]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
Daily bump.
[thirdparty/gcc.git] / gcc / doc / invoke.texi
CommitLineData
6441eb6d 1@c Copyright (C) 1988-2025 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
7137812c 11Copyright @copyright{} 1988-2025 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.
a0e64a04
PN
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}
d77de738
ML
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++.
ef458b3f 153* OpenMP and OpenACC Options:: Controlling multiprocessing and offloading.
d77de738
ML
154* Diagnostic Message Formatting Options:: Controlling how diagnostics should
155 be formatted.
156* Warning Options:: How picky should the compiler be?
157* Static Analyzer Options:: More expensive warnings.
158* Debugging Options:: Producing debuggable code.
159* Optimize Options:: How much optimization?
160* Instrumentation Options:: Enabling profiling and extra run-time error checking.
161* Preprocessor Options:: Controlling header files and macro definitions.
162 Also, getting dependency information for Make.
163* Assembler Options:: Passing options to the assembler.
164* Link Options:: Specifying libraries and so on.
165* Directory Options:: Where to find header files and libraries.
166 Where to find the compiler executable files.
167* Code Gen Options:: Specifying conventions for function calls, data layout
168 and register usage.
169* Developer Options:: Printing GCC configuration info, statistics, and
170 debugging dumps.
171* Submodel Options:: Target-specific options, such as compiling for a
172 specific processor variant.
173* Spec Files:: How to pass switches to sub-processes.
174* Environment Variables:: Env vars that affect GCC.
175* Precompiled Headers:: Compiling a header once, and using it many times.
176* C++ Modules:: Experimental C++20 module system.
177@end menu
178
179@c man begin OPTIONS
180
181@node Option Summary
182@section Option Summary
183
184Here is a summary of all the options, grouped by type. Explanations are
185in the following sections.
186
187@table @emph
188@item Overall Options
189@xref{Overall Options,,Options Controlling the Kind of Output}.
43b72ede
AA
190@gccoptlist{-c -S -E -o @var{file}
191-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf}
192-dumpdir @var{dumppfx} -x @var{language}
193-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version
194-pass-exit-codes -pipe -specs=@var{file} -wrapper
195@@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map
196-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}
d77de738
ML
197-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
198
199@item C Language Options
200@xref{C Dialect Options,,Options Controlling C Dialect}.
43b72ede
AA
201@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename}
202-fno-asm
203-fno-builtin -fno-builtin-@var{function} -fcond-mismatch
204-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted
205-flax-vector-conversions -fms-extensions
43b72ede
AA
206-fpermitted-flt-eval-methods=@var{standard}
207-fplan9-extensions -fsigned-bitfields -funsigned-bitfields
eb71695f 208-fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}]
17d8a3da 209-fsso-struct=@var{endianness}}
d77de738
ML
210
211@item C++ Language Options
212@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
43b72ede 213@gccoptlist{-fabi-version=@var{n} -fno-access-control
498933e5 214-faligned-new=@var{n} -fno-assume-sane-operators-new-delete
27778979 215-fchar8_t -fcheck-new
650e9156 216-fconcepts -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n}
43b72ede
AA
217-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n}
218-fno-elide-constructors
219-fno-enforce-eh-specs
220-fno-gnu-keywords
1f1c4322 221-fno-immediate-escalation
43b72ede
AA
222-fno-implicit-templates
223-fno-implicit-inline-templates
224-fno-implement-inlines
d9c3c3c8 225-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules
43b72ede
AA
226-fmodule-implicit-inline
227-fno-module-lazy
228-fmodule-mapper=@var{specification}
229-fmodule-version-ignore
230-fms-extensions
231-fnew-inheriting-ctors
232-fnew-ttp-matching
233-fno-nonansi-builtins -fnothrow-opt -fno-operator-names
ef10cb86 234-fno-optional-diags
650e9156 235-fno-pretty-templates -frange-for-ext-temps
43b72ede 236-fno-rtti -fsized-deallocation
498933e5 237-fstrong-eval-order@r{[}=@var{kind}@r{]}
43b72ede
AA
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
a2746e43 254-Wno-defaulted-function-deleted
43b72ede
AA
255-Wno-delete-incomplete
256-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare
257-Wdeprecated-copy -Wdeprecated-copy-dtor
258-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
b106f11d 259-Weffc++ -Wno-elaborated-enum-base
08edf85f 260-Wno-exceptions -Wextra-semi -Wno-global-module -Wno-inaccessible-base
43b72ede
AA
261-Wno-inherited-variadic-ctor -Wno-init-list-lifetime
262-Winvalid-constexpr -Winvalid-imported-macros
263-Wno-invalid-offsetof -Wno-literal-suffix
264-Wmismatched-new-delete -Wmismatched-tags
265-Wmultiple-inheritance -Wnamespaces -Wnarrowing
266-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
267-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
268-Wrange-loop-construct -Wredundant-move -Wredundant-tags
117782e0 269-Wreorder -Wregister -Wno-sfinae-incomplete
43b72ede
AA
270-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
271-Wno-non-template-friend -Wold-style-cast
272-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
273-Wsized-deallocation -Wsuggest-final-methods
596d1ed9 274-Wsuggest-final-types -Wsuggest-override -Wno-template-body
0c2ae384 275-Wno-template-id-cdtor -Wtemplate-names-tu-local
25bb8a40 276-Wno-terminate -Wno-vexing-parse -Wvirtual-inheritance
182d891e 277-Wno-virtual-move-assign -Wvolatile}
d77de738
ML
278
279@item Objective-C and Objective-C++ Language Options
280@xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
281Objective-C and Objective-C++ Dialects}.
43b72ede
AA
282@gccoptlist{-fconstant-string-class=@var{class-name}
283-fgnu-runtime -fnext-runtime
284-fno-nil-receivers
285-fobjc-abi-version=@var{n}
286-fobjc-call-cxx-cdtors
287-fobjc-direct-dispatch
288-fobjc-exceptions
289-fobjc-gc
290-fobjc-nilcheck
291-fobjc-std=objc1
292-fno-local-ivars
293-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
294-freplace-objc-classes
295-fzero-link
296-gen-decls
297-Wassign-intercept -Wno-property-assign-default
298-Wno-protocol -Wobjc-root-class -Wselector
299-Wstrict-selector-match
d77de738
ML
300-Wundeclared-selector}
301
ef458b3f
SL
302@item OpenMP and OpenACC Options
303@xref{OpenMP and OpenACC Options,,Options Controlling OpenMP and OpenACC}.
304@gccoptlist{-foffload=@var{arg} -foffload-options=@var{arg}
305-fopenacc -fopenacc-dim=@var{geom}
306-fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}}
307
d77de738
ML
308@item Diagnostic Message Formatting Options
309@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
43b72ede
AA
310@gccoptlist{-fmessage-length=@var{n}
311-fdiagnostics-plain-output
312-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
313-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
314-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
51ce3734 315-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{]}
0b73e938
DM
316-fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
317-fdiagnostics-set-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
3bd8241a 318-fno-diagnostics-json-formatting
43b72ede 319-fno-diagnostics-show-option -fno-diagnostics-show-caret
770657d0 320-fno-diagnostics-show-event-links
43b72ede
AA
321-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
322-fno-diagnostics-show-cwe
7d73c01c
DM
323-fno-diagnostics-show-rules
324-fno-diagnostics-show-highlight-colors
43b72ede
AA
325-fdiagnostics-minimum-margin-width=@var{width}
326-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
327-fdiagnostics-show-template-tree -fno-elide-type
328-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
329-fdiagnostics-show-path-depths
330-fno-show-column
331-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
332-fdiagnostics-column-origin=@var{origin}
4f01ae37
DM
333-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}
334-fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}}
d77de738
ML
335
336@item Warning Options
337@xref{Warning Options,,Options to Request or Suppress Warnings}.
43b72ede 338@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
ef10cb86 339-pedantic-errors -fpermissive
43b72ede
AA
340-w -Wextra -Wall -Wabi=@var{n}
341-Waddress -Wno-address-of-packed-member -Waggregate-return
e7dd72ae 342-Walloc-size -Walloc-size-larger-than=@var{byte-size} -Walloc-zero
99f9e901 343-Walloca -Walloca-larger-than=@var{byte-size} -Wauto-profile
43b72ede
AA
344-Wno-aggressive-loop-optimizations
345-Warith-conversion
346-Warray-bounds -Warray-bounds=@var{n} -Warray-compare
8fd992a3 347-Warray-parameter -Warray-parameter=@var{n}
43b72ede
AA
348-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
349-Wno-attribute-warning
350-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
351-Wbool-compare -Wbool-operation
352-Wno-builtin-declaration-mismatch
353-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
0cf68222 354-Wc11-c23-compat -Wc23-c2y-compat
43b72ede
AA
355-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
356-Wc++20-compat
357-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
358-Wno-c++20-extensions -Wno-c++23-extensions
e7dd72ae 359-Wcalloc-transposed-args
43b72ede
AA
360-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
361-Wchar-subscripts
362-Wclobbered -Wcomment
e1f45bea 363-Wcompare-distinct-pointer-types
43b72ede
AA
364-Wno-complain-wrong-lang
365-Wconversion -Wno-coverage-mismatch -Wno-cpp
366-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
367-Wdate-time
368-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
369-Wdisabled-optimization
370-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
371-Wno-div-by-zero -Wdouble-promotion
372-Wduplicated-branches -Wduplicated-cond
373-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
374-Wenum-int-mismatch
375-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
44e3f39a 376-Wflex-array-member-not-at-end
43b72ede
AA
377-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
378-Wno-format-contains-nul -Wno-format-extra-args
379-Wformat-nonliteral -Wformat-overflow=@var{n}
380-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
381-Wformat-y2k -Wframe-address
382-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
5943a2fa 383-Wheader-guard -Wno-if-not-aligned -Wno-ignored-attributes
24592abd 384-Wignored-qualifiers -Wno-incompatible-pointer-types -Whardened
43b72ede
AA
385-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
386-Wno-implicit-function-declaration -Wno-implicit-int
387-Winfinite-recursion
388-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
389-Wno-int-to-pointer-cast -Wno-invalid-memory-model
390-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
d4499a23
JJ
391-Wlarger-than=@var{byte-size} -Wleading-whitespace=@var{kind}
392-Wlogical-not-parentheses -Wlogical-op
43b72ede
AA
393-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
394-Wmemset-elt-size -Wmemset-transposed-args
395-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
396-Wmissing-field-initializers -Wmissing-format-attribute
634215cd
JJ
397-Wmissing-include-dirs -Wmissing-noreturn -Wmusttail-local-addr
398-Wmaybe-musttail-local-addr -Wno-missing-profile
43b72ede
AA
399-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
400-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
401-Wnull-dereference -Wno-odr
402-Wopenacc-parallelism
449b6b81 403-Wopenmp -Wopenmp-simd
43b72ede
AA
404-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
405-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
406-Wparentheses -Wno-pedantic-ms-format
407-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
821d5610 408-Wno-pragmas -Wno-pragma-once-outside-header -Wno-prio-ctor-dtor
027491d7
SL
409-Wno-psabi
410-Wredundant-decls -Wrestrict
411-Wno-return-local-addr -Wreturn-type
43b72ede
AA
412-Wno-scalar-storage-order -Wsequence-point
413-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
414-Wno-shadow-ivar
415-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
416-Wno-shift-overflow -Wshift-overflow=@var{n}
417-Wsign-compare -Wsign-conversion
418-Wno-sizeof-array-argument
419-Wsizeof-array-div
420-Wsizeof-pointer-div -Wsizeof-pointer-memaccess
421-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
422-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
423-Wstring-compare
424-Wno-stringop-overflow -Wno-stringop-overread
eb71695f 425-Wno-stringop-truncation -Wstrict-flex-arrays
c768cd07 426-Wsuggest-attribute=@var{attribute-name}
43b72ede
AA
427-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
428-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
ac615e10
JJ
429-Wsystem-headers -Wtautological-compare -Wtrailing-whitespace
430-Wtrailing-whitespace=@var{kind} -Wtrampolines -Wtrigraphs
9a5e8f9d 431-Wtrivial-auto-var-init -Wno-tsan -Wtype-limits -Wundef
43b72ede 432-Wuninitialized -Wunknown-pragmas
44c9403e
AC
433-Wunsuffixed-float-constants
434-Wunterminated-string-initialization
435-Wunused
43b72ede
AA
436-Wunused-but-set-parameter -Wunused-but-set-variable
437-Wunused-const-variable -Wunused-const-variable=@var{n}
438-Wunused-function -Wunused-label -Wunused-local-typedefs
439-Wunused-macros
440-Wunused-parameter -Wno-unused-result
441-Wunused-value -Wunused-variable
25bb8a40 442-Wuse-after-free -Wuse-after-free=@var{n} -Wuseless-cast
43b72ede
AA
443-Wno-varargs -Wvariadic-macros
444-Wvector-operation-performance
445-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
446-Wvolatile-register-var -Wwrite-strings
9a5e8f9d 447-Wno-xor-used-as-pow
182d891e 448-Wzero-as-null-pointer-constant
d77de738
ML
449-Wzero-length-bounds}
450
451@item Static Analyzer Options
452@gccoptlist{
43b72ede
AA
453-fanalyzer
454-fanalyzer-call-summaries
455-fanalyzer-checker=@var{name}
456-fno-analyzer-feasibility
457-fanalyzer-fine-grained
ce8cdf5b 458-fanalyzer-show-events-in-system-headers
43b72ede
AA
459-fno-analyzer-state-merge
460-fno-analyzer-state-purge
461-fno-analyzer-suppress-followups
462-fanalyzer-transitivity
463-fno-analyzer-undo-inlining
464-fanalyzer-verbose-edges
465-fanalyzer-verbose-state-changes
466-fanalyzer-verbosity=@var{level}
467-fdump-analyzer
468-fdump-analyzer-callgraph
469-fdump-analyzer-exploded-graph
470-fdump-analyzer-exploded-nodes
471-fdump-analyzer-exploded-nodes-2
472-fdump-analyzer-exploded-nodes-3
473-fdump-analyzer-exploded-paths
474-fdump-analyzer-feasibility
841008d3 475-fdump-analyzer-infinite-loop
43b72ede
AA
476-fdump-analyzer-json
477-fdump-analyzer-state-purge
478-fdump-analyzer-stderr
479-fdump-analyzer-supergraph
480-fdump-analyzer-untracked
481-Wno-analyzer-double-fclose
482-Wno-analyzer-double-free
483-Wno-analyzer-exposure-through-output-file
484-Wno-analyzer-exposure-through-uninit-copy
485-Wno-analyzer-fd-access-mode-mismatch
486-Wno-analyzer-fd-double-close
487-Wno-analyzer-fd-leak
488-Wno-analyzer-fd-phase-mismatch
489-Wno-analyzer-fd-type-mismatch
490-Wno-analyzer-fd-use-after-close
491-Wno-analyzer-fd-use-without-check
492-Wno-analyzer-file-leak
493-Wno-analyzer-free-of-non-heap
494-Wno-analyzer-imprecise-fp-arithmetic
841008d3 495-Wno-analyzer-infinite-loop
43b72ede
AA
496-Wno-analyzer-infinite-recursion
497-Wno-analyzer-jump-through-null
498-Wno-analyzer-malloc-leak
499-Wno-analyzer-mismatching-deallocation
500-Wno-analyzer-null-argument
501-Wno-analyzer-null-dereference
502-Wno-analyzer-out-of-bounds
034d99e8 503-Wno-analyzer-overlapping-buffers
43b72ede
AA
504-Wno-analyzer-possible-null-argument
505-Wno-analyzer-possible-null-dereference
506-Wno-analyzer-putenv-of-auto-var
507-Wno-analyzer-shift-count-negative
508-Wno-analyzer-shift-count-overflow
509-Wno-analyzer-stale-setjmp-buffer
510-Wno-analyzer-tainted-allocation-size
511-Wno-analyzer-tainted-assertion
512-Wno-analyzer-tainted-array-index
513-Wno-analyzer-tainted-divisor
514-Wno-analyzer-tainted-offset
515-Wno-analyzer-tainted-size
7a39e0ca 516-Wno-analyzer-throw-of-unexpected-type
08b7462d 517-Wanalyzer-symbol-too-complex
43b72ede 518-Wanalyzer-too-complex
13dcaf1b 519-Wno-analyzer-undefined-behavior-ptrdiff
f65f63c4 520-Wno-analyzer-undefined-behavior-strtok
43b72ede
AA
521-Wno-analyzer-unsafe-call-within-signal-handler
522-Wno-analyzer-use-after-free
523-Wno-analyzer-use-of-pointer-in-stale-stack-frame
524-Wno-analyzer-use-of-uninitialized-value
525-Wno-analyzer-va-arg-type-mismatch
526-Wno-analyzer-va-list-exhausted
527-Wno-analyzer-va-list-leak
528-Wno-analyzer-va-list-use-after-va-end
529-Wno-analyzer-write-to-const
530-Wno-analyzer-write-to-string-literal
d77de738
ML
531}
532
533@item C and Objective-C-only Warning Options
631cd92b
FW
534@gccoptlist{-Wbad-function-cast -Wdeprecated-non-prototype -Wfree-labels
535-Wmissing-declarations -Wmissing-parameter-name -Wmissing-parameter-type
8833389e
FW
536-Wdeclaration-missing-parameter-type -Wmissing-prototypes
537-Wmissing-variable-declarations -Wnested-externs -Wold-style-declaration
538-Wold-style-definition -Wstrict-prototypes -Wtraditional
539-Wtraditional-conversion -Wdeclaration-after-statement -Wpointer-sign}
d77de738
ML
540
541@item Debugging Options
542@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
543@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
544-gbtf -gctf -gctf@var{level}
b8977d92 545-gprune-btf -gno-prune-btf
43b72ede
AA
546-ggdb -grecord-gcc-switches -gno-record-gcc-switches
547-gstrict-dwarf -gno-strict-dwarf
548-gas-loc-support -gno-as-loc-support
549-gas-locview-support -gno-as-locview-support
3eeb4801 550-gcodeview
43b72ede
AA
551-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
552-gstatement-frontiers -gno-statement-frontiers
553-gvariable-location-views -gno-variable-location-views
554-ginternal-reset-location-views -gno-internal-reset-location-views
555-ginline-points -gno-inline-points
556-gvms -gz@r{[}=@var{type}@r{]}
557-gsplit-dwarf -gdescribe-dies -gno-describe-dies
558-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
559-fno-eliminate-unused-debug-types
560-femit-struct-debug-baseonly -femit-struct-debug-reduced
561-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
562-fno-eliminate-unused-debug-symbols -femit-class-debug-always
563-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
564-fvar-tracking -fvar-tracking-assignments}
565
566@item Optimization Options
567@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
568@gccoptlist{-faggressive-loop-optimizations
569-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
570-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
571-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
572-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
0f5a9a00 573-fmin-function-alignment=[@var{n}]
43b72ede
AA
574-fno-allocation-dce -fallow-store-data-races
575-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
aaf55e09 576-fauto-profile-inlining -fauto-inc-dec -fbranch-probabilities
43b72ede
AA
577-fcaller-saves
578-fcombine-stack-adjustments -fconserve-stack
04c9cf5c 579-ffold-mem-offsets
43b72ede
AA
580-fcompare-elim -fcprop-registers -fcrossjumping
581-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
e543eaa6 582-fcx-limited-range -fcx-method
43b72ede
AA
583-fdata-sections -fdce -fdelayed-branch
584-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
585-fdevirtualize-at-ltrans -fdse
586-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
587-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
588-ffinite-loops
589-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
590-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
591-fgcse-sm -fhoist-adjacent-loads -fif-conversion
592-fif-conversion2 -findirect-inlining
1ff6d9f7 593-finline-stringops[=@var{fn}]
43b72ede
AA
594-finline-functions -finline-functions-called-once -finline-limit=@var{n}
595-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
596-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
6d9fdf4b 597-fipa-reference -fipa-reference-addressable -fipa-reorder-for-locality
43b72ede 598-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
7828dc07 599-flate-combine-instructions -flifetime-dse -flive-patching=@var{level}
43b72ede
AA
600-fira-region=@var{region} -fira-hoist-pressure
601-fira-loop-pressure -fno-ira-share-save-slots
602-fno-ira-share-spill-slots
603-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
604-fivopts -fkeep-inline-functions -fkeep-static-functions
605-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
606-floop-block -floop-interchange -floop-strip-mine
607-floop-unroll-and-jam -floop-nest-optimize
608-floop-parallelize-all -flra-remat -flto -flto-compression-level
63e7478d
MJ
609-flto-partition=@var{alg} -flto-incremental=@var{path}
610-flto-incremental-cache-size=@var{n} -fmalloc-dce -fmerge-all-constants
43b72ede
AA
611-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
612-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
613-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
614-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
615-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
616-fno-sched-spec -fno-signed-zeros
617-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
062ad209 618-fomit-frame-pointer -foptimize-crc -foptimize-sibling-calls
43b72ede
AA
619-fpartial-inlining -fpeel-loops -fpredictive-commoning
620-fprefetch-loop-arrays
621-fprofile-correction
622-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
623-fprofile-values -fprofile-reorder-functions
624-freciprocal-math -free -frename-registers -freorder-blocks
625-freorder-blocks-algorithm=@var{algorithm}
626-freorder-blocks-and-partition -freorder-functions
627-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
628-frounding-math -fsave-optimization-record
629-fsched2-use-superblocks -fsched-pressure
630-fsched-spec-load -fsched-spec-load-dangerous
631-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
632-fsched-group-heuristic -fsched-critical-path-heuristic
633-fsched-spec-insn-heuristic -fsched-rank-heuristic
634-fsched-last-insn-heuristic -fsched-dep-count-heuristic
635-fschedule-fusion
636-fschedule-insns -fschedule-insns2 -fsection-anchors
637-fselective-scheduling -fselective-scheduling2
638-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
639-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
640-fsignaling-nans
641-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
642-fsplit-paths
643-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
644-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
645-fthread-jumps -ftracer -ftree-bit-ccp
f6b0dc1b
SL
646-ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-coalesce-vars
647-ftree-copy-prop -ftree-cselim -ftree-dce -ftree-dominator-opts
43b72ede
AA
648-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
649-ftree-loop-if-convert -ftree-loop-im
650-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
651-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
652-ftree-loop-vectorize
653-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
654-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
655-ftree-switch-conversion -ftree-tail-merge
656-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
657-funconstrained-commons -funit-at-a-time -funroll-all-loops
658-funroll-loops -funsafe-math-optimizations -funswitch-loops
659-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
660-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
661--param @var{name}=@var{value}
662-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
663
664@item Program Instrumentation Options
665@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede 666@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
08a52331 667-fcondition-coverage
8ed2d5d2 668-fpath-coverage
43b72ede
AA
669-fprofile-abs-path
670-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
671-fprofile-info-section -fprofile-info-section=@var{name}
672-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
673-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
674-fprofile-exclude-files=@var{regex}
675-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
676-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
677-fsanitize-trap -fsanitize-trap=@var{style}
678-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
3026daa8 679-fsanitize-undefined-trap-on-error -fbounds-check -fcf-protection
43b72ede 680-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
24592abd 681-fharden-compares -fharden-conditional-branches -fhardened
551935d1
AO
682-fharden-control-flow-redundancy -fhardcfr-skip-leaf
683-fhardcfr-check-exceptions -fhardcfr-check-returning-calls
684-fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
43b72ede
AA
685-fstack-protector -fstack-protector-all -fstack-protector-strong
686-fstack-protector-explicit -fstack-check
687-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
688-fno-stack-limit -fsplit-stack
f0a90c7d
AO
689-fstrub=disable -fstrub=strict -fstrub=relaxed
690-fstrub=all -fstrub=at-calls -fstrub=internal
43b72ede
AA
691-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
692-fvtv-counts -fvtv-debug
693-finstrument-functions -finstrument-functions-once
694-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
695-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
b42dd137
M
696-fprofile-prefix-map=@var{old}=@var{new}
697-fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}}
d77de738
ML
698
699@item Preprocessor Options
700@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
701@gccoptlist{-A@var{question}=@var{answer}
702-A-@var{question}@r{[}=@var{answer}@r{]}
703-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
704-dD -dI -dM -dN -dU
705-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
706-fexec-charset=@var{charset} -fextended-identifiers
d9cdc500 707-finput-charset=@var{charset}
43b72ede
AA
708-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
709-fno-canonical-system-headers -fpch-deps -fpch-preprocess
710-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
711-fwide-exec-charset=@var{charset} -fworking-directory
712-H -imacros @var{file} -include @var{file}
713-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
714-no-integrated-cpp -P -pthread -remap
715-traditional -traditional-cpp -trigraphs
716-U@var{macro} -undef
d77de738
ML
717-Wp,@var{option} -Xpreprocessor @var{option}}
718
719@item Assembler Options
720@xref{Assembler Options,,Passing Options to the Assembler}.
721@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
722
723@item Linker Options
724@xref{Link Options,,Options for Linking}.
43b72ede
AA
725@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
726-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
727-e @var{entry} --entry=@var{entry}
728-pie -pthread -r -rdynamic
729-s -static -static-pie -static-libgcc -static-libstdc++
730-static-libasan -static-libtsan -static-liblsan -static-libubsan
731-shared -shared-libgcc -symbolic
732-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
733-u @var{symbol} -z @var{keyword}}
734
735@item Directory Options
736@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
737@gccoptlist{-B@var{prefix} -I@var{dir} -I-
738-idirafter @var{dir}
739-imacros @var{file} -imultilib @var{dir}
740-iplugindir=@var{dir} -iprefix @var{file}
741-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
742-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
eba6d2aa 743--embed-dir=@var{dir}
43b72ede 744-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
745-nostdinc -nostdinc++ --sysroot=@var{dir}}
746
747@item Code Generation Options
748@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
749@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
750-ffixed-@var{reg} -fexceptions
751-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
752-fasynchronous-unwind-tables
753-fno-gnu-unique
754-finhibit-size-directive -fcommon -fno-ident
755-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
756-fno-jump-tables -fno-bit-tests
757-frecord-gcc-switches
758-freg-struct-return -fshort-enums -fshort-wchar
759-fverbose-asm -fpack-struct[=@var{n}]
760-fleading-underscore -ftls-model=@var{model}
761-fstack-reuse=@var{reuse_level}
28d8c680
AB
762-ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
763-ftrapv -fwrapv
43b72ede 764-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
0547dbb7
JJ
765-fstrict-volatile-bitfields -fsync-libcalls
766-fzero-init-padding-bits=@var{value}}
d77de738
ML
767
768@item Developer Options
769@xref{Developer Options,,GCC Developer Options}.
43b72ede 770@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 771-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
772-fchecking -fchecking=@var{n}
773-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
774-fdisable-ipa-@var{pass_name}
775-fdisable-rtl-@var{pass_name}
776-fdisable-rtl-@var{pass-name}=@var{range-list}
777-fdisable-tree-@var{pass_name}
778-fdisable-tree-@var{pass-name}=@var{range-list}
779-fdump-debug -fdump-earlydebug
780-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
781-fdump-final-insns@r{[}=@var{file}@r{]}
782-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
783-fdump-lang-all
784-fdump-lang-@var{switch}
785-fdump-lang-@var{switch}-@var{options}
786-fdump-lang-@var{switch}-@var{options}=@var{filename}
787-fdump-passes
788-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
789-fdump-statistics
790-fdump-tree-all
791-fdump-tree-@var{switch}
792-fdump-tree-@var{switch}-@var{options}
793-fdump-tree-@var{switch}-@var{options}=@var{filename}
794-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
795-fenable-@var{kind}-@var{pass}
796-fenable-@var{kind}-@var{pass}=@var{range-list}
797-fira-verbose=@var{n}
798-flto-report -flto-report-wpa -fmem-report-wpa
799-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
800-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
801-fmultiflags -fprofile-report
802-frandom-seed=@var{string} -fsched-verbose=@var{n}
803-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
804-fstats -fstack-usage -ftime-report -ftime-report-details
805-fvar-tracking-assignments-toggle -gtoggle
806-print-file-name=@var{library} -print-libgcc-file-name
807-print-multi-directory -print-multi-lib -print-multi-os-directory
808-print-prog-name=@var{program} -print-search-dirs -Q
809-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
810-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
811
812@item Machine-Dependent Options
813@xref{Submodel Options,,Machine-Dependent Options}.
814@c This list is ordered alphanumerically by subsection name.
815@c Try and put the significant identifier (CPU or system) first,
816@c so users have a clue at guessing where the ones they want will be.
817
26226ace 818@emph{AArch64 Options} (@ref{AArch64 Options})
43b72ede
AA
819@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
820-mgeneral-regs-only
821-mcmodel=tiny -mcmodel=small -mcmodel=large
822-mstrict-align -mno-strict-align
823-momit-leaf-frame-pointer
824-mtls-dialect=desc -mtls-dialect=traditional
825-mtls-size=@var{size}
826-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
827-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
828-mpc-relative-literal-loads
829-msign-return-address=@var{scope}
d77de738 830-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
56ded80b 831+@var{b-key}]|@var{bti}|@var{gcs}
43b72ede
AA
832-mharden-sls=@var{opts}
833-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
834-moverride=@var{string} -mverbose-cost-dump
835-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
836-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
e5798872
AR
837-moutline-atomics -mearly-ldp-fusion -mlate-ldp-fusion
838-Wexperimental-fmv-target}
d77de738 839
26226ace 840@emph{Adapteva Epiphany Options} (@ref{Adapteva Epiphany Options})
43b72ede
AA
841@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
842-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
843-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
844-mround-nearest -mlong-calls -mshort-calls -msmall16
845-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
846-msplit-vecmove-early -m1reg-@var{reg}}
847
26226ace 848@emph{AMD GCN Options} (@ref{AMD GCN Options})
d77de738
ML
849@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
850
26226ace 851@emph{ARC Options} (@ref{ARC Options})
43b72ede
AA
852@gccoptlist{-mbarrel-shifter -mjli-always
853-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
854-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
855-mea -mno-mpy -mmul32x16 -mmul64 -matomic
856-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
857-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
858-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
859-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
860-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
861-mvolatile-cache -mtp-regno=@var{regno}
862-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
863-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
864-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
865-mlra-priority-compact -mlra-priority-noncompact -mmillicode
866-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
867-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
868-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
869-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
870
26226ace 871@emph{ARM Options} (@ref{ARM Options})
43b72ede
AA
872@gccoptlist{-mapcs-frame -mno-apcs-frame
873-mabi=@var{name}
874-mapcs-stack-check -mno-apcs-stack-check
875-mapcs-reentrant -mno-apcs-reentrant
876-mgeneral-regs-only
877-msched-prolog -mno-sched-prolog
878-mlittle-endian -mbig-endian
879-mbe8 -mbe32
880-mfloat-abi=@var{name}
d77de738 881-mfp16-format=@var{name}
43b72ede
AA
882-mthumb-interwork -mno-thumb-interwork
883-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
884-mtune=@var{name} -mprint-tune-info
885-mstructure-size-boundary=@var{n}
886-mabort-on-noreturn
887-mlong-calls -mno-long-calls
888-msingle-pic-base -mno-single-pic-base
889-mpic-register=@var{reg}
890-mnop-fun-dllimport
891-mpoke-function-name
892-mthumb -marm -mflip-thumb
893-mtpcs-frame -mtpcs-leaf-frame
894-mcaller-super-interworking -mcallee-super-interworking
895-mtp=@var{name} -mtls-dialect=@var{dialect}
896-mword-relocations
897-mfix-cortex-m3-ldrd
898-mfix-cortex-a57-aes-1742098
899-mfix-cortex-a72-aes-1655431
900-munaligned-access
901-mneon-for-64bits
902-mslow-flash-data
903-masm-syntax-unified
904-mrestrict-it
905-mverbose-cost-dump
906-mpure-code
907-mcmse
908-mfix-cmse-cve-2021-35465
909-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
910-mfdpic
14fab5fb
AC
911-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
912[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738 913
26226ace 914@emph{AVR Options} (@ref{AVR Options})
cb27337f 915@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args -mcvt
c3db52bb 916-mbranch-cost=@var{cost} -mfuse-add=@var{level} -mfuse-move=@var{level}
42503cc2 917-mcall-prologues -mgas-isr-prologues -mint8 -mflmap
0fa06d7f 918-mdouble=@var{bits} -mlong-double=@var{bits} -mno-call-main
bf6f77ed 919-mn_flash=@var{size} -mfract-convert-truncate -mno-interrupts
43b72ede 920-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
94355acc
GJL
921-mrodata-in-ram -msplit-bit-shift -msplit-ldst -mshort-calls
922-mskip-bug -muse-nonzero-bits -nodevicelib -nodevicespecs
d77de738
ML
923-Waddr-space-convert -Wmisspelled-isr}
924
26226ace 925@emph{Blackfin Options} (@ref{Blackfin Options})
43b72ede
AA
926@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
927-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
928-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
929-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
930-mno-id-shared-library -mshared-library-id=@var{n}
931-mleaf-id-shared-library -mno-leaf-id-shared-library
932-msep-data -mno-sep-data -mlong-calls -mno-long-calls
933-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
934-micplb}
935
26226ace 936@emph{C6X Options} (@ref{C6X Options})
43b72ede 937@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
938-msim -msdata=@var{sdata-type}}
939
26226ace 940@emph{CRIS Options} (@ref{CRIS Options})
d77de738 941@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
942-mtune=@var{cpu} -mmax-stack-frame=@var{n}
943-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
944-mstack-align -mdata-align -mconst-align
945-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
946-melf -maout -sim -sim2
d77de738
ML
947-mmul-bug-workaround -mno-mul-bug-workaround}
948
26226ace 949@emph{C-SKY Options} (@ref{C-SKY Options})
43b72ede
AA
950@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
951-mbig-endian -EB -mlittle-endian -EL
952-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
953-mfloat-abi=@var{name}
954-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
955-mdsp -medsp -mvdsp
956-mdiv -msmart -mhigh-registers -manchor
957-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
958-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
959
26226ace
SL
960@emph{Cygwin and MinGW Options} (@ref{Cygwin and MinGW Options})
961@gccoptlist{-mconsole -mcrtdll=@var{library} -mdll
962-mnop-fun-dllimport -mthread
963-municode -mwin32 -mwindows -fno-set-stack-executable}
964
965@emph{Darwin Options} (@ref{Darwin Options})
43b72ede
AA
966@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
967-arch_only -bind_at_load -bundle -bundle_loader
968-client_name -compatibility_version -current_version
969-dead_strip
970-dependency-file -dylib_file -dylinker_install_name
971-dynamic -dynamiclib -exported_symbols_list
972-filelist -flat_namespace -force_cpusubtype_ALL
973-force_flat_namespace -headerpad_max_install_names
974-iframework
975-image_base -init -install_name -keep_private_externs
976-multi_module -multiply_defined -multiply_defined_unused
47b634a3 977-noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
43b72ede
AA
978-nofixprebinding -nomultidefs -noprebind -noseglinkedit
979-pagezero_size -prebind -prebind_all_twolevel_modules
980-private_bundle -read_only_relocs -sectalign
981-sectobjectsymbols -whyload -seg1addr
982-sectcreate -sectobjectsymbols -sectorder
983-segaddr -segs_read_only_addr -segs_read_write_addr
984-seg_addr_table -seg_addr_table_filename -seglinkedit
985-segprot -segs_read_only_addr -segs_read_write_addr
986-single_module -static -sub_library -sub_umbrella
987-twolevel_namespace -umbrella -undefined
988-unexported_symbols_list -weak_reference_mismatches
989-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
990-mkernel -mone-byte-bool}
991
26226ace 992@emph{DEC Alpha Options} (@ref{DEC Alpha Options})
43b72ede
AA
993@gccoptlist{-mno-fp-regs -msoft-float
994-mieee -mieee-with-inexact -mieee-conformant
995-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
996-mtrap-precision=@var{mode} -mbuild-constants
997-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
998-mbwx -mmax -mfix -mcix
1b85c548 999-msafe-bwa -msafe-partial
43b72ede
AA
1000-mfloat-vax -mfloat-ieee
1001-mexplicit-relocs -msmall-data -mlarge-data
1002-msmall-text -mlarge-text
d77de738
ML
1003-mmemory-latency=@var{time}}
1004
26226ace 1005@emph{eBPF Options} (@ref{eBPF Options})
9cbf4286 1006@gccoptlist{-mbig-endian -mlittle-endian
77d0f9ec 1007-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
14dab1a1 1008-mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
0e850eff 1009-masm=@var{dialect} -minline-memops-threshold=@var{bytes}}
d77de738 1010
26226ace 1011@emph{FR30 Options} (@ref{FR30 Options})
d77de738
ML
1012@gccoptlist{-msmall-model -mno-lsim}
1013
26226ace 1014@emph{FT32 Options} (@ref{FT32 Options})
d77de738
ML
1015@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
1016
26226ace 1017@emph{FRV Options} (@ref{FRV Options})
43b72ede
AA
1018@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
1019-mhard-float -msoft-float
1020-malloc-cc -mfixed-cc -mdword -mno-dword
1021-mdouble -mno-double
1022-mmedia -mno-media -mmuladd -mno-muladd
1023-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
1024-mlinked-fp -mlong-calls -malign-labels
1025-mlibrary-pic -macc-4 -macc-8
1026-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
1027-moptimize-membar -mno-optimize-membar
1028-mscc -mno-scc -mcond-exec -mno-cond-exec
1029-mvliw-branch -mno-vliw-branch
1030-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
1031-mno-nested-cond-exec -mtomcat-stats
1032-mTLS -mtls
d77de738
ML
1033-mcpu=@var{cpu}}
1034
26226ace 1035@emph{GNU/Linux Options} (@ref{GNU/Linux Options})
43b72ede 1036@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
1037-tno-android-cc -tno-android-ld}
1038
26226ace 1039@emph{H8/300 Options} (@ref{H8/300 Options})
d77de738
ML
1040@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
1041
26226ace 1042@emph{HPPA Options} (@ref{HPPA Options})
43b72ede
AA
1043@gccoptlist{-march=@var{architecture-type}
1044-matomic-libcalls -mbig-switch
1045-mcaller-copies -mdisable-fpregs -mdisable-indexing
1046-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
1047-mfixed-range=@var{register-range}
1048-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1049-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1050-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1051-mno-jump-in-delay -mno-long-load-store
1052-mno-portable-runtime -mno-soft-float
1053-mno-space-regs -msoft-float -mpa-risc-1-0
1054-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1055-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
1056-munix=@var{unix-std} -nolibdld -static -threads}
1057
26226ace 1058@emph{IA-64 Options} (@ref{IA-64 Options})
43b72ede
AA
1059@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1060-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1061-mconstant-gp -mauto-pic -mfused-madd
1062-minline-float-divide-min-latency
1063-minline-float-divide-max-throughput
1064-mno-inline-float-divide
1065-minline-int-divide-min-latency
1066-minline-int-divide-max-throughput
1067-mno-inline-int-divide
1068-minline-sqrt-min-latency -minline-sqrt-max-throughput
1069-mno-inline-sqrt
1070-mdwarf2-asm -mearly-stop-bits
1071-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1072-mtune=@var{cpu-type} -milp32 -mlp64
1073-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1074-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1075-msched-spec-ldc -msched-spec-control-ldc
1076-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1077-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1078-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1079-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1080
26226ace 1081@emph{LM32 Options} (@ref{LM32 Options})
43b72ede 1082@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1083-msign-extend-enabled -muser-enabled}
1084
26226ace 1085@emph{LoongArch Options} (@ref{LoongArch Options})
b4ebdd15 1086@gccoptlist{-march=@var{arch-type} -mtune=@var{tune-type} -mabi=@var{base-abi-type}
bb4a8198
YY
1087-mfpu=@var{fpu-type} -msimd=@var{simd-type}
1088-msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
7c50f954
LC
1089-mbranch-cost=@var{n} -maddr-reg-reg-cost=@var{n} -mcheck-zero-division
1090-mno-check-zero-division
43b72ede
AA
1091-mcond-move-int -mno-cond-move-int
1092-mcond-move-float -mno-cond-move-float
92864116 1093-memcpy -mno-memcpy -mstrict-align -mno-strict-align -G @var{num}
43b72ede 1094-mmax-inline-memcpy-size=@var{n}
e1b1cba1 1095-mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
43b72ede 1096-mdirect-extern-access -mno-direct-extern-access
7f424c31
LC
1097-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as
1098-mrecip -mrecip=@var{opt} -mfrecipe -mno-frecipe -mdiv32 -mno-div32
b253b469 1099-mlam-bh -mno-lam-bh -mlamcas -mno-lamcas -mld-seq-sa -mno-ld-seq-sa
0ee028f5 1100-mtls-dialect=@var{opt} -mannotate-tablejump -mno-annotate-tablejump}
d77de738 1101
26226ace
SL
1102@emph{M32C Options} (@ref{M32C Options})
1103@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1104
1105@emph{M32R/D Options} (@ref{M32R/D Options})
43b72ede
AA
1106@gccoptlist{-m32r2 -m32rx -m32r
1107-mdebug
1108-malign-loops -mno-align-loops
1109-missue-rate=@var{number}
1110-mbranch-cost=@var{number}
1111-mmodel=@var{code-size-model-type}
1112-msdata=@var{sdata-type}
1113-mno-flush-func -mflush-func=@var{name}
1114-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1115-G @var{num}}
1116
26226ace 1117@emph{M680x0 Options} (@ref{M680x0 Options})
43b72ede
AA
1118@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1119-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1120-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1121-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1122-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1123-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1124-malign-int -mstrict-align -msep-data -mno-sep-data
1125-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1126-mxgot -mno-xgot -mlong-jump-table-offsets}
1127
26226ace 1128@emph{MCore Options} (@ref{MCore Options})
43b72ede
AA
1129@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1130-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1131-m4byte-functions -mno-4byte-functions -mcallgraph-data
1132-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1133-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1134
26226ace 1135@emph{MicroBlaze Options} (@ref{MicroBlaze Options})
43b72ede
AA
1136@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1137-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1138-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1139-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1140-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1141-mpic-data-is-text-relative}
1142
26226ace 1143@emph{MIPS Options} (@ref{MIPS Options})
43b72ede
AA
1144@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1145-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1146-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1147-mips16 -mno-mips16 -mflip-mips16
1148-minterlink-compressed -mno-interlink-compressed
1149-minterlink-mips16 -mno-interlink-mips16
1150-mabi=@var{abi} -mabicalls -mno-abicalls
1151-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1152-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1153-mno-float -msingle-float -mdouble-float
1154-modd-spreg -mno-odd-spreg
1155-mabs=@var{mode} -mnan=@var{encoding}
1156-mdsp -mno-dsp -mdspr2 -mno-dspr2
1157-mmcu -mmno-mcu
1158-meva -mno-eva
1159-mvirt -mno-virt
1160-mxpa -mno-xpa
1161-mcrc -mno-crc
1162-mginv -mno-ginv
1163-mmicromips -mno-micromips
1164-mmsa -mno-msa
1165-mloongson-mmi -mno-loongson-mmi
1166-mloongson-ext -mno-loongson-ext
1167-mloongson-ext2 -mno-loongson-ext2
1168-mfpu=@var{fpu-type}
1169-msmartmips -mno-smartmips
1170-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1171-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1172-mlong64 -mlong32 -msym32 -mno-sym32
1173-G@var{num} -mlocal-sdata -mno-local-sdata
1174-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1175-membedded-data -mno-embedded-data
1176-muninit-const-in-rodata -mno-uninit-const-in-rodata
1177-mcode-readable=@var{setting}
1178-msplit-addresses -mno-split-addresses
1179-mexplicit-relocs -mno-explicit-relocs
58af788d 1180-mexplicit-relocs=@var{release}
43b72ede
AA
1181-mcheck-zero-division -mno-check-zero-division
1182-mdivide-traps -mdivide-breaks
1183-mload-store-pairs -mno-load-store-pairs
acc38ff5
YS
1184-mstrict-align -mno-strict-align
1185-mno-unaligned-access -munaligned-access
43b72ede
AA
1186-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1187-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1188-mfix-24k -mno-fix-24k
1189-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1190-mfix-r5900 -mno-fix-r5900
1191-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1192-mfix-vr4120 -mno-fix-vr4120
1193-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1194-mflush-func=@var{func} -mno-flush-func
1195-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1196-mcompact-branches=@var{policy}
1197-mfp-exceptions -mno-fp-exceptions
1198-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1199-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1200-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1201-mframe-header-opt -mno-frame-header-opt}
1202
26226ace 1203@emph{MMIX Options} (@ref{MMIX Options})
43b72ede
AA
1204@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1205-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1206-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1207-mno-base-addresses -msingle-exit -mno-single-exit}
1208
26226ace 1209@emph{MN10300 Options} (@ref{MN10300 Options})
43b72ede
AA
1210@gccoptlist{-mmult-bug -mno-mult-bug
1211-mno-am33 -mam33 -mam33-2 -mam34
1212-mtune=@var{cpu-type}
1213-mreturn-pointer-on-d0
d77de738
ML
1214-mno-crt0 -mrelax -mliw -msetlb}
1215
26226ace 1216@emph{Moxie Options} (@ref{Moxie Options})
d77de738
ML
1217@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1218
26226ace 1219@emph{MSP430 Options} (@ref{MSP430 Options})
43b72ede
AA
1220@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1221-mwarn-mcu
1222-mcode-region= -mdata-region=
1223-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1224-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1225
26226ace 1226@emph{NDS32 Options} (@ref{NDS32 Options})
43b72ede
AA
1227@gccoptlist{-mbig-endian -mlittle-endian
1228-mreduced-regs -mfull-regs
1229-mcmov -mno-cmov
1230-mext-perf -mno-ext-perf
1231-mext-perf2 -mno-ext-perf2
1232-mext-string -mno-ext-string
1233-mv3push -mno-v3push
1234-m16bit -mno-16bit
1235-misr-vector-size=@var{num}
1236-mcache-block-size=@var{num}
1237-march=@var{arch}
1238-mcmodel=@var{code-model}
d77de738
ML
1239-mctor-dtor -mrelax}
1240
26226ace 1241@emph{Nvidia PTX Options} (@ref{Nvidia PTX Options})
d77de738
ML
1242@gccoptlist{-m64 -mmainkernel -moptimize}
1243
26226ace 1244@emph{OpenRISC Options} (@ref{OpenRISC Options})
43b72ede
AA
1245@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1246-msoft-mul -msoft-div
1247-msoft-float -mhard-float -mdouble-float -munordered-float
1248-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1249-mcmodel=@var{code-model}}
1250
26226ace 1251@emph{PDP-11 Options} (@ref{PDP-11 Options})
43b72ede
AA
1252@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1253-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1254-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1255
d77de738
ML
1256@emph{PowerPC Options}
1257See RS/6000 and PowerPC Options.
1258
26226ace 1259@emph{PRU Options} (@ref{PRU Options})
43b72ede 1260@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1261-mabi=@var{variant}}
d77de738 1262
26226ace 1263@emph{RISC-V Options} (@ref{RISC-V Options})
43b72ede
AA
1264@gccoptlist{-mbranch-cost=@var{N-instruction}
1265-mplt -mno-plt
1266-mabi=@var{ABI-string}
1267-mfdiv -mno-fdiv
a6114c2a 1268-mfence-tso -mno-fence-tso
43b72ede
AA
1269-mdiv -mno-div
1270-misa-spec=@var{ISA-spec-string}
4a182418 1271-march=@var{ISA-string|Profiles|Profiles_ISA-string|CPU/processor string}
43b72ede
AA
1272-mtune=@var{processor-string}
1273-mpreferred-stack-boundary=@var{num}
1274-msmall-data-limit=@var{N-bytes}
1275-msave-restore -mno-save-restore
1276-mshorten-memrefs -mno-shorten-memrefs
1277-mstrict-align -mno-strict-align
6ffea3e3 1278-mcmodel=medlow -mcmodel=medany -mcmodel=large
43b72ede
AA
1279-mexplicit-relocs -mno-explicit-relocs
1280-mrelax -mno-relax
1281-mriscv-attribute -mno-riscv-attribute
1282-malign-data=@var{type}
1283-mbig-endian -mlittle-endian
1284-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1285-mstack-protector-guard-offset=@var{offset}
f797260a 1286-mcsr-check -mno-csr-check
dc95b338 1287-mmovcc -mno-movcc
df48285b 1288-minline-atomics -mno-inline-atomics
949f1ccf
CM
1289-minline-strlen -mno-inline-strlen
1290-minline-strcmp -mno-inline-strcmp
97069657
TI
1291-minline-strncmp -mno-inline-strncmp
1292-mtls-dialect=desc -mtls-dialect=trad}
d77de738 1293
26226ace 1294@emph{RL78 Options} (@ref{RL78 Options})
43b72ede
AA
1295@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1296-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1297-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1298
26226ace 1299@emph{RS/6000 and PowerPC Options} (@ref{RS/6000 and PowerPC Options})
43b72ede
AA
1300@gccoptlist{-mcpu=@var{cpu-type}
1301-mtune=@var{cpu-type}
1302-mcmodel=@var{code-model}
1303-mpowerpc64
1304-maltivec -mno-altivec
1305-mpowerpc-gpopt -mno-powerpc-gpopt
1306-mpowerpc-gfxopt -mno-powerpc-gfxopt
1307-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1308-mfprnd -mno-fprnd
1309-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1310-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1311-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1312-malign-power -malign-natural
1313-msoft-float -mhard-float -mmultiple -mno-multiple
1314-mupdate -mno-update
1315-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1316-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1317-mstrict-align -mno-strict-align -mrelocatable
1318-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1319-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1320-mdynamic-no-pic -mswdiv -msingle-pic-base
1321-mprioritize-restricted-insns=@var{priority}
1322-msched-costly-dep=@var{dependence_type}
1323-minsert-sched-nops=@var{scheme}
1324-mcall-aixdesc -mcall-eabi -mcall-freebsd
1325-mcall-linux -mcall-netbsd -mcall-openbsd
1326-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1327-mtraceback=@var{traceback_type}
1328-maix-struct-return -msvr4-struct-return
1329-mabi=@var{abi-type} -msecure-plt -mbss-plt
96698551 1330-msplit-patch-nops
43b72ede
AA
1331-mlongcall -mno-longcall -mpltseq -mno-pltseq
1332-mblock-move-inline-limit=@var{num}
1333-mblock-compare-inline-limit=@var{num}
1334-mblock-compare-inline-loop-limit=@var{num}
1335-mno-block-ops-unaligned-vsx
1336-mstring-compare-inline-limit=@var{num}
1337-misel -mno-isel
1338-mvrsave -mno-vrsave
1339-mmulhw -mno-mulhw
1340-mdlmzb -mno-dlmzb
1341-mprototype -mno-prototype
1342-msim -mmvme -mads -myellowknife -memb -msdata
1343-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1344-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1345-mno-recip-precision
1346-mveclibabi=@var{type} -mfriz -mno-friz
1347-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1348-msave-toc-indirect -mno-save-toc-indirect
438ef143 1349-mpower8-fusion -mno-mpower8-fusion
43b72ede
AA
1350-mcrypto -mno-crypto -mhtm -mno-htm
1351-mquad-memory -mno-quad-memory
1352-mquad-memory-atomic -mno-quad-memory-atomic
1353-mcompat-align-parm -mno-compat-align-parm
1354-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1355-mgnu-attribute -mno-gnu-attribute
1356-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1357-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1358-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1359-mprivileged -mno-privileged}
1360
26226ace 1361@emph{RX Options} (@ref{RX Options})
43b72ede
AA
1362@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1363-mcpu=
1364-mbig-endian-data -mlittle-endian-data
1365-msmall-data
1366-msim -mno-sim
1367-mas100-syntax -mno-as100-syntax
1368-mrelax
1369-mmax-constant-size=
1370-mint-register=
1371-mpid
1372-mallow-string-insns -mno-allow-string-insns
1373-mjsr
1374-mno-warn-multiple-fast-interrupts
d77de738
ML
1375-msave-acc-in-interrupts}
1376
26226ace 1377@emph{S/390 and zSeries Options} (@ref{S/390 and zSeries Options})
43b72ede
AA
1378@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1379-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1380-mlong-double-64 -mlong-double-128
1381-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1382-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1383-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1384-mhtm -mvx -mzvector
1385-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1386-mfused-madd -mno-fused-madd
1387-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1388-mhotpatch=@var{halfwords},@var{halfwords}}
1389
26226ace 1390@emph{SH Options} (@ref{SH Options})
43b72ede
AA
1391@gccoptlist{-m1 -m2 -m2e
1392-m2a-nofpu -m2a-single-only -m2a-single -m2a
1393-m3 -m3e
1394-m4-nofpu -m4-single-only -m4-single -m4
1395-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1396-mb -ml -mdalign -mrelax
1397-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1398-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1399-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1400-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1401-maccumulate-outgoing-args
1402-matomic-model=@var{atomic-model}
1403-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1404-mcbranch-force-delay-slot
1405-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1406-mpretend-cmove -mtas}
1407
26226ace 1408@emph{Solaris 2 Options} (@ref{Solaris 2 Options})
43b72ede 1409@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1410-pthreads}
1411
26226ace 1412@emph{SPARC Options} (@ref{SPARC Options})
43b72ede
AA
1413@gccoptlist{-mcpu=@var{cpu-type}
1414-mtune=@var{cpu-type}
1415-mcmodel=@var{code-model}
1416-mmemory-model=@var{mem-model}
1417-m32 -m64 -mapp-regs -mno-app-regs
1418-mfaster-structs -mno-faster-structs -mflat -mno-flat
1419-mfpu -mno-fpu -mhard-float -msoft-float
1420-mhard-quad-float -msoft-quad-float
1421-mstack-bias -mno-stack-bias
1422-mstd-struct-return -mno-std-struct-return
1423-munaligned-doubles -mno-unaligned-doubles
1424-muser-mode -mno-user-mode
1425-mv8plus -mno-v8plus -mvis -mno-vis
d309844d
EB
1426-mvis2 -mno-vis2
1427-mvis3 -mno-vis3 -mvis3b -mno-vis3b
43b72ede
AA
1428-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1429-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1430-mpopc -mno-popc -msubxc -mno-subxc
b388f65a 1431-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc}
d77de738 1432
26226ace 1433@emph{System V Options} (@ref{System V Options})
d77de738
ML
1434@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1435
26226ace 1436@emph{V850 Options} (@ref{V850 Options})
43b72ede
AA
1437@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1438-mprolog-function -mno-prolog-function -mspace
1439-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1440-mapp-regs -mno-app-regs
1441-mdisable-callt -mno-disable-callt
1442-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1443-mv850e -mv850 -mv850e3v5
1444-mloop
1445-mrelax
1446-mlong-jumps
1447-msoft-float
1448-mhard-float
1449-mgcc-abi
1450-mrh850-abi
d77de738
ML
1451-mbig-switch}
1452
26226ace 1453@emph{VAX Options} (@ref{VAX Options})
314448fc 1454@gccoptlist{-munix -mgnu -md -md-float -mg -mg-float -mlra}
d77de738 1455
26226ace 1456@emph{Visium Options} (@ref{Visium Options})
43b72ede 1457@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1458-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1459
26226ace 1460@emph{VMS Options} (@ref{VMS Options})
43b72ede 1461@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1462-mpointer-size=@var{size}}
1463
26226ace 1464@emph{VxWorks Options} (@ref{VxWorks Options})
b6f4b000 1465@gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
d77de738
ML
1466-Xbind-lazy -Xbind-now}
1467
26226ace 1468@emph{x86 Options} (@ref{x86 Options})
43b72ede
AA
1469@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1470-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1471-mfpmath=@var{unit}
1472-masm=@var{dialect} -mno-fancy-math-387
1473-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1474-mno-wide-multiply -mrtd -malign-double
1475-mpreferred-stack-boundary=@var{num}
1476-mincoming-stack-boundary=@var{num}
1477-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1478-mrecip -mrecip=@var{opt}
1479-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
ad5b757d 1480-mpartial-vector-fp-math
43b72ede 1481-mmove-max=@var{bits} -mstore-max=@var{bits}
a307a26e 1482-mnoreturn-no-callee-saved-registers
43b72ede 1483-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
e1a7e2c5 1484-mavx2 -mavx512f -mavx512cd -mavx512vl
43b72ede
AA
1485-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1486-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
e1a7e2c5 1487-mptwrite -mclflushopt -mclwb -mxsavec -mxsaves
43b72ede
AA
1488-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1489-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1490-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1491-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1492-mavx512vbmi2 -mavx512bf16 -menqcmd
1493-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
e1a7e2c5 1494-mavx512vnni -mprfchw -mrdpid
43b72ede 1495-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
dd859e93 1496-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni -mamx-fp8
43b72ede 1497-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
e686416b 1498-mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
c052a6f4
HJ
1499-musermsr -mavx10.1 -mavx10.2 -mamx-avx512 -mamx-tf32 -mamx-transpose -mmovrs
1500-mamx-movrs
43b72ede
AA
1501-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1502-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1503-mkl -mwidekl
1504-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1505-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1506-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1507-mregparm=@var{num} -msseregparm
1508-mveclibabi=@var{type} -mvect8-ret-in-mem
1509-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1510-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1511-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1512-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1513-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1514-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1515-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1516-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1517-mstack-protector-guard-reg=@var{reg}
1518-mstack-protector-guard-offset=@var{offset}
1519-mstack-protector-guard-symbol=@var{symbol}
1520-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1521-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1522-mindirect-branch-register -mharden-sls=@var{choice}
1523-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1524-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1525
1526@emph{x86 Windows Options}
26226ace 1527See Cygwin and MinGW Options.
e8d00373 1528
26226ace 1529@emph{Xstormy16 Options} (@ref{Xstormy16 Options})
d77de738
ML
1530@gccoptlist{-msim}
1531
26226ace 1532@emph{Xtensa Options} (@ref{Xtensa Options})
43b72ede
AA
1533@gccoptlist{-mconst16 -mno-const16
1534-mfused-madd -mno-fused-madd
1535-mforce-no-pic
1536-mserialize-volatile -mno-serialize-volatile
1537-mtext-section-literals -mno-text-section-literals
1538-mauto-litpools -mno-auto-litpools
1539-mtarget-align -mno-target-align
1540-mlongcalls -mno-longcalls
1541-mabi=@var{abi-type}
675b390e
MF
1542-mextra-l32r-costs=@var{cycles}
1543-mstrict-align -mno-strict-align}
d77de738
ML
1544
1545@emph{zSeries Options}
1546See S/390 and zSeries Options.
1547@end table
1548
1549
1550@node Overall Options
1551@section Options Controlling the Kind of Output
1552
1553Compilation can involve up to four stages: preprocessing, compilation
1554proper, assembly and linking, always in that order. GCC is capable of
1555preprocessing and compiling several files either into several
1556assembler input files, or into one assembler input file; then each
1557assembler input file produces an object file, and linking combines all
1558the object files (those newly compiled, and those specified as input)
1559into an executable file.
1560
1561@cindex file name suffix
1562For any given input file, the file name suffix determines what kind of
1563compilation is done:
1564
1565@table @gcctabopt
1566@item @var{file}.c
1567C source code that must be preprocessed.
1568
1569@item @var{file}.i
1570C source code that should not be preprocessed.
1571
1572@item @var{file}.ii
1573C++ source code that should not be preprocessed.
1574
1575@item @var{file}.m
1576Objective-C source code. Note that you must link with the @file{libobjc}
1577library to make an Objective-C program work.
1578
1579@item @var{file}.mi
1580Objective-C source code that should not be preprocessed.
1581
1582@item @var{file}.mm
1583@itemx @var{file}.M
1584Objective-C++ source code. Note that you must link with the @file{libobjc}
1585library to make an Objective-C++ program work. Note that @samp{.M} refers
1586to a literal capital M@.
1587
1588@item @var{file}.mii
1589Objective-C++ source code that should not be preprocessed.
1590
1591@item @var{file}.h
1592C, C++, Objective-C or Objective-C++ header file to be turned into a
1593precompiled header (default), or C, C++ header file to be turned into an
1594Ada spec (via the @option{-fdump-ada-spec} switch).
1595
1596@item @var{file}.cc
1597@itemx @var{file}.cp
1598@itemx @var{file}.cxx
1599@itemx @var{file}.cpp
1600@itemx @var{file}.CPP
1601@itemx @var{file}.c++
1602@itemx @var{file}.C
1603C++ source code that must be preprocessed. Note that in @samp{.cxx},
1604the last two letters must both be literally @samp{x}. Likewise,
1605@samp{.C} refers to a literal capital C@.
1606
1607@item @var{file}.mm
1608@itemx @var{file}.M
1609Objective-C++ source code that must be preprocessed.
1610
1611@item @var{file}.mii
1612Objective-C++ source code that should not be preprocessed.
1613
1614@item @var{file}.hh
1615@itemx @var{file}.H
1616@itemx @var{file}.hp
1617@itemx @var{file}.hxx
1618@itemx @var{file}.hpp
1619@itemx @var{file}.HPP
1620@itemx @var{file}.h++
1621@itemx @var{file}.tcc
1622C++ header file to be turned into a precompiled header or Ada spec.
1623
1624@item @var{file}.f
1625@itemx @var{file}.for
1626@itemx @var{file}.ftn
ba615557 1627@itemx @var{file}.fi
d77de738
ML
1628Fixed form Fortran source code that should not be preprocessed.
1629
1630@item @var{file}.F
1631@itemx @var{file}.FOR
1632@itemx @var{file}.fpp
1633@itemx @var{file}.FPP
1634@itemx @var{file}.FTN
1635Fixed form Fortran source code that must be preprocessed (with the traditional
1636preprocessor).
1637
1638@item @var{file}.f90
1639@itemx @var{file}.f95
1640@itemx @var{file}.f03
1641@itemx @var{file}.f08
ba615557 1642@itemx @var{file}.fii
d77de738
ML
1643Free form Fortran source code that should not be preprocessed.
1644
1645@item @var{file}.F90
1646@itemx @var{file}.F95
1647@itemx @var{file}.F03
1648@itemx @var{file}.F08
1649Free form Fortran source code that must be preprocessed (with the
1650traditional preprocessor).
1651
ab79cd87
JL
1652@item @var{file}.cob
1653@item @var{file}.COB
1654@item @var{file}.cbl
1655@item @var{file}.CBL
1656COBOL source code.
1657
d77de738
ML
1658@item @var{file}.go
1659Go source code.
1660
1661@item @var{file}.d
1662D source code.
1663
1664@item @var{file}.di
1665D interface file.
1666
1667@item @var{file}.dd
1668D documentation code (Ddoc).
1669
1670@item @var{file}.ads
1671Ada source code file that contains a library unit declaration (a
1672declaration of a package, subprogram, or generic, or a generic
1673instantiation), or a library unit renaming declaration (a package,
1674generic, or subprogram renaming declaration). Such files are also
1675called @dfn{specs}.
1676
1677@item @var{file}.adb
1678Ada source code file containing a library unit body (a subprogram or
1679package body). Such files are also called @dfn{bodies}.
1680
1681@c GCC also knows about some suffixes for languages not yet included:
1682@c Ratfor:
1683@c @var{file}.r
1684
1685@item @var{file}.s
1686Assembler code.
1687
1688@item @var{file}.S
1689@itemx @var{file}.sx
1690Assembler code that must be preprocessed.
1691
1692@item @var{other}
1693An object file to be fed straight into linking.
1694Any file name with no recognized suffix is treated this way.
1695@end table
1696
1697@opindex x
1698You can specify the input language explicitly with the @option{-x} option:
1699
1700@table @gcctabopt
1701@item -x @var{language}
1702Specify explicitly the @var{language} for the following input files
1703(rather than letting the compiler choose a default based on the file
1704name suffix). This option applies to all following input files until
1705the next @option{-x} option. Possible values for @var{language} are:
1706@smallexample
1707c c-header cpp-output
1708c++ c++-header c++-system-header c++-user-header c++-cpp-output
1709objective-c objective-c-header objective-c-cpp-output
1710objective-c++ objective-c++-header objective-c++-cpp-output
1711assembler assembler-with-cpp
1712ada
ab79cd87 1713cobol
d77de738
ML
1714d
1715f77 f77-cpp-input f95 f95-cpp-input
1716go
1717@end smallexample
1718
cfc9f421
JD
1719Note that @option{-x} does not imply a particular language standard.
1720For example @option{-x f77} may also require @option{-std=legacy} for some older
1721source codes.
1722
d77de738
ML
1723@item -x none
1724Turn off any specification of a language, so that subsequent files are
cfc9f421 1725handled according to their file name suffixes (as if @option{-x}
d77de738
ML
1726has not been used at all).
1727@end table
1728
1729If you only want some of the stages of compilation, you can use
1730@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1731one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1732@command{gcc} is to stop. Note that some combinations (for example,
1733@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1734
1735@table @gcctabopt
d77de738 1736@opindex c
ddf6fe37 1737@item -c
d77de738
ML
1738Compile or assemble the source files, but do not link. The linking
1739stage simply is not done. The ultimate output is in the form of an
1740object file for each source file.
1741
1742By default, the object file name for a source file is made by replacing
1743the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1744
1745Unrecognized input files, not requiring compilation or assembly, are
1746ignored.
1747
d77de738 1748@opindex S
ddf6fe37 1749@item -S
d77de738
ML
1750Stop after the stage of compilation proper; do not assemble. The output
1751is in the form of an assembler code file for each non-assembler input
1752file specified.
1753
1754By default, the assembler file name for a source file is made by
1755replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1756
1757Input files that don't require compilation are ignored.
1758
d77de738 1759@opindex E
ddf6fe37 1760@item -E
d77de738
ML
1761Stop after the preprocessing stage; do not run the compiler proper. The
1762output is in the form of preprocessed source code, which is sent to the
1763standard output.
1764
1765Input files that don't require preprocessing are ignored.
1766
1767@cindex output file option
d77de738 1768@opindex o
ddf6fe37 1769@item -o @var{file}
d77de738
ML
1770Place the primary output in file @var{file}. This applies to whatever
1771sort of output is being produced, whether it be an executable file, an
1772object file, an assembler file or preprocessed C code.
1773
1774If @option{-o} is not specified, the default is to put an executable
1775file in @file{a.out}, the object file for
1776@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1777assembler file in @file{@var{source}.s}, a precompiled header file in
1778@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1779standard output.
1780
1781Though @option{-o} names only the primary output, it also affects the
1782naming of auxiliary and dump outputs. See the examples below. Unless
1783overridden, both auxiliary outputs and dump outputs are placed in the
1784same directory as the primary output. In auxiliary outputs, the suffix
1785of the input file is replaced with that of the auxiliary output file
1786type; in dump outputs, the suffix of the dump file is appended to the
1787input file suffix. In compilation commands, the base name of both
1788auxiliary and dump outputs is that of the primary output; in compile and
1789link commands, the primary output name, minus the executable suffix, is
1790combined with the input file name. If both share the same base name,
1791disregarding the suffix, the result of the combination is that base
1792name, otherwise, they are concatenated, separated by a dash.
1793
1794@smallexample
1795gcc -c foo.c ...
1796@end smallexample
1797
1798will use @file{foo.o} as the primary output, and place aux outputs and
1799dumps next to it, e.g., aux file @file{foo.dwo} for
1800@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1801@option{-fdump-rtl-final}.
1802
1803If a non-linker output file is explicitly specified, aux and dump files
1804by default take the same base name:
1805
1806@smallexample
1807gcc -c foo.c -o dir/foobar.o ...
1808@end smallexample
1809
1810will name aux outputs @file{dir/foobar.*} and dump outputs
1811@file{dir/foobar.c.*}.
1812
1813A linker output will instead prefix aux and dump outputs:
1814
1815@smallexample
1816gcc foo.c bar.c -o dir/foobar ...
1817@end smallexample
1818
1819will generally name aux outputs @file{dir/foobar-foo.*} and
1820@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1821@file{dir/foobar-bar.c.*}.
1822
1823The one exception to the above is when the executable shares the base
1824name with the single input:
1825
1826@smallexample
1827gcc foo.c -o dir/foo ...
1828@end smallexample
1829
1830in which case aux outputs are named @file{dir/foo.*} and dump outputs
1831named @file{dir/foo.c.*}.
1832
1833The location and the names of auxiliary and dump outputs can be adjusted
1834by the options @option{-dumpbase}, @option{-dumpbase-ext},
1835@option{-dumpdir}, @option{-save-temps=cwd}, and
1836@option{-save-temps=obj}.
1837
1838
d77de738 1839@opindex dumpbase
ddf6fe37 1840@item -dumpbase @var{dumpbase}
d77de738
ML
1841This option sets the base name for auxiliary and dump output files. It
1842does not affect the name of the primary output file. Intermediate
1843outputs, when preserved, are not regarded as primary outputs, but as
1844auxiliary outputs:
1845
1846@smallexample
1847gcc -save-temps -S foo.c
1848@end smallexample
1849
1850saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1851then compiles to the (implied) output file @file{foo.s}, whereas:
1852
1853@smallexample
1854gcc -save-temps -dumpbase save-foo -c foo.c
1855@end smallexample
1856
1857preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1858an intermediate, thus auxiliary output), and then assembles to the
1859(implied) output file @file{foo.o}.
1860
1861Absent this option, dump and aux files take their names from the input
1862file, or from the (non-linker) output file, if one is explicitly
1863specified: dump output files (e.g. those requested by @option{-fdump-*}
1864options) with the input name suffix, and aux output files (those
1865requested by other non-dump options, e.g. @code{-save-temps},
1866@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1867
1868Similar suffix differentiation of dump and aux outputs can be attained
1869for explicitly-given @option{-dumpbase basename.suf} by also specifying
1870@option{-dumpbase-ext .suf}.
1871
1872If @var{dumpbase} is explicitly specified with any directory component,
1873any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1874@option{-save-temps=*}) is ignored, and instead of appending to it,
1875@var{dumpbase} fully overrides it:
1876
1877@smallexample
1878gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1879 -dumpdir pfx- -save-temps=cwd ...
1880@end smallexample
1881
1882creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1883@file{dir/} in @option{-o}, the @file{./} prefix implied by
1884@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1885
1886When @option{-dumpbase} is specified in a command that compiles multiple
1887inputs, or that compiles and then links, it may be combined with
1888@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1889file is compiled using the combined @var{dumppfx}, and default values
1890for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1891file:
1892
1893@smallexample
1894gcc foo.c bar.c -c -dumpbase main ...
1895@end smallexample
1896
1897creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1898overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1899as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1900and @file{main-bar.*}.
1901
1902An empty string specified as @var{dumpbase} avoids the influence of the
1903output basename in the naming of auxiliary and dump outputs during
1904compilation, computing default values :
1905
1906@smallexample
1907gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1908@end smallexample
1909
1910will name aux outputs @file{dir/foo.*} and dump outputs
1911@file{dir/foo.c.*}. Note how their basenames are taken from the input
1912name, but the directory still defaults to that of the output.
1913
1914The empty-string dumpbase does not prevent the use of the output
1915basename for outputs during linking:
1916
1917@smallexample
1918gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1919@end smallexample
1920
1921The compilation of the source files will name auxiliary outputs
1922@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1923@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1924linking will use @file{dir/foobar.} as the prefix for dumps and
1925auxiliary files.
1926
1927
d77de738 1928@opindex dumpbase-ext
ddf6fe37 1929@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1930When forming the name of an auxiliary (but not a dump) output file, drop
1931trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1932suffixes. If not specified, this option defaults to the suffix of a
1933default @var{dumpbase}, i.e., the suffix of the input file when
1934@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1935is combined with @var{dumppfx}.
1936
1937@smallexample
1938gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1939@end smallexample
1940
1941creates @file{dir/foo.o} as the main output, and generates auxiliary
1942outputs in @file{dir/x-foo.*}, taking the location of the primary
1943output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1944outputs retain the suffix: @file{dir/x-foo.c.*}.
1945
1946This option is disregarded if it does not match the suffix of a
1947specified @var{dumpbase}, except as an alternative to the executable
1948suffix when appending the linker output base name to @var{dumppfx}, as
1949specified below:
1950
1951@smallexample
1952gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1953@end smallexample
1954
1955creates @file{main.out} as the primary output, and avoids overwriting
1956the auxiliary and dump outputs by using the executable name minus
1957@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1958@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1959@file{main-foo.c.*} and @file{main-bar.c.*}.
1960
1961
d77de738 1962@opindex dumpdir
ddf6fe37 1963@item -dumpdir @var{dumppfx}
d77de738
ML
1964When forming the name of an auxiliary or dump output file, use
1965@var{dumppfx} as a prefix:
1966
1967@smallexample
1968gcc -dumpdir pfx- -c foo.c ...
1969@end smallexample
1970
1971creates @file{foo.o} as the primary output, and auxiliary outputs named
1972@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1973@var{dumpbase} derived from the default primary output, derived in turn
1974from the input name. Dump outputs also take the input name suffix:
1975@file{pfx-foo.c.*}.
1976
1977If @var{dumppfx} is to be used as a directory name, it must end with a
1978directory separator:
1979
1980@smallexample
1981gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1982@end smallexample
1983
1984creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1985named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1986default @var{dumpbase} derived from the primary output name. Dump
1987outputs also take the input name suffix: @file{dir/bar.c.*}.
1988
1989It defaults to the location of the output file, unless the output
1990file is a special file like @code{/dev/null}. Options
1991@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1992default, just like an explicit @option{-dumpdir} option. In case
1993multiple such options are given, the last one prevails:
1994
1995@smallexample
1996gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1997@end smallexample
1998
1999outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
2000@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
2001@option{-dumpdir} option. It does not matter that @option{=obj} is the
2002default for @option{-save-temps}, nor that the output directory is
2003implicitly the current directory. Dump outputs are named
2004@file{foo.c.*}.
2005
2006When compiling from multiple input files, if @option{-dumpbase} is
2007specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
2008are appended to (or override, if containing any directory components) an
2009explicit or defaulted @var{dumppfx}, so that each of the multiple
2010compilations gets differently-named aux and dump outputs.
2011
2012@smallexample
2013gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
2014@end smallexample
2015
2016outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
2017@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
2018Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
2019and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
2020single-input compilation:
2021
2022@smallexample
2023gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
2024@end smallexample
2025
2026that, applying @option{-dumpbase} to a single source, does not compute
2027and append a separate @var{dumpbase} per input file. Its auxiliary and
2028dump outputs go in @file{dir/pfx-main.*}.
2029
2030When compiling and then linking from multiple input files, a defaulted
2031or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
2032transformation above (e.g. the compilation of @file{foo.c} and
2033@file{bar.c} above, but without @option{-c}). If neither
2034@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
2035base name, minus @var{auxdropsuf}, if specified, or the executable
2036suffix otherwise, plus a dash is appended to the default @var{dumppfx}
2037instead. Note, however, that unlike earlier cases of linking:
2038
2039@smallexample
2040gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
2041@end smallexample
2042
2043does not append the output name @file{main} to @var{dumppfx}, because
2044@option{-dumpdir} is explicitly specified. The goal is that the
2045explicitly-specified @var{dumppfx} may contain the specified output name
2046as part of the prefix, if desired; only an explicitly-specified
2047@option{-dumpbase} would be combined with it, in order to avoid simply
2048discarding a meaningful option.
2049
2050When compiling and then linking from a single input file, the linker
2051output base name will only be appended to the default @var{dumppfx} as
2052above if it does not share the base name with the single input file
2053name. This has been covered in single-input linking cases above, but
2054not with an explicit @option{-dumpdir} that inhibits the combination,
2055even if overridden by @option{-save-temps=*}:
2056
2057@smallexample
2058gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2059@end smallexample
2060
2061Auxiliary outputs are named @file{foo.*}, and dump outputs
2062@file{foo.c.*}, in the current working directory as ultimately requested
2063by @option{-save-temps=cwd}.
2064
2065Summing it all up for an intuitive though slightly imprecise data flow:
2066the primary output name is broken into a directory part and a basename
2067part; @var{dumppfx} is set to the former, unless overridden by
2068@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2069to the latter, unless overriden by @option{-dumpbase}. If there are
2070multiple inputs or linking, this @var{dumpbase} may be combined with
2071@var{dumppfx} and taken from each input file. Auxiliary output names
2072for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2073minus suffix, and the auxiliary output suffix; dump output names are
2074only different in that the suffix from @var{dumpbase} is retained.
2075
2076When it comes to auxiliary and dump outputs created during LTO
2077recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2078given or as derived from the linker output name but not from inputs,
2079even in cases in which this combination would not otherwise be used as
2080such, is passed down with a trailing period replacing the compiler-added
2081dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2082being involved in linking, this program does not normally get any
2083@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2084
2085When running sub-compilers, @command{lto-wrapper} appends LTO stage
2086names to the received @var{dumppfx}, ensures it contains a directory
2087component so that it overrides any @option{-dumpdir}, and passes that as
2088@option{-dumpbase} to sub-compilers.
2089
d77de738 2090@opindex v
ddf6fe37 2091@item -v
d77de738
ML
2092Print (on standard error output) the commands executed to run the stages
2093of compilation. Also print the version number of the compiler driver
2094program and of the preprocessor and the compiler proper.
2095
d77de738 2096@opindex ###
ddf6fe37 2097@item -###
d77de738
ML
2098Like @option{-v} except the commands are not executed and arguments
2099are quoted unless they contain only alphanumeric characters or @code{./-_}.
2100This is useful for shell scripts to capture the driver-generated command lines.
2101
d77de738 2102@opindex help
ddf6fe37 2103@item --help
d77de738
ML
2104Print (on the standard output) a description of the command-line options
2105understood by @command{gcc}. If the @option{-v} option is also specified
2106then @option{--help} is also passed on to the various processes
2107invoked by @command{gcc}, so that they can display the command-line options
2108they accept. If the @option{-Wextra} option has also been specified
2109(prior to the @option{--help} option), then command-line options that
2110have no documentation associated with them are also displayed.
2111
d77de738 2112@opindex target-help
ddf6fe37 2113@item --target-help
d77de738
ML
2114Print (on the standard output) a description of target-specific command-line
2115options for each tool. For some targets extra target-specific
2116information may also be printed.
2117
2118@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2119Print (on the standard output) a description of the command-line
2120options understood by the compiler that fit into all specified classes
2121and qualifiers. These are the supported classes:
2122
2123@table @asis
2124@item @samp{optimizers}
2125Display all of the optimization options supported by the
2126compiler.
2127
2128@item @samp{warnings}
2129Display all of the options controlling warning messages
2130produced by the compiler.
2131
2132@item @samp{target}
2133Display target-specific options. Unlike the
2134@option{--target-help} option however, target-specific options of the
2135linker and assembler are not displayed. This is because those
2136tools do not currently support the extended @option{--help=} syntax.
2137
2138@item @samp{params}
2139Display the values recognized by the @option{--param}
2140option.
2141
2142@item @var{language}
2143Display the options supported for @var{language}, where
2144@var{language} is the name of one of the languages supported in this
2145version of GCC@. If an option is supported by all languages, one needs
2146to select @samp{common} class.
2147
2148@item @samp{common}
2149Display the options that are common to all languages.
2150@end table
2151
2152These are the supported qualifiers:
2153
2154@table @asis
2155@item @samp{undocumented}
2156Display only those options that are undocumented.
2157
2158@item @samp{joined}
2159Display options taking an argument that appears after an equal
2160sign in the same continuous piece of text, such as:
2161@samp{--help=target}.
2162
2163@item @samp{separate}
2164Display options taking an argument that appears as a separate word
2165following the original option, such as: @samp{-o output-file}.
2166@end table
2167
2168Thus for example to display all the undocumented target-specific
2169switches supported by the compiler, use:
2170
2171@smallexample
2172--help=target,undocumented
2173@end smallexample
2174
2175The sense of a qualifier can be inverted by prefixing it with the
2176@samp{^} character, so for example to display all binary warning
2177options (i.e., ones that are either on or off and that do not take an
2178argument) that have a description, use:
2179
2180@smallexample
2181--help=warnings,^joined,^undocumented
2182@end smallexample
2183
2184The argument to @option{--help=} should not consist solely of inverted
2185qualifiers.
2186
2187Combining several classes is possible, although this usually
2188restricts the output so much that there is nothing to display. One
2189case where it does work, however, is when one of the classes is
2190@var{target}. For example, to display all the target-specific
2191optimization options, use:
2192
2193@smallexample
2194--help=target,optimizers
2195@end smallexample
2196
2197The @option{--help=} option can be repeated on the command line. Each
2198successive use displays its requested class of options, skipping
2199those that have already been displayed. If @option{--help} is also
2200specified anywhere on the command line then this takes precedence
2201over any @option{--help=} option.
2202
a5212edf 2203@opindex Q
d77de738
ML
2204If the @option{-Q} option appears on the command line before the
2205@option{--help=} option, then the descriptive text displayed by
2206@option{--help=} is changed. Instead of describing the displayed
2207options, an indication is given as to whether the option is enabled,
2208disabled or set to a specific value (assuming that the compiler
2209knows this at the point where the @option{--help=} option is used).
2210
2211Here is a truncated example from the ARM port of @command{gcc}:
2212
2213@smallexample
2214 % gcc -Q -mabi=2 --help=target -c
2215 The following options are target specific:
2216 -mabi= 2
2217 -mabort-on-noreturn [disabled]
2218 -mapcs [disabled]
2219@end smallexample
2220
2221The output is sensitive to the effects of previous command-line
2222options, so for example it is possible to find out which optimizations
2223are enabled at @option{-O2} by using:
2224
2225@smallexample
2226-Q -O2 --help=optimizers
2227@end smallexample
2228
2229Alternatively you can discover which binary optimizations are enabled
2230by @option{-O3} by using:
2231
2232@smallexample
2233gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2234gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2235diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2236@end smallexample
2237
d77de738 2238@opindex version
ddf6fe37 2239@item --version
d77de738
ML
2240Display the version number and copyrights of the invoked GCC@.
2241
d77de738 2242@opindex pass-exit-codes
ddf6fe37 2243@item -pass-exit-codes
d77de738
ML
2244Normally the @command{gcc} program exits with the code of 1 if any
2245phase of the compiler returns a non-success return code. If you specify
2246@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2247the numerically highest error produced by any phase returning an error
2248indication. The C, C++, and Fortran front ends return 4 if an internal
2249compiler error is encountered.
2250
d77de738 2251@opindex pipe
ddf6fe37 2252@item -pipe
d77de738
ML
2253Use pipes rather than temporary files for communication between the
2254various stages of compilation. This fails to work on some systems where
2255the assembler is unable to read from a pipe; but the GNU assembler has
2256no trouble.
2257
d77de738 2258@opindex specs
ddf6fe37 2259@item -specs=@var{file}
d77de738
ML
2260Process @var{file} after the compiler reads in the standard @file{specs}
2261file, in order to override the defaults which the @command{gcc} driver
2262program uses when determining what switches to pass to @command{cc1},
2263@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2264@option{-specs=@var{file}} can be specified on the command line, and they
2265are processed in order, from left to right. @xref{Spec Files}, for
2266information about the format of the @var{file}.
2267
d77de738 2268@opindex wrapper
ddf6fe37 2269@item -wrapper
d77de738
ML
2270Invoke all subcommands under a wrapper program. The name of the
2271wrapper program and its parameters are passed as a comma separated
2272list.
2273
2274@smallexample
2275gcc -c t.c -wrapper gdb,--args
2276@end smallexample
2277
2278@noindent
2279This invokes all subprograms of @command{gcc} under
2280@samp{gdb --args}, thus the invocation of @command{cc1} is
2281@samp{gdb --args cc1 @dots{}}.
2282
d77de738 2283@opindex ffile-prefix-map
ddf6fe37 2284@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2285When compiling files residing in directory @file{@var{old}}, record
2286any references to them in the result of the compilation as if the
2287files resided in directory @file{@var{new}} instead. Specifying this
2288option is equivalent to specifying all the individual
2289@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2290builds that are location independent. Directories referenced by
2eb0191a
JJ
2291directives are not affected by these options. See also
2292@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2293@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2294
2eb0191a 2295@opindex fcanon-prefix-map
e54b01a1 2296@item -fcanon-prefix-map
2eb0191a
JJ
2297For the @option{-f*-prefix-map} options normally comparison
2298of @file{@var{old}} prefix against the filename that would be normally
2299referenced in the result of the compilation is done using textual
2300comparison of the prefixes, or ignoring character case for case insensitive
2301filesystems and considering slashes and backslashes as equal on DOS based
2302filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2303to be done on canonicalized paths of @file{@var{old}}
2304and the referenced filename.
d77de738 2305
d77de738 2306@opindex fplugin
ddf6fe37 2307@item -fplugin=@var{name}.so
d77de738
ML
2308Load the plugin code in file @var{name}.so, assumed to be a
2309shared object to be dlopen'd by the compiler. The base name of
2310the shared object file is used to identify the plugin for the
2311purposes of argument parsing (See
2312@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2313Each plugin should define the callback functions specified in the
2314Plugins API.
2315
d77de738 2316@opindex fplugin-arg
ddf6fe37 2317@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2318Define an argument called @var{key} with a value of @var{value}
2319for the plugin called @var{name}.
2320
d77de738 2321@opindex fdump-ada-spec
ddf6fe37 2322@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2323For C and C++ source and include files, generate corresponding Ada specs.
2324@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2325GNAT User's Guide}, which provides detailed documentation on this feature.
2326
d77de738 2327@opindex fada-spec-parent
ddf6fe37 2328@item -fada-spec-parent=@var{unit}
d77de738
ML
2329In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2330Ada specs as child units of parent @var{unit}.
2331
d77de738 2332@opindex fdump-go-spec
ddf6fe37 2333@item -fdump-go-spec=@var{file}
d77de738
ML
2334For input files in any language, generate corresponding Go
2335declarations in @var{file}. This generates Go @code{const},
2336@code{type}, @code{var}, and @code{func} declarations which may be a
2337useful way to start writing a Go interface to code written in some
2338other language.
2339
2340@include @value{srcdir}/../libiberty/at-file.texi
2341@end table
2342
2343@node Invoking G++
2344@section Compiling C++ Programs
2345
2346@cindex suffixes for C++ source
2347@cindex C++ source file suffixes
2348C++ source files conventionally use one of the suffixes @samp{.C},
2349@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2350@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
ff41abdc
JM
2351@samp{.H}, or (for shared template code) @samp{.tcc};
2352preprocessed C++ files use the suffix @samp{.ii}; and C++20 module interface
2353units sometimes use @samp{.ixx}, @samp{.cppm}, @samp{.cxxm}, @samp{.c++m},
2354or @samp{.ccm}.
2355
2356GCC recognizes files with these names and compiles them as C++ programs even if you
d77de738
ML
2357call the compiler the same way as for compiling C programs (usually
2358with the name @command{gcc}).
2359
2360@findex g++
2361@findex c++
2362However, the use of @command{gcc} does not add the C++ library.
2363@command{g++} is a program that calls GCC and automatically specifies linking
2364against the C++ library. It treats @samp{.c},
2365@samp{.h} and @samp{.i} files as C++ source files instead of C source
2366files unless @option{-x} is used. This program is also useful when
2367precompiling a C header file with a @samp{.h} extension for use in C++
2368compilations. On many systems, @command{g++} is also installed with
2369the name @command{c++}.
2370
2371@cindex invoking @command{g++}
2372When you compile C++ programs, you may specify many of the same
2373command-line options that you use for compiling programs in any
2374language; or command-line options meaningful for C and related
2375languages; or options that are meaningful only for C++ programs.
2376@xref{C Dialect Options,,Options Controlling C Dialect}, for
2377explanations of options for languages related to C@.
2378@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2379explanations of options that are meaningful only for C++ programs.
2380
2381@node C Dialect Options
2382@section Options Controlling C Dialect
2383@cindex dialect options
2384@cindex language dialect options
2385@cindex options, dialect
2386
2387The following options control the dialect of C (or languages derived
2388from C, such as C++, Objective-C and Objective-C++) that the compiler
2389accepts:
2390
2391@table @gcctabopt
2392@cindex ANSI support
2393@cindex ISO support
d77de738 2394@opindex ansi
ddf6fe37 2395@item -ansi
d77de738
ML
2396In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2397equivalent to @option{-std=c++98}.
2398
d77de738 2399@opindex std
ddf6fe37 2400@item -std=
d77de738
ML
2401Determine the language standard. @xref{Standards,,Language Standards
2402Supported by GCC}, for details of these standard versions. This option
2403is currently only supported when compiling C or C++.
2404
2405The compiler can accept several base standards, such as @samp{c90} or
2406@samp{c++98}, and GNU dialects of those standards, such as
2407@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2408compiler accepts all programs following that standard plus those
2409using GNU extensions that do not contradict it. For example,
2410@option{-std=c90} turns off certain features of GCC that are
2411incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2412keywords, but not other GNU extensions that do not have a meaning in
2413ISO C90, such as omitting the middle term of a @code{?:}
2414expression. On the other hand, when a GNU dialect of a standard is
2415specified, all features supported by the compiler are enabled, even when
2416those features change the meaning of the base standard. As a result, some
2417strict-conforming programs may be rejected. The particular standard
2418is used by @option{-Wpedantic} to identify which features are GNU
2419extensions given that version of the standard. For example
2420@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2421comments, while @option{-std=gnu99 -Wpedantic} does not.
2422
2423A value for this option must be provided; possible values are
2424
2425@table @samp
2426@item c90
2427@itemx c89
2428@itemx iso9899:1990
2429Support all ISO C90 programs (certain GNU extensions that conflict
2430with ISO C90 are disabled). Same as @option{-ansi} for C code.
2431
2432@item iso9899:199409
2433ISO C90 as modified in amendment 1.
2434
2435@item c99
2436@itemx c9x
2437@itemx iso9899:1999
2438@itemx iso9899:199x
2439ISO C99. This standard is substantially completely supported, modulo
2440bugs and floating-point issues
2441(mainly but not entirely relating to optional C99 features from
2442Annexes F and G). See
a27540cf
MP
2443@w{@uref{https://gcc.gnu.org/projects/c-status.html}} for more information.
2444The names @samp{c9x} and @samp{iso9899:199x} are deprecated.
d77de738
ML
2445
2446@item c11
2447@itemx c1x
2448@itemx iso9899:2011
2449ISO C11, the 2011 revision of the ISO C standard. This standard is
2450substantially completely supported, modulo bugs, floating-point issues
2451(mainly but not entirely relating to optional C11 features from
2452Annexes F and G) and the optional Annexes K (Bounds-checking
2453interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2454
2455@item c17
2456@itemx c18
2457@itemx iso9899:2017
2458@itemx iso9899:2018
2459ISO C17, the 2017 revision of the ISO C standard
2460(published in 2018). This standard is
2461same as C11 except for corrections of defects (all of which are also
2462applied with @option{-std=c11}) and a new value of
2463@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2464
fad61bf7
JM
2465@item c23
2466@itemx c2x
2467@itemx iso9899:2024
ab8d3606
JJ
2468ISO C23, the 2023 revision of the ISO C standard (published in 2024). The
2469name @samp{c2x} is deprecated.
d77de738 2470
0cf68222
JM
2471@item c2y
2472The next version of the ISO C standard, still under development. The
2473support for this version is experimental and incomplete.
2474
d77de738
ML
2475@item gnu90
2476@itemx gnu89
2477GNU dialect of ISO C90 (including some C99 features).
2478
2479@item gnu99
2480@itemx gnu9x
2481GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2482
2483@item gnu11
2484@itemx gnu1x
2485GNU dialect of ISO C11.
2486The name @samp{gnu1x} is deprecated.
2487
2488@item gnu17
2489@itemx gnu18
55e3bd37 2490GNU dialect of ISO C17.
d77de738 2491
fad61bf7
JM
2492@item gnu23
2493@itemx gnu2x
55e3bd37
JM
2494GNU dialect of ISO C23. This is the default for C code. The name
2495@samp{gnu2x} is deprecated.
0cf68222
JM
2496
2497@item gnu2y
d77de738
ML
2498The next version of the ISO C standard, still under development, plus
2499GNU extensions. The support for this version is experimental and
fad61bf7 2500incomplete. The name @samp{gnu2x} is deprecated.
d77de738
ML
2501
2502@item c++98
2503@itemx c++03
2504The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2505additional defect reports. Same as @option{-ansi} for C++ code.
2506
2507@item gnu++98
2508@itemx gnu++03
2509GNU dialect of @option{-std=c++98}.
2510
2511@item c++11
2512@itemx c++0x
2513The 2011 ISO C++ standard plus amendments.
2514The name @samp{c++0x} is deprecated.
2515
2516@item gnu++11
2517@itemx gnu++0x
2518GNU dialect of @option{-std=c++11}.
2519The name @samp{gnu++0x} is deprecated.
2520
2521@item c++14
2522@itemx c++1y
2523The 2014 ISO C++ standard plus amendments.
2524The name @samp{c++1y} is deprecated.
2525
2526@item gnu++14
2527@itemx gnu++1y
2528GNU dialect of @option{-std=c++14}.
2529The name @samp{gnu++1y} is deprecated.
2530
2531@item c++17
2532@itemx c++1z
2533The 2017 ISO C++ standard plus amendments.
2534The name @samp{c++1z} is deprecated.
2535
2536@item gnu++17
2537@itemx gnu++1z
2538GNU dialect of @option{-std=c++17}.
2539This is the default for C++ code.
2540The name @samp{gnu++1z} is deprecated.
2541
2542@item c++20
2543@itemx c++2a
2544The 2020 ISO C++ standard plus amendments.
2545Support is experimental, and could change in incompatible ways in
2546future releases.
2547The name @samp{c++2a} is deprecated.
2548
2549@item gnu++20
2550@itemx gnu++2a
2551GNU dialect of @option{-std=c++20}.
2552Support is experimental, and could change in incompatible ways in
2553future releases.
2554The name @samp{gnu++2a} is deprecated.
2555
d949b94e
JJ
2556@item c++23
2557@itemx c++2b
2558The 2023 ISO C++ standard plus amendments (published in 2024).
2559Support is experimental, and could change in incompatible ways in
2560future releases.
2561The name @samp{c++2b} is deprecated.
d77de738 2562
d949b94e
JJ
2563@item gnu++23
2564@itemx gnu++2b
2565GNU dialect of @option{-std=c++23}.
2566Support is experimental, and could change in incompatible ways in
2567future releases.
2568The name @samp{gnu++2b} is deprecated.
5388a43f
MP
2569
2570@item c++2c
2571@itemx c++26
2572The next revision of the ISO C++ standard, planned for
25732026. Support is highly experimental, and will almost certainly
2574change in incompatible ways in future releases.
2575
2576@item gnu++2c
2577@itemx gnu++26
2578GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2579and will almost certainly change in incompatible ways in future
2580releases.
d77de738
ML
2581@end table
2582
d77de738 2583@opindex aux-info
ddf6fe37 2584@item -aux-info @var{filename}
d77de738
ML
2585Output to the given filename prototyped declarations for all functions
2586declared and/or defined in a translation unit, including those in header
2587files. This option is silently ignored in any language other than C@.
2588
2589Besides declarations, the file indicates, in comments, the origin of
2590each declaration (source file and line), whether the declaration was
2591implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2592@samp{O} for old, respectively, in the first character after the line
2593number and the colon), and whether it came from a declaration or a
2594definition (@samp{C} or @samp{F}, respectively, in the following
2595character). In the case of function definitions, a K&R-style list of
2596arguments followed by their declarations is also provided, inside
2597comments, after the declaration.
2598
d77de738
ML
2599@opindex fno-asm
2600@opindex fasm
ddf6fe37 2601@item -fno-asm
d77de738
ML
2602Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2603keyword, so that code can use these words as identifiers. You can use
2604the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2605instead. In C, @option{-ansi} implies @option{-fno-asm}.
2606
2607In C++, @code{inline} is a standard keyword and is not affected by
2608this switch. You may want to use the @option{-fno-gnu-keywords} flag
2609instead, which disables @code{typeof} but not @code{asm} and
2610@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2611this switch only affects the @code{asm} and @code{typeof} keywords,
fad61bf7
JM
2612since @code{inline} is a standard keyword in ISO C99. In C23 mode
2613(@option{-std=c23} or @option{-std=gnu23}), this switch only affects
d77de738 2614the @code{asm} keyword, since @code{typeof} is a standard keyword in
fad61bf7 2615ISO C23.
d77de738 2616
d77de738
ML
2617@opindex fno-builtin
2618@opindex fbuiltin
f33d7a88 2619@cindex built-in functions
ddf6fe37
AA
2620@item -fno-builtin
2621@itemx -fno-builtin-@var{function}
d77de738 2622Don't recognize built-in functions that do not begin with
35e0f112
SL
2623@samp{__builtin_} as prefix. @xref{Library Builtins},
2624for details of the functions affected,
d77de738
ML
2625including those which are not built-in functions when @option{-ansi} or
2626@option{-std} options for strict ISO C conformance are used because they
2627do not have an ISO standard meaning.
2628
2629GCC normally generates special code to handle certain built-in functions
2630more efficiently; for instance, calls to @code{alloca} may become single
2631instructions which adjust the stack directly, and calls to @code{memcpy}
2632may become inline copy loops. The resulting code is often both smaller
2633and faster, but since the function calls no longer appear as such, you
2634cannot set a breakpoint on those calls, nor can you change the behavior
2635of the functions by linking with a different library. In addition,
2636when a function is recognized as a built-in function, GCC may use
2637information about that function to warn about problems with calls to
2638that function, or to generate more efficient code, even if the
2639resulting code still contains calls to that function. For example,
2640warnings are given with @option{-Wformat} for bad calls to
2641@code{printf} when @code{printf} is built in and @code{strlen} is
2642known not to modify global memory.
2643
2644With the @option{-fno-builtin-@var{function}} option
2645only the built-in function @var{function} is
2646disabled. @var{function} must not begin with @samp{__builtin_}. If a
2647function is named that is not built-in in this version of GCC, this
2648option is ignored. There is no corresponding
2649@option{-fbuiltin-@var{function}} option; if you wish to enable
2650built-in functions selectively when using @option{-fno-builtin} or
2651@option{-ffreestanding}, you may define macros such as:
2652
2653@smallexample
2654#define abs(n) __builtin_abs ((n))
2655#define strcpy(d, s) __builtin_strcpy ((d), (s))
2656@end smallexample
2657
d77de738 2658@opindex fcond-mismatch
ddf6fe37 2659@item -fcond-mismatch
d77de738
ML
2660Allow conditional expressions with mismatched types in the second and
2661third arguments. The value of such an expression is void. This option
2662is not supported for C++.
2663
d77de738
ML
2664@opindex ffreestanding
2665@cindex hosted environment
f33d7a88 2666@item -ffreestanding
d77de738
ML
2667
2668Assert that compilation targets a freestanding environment. This
2669implies @option{-fno-builtin}. A freestanding environment
2670is one in which the standard library may not exist, and program startup may
2671not necessarily be at @code{main}. The most obvious example is an OS kernel.
2672This is equivalent to @option{-fno-hosted}.
2673
2674@xref{Standards,,Language Standards Supported by GCC}, for details of
2675freestanding and hosted environments.
2676
d77de738 2677@opindex fgimple
ddf6fe37 2678@item -fgimple
d77de738
ML
2679
2680Enable parsing of function definitions marked with @code{__GIMPLE}.
2681This is an experimental feature that allows unit testing of GIMPLE
2682passes.
2683
d77de738 2684@opindex fgnu-tm
ddf6fe37 2685@item -fgnu-tm
d77de738
ML
2686When the option @option{-fgnu-tm} is specified, the compiler
2687generates code for the Linux variant of Intel's current Transactional
2688Memory ABI specification document (Revision 1.1, May 6 2009). This is
2689an experimental feature whose interface may change in future versions
2690of GCC, as the official specification changes. Please note that not
2691all architectures are supported for this feature.
2692
2693For more information on GCC's support for transactional memory,
2694@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2695Transactional Memory Library}.
2696
2697Note that the transactional memory feature is not supported with
2698non-call exceptions (@option{-fnon-call-exceptions}).
2699
d77de738 2700@opindex fgnu89-inline
ddf6fe37 2701@item -fgnu89-inline
d77de738
ML
2702The option @option{-fgnu89-inline} tells GCC to use the traditional
2703GNU semantics for @code{inline} functions when in C99 mode.
2704@xref{Inline,,An Inline Function is As Fast As a Macro}.
2705Using this option is roughly equivalent to adding the
2706@code{gnu_inline} function attribute to all inline functions
2707(@pxref{Function Attributes}).
2708
2709The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2710C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2711specifies the default behavior).
2712This option is not supported in @option{-std=c90} or
2713@option{-std=gnu90} mode.
2714
2715The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2716@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2717in effect for @code{inline} functions. @xref{Common Predefined
2718Macros,,,cpp,The C Preprocessor}.
2719
d77de738
ML
2720@opindex fhosted
2721@cindex hosted environment
f33d7a88 2722@item -fhosted
d77de738
ML
2723
2724Assert that compilation targets a hosted environment. This implies
2725@option{-fbuiltin}. A hosted environment is one in which the
2726entire standard library is available, and in which @code{main} has a return
2727type of @code{int}. Examples are nearly everything except a kernel.
2728This is equivalent to @option{-fno-freestanding}.
2729
d77de738 2730@opindex flax-vector-conversions
ddf6fe37 2731@item -flax-vector-conversions
d77de738
ML
2732Allow implicit conversions between vectors with differing numbers of
2733elements and/or incompatible element types. This option should not be
2734used for new code.
2735
d77de738 2736@opindex fms-extensions
ddf6fe37 2737@item -fms-extensions
d77de738
ML
2738Accept some non-standard constructs used in Microsoft header files.
2739
2740In C++ code, this allows member names in structures to be similar
2741to previous types declarations.
2742
2743@smallexample
2744typedef int UOW;
2745struct ABC @{
2746 UOW UOW;
2747@};
2748@end smallexample
2749
2750Some cases of unnamed fields in structures and unions are only
2751accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2752fields within structs/unions}, for details.
2753
2754Note that this option is off for all targets except for x86
2755targets using ms-abi.
2756
d77de738
ML
2757@opindex fpermitted-flt-eval-methods
2758@opindex fpermitted-flt-eval-methods=c11
2759@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2760@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2761ISO/IEC TS 18661-3 defines new permissible values for
2762@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2763a semantic type that is an interchange or extended format should be
2764evaluated to the precision and range of that type. These new values are
2765a superset of those permitted under C99/C11, which does not specify the
2766meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2767conforming to C11 may not have been written expecting the possibility of
2768the new values.
2769
2770@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2771should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2772or the extended set of values specified in ISO/IEC TS 18661-3.
2773
2774@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2775
2776The default when in a standards compliant mode (@option{-std=c11} or similar)
2777is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2778dialect (@option{-std=gnu11} or similar) is
2779@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2780
024f135a
BB
2781@opindex fdeps-
2782The @samp{-fdeps-*} options are used to extract structured dependency
2783information for a source. This involves determining what resources provided by
2784other source files will be required to compile the source as well as what
2785resources are provided by the source. This information can be used to add
2786required dependencies between compilation rules of dependent sources based on
2787their contents rather than requiring such information be reflected within the
2788build tools as well.
2789
2790@opindex fdeps-file
2791@item -fdeps-file=@var{file}
2792Where to write structured dependency information.
2793
2794@opindex fdeps-format
2795@item -fdeps-format=@var{format}
2796The format to use for structured dependency information. @samp{p1689r5} is the
2797only supported format right now. Note that when this argument is specified, the
2798output of @samp{-MF} is stripped of some information (namely C++ modules) so
2799that it does not use extended makefile syntax not understood by most tools.
2800
2801@opindex fdeps-target
2802@item -fdeps-target=@var{file}
2803Analogous to @option{-MT} but for structured dependency information. This
2804indicates the target which will ultimately need any required resources and
2805provide any resources extracted from the source that may be required by other
2806sources.
2807
d77de738 2808@opindex fplan9-extensions
ddf6fe37 2809@item -fplan9-extensions
d77de738
ML
2810Accept some non-standard constructs used in Plan 9 code.
2811
2812This enables @option{-fms-extensions}, permits passing pointers to
2813structures with anonymous fields to functions that expect pointers to
2814elements of the type of the field, and permits referring to anonymous
2815fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2816struct/union fields within structs/unions}, for details. This is only
2817supported for C, not C++.
2818
d77de738
ML
2819@opindex fsigned-bitfields
2820@opindex funsigned-bitfields
2821@opindex fno-signed-bitfields
2822@opindex fno-unsigned-bitfields
ddf6fe37
AA
2823@item -fsigned-bitfields
2824@itemx -funsigned-bitfields
2825@itemx -fno-signed-bitfields
2826@itemx -fno-unsigned-bitfields
d77de738
ML
2827These options control whether a bit-field is signed or unsigned, when the
2828declaration does not use either @code{signed} or @code{unsigned}. By
2829default, such a bit-field is signed, because this is consistent: the
2830basic integer types such as @code{int} are signed types.
2831
d77de738 2832@opindex fsigned-char
ddf6fe37 2833@item -fsigned-char
d77de738
ML
2834Let the type @code{char} be signed, like @code{signed char}.
2835
2836Note that this is equivalent to @option{-fno-unsigned-char}, which is
2837the negative form of @option{-funsigned-char}. Likewise, the option
2838@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2839
d77de738 2840@opindex funsigned-char
ddf6fe37 2841@item -funsigned-char
d77de738
ML
2842Let the type @code{char} be unsigned, like @code{unsigned char}.
2843
2844Each kind of machine has a default for what @code{char} should
2845be. It is either like @code{unsigned char} by default or like
2846@code{signed char} by default.
2847
2848Ideally, a portable program should always use @code{signed char} or
2849@code{unsigned char} when it depends on the signedness of an object.
2850But many programs have been written to use plain @code{char} and
2851expect it to be signed, or expect it to be unsigned, depending on the
2852machines they were written for. This option, and its inverse, let you
2853make such a program work with the opposite default.
2854
2855The type @code{char} is always a distinct type from each of
2856@code{signed char} or @code{unsigned char}, even though its behavior
2857is always just like one of those two.
2858
d77de738
ML
2859@opindex fstrict-flex-arrays
2860@opindex fno-strict-flex-arrays
d77de738 2861@opindex fstrict-flex-arrays=@var{level}
eb71695f
SL
2862@item -fstrict-flex-arrays @r{(C and C++ only)}
2863@itemx -fstrict-flex-arrays=@var{level} @r{(C and C++ only)}
d77de738
ML
2864Control when to treat the trailing array of a structure as a flexible array
2865member for the purpose of accessing the elements of such an array. The value
2866of @var{level} controls the level of strictness.
2867
eb71695f 2868@option{-fstrict-flex-arrays} is equivalent to
d136fa00
SL
2869@option{-fstrict-flex-arrays=3}, which is the strictest;
2870a trailing array is treated as a flexible array member only when
2871it is declared as a flexible array member per C99 standard onwards.
eb71695f
SL
2872
2873The negative form @option{-fno-strict-flex-arrays} is equivalent to
2874@option{-fstrict-flex-arrays=0}, which is the least strict. In this
d136fa00
SL
2875case all trailing arrays of structures are treated as flexible array members.
2876
2877There are two more levels in between 0 and 3, which are provided to
2878support older code that uses the GCC zero-length array extension
2879(@samp{[0]}) or one-element array as flexible array members
2880(@samp{[1]}). When @var{level} is 1, the trailing array is treated as
2881a flexible array member when it is declared as either @samp{[]},
2882@samp{[0]}, or @samp{[1]}. When @var{level} is 2, the trailing array
2883is treated as a flexible array member when it is declared as either
2884@samp{[]}, or @samp{[0]}.
d77de738
ML
2885
2886You can control this behavior for a specific trailing array field of a
2887structure by using the variable attribute @code{strict_flex_array} attribute
2888(@pxref{Variable Attributes}).
2889
eb71695f
SL
2890The @option{-fstrict_flex_arrays} option interacts with the
2891@option{-Wstrict-flex-arrays} option. @xref{Warning Options}, for more
2892information.
2893
d77de738 2894@opindex fsso-struct
ddf6fe37 2895@item -fsso-struct=@var{endianness}
d77de738
ML
2896Set the default scalar storage order of structures and unions to the
2897specified endianness. The accepted values are @samp{big-endian},
2898@samp{little-endian} and @samp{native} for the native endianness of
2899the target (the default). This option is not supported for C++.
2900
2901@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2902code that is not binary compatible with code generated without it if the
2903specified endianness is not the native endianness of the target.
2904@end table
2905
2906@node C++ Dialect Options
2907@section Options Controlling C++ Dialect
2908
2909@cindex compiler options, C++
2910@cindex C++ options, command-line
2911@cindex options, C++
2912This section describes the command-line options that are only meaningful
2913for C++ programs. You can also use most of the GNU compiler options
2914regardless of what language your program is in. For example, you
2915might compile a file @file{firstClass.C} like this:
2916
2917@smallexample
2918g++ -g -fstrict-enums -O -c firstClass.C
2919@end smallexample
2920
2921@noindent
2922In this example, only @option{-fstrict-enums} is an option meant
2923only for C++ programs; you can use the other options with any
2924language supported by GCC@.
2925
2926Some options for compiling C programs, such as @option{-std}, are also
2927relevant for C++ programs.
2928@xref{C Dialect Options,,Options Controlling C Dialect}.
2929
2930Here is a list of options that are @emph{only} for compiling C++ programs:
2931
2932@table @gcctabopt
2933
d77de738 2934@opindex fabi-version
ddf6fe37 2935@item -fabi-version=@var{n}
d77de738
ML
2936Use version @var{n} of the C++ ABI@. The default is version 0.
2937
2938Version 0 refers to the version conforming most closely to
2939the C++ ABI specification. Therefore, the ABI obtained using version 0
2940will change in different versions of G++ as ABI bugs are fixed.
2941
2942Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2943
2944Version 2 is the version of the C++ ABI that first appeared in G++
29453.4, and was the default through G++ 4.9.
2946
2947Version 3 corrects an error in mangling a constant address as a
2948template argument.
2949
2950Version 4, which first appeared in G++ 4.5, implements a standard
2951mangling for vector types.
2952
2953Version 5, which first appeared in G++ 4.6, corrects the mangling of
2954attribute const/volatile on function pointer types, decltype of a
2955plain decl, and use of a function parameter in the declaration of
2956another parameter.
2957
2958Version 6, which first appeared in G++ 4.7, corrects the promotion
2959behavior of C++11 scoped enums and the mangling of template argument
2960packs, const/static_cast, prefix ++ and --, and a class scope function
2961used as a template argument.
2962
2963Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2964builtin type and corrects the mangling of lambdas in default argument
2965scope.
2966
2967Version 8, which first appeared in G++ 4.9, corrects the substitution
2968behavior of function types with function-cv-qualifiers.
2969
2970Version 9, which first appeared in G++ 5.2, corrects the alignment of
2971@code{nullptr_t}.
2972
2973Version 10, which first appeared in G++ 6.1, adds mangling of
2974attributes that affect type identity, such as ia32 calling convention
2975attributes (e.g.@: @samp{stdcall}).
2976
2977Version 11, which first appeared in G++ 7, corrects the mangling of
2978sizeof... expressions and operator names. For multiple entities with
2979the same name within a function, that are declared in different scopes,
2980the mangling now changes starting with the twelfth occurrence. It also
2981implies @option{-fnew-inheriting-ctors}.
2982
2983Version 12, which first appeared in G++ 8, corrects the calling
2984conventions for empty classes on the x86_64 target and for classes
2985with only deleted copy/move constructors. It accidentally changes the
2986calling convention for classes with a deleted copy constructor and a
2987trivial move constructor.
2988
2989Version 13, which first appeared in G++ 8.2, fixes the accidental
2990change in version 12.
2991
2992Version 14, which first appeared in G++ 10, corrects the mangling of
2993the nullptr expression.
2994
2995Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2996tag regression.
2997
2998Version 16, which first appeared in G++ 11, changes the mangling of
2999@code{__alignof__} to be distinct from that of @code{alignof}, and
3000dependent operator names.
3001
3002Version 17, which first appeared in G++ 12, fixes layout of classes
3003that inherit from aggregate classes with default member initializers
3004in C++14 and up.
3005
b9857b78 3006Version 18, which first appeared in G++ 13, fixes manglings of lambdas
d77de738
ML
3007that have additional context.
3008
87c44600
JM
3009Version 19, which first appeared in G++ 14, fixes manglings of
3010structured bindings to include ABI tags, handling of cv-qualified
3011[[no_unique_address]] members, and adds mangling of C++20 constraints
3012on function templates.
cd37325b 3013
685c458f
NS
3014Version 20, which first appeared in G++ 15, fixes manglings of lambdas
3015in static data member initializers.
3016
87c44600 3017Version 21, which first appeared in G++ 16, fixes unnecessary captures
e6e3b077
JM
3018in noexcept lambdas (c++/119764) and layout of a base class
3019with all explicitly defaulted constructors (c++/120012).
87c44600 3020
d77de738
ML
3021See also @option{-Wabi}.
3022
d77de738 3023@opindex fabi-compat-version
ddf6fe37 3024@item -fabi-compat-version=@var{n}
d77de738
ML
3025On targets that support strong aliases, G++
3026works around mangling changes by creating an alias with the correct
3027mangled name when defining a symbol with an incorrect mangled name.
3028This switch specifies which ABI version to use for the alias.
3029
3030With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3031compatibility). If another ABI version is explicitly selected, this
3032defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3033use @option{-fabi-compat-version=2}.
3034
3035If this option is not provided but @option{-Wabi=@var{n}} is, that
3036version is used for compatibility aliases. If this option is provided
3037along with @option{-Wabi} (without the version), the version from this
3038option is used for the warning.
3039
d77de738
ML
3040@opindex fno-access-control
3041@opindex faccess-control
ddf6fe37 3042@item -fno-access-control
d77de738
ML
3043Turn off all access checking. This switch is mainly useful for working
3044around bugs in the access control code.
3045
d77de738 3046@opindex faligned-new
ddf6fe37 3047@item -faligned-new
d77de738
ML
3048Enable support for C++17 @code{new} of types that require more
3049alignment than @code{void* ::operator new(std::size_t)} provides. A
3050numeric argument such as @code{-faligned-new=32} can be used to
3051specify how much alignment (in bytes) is provided by that function,
3052but few users will need to override the default of
3053@code{alignof(std::max_align_t)}.
3054
3055This flag is enabled by default for @option{-std=c++17}.
3056
27778979
JJ
3057@opindex fno-assume-sane-operators-new-delete
3058@opindex fassume-sane-operators-new-delete
3059@item -fno-assume-sane-operators-new
3060The C++ standard allows replacing the global @code{new}, @code{new[]},
3061@code{delete} and @code{delete[]} operators, though a lot of C++ programs
3062don't replace them and just use the implementation provided version.
3063Furthermore, the C++ standard allows omitting those calls if they are
3064made from new or delete expressions (and by extension the same is
3065assumed if @code{__builtin_operator_new} or @code{__builtin_operator_delete}
3066functions are used).
3067This option allows control over some optimizations around calls
3068to those operators.
3069With @code{-fassume-sane-operators-new-delete} option GCC may assume that
3070calls to the replaceable global operators from new or delete expressions or
3071from @code{__builtin_operator_new} or @code{__builtin_operator_delete} calls
3072don't read or modify any global variables or variables whose address could
3073escape to the operators (global state; except for @code{errno} for the
3074@code{new} and @code{new[]} operators).
3075This allows most optimizations across those calls and is something that
3076the implementation provided operators satisfy unless @code{malloc}
3077implementation details are observable in the code or unless @code{malloc}
3078hooks are used, but might not be satisfied if a program replaces those
3079operators. This behavior is enabled by default.
3080With @code{-fno-assume-sane-operators-new-delete} option GCC must
3081assume all these calls (whether from new or delete expressions or called
3082directly) may read and write global state unless proven otherwise (e.g.@:
3083when GCC compiles their implementation). Use this option if those
3084operators are or may be replaced and code needs to expect such behavior.
3085
d77de738
ML
3086@opindex fchar8_t
3087@opindex fno-char8_t
ddf6fe37
AA
3088@item -fchar8_t
3089@itemx -fno-char8_t
d77de738
ML
3090Enable support for @code{char8_t} as adopted for C++20. This includes
3091the addition of a new @code{char8_t} fundamental type, changes to the
3092types of UTF-8 string and character literals, new signatures for
3093user-defined literals, associated standard library updates, and new
3094@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3095
3096This option enables functions to be overloaded for ordinary and UTF-8
3097strings:
3098
3099@smallexample
3100int f(const char *); // #1
3101int f(const char8_t *); // #2
3102int v1 = f("text"); // Calls #1
3103int v2 = f(u8"text"); // Calls #2
3104@end smallexample
3105
3106@noindent
3107and introduces new signatures for user-defined literals:
3108
3109@smallexample
3110int operator""_udl1(char8_t);
3111int v3 = u8'x'_udl1;
3112int operator""_udl2(const char8_t*, std::size_t);
3113int v4 = u8"text"_udl2;
3114template<typename T, T...> int operator""_udl3();
3115int v5 = u8"text"_udl3;
3116@end smallexample
3117
3118@noindent
3119The change to the types of UTF-8 string and character literals introduces
3120incompatibilities with ISO C++11 and later standards. For example, the
3121following code is well-formed under ISO C++11, but is ill-formed when
3122@option{-fchar8_t} is specified.
3123
3124@smallexample
d77de738
ML
3125const char *cp = u8"xx";// error: invalid conversion from
3126 // `const char8_t*' to `const char*'
3127int f(const char*);
3128auto v = f(u8"xx"); // error: invalid conversion from
3129 // `const char8_t*' to `const char*'
3130std::string s@{u8"xx"@}; // error: no matching function for call to
3131 // `std::basic_string<char>::basic_string()'
3132using namespace std::literals;
3133s = u8"xx"s; // error: conversion from
3134 // `basic_string<char8_t>' to non-scalar
3135 // type `basic_string<char>' requested
3136@end smallexample
3137
d77de738 3138@opindex fcheck-new
ddf6fe37 3139@item -fcheck-new
d77de738
ML
3140Check that the pointer returned by @code{operator new} is non-null
3141before attempting to modify the storage allocated. This check is
3142normally unnecessary because the C++ standard specifies that
3143@code{operator new} only returns @code{0} if it is declared
3144@code{throw()}, in which case the compiler always checks the
3145return value even without this option. In all other cases, when
3146@code{operator new} has a non-empty exception specification, memory
3147exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3148@samp{new (nothrow)}.
3149
d77de738 3150@opindex fconcepts
ddf6fe37 3151@item -fconcepts
d77de738
ML
3152Enable support for the C++ Concepts feature for constraining template
3153arguments. With @option{-std=c++20} and above, Concepts are part of
3154the language standard, so @option{-fconcepts} defaults to on.
3155
3156Some constructs that were allowed by the earlier C++ Extensions for
3157Concepts Technical Specification, ISO 19217 (2015), but didn't make it
b3d4a021 3158into the standard, could additionally be enabled by
d836db14 3159@option{-fconcepts-ts}. The option @option{-fconcepts-ts} was deprecated
f0fb6b6a
MP
3160in GCC 14 and removed in GCC 15; users are expected to convert their code
3161to C++20 concepts.
d77de738 3162
d77de738 3163@opindex fconstexpr-depth
ddf6fe37 3164@item -fconstexpr-depth=@var{n}
d77de738
ML
3165Set the maximum nested evaluation depth for C++11 constexpr functions
3166to @var{n}. A limit is needed to detect endless recursion during
3167constant expression evaluation. The minimum specified by the standard
3168is 512.
3169
d77de738 3170@opindex fconstexpr-cache-depth
ddf6fe37 3171@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3172Set the maximum level of nested evaluation depth for C++11 constexpr
3173functions that will be cached to @var{n}. This is a heuristic that
3174trades off compilation speed (when the cache avoids repeated
3175calculations) against memory consumption (when the cache grows very
3176large from highly recursive evaluations). The default is 8. Very few
3177users are likely to want to adjust it, but if your code does heavy
3178constexpr calculations you might want to experiment to find which
3179value works best for you.
3180
d77de738 3181@opindex fconstexpr-fp-except
ddf6fe37 3182@item -fconstexpr-fp-except
d77de738
ML
3183Annex F of the C standard specifies that IEC559 floating point
3184exceptions encountered at compile time should not stop compilation.
3185C++ compilers have historically not followed this guidance, instead
3186treating floating point division by zero as non-constant even though
3187it has a well defined value. This flag tells the compiler to give
3188Annex F priority over other rules saying that a particular operation
3189is undefined.
3190
3191@smallexample
3192constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3193@end smallexample
3194
d77de738 3195@opindex fconstexpr-loop-limit
ddf6fe37 3196@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3197Set the maximum number of iterations for a loop in C++14 constexpr functions
3198to @var{n}. A limit is needed to detect infinite loops during
3199constant expression evaluation. The default is 262144 (1<<18).
3200
d77de738 3201@opindex fconstexpr-ops-limit
ddf6fe37 3202@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3203Set the maximum number of operations during a single constexpr evaluation.
3204Even when number of iterations of a single loop is limited with the above limit,
3205if there are several nested loops and each of them has many iterations but still
3206smaller than the above limit, or if in a body of some loop or even outside
3207of a loop too many expressions need to be evaluated, the resulting constexpr
3208evaluation might take too long.
3209The default is 33554432 (1<<25).
3210
2efb237f 3211@opindex fcontracts
ddf6fe37 3212@item -fcontracts
2efb237f
JCI
3213Enable experimental support for the C++ Contracts feature, as briefly
3214added to and then removed from the C++20 working paper (N4820). The
3215implementation also includes proposed enhancements from papers P1290,
3216P1332, and P1429. This functionality is intended mostly for those
3217interested in experimentation towards refining the feature to get it
3218into shape for a future C++ standard.
3219
3220On violation of a checked contract, the violation handler is called.
3221Users can replace the violation handler by defining
3222@smallexample
4ace81b6
SL
3223void
3224handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3225@end smallexample
3226
3227There are different sets of additional flags that can be used together
3228to specify which contracts will be checked and how, for N4820
3229contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3230used together.
3231
3232@table @gcctabopt
2efb237f 3233@opindex fcontract-mode
ddf6fe37 3234@item -fcontract-mode=[on|off]
2efb237f
JCI
3235Control whether any contracts have any semantics at all. Defaults to on.
3236
2efb237f 3237@opindex fcontract-assumption-mode
ddf6fe37 3238@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3239[N4820] Control whether contracts with level @samp{axiom}
3240should have the assume semantic. Defaults to on.
3241
2efb237f 3242@opindex fcontract-build-level
ddf6fe37 3243@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3244[N4820] Specify which level of contracts to generate checks
3245for. Defaults to @samp{default}.
3246
2efb237f 3247@opindex fcontract-continuation-mode
ddf6fe37 3248@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3249[N4820] Control whether to allow the program to continue executing
3250after a contract violation. That is, do checked contracts have the
3251@samp{maybe} semantic described below rather than the @samp{never}
3252semantic. Defaults to off.
3253
2efb237f 3254@opindex fcontract-role
ddf6fe37 3255@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3256[P1332] Specify the concrete semantics for each contract level
3257of a particular contract role.
3258
3259@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3260[P1429] Specify the concrete semantic for a particular
3261contract level.
3262
2efb237f 3263@opindex fcontract-strict-declarations
ddf6fe37 3264@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3265Control whether to reject adding contracts to a function after its
3266first declaration. Defaults to off.
3267@end table
3268
3269The possible concrete semantics for that can be specified with
3270@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3271
3272@table @code
3273@item ignore
3274This contract has no effect.
3275
3276@item assume
3277This contract is treated like C++23 @code{[[assume]]}.
3278
3279@item check_never_continue
3280@itemx never
3281@itemx abort
3282This contract is checked. If it fails, the violation handler is
3283called. If the handler returns, @code{std::terminate} is called.
3284
3285@item check_maybe_continue
3286@itemx maybe
3287This contract is checked. If it fails, the violation handler is
3288called. If the handler returns, execution continues normally.
3289@end table
3290
d77de738 3291@opindex fcoroutines
ddf6fe37 3292@item -fcoroutines
d77de738
ML
3293Enable support for the C++ coroutines extension (experimental).
3294
d6840b31
PP
3295@opindex fdiagnostics-all-candidates
3296@item -fdiagnostics-all-candidates
3297Permit the C++ front end to note all candidates during overload resolution
3298failure, including when a deleted function is selected.
3299
f59ff19b
JM
3300@item -fdump-lang-
3301@itemx -fdump-lang-@var{switch}
3302@itemx -fdump-lang-@var{switch}-@var{options}
3303@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
3304Control the dumping of C++-specific information. The @var{options}
3305and @var{filename} portions behave as described in the
3306@option{-fdump-tree} option. The following @var{switch} values are
3307accepted:
3308
3309@table @samp
3310@item all
3311Enable all of the below.
3312
3313@opindex fdump-lang-class
3314@item class
3315Dump class hierarchy information. Virtual table information is emitted
3316unless '@option{slim}' is specified.
3317
3318@opindex fdump-lang-module
3319@item module
3320Dump module information. Options @option{lineno} (locations),
3321@option{graph} (reachability), @option{blocks} (clusters),
3322@option{uid} (serialization), @option{alias} (mergeable),
3323@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
3324(macros) may provide additional information.
3325
3326@opindex fdump-lang-raw
3327@item raw
3328Dump the raw internal tree data.
3329
3330@opindex fdump-lang-tinst
3331@item tinst
3332Dump the sequence of template instantiations, indented to show the
3333depth of recursion. The @option{lineno} option adds the source
3334location where the instantiation was triggered, and the
3335@option{details} option also dumps pre-instantiation substitutions
3336such as those performed during template argument deduction.
3337
3338Lines in the .tinst dump start with @samp{I} for an instantiation,
3339@samp{S} for another substitution, and @samp{R[IS]} for the reopened
3340context of a deferred instantiation.
3341
3342@end table
3343
d77de738
ML
3344@opindex fno-elide-constructors
3345@opindex felide-constructors
ddf6fe37 3346@item -fno-elide-constructors
d77de738
ML
3347The C++ standard allows an implementation to omit creating a temporary
3348that is only used to initialize another object of the same type.
3349Specifying this option disables that optimization, and forces G++ to
3350call the copy constructor in all cases. This option also causes G++
3351to call trivial member functions which otherwise would be expanded inline.
3352
3353In C++17, the compiler is required to omit these temporaries, but this
3354option still affects trivial member functions.
3355
d77de738
ML
3356@opindex fno-enforce-eh-specs
3357@opindex fenforce-eh-specs
ddf6fe37 3358@item -fno-enforce-eh-specs
d77de738
ML
3359Don't generate code to check for violation of exception specifications
3360at run time. This option violates the C++ standard, but may be useful
3361for reducing code size in production builds, much like defining
3362@code{NDEBUG}. This does not give user code permission to throw
3363exceptions in violation of the exception specifications; the compiler
3364still optimizes based on the specifications, so throwing an
3365unexpected exception results in undefined behavior at run time.
3366
d77de738
ML
3367@opindex fextern-tls-init
3368@opindex fno-extern-tls-init
ddf6fe37
AA
3369@item -fextern-tls-init
3370@itemx -fno-extern-tls-init
d77de738
ML
3371The C++11 and OpenMP standards allow @code{thread_local} and
3372@code{threadprivate} variables to have dynamic (runtime)
3373initialization. To support this, any use of such a variable goes
3374through a wrapper function that performs any necessary initialization.
3375When the use and definition of the variable are in the same
3376translation unit, this overhead can be optimized away, but when the
3377use is in a different translation unit there is significant overhead
3378even if the variable doesn't actually need dynamic initialization. If
3379the programmer can be sure that no use of the variable in a
3380non-defining TU needs to trigger dynamic initialization (either
3381because the variable is statically initialized, or a use of the
3382variable in the defining TU will be executed before any uses in
3383another TU), they can avoid this overhead with the
3384@option{-fno-extern-tls-init} option.
3385
3386On targets that support symbol aliases, the default is
3387@option{-fextern-tls-init}. On targets that do not support symbol
3388aliases, the default is @option{-fno-extern-tls-init}.
3389
d77de738
ML
3390@opindex ffold-simple-inlines
3391@opindex fno-fold-simple-inlines
ddf6fe37
AA
3392@item -ffold-simple-inlines
3393@itemx -fno-fold-simple-inlines
d77de738 3394Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
fa365450
VV
3395@code{std::addressof}, @code{std::to_underlying}
3396and @code{std::as_const}. In contrast to inlining, this
d77de738
ML
3397means no debug information will be generated for such calls. Since these
3398functions are rarely interesting to debug, this flag is enabled by default
3399unless @option{-fno-inline} is active.
3400
d77de738
ML
3401@opindex fno-gnu-keywords
3402@opindex fgnu-keywords
ddf6fe37 3403@item -fno-gnu-keywords
d77de738
ML
3404Do not recognize @code{typeof} as a keyword, so that code can use this
3405word as an identifier. You can use the keyword @code{__typeof__} instead.
3406This option is implied by the strict ISO C++ dialects: @option{-ansi},
3407@option{-std=c++98}, @option{-std=c++11}, etc.
3408
1f1c4322
MP
3409@opindex fno-immediate-escalation
3410@opindex fimmediate-escalation
3411@item -fno-immediate-escalation
3412Do not enable immediate function escalation whereby certain functions
3413can be promoted to consteval, as specified in P2564R3. For example:
3414
3415@example
3416consteval int id(int i) @{ return i; @}
3417
3418constexpr int f(auto t)
3419@{
3420 return t + id(t); // id causes f<int> to be promoted to consteval
3421@}
3422
3423void g(int i)
3424@{
3425 f (3);
3426@}
3427@end example
3428
3429compiles in C++20: @code{f} is an immediate-escalating function (due to
3430the @code{auto} it is a function template and is declared @code{constexpr})
3431and @code{id(t)} is an immediate-escalating expression, so @code{f} is
3432promoted to @code{consteval}. Consequently, the call to @code{id(t)}
3433is in an immediate context, so doesn't have to produce a constant (that
3434is the mechanism allowing consteval function composition). However,
3435with @option{-fno-immediate-escalation}, @code{f} is not promoted to
3436@code{consteval}, and since the call to consteval function @code{id(t)}
3437is not a constant expression, the compiler rejects the code.
3438
3439This option is turned on by default; it is only effective in C++20 mode
3440or later.
3441
d77de738 3442@opindex fimplicit-constexpr
ddf6fe37 3443@item -fimplicit-constexpr
d77de738
ML
3444Make inline functions implicitly constexpr, if they satisfy the
3445requirements for a constexpr function. This option can be used in
3446C++14 mode or later. This can result in initialization changing from
3447dynamic to static and other optimizations.
3448
d77de738
ML
3449@opindex fno-implicit-templates
3450@opindex fimplicit-templates
ddf6fe37 3451@item -fno-implicit-templates
d77de738
ML
3452Never emit code for non-inline templates that are instantiated
3453implicitly (i.e.@: by use); only emit code for explicit instantiations.
3454If you use this option, you must take care to structure your code to
3455include all the necessary explicit instantiations to avoid getting
3456undefined symbols at link time.
3457@xref{Template Instantiation}, for more information.
3458
d77de738
ML
3459@opindex fno-implicit-inline-templates
3460@opindex fimplicit-inline-templates
ddf6fe37 3461@item -fno-implicit-inline-templates
d77de738
ML
3462Don't emit code for implicit instantiations of inline templates, either.
3463The default is to handle inlines differently so that compiles with and
3464without optimization need the same set of explicit instantiations.
3465
d77de738
ML
3466@opindex fno-implement-inlines
3467@opindex fimplement-inlines
ddf6fe37 3468@item -fno-implement-inlines
d77de738
ML
3469To save space, do not emit out-of-line copies of inline functions
3470controlled by @code{#pragma implementation}. This causes linker
3471errors if these functions are not inlined everywhere they are called.
3472
d9c3c3c8
JM
3473@opindex fmodules
3474@opindex fno-modules
3475@item -fmodules
3476@itemx -fno-modules
d77de738 3477Enable support for C++20 modules (@pxref{C++ Modules}). The
d9c3c3c8 3478@option{-fno-modules} is usually not needed, as that is the
d77de738
ML
3479default. Even though this is a C++20 feature, it is not currently
3480implicitly enabled by selecting that standard version.
3481
ddf6fe37 3482@opindex fmodule-header
d77de738
ML
3483@item -fmodule-header
3484@itemx -fmodule-header=user
3485@itemx -fmodule-header=system
d77de738
ML
3486Compile a header file to create an importable header unit.
3487
d77de738 3488@opindex fmodule-implicit-inline
ddf6fe37 3489@item -fmodule-implicit-inline
d77de738
ML
3490Member functions defined in their class definitions are not implicitly
3491inline for modular code. This is different to traditional C++
3492behavior, for good reasons. However, it may result in a difficulty
3493during code porting. This option makes such function definitions
3494implicitly inline. It does however generate an ABI incompatibility,
3495so you must use it everywhere or nowhere. (Such definitions outside
3496of a named module remain implicitly inline, regardless.)
3497
d77de738
ML
3498@opindex fno-module-lazy
3499@opindex fmodule-lazy
ddf6fe37 3500@item -fno-module-lazy
d77de738
ML
3501Disable lazy module importing and module mapper creation.
3502
f33d7a88
AA
3503@vindex CXX_MODULE_MAPPER @r{environment variable}
3504@opindex fmodule-mapper
d77de738
ML
3505@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3506@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3507@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3508@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3509@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3510@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3511An oracle to query for module name to filename mappings. If
3512unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3513and if that is unset, an in-process default is provided.
3514
d77de738 3515@opindex fmodule-only
ddf6fe37 3516@item -fmodule-only
d77de738
ML
3517Only emit the Compiled Module Interface, inhibiting any object file.
3518
d77de738 3519@opindex fms-extensions
ddf6fe37 3520@item -fms-extensions
d77de738
ML
3521Disable Wpedantic warnings about constructs used in MFC, such as implicit
3522int and getting a pointer to member function via non-standard syntax.
3523
d77de738 3524@opindex fnew-inheriting-ctors
ddf6fe37 3525@item -fnew-inheriting-ctors
d77de738
ML
3526Enable the P0136 adjustment to the semantics of C++11 constructor
3527inheritance. This is part of C++17 but also considered to be a Defect
3528Report against C++11 and C++14. This flag is enabled by default
3529unless @option{-fabi-version=10} or lower is specified.
3530
d77de738 3531@opindex fnew-ttp-matching
ddf6fe37 3532@item -fnew-ttp-matching
d77de738
ML
3533Enable the P0522 resolution to Core issue 150, template template
3534parameters and default arguments: this allows a template with default
3535template arguments as an argument for a template template parameter
3536with fewer template parameters. This flag is enabled by default for
3537@option{-std=c++17}.
3538
d77de738
ML
3539@opindex fno-nonansi-builtins
3540@opindex fnonansi-builtins
ddf6fe37 3541@item -fno-nonansi-builtins
d77de738
ML
3542Disable built-in declarations of functions that are not mandated by
3543ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3544@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3545
d77de738 3546@opindex fnothrow-opt
ddf6fe37 3547@item -fnothrow-opt
d77de738
ML
3548Treat a @code{throw()} exception specification as if it were a
3549@code{noexcept} specification to reduce or eliminate the text size
3550overhead relative to a function with no exception specification. If
3551the function has local variables of types with non-trivial
3552destructors, the exception specification actually makes the
3553function smaller because the EH cleanups for those variables can be
3554optimized away. The semantic effect is that an exception thrown out of
3555a function with such an exception specification results in a call
3556to @code{terminate} rather than @code{unexpected}.
3557
d77de738
ML
3558@opindex fno-operator-names
3559@opindex foperator-names
ddf6fe37 3560@item -fno-operator-names
d77de738
ML
3561Do not treat the operator name keywords @code{and}, @code{bitand},
3562@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3563synonyms as keywords.
3564
d77de738
ML
3565@opindex fno-optional-diags
3566@opindex foptional-diags
ddf6fe37 3567@item -fno-optional-diags
d77de738
ML
3568Disable diagnostics that the standard says a compiler does not need to
3569issue. Currently, the only such diagnostic issued by G++ is the one for
3570a name having multiple meanings within a class.
3571
d77de738
ML
3572@opindex fno-pretty-templates
3573@opindex fpretty-templates
ddf6fe37 3574@item -fno-pretty-templates
d77de738
ML
3575When an error message refers to a specialization of a function
3576template, the compiler normally prints the signature of the
3577template followed by the template arguments and any typedefs or
3578typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3579rather than @code{void f(int)}) so that it's clear which template is
3580involved. When an error message refers to a specialization of a class
3581template, the compiler omits any template arguments that match
3582the default template arguments for that template. If either of these
3583behaviors make it harder to understand the error message rather than
3584easier, you can use @option{-fno-pretty-templates} to disable them.
3585
650e9156
JJ
3586@opindex frange-for-ext-temps
3587@item -frange-for-ext-temps
3588Enable lifetime extension of C++ range based for temporaries.
3589With @option{-std=c++23} and above this is part of the language standard,
3590so lifetime of the temporaries is extended until the end of the loop
556248d7
JM
3591by default. This option allows enabling that behavior also
3592in earlier versions of the standard.
650e9156 3593
d77de738
ML
3594@opindex fno-rtti
3595@opindex frtti
ddf6fe37 3596@item -fno-rtti
d77de738
ML
3597Disable generation of information about every class with virtual
3598functions for use by the C++ run-time type identification features
3599(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3600of the language, you can save some space by using this flag. Note that
3601exception handling uses the same information, but G++ generates it as
3602needed. The @code{dynamic_cast} operator can still be used for casts that
3603do not require run-time type information, i.e.@: casts to @code{void *} or to
3604unambiguous base classes.
3605
3606Mixing code compiled with @option{-frtti} with that compiled with
3607@option{-fno-rtti} may not work. For example, programs may
a0e64a04
PN
3608fail to link if a class compiled with @option{-fno-rtti} is used as a base
3609for a class compiled with @option{-frtti}.
d77de738 3610
d77de738 3611@opindex fsized-deallocation
ddf6fe37 3612@item -fsized-deallocation
d77de738
ML
3613Enable the built-in global declarations
3614@smallexample
3615void operator delete (void *, std::size_t) noexcept;
3616void operator delete[] (void *, std::size_t) noexcept;
3617@end smallexample
3618as introduced in C++14. This is useful for user-defined replacement
3619deallocation functions that, for example, use the size of the object
3620to make deallocation faster. Enabled by default under
3621@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3622warns about places that might want to add a definition.
3623
d77de738 3624@opindex fstrict-enums
ddf6fe37 3625@item -fstrict-enums
d77de738
ML
3626Allow the compiler to optimize using the assumption that a value of
3627enumerated type can only be one of the values of the enumeration (as
3628defined in the C++ standard; basically, a value that can be
3629represented in the minimum number of bits needed to represent all the
3630enumerators). This assumption may not be valid if the program uses a
3631cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3632This option has no effect for an enumeration type with a fixed underlying
3633type.
d77de738 3634
d77de738 3635@opindex fstrong-eval-order
ddf6fe37 3636@item -fstrong-eval-order
498933e5 3637@itemx -fstrong-eval-order=@var{kind}
d77de738
ML
3638Evaluate member access, array subscripting, and shift expressions in
3639left-to-right order, and evaluate assignment in right-to-left order,
498933e5
SL
3640as adopted for C++17. @option{-fstrong-eval-order} is equivalent to
3641@option{-fstrong-eval-order=all},
3642and is enabled by default with @option{-std=c++17} or later.
3643
d77de738 3644@option{-fstrong-eval-order=some} enables just the ordering of member
498933e5
SL
3645access and shift expressions, and is the default for C++ dialects prior to
3646C++17.
3647
3648@option{-fstrong-eval-order=none} is equivalent to
3649@option{-fno-strong-eval-order}.
d77de738 3650
d77de738 3651@opindex ftemplate-backtrace-limit
ddf6fe37 3652@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3653Set the maximum number of template instantiation notes for a single
3654warning or error to @var{n}. The default value is 10.
3655
d77de738 3656@opindex ftemplate-depth
ddf6fe37 3657@item -ftemplate-depth=@var{n}
d77de738
ML
3658Set the maximum instantiation depth for template classes to @var{n}.
3659A limit on the template instantiation depth is needed to detect
3660endless recursions during template class instantiation. ANSI/ISO C++
3661conforming programs must not rely on a maximum depth greater than 17
3662(changed to 1024 in C++11). The default value is 900, as the compiler
3663can run out of stack space before hitting 1024 in some situations.
3664
d77de738
ML
3665@opindex fno-threadsafe-statics
3666@opindex fthreadsafe-statics
ddf6fe37 3667@item -fno-threadsafe-statics
d77de738
ML
3668Do not emit the extra code to use the routines specified in the C++
3669ABI for thread-safe initialization of local statics. You can use this
3670option to reduce code size slightly in code that doesn't need to be
3671thread-safe.
3672
d77de738 3673@opindex fuse-cxa-atexit
ddf6fe37 3674@item -fuse-cxa-atexit
d77de738
ML
3675Register destructors for objects with static storage duration with the
3676@code{__cxa_atexit} function rather than the @code{atexit} function.
3677This option is required for fully standards-compliant handling of static
3678destructors, but only works if your C library supports
3679@code{__cxa_atexit}.
3680
d77de738
ML
3681@opindex fno-use-cxa-get-exception-ptr
3682@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3683@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3684Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3685causes @code{std::uncaught_exception} to be incorrect, but is necessary
3686if the runtime routine is not available.
3687
d77de738 3688@opindex fvisibility-inlines-hidden
ddf6fe37 3689@item -fvisibility-inlines-hidden
d77de738
ML
3690This switch declares that the user does not attempt to compare
3691pointers to inline functions or methods where the addresses of the two functions
3692are taken in different shared objects.
3693
3694The effect of this is that GCC may, effectively, mark inline methods with
3695@code{__attribute__ ((visibility ("hidden")))} so that they do not
3696appear in the export table of a DSO and do not require a PLT indirection
3697when used within the DSO@. Enabling this option can have a dramatic effect
3698on load and link times of a DSO as it massively reduces the size of the
3699dynamic export table when the library makes heavy use of templates.
3700
3701The behavior of this switch is not quite the same as marking the
3702methods as hidden directly, because it does not affect static variables
3703local to the function or cause the compiler to deduce that
3704the function is defined in only one shared object.
3705
3706You may mark a method as having a visibility explicitly to negate the
3707effect of the switch for that method. For example, if you do want to
3708compare pointers to a particular inline method, you might mark it as
3709having default visibility. Marking the enclosing class with explicit
3710visibility has no effect.
3711
3712Explicitly instantiated inline methods are unaffected by this option
3713as their linkage might otherwise cross a shared library boundary.
3714@xref{Template Instantiation}.
3715
d77de738 3716@opindex fvisibility-ms-compat
ddf6fe37 3717@item -fvisibility-ms-compat
d77de738
ML
3718This flag attempts to use visibility settings to make GCC's C++
3719linkage model compatible with that of Microsoft Visual Studio.
3720
3721The flag makes these changes to GCC's linkage model:
3722
3723@enumerate
3724@item
3725It sets the default visibility to @code{hidden}, like
3726@option{-fvisibility=hidden}.
3727
3728@item
3729Types, but not their members, are not hidden by default.
3730
3731@item
3732The One Definition Rule is relaxed for types without explicit
3733visibility specifications that are defined in more than one
3734shared object: those declarations are permitted if they are
3735permitted when this option is not used.
3736@end enumerate
3737
3738In new code it is better to use @option{-fvisibility=hidden} and
3739export those classes that are intended to be externally visible.
3740Unfortunately it is possible for code to rely, perhaps accidentally,
3741on the Visual Studio behavior.
3742
3743Among the consequences of these changes are that static data members
3744of the same type with the same name but defined in different shared
3745objects are different, so changing one does not change the other;
3746and that pointers to function members defined in different shared
3747objects may not compare equal. When this flag is given, it is a
3748violation of the ODR to define types with the same name differently.
3749
d77de738
ML
3750@opindex fno-weak
3751@opindex fweak
ddf6fe37 3752@item -fno-weak
d77de738
ML
3753Do not use weak symbol support, even if it is provided by the linker.
3754By default, G++ uses weak symbols if they are available. This
3755option exists only for testing, and should not be used by end-users;
3756it results in inferior code and has no benefits. This option may
3757be removed in a future release of G++.
3758
d77de738
ML
3759@opindex fext-numeric-literals
3760@opindex fno-ext-numeric-literals
ddf6fe37 3761@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3762Accept imaginary, fixed-point, or machine-defined
3763literal number suffixes as GNU extensions.
3764When this option is turned off these suffixes are treated
3765as C++11 user-defined literal numeric suffixes.
3766This is on by default for all pre-C++11 dialects and all GNU dialects:
3767@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3768@option{-std=gnu++14}.
3769This option is off by default
3770for ISO C++11 onwards (@option{-std=c++11}, ...).
3771
d77de738 3772@opindex nostdinc++
ddf6fe37 3773@item -nostdinc++
d77de738
ML
3774Do not search for header files in the standard directories specific to
3775C++, but do still search the other standard directories. (This option
3776is used when building the C++ library.)
3777
ddf6fe37
AA
3778@opindex flang-info-include-translate
3779@opindex flang-info-include-translate-not
d77de738
ML
3780@item -flang-info-include-translate
3781@itemx -flang-info-include-translate-not
3782@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3783Inform of include translation events. The first will note accepted
3784include translations, the second will note declined include
3785translations. The @var{header} form will inform of include
3786translations relating to that specific header. If @var{header} is of
3787the form @code{"user"} or @code{<system>} it will be resolved to a
3788specific user or system header using the include path.
3789
ddf6fe37 3790@opindex flang-info-module-cmi
d77de738
ML
3791@item -flang-info-module-cmi
3792@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3793Inform of Compiled Module Interface pathnames. The first will note
3794all read CMI pathnames. The @var{module} form will not reading a
3795specific module's CMI. @var{module} may be a named module or a
3796header-unit (the latter indicated by either being a pathname containing
3797directory separators or enclosed in @code{<>} or @code{""}).
3798
d77de738 3799@opindex stdlib
ddf6fe37 3800@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3801When G++ is configured to support this option, it allows specification of
3802alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3803(the default, native C++ runtime for G++) and @var{libc++} which is the
3804C++ runtime installed on some operating systems (e.g. Darwin versions from
3805Darwin11 onwards). The option switches G++ to use the headers from the
3806specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3807when a C++ runtime is required for linking.
3808@end table
3809
3810In addition, these warning options have meanings only for C++ programs:
3811
3812@table @gcctabopt
d77de738 3813@opindex Wabi-tag
ddf6fe37 3814@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3815Warn when a type with an ABI tag is used in a context that does not
3816have that ABI tag. See @ref{C++ Attributes} for more information
3817about ABI tags.
3818
d77de738
ML
3819@opindex Wcomma-subscript
3820@opindex Wno-comma-subscript
ddf6fe37 3821@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3822Warn about uses of a comma expression within a subscripting expression.
3823This usage was deprecated in C++20 and is going to be removed in C++23.
3824However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3825
3826@smallexample
3827@group
3828void f(int *a, int b, int c) @{
3829 a[b,c]; // deprecated in C++20, invalid in C++23
3830 a[(b,c)]; // OK
3831@}
3832@end group
3833@end smallexample
3834
3835In C++23 it is valid to have comma separated expressions in a subscript
3836when an overloaded subscript operator is found and supports the right
3837number and types of arguments. G++ will accept the formerly valid syntax
3838for code that is not valid in C++23 but used to be valid but deprecated
3839in C++20 with a pedantic warning that can be disabled with
3840@option{-Wno-comma-subscript}.
3841
dca2b479
JM
3842Enabled by default with @option{-std=c++20} unless
3843@option{-Wno-deprecated}, and after @option{-std=c++23} regardless of
3844@option{-Wno-deprecated}. Before @option{-std=c++20}, enabled with
3845explicit @option{-Wdeprecated}.
d77de738 3846
5fccebdb
JM
3847This warning is upgraded to an error by @option{-pedantic-errors} in
3848C++23 mode or later.
3849
d77de738
ML
3850@opindex Wctad-maybe-unsupported
3851@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3852@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3853Warn when performing class template argument deduction (CTAD) on a type with
3854no explicitly written deduction guides. This warning will point out cases
3855where CTAD succeeded only because the compiler synthesized the implicit
3856deduction guides, which might not be what the programmer intended. Certain
3857style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3858types that are designed to support CTAD. This warning can be suppressed with
3859the following pattern:
3860
3861@smallexample
3862struct allow_ctad_t; // any name works
3863template <typename T> struct S @{
3864 S(T) @{ @}
3865@};
4ace81b6
SL
3866// Guide with incomplete parameter type will never be considered.
3867S(allow_ctad_t) -> S<void>;
d77de738
ML
3868@end smallexample
3869
d77de738
ML
3870@opindex Wctor-dtor-privacy
3871@opindex Wno-ctor-dtor-privacy
ddf6fe37 3872@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3873Warn when a class seems unusable because all the constructors or
3874destructors in that class are private, and it has neither friends nor
3875public static member functions. Also warn if there are no non-private
3876methods, and there's at least one private member function that isn't
3877a constructor or destructor.
3878
d77de738
ML
3879@opindex Wdangling-reference
3880@opindex Wno-dangling-reference
ddf6fe37 3881@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3882Warn when a reference is bound to a temporary whose lifetime has ended.
3883For example:
3884
3885@smallexample
3886int n = 1;
3887const int& r = std::max(n - 1, n + 1); // r is dangling
3888@end smallexample
3889
3890In the example above, two temporaries are created, one for each
3891argument, and a reference to one of the temporaries is returned.
3892However, both temporaries are destroyed at the end of the full
3893expression, so the reference @code{r} is dangling. This warning
3894also detects dangling references in member initializer lists:
3895
3896@smallexample
3897const int& f(const int& i) @{ return i; @}
3898struct S @{
3899 const int &r; // r is dangling
3900 S() : r(f(10)) @{ @}
3901@};
3902@end smallexample
3903
3904Member functions are checked as well, but only their object argument:
3905
3906@smallexample
3907struct S @{
3908 const S& self () @{ return *this; @}
3909@};
3910const S& s = S().self(); // s is dangling
3911@end smallexample
3912
3913Certain functions are safe in this respect, for example @code{std::use_facet}:
3914they take and return a reference, but they don't return one of its arguments,
3915which can fool the warning. Such functions can be excluded from the warning
3916by wrapping them in a @code{#pragma}:
3917
3918@smallexample
3919#pragma GCC diagnostic push
3920#pragma GCC diagnostic ignored "-Wdangling-reference"
3921const T& foo (const T&) @{ @dots{} @}
3922#pragma GCC diagnostic pop
3923@end smallexample
3924
c7607c4c
MP
3925The @code{#pragma} can also surround the class; in that case, the warning
3926will be disabled for all the member functions.
3927
ce51e843
ML
3928@option{-Wdangling-reference} also warns about code like
3929
3930@smallexample
3931auto p = std::minmax(1, 2);
3932@end smallexample
3933
3934where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3935both references dangle after the end of the full expression that contains
3936the call to @code{std::minmax}.
3937
f2061b2a
MP
3938The warning does not warn for @code{std::span}-like classes. We consider
3939classes of the form:
3940
3941@smallexample
3942template<typename T>
3943struct Span @{
3944 T* data_;
3945 std::size len_;
3946@};
3947@end smallexample
3948
8efcdbf5 3949as @code{std::span}-like; that is, the class is a non-union class
f2061b2a
MP
3950that has a pointer data member and a trivial destructor.
3951
c7607c4c
MP
3952The warning can be disabled by using the @code{gnu::no_dangling} attribute
3953(@pxref{C++ Attributes}).
3954
5ebfaf2d 3955This warning is enabled by @option{-Wextra}.
d77de738 3956
d77de738
ML
3957@opindex Wdelete-non-virtual-dtor
3958@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3959@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3960Warn when @code{delete} is used to destroy an instance of a class that
3961has virtual functions and non-virtual destructor. It is unsafe to delete
3962an instance of a derived class through a pointer to a base class if the
3963base class does not have a virtual destructor. This warning is enabled
3964by @option{-Wall}.
3965
d77de738
ML
3966@opindex Wdeprecated-copy
3967@opindex Wno-deprecated-copy
ddf6fe37 3968@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3969Warn that the implicit declaration of a copy constructor or copy
3970assignment operator is deprecated if the class has a user-provided
3971copy constructor or copy assignment operator, in C++11 and up. This
3972warning is enabled by @option{-Wextra}. With
3973@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3974user-provided destructor.
3975
d77de738
ML
3976@opindex Wdeprecated-enum-enum-conversion
3977@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3978@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3979Disable the warning about the case when the usual arithmetic conversions
3980are applied on operands where one is of enumeration type and the other is
3981of a different enumeration type. This conversion was deprecated in C++20.
3982For example:
3983
3984@smallexample
3985enum E1 @{ e @};
3986enum E2 @{ f @};
3987int k = f - e;
3988@end smallexample
3989
3990@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3991@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
dca2b479 3992by @option{-Wenum-conversion} or @option{-Wdeprecated}.
d77de738 3993
d77de738
ML
3994@opindex Wdeprecated-enum-float-conversion
3995@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3996@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3997Disable the warning about the case when the usual arithmetic conversions
3998are applied on operands where one is of enumeration type and the other is
3999of a floating-point type. This conversion was deprecated in C++20. For
4000example:
4001
4002@smallexample
4003enum E1 @{ e @};
4004enum E2 @{ f @};
4005bool b = e <= 3.7;
4006@end smallexample
4007
4008@option{-Wdeprecated-enum-float-conversion} is enabled by default with
4009@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
dca2b479 4010by @option{-Wenum-conversion} or @option{-Wdeprecated}.
d77de738 4011
b6ff52a9
JM
4012@opindex Wdeprecated-literal-operator
4013@opindex Wno-deprecated-literal-operator
4014@item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)}
4015Warn that the declaration of a user-defined literal operator with a
4016space before the suffix is deprecated. This warning is enabled by
dca2b479 4017default in C++23, or with explicit @option{-Wdeprecated}.
b6ff52a9
JM
4018
4019@smallexample
4020string operator "" _i18n(const char*, std::size_t); // deprecated
4021string operator ""_i18n(const char*, std::size_t); // preferred
4022@end smallexample
4023
cc67d95d
JJ
4024@opindex Wdeprecated-variadic-comma-omission
4025@opindex Wno-deprecated-variadic-comma-omission
4026@item -Wdeprecated-variadic-comma-omission @r{(C++ and Objective-C++ only)}
4027Warn that omitting a comma before the varargs @code{...} at the end of
4028a function parameter list is deprecated. This warning is enabled by
4029default in C++26, or with explicit @option{-Wdeprecated}.
4030
4031@smallexample
4032void f1(int...); // deprecated
4033void f1(int, ...); // preferred
4034template <typename ...T>
4035void f2(T...); // ok
4036template <typename ...T>
4037void f3(T......); // deprecated
4038@end smallexample
4039
b106f11d
AC
4040@opindex Welaborated-enum-base
4041@opindex Wno-elaborated-enum-base
4042@item -Wno-elaborated-enum-base
4043For C++11 and above, warn if an (invalid) additional enum-base is used
4044in an elaborated-type-specifier. That is, if an enum with given
4045underlying type and no enumerator list is used in a declaration other
4046than just a standalone declaration of the enum. Enabled by default. This
4047warning is upgraded to an error with -pedantic-errors.
4048
d77de738
ML
4049@opindex Winit-list-lifetime
4050@opindex Wno-init-list-lifetime
ddf6fe37 4051@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
4052Do not warn about uses of @code{std::initializer_list} that are likely
4053to result in dangling pointers. Since the underlying array for an
4054@code{initializer_list} is handled like a normal C++ temporary object,
4055it is easy to inadvertently keep a pointer to the array past the end
4056of the array's lifetime. For example:
4057
4058@itemize @bullet
4059@item
4060If a function returns a temporary @code{initializer_list}, or a local
4061@code{initializer_list} variable, the array's lifetime ends at the end
4062of the return statement, so the value returned has a dangling pointer.
4063
4064@item
4065If a new-expression creates an @code{initializer_list}, the array only
4066lives until the end of the enclosing full-expression, so the
4067@code{initializer_list} in the heap has a dangling pointer.
4068
4069@item
4070When an @code{initializer_list} variable is assigned from a
4071brace-enclosed initializer list, the temporary array created for the
4072right side of the assignment only lives until the end of the
4073full-expression, so at the next statement the @code{initializer_list}
4074variable has a dangling pointer.
4075
4076@smallexample
4077// li's initial underlying array lives as long as li
4078std::initializer_list<int> li = @{ 1,2,3 @};
4079// assignment changes li to point to a temporary array
4080li = @{ 4, 5 @};
4081// now the temporary is gone and li has a dangling pointer
4082int i = li.begin()[0] // undefined behavior
4083@end smallexample
4084
4085@item
4086When a list constructor stores the @code{begin} pointer from the
4087@code{initializer_list} argument, this doesn't extend the lifetime of
4088the array, so if a class variable is constructed from a temporary
4089@code{initializer_list}, the pointer is left dangling by the end of
4090the variable declaration statement.
4091
4092@end itemize
4093
c85f8dbb
MP
4094@opindex Winvalid-constexpr
4095@opindex Wno-invalid-constexpr
ddf6fe37 4096@item -Winvalid-constexpr
c85f8dbb
MP
4097
4098Warn when a function never produces a constant expression. In C++20
4099and earlier, for every @code{constexpr} function and function template,
4100there must be at least one set of function arguments in at least one
4101instantiation such that an invocation of the function or constructor
4102could be an evaluated subexpression of a core constant expression.
4103C++23 removed this restriction, so it's possible to have a function
4104or a function template marked @code{constexpr} for which no invocation
4105satisfies the requirements of a core constant expression.
4106
4107This warning is enabled as a pedantic warning by default in C++20 and
4108earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
4109which case it will be an ordinary warning. For example:
4110
4111@smallexample
4112void f (int& i);
4113constexpr void
4114g (int& i)
4115@{
4ace81b6
SL
4116 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
4117 f(i);
c85f8dbb
MP
4118@}
4119@end smallexample
4120
d77de738
ML
4121@opindex Winvalid-imported-macros
4122@opindex Wno-invalid-imported-macros
ddf6fe37 4123@item -Winvalid-imported-macros
d77de738
ML
4124Verify all imported macro definitions are valid at the end of
4125compilation. This is not enabled by default, as it requires
4126additional processing to determine. It may be useful when preparing
4127sets of header-units to ensure consistent macros.
4128
d77de738
ML
4129@opindex Wliteral-suffix
4130@opindex Wno-literal-suffix
ddf6fe37 4131@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
4132Do not warn when a string or character literal is followed by a
4133ud-suffix which does not begin with an underscore. As a conforming
4134extension, GCC treats such suffixes as separate preprocessing tokens
4135in order to maintain backwards compatibility with code that uses
4136formatting macros from @code{<inttypes.h>}. For example:
4137
4138@smallexample
4139#define __STDC_FORMAT_MACROS
4140#include <inttypes.h>
4141#include <stdio.h>
4142
4143int main() @{
4144 int64_t i64 = 123;
4145 printf("My int64: %" PRId64"\n", i64);
4146@}
4147@end smallexample
4148
4149In this case, @code{PRId64} is treated as a separate preprocessing token.
4150
4151This option also controls warnings when a user-defined literal
4152operator is declared with a literal suffix identifier that doesn't
4153begin with an underscore. Literal suffix identifiers that don't begin
4154with an underscore are reserved for future standardization.
4155
4156These warnings are enabled by default.
4157
d77de738
ML
4158@opindex Wnarrowing
4159@opindex Wno-narrowing
ddf6fe37 4160@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
4161For C++11 and later standards, narrowing conversions are diagnosed by default,
4162as required by the standard. A narrowing conversion from a constant produces
4163an error, and a narrowing conversion from a non-constant produces a warning,
4164but @option{-Wno-narrowing} suppresses the diagnostic.
4165Note that this does not affect the meaning of well-formed code;
4166narrowing conversions are still considered ill-formed in SFINAE contexts.
4167
4168With @option{-Wnarrowing} in C++98, warn when a narrowing
4169conversion prohibited by C++11 occurs within
4170@samp{@{ @}}, e.g.
4171
4172@smallexample
4173int i = @{ 2.2 @}; // error: narrowing from double to int
4174@end smallexample
4175
4176This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4177
d77de738
ML
4178@opindex Wnoexcept
4179@opindex Wno-noexcept
ddf6fe37 4180@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
4181Warn when a noexcept-expression evaluates to false because of a call
4182to a function that does not have a non-throwing exception
4183specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4184the compiler to never throw an exception.
4185
d77de738
ML
4186@opindex Wnoexcept-type
4187@opindex Wno-noexcept-type
ddf6fe37 4188@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
4189Warn if the C++17 feature making @code{noexcept} part of a function
4190type changes the mangled name of a symbol relative to C++14. Enabled
4191by @option{-Wabi} and @option{-Wc++17-compat}.
4192
4193As an example:
4194
4195@smallexample
4196template <class T> void f(T t) @{ t(); @};
4197void g() noexcept;
a0e64a04 4198void h() @{ f(g); @}
d77de738
ML
4199@end smallexample
4200
4201@noindent
4202In C++14, @code{f} calls @code{f<void(*)()>}, but in
4203C++17 it calls @code{f<void(*)()noexcept>}.
4204
d77de738
ML
4205@opindex Wclass-memaccess
4206@opindex Wno-class-memaccess
ddf6fe37 4207@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4208Warn when the destination of a call to a raw memory function such as
4209@code{memset} or @code{memcpy} is an object of class type, and when writing
4210into such an object might bypass the class non-trivial or deleted constructor
4211or copy assignment, violate const-correctness or encapsulation, or corrupt
4212virtual table pointers. Modifying the representation of such objects may
4213violate invariants maintained by member functions of the class. For example,
4214the call to @code{memset} below is undefined because it modifies a non-trivial
4215class object and is, therefore, diagnosed. The safe way to either initialize
4216or clear the storage of objects of such types is by using the appropriate
4217constructor or assignment operator, if one is available.
4218@smallexample
4219std::string str = "abc";
4220memset (&str, 0, sizeof str);
4221@end smallexample
4222The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4223Explicitly casting the pointer to the class object to @code{void *} or
4224to a type that can be safely accessed by the raw memory function suppresses
4225the warning.
4226
d77de738
ML
4227@opindex Wnon-virtual-dtor
4228@opindex Wno-non-virtual-dtor
ddf6fe37 4229@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4230Warn when a class has virtual functions and an accessible non-virtual
4231destructor itself or in an accessible polymorphic base class, in which
4232case it is possible but unsafe to delete an instance of a derived
4233class through a pointer to the class itself or base class. This
4234warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4235The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4236should be preferred because it warns about the unsafe cases without false
4237positives.
d77de738 4238
d77de738
ML
4239@opindex Wregister
4240@opindex Wno-register
ddf6fe37 4241@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4242Warn on uses of the @code{register} storage class specifier, except
4243when it is part of the GNU @ref{Explicit Register Variables} extension.
4244The use of the @code{register} keyword as storage class specifier has
4245been deprecated in C++11 and removed in C++17.
4246Enabled by default with @option{-std=c++17}.
4247
d77de738
ML
4248@opindex Wreorder
4249@opindex Wno-reorder
4250@cindex reordering, warning
4251@cindex warning for reordering of member initializers
f33d7a88 4252@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4253Warn when the order of member initializers given in the code does not
4254match the order in which they must be executed. For instance:
4255
4256@smallexample
4257struct A @{
4258 int i;
4259 int j;
4260 A(): j (0), i (1) @{ @}
4261@};
4262@end smallexample
4263
4264@noindent
4265The compiler rearranges the member initializers for @code{i}
4266and @code{j} to match the declaration order of the members, emitting
4267a warning to that effect. This warning is enabled by @option{-Wall}.
4268
d77de738
ML
4269@opindex Wpessimizing-move
4270@opindex Wno-pessimizing-move
ddf6fe37 4271@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4272This warning warns when a call to @code{std::move} prevents copy
4273elision. A typical scenario when copy elision can occur is when returning in
4274a function with a class return type, when the expression being returned is the
4275name of a non-volatile automatic object, and is not a function parameter, and
4276has the same type as the function return type.
4277
4278@smallexample
4279struct T @{
4280@dots{}
4281@};
4282T fn()
4283@{
4284 T t;
4285 @dots{}
4286 return std::move (t);
4287@}
4288@end smallexample
4289
4290But in this example, the @code{std::move} call prevents copy elision.
4291
4292This warning is enabled by @option{-Wall}.
4293
d77de738
ML
4294@opindex Wredundant-move
4295@opindex Wno-redundant-move
ddf6fe37 4296@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4297This warning warns about redundant calls to @code{std::move}; that is, when
4298a move operation would have been performed even without the @code{std::move}
4299call. This happens because the compiler is forced to treat the object as if
4300it were an rvalue in certain situations such as returning a local variable,
4301where copy elision isn't applicable. Consider:
4302
4303@smallexample
4304struct T @{
4305@dots{}
4306@};
4307T fn(T t)
4308@{
4309 @dots{}
4310 return std::move (t);
4311@}
4312@end smallexample
4313
4314Here, the @code{std::move} call is redundant. Because G++ implements Core
4315Issue 1579, another example is:
4316
4317@smallexample
4318struct T @{ // convertible to U
4319@dots{}
4320@};
4321struct U @{
4322@dots{}
4323@};
4324U fn()
4325@{
4326 T t;
4327 @dots{}
4328 return std::move (t);
4329@}
4330@end smallexample
4331In this example, copy elision isn't applicable because the type of the
4332expression being returned and the function return type differ, yet G++
4333treats the return value as if it were designated by an rvalue.
4334
4335This warning is enabled by @option{-Wextra}.
4336
d77de738
ML
4337@opindex Wrange-loop-construct
4338@opindex Wno-range-loop-construct
ddf6fe37 4339@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4340This warning warns when a C++ range-based for-loop is creating an unnecessary
4341copy. This can happen when the range declaration is not a reference, but
4342probably should be. For example:
4343
4344@smallexample
4345struct S @{ char arr[128]; @};
4346void fn () @{
4347 S arr[5];
4348 for (const auto x : arr) @{ @dots{} @}
4349@}
4350@end smallexample
4351
4352It does not warn when the type being copied is a trivially-copyable type whose
4353size is less than 64 bytes.
4354
4355This warning also warns when a loop variable in a range-based for-loop is
4356initialized with a value of a different type resulting in a copy. For example:
4357
4358@smallexample
4359void fn() @{
4360 int arr[10];
4361 for (const double &x : arr) @{ @dots{} @}
4362@}
4363@end smallexample
4364
4365In the example above, in every iteration of the loop a temporary value of
4366type @code{double} is created and destroyed, to which the reference
4367@code{const double &} is bound.
4368
4369This warning is enabled by @option{-Wall}.
4370
d77de738
ML
4371@opindex Wredundant-tags
4372@opindex Wno-redundant-tags
ddf6fe37 4373@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4374Warn about redundant class-key and enum-key in references to class types
4375and enumerated types in contexts where the key can be eliminated without
4376causing an ambiguity. For example:
4377
4378@smallexample
4379struct foo;
4380struct foo *p; // warn that keyword struct can be eliminated
4381@end smallexample
4382
4383@noindent
4384On the other hand, in this example there is no warning:
4385
4386@smallexample
4387struct foo;
4388void foo (); // "hides" struct foo
4389void bar (struct foo&); // no warning, keyword struct is necessary
4390@end smallexample
4391
d77de738
ML
4392@opindex Wsubobject-linkage
4393@opindex Wno-subobject-linkage
ddf6fe37 4394@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4395Do not warn
4396if a class type has a base or a field whose type uses the anonymous
4397namespace or depends on a type with no linkage. If a type A depends on
4398a type B with no or internal linkage, defining it in multiple
4399translation units would be an ODR violation because the meaning of B
4400is different in each translation unit. If A only appears in a single
4401translation unit, the best way to silence the warning is to give it
4402internal linkage by putting it in an anonymous namespace as well. The
4403compiler doesn't give this warning for types defined in the main .C
4404file, as those are unlikely to have multiple definitions.
4405@option{-Wsubobject-linkage} is enabled by default.
4406
d77de738
ML
4407@opindex Weffc++
4408@opindex Wno-effc++
ddf6fe37 4409@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4410Warn about violations of the following style guidelines from Scott Meyers'
4411@cite{Effective C++} series of books:
4412
4413@itemize @bullet
4414@item
4415Define a copy constructor and an assignment operator for classes
4416with dynamically-allocated memory.
4417
4418@item
4419Prefer initialization to assignment in constructors.
4420
4421@item
4422Have @code{operator=} return a reference to @code{*this}.
4423
4424@item
4425Don't try to return a reference when you must return an object.
4426
4427@item
4428Distinguish between prefix and postfix forms of increment and
4429decrement operators.
4430
4431@item
4432Never overload @code{&&}, @code{||}, or @code{,}.
4433
4434@end itemize
4435
4436This option also enables @option{-Wnon-virtual-dtor}, which is also
4437one of the effective C++ recommendations. However, the check is
4438extended to warn about the lack of virtual destructor in accessible
4439non-polymorphic bases classes too.
4440
4441When selecting this option, be aware that the standard library
4442headers do not obey all of these guidelines; use @samp{grep -v}
4443to filter out those warnings.
4444
d77de738
ML
4445@opindex Wexceptions
4446@opindex Wno-exceptions
ddf6fe37 4447@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4448Disable the warning about the case when an exception handler is shadowed by
4449another handler, which can point out a wrong ordering of exception handlers.
4450
117782e0
JM
4451@opindex Wsfinae-incomplete
4452@opindex Wno-sfinae-incomplete
4453Warn about a class that is found to be incomplete, or a function with
4454auto return type that has not yet been deduced, in a context where
4455that causes substitution failure rather than an error, and then the
4456class or function is defined later in the translation unit. This is
4457problematic because template instantiations or concept checks could
4458have different results if they first occur either before or after the
4459definition.
4460
4461This warning is enabled by default. @option{-Wsfinae-incomplete=2}
4462adds a warning at the point of substitution failure, to make it easier
4463to track down problems flagged by the default mode.
4464
d77de738
ML
4465@opindex Wstrict-null-sentinel
4466@opindex Wno-strict-null-sentinel
ddf6fe37 4467@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4468Warn about the use of an uncasted @code{NULL} as sentinel. When
4469compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4470to @code{__null}. Although it is a null pointer constant rather than a
4471null pointer, it is guaranteed to be of the same size as a pointer.
4472But this use is not portable across different compilers.
4473
d77de738
ML
4474@opindex Wno-non-template-friend
4475@opindex Wnon-template-friend
ddf6fe37 4476@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4477Disable warnings when non-template friend functions are declared
4478within a template. In very old versions of GCC that predate implementation
a0e64a04 4479of the ISO standard, declarations such as
d77de738
ML
4480@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4481could be interpreted as a particular specialization of a template
a0e64a04 4482function; the warning exists to diagnose compatibility problems,
d77de738
ML
4483and is enabled by default.
4484
d77de738
ML
4485@opindex Wold-style-cast
4486@opindex Wno-old-style-cast
ddf6fe37 4487@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4488Warn if an old-style (C-style) cast to a non-void type is used within
4489a C++ program. The new-style casts (@code{dynamic_cast},
4490@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4491less vulnerable to unintended effects and much easier to search for.
4492
d77de738
ML
4493@opindex Woverloaded-virtual
4494@opindex Wno-overloaded-virtual
4495@cindex overloaded virtual function, warning
4496@cindex warning for overloaded virtual function
f33d7a88
AA
4497@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4498@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4499Warn when a function declaration hides virtual functions from a
4500base class. For example, in:
4501
4502@smallexample
4503struct A @{
4504 virtual void f();
4505@};
4506
4507struct B: public A @{
4508 void f(int); // does not override
4509@};
4510@end smallexample
4511
4512the @code{A} class version of @code{f} is hidden in @code{B}, and code
4513like:
4514
4515@smallexample
4516B* b;
4517b->f();
4518@end smallexample
4519
4520@noindent
4521fails to compile.
4522
d82490d5
JW
4523In cases where the different signatures are not an accident, the
4524simplest solution is to add a using-declaration to the derived class
4525to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4526
d77de738
ML
4527The optional level suffix controls the behavior when all the
4528declarations in the derived class override virtual functions in the
4529base class, even if not all of the base functions are overridden:
4530
4531@smallexample
4532struct C @{
4533 virtual void f();
4534 virtual void f(int);
4535@};
4536
4537struct D: public C @{
4538 void f(int); // does override
4539@}
4540@end smallexample
4541
4542This pattern is less likely to be a mistake; if D is only used
4543virtually, the user might have decided that the base class semantics
4544for some of the overloads are fine.
4545
4546At level 1, this case does not warn; at level 2, it does.
4547@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4548included in @option{-Wall}.
4549
d77de738
ML
4550@opindex Wno-pmf-conversions
4551@opindex Wpmf-conversions
ddf6fe37 4552@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4553Disable the diagnostic for converting a bound pointer to member function
4554to a plain pointer.
4555
d77de738
ML
4556@opindex Wsign-promo
4557@opindex Wno-sign-promo
ddf6fe37 4558@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4559Warn when overload resolution chooses a promotion from unsigned or
4560enumerated type to a signed type, over a conversion to an unsigned type of
4561the same size. Previous versions of G++ tried to preserve
4562unsignedness, but the standard mandates the current behavior.
4563
d77de738
ML
4564@opindex Wtemplates
4565@opindex Wno-templates
ddf6fe37 4566@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4567Warn when a primary template declaration is encountered. Some coding
4568rules disallow templates, and this may be used to enforce that rule.
4569The warning is inactive inside a system header file, such as the STL, so
4570one can still use the STL. One may also instantiate or specialize
4571templates.
4572
d77de738
ML
4573@opindex Wmismatched-new-delete
4574@opindex Wno-mismatched-new-delete
ddf6fe37 4575@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4576Warn for mismatches between calls to @code{operator new} or @code{operator
4577delete} and the corresponding call to the allocation or deallocation function.
4578This includes invocations of C++ @code{operator delete} with pointers
4579returned from either mismatched forms of @code{operator new}, or from other
4580functions that allocate objects for which the @code{operator delete} isn't
4581a suitable deallocator, as well as calls to other deallocation functions
4582with pointers returned from @code{operator new} for which the deallocation
4583function isn't suitable.
4584
4585For example, the @code{delete} expression in the function below is diagnosed
4586because it doesn't match the array form of the @code{new} expression
4587the pointer argument was returned from. Similarly, the call to @code{free}
4588is also diagnosed.
4589
4590@smallexample
4591void f ()
4592@{
4593 int *a = new int[n];
4594 delete a; // warning: mismatch in array forms of expressions
4595
4596 char *p = new char[n];
4597 free (p); // warning: mismatch between new and free
4598@}
4599@end smallexample
4600
4601The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4602involving allocation and deallocation functions other than @code{operator
4603new} and @code{operator delete}.
4604
4605@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4606
d77de738
ML
4607@opindex Wmismatched-tags
4608@opindex Wno-mismatched-tags
ddf6fe37 4609@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4610Warn for declarations of structs, classes, and class templates and their
4611specializations with a class-key that does not match either the definition
4612or the first declaration if no definition is provided.
4613
4614For example, the declaration of @code{struct Object} in the argument list
4615of @code{draw} triggers the warning. To avoid it, either remove the redundant
4616class-key @code{struct} or replace it with @code{class} to match its definition.
4617@smallexample
4618class Object @{
4619public:
4620 virtual ~Object () = 0;
4621@};
4622void draw (struct Object*);
4623@end smallexample
4624
4625It is not wrong to declare a class with the class-key @code{struct} as
4626the example above shows. The @option{-Wmismatched-tags} option is intended
4627to help achieve a consistent style of class declarations. In code that is
4628intended to be portable to Windows-based compilers the warning helps prevent
4629unresolved references due to the difference in the mangling of symbols
4630declared with different class-keys. The option can be used either on its
4631own or in conjunction with @option{-Wredundant-tags}.
4632
d77de738
ML
4633@opindex Wmultiple-inheritance
4634@opindex Wno-multiple-inheritance
ddf6fe37 4635@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4636Warn when a class is defined with multiple direct base classes. Some
4637coding rules disallow multiple inheritance, and this may be used to
4638enforce that rule. The warning is inactive inside a system header file,
4639such as the STL, so one can still use the STL. One may also define
4640classes that indirectly use multiple inheritance.
4641
d77de738
ML
4642@opindex Wvirtual-inheritance
4643@opindex Wno-virtual-inheritance
ddf6fe37 4644@item -Wvirtual-inheritance
d77de738
ML
4645Warn when a class is defined with a virtual direct base class. Some
4646coding rules disallow multiple inheritance, and this may be used to
4647enforce that rule. The warning is inactive inside a system header file,
4648such as the STL, so one can still use the STL. One may also define
4649classes that indirectly use virtual inheritance.
4650
d77de738
ML
4651@opindex Wvirtual-move-assign
4652@opindex Wno-virtual-move-assign
ddf6fe37 4653@item -Wno-virtual-move-assign
d77de738
ML
4654Suppress warnings about inheriting from a virtual base with a
4655non-trivial C++11 move assignment operator. This is dangerous because
4656if the virtual base is reachable along more than one path, it is
4657moved multiple times, which can mean both objects end up in the
4658moved-from state. If the move assignment operator is written to avoid
4659moving from a moved-from object, this warning can be disabled.
4660
d77de738
ML
4661@opindex Wnamespaces
4662@opindex Wno-namespaces
ddf6fe37 4663@item -Wnamespaces
d77de738
ML
4664Warn when a namespace definition is opened. Some coding rules disallow
4665namespaces, and this may be used to enforce that rule. The warning is
4666inactive inside a system header file, such as the STL, so one can still
4667use the STL. One may also use using directives and qualified names.
4668
596d1ed9
PP
4669@opindex Wtemplate-body
4670@opindex Wno-template-body
4671@item -Wno-template-body @r{(C++ and Objective-C++ only)}
4672Disable diagnosing errors when parsing a template, and instead issue an
4673error only upon instantiation of the template. This flag can also be
4674used to downgrade such errors into warnings with @option{Wno-error=} or
4675@option{-fpermissive}.
4676
cff174fa
MP
4677@opindex Wtemplate-id-cdtor
4678@opindex Wno-template-id-cdtor
4679@item -Wno-template-id-cdtor @r{(C++ and Objective-C++ only)}
4680Disable the warning about the use of simple-template-id as the declarator-id
4681of a constructor or destructor, which became invalid in C++20 via DR 2237.
4682For example:
4683
4684@smallexample
4685template<typename T> struct S @{
4686 S<T>(); // should be S();
4687 ~S<T>(); // should be ~S();
4688@};
4689@end smallexample
4690
4691@option{-Wtemplate-id-cdtor} is enabled by default with
4692@option{-std=c++20}; it is also enabled by @option{-Wc++20-compat}.
4693
0c2ae384
NS
4694@opindex Wtemplate-names-tu-local
4695@opindex Wno-template-names-tu-local
4696@item -Wtemplate-names-tu-local
4697Warn when a template body hides an exposure of a translation-unit-local
4698entity. In most cases, referring to a translation-unit-local entity
4699(such as an internal linkage declaration) within an entity that is
4700emitted into a module's CMI is an error. However, within the
4701initializer of a variable, or in the body of a non-inline function,
4702this is not an exposure and no error is emitted.
4703
4704This can cause variable or function templates to accidentally become
4705unusable if they reference such an entity, because other translation
4706units that import the template will never be able to instantiate it.
4707This warning attempts to detect cases where this might occur.
4708The presence of an explicit instantiation silences the warning.
4709
4710This flag is enabled by @option{-Wextra}.
4711
d77de738
ML
4712@opindex Wterminate
4713@opindex Wno-terminate
ddf6fe37 4714@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4715Disable the warning about a throw-expression that will immediately
4716result in a call to @code{terminate}.
4717
d77de738
ML
4718@opindex Wvexing-parse
4719@opindex Wno-vexing-parse
ddf6fe37 4720@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4721Warn about the most vexing parse syntactic ambiguity. This warns about
4722the cases when a declaration looks like a variable definition, but the
4723C++ language requires it to be interpreted as a function declaration.
4724For instance:
4725
4726@smallexample
4727void f(double a) @{
4728 int i(); // extern int i (void);
4729 int n(int(a)); // extern int n (int);
4730@}
4731@end smallexample
4732
4733Another example:
4734
4735@smallexample
4736struct S @{ S(int); @};
4737void f(double a) @{
4738 S x(int(a)); // extern struct S x (int);
4739 S y(int()); // extern struct S y (int (*) (void));
4740 S z(); // extern struct S z (void);
4741@}
4742@end smallexample
4743
4744The warning will suggest options how to deal with such an ambiguity; e.g.,
4745it can suggest removing the parentheses or using braces instead.
4746
4747This warning is enabled by default.
4748
d77de738
ML
4749@opindex Wno-class-conversion
4750@opindex Wclass-conversion
ddf6fe37 4751@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4752Do not warn when a conversion function converts an
4753object to the same type, to a base class of that type, or to void; such
4754a conversion function will never be called.
4755
d77de738
ML
4756@opindex Wvolatile
4757@opindex Wno-volatile
ddf6fe37 4758@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4759Warn about deprecated uses of the @code{volatile} qualifier. This includes
4760postfix and prefix @code{++} and @code{--} expressions of
4761@code{volatile}-qualified types, using simple assignments where the left
4762operand is a @code{volatile}-qualified non-class type for their value,
4763compound assignments where the left operand is a @code{volatile}-qualified
4764non-class type, @code{volatile}-qualified function return type,
4765@code{volatile}-qualified parameter type, and structured bindings of a
4766@code{volatile}-qualified type. This usage was deprecated in C++20.
4767
dca2b479
JM
4768Enabled by default with @option{-std=c++20}. Before
4769@option{-std=c++20}, enabled with explicit @option{-Wdeprecated}.
d77de738 4770
d77de738
ML
4771@opindex Waligned-new
4772@opindex Wno-aligned-new
ddf6fe37 4773@item -Waligned-new
d77de738
ML
4774Warn about a new-expression of a type that requires greater alignment
4775than the @code{alignof(std::max_align_t)} but uses an allocation
4776function without an explicit alignment parameter. This option is
4777enabled by @option{-Wall}.
4778
4779Normally this only warns about global allocation functions, but
4780@option{-Waligned-new=all} also warns about class member allocation
4781functions.
4782
d77de738
ML
4783@opindex Wplacement-new
4784@opindex Wno-placement-new
ddf6fe37
AA
4785@item -Wno-placement-new
4786@itemx -Wplacement-new=@var{n}
d77de738
ML
4787Warn about placement new expressions with undefined behavior, such as
4788constructing an object in a buffer that is smaller than the type of
4789the object. For example, the placement new expression below is diagnosed
4790because it attempts to construct an array of 64 integers in a buffer only
479164 bytes large.
4792@smallexample
4793char buf [64];
4794new (buf) int[64];
4795@end smallexample
4796This warning is enabled by default.
4797
4798@table @gcctabopt
4799@item -Wplacement-new=1
4800This is the default warning level of @option{-Wplacement-new}. At this
4801level the warning is not issued for some strictly undefined constructs that
4802GCC allows as extensions for compatibility with legacy code. For example,
4803the following @code{new} expression is not diagnosed at this level even
4804though it has undefined behavior according to the C++ standard because
4805it writes past the end of the one-element array.
4806@smallexample
4807struct S @{ int n, a[1]; @};
4808S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4809new (s->a)int [32]();
4810@end smallexample
4811
4812@item -Wplacement-new=2
4813At this level, in addition to diagnosing all the same constructs as at level
48141, a diagnostic is also issued for placement new expressions that construct
4815an object in the last member of structure whose type is an array of a single
4816element and whose size is less than the size of the object being constructed.
4817While the previous example would be diagnosed, the following construct makes
4818use of the flexible member array extension to avoid the warning at level 2.
4819@smallexample
4820struct S @{ int n, a[]; @};
4821S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4822new (s->a)int [32]();
4823@end smallexample
4824
4825@end table
4826
d77de738
ML
4827@opindex Wcatch-value
4828@opindex Wno-catch-value
ddf6fe37
AA
4829@item -Wcatch-value
4830@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4831Warn about catch handlers that do not catch via reference.
4832With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4833warn about polymorphic class types that are caught by value.
4834With @option{-Wcatch-value=2} warn about all class types that are caught
4835by value. With @option{-Wcatch-value=3} warn about all types that are
4836not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4837
d77de738
ML
4838@opindex Wconditionally-supported
4839@opindex Wno-conditionally-supported
ddf6fe37 4840@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4841Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4842
a2746e43
MP
4843@opindex Wdefaulted-function-deleted
4844@opindex Wno-defaulted-function-deleted
4845@item -Wno-defaulted-function-deleted @r{(C++ and Objective-C++ only)}
4846Warn when an explicitly defaulted function is deleted by the compiler.
4847That can occur when the function's declared type does not match the type
4848of the function that would have been implicitly declared. This warning
4849is enabled by default.
4850
d77de738
ML
4851@opindex Wdelete-incomplete
4852@opindex Wno-delete-incomplete
ddf6fe37 4853@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4854Do not warn when deleting a pointer to incomplete type, which may cause
4855undefined behavior at runtime. This warning is enabled by default.
4856
d77de738
ML
4857@opindex Wextra-semi
4858@opindex Wno-extra-semi
ddf6fe37 4859@item -Wextra-semi @r{(C++, Objective-C++ only)}
0b3eac4b
MP
4860Warn about redundant semicolons. There are various contexts in which an extra
4861semicolon can occur. One is a semicolon after in-class function definitions,
4862which is valid in all C++ dialects (and is never a pedwarn):
4863
4864@smallexample
4865struct S @{
4866 void foo () @{@};
4867@};
4868@end smallexample
4869
4870Another is an extra semicolon at namespace scope, which has been allowed
4871since C++11 (therefore is a pedwarn in C++98):
4872
4873@smallexample
4874struct S @{
4875@};
4876;
4877@end smallexample
4878
4879And yet another is an extra semicolon in class definitions, which has been
4880allowed since C++11 (therefore is a pedwarn in C++98):
4881
4882@smallexample
4883struct S @{
4884 int a;
4885 ;
4886@};
4887@end smallexample
d77de738 4888
08edf85f
PP
4889@opindex Wno-global-module
4890@opindex Wglobal-module
4891@item -Wno-global-module @r{(C++ and Objective-C++ only)}
4892Disable the diagnostic for when the global module fragment of a module
4893unit does not consist only of preprocessor directives.
4894
d77de738
ML
4895@opindex Winaccessible-base
4896@opindex Wno-inaccessible-base
ddf6fe37 4897@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4898This option controls warnings
4899when a base class is inaccessible in a class derived from it due to
4900ambiguity. The warning is enabled by default.
4901Note that the warning for ambiguous virtual
4902bases is enabled by the @option{-Wextra} option.
4903@smallexample
4904@group
4905struct A @{ int a; @};
4906
4907struct B : A @{ @};
4908
4909struct C : B, A @{ @};
4910@end group
4911@end smallexample
4912
d77de738
ML
4913@opindex Winherited-variadic-ctor
4914@opindex Wno-inherited-variadic-ctor
ddf6fe37 4915@item -Wno-inherited-variadic-ctor
d77de738
ML
4916Suppress warnings about use of C++11 inheriting constructors when the
4917base class inherited from has a C variadic constructor; the warning is
4918on by default because the ellipsis is not inherited.
4919
d77de738
ML
4920@opindex Wno-invalid-offsetof
4921@opindex Winvalid-offsetof
ddf6fe37 4922@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4923Suppress warnings from applying the @code{offsetof} macro to a non-POD
4924type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4925to a non-standard-layout type is undefined. In existing C++ implementations,
4926however, @code{offsetof} typically gives meaningful results.
4927This flag is for users who are aware that they are
4928writing nonportable code and who have deliberately chosen to ignore the
4929warning about it.
4930
4931The restrictions on @code{offsetof} may be relaxed in a future version
4932of the C++ standard.
4933
d77de738
ML
4934@opindex Wsized-deallocation
4935@opindex Wno-sized-deallocation
ddf6fe37 4936@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4937Warn about a definition of an unsized deallocation function
4938@smallexample
4939void operator delete (void *) noexcept;
4940void operator delete[] (void *) noexcept;
4941@end smallexample
4942without a definition of the corresponding sized deallocation function
4943@smallexample
4944void operator delete (void *, std::size_t) noexcept;
4945void operator delete[] (void *, std::size_t) noexcept;
4946@end smallexample
4947or vice versa. Enabled by @option{-Wextra} along with
4948@option{-fsized-deallocation}.
4949
d77de738
ML
4950@opindex Wno-suggest-final-types
4951@opindex Wsuggest-final-types
ddf6fe37 4952@item -Wsuggest-final-types
d77de738
ML
4953Warn about types with virtual methods where code quality would be improved
4954if the type were declared with the C++11 @code{final} specifier,
4955or, if possible,
4956declared in an anonymous namespace. This allows GCC to more aggressively
4957devirtualize the polymorphic calls. This warning is more effective with
4958link-time optimization,
4959where the information about the class hierarchy graph is
4960more complete.
4961
d77de738
ML
4962@opindex Wno-suggest-final-methods
4963@opindex Wsuggest-final-methods
ddf6fe37 4964@item -Wsuggest-final-methods
d77de738
ML
4965Warn about virtual methods where code quality would be improved if the method
4966were declared with the C++11 @code{final} specifier,
4967or, if possible, its type were
4968declared in an anonymous namespace or with the @code{final} specifier.
4969This warning is
4970more effective with link-time optimization, where the information about the
4971class hierarchy graph is more complete. It is recommended to first consider
4972suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4973annotations.
4974
d77de738
ML
4975@opindex Wsuggest-override
4976@opindex Wno-suggest-override
ddf6fe37 4977@item -Wsuggest-override
d77de738
ML
4978Warn about overriding virtual functions that are not marked with the
4979@code{override} keyword.
4980
d77de738
ML
4981@opindex Wconversion-null
4982@opindex Wno-conversion-null
ddf6fe37 4983@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4984Do not warn for conversions between @code{NULL} and non-pointer
4985types. @option{-Wconversion-null} is enabled by default.
4986
4987@end table
4988
4989@node Objective-C and Objective-C++ Dialect Options
4990@section Options Controlling Objective-C and Objective-C++ Dialects
4991
4992@cindex compiler options, Objective-C and Objective-C++
4993@cindex Objective-C and Objective-C++ options, command-line
4994@cindex options, Objective-C and Objective-C++
4995(NOTE: This manual does not describe the Objective-C and Objective-C++
4996languages themselves. @xref{Standards,,Language Standards
4997Supported by GCC}, for references.)
4998
4999This section describes the command-line options that are only meaningful
5000for Objective-C and Objective-C++ programs. You can also use most of
5001the language-independent GNU compiler options.
5002For example, you might compile a file @file{some_class.m} like this:
5003
5004@smallexample
5005gcc -g -fgnu-runtime -O -c some_class.m
5006@end smallexample
5007
5008@noindent
5009In this example, @option{-fgnu-runtime} is an option meant only for
5010Objective-C and Objective-C++ programs; you can use the other options with
5011any language supported by GCC@.
5012
5013Note that since Objective-C is an extension of the C language, Objective-C
5014compilations may also use options specific to the C front-end (e.g.,
5015@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
5016C++-specific options (e.g., @option{-Wabi}).
5017
5018Here is a list of options that are @emph{only} for compiling Objective-C
5019and Objective-C++ programs:
5020
5021@table @gcctabopt
d77de738 5022@opindex fconstant-string-class
ddf6fe37 5023@item -fconstant-string-class=@var{class-name}
d77de738
ML
5024Use @var{class-name} as the name of the class to instantiate for each
5025literal string specified with the syntax @code{@@"@dots{}"}. The default
5026class name is @code{NXConstantString} if the GNU runtime is being used, and
cdd4b3c0 5027@code{NSConstantString} if the NeXT runtime is being used (see below). On
a335cf24 5028Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
cdd4b3c0
IS
5029also present, overrides the @option{-fconstant-string-class} setting and cause
5030@code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
5031Note that @option{-fconstant-cfstrings} is an alias for the target-specific
5032@option{-mconstant-cfstrings} equivalent.
d77de738 5033
d77de738 5034@opindex fgnu-runtime
ddf6fe37 5035@item -fgnu-runtime
d77de738
ML
5036Generate object code compatible with the standard GNU Objective-C
5037runtime. This is the default for most types of systems.
5038
d77de738 5039@opindex fnext-runtime
ddf6fe37 5040@item -fnext-runtime
d77de738 5041Generate output compatible with the NeXT runtime. This is the default
a335cf24 5042for NeXT-based systems, including Darwin / macOS. The macro
d77de738
ML
5043@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
5044used.
5045
d77de738
ML
5046@opindex fno-nil-receivers
5047@opindex fnil-receivers
ddf6fe37 5048@item -fno-nil-receivers
d77de738
ML
5049Assume that all Objective-C message dispatches (@code{[receiver
5050message:arg]}) in this translation unit ensure that the receiver is
5051not @code{nil}. This allows for more efficient entry points in the
5052runtime to be used. This option is only available in conjunction with
5053the NeXT runtime and ABI version 0 or 1.
5054
d77de738 5055@opindex fobjc-abi-version
ddf6fe37 5056@item -fobjc-abi-version=@var{n}
d77de738
ML
5057Use version @var{n} of the Objective-C ABI for the selected runtime.
5058This option is currently supported only for the NeXT runtime. In that
5059case, Version 0 is the traditional (32-bit) ABI without support for
5060properties and other Objective-C 2.0 additions. Version 1 is the
5061traditional (32-bit) ABI with support for properties and other
5062Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
5063nothing is specified, the default is Version 0 on 32-bit target
5064machines, and Version 2 on 64-bit target machines.
5065
d77de738 5066@opindex fobjc-call-cxx-cdtors
ddf6fe37 5067@item -fobjc-call-cxx-cdtors
d77de738
ML
5068For each Objective-C class, check if any of its instance variables is a
5069C++ object with a non-trivial default constructor. If so, synthesize a
5070special @code{- (id) .cxx_construct} instance method which runs
5071non-trivial default constructors on any such instance variables, in order,
5072and then return @code{self}. Similarly, check if any instance variable
5073is a C++ object with a non-trivial destructor, and if so, synthesize a
5074special @code{- (void) .cxx_destruct} method which runs
5075all such default destructors, in reverse order.
5076
5077The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
5078methods thusly generated only operate on instance variables
5079declared in the current Objective-C class, and not those inherited
5080from superclasses. It is the responsibility of the Objective-C
5081runtime to invoke all such methods in an object's inheritance
5082hierarchy. The @code{- (id) .cxx_construct} methods are invoked
5083by the runtime immediately after a new object instance is allocated;
5084the @code{- (void) .cxx_destruct} methods are invoked immediately
5085before the runtime deallocates an object instance.
5086
5087As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
5088support for invoking the @code{- (id) .cxx_construct} and
5089@code{- (void) .cxx_destruct} methods.
5090
d77de738 5091@opindex fobjc-direct-dispatch
ddf6fe37 5092@item -fobjc-direct-dispatch
d77de738
ML
5093Allow fast jumps to the message dispatcher. On Darwin this is
5094accomplished via the comm page.
5095
d77de738 5096@opindex fobjc-exceptions
ddf6fe37 5097@item -fobjc-exceptions
d77de738
ML
5098Enable syntactic support for structured exception handling in
5099Objective-C, similar to what is offered by C++. This option
5100is required to use the Objective-C keywords @code{@@try},
5101@code{@@throw}, @code{@@catch}, @code{@@finally} and
5102@code{@@synchronized}. This option is available with both the GNU
5103runtime and the NeXT runtime (but not available in conjunction with
5104the NeXT runtime on Mac OS X 10.2 and earlier).
5105
d77de738 5106@opindex fobjc-gc
ddf6fe37 5107@item -fobjc-gc
d77de738
ML
5108Enable garbage collection (GC) in Objective-C and Objective-C++
5109programs. This option is only available with the NeXT runtime; the
5110GNU runtime has a different garbage collection implementation that
5111does not require special compiler flags.
5112
d77de738 5113@opindex fobjc-nilcheck
ddf6fe37 5114@item -fobjc-nilcheck
d77de738
ML
5115For the NeXT runtime with version 2 of the ABI, check for a nil
5116receiver in method invocations before doing the actual method call.
5117This is the default and can be disabled using
5118@option{-fno-objc-nilcheck}. Class methods and super calls are never
5119checked for nil in this way no matter what this flag is set to.
5120Currently this flag does nothing when the GNU runtime, or an older
5121version of the NeXT runtime ABI, is used.
5122
d77de738 5123@opindex fobjc-std
ddf6fe37 5124@item -fobjc-std=objc1
d77de738
ML
5125Conform to the language syntax of Objective-C 1.0, the language
5126recognized by GCC 4.0. This only affects the Objective-C additions to
5127the C/C++ language; it does not affect conformance to C/C++ standards,
5128which is controlled by the separate C/C++ dialect option flags. When
5129this option is used with the Objective-C or Objective-C++ compiler,
5130any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
5131This is useful if you need to make sure that your Objective-C code can
5132be compiled with older versions of GCC@.
5133
d77de738 5134@opindex freplace-objc-classes
ddf6fe37 5135@item -freplace-objc-classes
d77de738
ML
5136Emit a special marker instructing @command{ld(1)} not to statically link in
5137the resulting object file, and allow @command{dyld(1)} to load it in at
5138run time instead. This is used in conjunction with the Fix-and-Continue
5139debugging mode, where the object file in question may be recompiled and
5140dynamically reloaded in the course of program execution, without the need
5141to restart the program itself. Currently, Fix-and-Continue functionality
5142is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5143and later.
5144
d77de738 5145@opindex fzero-link
ddf6fe37 5146@item -fzero-link
d77de738
ML
5147When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5148to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5149compile time) with static class references that get initialized at load time,
5150which improves run-time performance. Specifying the @option{-fzero-link} flag
5151suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5152to be retained. This is useful in Zero-Link debugging mode, since it allows
5153for individual class implementations to be modified during program execution.
5154The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5155regardless of command-line options.
5156
d77de738
ML
5157@opindex fno-local-ivars
5158@opindex flocal-ivars
ddf6fe37 5159@item -fno-local-ivars
d77de738
ML
5160By default instance variables in Objective-C can be accessed as if
5161they were local variables from within the methods of the class they're
5162declared in. This can lead to shadowing between instance variables
5163and other variables declared either locally inside a class method or
5164globally with the same name. Specifying the @option{-fno-local-ivars}
5165flag disables this behavior thus avoiding variable shadowing issues.
5166
d77de738 5167@opindex fivar-visibility
ddf6fe37 5168@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
5169Set the default instance variable visibility to the specified option
5170so that instance variables declared outside the scope of any access
5171modifier directives default to the specified visibility.
5172
d77de738 5173@opindex gen-decls
ddf6fe37 5174@item -gen-decls
d77de738
ML
5175Dump interface declarations for all classes seen in the source file to a
5176file named @file{@var{sourcename}.decl}.
5177
d77de738
ML
5178@opindex Wassign-intercept
5179@opindex Wno-assign-intercept
ddf6fe37 5180@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5181Warn whenever an Objective-C assignment is being intercepted by the
5182garbage collector.
5183
d77de738
ML
5184@opindex Wproperty-assign-default
5185@opindex Wno-property-assign-default
ddf6fe37 5186@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5187Do not warn if a property for an Objective-C object has no assign
5188semantics specified.
5189
d77de738
ML
5190@opindex Wno-protocol
5191@opindex Wprotocol
ddf6fe37 5192@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5193If a class is declared to implement a protocol, a warning is issued for
5194every method in the protocol that is not implemented by the class. The
5195default behavior is to issue a warning for every method not explicitly
5196implemented in the class, even if a method implementation is inherited
5197from the superclass. If you use the @option{-Wno-protocol} option, then
5198methods inherited from the superclass are considered to be implemented,
5199and no warning is issued for them.
5200
d77de738 5201@opindex Wobjc-root-class
ddf6fe37 5202@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5203Warn if a class interface lacks a superclass. Most classes will inherit
5204from @code{NSObject} (or @code{Object}) for example. When declaring
5205classes intended to be root classes, the warning can be suppressed by
5206marking their interfaces with @code{__attribute__((objc_root_class))}.
5207
d77de738
ML
5208@opindex Wselector
5209@opindex Wno-selector
ddf6fe37 5210@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5211Warn if multiple methods of different types for the same selector are
5212found during compilation. The check is performed on the list of methods
5213in the final stage of compilation. Additionally, a check is performed
5214for each selector appearing in a @code{@@selector(@dots{})}
5215expression, and a corresponding method for that selector has been found
5216during compilation. Because these checks scan the method table only at
5217the end of compilation, these warnings are not produced if the final
5218stage of compilation is not reached, for example because an error is
5219found during compilation, or because the @option{-fsyntax-only} option is
5220being used.
5221
d77de738
ML
5222@opindex Wstrict-selector-match
5223@opindex Wno-strict-selector-match
ddf6fe37 5224@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5225Warn if multiple methods with differing argument and/or return types are
5226found for a given selector when attempting to send a message using this
5227selector to a receiver of type @code{id} or @code{Class}. When this flag
5228is off (which is the default behavior), the compiler omits such warnings
5229if any differences found are confined to types that share the same size
5230and alignment.
5231
d77de738
ML
5232@opindex Wundeclared-selector
5233@opindex Wno-undeclared-selector
ddf6fe37 5234@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5235Warn if a @code{@@selector(@dots{})} expression referring to an
5236undeclared selector is found. A selector is considered undeclared if no
5237method with that name has been declared before the
5238@code{@@selector(@dots{})} expression, either explicitly in an
5239@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5240an @code{@@implementation} section. This option always performs its
5241checks as soon as a @code{@@selector(@dots{})} expression is found,
5242while @option{-Wselector} only performs its checks in the final stage of
5243compilation. This also enforces the coding style convention
5244that methods and selectors must be declared before being used.
5245
d77de738 5246@opindex print-objc-runtime-info
ddf6fe37 5247@item -print-objc-runtime-info
d77de738
ML
5248Generate C header describing the largest structure that is passed by
5249value, if any.
5250
5251@end table
5252
ef458b3f
SL
5253@node OpenMP and OpenACC Options
5254@section Options Controlling OpenMP and OpenACC
5255@cindex OpenMP options
5256@cindex OpenACC options
5257
5258GCC supports OpenMP extensions to the C, C++, and Fortran languages
5259with the @option{-fopenmp} option. Similarly, OpenACC extensions are
5260supported in all three languages with @option{-fopenacc}.
5261@xref{OpenMP} and @ref{OpenACC} for an overview of these extensions.
5262
5263@table @gcctabopt
5264@opindex foffload
5265@cindex Offloading targets
5266@cindex OpenACC offloading targets
5267@cindex OpenMP offloading targets
5268@item -foffload=disable
5269@itemx -foffload=default
5270@itemx -foffload=@var{target-list}
5271Specify for which OpenMP and OpenACC offload targets code should be generated.
5272The default behavior, equivalent to @option{-foffload=default}, is to generate
5273code for all supported offload targets. The @option{-foffload=disable} form
5274generates code only for the host fallback, while
5275@option{-foffload=@var{target-list}} generates code only for the specified
5276comma-separated list of offload targets.
5277
5278Offload targets are specified in GCC's internal target-triplet format. You can
5279run the compiler with @option{-v} to show the list of configured offload targets
5280under @code{OFFLOAD_TARGET_NAMES}.
5281
5282@opindex foffload-options
5283@cindex Offloading options
5284@cindex OpenACC offloading options
5285@cindex OpenMP offloading options
5286@item -foffload-options=@var{options}
5287@itemx -foffload-options=@var{target-triplet-list}=@var{options}
5288
5289With @option{-foffload-options=@var{options}}, GCC passes the specified
5290@var{options} to the compilers for all enabled offloading targets. You can
5291specify options that apply only to a specific target or targets by using
5292the @option{-foffload-options=@var{target-list}=@var{options}} form. The
5293@var{target-list} is a comma-separated list in the same format as for the
5294@option{-foffload=} option.
5295
5296Typical command lines are
5297
5298@smallexample
5299-foffload-options='-fno-math-errno -ffinite-math-only' \
5300 -foffload-options=nvptx-none=-latomic
5301-foffload-options=amdgcn-amdhsa=-march=gfx906
5302@end smallexample
5303
5304@opindex fopenacc
5305@cindex OpenACC accelerator programming
5306@item -fopenacc
5307Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
5308@samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
5309@samp{*$acc} in fixed-form Fortran. This option
5310implies @option{-pthread}, and thus is only supported on targets that
5311have support for @option{-pthread}.
5312
5313@opindex fopenacc-dim
5314@item -fopenacc-dim=@var{geom}
5315Specify default compute dimensions for parallel offload regions that do
5316not explicitly specify them. The @var{geom} value is a triple of
5317@samp{:}-separated sizes, in order @var{gang}, @var{worker}, and @var{vector}.
5318A size can be omitted, to use a target-specific default value.
5319
5320@opindex fopenmp
5321@cindex OpenMP parallel
5322@item -fopenmp
5323Enable handling of OpenMP directives @samp{#pragma omp},
5324@samp{[[omp::directive(...)]]}, @samp{[[omp::decl(...)]]},
5325and @samp{[[omp::sequence(...)]]} in C/C++. In Fortran, it enables
5326@samp{!$omp} and the conditional compilation sentinel @samp{!$}.
5327In fixed source form Fortran, the sentinels can also start with
5328@samp{c} or @samp{*}.
5329
5330This option implies @option{-pthread}, and thus is only supported on
5331targets that have support for @option{-pthread}. @option{-fopenmp}
5332implies @option{-fopenmp-simd}.
5333
5334@opindex fopenmp-simd
5335@cindex OpenMP SIMD
5336@cindex SIMD
5337@item -fopenmp-simd
5338Enable handling of OpenMP's @code{simd}, @code{declare simd},
5339@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
5340and @code{loop} directive, and of combined or composite directives with
5341@code{simd} as constituent with @code{#pragma omp},
5342@code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
5343@code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
5344additionally enables the conditional compilation sentinel @samp{!$} in
5345Fortran. In fixed source form Fortran, the sentinels can also start with
5346@samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
5347@option{-fopenmp} is additionally specified, the @code{loop} region binds
5348to the current task region, independent of the specified @code{bind} clause.
5349
5350@opindex fopenmp-target-simd-clone
5351@cindex OpenMP target SIMD clone
5352@item -fopenmp-target-simd-clone
5353@item -fopenmp-target-simd-clone=@var{device-type}
5354In addition to generating SIMD clones for functions marked with the
5355@code{declare simd} directive, GCC also generates clones
5356for functions marked with the OpenMP @code{declare target} directive
5357that are suitable for vectorization when this option is in effect. The
5358@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
5359and @code{any}, which correspond to keywords for the @code{device_type}
5360clause of the @code{declare target} directive; clones are generated for
5361the intersection of devices specified.
5362@option{-fopenmp-target-simd-clone} is equivalent to
5363@option{-fopenmp-target-simd-clone=any} and
5364@option{-fno-openmp-target-simd-clone} is equivalent to
5365@option{-fopenmp-target-simd-clone=none}.
5366
5367At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
5368optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
5369it is disabled by default.
5370
5371@end table
5372
d77de738
ML
5373@node Diagnostic Message Formatting Options
5374@section Options to Control Diagnostic Messages Formatting
5375@cindex options to control diagnostics formatting
5376@cindex diagnostic messages
5377@cindex message formatting
5378
5379Traditionally, diagnostic messages have been formatted irrespective of
5380the output device's aspect (e.g.@: its width, @dots{}). You can use the
5381options described below
a0e64a04 5382to control the formatting algorithm for diagnostic messages,
d77de738
ML
5383e.g.@: how many characters per line, how often source location
5384information should be reported. Note that some language front ends may not
5385honor these options.
5386
5387@table @gcctabopt
d77de738 5388@opindex fmessage-length
ddf6fe37 5389@item -fmessage-length=@var{n}
d77de738
ML
5390Try to format error messages so that they fit on lines of about
5391@var{n} characters. If @var{n} is zero, then no line-wrapping is
5392done; each error message appears on a single line. This is the
5393default for all front ends.
5394
5395Note - this option also affects the display of the @samp{#error} and
5396@samp{#warning} pre-processor directives, and the @samp{deprecated}
5397function/type/variable attribute. It does not however affect the
5398@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5399
5400@item -fdiagnostics-plain-output
5401This option requests that diagnostic output look as plain as possible, which
5402may be useful when running @command{dejagnu} or other utilities that need to
5403parse diagnostics output and prefer that it remain more stable over time.
5404@option{-fdiagnostics-plain-output} is currently equivalent to the following
5405options:
43b72ede
AA
5406@gccoptlist{-fno-diagnostics-show-caret
5407-fno-diagnostics-show-line-numbers
5408-fdiagnostics-color=never
5409-fdiagnostics-urls=never
4f01ae37 5410-fdiagnostics-path-format=separate-events
770657d0
DM
5411-fdiagnostics-text-art-charset=none
5412-fno-diagnostics-show-event-links}
d77de738
ML
5413In the future, if GCC changes the default appearance of its diagnostics, the
5414corresponding option to disable the new behavior will be added to this list.
5415
d77de738 5416@opindex fdiagnostics-show-location
ddf6fe37 5417@item -fdiagnostics-show-location=once
d77de738
ML
5418Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5419reporter to emit source location information @emph{once}; that is, in
5420case the message is too long to fit on a single physical line and has to
5421be wrapped, the source location won't be emitted (as prefix) again,
5422over and over, in subsequent continuation lines. This is the default
5423behavior.
5424
5425@item -fdiagnostics-show-location=every-line
5426Only meaningful in line-wrapping mode. Instructs the diagnostic
5427messages reporter to emit the same source location information (as
5428prefix) for physical lines that result from the process of breaking
5429a message which is too long to fit on a single line.
5430
ddf6fe37 5431@opindex fdiagnostics-color
d77de738
ML
5432@cindex highlight, color
5433@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5434@item -fdiagnostics-color[=@var{WHEN}]
5435@itemx -fno-diagnostics-color
d77de738
ML
5436Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5437or @samp{auto}. The default depends on how the compiler has been configured,
5438it can be any of the above @var{WHEN} options or also @samp{never}
5439if @env{GCC_COLORS} environment variable isn't present in the environment,
5440and @samp{auto} otherwise.
5441@samp{auto} makes GCC use color only when the standard error is a terminal,
5442and when not executing in an emacs shell.
5443The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5444aliases for @option{-fdiagnostics-color=always} and
5445@option{-fdiagnostics-color=never}, respectively.
5446
5447The colors are defined by the environment variable @env{GCC_COLORS}.
5448Its value is a colon-separated list of capabilities and Select Graphic
5449Rendition (SGR) substrings. SGR commands are interpreted by the
5450terminal or terminal emulator. (See the section in the documentation
5451of your text terminal for permitted values and their meanings as
5452character attributes.) These substring values are integers in decimal
5453representation and can be concatenated with semicolons.
5454Common values to concatenate include
5455@samp{1} for bold,
5456@samp{4} for underline,
5457@samp{5} for blink,
5458@samp{7} for inverse,
5459@samp{39} for default foreground color,
5460@samp{30} to @samp{37} for foreground colors,
5461@samp{90} to @samp{97} for 16-color mode foreground colors,
5462@samp{38;5;0} to @samp{38;5;255}
5463for 88-color and 256-color modes foreground colors,
5464@samp{49} for default background color,
5465@samp{40} to @samp{47} for background colors,
5466@samp{100} to @samp{107} for 16-color mode background colors,
5467and @samp{48;5;0} to @samp{48;5;255}
5468for 88-color and 256-color modes background colors.
5469
5470The default @env{GCC_COLORS} is
5471@smallexample
5472error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5473quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5474diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
7d73c01c
DM
5475type-diff=01;32:fnname=01;32:targs=35:valid=01;31:invalid=01;32\
5476highlight-a=01;32:highlight-b=01;34
d77de738
ML
5477@end smallexample
5478@noindent
5479where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5480@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5481@samp{01} is bold, and @samp{31} is red.
5482Setting @env{GCC_COLORS} to the empty string disables colors.
5483Supported capabilities are as follows.
5484
5485@table @code
d77de738 5486@vindex error GCC_COLORS @r{capability}
f33d7a88 5487@item error=
d77de738
ML
5488SGR substring for error: markers.
5489
d77de738 5490@vindex warning GCC_COLORS @r{capability}
f33d7a88 5491@item warning=
d77de738
ML
5492SGR substring for warning: markers.
5493
d77de738 5494@vindex note GCC_COLORS @r{capability}
f33d7a88 5495@item note=
d77de738
ML
5496SGR substring for note: markers.
5497
d77de738 5498@vindex path GCC_COLORS @r{capability}
f33d7a88 5499@item path=
d77de738
ML
5500SGR substring for colorizing paths of control-flow events as printed
5501via @option{-fdiagnostics-path-format=}, such as the identifiers of
5502individual events and lines indicating interprocedural calls and returns.
5503
d77de738 5504@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5505@item range1=
d77de738
ML
5506SGR substring for first additional range.
5507
d77de738 5508@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5509@item range2=
d77de738
ML
5510SGR substring for second additional range.
5511
d77de738 5512@vindex locus GCC_COLORS @r{capability}
f33d7a88 5513@item locus=
d77de738
ML
5514SGR substring for location information, @samp{file:line} or
5515@samp{file:line:column} etc.
5516
d77de738 5517@vindex quote GCC_COLORS @r{capability}
f33d7a88 5518@item quote=
d77de738
ML
5519SGR substring for information printed within quotes.
5520
d77de738 5521@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5522@item fnname=
d77de738
ML
5523SGR substring for names of C++ functions.
5524
d77de738 5525@vindex targs GCC_COLORS @r{capability}
f33d7a88 5526@item targs=
d77de738
ML
5527SGR substring for C++ function template parameter bindings.
5528
d77de738 5529@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5530@item fixit-insert=
d77de738
ML
5531SGR substring for fix-it hints suggesting text to
5532be inserted or replaced.
5533
d77de738 5534@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5535@item fixit-delete=
d77de738
ML
5536SGR substring for fix-it hints suggesting text to
5537be deleted.
5538
d77de738 5539@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5540@item diff-filename=
d77de738
ML
5541SGR substring for filename headers within generated patches.
5542
d77de738 5543@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5544@item diff-hunk=
d77de738
ML
5545SGR substring for the starts of hunks within generated patches.
5546
d77de738 5547@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5548@item diff-delete=
d77de738
ML
5549SGR substring for deleted lines within generated patches.
5550
d77de738 5551@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5552@item diff-insert=
d77de738
ML
5553SGR substring for inserted lines within generated patches.
5554
d77de738 5555@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5556@item type-diff=
d77de738
ML
5557SGR substring for highlighting mismatching types within template
5558arguments in the C++ frontend.
4b02dd48
DM
5559
5560@vindex valid GCC_COLORS @r{capability}
5561@item valid=
5562SGR substring for highlighting valid elements within text art diagrams.
5563
5564@vindex invalid GCC_COLORS @r{capability}
5565@item invalid=
5566SGR substring for highlighting invalid elements within text art diagrams.
7d73c01c
DM
5567
5568@vindex highlight-a GCC_COLORS @r{capability}
5569@vindex highlight-b GCC_COLORS @r{capability}
5570@item highlight-a=
5571@item highlight-b=
5572SGR substrings for contrasting two different things within diagnostics,
5573such as a pair of mismatching types.
5574See @option{-fdiagnostics-show-highlight-colors}.
d77de738
ML
5575@end table
5576
d77de738
ML
5577@opindex fdiagnostics-urls
5578@cindex urls
5579@vindex GCC_URLS @r{environment variable}
5580@vindex TERM_URLS @r{environment variable}
f33d7a88 5581@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5582Use escape sequences to embed URLs in diagnostics. For example, when
5583@option{-fdiagnostics-show-option} emits text showing the command-line
5584option controlling a diagnostic, embed a URL for documentation of that
5585option.
5586
5587@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5588@samp{auto} makes GCC use URL escape sequences only when the standard error
5589is a terminal, and when not executing in an emacs shell or any graphical
5590terminal which is known to be incompatible with this feature, see below.
5591
5592The default depends on how the compiler has been configured.
5593It can be any of the above @var{WHEN} options.
5594
5595GCC can also be configured (via the
5596@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5597so that the default is affected by environment variables.
5598Under such a configuration, GCC defaults to using @samp{auto}
5599if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5600present and non-empty in the environment of the compiler, or @samp{never}
5601if neither are.
5602
5603However, even with @option{-fdiagnostics-urls=always} the behavior is
5604dependent on those environment variables:
5605If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5606diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5607If set to @samp{bel}, the default, URLs use BEL escape sequences.
5608Any other non-empty value enables the feature.
5609If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5610Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5611BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5612
5613At this time GCC tries to detect also a few terminals that are known to
5614not implement the URL feature, and have bugs or at least had bugs in
5615some versions that are still in use, where the URL escapes are likely
5616to misbehave, i.e. print garbage on the screen.
5617That list is currently xfce4-terminal, certain known to be buggy
5618gnome-terminal versions, the linux console, and mingw.
5619This check can be skipped with the @option{-fdiagnostics-urls=always}.
5620
d77de738
ML
5621@opindex fno-diagnostics-show-option
5622@opindex fdiagnostics-show-option
ddf6fe37 5623@item -fno-diagnostics-show-option
d77de738
ML
5624By default, each diagnostic emitted includes text indicating the
5625command-line option that directly controls the diagnostic (if such an
5626option is known to the diagnostic machinery). Specifying the
5627@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5628
d77de738
ML
5629@opindex fno-diagnostics-show-caret
5630@opindex fdiagnostics-show-caret
ddf6fe37 5631@item -fno-diagnostics-show-caret
d77de738
ML
5632By default, each diagnostic emitted includes the original source line
5633and a caret @samp{^} indicating the column. This option suppresses this
5634information. The source line is truncated to @var{n} characters, if
5635the @option{-fmessage-length=n} option is given. When the output is done
5636to the terminal, the width is limited to the width given by the
5637@env{COLUMNS} environment variable or, if not set, to the terminal width.
5638
d77de738
ML
5639@opindex fno-diagnostics-show-labels
5640@opindex fdiagnostics-show-labels
ddf6fe37 5641@item -fno-diagnostics-show-labels
d77de738
ML
5642By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5643diagnostics can label ranges of source code with pertinent information, such
5644as the types of expressions:
5645
5646@smallexample
5647 printf ("foo %s bar", long_i + long_j);
5648 ~^ ~~~~~~~~~~~~~~~
5649 | |
5650 char * long int
5651@end smallexample
5652
5653This option suppresses the printing of these labels (in the example above,
5654the vertical bars and the ``char *'' and ``long int'' text).
5655
770657d0
DM
5656@opindex fno-diagnostics-show-event-links
5657@opindex fdiagnostics-show-event-links
5658@item -fno-diagnostics-show-event-links
5659By default, when printing execution paths (via
5660@option{-fdiagnostics-path-format=inline-events}), GCC will print lines
5661connecting related events, such as the line connecting events 1 and 2 in:
5662
5663@smallexample
5664 3 | if (p)
5665 | ^
5666 | |
5667 | (1) following `false' branch (when `p' is NULL)... ->-+
5668 | |
5669 | |
5670 |+------------------------------------------------------------+
5671 4 || return 0;
5672 5 || return *p;
5673 || ~
5674 || |
5675 |+-------->(2) ...to here
5676 | (3) dereference of NULL `p'
5677@end smallexample
5678
5679This option suppresses the printing of such connector lines.
5680
d77de738
ML
5681@opindex fno-diagnostics-show-cwe
5682@opindex fdiagnostics-show-cwe
ddf6fe37 5683@item -fno-diagnostics-show-cwe
d77de738
ML
5684Diagnostic messages can optionally have an associated
5685@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5686GCC itself only provides such metadata for some of the @option{-fanalyzer}
5687diagnostics. GCC plugins may also provide diagnostics with such metadata.
5688By default, if this information is present, it will be printed with
5689the diagnostic. This option suppresses the printing of this metadata.
5690
d77de738
ML
5691@opindex fno-diagnostics-show-rules
5692@opindex fdiagnostics-show-rules
ddf6fe37 5693@item -fno-diagnostics-show-rules
d77de738
ML
5694Diagnostic messages can optionally have rules associated with them, such
5695as from a coding standard, or a specification.
5696GCC itself does not do this for any of its diagnostics, but plugins may do so.
5697By default, if this information is present, it will be printed with
5698the diagnostic. This option suppresses the printing of this metadata.
5699
7d73c01c
DM
5700@opindex fno-diagnostics-show-highlight-colors
5701@opindex fdiagnostics-show-highlight-colors
5702@item -fno-diagnostics-show-highlight-colors
5703
5704GCC can use color for emphasis and contrast when printing diagnostic
5705messages and quoting the user's source.
5706
5707For example, in
5708
5709@smallexample
5710demo.c: In function `test_bad_format_string_args':
5711../../src/demo.c:25:18: warning: format `%i' expects argument of type `int', but argument 2 has type `const char *' [-Wformat=]
5712 25 | printf("hello %i", msg);
5713 | ~^ ~~~
5714 | | |
5715 | int const char *
5716 | %s
5717@end smallexample
5718
5719@itemize @bullet
5720@item
5721the @code{%i} and @code{int} in the message and the @code{int} in the
5722quoted source are colored using @code{highlight-a} (bold green by default),
5723and
5724@item
5725the @code{const char *} in the message and in the quoted source are both
5726colored using @code{highlight-b} (bold blue by default).
5727@end itemize
5728
5729The intent is to draw the reader's eyes to the relationships between the
5730various aspects of the diagnostic message and the source, using color
5731to group related elements and distinguish between mismatching ones.
5732
5733This additional colorization is enabled by default if color printing
5734is enabled (as per @option{-fdiagnostics-color=}), but it can be separately
5735disabled via @option{-fno-diagnostics-show-highlight-colors}.
5736
d77de738
ML
5737@opindex fno-diagnostics-show-line-numbers
5738@opindex fdiagnostics-show-line-numbers
ddf6fe37 5739@item -fno-diagnostics-show-line-numbers
d77de738
ML
5740By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5741a left margin is printed, showing line numbers. This option suppresses this
5742left margin.
5743
d77de738 5744@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5745@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5746This option controls the minimum width of the left margin printed by
5747@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5748
d77de738 5749@opindex fdiagnostics-parseable-fixits
ddf6fe37 5750@item -fdiagnostics-parseable-fixits
d77de738
ML
5751Emit fix-it hints in a machine-parseable format, suitable for consumption
5752by IDEs. For each fix-it, a line will be printed after the relevant
5753diagnostic, starting with the string ``fix-it:''. For example:
5754
5755@smallexample
5756fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5757@end smallexample
5758
5759The location is expressed as a half-open range, expressed as a count of
5760bytes, starting at byte 1 for the initial column. In the above example,
5761bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5762given string:
5763
5764@smallexample
576500000000011111111112222222222
576612345678901234567890123456789
5767 gtk_widget_showall (dlg);
5768 ^^^^^^^^^^^^^^^^^^
5769 gtk_widget_show_all
5770@end smallexample
5771
5772The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5773newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5774(e.g. vertical tab as ``\013'').
5775
5776An empty replacement string indicates that the given range is to be removed.
5777An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5778be inserted at the given position.
5779
d77de738 5780@opindex fdiagnostics-generate-patch
ddf6fe37 5781@item -fdiagnostics-generate-patch
d77de738
ML
5782Print fix-it hints to stderr in unified diff format, after any diagnostics
5783are printed. For example:
5784
5785@smallexample
5786--- test.c
5787+++ test.c
5788@@ -42,5 +42,5 @@
5789
5790 void show_cb(GtkDialog *dlg)
5791 @{
5792- gtk_widget_showall(dlg);
5793+ gtk_widget_show_all(dlg);
5794 @}
5795
5796@end smallexample
5797
5798The diff may or may not be colorized, following the same rules
5799as for diagnostics (see @option{-fdiagnostics-color}).
5800
d77de738 5801@opindex fdiagnostics-show-template-tree
ddf6fe37 5802@item -fdiagnostics-show-template-tree
d77de738
ML
5803
5804In the C++ frontend, when printing diagnostics showing mismatching
5805template types, such as:
5806
5807@smallexample
5808 could not convert 'std::map<int, std::vector<double> >()'
5809 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5810@end smallexample
5811
5812the @option{-fdiagnostics-show-template-tree} flag enables printing a
5813tree-like structure showing the common and differing parts of the types,
5814such as:
5815
5816@smallexample
5817 map<
5818 [...],
5819 vector<
5820 [double != float]>>
5821@end smallexample
5822
5823The parts that differ are highlighted with color (``double'' and
5824``float'' in this case).
5825
d77de738
ML
5826@opindex fno-elide-type
5827@opindex felide-type
ddf6fe37 5828@item -fno-elide-type
d77de738
ML
5829By default when the C++ frontend prints diagnostics showing mismatching
5830template types, common parts of the types are printed as ``[...]'' to
5831simplify the error message. For example:
5832
5833@smallexample
5834 could not convert 'std::map<int, std::vector<double> >()'
5835 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5836@end smallexample
5837
5838Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5839This flag also affects the output of the
5840@option{-fdiagnostics-show-template-tree} flag.
5841
d77de738 5842@opindex fdiagnostics-path-format
ddf6fe37 5843@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5844Specify how to print paths of control-flow events for diagnostics that
5845have such a path associated with them.
5846
5847@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5848the default.
5849
5850@samp{none} means to not print diagnostic paths.
5851
5852@samp{separate-events} means to print a separate ``note'' diagnostic for
5853each event within the diagnostic. For example:
5854
5855@smallexample
5856test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5857test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5858test.c:27:3: note: (2) when 'i < count'
5859test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5860@end smallexample
5861
5862@samp{inline-events} means to print the events ``inline'' within the source
5863code. This view attempts to consolidate the events into runs of
5864sufficiently-close events, printing them as labelled ranges within the source.
5865
5866For example, the same events as above might be printed as:
5867
5868@smallexample
5869 'test': events 1-3
3cd26744
DM
5870 25 | list = PyList_New(0);
5871 | ^~~~~~~~~~~~~
5872 | |
5873 | (1) when 'PyList_New' fails, returning NULL
5874 26 |
5875 27 | for (i = 0; i < count; i++) @{
5876 | ~~~
5877 | |
5878 | (2) when 'i < count'
5879 28 | item = PyLong_FromLong(random());
5880 29 | PyList_Append(list, item);
5881 | ~~~~~~~~~~~~~~~~~~~~~~~~~
5882 | |
5883 | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
d77de738
ML
5884@end smallexample
5885
5886Interprocedural control flow is shown by grouping the events by stack frame,
5887and using indentation to show how stack frames are nested, pushed, and popped.
5888
5889For example:
5890
5891@smallexample
5892 'test': events 1-2
5893 |
5894 | 133 | @{
5895 | | ^
5896 | | |
5897 | | (1) entering 'test'
5898 | 134 | boxed_int *obj = make_boxed_int (i);
5899 | | ~~~~~~~~~~~~~~~~~~
5900 | | |
5901 | | (2) calling 'make_boxed_int'
5902 |
5903 +--> 'make_boxed_int': events 3-4
5904 |
5905 | 120 | @{
5906 | | ^
5907 | | |
5908 | | (3) entering 'make_boxed_int'
5909 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5910 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5911 | | |
5912 | | (4) calling 'wrapped_malloc'
5913 |
5914 +--> 'wrapped_malloc': events 5-6
5915 |
5916 | 7 | @{
5917 | | ^
5918 | | |
5919 | | (5) entering 'wrapped_malloc'
5920 | 8 | return malloc (size);
5921 | | ~~~~~~~~~~~~~
5922 | | |
5923 | | (6) calling 'malloc'
5924 |
5925 <-------------+
5926 |
5927 'test': event 7
5928 |
5929 | 138 | free_boxed_int (obj);
5930 | | ^~~~~~~~~~~~~~~~~~~~
5931 | | |
5932 | | (7) calling 'free_boxed_int'
5933 |
5934(etc)
5935@end smallexample
5936
d77de738 5937@opindex fdiagnostics-show-path-depths
ddf6fe37 5938@item -fdiagnostics-show-path-depths
d77de738
ML
5939This option provides additional information when printing control-flow paths
5940associated with a diagnostic.
5941
5942If this is option is provided then the stack depth will be printed for
5943each run of events within @option{-fdiagnostics-path-format=inline-events}.
5944If provided with @option{-fdiagnostics-path-format=separate-events}, then
5945the stack depth and function declaration will be appended when printing
5946each event.
5947
5948This is intended for use by GCC developers and plugin developers when
5949debugging diagnostics that report interprocedural control flow.
5950
d77de738
ML
5951@opindex fno-show-column
5952@opindex fshow-column
ddf6fe37 5953@item -fno-show-column
d77de738
ML
5954Do not print column numbers in diagnostics. This may be necessary if
5955diagnostics are being scanned by a program that does not understand the
5956column numbers, such as @command{dejagnu}.
5957
d77de738 5958@opindex fdiagnostics-column-unit
ddf6fe37 5959@item -fdiagnostics-column-unit=@var{UNIT}
d77de738 5960Select the units for the column number. This affects traditional diagnostics
51ce3734 5961(in the absence of @option{-fno-show-column}).
d77de738
ML
5962
5963The default @var{UNIT}, @samp{display}, considers the number of display
5964columns occupied by each character. This may be larger than the number
5965of bytes required to encode the character, in the case of tab
5966characters, or it may be smaller, in the case of multibyte characters.
5967For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5968display column, and its UTF-8 encoding requires two bytes; the character
5969``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5970its UTF-8 encoding requires four bytes.
5971
5972Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5973count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5974
d77de738 5975@opindex fdiagnostics-column-origin
ddf6fe37 5976@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5977Select the origin for column numbers, i.e. the column number assigned to the
5978first column. The default value of 1 corresponds to traditional GCC
5979behavior and to the GNU style guide. Some utilities may perform better with an
5980origin of 0; any non-negative value may be specified.
5981
d77de738 5982@opindex fdiagnostics-escape-format
ddf6fe37 5983@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5984When GCC prints pertinent source lines for a diagnostic it normally attempts
5985to print the source bytes directly. However, some diagnostics relate to encoding
5986issues in the source file, such as malformed UTF-8, or issues with Unicode
5987normalization. These diagnostics are flagged so that GCC will escape bytes
5988that are not printable ASCII when printing their pertinent source lines.
5989
5990This option controls how such bytes should be escaped.
5991
5992The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5993are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5994correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5995displayed as hexadecimal in the form @samp{<XX>}.
5996
5997For example, a source line containing the string @samp{before} followed by the
5998Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
59990xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
6000the string @samp{after} will be printed for such a diagnostic as:
6001
6002@smallexample
6003 before<U+03C0><BF>after
6004@end smallexample
6005
6006Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
6007in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
6008Unicode characters. For the example above, the following will be printed:
6009
6010@smallexample
6011 before<CF><80><BF>after
6012@end smallexample
6013
4f01ae37
DM
6014@opindex fdiagnostics-text-art-charset
6015@item -fdiagnostics-text-art-charset=@var{CHARSET}
6016Some diagnostics can contain ``text art'' diagrams: visualizations created
6017from text, intended to be viewed in a monospaced font.
6018
6019This option selects which characters should be used for printing such
6020diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
6021or @samp{emoji}.
6022
6023The @samp{none} value suppresses the printing of such diagrams.
6024The @samp{ascii} value will ensure that such diagrams are pure ASCII
6025(``ASCII art''). The @samp{unicode} value will allow for conservative use of
6026unicode drawing characters (such as box-drawing characters). The @samp{emoji}
6027value further adds the possibility of emoji in the output (such as emitting
6028U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
6029emoji variant of the character).
6030
04013e44
DM
6031The default is @samp{emoji}, except when the environment variable @env{LANG}
6032is set to @samp{C}, in which case the default is @samp{ascii}.
4f01ae37 6033
d77de738 6034@opindex fdiagnostics-format
ddf6fe37 6035@item -fdiagnostics-format=@var{FORMAT}
d77de738 6036Select a different format for printing diagnostics.
51ce3734 6037@var{FORMAT} is @samp{text}, @samp{sarif-stderr} or @samp{sarif-file}.
d77de738 6038
0b73e938
DM
6039Using this option replaces any additional ``output sinks'' added by
6040@option{-fdiagnostics-add-output=}, or that set by
6041@option{-fdiagnostics-set-output=}.
6042
d77de738
ML
6043The default is @samp{text}.
6044
6045The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
6046diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
6047named @file{@var{source}.sarif}, respectively.
6048
0b73e938
DM
6049@opindex fdiagnostics-add-output
6050@item -fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
6051Add an additional ``output sink'' for emitting diagnostics.
6052
6053@var{DIAGNOSTICS-OUTPUT-SPEC} should specify a scheme, optionally followed
6054by @code{:} and one or more @var{KEY}=@var{VALUE} pairs, in this form:
6055
6056@smallexample
6057@var{SCHEME}
6058@var{SCHEME}:@var{KEY}=@var{VALUE}
6059@var{SCHEME}:@var{KEY}=@var{VALUE},@var{KEY2}=@var{VALUE2}
6060@end smallexample
6061
6062etc.
6063
a5af2ec1
DM
6064Schemes, keys, or values with a name prefixed ``experimental'' may change
6065or be removed without notice.
6066
0b73e938
DM
6067@var{SCHEME} can be
6068
6069@table @gcctabopt
6070
6071@item text
6072Emit diagnostics to stderr using GCC's classic text output format.
6073
6074Supported keys are:
6075
6076@table @gcctabopt
6077
6078@item color=@r{[}yes@r{|}no@r{]}
6079Override colorization settings from @option{-fdiagnostics-color} for this
6080text output.
6081
a5af2ec1
DM
6082@item experimental-nesting=@r{[}yes@r{|}no@r{]}
6083Enable an experimental mode that emphasizes hierarchical relationships
6084within diagnostics messages, displaying location information on separate
6085lines.
6086
6087@item experimental-nesting-show-locations=@r{[}yes@r{|}no@r{]}
6088If @code{experimental-nesting=yes}, then by default locations are
6089shown; set this key to @code{no} to disable printing such locations.
6090This exists for use by GCC developers, for writing DejaGnu test cases.
6091
6092@item experimental-nesting-show-levels=@r{[}yes@r{|}no@r{]}
6093This is a debugging option for use with @code{experimental-nesting=yes}.
6094Set this key to @code{yes} to print explicit nesting levels in the output.
6095This exists for use by GCC developers.
6096
0b73e938
DM
6097@end table
6098
6099@item sarif
6100Emit diagnostics to a file in SARIF format.
6101
6102Supported keys are:
6103
6104@table @gcctabopt
6105
6106@item file=@var{FILENAME}
6107Specify the filename to write the SARIF output to, potentially with a
6108leading absolute or relative path. If not specified, it defaults to
6109@file{@var{source}.sarif}.
6110
e504a59b
DM
6111@item serialization=@r{[}json@r{]}
6112Specify the serialization format to use when writing out the SARIF.
6113Currently this can only be @code{json}, but is present as an
6114extension point for experimenting with other serializations.
6115
0b73e938
DM
6116@item version=@r{[}2.1@r{|}2.2-prerelease@r{]}
6117Specify the version of SARIF to use for the output. If not specified,
6118defaults to 2.1. @code{2.2-prerelease} uses an unofficial draft of the
6119future SARIF 2.2 specification and should only be used for experimentation
6120in this release.
6121
6122@end table
6123
2334d30c
DM
6124There is also this key intended for use by GCC developers, rather than
6125end-users, and subject to change or removal without notice:
6126
6127@table @gcctabopt
6128
6129@item xml-state=@r{[}yes@r{|}no@r{]}
6130This is a debugging feature and defaults to @code{no}.
6131If @code{xml-state=yes}, then attempt to capture detailed state information
6132from @option{-fanalyzer} in the generated SARIF.
6133
6134@end table
6135
1a2c6221
DM
6136@item experimental-html
6137Emit diagnostics to a file in HTML format. This scheme is experimental,
04871e74
DM
6138and may go away in future GCC releases. The keys and details of the output
6139are also subject to change.
1a2c6221
DM
6140
6141Supported keys are:
6142
6143@table @gcctabopt
6144
04871e74
DM
6145@item css=@r{[}yes@r{|}no@r{]}
6146Add an embedded <style> to the generated HTML. Defaults to yes.
6147
1a2c6221
DM
6148@item file=@var{FILENAME}
6149Specify the filename to write the HTML output to, potentially with a
6150leading absolute or relative path. If not specified, it defaults to
6151@file{@var{source}.html}.
6152
04871e74
DM
6153@item javascript=@r{[}yes@r{|}no@r{]}
6154Add an embedded <script> to the generated HTML providing a barebones UI
6155for viewing results. Defaults to yes.
6156
1a2c6221
DM
6157@end table
6158
2334d30c
DM
6159There are also these keys intended for use by GCC developers, rather than
6160end-users, and subject to change or removal without notice:
6161
6162@table @gcctabopt
6163
6164@item show-state-diagrams=@r{[}yes@r{|}no@r{]}
6165This is a debugging feature and defaults to @code{no}.
6166If @code{show-state-diagrams=yes}, then attempt to use @command{dot} to
6167generate SVG diagrams in the generated HTML, visualizing the state at each
6168event in a diagnostic path.
6169These are visible by pressing ``j'' and ``k'' to single-step forward and
6170backward through events. Enabling this option will slow down
6171HTML generation.
6172
6173@item show-state-diagrams-dot-src=@r{[}yes@r{|}no@r{]}
6174This is a debugging feature and defaults to @code{no}.
6175If @code{show-state-diagrams-dot-src=yes}
6176then if @code{show-state-diagrams=yes},
6177the generated state diagrams will also show the .dot source input to
6178GraphViz used for the diagram.
6179
6180@item show-state-diagrams-xml=@r{[}yes@r{|}no@r{]}
6181This is a debugging feature and defaults to @code{no}.
6182If @code{show-state-diagrams-xml=yes}
6183then if @code{show-state-diagrams=yes}, the generated state diagrams will
6184also show an XML representation of the state.
6185
6186@end table
6187
0b73e938
DM
6188@end table
6189
6190For example,
6191
6192@smallexample
6193-fdiagnostics-add-output=sarif:version=2.1,file=foo.2.1.sarif
6194-fdiagnostics-add-output=sarif:version=2.2-prerelease,file=foo.2.2.sarif
6195@end smallexample
6196
6197would add a pair of outputs, each writing to a different file, using
6198versions 2.1 and 2.2 of the SARIF standard respectively.
6199
6200In EBNF:
6201
6202@smallexample
6203
6204@var{diagnostics-output-specifier} = @var{diagnostics-output-name}
6205 | @var{diagnostics-output-name}, ":", @var{key-value-pairs};
6206
1a2c6221 6207@var{diagnostics-output-name} = "text" | "sarif" | "experimental-html";
0b73e938
DM
6208
6209@var{key-value-pairs} = @var{key-value-pair}
6210 | @var{key-value-pair} "," @var{key-value-pairs};
6211
6212@var{key-value-pair} = @var{key} "=" @var{value};
6213
6214@var{key} = ? string without a '=' ? ;
6215@var{value} = ? string without a ',' ? ;
6216
6217@end smallexample
6218
6219@opindex fdiagnostics-set-output
6220@item -fdiagnostics-set-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
6221This works in a similar way to @option{-fdiagnostics-add-output=} except
6222that instead of adding an additional ``output sink'' for diagnostics, it
6223replaces all existing output sinks, such as from @option{-fdiagnostics-format=},
6224@option{-fdiagnostics-add-output=}, or a prior call to
6225@option{-fdiagnostics-set-output=}.
6226
3bd8241a
DM
6227@opindex fno-diagnostics-json-formatting
6228@opindex fdiagnostics-json-formatting
6229@item -fno-diagnostics-json-formatting
6230By default, when JSON is emitted for diagnostics (via
51ce3734
DM
6231@option{-fdiagnostics-format=sarif-stderr} or
6232@option{-fdiagnostics-format=sarif-file}),
3bd8241a
DM
6233GCC will add newlines and indentation to visually emphasize the
6234hierarchical structure of the JSON.
6235
6236Use @option{-fno-diagnostics-json-formatting} to suppress this whitespace.
6237It must be passed before the option it is to affect.
6238
6239This is intended for compatibility with tools that do not expect the output
6240to contain newlines, such as that emitted by older GCC releases.
6241
d77de738
ML
6242@end table
6243
6244@node Warning Options
6245@section Options to Request or Suppress Warnings
6246@cindex options to control warnings
6247@cindex warning messages
6248@cindex messages, warning
6249@cindex suppressing warnings
6250
6251Warnings are diagnostic messages that report constructions that
6252are not inherently erroneous but that are risky or suggest there
6253may have been an error.
6254
6255The following language-independent options do not enable specific
6256warnings but control the kinds of diagnostics produced by GCC@.
6257
6258@table @gcctabopt
6259@cindex syntax checking
d77de738 6260@opindex fsyntax-only
ddf6fe37 6261@item -fsyntax-only
d77de738
ML
6262Check the code for syntax errors, but don't do anything beyond that.
6263
d77de738 6264@opindex fmax-errors
ddf6fe37 6265@item -fmax-errors=@var{n}
d77de738
ML
6266Limits the maximum number of error messages to @var{n}, at which point
6267GCC bails out rather than attempting to continue processing the source
6268code. If @var{n} is 0 (the default), there is no limit on the number
6269of error messages produced. If @option{-Wfatal-errors} is also
6270specified, then @option{-Wfatal-errors} takes precedence over this
6271option.
6272
d77de738 6273@opindex w
ddf6fe37 6274@item -w
d77de738
ML
6275Inhibit all warning messages.
6276
d77de738
ML
6277@opindex Werror
6278@opindex Wno-error
ddf6fe37 6279@item -Werror
0acac6c4 6280Turn all warnings into errors.
d77de738 6281
d77de738
ML
6282@opindex Werror=
6283@opindex Wno-error=
ddf6fe37 6284@item -Werror=
0acac6c4 6285Turn the specified warning into an error. The specifier for a warning
d77de738
ML
6286is appended; for example @option{-Werror=switch} turns the warnings
6287controlled by @option{-Wswitch} into errors. This switch takes a
6288negative form, to be used to negate @option{-Werror} for specific
6289warnings; for example @option{-Wno-error=switch} makes
6290@option{-Wswitch} warnings not be errors, even when @option{-Werror}
6291is in effect.
6292
6293The warning message for each controllable warning includes the
6294option that controls the warning. That option can then be used with
6295@option{-Werror=} and @option{-Wno-error=} as described above.
6296(Printing of the option in the warning message can be disabled using the
6297@option{-fno-diagnostics-show-option} flag.)
6298
6299Note that specifying @option{-Werror=}@var{foo} automatically implies
6300@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6301imply anything.
6302
d77de738
ML
6303@opindex Wfatal-errors
6304@opindex Wno-fatal-errors
ddf6fe37 6305@item -Wfatal-errors
d77de738
ML
6306This option causes the compiler to abort compilation on the first error
6307occurred rather than trying to keep going and printing further error
6308messages.
6309
6310@end table
6311
6312You can request many specific warnings with options beginning with
5c06ad9a
SL
6313@samp{-W}, for example @option{-Wunused-variable} to request warnings on
6314declarations of variables that are never used.
6315Each of these specific warning options also
6316has a negative form beginning with @samp{-Wno-} to turn off warnings; for
6317example, @option{-Wno-unused-variable}. This manual lists only one of the
d77de738
ML
6318two forms, whichever is not the default. For further
6319language-specific options also refer to @ref{C++ Dialect Options} and
6320@ref{Objective-C and Objective-C++ Dialect Options}.
6321Additional warnings can be produced by enabling the static analyzer;
6322@xref{Static Analyzer Options}.
6323
6324Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6325options, such as @option{-Wunused}, which may turn on further options,
5c06ad9a 6326such as @option{-Wunused-variable}. The combined effect of positive and
d77de738 6327negative forms is that more specific options have priority over less
5c06ad9a 6328specific ones, independently of their position in the command line. For
d77de738
ML
6329options of the same specificity, the last one takes effect. Options
6330enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5c06ad9a 6331as if they appeared at the end of the command line.
d77de738
ML
6332
6333When an unrecognized warning option is requested (e.g.,
5c06ad9a 6334@option{-Wunknown-warning}), GCC gives an error stating
d77de738
ML
6335that the option is not recognized. However, if the @option{-Wno-} form
6336is used, the behavior is slightly different: no diagnostic is
6337produced for @option{-Wno-unknown-warning} unless other diagnostics
6338are being produced. This allows the use of new @option{-Wno-} options
6339with old compilers, but if something goes wrong, the compiler
6340warns that an unrecognized option is present.
6341
6342The effectiveness of some warnings depends on optimizations also being
5c06ad9a
SL
6343enabled. For example, @option{-Wsuggest-final-types} is more effective
6344with link-time optimization. Some other warnings may
d77de738 6345not be issued at all unless optimization is enabled. While optimization
5c06ad9a
SL
6346in general improves the efficacy of warnings about control and data-flow
6347problems, in some cases it may also cause false positives.
d77de738
ML
6348
6349@table @gcctabopt
d77de738
ML
6350@opindex pedantic
6351@opindex Wpedantic
6352@opindex Wno-pedantic
ddf6fe37
AA
6353@item -Wpedantic
6354@itemx -pedantic
d77de738 6355Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
6356diagnose all programs that use forbidden extensions, and some other
6357programs that do not follow ISO C and ISO C++. This follows the version
6358of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
6359
6360Valid ISO C and ISO C++ programs should compile properly with or without
6361this option (though a rare few require @option{-ansi} or a
5fccebdb 6362@option{-std} option specifying the version of the standard)@. However,
d77de738 6363without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6364features are supported as well. With this option, they are diagnosed
6365(or rejected with @option{-pedantic-errors}).
d77de738
ML
6366
6367@option{-Wpedantic} does not cause warning messages for use of the
6368alternate keywords whose names begin and end with @samp{__}. This alternate
6369format can also be used to disable warnings for non-ISO @samp{__intN} types,
6370i.e. @samp{__intN__}.
6371Pedantic warnings are also disabled in the expression that follows
6372@code{__extension__}. However, only system header files should use
6373these escape routes; application programs should avoid them.
6374@xref{Alternate Keywords}.
6375
5fccebdb
JM
6376Some warnings about non-conforming programs are controlled by options
6377other than @option{-Wpedantic}; in many cases they are implied by
6378@option{-Wpedantic} but can be disabled separately by their specific
6379option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6380
6381Where the standard specified with @option{-std} represents a GNU
6382extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6383corresponding @dfn{base standard}, the version of ISO C on which the GNU
6384extended dialect is based. Warnings from @option{-Wpedantic} are given
6385where they are required by the base standard. (It does not make sense
6386for such warnings to be given only for features not in the specified GNU
6387C dialect, since by definition the GNU dialects of C include all
6388features the compiler supports with the given option, and there would be
6389nothing to warn about.)
6390
d77de738 6391@opindex pedantic-errors
ddf6fe37 6392@item -pedantic-errors
d77de738
ML
6393Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6394requires a diagnostic, in some cases where there is undefined behavior
6395at compile-time and in some other cases that do not prevent compilation
6396of programs that are valid according to the standard. This is not
5fccebdb
JM
6397equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6398useful, as it only makes errors of the diagnostics that are controlled by
6399@option{-Wpedantic}, whereas this option also affects required diagnostics that
6400are always enabled or controlled by options other than @option{-Wpedantic}.
6401
6402If you want the required diagnostics that are warnings by default to
6403be errors instead, but don't also want to enable the @option{-Wpedantic}
6404diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6405(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6406only as warnings).
6407
6408Some required diagnostics are errors by default, but can be reduced to
6409warnings using @option{-fpermissive} or their specific warning option,
6410e.g. @option{-Wno-error=narrowing}.
6411
6412Some diagnostics for non-ISO practices are controlled by specific
6413warning options other than @option{-Wpedantic}, but are also made
6414errors by @option{-pedantic-errors}. For instance:
6415
6416@gccoptlist{
6417-Wattributes @r{(for standard attributes)}
6418-Wchanges-meaning @r{(C++)}
6419-Wcomma-subscript @r{(C++23 or later)}
6420-Wdeclaration-after-statement @r{(C90 or earlier)}
b106f11d 6421-Welaborated-enum-base @r{(C++11 or later)}
5fccebdb
JM
6422-Wimplicit-int @r{(C99 or later)}
6423-Wimplicit-function-declaration @r{(C99 or later)}
6424-Wincompatible-pointer-types
6425-Wint-conversion
6426-Wlong-long @r{(C90 or earlier)}
6427-Wmain
6428-Wnarrowing @r{(C++11 or later)}
6429-Wpointer-arith
6430-Wpointer-sign
6431-Wincompatible-pointer-types
6432-Wregister @r{(C++17 or later)}
6433-Wvla @r{(C90 or earlier)}
6434-Wwrite-strings @r{(C++11 or later)}
6435}
d77de738 6436
ef10cb86
JM
6437@opindex fpermissive
6438@item -fpermissive
6439Downgrade some required diagnostics about nonconformant code from
6440errors to warnings. Thus, using @option{-fpermissive} allows some
6441nonconforming code to compile. Some C++ diagnostics are controlled
da4315f5
FW
6442only by this flag, but it also downgrades some C and C++ diagnostics
6443that have their own flag:
ef10cb86
JM
6444
6445@gccoptlist{
ff9efa3f 6446-Wdeclaration-missing-parameter-type @r{(C and Objective-C only)}
55e94561 6447-Wimplicit-function-declaration @r{(C and Objective-C only)}
4ee2aca7 6448-Wimplicit-int @r{(C and Objective-C only)}
9715c545 6449-Wincompatible-pointer-types @r{(C and Objective-C only)}
2c3db94d 6450-Wint-conversion @r{(C and Objective-C only)}
fa99f7d1 6451-Wnarrowing @r{(C++ and Objective-C++ only)}
4ecfa6c4 6452-Wreturn-mismatch @r{(C and Objective-C only)}
596d1ed9 6453-Wtemplate-body @r{(C++ and Objective-C++ only)}
ef10cb86
JM
6454}
6455
da4315f5
FW
6456The @option{-fpermissive} option is the default for historic C language
6457modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6458@option{-std=gnu90}).
6459
d77de738
ML
6460@opindex Wall
6461@opindex Wno-all
ddf6fe37 6462@item -Wall
d77de738
ML
6463This enables all the warnings about constructions that some users
6464consider questionable, and that are easy to avoid (or modify to
6465prevent the warning), even in conjunction with macros. This also
6466enables some language-specific warnings described in @ref{C++ Dialect
6467Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6468
6469@option{-Wall} turns on the following warning flags:
6470
43b72ede 6471@gccoptlist{-Waddress
7e758890 6472-Waligned-new @r{(C++ and Objective-C++ only)}
43b72ede
AA
6473-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6474-Warray-compare
7e758890 6475-Warray-parameter=2
43b72ede
AA
6476-Wbool-compare
6477-Wbool-operation
7e758890 6478-Wc++11-compat -Wc++14-compat -Wc++17compat -Wc++20compat
43b72ede
AA
6479-Wcatch-value @r{(C++ and Objective-C++ only)}
6480-Wchar-subscripts
7e758890 6481-Wclass-memaccess @r{(C++ and Objective-C++ only)}
43b72ede 6482-Wcomment
7e758890 6483-Wdangling-else
43b72ede 6484-Wdangling-pointer=2
7e758890 6485-Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
43b72ede
AA
6486-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6487-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6488-Wenum-int-mismatch @r{(C and Objective-C only)}
7e758890
SL
6489-Wformat=1
6490-Wformat-contains-nul
6491-Wformat-diag
6492-Wformat-extra-args
6493-Wformat-overflow=1
6494-Wformat-truncation=1
6495-Wformat-zero-length
6496-Wframe-address
43b72ede 6497-Wimplicit @r{(C and Objective-C only)}
43b72ede 6498-Wimplicit-function-declaration @r{(C and Objective-C only)}
7e758890
SL
6499-Wimplicit-int @r{(C and Objective-C only)}
6500-Winfinite-recursion
6501-Winit-self @r{(C++ and Objective-C++ only)}
6502-Wint-in-bool-context
43b72ede
AA
6503-Wlogical-not-parentheses
6504-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6505-Wmaybe-uninitialized
6506-Wmemset-elt-size
6507-Wmemset-transposed-args
6508-Wmisleading-indentation @r{(only for C/C++)}
6509-Wmismatched-dealloc
7e758890 6510-Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
43b72ede
AA
6511-Wmissing-attributes
6512-Wmissing-braces @r{(only for C/ObjC)}
6513-Wmultistatement-macros
7e758890 6514-Wnarrowing @r{(C++ and Objective-C++ only)}
43b72ede
AA
6515-Wnonnull
6516-Wnonnull-compare
7e758890
SL
6517-Wopenmp-simd @r{(C and C++ only)}
6518-Woverloaded-virtual=1 @r{(C++ and Objective-C++ only)}
6519-Wpacked-not-aligned
43b72ede 6520-Wparentheses
7e758890
SL
6521-Wpessimizing-move @r{(C++ and Objective-C++ only)}
6522-Wpointer-sign @r{(only for C/ObjC)}
6523-Wrange-loop-construct @r{(C++ and Objective-C++ only)}
6524-Wreorder @r{(C++ and Objective-C++ only)}
43b72ede
AA
6525-Wrestrict
6526-Wreturn-type
7e758890 6527-Wself-move @r{(C++ and Objective-C++ only)}
43b72ede 6528-Wsequence-point
7e758890 6529-Wsign-compare @r{(C++ and Objective-C++ only)}
43b72ede
AA
6530-Wsizeof-array-div
6531-Wsizeof-pointer-div
6532-Wsizeof-pointer-memaccess
6533-Wstrict-aliasing
6534-Wstrict-overflow=1
6535-Wswitch
6536-Wtautological-compare
6537-Wtrigraphs
6538-Wuninitialized
6539-Wunknown-pragmas
7e758890
SL
6540-Wunused
6541-Wunused-but-set-variable
6542-Wunused-const-variable=1 @r{(only for C/ObjC)}
43b72ede
AA
6543-Wunused-function
6544-Wunused-label
7e758890 6545-Wunused-local-typedefs
43b72ede
AA
6546-Wunused-value
6547-Wunused-variable
6548-Wuse-after-free=2
7e758890 6549-Wvla-parameter
43b72ede 6550-Wvolatile-register-var
d77de738
ML
6551-Wzero-length-bounds}
6552
6553Note that some warning flags are not implied by @option{-Wall}. Some of
6554them warn about constructions that users generally do not consider
6555questionable, but which occasionally you might wish to check for;
6556others warn about constructions that are necessary or hard to avoid in
6557some cases, and there is no simple way to modify the code to suppress
6558the warning. Some of them are enabled by @option{-Wextra} but many of
6559them must be enabled individually.
6560
d77de738
ML
6561@opindex W
6562@opindex Wextra
6563@opindex Wno-extra
ddf6fe37 6564@item -Wextra
d77de738
ML
6565This enables some extra warning flags that are not enabled by
6566@option{-Wall}. (This option used to be called @option{-W}. The older
6567name is still supported, but the newer name is more descriptive.)
6568
7e758890
SL
6569@gccoptlist{-Wabsolute-value @r{(only for C/ObjC)}
6570-Walloc-size
6571-Wcalloc-transposed-args
43b72ede 6572-Wcast-function-type
7e758890 6573-Wclobbered
5ebfaf2d 6574-Wdangling-reference @r{(C++ only)}
7e758890 6575-Wdeprecated-copy @r{(C++ and Objective-C++ only)}
43b72ede 6576-Wempty-body
7e758890
SL
6577-Wenum-conversion @r{(only for C/ObjC)}
6578-Wexpansion-to-defined
6579-Wignored-qualifiers @r{(only for C/C++)}
43b72ede 6580-Wimplicit-fallthrough=3
7e758890 6581-Wmaybe-uninitialized
43b72ede 6582-Wmissing-field-initializers
8833389e 6583-Wmissing-parameter-name @r{(C/ObjC only)}
7e758890
SL
6584-Wmissing-parameter-type @r{(C/ObjC only)}
6585-Wold-style-declaration @r{(C/ObjC only)}
6586-Woverride-init @r{(C/ObjC only)}
6587-Wredundant-move @r{(C++ and Objective-C++ only)}
6588-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6589-Wsign-compare @r{(C++ and Objective-C++ only)}
6590-Wsized-deallocation @r{(C++ and Objective-C++ only)}
43b72ede 6591-Wstring-compare
43b72ede
AA
6592-Wtype-limits
6593-Wuninitialized
44c9403e 6594-Wunterminated-string-initialization
43b72ede 6595-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6596-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6597
d77de738
ML
6598The option @option{-Wextra} also prints warning messages for the
6599following cases:
6600
6601@itemize @bullet
6602
6603@item
6604A pointer is compared against integer zero with @code{<}, @code{<=},
6605@code{>}, or @code{>=}.
6606
6607@item
6608(C++ only) An enumerator and a non-enumerator both appear in a
6609conditional expression.
6610
6611@item
6612(C++ only) Ambiguous virtual bases.
6613
6614@item
6615(C++ only) Subscripting an array that has been declared @code{register}.
6616
6617@item
6618(C++ only) Taking the address of a variable that has been declared
6619@code{register}.
6620
6621@item
6622(C++ only) A base class is not initialized in the copy constructor
6623of a derived class.
6624
6625@end itemize
6626
d77de738
ML
6627@opindex Wabi
6628@opindex Wno-abi
ddf6fe37 6629@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6630
6631Warn about code affected by ABI changes. This includes code that may
6632not be compatible with the vendor-neutral C++ ABI as well as the psABI
027491d7
SL
6633for the particular target. The latter warnings are also controlled
6634separately by @option{-Wpsabi}, which is implied by @option{-Wabi}.
d77de738
ML
6635
6636Since G++ now defaults to updating the ABI with each major release,
6637normally @option{-Wabi} warns only about C++ ABI compatibility
6638problems if there is a check added later in a release series for an
6639ABI issue discovered since the initial release. @option{-Wabi} warns
6640about more things if an older ABI version is selected (with
6641@option{-fabi-version=@var{n}}).
6642
6643@option{-Wabi} can also be used with an explicit version number to
6644warn about C++ ABI compatibility with a particular @option{-fabi-version}
6645level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6646@option{-fabi-version=2}.
6647
6648If an explicit version number is provided and
6649@option{-fabi-compat-version} is not specified, the version number
6650from this option is used for compatibility aliases. If no explicit
6651version number is provided with this option, but
6652@option{-fabi-compat-version} is specified, that version number is
6653used for C++ ABI warnings.
6654
6655Although an effort has been made to warn about
6656all such cases, there are probably some cases that are not warned about,
6657even though G++ is generating incompatible code. There may also be
6658cases where warnings are emitted even though the code that is generated
6659is compatible.
6660
6661You should rewrite your code to avoid these warnings if you are
6662concerned about the fact that code generated by G++ may not be binary
6663compatible with code generated by other compilers.
6664
6665Known incompatibilities in @option{-fabi-version=2} (which was the
6666default from GCC 3.4 to 4.9) include:
6667
6668@itemize @bullet
6669
6670@item
6671A template with a non-type template parameter of reference type was
6672mangled incorrectly:
6673@smallexample
6674extern int N;
6675template <int &> struct S @{@};
6676void n (S<N>) @{2@}
6677@end smallexample
6678
6679This was fixed in @option{-fabi-version=3}.
6680
6681@item
6682SIMD vector types declared using @code{__attribute ((vector_size))} were
6683mangled in a non-standard way that does not allow for overloading of
6684functions taking vectors of different sizes.
6685
6686The mangling was changed in @option{-fabi-version=4}.
6687
6688@item
6689@code{__attribute ((const))} and @code{noreturn} were mangled as type
6690qualifiers, and @code{decltype} of a plain declaration was folded away.
6691
6692These mangling issues were fixed in @option{-fabi-version=5}.
6693
6694@item
6695Scoped enumerators passed as arguments to a variadic function are
6696promoted like unscoped enumerators, causing @code{va_arg} to complain.
6697On most targets this does not actually affect the parameter passing
6698ABI, as there is no way to pass an argument smaller than @code{int}.
6699
6700Also, the ABI changed the mangling of template argument packs,
6701@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6702a class scope function used as a template argument.
6703
6704These issues were corrected in @option{-fabi-version=6}.
6705
6706@item
6707Lambdas in default argument scope were mangled incorrectly, and the
6708ABI changed the mangling of @code{nullptr_t}.
6709
6710These issues were corrected in @option{-fabi-version=7}.
6711
6712@item
6713When mangling a function type with function-cv-qualifiers, the
6714un-qualified function type was incorrectly treated as a substitution
6715candidate.
6716
6717This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6718
6719@item
6720@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6721unaligned accesses. Note that this did not affect the ABI of a
6722function with a @code{nullptr_t} parameter, as parameters have a
6723minimum alignment.
6724
6725This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6726
6727@item
6728Target-specific attributes that affect the identity of a type, such as
6729ia32 calling conventions on a function type (stdcall, regparm, etc.),
6730did not affect the mangled name, leading to name collisions when
6731function pointers were used as template arguments.
6732
6733This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6734
6735@end itemize
6736
027491d7
SL
6737@opindex Wpsabi
6738@opindex Wno-psabi
6739@item -Wpsabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738 6740
027491d7
SL
6741@option{-Wpsabi} enables warnings about processor-specific ABI
6742changes, such as changes in alignment requirements or how function
6743arguments are passed. On several targets, including AArch64, ARM,
6744x86, MIPS, RS6000/PowerPC, and S/390, these details have changed
6745between different versions of GCC and/or different versions of the C
6746or C++ language standards in ways that affect binary compatibility of
6747compiled code. With @option{-Wpsabi}, GCC can detect potentially
6748incompatible usages and warn you about them.
d77de738 6749
027491d7
SL
6750@option{-Wpsabi} is enabled by default, and is also implied by
6751@option{-Wabi}.
d77de738 6752
11f0ea45
AP
6753@opindex Wchanges-meaning
6754@opindex Wno-changes-meaning
e2f939d3
JM
6755@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6756C++ requires that unqualified uses of a name within a class have the
6757same meaning in the complete scope of the class, so declaring the name
6758after using it is ill-formed:
6759@smallexample
6760struct A;
6761struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6762struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6763@end smallexample
6764By default, the B1 case is only a warning because the two declarations
6765have the same type, while the B2 case is an error. Both diagnostics
6766can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6767error case can be reduced to a warning with
6768@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6769
6770Both diagnostics are also suppressed by @option{-fms-extensions}.
6771
d77de738
ML
6772@opindex Wchar-subscripts
6773@opindex Wno-char-subscripts
ddf6fe37 6774@item -Wchar-subscripts
d77de738
ML
6775Warn if an array subscript has type @code{char}. This is a common cause
6776of error, as programmers often forget that this type is signed on some
6777machines.
6778This warning is enabled by @option{-Wall}.
6779
d77de738
ML
6780@opindex Wno-coverage-mismatch
6781@opindex Wcoverage-mismatch
ddf6fe37 6782@item -Wno-coverage-mismatch
d77de738
ML
6783Warn if feedback profiles do not match when using the
6784@option{-fprofile-use} option.
6785If a source file is changed between compiling with @option{-fprofile-generate}
6786and with @option{-fprofile-use}, the files with the profile feedback can fail
6787to match the source file and GCC cannot use the profile feedback
6788information. By default, this warning is enabled and is treated as an
6789error. @option{-Wno-coverage-mismatch} can be used to disable the
6790warning or @option{-Wno-error=coverage-mismatch} can be used to
6791disable the error. Disabling the error for this warning can result in
6792poorly optimized code and is useful only in the
6793case of very minor changes such as bug fixes to an existing code-base.
6794Completely disabling the warning is not recommended.
6795
08a52331
JK
6796@opindex Wno-coverage-too-many-conditions
6797@opindex Wcoverage-too-many-conditions
6798@item -Wno-coverage-too-many-conditions
6799Warn if @option{-fcondition-coverage} is used and an expression have too many
6800terms and GCC gives up coverage. Coverage is given up when there are more
6801terms in the conditional than there are bits in a @code{gcov_type_unsigned}.
6802This warning is enabled by default.
6803
8ed2d5d2
JK
6804@opindex Wno-coverage-too-many-paths
6805@opindex Wcoverage-too-many-paths
6806@item -Wno-coverage-too-many-paths
6807Warn if @option{-fpath-coverage} is used and a function has too many
6808paths and GCC gives up coverage. Giving up is controlled by
6809@option{-fpath-coverage-limit}. This warning is enabled by default.
6810
d77de738
ML
6811@opindex Wno-coverage-invalid-line-number
6812@opindex Wcoverage-invalid-line-number
ddf6fe37 6813@item -Wno-coverage-invalid-line-number
d77de738
ML
6814Warn in case a function ends earlier than it begins due
6815to an invalid linenum macros. The warning is emitted only
6816with @option{--coverage} enabled.
6817
6818By default, this warning is enabled and is treated as an
6819error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6820warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6821disable the error.
6822
d77de738
ML
6823@opindex Wno-cpp
6824@opindex Wcpp
ddf6fe37 6825@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6826Suppress warning messages emitted by @code{#warning} directives.
6827
d77de738
ML
6828@opindex Wdouble-promotion
6829@opindex Wno-double-promotion
ddf6fe37 6830@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6831Give a warning when a value of type @code{float} is implicitly
6832promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6833floating-point unit implement @code{float} in hardware, but emulate
6834@code{double} in software. On such a machine, doing computations
6835using @code{double} values is much more expensive because of the
6836overhead required for software emulation.
6837
6838It is easy to accidentally do computations with @code{double} because
6839floating-point literals are implicitly of type @code{double}. For
6840example, in:
6841@smallexample
6842@group
6843float area(float radius)
6844@{
6845 return 3.14159 * radius * radius;
6846@}
6847@end group
6848@end smallexample
6849the compiler performs the entire computation with @code{double}
6850because the floating-point literal is a @code{double}.
6851
d77de738
ML
6852@opindex Wduplicate-decl-specifier
6853@opindex Wno-duplicate-decl-specifier
ddf6fe37 6854@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6855Warn if a declaration has duplicate @code{const}, @code{volatile},
6856@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6857@option{-Wall}.
6858
d77de738
ML
6859@opindex Wformat
6860@opindex Wno-format
6861@opindex ffreestanding
6862@opindex fno-builtin
6863@opindex Wformat=
ddf6fe37
AA
6864@item -Wformat
6865@itemx -Wformat=@var{n}
d77de738
ML
6866Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6867the arguments supplied have types appropriate to the format string
6868specified, and that the conversions specified in the format string make
6869sense. This includes standard functions, and others specified by format
6870attributes (@pxref{Function Attributes}), in the @code{printf},
6871@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6872not in the C standard) families (or other target-specific families).
6873Which functions are checked without format attributes having been
6874specified depends on the standard version selected, and such checks of
6875functions without the attribute specified are disabled by
6876@option{-ffreestanding} or @option{-fno-builtin}.
6877
6878The formats are checked against the format features supported by GNU
6879libc version 2.2. These include all ISO C90 and C99 features, as well
6880as features from the Single Unix Specification and some BSD and GNU
6881extensions. Other library implementations may not support all these
6882features; GCC does not support warning about features that go beyond a
6883particular library's limitations. However, if @option{-Wpedantic} is used
6884with @option{-Wformat}, warnings are given about format features not
6885in the selected standard version (but not for @code{strfmon} formats,
6886since those are not in any version of the C standard). @xref{C Dialect
6887Options,,Options Controlling C Dialect}.
6888
6889@table @gcctabopt
d77de738
ML
6890@opindex Wformat
6891@opindex Wformat=1
ddf6fe37
AA
6892@item -Wformat=1
6893@itemx -Wformat
d77de738
ML
6894Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6895@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6896@option{-Wformat} also checks for null format arguments for several
6897functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6898aspects of this level of format checking can be disabled by the
6899options: @option{-Wno-format-contains-nul},
6900@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6901@option{-Wformat} is enabled by @option{-Wall}.
6902
d77de738 6903@opindex Wformat=2
ddf6fe37 6904@item -Wformat=2
d77de738
ML
6905Enable @option{-Wformat} plus additional format checks. Currently
6906equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6907-Wformat-y2k}.
6908@end table
6909
d77de738
ML
6910@opindex Wno-format-contains-nul
6911@opindex Wformat-contains-nul
ddf6fe37 6912@item -Wno-format-contains-nul
d77de738
ML
6913If @option{-Wformat} is specified, do not warn about format strings that
6914contain NUL bytes.
6915
d77de738
ML
6916@opindex Wno-format-extra-args
6917@opindex Wformat-extra-args
ddf6fe37 6918@item -Wno-format-extra-args
d77de738
ML
6919If @option{-Wformat} is specified, do not warn about excess arguments to a
6920@code{printf} or @code{scanf} format function. The C standard specifies
6921that such arguments are ignored.
6922
6923Where the unused arguments lie between used arguments that are
6924specified with @samp{$} operand number specifications, normally
6925warnings are still given, since the implementation could not know what
6926type to pass to @code{va_arg} to skip the unused arguments. However,
6927in the case of @code{scanf} formats, this option suppresses the
6928warning if the unused arguments are all pointers, since the Single
6929Unix Specification says that such unused arguments are allowed.
6930
d77de738
ML
6931@opindex Wformat-overflow
6932@opindex Wno-format-overflow
ddf6fe37
AA
6933@item -Wformat-overflow
6934@itemx -Wformat-overflow=@var{level}
d77de738
ML
6935Warn about calls to formatted input/output functions such as @code{sprintf}
6936and @code{vsprintf} that might overflow the destination buffer. When the
6937exact number of bytes written by a format directive cannot be determined
6938at compile-time it is estimated based on heuristics that depend on the
6939@var{level} argument and on optimization. While enabling optimization
6940will in most cases improve the accuracy of the warning, it may also
6941result in false positives.
6942
6943@table @gcctabopt
d77de738
ML
6944@opindex Wformat-overflow
6945@opindex Wno-format-overflow
ddf6fe37
AA
6946@item -Wformat-overflow
6947@itemx -Wformat-overflow=1
d77de738
ML
6948Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6949employs a conservative approach that warns only about calls that most
6950likely overflow the buffer. At this level, numeric arguments to format
6951directives with unknown values are assumed to have the value of one, and
6952strings of unknown length to be empty. Numeric arguments that are known
6953to be bounded to a subrange of their type, or string arguments whose output
6954is bounded either by their directive's precision or by a finite set of
6955string literals, are assumed to take on the value within the range that
6956results in the most bytes on output. For example, the call to @code{sprintf}
6957below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6958the terminating NUL character (@code{'\0'}) appended by the function
6959to the destination buffer will be written past its end. Increasing
6960the size of the buffer by a single byte is sufficient to avoid the
6961warning, though it may not be sufficient to avoid the overflow.
6962
6963@smallexample
6964void f (int a, int b)
6965@{
6966 char buf [13];
6967 sprintf (buf, "a = %i, b = %i\n", a, b);
6968@}
6969@end smallexample
6970
6971@item -Wformat-overflow=2
6972Level @var{2} warns also about calls that might overflow the destination
6973buffer given an argument of sufficient length or magnitude. At level
6974@var{2}, unknown numeric arguments are assumed to have the minimum
6975representable value for signed types with a precision greater than 1, and
6976the maximum representable value otherwise. Unknown string arguments whose
6977length cannot be assumed to be bounded either by the directive's precision,
6978or by a finite set of string literals they may evaluate to, or the character
6979array they may point to, are assumed to be 1 character long.
6980
6981At level @var{2}, the call in the example above is again diagnosed, but
6982this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6983@code{%i} directive will write some of its digits beyond the end of
6984the destination buffer. To make the call safe regardless of the values
6985of the two variables, the size of the destination buffer must be increased
6986to at least 34 bytes. GCC includes the minimum size of the buffer in
6987an informational note following the warning.
6988
6989An alternative to increasing the size of the destination buffer is to
6990constrain the range of formatted values. The maximum length of string
6991arguments can be bounded by specifying the precision in the format
6992directive. When numeric arguments of format directives can be assumed
6993to be bounded by less than the precision of their type, choosing
6994an appropriate length modifier to the format specifier will reduce
6995the required buffer size. For example, if @var{a} and @var{b} in the
6996example above can be assumed to be within the precision of
6997the @code{short int} type then using either the @code{%hi} format
6998directive or casting the argument to @code{short} reduces the maximum
6999required size of the buffer to 24 bytes.
7000
7001@smallexample
7002void f (int a, int b)
7003@{
7004 char buf [23];
7005 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
7006@}
7007@end smallexample
7008@end table
7009
d77de738
ML
7010@opindex Wno-format-zero-length
7011@opindex Wformat-zero-length
ddf6fe37 7012@item -Wno-format-zero-length
d77de738
ML
7013If @option{-Wformat} is specified, do not warn about zero-length formats.
7014The C standard specifies that zero-length formats are allowed.
7015
d77de738
ML
7016@opindex Wformat-nonliteral
7017@opindex Wno-format-nonliteral
ddf6fe37 7018@item -Wformat-nonliteral
d77de738
ML
7019If @option{-Wformat} is specified, also warn if the format string is not a
7020string literal and so cannot be checked, unless the format function
7021takes its format arguments as a @code{va_list}.
7022
d77de738
ML
7023@opindex Wformat-security
7024@opindex Wno-format-security
ddf6fe37 7025@item -Wformat-security
d77de738
ML
7026If @option{-Wformat} is specified, also warn about uses of format
7027functions that represent possible security problems. At present, this
7028warns about calls to @code{printf} and @code{scanf} functions where the
7029format string is not a string literal and there are no format arguments,
7030as in @code{printf (foo);}. This may be a security hole if the format
7031string came from untrusted input and contains @samp{%n}. (This is
7032currently a subset of what @option{-Wformat-nonliteral} warns about, but
7033in future warnings may be added to @option{-Wformat-security} that are not
7034included in @option{-Wformat-nonliteral}.)
7035
d77de738
ML
7036@opindex Wformat-signedness
7037@opindex Wno-format-signedness
ddf6fe37 7038@item -Wformat-signedness
d77de738
ML
7039If @option{-Wformat} is specified, also warn if the format string
7040requires an unsigned argument and the argument is signed and vice versa.
7041
d77de738
ML
7042@opindex Wformat-truncation
7043@opindex Wno-format-truncation
ddf6fe37
AA
7044@item -Wformat-truncation
7045@itemx -Wformat-truncation=@var{level}
d77de738
ML
7046Warn about calls to formatted input/output functions such as @code{snprintf}
7047and @code{vsnprintf} that might result in output truncation. When the exact
7048number of bytes written by a format directive cannot be determined at
7049compile-time it is estimated based on heuristics that depend on
7050the @var{level} argument and on optimization. While enabling optimization
7051will in most cases improve the accuracy of the warning, it may also result
7052in false positives. Except as noted otherwise, the option uses the same
7053logic @option{-Wformat-overflow}.
7054
7055@table @gcctabopt
d77de738
ML
7056@opindex Wformat-truncation
7057@opindex Wno-format-truncation
ddf6fe37
AA
7058@item -Wformat-truncation
7059@itemx -Wformat-truncation=1
d77de738
ML
7060Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
7061employs a conservative approach that warns only about calls to bounded
7062functions whose return value is unused and that will most likely result
7063in output truncation.
7064
7065@item -Wformat-truncation=2
7066Level @var{2} warns also about calls to bounded functions whose return
7067value is used and that might result in truncation given an argument of
7068sufficient length or magnitude.
7069@end table
7070
d77de738
ML
7071@opindex Wformat-y2k
7072@opindex Wno-format-y2k
ddf6fe37 7073@item -Wformat-y2k
d77de738
ML
7074If @option{-Wformat} is specified, also warn about @code{strftime}
7075formats that may yield only a two-digit year.
7076
d77de738
ML
7077@opindex Wnonnull
7078@opindex Wno-nonnull
ddf6fe37 7079@item -Wnonnull
d77de738
ML
7080Warn about passing a null pointer for arguments marked as
7081requiring a non-null value by the @code{nonnull} function attribute.
7082
7083@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
7084can be disabled with the @option{-Wno-nonnull} option.
7085
d77de738
ML
7086@opindex Wnonnull-compare
7087@opindex Wno-nonnull-compare
ddf6fe37 7088@item -Wnonnull-compare
d77de738
ML
7089Warn when comparing an argument marked with the @code{nonnull}
7090function attribute against null inside the function.
7091
7092@option{-Wnonnull-compare} is included in @option{-Wall}. It
7093can be disabled with the @option{-Wno-nonnull-compare} option.
7094
d77de738
ML
7095@opindex Wnull-dereference
7096@opindex Wno-null-dereference
ddf6fe37 7097@item -Wnull-dereference
d77de738
ML
7098Warn if the compiler detects paths that trigger erroneous or
7099undefined behavior due to dereferencing a null pointer. This option
7100is only active when @option{-fdelete-null-pointer-checks} is active,
7101which is enabled by optimizations in most targets. The precision of
7102the warnings depends on the optimization options used.
7103
634215cd 7104@opindex Wno-musttail-local-addr
50ca15ba 7105@opindex Wmusttail-local-addr
634215cd
JJ
7106@item -Wno-musttail-local-addr
7107Do not warn about passing a pointer (or in C++, a reference) to a
7108local variable or label to argument of a @code{musttail} call. Those
7109variables go out of scope before the tail call instruction.
7110
7111@opindex Wmaybe-musttail-local-addr
50ca15ba 7112@opindex Wno-maybe-musttail-local-addr
634215cd
JJ
7113@item -Wmaybe-musttail-local-addr
7114Warn when address of a local variable can escape to a @code{musttail}
7115call, unless it goes out of scope already before the @code{musttail}
7116call.
7117
7118@smallexample
7119int foo (int *);
7120
7121int
7122bar (int *x)
7123@{
7124 if (x[0] == 1)
7125 @{
7126 int a = 42;
7127 foo (&a);
7128 /* Without the @code{musttail} attribute this call would not
7129 be tail called, because address of the @code{a} variable escapes
7130 and the second foo call could dereference it. With the attribute
7131 the local variables are assumed to go out of scope immediately
7132 before the tail call instruction and the compiler warns about
7133 this. */
7134 [[gnu::musttail]] return foo (nullptr);
7135 @}
7136 else
7137 @{
7138 @{
7139 int a = 42;
7140 foo (&a);
7141 @}
7142 /* The @code{a} variable isn't already in scope, so even when it
7143 escaped, even without @code{musttail} attribute it would be
7144 undefined behavior to dereference it and the compiler could
7145 turn this into a tail call. No warning is diagnosed here. */
7146 [[gnu::musttail]] return foo (nullptr);
7147 @}
7148@}
7149@end smallexample
7150
7151This warning is enabled by @option{-Wextra}.
7152
2ae5384d
JM
7153@opindex Wnrvo
7154@opindex Wno-nrvo
7155@item -Wnrvo @r{(C++ and Objective-C++ only)}
7156Warn if the compiler does not elide the copy from a local variable to
7157the return value of a function in a context where it is allowed by
7158[class.copy.elision]. This elision is commonly known as the Named
7159Return Value Optimization. For instance, in the example below the
72cfa0f7 7160compiler cannot elide copies from both v1 and v2, so it elides neither.
2ae5384d
JM
7161
7162@smallexample
7163std::vector<int> f()
7164@{
7165 std::vector<int> v1, v2;
7166 // ...
7167 if (cond) return v1;
7168 else return v2; // warning: not eliding copy
7169@}
7170@end smallexample
7171
d77de738
ML
7172@opindex Winfinite-recursion
7173@opindex Wno-infinite-recursion
ddf6fe37 7174@item -Winfinite-recursion
d77de738
ML
7175Warn about infinitely recursive calls. The warning is effective at all
7176optimization levels but requires optimization in order to detect infinite
7177recursion in calls between two or more functions.
7178@option{-Winfinite-recursion} is included in @option{-Wall}.
7179
ce51e843
ML
7180Compare with @option{-Wanalyzer-infinite-recursion} which provides a
7181similar diagnostic, but is implemented in a different way (as part of
7182@option{-fanalyzer}).
7183
d77de738
ML
7184@opindex Winit-self
7185@opindex Wno-init-self
ddf6fe37 7186@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7187Warn about uninitialized variables that are initialized with themselves.
7188Note this option can only be used with the @option{-Wuninitialized} option.
7189
7190For example, GCC warns about @code{i} being uninitialized in the
7191following snippet only when @option{-Winit-self} has been specified:
7192@smallexample
7193@group
7194int f()
7195@{
7196 int i = i;
7197 return i;
7198@}
7199@end group
7200@end smallexample
7201
7202This warning is enabled by @option{-Wall} in C++.
7203
d77de738
ML
7204@opindex Wimplicit-int
7205@opindex Wno-implicit-int
ddf6fe37 7206@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738 7207This option controls warnings when a declaration does not specify a type.
4ee2aca7
FW
7208This warning is enabled by default, as an error, in C99 and later
7209dialects of C, and also by @option{-Wall}. The error can be downgraded
7210to a warning using @option{-fpermissive} (along with certain other
7211errors), or for this error alone, with @option{-Wno-error=implicit-int}.
d77de738 7212
5fccebdb
JM
7213This warning is upgraded to an error by @option{-pedantic-errors}.
7214
d77de738
ML
7215@opindex Wimplicit-function-declaration
7216@opindex Wno-implicit-function-declaration
ddf6fe37 7217@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738 7218This option controls warnings when a function is used before being declared.
55e94561
FW
7219This warning is enabled by default, as an error, in C99 and later
7220dialects of C, and also by @option{-Wall}. The error can be downgraded
7221to a warning using @option{-fpermissive} (along with certain other
7222errors), or for this error alone, with
7223@option{-Wno-error=implicit-function-declaration}.
5fccebdb
JM
7224
7225This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 7226
d77de738
ML
7227@opindex Wimplicit
7228@opindex Wno-implicit
ddf6fe37 7229@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
7230Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
7231This warning is enabled by @option{-Wall}.
7232
24592abd
MP
7233@opindex Whardened
7234@opindex Wno-hardened
7235@item -Whardened
7236Warn when @option{-fhardened} did not enable an option from its set (for
7237which see @option{-fhardened}). For instance, using @option{-fhardened}
7238and @option{-fstack-protector} at the same time on the command line causes
a134dcd8
MP
7239@option{-Whardened} to warn because @option{-fstack-protector-strong} will
7240not be enabled by @option{-fhardened}.
24592abd
MP
7241
7242This warning is enabled by default and has effect only when @option{-fhardened}
7243is enabled.
7244
d77de738
ML
7245@opindex Wimplicit-fallthrough
7246@opindex Wno-implicit-fallthrough
ddf6fe37 7247@item -Wimplicit-fallthrough
d77de738
ML
7248@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
7249and @option{-Wno-implicit-fallthrough} is the same as
7250@option{-Wimplicit-fallthrough=0}.
7251
d77de738 7252@opindex Wimplicit-fallthrough=
ddf6fe37 7253@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
7254Warn when a switch case falls through. For example:
7255
7256@smallexample
7257@group
7258switch (cond)
7259 @{
7260 case 1:
7261 a = 1;
7262 break;
7263 case 2:
7264 a = 2;
7265 case 3:
7266 a = 3;
7267 break;
7268 @}
7269@end group
7270@end smallexample
7271
7272This warning does not warn when the last statement of a case cannot
7273fall through, e.g. when there is a return statement or a call to function
7274declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
7275also takes into account control flow statements, such as ifs, and only
7276warns when appropriate. E.g.@:
7277
7278@smallexample
7279@group
7280switch (cond)
7281 @{
7282 case 1:
7283 if (i > 3) @{
7284 bar (5);
7285 break;
7286 @} else if (i < 1) @{
7287 bar (0);
7288 @} else
7289 return;
7290 default:
7291 @dots{}
7292 @}
7293@end group
7294@end smallexample
7295
7296Since there are occasions where a switch case fall through is desirable,
7297GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
7298to be used along with a null statement to suppress this warning that
7299would normally occur:
7300
7301@smallexample
7302@group
7303switch (cond)
7304 @{
7305 case 1:
7306 bar (0);
7307 __attribute__ ((fallthrough));
7308 default:
7309 @dots{}
7310 @}
7311@end group
7312@end smallexample
7313
7314C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
7315warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
7316or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
7317Instead of these attributes, it is also possible to add a fallthrough comment
7318to silence the warning. The whole body of the C or C++ style comment should
7319match the given regular expressions listed below. The option argument @var{n}
7320specifies what kind of comments are accepted:
7321
7322@itemize @bullet
7323
7324@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
7325
7326@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
7327expression, any comment is used as fallthrough comment.
7328
7329@item @option{-Wimplicit-fallthrough=2} case insensitively matches
7330@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
7331
7332@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
7333following regular expressions:
7334
7335@itemize @bullet
7336
7337@item @code{-fallthrough}
7338
7339@item @code{@@fallthrough@@}
7340
7341@item @code{lint -fallthrough[ \t]*}
7342
7343@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
7344
7345@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7346
7347@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7348
7349@end itemize
7350
7351@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
7352following regular expressions:
7353
7354@itemize @bullet
7355
7356@item @code{-fallthrough}
7357
7358@item @code{@@fallthrough@@}
7359
7360@item @code{lint -fallthrough[ \t]*}
7361
7362@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
7363
7364@end itemize
7365
7366@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
7367fallthrough comments, only attributes disable the warning.
7368
7369@end itemize
7370
7371The comment needs to be followed after optional whitespace and other comments
7372by @code{case} or @code{default} keywords or by a user label that precedes some
7373@code{case} or @code{default} label.
7374
7375@smallexample
7376@group
7377switch (cond)
7378 @{
7379 case 1:
7380 bar (0);
7381 /* FALLTHRU */
7382 default:
7383 @dots{}
7384 @}
7385@end group
7386@end smallexample
7387
7388The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7389
d77de738
ML
7390@opindex Wif-not-aligned
7391@opindex Wno-if-not-aligned
ddf6fe37 7392@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7393Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7394should be issued. These warnings are enabled by default.
7395
d77de738
ML
7396@opindex Wignored-qualifiers
7397@opindex Wno-ignored-qualifiers
ddf6fe37 7398@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
7399Warn if the return type of a function has a type qualifier
7400such as @code{const}. For ISO C such a type qualifier has no effect,
7401since the value returned by a function is not an lvalue.
7402For C++, the warning is only emitted for scalar types or @code{void}.
7403ISO C prohibits qualified @code{void} return types on function
7404definitions, so such return types always receive a warning
7405even without this option.
7406
7407This warning is also enabled by @option{-Wextra}.
7408
d77de738
ML
7409@opindex Wignored-attributes
7410@opindex Wno-ignored-attributes
ddf6fe37 7411@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
7412This option controls warnings when an attribute is ignored.
7413This is different from the
7414@option{-Wattributes} option in that it warns whenever the compiler decides
7415to drop an attribute, not that the attribute is either unknown, used in a
7416wrong place, etc. This warning is enabled by default.
7417
d77de738
ML
7418@opindex Wmain
7419@opindex Wno-main
ddf6fe37 7420@item -Wmain
d77de738
ML
7421Warn if the type of @code{main} is suspicious. @code{main} should be
7422a function with external linkage, returning int, taking either zero
7423arguments, two, or three arguments of appropriate types. This warning
7424is enabled by default in C++ and is enabled by either @option{-Wall}
7425or @option{-Wpedantic}.
7426
5fccebdb
JM
7427This warning is upgraded to an error by @option{-pedantic-errors}.
7428
d77de738
ML
7429@opindex Wmisleading-indentation
7430@opindex Wno-misleading-indentation
ddf6fe37 7431@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
7432Warn when the indentation of the code does not reflect the block structure.
7433Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7434@code{for} clauses with a guarded statement that does not use braces,
7435followed by an unguarded statement with the same indentation.
7436
7437In the following example, the call to ``bar'' is misleadingly indented as
7438if it were guarded by the ``if'' conditional.
7439
7440@smallexample
7441 if (some_condition ())
7442 foo ();
7443 bar (); /* Gotcha: this is not guarded by the "if". */
7444@end smallexample
7445
7446In the case of mixed tabs and spaces, the warning uses the
7447@option{-ftabstop=} option to determine if the statements line up
7448(defaulting to 8).
7449
7450The warning is not issued for code involving multiline preprocessor logic
7451such as the following example.
7452
7453@smallexample
7454 if (flagA)
7455 foo (0);
7456#if SOME_CONDITION_THAT_DOES_NOT_HOLD
7457 if (flagB)
7458#endif
7459 foo (1);
7460@end smallexample
7461
7462The warning is not issued after a @code{#line} directive, since this
7463typically indicates autogenerated code, and no assumptions can be made
7464about the layout of the file that the directive references.
7465
7466This warning is enabled by @option{-Wall} in C and C++.
7467
d77de738
ML
7468@opindex Wmissing-attributes
7469@opindex Wno-missing-attributes
ddf6fe37 7470@item -Wmissing-attributes
d77de738
ML
7471Warn when a declaration of a function is missing one or more attributes
7472that a related function is declared with and whose absence may adversely
7473affect the correctness or efficiency of generated code. For example,
7474the warning is issued for declarations of aliases that use attributes
7475to specify less restrictive requirements than those of their targets.
7476This typically represents a potential optimization opportunity.
7477By contrast, the @option{-Wattribute-alias=2} option controls warnings
7478issued when the alias is more restrictive than the target, which could
7479lead to incorrect code generation.
7480Attributes considered include @code{alloc_align}, @code{alloc_size},
7481@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7482@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7483@code{returns_nonnull}, and @code{returns_twice}.
7484
7485In C++, the warning is issued when an explicit specialization of a primary
7486template declared with attribute @code{alloc_align}, @code{alloc_size},
7487@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7488or @code{nonnull} is declared without it. Attributes @code{deprecated},
7489@code{error}, and @code{warning} suppress the warning.
7490(@pxref{Function Attributes}).
7491
7492You can use the @code{copy} attribute to apply the same
7493set of attributes to a declaration as that on another declaration without
7494explicitly enumerating the attributes. This attribute can be applied
7495to declarations of functions (@pxref{Common Function Attributes}),
7496variables (@pxref{Common Variable Attributes}), or types
7497(@pxref{Common Type Attributes}).
7498
7499@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7500
7501For example, since the declaration of the primary function template
7502below makes use of both attribute @code{malloc} and @code{alloc_size}
7503the declaration of the explicit specialization of the template is
7504diagnosed because it is missing one of the attributes.
7505
7506@smallexample
7507template <class T>
7508T* __attribute__ ((malloc, alloc_size (1)))
7509allocate (size_t);
7510
7511template <>
7512void* __attribute__ ((malloc)) // missing alloc_size
7513allocate<void> (size_t);
7514@end smallexample
7515
d77de738
ML
7516@opindex Wmissing-braces
7517@opindex Wno-missing-braces
ddf6fe37 7518@item -Wmissing-braces
d77de738
ML
7519Warn if an aggregate or union initializer is not fully bracketed. In
7520the following example, the initializer for @code{a} is not fully
7521bracketed, but that for @code{b} is fully bracketed.
7522
7523@smallexample
7524int a[2][2] = @{ 0, 1, 2, 3 @};
7525int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7526@end smallexample
7527
7528This warning is enabled by @option{-Wall}.
7529
d77de738
ML
7530@opindex Wmissing-include-dirs
7531@opindex Wno-missing-include-dirs
ddf6fe37 7532@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
72cfa0f7 7533Warn if a user-supplied include directory does not exist. This option is disabled
d77de738
ML
7534by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7535enabled by default by warning for -I and -J, only.
7536
d77de738
ML
7537@opindex Wmissing-profile
7538@opindex Wno-missing-profile
ddf6fe37 7539@item -Wno-missing-profile
d77de738
ML
7540This option controls warnings if feedback profiles are missing when using the
7541@option{-fprofile-use} option.
7542This option diagnoses those cases where a new function or a new file is added
7543between compiling with @option{-fprofile-generate} and with
7544@option{-fprofile-use}, without regenerating the profiles.
7545In these cases, the profile feedback data files do not contain any
7546profile feedback information for
7547the newly added function or file respectively. Also, in the case when profile
7548count data (.gcda) files are removed, GCC cannot use any profile feedback
7549information. In all these cases, warnings are issued to inform you that a
7550profile generation step is due.
7551Ignoring the warning can result in poorly optimized code.
7552@option{-Wno-missing-profile} can be used to
7553disable the warning, but this is not recommended and should be done only
7554when non-existent profile data is justified.
7555
d77de738
ML
7556@opindex Wmismatched-dealloc
7557@opindex Wno-mismatched-dealloc
ddf6fe37 7558@item -Wmismatched-dealloc
d77de738
ML
7559
7560Warn for calls to deallocation functions with pointer arguments returned
f5964f1a 7561from allocation functions for which the former isn't a suitable
d77de738
ML
7562deallocator. A pair of functions can be associated as matching allocators
7563and deallocators by use of attribute @code{malloc}. Unless disabled by
7564the @option{-fno-builtin} option the standard functions @code{calloc},
7565@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7566forms of C++ @code{operator new} and @code{operator delete} are implicitly
7567associated as matching allocators and deallocators. In the following
7568example @code{mydealloc} is the deallocator for pointers returned from
7569@code{myalloc}.
7570
7571@smallexample
7572void mydealloc (void*);
7573
7574__attribute__ ((malloc (mydealloc, 1))) void*
7575myalloc (size_t);
7576
7577void f (void)
7578@{
7579 void *p = myalloc (32);
7580 // @dots{}use p@dots{}
7581 free (p); // warning: not a matching deallocator for myalloc
7582 mydealloc (p); // ok
7583@}
7584@end smallexample
7585
7586In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7587mismatches involving either @code{operator new} or @code{operator delete}.
7588
7589Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7590
d77de738
ML
7591@opindex Wmultistatement-macros
7592@opindex Wno-multistatement-macros
ddf6fe37 7593@item -Wmultistatement-macros
d77de738
ML
7594Warn about unsafe multiple statement macros that appear to be guarded
7595by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7596@code{while}, in which only the first statement is actually guarded after
7597the macro is expanded.
7598
7599For example:
7600
7601@smallexample
7602#define DOIT x++; y++
7603if (c)
7604 DOIT;
7605@end smallexample
7606
7607will increment @code{y} unconditionally, not just when @code{c} holds.
7608The can usually be fixed by wrapping the macro in a do-while loop:
7609@smallexample
7610#define DOIT do @{ x++; y++; @} while (0)
7611if (c)
7612 DOIT;
7613@end smallexample
7614
7615This warning is enabled by @option{-Wall} in C and C++.
7616
d77de738
ML
7617@opindex Wparentheses
7618@opindex Wno-parentheses
ddf6fe37 7619@item -Wparentheses
d77de738
ML
7620Warn if parentheses are omitted in certain contexts, such
7621as when there is an assignment in a context where a truth value
7622is expected, or when operators are nested whose precedence people
7623often get confused about.
7624
7625Also warn if a comparison like @code{x<=y<=z} appears; this is
7626equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7627interpretation from that of ordinary mathematical notation.
7628
7629Also warn for dangerous uses of the GNU extension to
7630@code{?:} with omitted middle operand. When the condition
7631in the @code{?}: operator is a boolean expression, the omitted value is
7632always 1. Often programmers expect it to be a value computed
7633inside the conditional expression instead.
7634
7635For C++ this also warns for some cases of unnecessary parentheses in
7636declarations, which can indicate an attempt at a function call instead
7637of a declaration:
7638@smallexample
7639@{
7640 // Declares a local variable called mymutex.
7641 std::unique_lock<std::mutex> (mymutex);
7642 // User meant std::unique_lock<std::mutex> lock (mymutex);
7643@}
7644@end smallexample
7645
7646This warning is enabled by @option{-Wall}.
7647
d77de738
ML
7648@opindex Wself-move
7649@opindex Wno-self-move
ddf6fe37 7650@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7651This warning warns when a value is moved to itself with @code{std::move}.
7652Such a @code{std::move} typically has no effect.
7653
7654@smallexample
7655struct T @{
7656@dots{}
7657@};
7658void fn()
7659@{
7660 T t;
7661 @dots{}
7662 t = std::move (t);
7663@}
7664@end smallexample
7665
7666This warning is enabled by @option{-Wall}.
7667
d77de738
ML
7668@opindex Wsequence-point
7669@opindex Wno-sequence-point
ddf6fe37 7670@item -Wsequence-point
d77de738
ML
7671Warn about code that may have undefined semantics because of violations
7672of sequence point rules in the C and C++ standards.
7673
7674The C and C++ standards define the order in which expressions in a C/C++
7675program are evaluated in terms of @dfn{sequence points}, which represent
7676a partial ordering between the execution of parts of the program: those
7677executed before the sequence point, and those executed after it. These
7678occur after the evaluation of a full expression (one which is not part
7679of a larger expression), after the evaluation of the first operand of a
7680@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7681function is called (but after the evaluation of its arguments and the
7682expression denoting the called function), and in certain other places.
7683Other than as expressed by the sequence point rules, the order of
7684evaluation of subexpressions of an expression is not specified. All
7685these rules describe only a partial order rather than a total order,
7686since, for example, if two functions are called within one expression
7687with no sequence point between them, the order in which the functions
7688are called is not specified. However, the standards committee have
7689ruled that function calls do not overlap.
7690
7691It is not specified when between sequence points modifications to the
7692values of objects take effect. Programs whose behavior depends on this
7693have undefined behavior; the C and C++ standards specify that ``Between
7694the previous and next sequence point an object shall have its stored
7695value modified at most once by the evaluation of an expression.
7696Furthermore, the prior value shall be read only to determine the value
7697to be stored.''. If a program breaks these rules, the results on any
7698particular implementation are entirely unpredictable.
7699
7700Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7701= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7702diagnosed by this option, and it may give an occasional false positive
7703result, but in general it has been found fairly effective at detecting
7704this sort of problem in programs.
7705
7706The C++17 standard will define the order of evaluation of operands in
7707more cases: in particular it requires that the right-hand side of an
7708assignment be evaluated before the left-hand side, so the above
7709examples are no longer undefined. But this option will still warn
7710about them, to help people avoid writing code that is undefined in C
7711and earlier revisions of C++.
7712
7713The standard is worded confusingly, therefore there is some debate
7714over the precise meaning of the sequence point rules in subtle cases.
7715Links to discussions of the problem, including proposed formal
7716definitions, may be found on the GCC readings page, at
7717@uref{https://gcc.gnu.org/@/readings.html}.
7718
7719This warning is enabled by @option{-Wall} for C and C++.
7720
d77de738
ML
7721@opindex Wno-return-local-addr
7722@opindex Wreturn-local-addr
ddf6fe37 7723@item -Wno-return-local-addr
d77de738
ML
7724Do not warn about returning a pointer (or in C++, a reference) to a
7725variable that goes out of scope after the function returns.
7726
6e312b2b
FW
7727@opindex Wreturn-mismatch
7728@opindex Wno-return-mismatch
7729@item -Wreturn-mismatch
7730Warn about return statements without an expressions in functions which
7731do not return @code{void}. Also warn about a @code{return} statement
7732with an expression in a function whose return type is @code{void},
7733unless the expression type is also @code{void}. As a GNU extension, the
7734latter case is accepted without a warning unless @option{-Wpedantic} is
7735used.
7736
7737Attempting to use the return value of a non-@code{void} function other
7738than @code{main} that flows off the end by reaching the closing curly
7739brace that terminates the function is undefined.
7740
4ecfa6c4
FW
7741This warning is specific to C and enabled by default. In C99 and later
7742language dialects, it is treated as an error. It can be downgraded
7743to a warning using @option{-fpermissive} (along with other warnings),
7744or for just this warning, with @option{-Wno-error=return-mismatch}.
6e312b2b 7745
d77de738
ML
7746@opindex Wreturn-type
7747@opindex Wno-return-type
ddf6fe37 7748@item -Wreturn-type
6e312b2b
FW
7749Warn whenever a function is defined with a return type that defaults to
7750@code{int} (unless @option{-Wimplicit-int} is active, which takes
7751precedence). Also warn if execution may reach the end of the function
7752body, or if the function does not contain any return statement at all.
7753
7754Attempting to use the return value of a non-@code{void} function other
7755than @code{main} that flows off the end by reaching the closing curly
7756brace that terminates the function is undefined.
d77de738
ML
7757
7758Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7759than @code{main} results in undefined behavior even when the value of
7760the function is not used.
7761
7762This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7763
d77de738
ML
7764@opindex Wshift-count-negative
7765@opindex Wno-shift-count-negative
ddf6fe37 7766@item -Wno-shift-count-negative
d77de738
ML
7767Controls warnings if a shift count is negative.
7768This warning is enabled by default.
7769
d77de738
ML
7770@opindex Wshift-count-overflow
7771@opindex Wno-shift-count-overflow
ddf6fe37 7772@item -Wno-shift-count-overflow
d77de738
ML
7773Controls warnings if a shift count is greater than or equal to the bit width
7774of the type. This warning is enabled by default.
7775
d77de738
ML
7776@opindex Wshift-negative-value
7777@opindex Wno-shift-negative-value
ddf6fe37 7778@item -Wshift-negative-value
d77de738
ML
7779Warn if left shifting a negative value. This warning is enabled by
7780@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7781
d77de738
ML
7782@opindex Wshift-overflow
7783@opindex Wno-shift-overflow
ddf6fe37
AA
7784@item -Wno-shift-overflow
7785@itemx -Wshift-overflow=@var{n}
d77de738
ML
7786These options control warnings about left shift overflows.
7787
7788@table @gcctabopt
7789@item -Wshift-overflow=1
7790This is the warning level of @option{-Wshift-overflow} and is enabled
7791by default in C99 and C++11 modes (and newer). This warning level does
7792not warn about left-shifting 1 into the sign bit. (However, in C, such
7793an overflow is still rejected in contexts where an integer constant expression
7794is required.) No warning is emitted in C++20 mode (and newer), as signed left
7795shifts always wrap.
7796
7797@item -Wshift-overflow=2
7798This warning level also warns about left-shifting 1 into the sign bit,
7799unless C++14 mode (or newer) is active.
7800@end table
7801
d77de738
ML
7802@opindex Wswitch
7803@opindex Wno-switch
ddf6fe37 7804@item -Wswitch
d77de738
ML
7805Warn whenever a @code{switch} statement has an index of enumerated type
7806and lacks a @code{case} for one or more of the named codes of that
7807enumeration. (The presence of a @code{default} label prevents this
1914ca87
JM
7808warning.) @code{case} labels that do not correspond to enumerators also
7809provoke warnings when this option is used, unless the enumeration is marked
7810with the @code{flag_enum} attribute.
d77de738
ML
7811This warning is enabled by @option{-Wall}.
7812
d77de738
ML
7813@opindex Wswitch-default
7814@opindex Wno-switch-default
ddf6fe37 7815@item -Wswitch-default
d77de738
ML
7816Warn whenever a @code{switch} statement does not have a @code{default}
7817case.
7818
d77de738
ML
7819@opindex Wswitch-enum
7820@opindex Wno-switch-enum
ddf6fe37 7821@item -Wswitch-enum
d77de738
ML
7822Warn whenever a @code{switch} statement has an index of enumerated type
7823and lacks a @code{case} for one or more of the named codes of that
1914ca87
JM
7824enumeration. @code{case} labels that do not correspond to enumerators also
7825provoke warnings when this option is used, unless the enumeration is marked
7826with the @code{flag_enum} attribute. The only difference
d77de738
ML
7827between @option{-Wswitch} and this option is that this option gives a
7828warning about an omitted enumeration code even if there is a
7829@code{default} label.
7830
d77de738
ML
7831@opindex Wswitch-bool
7832@opindex Wno-switch-bool
ddf6fe37 7833@item -Wno-switch-bool
d77de738
ML
7834Do not warn when a @code{switch} statement has an index of boolean type
7835and the case values are outside the range of a boolean type.
7836It is possible to suppress this warning by casting the controlling
7837expression to a type other than @code{bool}. For example:
7838@smallexample
7839@group
7840switch ((int) (a == 4))
7841 @{
7842 @dots{}
7843 @}
7844@end group
7845@end smallexample
7846This warning is enabled by default for C and C++ programs.
7847
d77de738
ML
7848@opindex Wswitch-outside-range
7849@opindex Wno-switch-outside-range
ddf6fe37 7850@item -Wno-switch-outside-range
d77de738
ML
7851This option controls warnings when a @code{switch} case has a value
7852that is outside of its
7853respective type range. This warning is enabled by default for
7854C and C++ programs.
7855
d77de738
ML
7856@opindex Wswitch-unreachable
7857@opindex Wno-switch-unreachable
ddf6fe37 7858@item -Wno-switch-unreachable
d77de738
ML
7859Do not warn when a @code{switch} statement contains statements between the
7860controlling expression and the first case label, which will never be
7861executed. For example:
7862@smallexample
7863@group
7864switch (cond)
7865 @{
7866 i = 15;
7867 @dots{}
7868 case 5:
7869 @dots{}
7870 @}
7871@end group
7872@end smallexample
7873@option{-Wswitch-unreachable} does not warn if the statement between the
7874controlling expression and the first case label is just a declaration:
7875@smallexample
7876@group
7877switch (cond)
7878 @{
7879 int i;
7880 @dots{}
7881 case 5:
7882 i = 5;
7883 @dots{}
7884 @}
7885@end group
7886@end smallexample
7887This warning is enabled by default for C and C++ programs.
7888
d77de738
ML
7889@opindex Wsync-nand
7890@opindex Wno-sync-nand
ddf6fe37 7891@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7892Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7893built-in functions are used. These functions changed semantics in GCC 4.4.
7894
d77de738
ML
7895@opindex Wtrivial-auto-var-init
7896@opindex Wno-trivial-auto-var-init
ddf6fe37 7897@item -Wtrivial-auto-var-init
d77de738
ML
7898Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7899variable. A common situation is an automatic variable that is declared
7900between the controlling expression and the first case label of a @code{switch}
7901statement.
7902
d77de738
ML
7903@opindex Wunused-but-set-parameter
7904@opindex Wno-unused-but-set-parameter
ddf6fe37 7905@item -Wunused-but-set-parameter
d77de738
ML
7906Warn whenever a function parameter is assigned to, but otherwise unused
7907(aside from its declaration).
7908
7909To suppress this warning use the @code{unused} attribute
7910(@pxref{Variable Attributes}).
7911
7912This warning is also enabled by @option{-Wunused} together with
7913@option{-Wextra}.
7914
d77de738
ML
7915@opindex Wunused-but-set-variable
7916@opindex Wno-unused-but-set-variable
ddf6fe37 7917@item -Wunused-but-set-variable
d77de738
ML
7918Warn whenever a local variable is assigned to, but otherwise unused
7919(aside from its declaration).
7920This warning is enabled by @option{-Wall}.
7921
7922To suppress this warning use the @code{unused} attribute
7923(@pxref{Variable Attributes}).
7924
7925This warning is also enabled by @option{-Wunused}, which is enabled
7926by @option{-Wall}.
7927
d77de738
ML
7928@opindex Wunused-function
7929@opindex Wno-unused-function
ddf6fe37 7930@item -Wunused-function
d77de738
ML
7931Warn whenever a static function is declared but not defined or a
7932non-inline static function is unused.
7933This warning is enabled by @option{-Wall}.
7934
d77de738
ML
7935@opindex Wunused-label
7936@opindex Wno-unused-label
ddf6fe37 7937@item -Wunused-label
d77de738
ML
7938Warn whenever a label is declared but not used.
7939This warning is enabled by @option{-Wall}.
7940
7941To suppress this warning use the @code{unused} attribute
7942(@pxref{Variable Attributes}).
7943
d77de738
ML
7944@opindex Wunused-local-typedefs
7945@opindex Wno-unused-local-typedefs
ddf6fe37 7946@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7947Warn when a typedef locally defined in a function is not used.
7948This warning is enabled by @option{-Wall}.
7949
d77de738
ML
7950@opindex Wunused-parameter
7951@opindex Wno-unused-parameter
ddf6fe37 7952@item -Wunused-parameter
d77de738 7953Warn whenever a function parameter is unused aside from its declaration.
5c3e2e13
SL
7954This option is not enabled by @code{-Wunused} unless @code{-Wextra} is also
7955specified.
d77de738
ML
7956
7957To suppress this warning use the @code{unused} attribute
7958(@pxref{Variable Attributes}).
7959
d77de738
ML
7960@opindex Wunused-result
7961@opindex Wno-unused-result
ddf6fe37 7962@item -Wno-unused-result
d77de738
ML
7963Do not warn if a caller of a function marked with attribute
7964@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7965its return value. The default is @option{-Wunused-result}.
7966
d77de738
ML
7967@opindex Wunused-variable
7968@opindex Wno-unused-variable
ddf6fe37 7969@item -Wunused-variable
d77de738
ML
7970Warn whenever a local or static variable is unused aside from its
7971declaration. This option implies @option{-Wunused-const-variable=1} for C,
7972but not for C++. This warning is enabled by @option{-Wall}.
7973
7974To suppress this warning use the @code{unused} attribute
7975(@pxref{Variable Attributes}).
7976
d77de738
ML
7977@opindex Wunused-const-variable
7978@opindex Wno-unused-const-variable
ddf6fe37
AA
7979@item -Wunused-const-variable
7980@itemx -Wunused-const-variable=@var{n}
d77de738 7981Warn whenever a constant static variable is unused aside from its declaration.
d77de738
ML
7982
7983To suppress this warning use the @code{unused} attribute
7984(@pxref{Variable Attributes}).
7985
7986@table @gcctabopt
7987@item -Wunused-const-variable=1
5c3e2e13 7988Warn about unused static const variables defined in the main
d77de738
ML
7989compilation unit, but not about static const variables declared in any
7990header included.
7991
5c3e2e13
SL
7992@option{-Wunused-const-variable=1} is enabled by either
7993@option{-Wunused-variable} or @option{-Wunused} for C, but not for
7994C++. In C this declares variable storage, but in C++ this is not an
7995error since const variables take the place of @code{#define}s.
7996
d77de738
ML
7997@item -Wunused-const-variable=2
7998This warning level also warns for unused constant static variables in
5c3e2e13
SL
7999headers (excluding system headers). It is equivalent to the short form
8000@option{-Wunused-const-variable}. This level must be explicitly
8001requested in both C and C++ because it might be hard to clean up all
d77de738
ML
8002headers included.
8003@end table
8004
d77de738
ML
8005@opindex Wunused-value
8006@opindex Wno-unused-value
ddf6fe37 8007@item -Wunused-value
d77de738
ML
8008Warn whenever a statement computes a result that is explicitly not
8009used. To suppress this warning cast the unused expression to
8010@code{void}. This includes an expression-statement or the left-hand
8011side of a comma expression that contains no side effects. For example,
8012an expression such as @code{x[i,j]} causes a warning, while
8013@code{x[(void)i,j]} does not.
8014
8015This warning is enabled by @option{-Wall}.
8016
d77de738
ML
8017@opindex Wunused
8018@opindex Wno-unused
ddf6fe37 8019@item -Wunused
5c3e2e13
SL
8020All the above @option{-Wunused} options combined, except those documented
8021as needing to be specified explicitly.
d77de738
ML
8022
8023In order to get a warning about an unused function parameter, you must
8024either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
5c3e2e13
SL
8025@option{-Wunused}), or separately specify @option{-Wunused-parameter} and/or
8026@option{-Wunused-but-set-parameter}.
8027
8028@option{-Wunused} enables only @option{-Wunused-const-variable=1} rather than
8029@option{-Wunused-const-variable}, and only for C, not C++.
d77de738 8030
25bb8a40
SL
8031@opindex Wuse-after-free
8032@opindex Wno-use-after-free
8033@item -Wuse-after-free @r{(C, Objective-C, C++ and Objective-C++ only)}
8034@itemx -Wuse-after-free=@var{n}
8035Warn about uses of pointers to dynamically allocated objects that have
8036been rendered indeterminate by a call to a deallocation function.
8037The warning is enabled at all optimization levels but may yield different
8038results with optimization than without.
8039
8040@table @gcctabopt
8041@item -Wuse-after-free=1
8042At level 1 the warning attempts to diagnose only unconditional uses
8043of pointers made indeterminate by a deallocation call or a successful
8044call to @code{realloc}, regardless of whether or not the call resulted
8045in an actual reallocation of memory. This includes double-@code{free}
8046calls as well as uses in arithmetic and relational expressions. Although
8047undefined, uses of indeterminate pointers in equality (or inequality)
8048expressions are not diagnosed at this level.
8049@item -Wuse-after-free=2
8050At level 2, in addition to unconditional uses, the warning also diagnoses
8051conditional uses of pointers made indeterminate by a deallocation call.
8052As at level 2, uses in equality (or inequality) expressions are not
8053diagnosed. For example, the second call to @code{free} in the following
8054function is diagnosed at this level:
8055@smallexample
8056struct A @{ int refcount; void *data; @};
8057
8058void release (struct A *p)
8059@{
8060 int refcount = --p->refcount;
8061 free (p);
8062 if (refcount == 0)
8063 free (p->data); // warning: p may be used after free
8064@}
8065@end smallexample
8066@item -Wuse-after-free=3
8067At level 3, the warning also diagnoses uses of indeterminate pointers in
8068equality expressions. All uses of indeterminate pointers are undefined
8069but equality tests sometimes appear after calls to @code{realloc} as
8070an attempt to determine whether the call resulted in relocating the object
8071to a different address. They are diagnosed at a separate level to aid
8072gradually transitioning legacy code to safe alternatives. For example,
8073the equality test in the function below is diagnosed at this level:
8074@smallexample
8075void adjust_pointers (int**, int);
8076
8077void grow (int **p, int n)
8078@{
8079 int **q = (int**)realloc (p, n *= 2);
8080 if (q == p)
8081 return;
8082 adjust_pointers ((int**)q, n);
8083@}
8084@end smallexample
8085To avoid the warning at this level, store offsets into allocated memory
8086instead of pointers. This approach obviates needing to adjust the stored
8087pointers after reallocation.
8088@end table
8089
8090@option{-Wuse-after-free=2} is included in @option{-Wall}.
8091
8092@opindex Wuseless-cast
8093@opindex Wno-useless-cast
8094@item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
8095Warn when an expression is cast to its own type. This warning does not
8096occur when a class object is converted to a non-reference type as that
8097is a way to create a temporary:
8098
8099@smallexample
8100struct S @{ @};
8101void g (S&&);
8102void f (S&& arg)
8103@{
8104 g (S(arg)); // make arg prvalue so that it can bind to S&&
8105@}
8106@end smallexample
8107
d77de738
ML
8108@opindex Wuninitialized
8109@opindex Wno-uninitialized
ddf6fe37 8110@item -Wuninitialized
d77de738
ML
8111Warn if an object with automatic or allocated storage duration is used
8112without having been initialized. In C++, also warn if a non-static
8113reference or non-static @code{const} member appears in a class without
8114constructors.
8115
8116In addition, passing a pointer (or in C++, a reference) to an uninitialized
8117object to a @code{const}-qualified argument of a built-in function known to
8118read the object is also diagnosed by this warning.
8119(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
8120
8121If you want to warn about code that uses the uninitialized value of the
8122variable in its own initializer, use the @option{-Winit-self} option.
8123
8124These warnings occur for individual uninitialized elements of
8125structure, union or array variables as well as for variables that are
8126uninitialized as a whole. They do not occur for variables or elements
8127declared @code{volatile}. Because these warnings depend on
8128optimization, the exact variables or elements for which there are
8129warnings depend on the precise optimization options and version of GCC
8130used.
8131
8132Note that there may be no warning about a variable that is used only
8133to compute a value that itself is never used, because such
8134computations may be deleted by data flow analysis before the warnings
8135are printed.
8136
8137In C++, this warning also warns about using uninitialized objects in
8138member-initializer-lists. For example, GCC warns about @code{b} being
8139uninitialized in the following snippet:
8140
8141@smallexample
8142struct A @{
8143 int a;
8144 int b;
8145 A() : a(b) @{ @}
8146@};
8147@end smallexample
8148
d77de738
ML
8149@opindex Winvalid-memory-model
8150@opindex Wno-invalid-memory-model
ddf6fe37 8151@item -Wno-invalid-memory-model
d77de738
ML
8152This option controls warnings
8153for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
8154and the C11 atomic generic functions with a memory consistency argument
8155that is either invalid for the operation or outside the range of values
8156of the @code{memory_order} enumeration. For example, since the
8157@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
8158defined for the relaxed, release, and sequentially consistent memory
8159orders the following code is diagnosed:
8160
8161@smallexample
8162void store (int *i)
8163@{
8164 __atomic_store_n (i, 0, memory_order_consume);
8165@}
8166@end smallexample
8167
8168@option{-Winvalid-memory-model} is enabled by default.
8169
d77de738
ML
8170@opindex Wmaybe-uninitialized
8171@opindex Wno-maybe-uninitialized
ddf6fe37 8172@item -Wmaybe-uninitialized
d77de738
ML
8173For an object with automatic or allocated storage duration, if there exists
8174a path from the function entry to a use of the object that is initialized,
8175but there exist some other paths for which the object is not initialized,
8176the compiler emits a warning if it cannot prove the uninitialized paths
8177are not executed at run time.
8178
8179In addition, passing a pointer (or in C++, a reference) to an uninitialized
8180object to a @code{const}-qualified function argument is also diagnosed by
8181this warning. (@option{-Wuninitialized} is issued for built-in functions
8182known to read the object.) Annotating the function with attribute
8183@code{access (none)} indicates that the argument isn't used to access
8184the object and avoids the warning (@pxref{Common Function Attributes}).
8185
8186These warnings are only possible in optimizing compilation, because otherwise
8187GCC does not keep track of the state of variables.
8188
8189These warnings are made optional because GCC may not be able to determine when
8190the code is correct in spite of appearing to have an error. Here is one
8191example of how this can happen:
8192
8193@smallexample
8194@group
8195@{
8196 int x;
8197 switch (y)
8198 @{
8199 case 1: x = 1;
8200 break;
8201 case 2: x = 4;
8202 break;
8203 case 3: x = 5;
8204 @}
8205 foo (x);
8206@}
8207@end group
8208@end smallexample
8209
8210@noindent
8211If the value of @code{y} is always 1, 2 or 3, then @code{x} is
8212always initialized, but GCC doesn't know this. To suppress the
8213warning, you need to provide a default case with assert(0) or
8214similar code.
8215
8216@cindex @code{longjmp} warnings
8217This option also warns when a non-volatile automatic variable might be
8218changed by a call to @code{longjmp}.
8219The compiler sees only the calls to @code{setjmp}. It cannot know
8220where @code{longjmp} will be called; in fact, a signal handler could
8221call it at any point in the code. As a result, you may get a warning
8222even when there is in fact no problem because @code{longjmp} cannot
8223in fact be called at the place that would cause a problem.
8224
8225Some spurious warnings can be avoided if you declare all the functions
8226you use that never return as @code{noreturn}. @xref{Function
8227Attributes}.
8228
8229This warning is enabled by @option{-Wall} or @option{-Wextra}.
8230
d77de738
ML
8231@opindex Wunknown-pragmas
8232@opindex Wno-unknown-pragmas
8233@cindex warning for unknown pragmas
8234@cindex unknown pragmas, warning
8235@cindex pragmas, warning of unknown
f33d7a88 8236@item -Wunknown-pragmas
a0e64a04 8237Warn when a @code{#pragma} directive is encountered that is not understood by
d77de738
ML
8238GCC@. If this command-line option is used, warnings are even issued
8239for unknown pragmas in system header files. This is not the case if
8240the warnings are only enabled by the @option{-Wall} command-line option.
8241
d77de738
ML
8242@opindex Wno-pragmas
8243@opindex Wpragmas
ddf6fe37 8244@item -Wno-pragmas
d77de738
ML
8245Do not warn about misuses of pragmas, such as incorrect parameters,
8246invalid syntax, or conflicts between pragmas. See also
8247@option{-Wunknown-pragmas}.
8248
821d5610
KM
8249@opindex Wno-pragma-once-outside-header
8250@opindex Wpragma-once-outside-header
8251@item -Wno-pragma-once-outside-header
8252Do not warn when @code{#pragma once} is used in a file that is not a header
8253file, such as a main file.
8254
d77de738
ML
8255@opindex Wno-prio-ctor-dtor
8256@opindex Wprio-ctor-dtor
ddf6fe37 8257@item -Wno-prio-ctor-dtor
d77de738
ML
8258Do not warn if a priority from 0 to 100 is used for constructor or destructor.
8259The use of constructor and destructor attributes allow you to assign a
8260priority to the constructor/destructor to control its order of execution
8261before @code{main} is called or after it returns. The priority values must be
8262greater than 100 as the compiler reserves priority values between 0--100 for
8263the implementation.
8264
d77de738
ML
8265@opindex Wstrict-aliasing
8266@opindex Wno-strict-aliasing
ddf6fe37 8267@item -Wstrict-aliasing
d77de738
ML
8268This option is only active when @option{-fstrict-aliasing} is active.
8269It warns about code that might break the strict aliasing rules that the
8270compiler is using for optimization. The warning does not catch all
8271cases, but does attempt to catch the more common pitfalls. It is
8272included in @option{-Wall}.
8273It is equivalent to @option{-Wstrict-aliasing=3}
8274
d77de738 8275@opindex Wstrict-aliasing=n
ddf6fe37 8276@item -Wstrict-aliasing=n
d77de738
ML
8277This option is only active when @option{-fstrict-aliasing} is active.
8278It warns about code that might break the strict aliasing rules that the
8279compiler is using for optimization.
8280Higher levels correspond to higher accuracy (fewer false positives).
a0e64a04 8281Higher levels also correspond to more effort, similar to the way @option{-O}
d77de738
ML
8282works.
8283@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
8284
8285Level 1: Most aggressive, quick, least accurate.
8286Possibly useful when higher levels
8287do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
8288false negatives. However, it has many false positives.
8289Warns for all pointer conversions between possibly incompatible types,
8290even if never dereferenced. Runs in the front end only.
8291
8292Level 2: Aggressive, quick, not too precise.
8293May still have many false positives (not as many as level 1 though),
8294and few false negatives (but possibly more than level 1).
8295Unlike level 1, it only warns when an address is taken. Warns about
8296incomplete types. Runs in the front end only.
8297
8298Level 3 (default for @option{-Wstrict-aliasing}):
8299Should have very few false positives and few false
8300negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
8301Takes care of the common pun+dereference pattern in the front end:
8302@code{*(int*)&some_float}.
8303If optimization is enabled, it also runs in the back end, where it deals
8304with multiple statement cases using flow-sensitive points-to information.
8305Only warns when the converted pointer is dereferenced.
8306Does not warn about incomplete types.
8307
d77de738
ML
8308@opindex Wstrict-overflow
8309@opindex Wno-strict-overflow
ddf6fe37
AA
8310@item -Wstrict-overflow
8311@itemx -Wstrict-overflow=@var{n}
d77de738
ML
8312This option is only active when signed overflow is undefined.
8313It warns about cases where the compiler optimizes based on the
8314assumption that signed overflow does not occur. Note that it does not
8315warn about all cases where the code might overflow: it only warns
8316about cases where the compiler implements some optimization. Thus
8317this warning depends on the optimization level.
8318
8319An optimization that assumes that signed overflow does not occur is
8320perfectly safe if the values of the variables involved are such that
8321overflow never does, in fact, occur. Therefore this warning can
8322easily give a false positive: a warning about code that is not
8323actually a problem. To help focus on important issues, several
8324warning levels are defined. No warnings are issued for the use of
8325undefined signed overflow when estimating how many iterations a loop
8326requires, in particular when determining whether a loop will be
8327executed at all.
8328
8329@table @gcctabopt
8330@item -Wstrict-overflow=1
8331Warn about cases that are both questionable and easy to avoid. For
8332example the compiler simplifies
8333@code{x + 1 > x} to @code{1}. This level of
8334@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
8335are not, and must be explicitly requested.
8336
8337@item -Wstrict-overflow=2
8338Also warn about other cases where a comparison is simplified to a
8339constant. For example: @code{abs (x) >= 0}. This can only be
8340simplified when signed integer overflow is undefined, because
8341@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
8342zero. @option{-Wstrict-overflow} (with no level) is the same as
8343@option{-Wstrict-overflow=2}.
8344
8345@item -Wstrict-overflow=3
8346Also warn about other cases where a comparison is simplified. For
8347example: @code{x + 1 > 1} is simplified to @code{x > 0}.
8348
8349@item -Wstrict-overflow=4
8350Also warn about other simplifications not covered by the above cases.
8351For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
8352
8353@item -Wstrict-overflow=5
8354Also warn about cases where the compiler reduces the magnitude of a
8355constant involved in a comparison. For example: @code{x + 2 > y} is
8356simplified to @code{x + 1 >= y}. This is reported only at the
8357highest warning level because this simplification applies to many
8358comparisons, so this warning level gives a very large number of
8359false positives.
8360@end table
8361
d77de738
ML
8362@opindex Wstring-compare
8363@opindex Wno-string-compare
ddf6fe37 8364@item -Wstring-compare
d77de738
ML
8365Warn for calls to @code{strcmp} and @code{strncmp} whose result is
8366determined to be either zero or non-zero in tests for such equality
8367owing to the length of one argument being greater than the size of
8368the array the other argument is stored in (or the bound in the case
8369of @code{strncmp}). Such calls could be mistakes. For example,
8370the call to @code{strcmp} below is diagnosed because its result is
8371necessarily non-zero irrespective of the contents of the array @code{a}.
8372
8373@smallexample
8374extern char a[4];
8375void f (char *d)
8376@{
8377 strcpy (d, "string");
8378 @dots{}
8379 if (0 == strcmp (a, d)) // cannot be true
8380 puts ("a and d are the same");
8381@}
8382@end smallexample
8383
8384@option{-Wstring-compare} is enabled by @option{-Wextra}.
8385
ddf6fe37
AA
8386@opindex Wstringop-overflow
8387@opindex Wno-stringop-overflow
d77de738
ML
8388@item -Wno-stringop-overflow
8389@item -Wstringop-overflow
8390@itemx -Wstringop-overflow=@var{type}
888e70b3
SL
8391Warn for code that can be statically determined to cause buffer overflows or
8392memory overruns, such as calls to @code{memcpy} and
8393@code{strcpy} that overflow the destination buffer. The
d77de738
ML
8394optional argument is one greater than the type of Object Size Checking to
8395perform to determine the size of the destination. @xref{Object Size Checking}.
888e70b3
SL
8396The argument is meaningful only for string functions
8397that operate on character arrays; raw memory functions like @code{memcpy}
8398always use type-zero Object Size Checking.
8399
8400The option also warns for calls that specify a size
d77de738 8401in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
888e70b3 8402
d77de738
ML
8403The option produces the best results with optimization enabled but can detect
8404a small subset of simple buffer overflows even without optimization in
8405calls to the GCC built-in functions like @code{__builtin_memcpy} that
8406correspond to the standard functions. In any case, the option warns about
8407just a subset of buffer overflows detected by the corresponding overflow
888e70b3
SL
8408checking built-ins, such as @code{__builtin___memcpy_chk}, which can perform
8409run-time checking if the access cannot be identified as safe
8410at compile time.
8411
8412For example, the option issues a warning for
d77de738
ML
8413the @code{strcpy} call below because it copies at least 5 characters
8414(the string @code{"blue"} including the terminating NUL) into the buffer
8415of size 4.
8416
8417@smallexample
8418enum Color @{ blue, purple, yellow @};
8419const char* f (enum Color clr)
8420@{
8421 static char buf [4];
8422 const char *str;
8423 switch (clr)
8424 @{
8425 case blue: str = "blue"; break;
8426 case purple: str = "purple"; break;
8427 case yellow: str = "yellow"; break;
8428 @}
8429
8430 return strcpy (buf, str); // warning here
8431@}
8432@end smallexample
8433
888e70b3
SL
8434The effect of this option is not limited to string or memory
8435manipulation functions. In this example, a warning is diagnosed
8436because a 1-element array is passed to a function requiring at least a
84374-element array argument:
8438
8439@smallexample
8440void f (int[static 4]);
8441
8442void g (void)
8443@{
8444 int *p = (int *) malloc (1 * sizeof(int));
8445 f (p); // warning here
8446@}
8447@end smallexample
8448
d77de738
ML
8449Option @option{-Wstringop-overflow=2} is enabled by default.
8450
8451@table @gcctabopt
d77de738
ML
8452@opindex Wstringop-overflow
8453@opindex Wno-stringop-overflow
ddf6fe37
AA
8454@item -Wstringop-overflow
8455@itemx -Wstringop-overflow=1
d77de738
ML
8456The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
8457to determine the sizes of destination objects. At this setting the option
8458does not warn for writes past the end of subobjects of larger objects accessed
8459by pointers unless the size of the largest surrounding object is known. When
8460the destination may be one of several objects it is assumed to be the largest
8461one of them. On Linux systems, when optimization is enabled at this setting
8462the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
8463is defined to a non-zero value.
8464
8465@item -Wstringop-overflow=2
8466The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
8467to determine the sizes of destination objects. At this setting the option
8468warns about overflows when writing to members of the largest complete
8469objects whose exact size is known. However, it does not warn for excessive
8470writes to the same members of unknown objects referenced by pointers since
8471they may point to arrays containing unknown numbers of elements. This is
8472the default setting of the option.
8473
8474@item -Wstringop-overflow=3
8475The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
8476to determine the sizes of destination objects. At this setting the option
8477warns about overflowing the smallest object or data member. This is the
8478most restrictive setting of the option that may result in warnings for safe
8479code.
8480
8481@item -Wstringop-overflow=4
8482The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
8483to determine the sizes of destination objects. At this setting the option
8484warns about overflowing any data members, and when the destination is
8485one of several objects it uses the size of the largest of them to decide
8486whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
8487setting of the option may result in warnings for benign code.
8488@end table
8489
d77de738
ML
8490@opindex Wstringop-overread
8491@opindex Wno-stringop-overread
ddf6fe37 8492@item -Wno-stringop-overread
d77de738
ML
8493Warn for calls to string manipulation functions such as @code{memchr}, or
8494@code{strcpy} that are determined to read past the end of the source
8495sequence.
8496
8497Option @option{-Wstringop-overread} is enabled by default.
8498
d77de738
ML
8499@opindex Wstringop-truncation
8500@opindex Wno-stringop-truncation
ddf6fe37 8501@item -Wno-stringop-truncation
d77de738
ML
8502Do not warn for calls to bounded string manipulation functions
8503such as @code{strncat},
8504@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8505or leave the destination unchanged.
8506
8507In the following example, the call to @code{strncat} specifies a bound that
8508is less than the length of the source string. As a result, the copy of
8509the source will be truncated and so the call is diagnosed. To avoid the
8510warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8511
8512@smallexample
8513void append (char *buf, size_t bufsize)
8514@{
8515 strncat (buf, ".txt", 3);
8516@}
8517@end smallexample
8518
8519As another example, the following call to @code{strncpy} results in copying
8520to @code{d} just the characters preceding the terminating NUL, without
8521appending the NUL to the end. Assuming the result of @code{strncpy} is
8522necessarily a NUL-terminated string is a common mistake, and so the call
8523is diagnosed. To avoid the warning when the result is not expected to be
8524NUL-terminated, call @code{memcpy} instead.
8525
8526@smallexample
8527void copy (char *d, const char *s)
8528@{
8529 strncpy (d, s, strlen (s));
8530@}
8531@end smallexample
8532
8533In the following example, the call to @code{strncpy} specifies the size
8534of the destination buffer as the bound. If the length of the source
8535string is equal to or greater than this size the result of the copy will
8536not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8537the warning, specify @code{sizeof buf - 1} as the bound and set the last
8538element of the buffer to @code{NUL}.
8539
8540@smallexample
8541void copy (const char *s)
8542@{
8543 char buf[80];
8544 strncpy (buf, s, sizeof buf);
8545 @dots{}
8546@}
8547@end smallexample
8548
8549In situations where a character array is intended to store a sequence
8550of bytes with no terminating @code{NUL} such an array may be annotated
8551with attribute @code{nonstring} to avoid this warning. Such arrays,
8552however, are not suitable arguments to functions that expect
8553@code{NUL}-terminated strings. To help detect accidental misuses of
8554such arrays GCC issues warnings unless it can prove that the use is
8555safe. @xref{Common Variable Attributes}.
8556
2a27ae32
QZ
8557@opindex Wstrict-flex-arrays
8558@opindex Wno-strict-flex-arrays
eb71695f
SL
8559@item -Wstrict-flex-arrays @r{(C and C++ only)}
8560Warn about improper usages of flexible array members
2a27ae32
QZ
8561according to the @var{level} of the @code{strict_flex_array (@var{level})}
8562attribute attached to the trailing array field of a structure if it's
8563available, otherwise according to the @var{level} of the option
eb71695f
SL
8564@option{-fstrict-flex-arrays=@var{level}}. @xref{Common Variable Attributes},
8565for more information about the attribute, and @ref{C Dialect Options} for
8566more information about the option. @code{-Wstrict-flex-arrays}
8567is effective only when @var{level} is greater than 0.
2a27ae32 8568
eb71695f 8569When @var{level}=1, warnings are issued for a trailing array reference
2a27ae32
QZ
8570of a structure that have 2 or more elements if the trailing array is referenced
8571as a flexible array member.
8572
eb71695f 8573When @var{level}=2, in addition to @var{level}=1, additional warnings are
2a27ae32
QZ
8574issued for a trailing one-element array reference of a structure
8575if the array is referenced as a flexible array member.
8576
eb71695f 8577When @var{level}=3, in addition to @var{level}=2, additional warnings are
2a27ae32
QZ
8578issued for a trailing zero-length array reference of a structure
8579if the array is referenced as a flexible array member.
8580
eb71695f
SL
8581This option is more effective when @option{-ftree-vrp} is active (the
8582default for @option{-O2} and above) but some warnings may be diagnosed
8583even without optimization.
2a27ae32 8584
d77de738
ML
8585@opindex Wsuggest-attribute=
8586@opindex Wno-suggest-attribute=
c768cd07 8587@item -Wsuggest-attribute=@var{attribute-name}
d77de738 8588Warn for cases where adding an attribute may be beneficial. The
c768cd07 8589@var{attribute-name}s currently supported are listed below.
d77de738
ML
8590
8591@table @gcctabopt
d77de738
ML
8592@opindex Wsuggest-attribute=pure
8593@opindex Wno-suggest-attribute=pure
8594@opindex Wsuggest-attribute=const
8595@opindex Wno-suggest-attribute=const
8596@opindex Wsuggest-attribute=noreturn
8597@opindex Wno-suggest-attribute=noreturn
8598@opindex Wmissing-noreturn
8599@opindex Wno-missing-noreturn
8600@opindex Wsuggest-attribute=malloc
8601@opindex Wno-suggest-attribute=malloc
c768cd07
SL
8602@opindex Wsuggest-attribute=returns_nonnull
8603@opindex Wno-suggest-attribute=returns_nonnull
ddf6fe37
AA
8604@item -Wsuggest-attribute=pure
8605@itemx -Wsuggest-attribute=const
8606@itemx -Wsuggest-attribute=noreturn
8607@itemx -Wmissing-noreturn
8608@itemx -Wsuggest-attribute=malloc
53ba8d66 8609@itemx -Wsuggest-attribute=returns_nonnull
d77de738
ML
8610
8611Warn about functions that might be candidates for attributes
c768cd07
SL
8612@code{pure}, @code{const}, @code{noreturn}, @code{malloc} or
8613@code{returns_nonnull}. The compiler
d77de738
ML
8614only warns for functions visible in other compilation units or (in the case of
8615@code{pure} and @code{const}) if it cannot prove that the function returns
8616normally. A function returns normally if it doesn't contain an infinite loop or
8617return abnormally by throwing, calling @code{abort} or trapping. This analysis
8618requires option @option{-fipa-pure-const}, which is enabled by default at
8619@option{-O} and higher. Higher optimization levels improve the accuracy
8620of the analysis.
8621
d77de738
ML
8622@opindex Wsuggest-attribute=format
8623@opindex Wmissing-format-attribute
8624@opindex Wno-suggest-attribute=format
8625@opindex Wno-missing-format-attribute
8626@opindex Wformat
8627@opindex Wno-format
ddf6fe37
AA
8628@item -Wsuggest-attribute=format
8629@itemx -Wmissing-format-attribute
d77de738
ML
8630
8631Warn about function pointers that might be candidates for @code{format}
8632attributes. Note these are only possible candidates, not absolute ones.
8633GCC guesses that function pointers with @code{format} attributes that
8634are used in assignment, initialization, parameter passing or return
8635statements should have a corresponding @code{format} attribute in the
8636resulting type. I.e.@: the left-hand side of the assignment or
8637initialization, the type of the parameter variable, or the return type
8638of the containing function respectively should also have a @code{format}
8639attribute to avoid the warning.
8640
8641GCC also warns about function definitions that might be
8642candidates for @code{format} attributes. Again, these are only
8643possible candidates. GCC guesses that @code{format} attributes
8644might be appropriate for any function that calls a function like
8645@code{vprintf} or @code{vscanf}, but this might not always be the
8646case, and some functions for which @code{format} attributes are
8647appropriate may not be detected.
8648
d77de738
ML
8649@opindex Wsuggest-attribute=cold
8650@opindex Wno-suggest-attribute=cold
ddf6fe37 8651@item -Wsuggest-attribute=cold
d77de738
ML
8652
8653Warn about functions that might be candidates for @code{cold} attribute. This
8654is based on static detection and generally only warns about functions which
8655always leads to a call to another @code{cold} function such as wrappers of
8656C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8657@end table
8658
d880e093
MU
8659@opindex Wno-alloc-size
8660@opindex Walloc-size
8661@item -Walloc-size
8662Warn about calls to allocation functions decorated with attribute
8663@code{alloc_size} that specify insufficient size for the target type of
8664the pointer the result is assigned to, including those to the built-in
8665forms of the functions @code{aligned_alloc}, @code{alloca},
e7dd72ae 8666@code{calloc}, @code{malloc}, and @code{realloc}.
d880e093 8667
d77de738
ML
8668@opindex Wno-alloc-zero
8669@opindex Walloc-zero
ddf6fe37 8670@item -Walloc-zero
d77de738
ML
8671Warn about calls to allocation functions decorated with attribute
8672@code{alloc_size} that specify zero bytes, including those to the built-in
8673forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8674@code{malloc}, and @code{realloc}. Because the behavior of these functions
8675when called with a zero size differs among implementations (and in the case
8676of @code{realloc} has been deprecated) relying on it may result in subtle
8677portability bugs and should be avoided.
8678
e7dd72ae
JJ
8679@opindex Wcalloc-transposed-args
8680@opindex Wno-calloc-transposed-args
8681@item -Wcalloc-transposed-args
8682Warn about calls to allocation functions decorated with attribute
8683@code{alloc_size} with two arguments, which use @code{sizeof} operator
8684as the earlier size argument and don't use it as the later size argument.
8685This is a coding style warning. The first argument to @code{calloc} is
8686documented to be number of elements in array, while the second argument
8687is size of each element, so @code{calloc (@var{n}, sizeof (int))} is preferred
8688over @code{calloc (sizeof (int), @var{n})}. If @code{sizeof} in the earlier
8689argument and not the latter is intentional, the warning can be suppressed
8690by using @code{calloc (sizeof (struct @var{S}) + 0, n)} or
8691@code{calloc (1 * sizeof (struct @var{S}), 4)} or using @code{sizeof} in the
8692later argument as well.
8693
d77de738
ML
8694@opindex Walloc-size-larger-than=
8695@opindex Wno-alloc-size-larger-than
ddf6fe37 8696@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8697Warn about calls to functions decorated with attribute @code{alloc_size}
8698that attempt to allocate objects larger than the specified number of bytes,
8699or where the result of the size computation in an integer type with infinite
8700precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8701@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8702Warnings controlled by the option can be disabled either by specifying
8703@var{byte-size} of @samp{SIZE_MAX} or more or by
8704@option{-Wno-alloc-size-larger-than}.
8705@xref{Function Attributes}.
8706
d77de738 8707@opindex Wno-alloc-size-larger-than
ddf6fe37 8708@item -Wno-alloc-size-larger-than
d77de738
ML
8709Disable @option{-Walloc-size-larger-than=} warnings. The option is
8710equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8711larger.
8712
d77de738
ML
8713@opindex Wno-alloca
8714@opindex Walloca
ddf6fe37 8715@item -Walloca
d77de738
ML
8716This option warns on all uses of @code{alloca} in the source.
8717
99f9e901
JH
8718@opindex Wno-auto-profile
8719@opindex Wauto-profile
8720@item -Wauto-profile
8721Output warnings about auto-profile inconsistencies.
8722
d77de738
ML
8723@opindex Walloca-larger-than=
8724@opindex Wno-alloca-larger-than
ddf6fe37 8725@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8726This option warns on calls to @code{alloca} with an integer argument whose
8727value is either zero, or that is not bounded by a controlling predicate
8728that limits its value to at most @var{byte-size}. It also warns for calls
8729to @code{alloca} where the bound value is unknown. Arguments of non-integer
8730types are considered unbounded even if they appear to be constrained to
8731the expected range.
8732
8733For example, a bounded case of @code{alloca} could be:
8734
8735@smallexample
8736void func (size_t n)
8737@{
8738 void *p;
8739 if (n <= 1000)
8740 p = alloca (n);
8741 else
8742 p = malloc (n);
8743 f (p);
8744@}
8745@end smallexample
8746
8747In the above example, passing @code{-Walloca-larger-than=1000} would not
8748issue a warning because the call to @code{alloca} is known to be at most
87491000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8750the compiler would emit a warning.
8751
8752Unbounded uses, on the other hand, are uses of @code{alloca} with no
8753controlling predicate constraining its integer argument. For example:
8754
8755@smallexample
8756void func ()
8757@{
8758 void *p = alloca (n);
8759 f (p);
8760@}
8761@end smallexample
8762
8763If @code{-Walloca-larger-than=500} were passed, the above would trigger
8764a warning, but this time because of the lack of bounds checking.
8765
8766Note, that even seemingly correct code involving signed integers could
8767cause a warning:
8768
8769@smallexample
8770void func (signed int n)
8771@{
8772 if (n < 500)
8773 @{
8774 p = alloca (n);
8775 f (p);
8776 @}
8777@}
8778@end smallexample
8779
8780In the above example, @var{n} could be negative, causing a larger than
8781expected argument to be implicitly cast into the @code{alloca} call.
8782
8783This option also warns when @code{alloca} is used in a loop.
8784
8785@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8786but is usually only effective when @option{-ftree-vrp} is active (default
8787for @option{-O2} and above).
8788
8789See also @option{-Wvla-larger-than=}@samp{byte-size}.
8790
d77de738 8791@opindex Wno-alloca-larger-than
ddf6fe37 8792@item -Wno-alloca-larger-than
d77de738
ML
8793Disable @option{-Walloca-larger-than=} warnings. The option is
8794equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8795
d77de738
ML
8796@opindex Warith-conversion
8797@opindex Wno-arith-conversion
ddf6fe37 8798@item -Warith-conversion
d77de738
ML
8799Do warn about implicit conversions from arithmetic operations even
8800when conversion of the operands to the same type cannot change their
8801values. This affects warnings from @option{-Wconversion},
8802@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8803
8804@smallexample
8805@group
8806void f (char c, int i)
8807@{
8808 c = c + i; // warns with @option{-Wconversion}
8809 c = c + 1; // only warns with @option{-Warith-conversion}
8810@}
8811@end group
8812@end smallexample
8813
d77de738
ML
8814@opindex Wno-array-bounds
8815@opindex Warray-bounds
ddf6fe37
AA
8816@item -Warray-bounds
8817@itemx -Warray-bounds=@var{n}
d77de738
ML
8818Warn about out of bounds subscripts or offsets into arrays. This warning
8819is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8820is active (the default for @option{-O2} and above) but a subset of instances
8821are issued even without optimization.
8822
710c9676
QZ
8823By default, the trailing array of a structure will be treated as a flexible
8824array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8825if it is declared as either a flexible array member per C99 standard onwards
8826(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8827array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8828zero-length arrays or one-element arrays are not warned by default.
8829
8830You can add the option @option{-fstrict-flex-arrays} or
8831@option{-fstrict-flex-arrays=@var{level}} to control how this
8832option treat trailing array of a structure as a flexible array member:
8833
8834when @var{level}<=1, no change to the default behavior.
8835
8836when @var{level}=2, additional warnings will be issued for out of bounds
8837subscripts or offsets into one-element arrays;
8838
8839when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8840issued for out of bounds subscripts or offsets into zero-length arrays.
8841
d77de738
ML
8842@table @gcctabopt
8843@item -Warray-bounds=1
8844This is the default warning level of @option{-Warray-bounds} and is enabled
8845by @option{-Wall}; higher levels are not, and must be explicitly requested.
8846
8847@item -Warray-bounds=2
710c9676
QZ
8848This warning level also warns about the intermediate results of pointer
8849arithmetic that may yield out of bounds values. This warning level may
8850give a larger number of false positives and is deactivated by default.
d77de738
ML
8851@end table
8852
44c9403e
AC
8853@opindex Wunterminated-string-initialization
8854@opindex Wno-unterminated-string-initialization
8855@item -Wunterminated-string-initialization @r{(C and Objective-C only)}
62296899
JJ
8856Warn about character arrays initialized as unterminated character sequences
8857with a string literal, unless the declaration being initialized has
8858the @code{nonstring} attribute.
44c9403e
AC
8859For example:
8860
8861@smallexample
62296899
JJ
8862char arr[3] = "foo"; /* Warning. */
8863char arr2[3] __attribute__((nonstring)) = "bar"; /* No warning. */
44c9403e
AC
8864@end smallexample
8865
62296899
JJ
8866This warning is enabled by @option{-Wextra}. If @option{-Wc++-compat}
8867is enabled, the warning has slightly different wording and warns even
8868if the declaration being initialized has the @code{nonstring} warning,
8869as in C++ such initializations are an error.
44c9403e 8870
d77de738
ML
8871@opindex Warray-compare
8872@opindex Wno-array-compare
ddf6fe37 8873@item -Warray-compare
d77de738
ML
8874Warn about equality and relational comparisons between two operands of array
8875type. This comparison was deprecated in C++20. For example:
8876
8877@smallexample
8878int arr1[5];
8879int arr2[5];
8880bool same = arr1 == arr2;
8881@end smallexample
8882
8883@option{-Warray-compare} is enabled by @option{-Wall}.
8884
ddf6fe37 8885@opindex Wno-array-parameter
8fd992a3 8886@opindex Warray-parameter
d77de738
ML
8887@item -Warray-parameter
8888@itemx -Warray-parameter=@var{n}
8fd992a3 8889Warn about redeclarations of functions involving parameters of array or
d77de738
ML
8890pointer types of inconsistent kinds or forms, and enable the detection
8891of out-of-bounds accesses to such parameters by warnings such as
8892@option{-Warray-bounds}.
8893
8fd992a3
SL
8894If the first function declaration uses the array form for a parameter
8895declaration, the bound specified
d77de738
ML
8896in the array is assumed to be the minimum number of elements expected to
8897be provided in calls to the function and the maximum number of elements
8898accessed by it. Failing to provide arguments of sufficient size or accessing
8899more than the maximum number of elements may be diagnosed by warnings such
8fd992a3
SL
8900as @option{-Warray-bounds} or @option{-Wstringop-overflow}.
8901At level 1, the warning diagnoses inconsistencies
d77de738
ML
8902involving array parameters declared using the @code{T[static N]} form.
8903
8fd992a3
SL
8904For example, the warning triggers for the second declaration of @code{f}
8905because the first one with the keyword @code{static} specifies that
8906the array argument must have at least four elements, while the second
8907allows an array of any size to be passed to @code{f}.
d77de738
ML
8908
8909@smallexample
8910void f (int[static 4]);
8911void f (int[]); // warning (inconsistent array form)
8912
8913void g (void)
8914@{
8fd992a3 8915 int *p = (int *)malloc (1 * sizeof (int));
d77de738
ML
8916 f (p); // warning (array too small)
8917 @dots{}
8918@}
8919@end smallexample
8920
8921At level 2 the warning also triggers for redeclarations involving any other
8922inconsistency in array or pointer argument forms denoting array sizes.
8923Pointers and arrays of unspecified bound are considered equivalent and do
8924not trigger a warning.
8925
8926@smallexample
8927void g (int*);
8928void g (int[]); // no warning
8929void g (int[8]); // warning (inconsistent array bound)
8930@end smallexample
8931
8932@option{-Warray-parameter=2} is included in @option{-Wall}. The
8933@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8934involving Variable Length Array arguments.
8935
8fd992a3
SL
8936The short form of the option @option{-Warray-parameter} is equivalent to
8937@option{-Warray-parameter=2}. The negative form @option{-Wno-array-parameter}
8938is equivalent to @option{-Warray-parameter=0}.
8939
d77de738
ML
8940@opindex Wattribute-alias
8941@opindex Wno-attribute-alias
ddf6fe37
AA
8942@item -Wattribute-alias=@var{n}
8943@itemx -Wno-attribute-alias
d77de738
ML
8944Warn about declarations using the @code{alias} and similar attributes whose
8945target is incompatible with the type of the alias.
8946@xref{Function Attributes,,Declaring Attributes of Functions}.
8947
8948@table @gcctabopt
8949@item -Wattribute-alias=1
8950The default warning level of the @option{-Wattribute-alias} option diagnoses
8951incompatibilities between the type of the alias declaration and that of its
8952target. Such incompatibilities are typically indicative of bugs.
8953
8954@item -Wattribute-alias=2
8955
8956At this level @option{-Wattribute-alias} also diagnoses cases where
8957the attributes of the alias declaration are more restrictive than the
8958attributes applied to its target. These mismatches can potentially
8959result in incorrect code generation. In other cases they may be
8960benign and could be resolved simply by adding the missing attribute to
8961the target. For comparison, see the @option{-Wmissing-attributes}
8962option, which controls diagnostics when the alias declaration is less
8963restrictive than the target, rather than more restrictive.
8964
8965Attributes considered include @code{alloc_align}, @code{alloc_size},
8966@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8967@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8968@code{returns_nonnull}, and @code{returns_twice}.
8969@end table
8970
8971@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8972This is the default. You can disable these warnings with either
8973@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8974
d77de738
ML
8975@opindex Wbidi-chars=
8976@opindex Wbidi-chars
8977@opindex Wno-bidi-chars
ddf6fe37 8978@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8979Warn about possibly misleading UTF-8 bidirectional control characters in
8980comments, string literals, character constants, and identifiers. Such
8981characters can change left-to-right writing direction into right-to-left
8982(and vice versa), which can cause confusion between the logical order and
8983visual order. This may be dangerous; for instance, it may seem that a piece
8984of code is not commented out, whereas it in fact is.
8985
8986There are three levels of warning supported by GCC@. The default is
8987@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8988bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8989@option{-Wbidi-chars=any} warns about any use of bidirectional control
8990characters.
8991
8992By default, this warning does not warn about UCNs. It is, however, possible
8993to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8994@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8995and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8996@option{-Wbidi-chars=any} was specified.
8997
d77de738
ML
8998@opindex Wno-bool-compare
8999@opindex Wbool-compare
ddf6fe37 9000@item -Wbool-compare
d77de738
ML
9001Warn about boolean expression compared with an integer value different from
9002@code{true}/@code{false}. For instance, the following comparison is
9003always false:
9004@smallexample
9005int n = 5;
9006@dots{}
9007if ((n > 1) == 2) @{ @dots{} @}
9008@end smallexample
9009This warning is enabled by @option{-Wall}.
9010
d77de738
ML
9011@opindex Wno-bool-operation
9012@opindex Wbool-operation
ddf6fe37 9013@item -Wbool-operation
d77de738
ML
9014Warn about suspicious operations on expressions of a boolean type. For
9015instance, bitwise negation of a boolean is very likely a bug in the program.
9016For C, this warning also warns about incrementing or decrementing a boolean,
9017which rarely makes sense. (In C++, decrementing a boolean is always invalid.
9018Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
9019
9020This warning is enabled by @option{-Wall}.
9021
d77de738
ML
9022@opindex Wno-duplicated-branches
9023@opindex Wduplicated-branches
ddf6fe37 9024@item -Wduplicated-branches
d77de738
ML
9025Warn when an if-else has identical branches. This warning detects cases like
9026@smallexample
9027if (p != NULL)
9028 return 0;
9029else
9030 return 0;
9031@end smallexample
9032It doesn't warn when both branches contain just a null statement. This warning
9033also warn for conditional operators:
9034@smallexample
9035 int i = x ? *p : *p;
9036@end smallexample
9037
d77de738
ML
9038@opindex Wno-duplicated-cond
9039@opindex Wduplicated-cond
ddf6fe37 9040@item -Wduplicated-cond
d77de738
ML
9041Warn about duplicated conditions in an if-else-if chain. For instance,
9042warn for the following code:
9043@smallexample
9044if (p->q != NULL) @{ @dots{} @}
9045else if (p->q != NULL) @{ @dots{} @}
9046@end smallexample
9047
d77de738
ML
9048@opindex Wno-frame-address
9049@opindex Wframe-address
ddf6fe37 9050@item -Wframe-address
d77de738
ML
9051Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
9052is called with an argument greater than 0. Such calls may return indeterminate
9053values or crash the program. The warning is included in @option{-Wall}.
9054
d77de738
ML
9055@opindex Wno-discarded-qualifiers
9056@opindex Wdiscarded-qualifiers
ddf6fe37 9057@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
9058Do not warn if type qualifiers on pointers are being discarded.
9059Typically, the compiler warns if a @code{const char *} variable is
9060passed to a function that takes a @code{char *} parameter. This option
9061can be used to suppress such a warning.
9062
d77de738
ML
9063@opindex Wno-discarded-array-qualifiers
9064@opindex Wdiscarded-array-qualifiers
ddf6fe37 9065@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
9066Do not warn if type qualifiers on arrays which are pointer targets
9067are being discarded. Typically, the compiler warns if a
9068@code{const int (*)[]} variable is passed to a function that
9069takes a @code{int (*)[]} parameter. This option can be used to
9070suppress such a warning.
9071
d77de738
ML
9072@opindex Wno-incompatible-pointer-types
9073@opindex Wincompatible-pointer-types
ddf6fe37 9074@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
9075Do not warn when there is a conversion between pointers that have incompatible
9076types. This warning is for cases not covered by @option{-Wno-pointer-sign},
9077which warns for pointer argument passing or assignment with different
9078signedness.
9079
9715c545
FW
9080By default, in C99 and later dialects of C, GCC treats this issue as an
9081error. The error can be downgraded to a warning using
9082@option{-fpermissive} (along with certain other errors), or for this
9083error alone, with @option{-Wno-error=incompatible-pointer-types}.
9084
5fccebdb
JM
9085This warning is upgraded to an error by @option{-pedantic-errors}.
9086
d77de738
ML
9087@opindex Wno-int-conversion
9088@opindex Wint-conversion
ddf6fe37 9089@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
9090Do not warn about incompatible integer to pointer and pointer to integer
9091conversions. This warning is about implicit conversions; for explicit
9092conversions the warnings @option{-Wno-int-to-pointer-cast} and
9093@option{-Wno-pointer-to-int-cast} may be used.
9094
2c3db94d
FW
9095By default, in C99 and later dialects of C, GCC treats this issue as an
9096error. The error can be downgraded to a warning using
9097@option{-fpermissive} (along with certain other errors), or for this
9098error alone, with @option{-Wno-error=int-conversion}.
9099
5fccebdb
JM
9100This warning is upgraded to an error by @option{-pedantic-errors}.
9101
182d891e
MU
9102@opindex Wzero-as-null-pointer-constant
9103@opindex Wno-zero-as-null-pointer-constant
9104@item -Wzero-as-null-pointer-constant
9105Warn when a literal @samp{0} is used as null pointer constant.
9106
d77de738
ML
9107@opindex Wzero-length-bounds
9108@opindex Wzero-length-bounds
ddf6fe37 9109@item -Wzero-length-bounds
d77de738
ML
9110Warn about accesses to elements of zero-length array members that might
9111overlap other members of the same object. Declaring interior zero-length
8e9c65d3 9112arrays is discouraged because accesses to them are undefined.
d77de738
ML
9113@xref{Zero Length}.
9114
9115For example, the first two stores in function @code{bad} are diagnosed
9116because the array elements overlap the subsequent members @code{b} and
9117@code{c}. The third store is diagnosed by @option{-Warray-bounds}
9118because it is beyond the bounds of the enclosing object.
9119
9120@smallexample
9121struct X @{ int a[0]; int b, c; @};
9122struct X x;
9123
9124void bad (void)
9125@{
9126 x.a[0] = 0; // -Wzero-length-bounds
9127 x.a[1] = 1; // -Wzero-length-bounds
9128 x.a[2] = 2; // -Warray-bounds
9129@}
9130@end smallexample
9131
9132Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
9133
d77de738
ML
9134@opindex Wno-div-by-zero
9135@opindex Wdiv-by-zero
ddf6fe37 9136@item -Wno-div-by-zero
d77de738
ML
9137Do not warn about compile-time integer division by zero. Floating-point
9138division by zero is not warned about, as it can be a legitimate way of
9139obtaining infinities and NaNs.
9140
d77de738
ML
9141@opindex Wsystem-headers
9142@opindex Wno-system-headers
9143@cindex warnings from system headers
9144@cindex system headers, warnings from
f33d7a88 9145@item -Wsystem-headers
d77de738
ML
9146Print warning messages for constructs found in system header files.
9147Warnings from system headers are normally suppressed, on the assumption
9148that they usually do not indicate real problems and would only make the
9149compiler output harder to read. Using this command-line option tells
9150GCC to emit warnings from system headers as if they occurred in user
9151code. However, note that using @option{-Wall} in conjunction with this
9152option does @emph{not} warn about unknown pragmas in system
9153headers---for that, @option{-Wunknown-pragmas} must also be used.
9154
d77de738
ML
9155@opindex Wtautological-compare
9156@opindex Wno-tautological-compare
ddf6fe37 9157@item -Wtautological-compare
d77de738
ML
9158Warn if a self-comparison always evaluates to true or false. This
9159warning detects various mistakes such as:
9160@smallexample
9161int i = 1;
9162@dots{}
9163if (i > i) @{ @dots{} @}
9164@end smallexample
9165
9166This warning also warns about bitwise comparisons that always evaluate
9167to true or false, for instance:
9168@smallexample
9169if ((a & 16) == 10) @{ @dots{} @}
9170@end smallexample
9171will always be false.
9172
9173This warning is enabled by @option{-Wall}.
9174
ac615e10
JJ
9175@opindex Wtrailing-whitespace
9176@opindex Wno-trailing-whitespace
9177@opindex Wtrailing-whitespace=
9178@item -Wtrailing-whitespace
9179@itemx -Wtrailing-whitespace=@var{kind}
9180Warn about trailing whitespace at the end of lines, including inside of
9181comments, but excluding trailing whitespace in raw string literals.
9182@code{-Wtrailing-whitespace} is equivalent to
ad7d5cd6
JJ
9183@code{-Wtrailing-whitespace=blanks} and warns just about trailing space and
9184horizontal tab characters. @code{-Wtrailing-whitespace=any} warns about
ac615e10
JJ
9185those or trailing form feed or vertical tab characters.
9186@code{-Wno-trailing-whitespace} or @code{-Wtrailing-whitespace=none}
9187disables the warning, which is the default.
9188This is a coding style warning.
9189
d4499a23
JJ
9190@opindex Wleading-whitespace=
9191@item -Wleading-whitespace=@var{kind}
9192Warn about style issues in leading whitespace, but not about the amount of
9193indentation. Some projects use coding styles where only spaces are used
9194for indentation, others use only tabs, others use zero or more tabs (for
9195multiples of @code{-ftabstop=@var{n}}) followed by zero or fewer than @var{n}
9196spaces. No warning is emitted on lines which contain solely whitespace
9197(although @code{-Wtrailing-whitespace=} warning might be emitted), no
9198warnings are emitted inside of raw string literals. Warnings are also emitted
9199for leading whitespace inside of multi-line comments.
9200@code{-Wleading-whitespace=spaces} warns about leading whitespace other than
9201spaces for projects which want to indent just by spaces.
9202@code{-Wleading-whitespace=tabs} warns about leading whitespace other than
9203horizontal tabs for projects which want to indent just by horizontal tabs.
9204@code{-Wleading-whitespace=blanks} warns about leading whitespace other than
9205spaces and horizontal tabs, or about horizontal tab after a space in the
9206leading whitespace, or about @var{n} or more consecutive spaces in leading
9207whitespace (where @var{n} is argument of @code{-ftabstop=@var{n}}, 8 by
9208default).
9209@code{-Wleading-whitespace=none} disables the warning, which is the default.
9210This is a coding style warning.
9211
d77de738
ML
9212@opindex Wtrampolines
9213@opindex Wno-trampolines
ddf6fe37 9214@item -Wtrampolines
d77de738
ML
9215Warn about trampolines generated for pointers to nested functions.
9216A trampoline is a small piece of data or code that is created at run
9217time on the stack when the address of a nested function is taken, and is
9218used to call the nested function indirectly. For some targets, it is
9219made up of data only and thus requires no special treatment. But, for
9220most targets, it is made up of code and thus requires the stack to be
9221made executable in order for the program to work properly.
9222
d77de738
ML
9223@opindex Wfloat-equal
9224@opindex Wno-float-equal
ddf6fe37 9225@item -Wfloat-equal
d77de738
ML
9226Warn if floating-point values are used in equality comparisons.
9227
9228The idea behind this is that sometimes it is convenient (for the
9229programmer) to consider floating-point values as approximations to
9230infinitely precise real numbers. If you are doing this, then you need
9231to compute (by analyzing the code, or in some other way) the maximum or
9232likely maximum error that the computation introduces, and allow for it
9233when performing comparisons (and when producing output, but that's a
9234different problem). In particular, instead of testing for equality, you
9235should check to see whether the two values have ranges that overlap; and
9236this is done with the relational operators, so equality comparisons are
9237probably mistaken.
9238
d77de738
ML
9239@opindex Wtraditional
9240@opindex Wno-traditional
ddf6fe37 9241@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
9242Warn about certain constructs that behave differently in traditional and
9243ISO C@. Also warn about ISO C constructs that have no traditional C
9244equivalent, and/or problematic constructs that should be avoided.
9245
9246@itemize @bullet
9247@item
9248Macro parameters that appear within string literals in the macro body.
9249In traditional C macro replacement takes place within string literals,
9250but in ISO C it does not.
9251
9252@item
9253In traditional C, some preprocessor directives did not exist.
9254Traditional preprocessors only considered a line to be a directive
9255if the @samp{#} appeared in column 1 on the line. Therefore
9256@option{-Wtraditional} warns about directives that traditional C
9257understands but ignores because the @samp{#} does not appear as the
9258first character on the line. It also suggests you hide directives like
9259@code{#pragma} not understood by traditional C by indenting them. Some
9260traditional implementations do not recognize @code{#elif}, so this option
9261suggests avoiding it altogether.
9262
9263@item
9264A function-like macro that appears without arguments.
9265
9266@item
9267The unary plus operator.
9268
9269@item
9270The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
9271constant suffixes. (Traditional C does support the @samp{L} suffix on integer
9272constants.) Note, these suffixes appear in macros defined in the system
9273headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
9274Use of these macros in user code might normally lead to spurious
9275warnings, however GCC's integrated preprocessor has enough context to
9276avoid warning in these cases.
9277
9278@item
9279A function declared external in one block and then used after the end of
9280the block.
9281
9282@item
9283A @code{switch} statement has an operand of type @code{long}.
9284
9285@item
9286A non-@code{static} function declaration follows a @code{static} one.
9287This construct is not accepted by some traditional C compilers.
9288
9289@item
9290The ISO type of an integer constant has a different width or
9291signedness from its traditional type. This warning is only issued if
9292the base of the constant is ten. I.e.@: hexadecimal or octal values, which
9293typically represent bit patterns, are not warned about.
9294
9295@item
9296Usage of ISO string concatenation is detected.
9297
9298@item
9299Initialization of automatic aggregates.
9300
9301@item
9302Identifier conflicts with labels. Traditional C lacks a separate
9303namespace for labels.
9304
9305@item
9306Initialization of unions. If the initializer is zero, the warning is
9307omitted. This is done under the assumption that the zero initializer in
9308user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
9309initializer warnings and relies on default initialization to zero in the
9310traditional C case.
9311
9312@item
9313Conversions by prototypes between fixed/floating-point values and vice
9314versa. The absence of these prototypes when compiling with traditional
9315C causes serious problems. This is a subset of the possible
9316conversion warnings; for the full set use @option{-Wtraditional-conversion}.
9317
9318@item
9319Use of ISO C style function definitions. This warning intentionally is
9320@emph{not} issued for prototype declarations or variadic functions
9321because these ISO C features appear in your code when using
9322libiberty's traditional C compatibility macros, @code{PARAMS} and
9323@code{VPARAMS}. This warning is also bypassed for nested functions
9324because that feature is already a GCC extension and thus not relevant to
9325traditional C compatibility.
9326@end itemize
9327
d77de738
ML
9328@opindex Wtraditional-conversion
9329@opindex Wno-traditional-conversion
ddf6fe37 9330@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
9331Warn if a prototype causes a type conversion that is different from what
9332would happen to the same argument in the absence of a prototype. This
9333includes conversions of fixed point to floating and vice versa, and
9334conversions changing the width or signedness of a fixed-point argument
9335except when the same as the default promotion.
9336
d77de738
ML
9337@opindex Wdeclaration-after-statement
9338@opindex Wno-declaration-after-statement
ddf6fe37 9339@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
9340Warn when a declaration is found after a statement in a block. This
9341construct, known from C++, was introduced with ISO C99 and is by default
9342allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
9343
5fccebdb
JM
9344This warning is upgraded to an error by @option{-pedantic-errors}.
9345
d77de738
ML
9346@opindex Wshadow
9347@opindex Wno-shadow
ddf6fe37 9348@item -Wshadow
d77de738
ML
9349Warn whenever a local variable or type declaration shadows another
9350variable, parameter, type, class member (in C++), or instance variable
9351(in Objective-C) or whenever a built-in function is shadowed. Note
9352that in C++, the compiler warns if a local variable shadows an
9353explicit typedef, but not if it shadows a struct/class/enum.
9354If this warning is enabled, it includes also all instances of
9355local shadowing. This means that @option{-Wno-shadow=local}
9356and @option{-Wno-shadow=compatible-local} are ignored when
9357@option{-Wshadow} is used.
9358Same as @option{-Wshadow=global}.
9359
d77de738
ML
9360@opindex Wno-shadow-ivar
9361@opindex Wshadow-ivar
ddf6fe37 9362@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
9363Do not warn whenever a local variable shadows an instance variable in an
9364Objective-C method.
9365
d77de738 9366@opindex Wshadow=global
ddf6fe37 9367@item -Wshadow=global
d77de738
ML
9368Warn for any shadowing.
9369Same as @option{-Wshadow}.
9370
d77de738 9371@opindex Wshadow=local
ddf6fe37 9372@item -Wshadow=local
d77de738
ML
9373Warn when a local variable shadows another local variable or parameter.
9374
d77de738 9375@opindex Wshadow=compatible-local
ddf6fe37 9376@item -Wshadow=compatible-local
d77de738
ML
9377Warn when a local variable shadows another local variable or parameter
9378whose type is compatible with that of the shadowing variable. In C++,
9379type compatibility here means the type of the shadowing variable can be
9380converted to that of the shadowed variable. The creation of this flag
9381(in addition to @option{-Wshadow=local}) is based on the idea that when
9382a local variable shadows another one of incompatible type, it is most
9383likely intentional, not a bug or typo, as shown in the following example:
9384
9385@smallexample
9386@group
9387for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
9388@{
9389 for (int i = 0; i < N; ++i)
9390 @{
9391 ...
9392 @}
9393 ...
9394@}
9395@end group
9396@end smallexample
9397
9398Since the two variable @code{i} in the example above have incompatible types,
9399enabling only @option{-Wshadow=compatible-local} does not emit a warning.
9400Because their types are incompatible, if a programmer accidentally uses one
9401in place of the other, type checking is expected to catch that and emit an
9402error or warning. Use of this flag instead of @option{-Wshadow=local} can
9403possibly reduce the number of warnings triggered by intentional shadowing.
9404Note that this also means that shadowing @code{const char *i} by
9405@code{char *i} does not emit a warning.
9406
9407This warning is also enabled by @option{-Wshadow=local}.
9408
d77de738
ML
9409@opindex Wlarger-than=
9410@opindex Wlarger-than-@var{byte-size}
ddf6fe37 9411@item -Wlarger-than=@var{byte-size}
d77de738
ML
9412Warn whenever an object is defined whose size exceeds @var{byte-size}.
9413@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9414Warnings controlled by the option can be disabled either by specifying
9415@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
9416
9417Also warn for calls to bounded functions such as @code{memchr} or
9418@code{strnlen} that specify a bound greater than the largest possible
9419object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
9420can only be disabled by @option{-Wno-larger-than}.
9421
d77de738 9422@opindex Wno-larger-than
ddf6fe37 9423@item -Wno-larger-than
d77de738
ML
9424Disable @option{-Wlarger-than=} warnings. The option is equivalent
9425to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
9426
d77de738
ML
9427@opindex Wframe-larger-than=
9428@opindex Wno-frame-larger-than
ddf6fe37 9429@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
9430Warn if the size of a function frame exceeds @var{byte-size}.
9431The computation done to determine the stack frame size is approximate
9432and not conservative.
9433The actual requirements may be somewhat greater than @var{byte-size}
9434even if you do not get a warning. In addition, any space allocated
9435via @code{alloca}, variable-length arrays, or related constructs
9436is not included by the compiler when determining
9437whether or not to issue a warning.
9438@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9439Warnings controlled by the option can be disabled either by specifying
9440@var{byte-size} of @samp{SIZE_MAX} or more or by
9441@option{-Wno-frame-larger-than}.
9442
d77de738 9443@opindex Wno-frame-larger-than
ddf6fe37 9444@item -Wno-frame-larger-than
d77de738
ML
9445Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
9446to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
9447
d77de738
ML
9448@opindex Wfree-nonheap-object
9449@opindex Wno-free-nonheap-object
ddf6fe37 9450@item -Wfree-nonheap-object
d77de738
ML
9451Warn when attempting to deallocate an object that was either not allocated
9452on the heap, or by using a pointer that was not returned from a prior call
9453to the corresponding allocation function. For example, because the call
9454to @code{stpcpy} returns a pointer to the terminating nul character and
9455not to the beginning of the object, the call to @code{free} below is
9456diagnosed.
9457
9458@smallexample
9459void f (char *p)
9460@{
9461 p = stpcpy (p, "abc");
9462 // ...
9463 free (p); // warning
9464@}
9465@end smallexample
9466
9467@option{-Wfree-nonheap-object} is included in @option{-Wall}.
9468
d77de738
ML
9469@opindex Wstack-usage
9470@opindex Wno-stack-usage
ddf6fe37 9471@item -Wstack-usage=@var{byte-size}
d77de738
ML
9472Warn if the stack usage of a function might exceed @var{byte-size}.
9473The computation done to determine the stack usage is conservative.
9474Any space allocated via @code{alloca}, variable-length arrays, or related
9475constructs is included by the compiler when determining whether or not to
9476issue a warning.
9477
9478The message is in keeping with the output of @option{-fstack-usage}.
9479
9480@itemize
9481@item
9482If the stack usage is fully static but exceeds the specified amount, it's:
9483
9484@smallexample
9485 warning: stack usage is 1120 bytes
9486@end smallexample
9487@item
9488If the stack usage is (partly) dynamic but bounded, it's:
9489
9490@smallexample
9491 warning: stack usage might be 1648 bytes
9492@end smallexample
9493@item
9494If the stack usage is (partly) dynamic and not bounded, it's:
9495
9496@smallexample
9497 warning: stack usage might be unbounded
9498@end smallexample
9499@end itemize
9500
9501@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
9502Warnings controlled by the option can be disabled either by specifying
9503@var{byte-size} of @samp{SIZE_MAX} or more or by
9504@option{-Wno-stack-usage}.
9505
d77de738 9506@opindex Wno-stack-usage
ddf6fe37 9507@item -Wno-stack-usage
d77de738
ML
9508Disable @option{-Wstack-usage=} warnings. The option is equivalent
9509to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
9510
d77de738
ML
9511@opindex Wunsafe-loop-optimizations
9512@opindex Wno-unsafe-loop-optimizations
ddf6fe37 9513@item -Wunsafe-loop-optimizations
d77de738
ML
9514Warn if the loop cannot be optimized because the compiler cannot
9515assume anything on the bounds of the loop indices. With
9516@option{-funsafe-loop-optimizations} warn if the compiler makes
9517such assumptions.
9518
d77de738
ML
9519@opindex Wno-pedantic-ms-format
9520@opindex Wpedantic-ms-format
ddf6fe37 9521@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
9522When used in combination with @option{-Wformat}
9523and @option{-pedantic} without GNU extensions, this option
9524disables the warnings about non-ISO @code{printf} / @code{scanf} format
9525width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
9526which depend on the MS runtime.
9527
d77de738
ML
9528@opindex Wpointer-arith
9529@opindex Wno-pointer-arith
ddf6fe37 9530@item -Wpointer-arith
d77de738
ML
9531Warn about anything that depends on the ``size of'' a function type or
9532of @code{void}. GNU C assigns these types a size of 1, for
9533convenience in calculations with @code{void *} pointers and pointers
9534to functions. In C++, warn also when an arithmetic operation involves
9535@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
9536
5fccebdb
JM
9537This warning is upgraded to an error by @option{-pedantic-errors}.
9538
d77de738
ML
9539@opindex Wpointer-compare
9540@opindex Wno-pointer-compare
ddf6fe37 9541@item -Wno-pointer-compare
d77de738
ML
9542Do not warn if a pointer is compared with a zero character constant.
9543This usually
9544means that the pointer was meant to be dereferenced. For example:
9545
9546@smallexample
9547const char *p = foo ();
9548if (p == '\0')
9549 return 42;
9550@end smallexample
9551
9552Note that the code above is invalid in C++11.
9553
9554This warning is enabled by default.
9555
d77de738
ML
9556@opindex Wtsan
9557@opindex Wno-tsan
9a5e8f9d
SL
9558@item -Wno-tsan
9559
9560Disable warnings about unsupported features in ThreadSanitizer.
d77de738
ML
9561
9562ThreadSanitizer does not support @code{std::atomic_thread_fence} and
9563can report false positives.
9564
d77de738
ML
9565@opindex Wtype-limits
9566@opindex Wno-type-limits
ddf6fe37 9567@item -Wtype-limits
d77de738
ML
9568Warn if a comparison is always true or always false due to the limited
9569range of the data type, but do not warn for constant expressions. For
9570example, warn if an unsigned variable is compared against zero with
9571@code{<} or @code{>=}. This warning is also enabled by
9572@option{-Wextra}.
9573
d77de738
ML
9574@opindex Wabsolute-value
9575@opindex Wno-absolute-value
ddf6fe37 9576@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
9577Warn for calls to standard functions that compute the absolute value
9578of an argument when a more appropriate standard function is available.
9579For example, calling @code{abs(3.14)} triggers the warning because the
9580appropriate function to call to compute the absolute value of a double
9581argument is @code{fabs}. The option also triggers warnings when the
9582argument in a call to such a function has an unsigned type. This
9583warning can be suppressed with an explicit type cast and it is also
9584enabled by @option{-Wextra}.
9585
9586@include cppwarnopts.texi
9587
d77de738
ML
9588@opindex Wbad-function-cast
9589@opindex Wno-bad-function-cast
ddf6fe37 9590@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738 9591Warn when a function call is cast to a non-matching type.
a0e64a04 9592For example, warn if a call to a function returning an integer type
d77de738
ML
9593is cast to a pointer type.
9594
d77de738
ML
9595@opindex Wc90-c99-compat
9596@opindex Wno-c90-c99-compat
ddf6fe37 9597@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
9598Warn about features not present in ISO C90, but present in ISO C99.
9599For instance, warn about use of variable length arrays, @code{long long}
9600type, @code{bool} type, compound literals, designated initializers, and so
9601on. This option is independent of the standards mode. Warnings are disabled
9602in the expression that follows @code{__extension__}.
9603
d77de738
ML
9604@opindex Wc99-c11-compat
9605@opindex Wno-c99-c11-compat
ddf6fe37 9606@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
9607Warn about features not present in ISO C99, but present in ISO C11.
9608For instance, warn about use of anonymous structures and unions,
9609@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9610@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9611and so on. This option is independent of the standards mode. Warnings are
9612disabled in the expression that follows @code{__extension__}.
9613
fad61bf7
JM
9614@opindex Wc11-c23-compat
9615@opindex Wno-c11-c23-compat
9616@item -Wc11-c23-compat @r{(C and Objective-C only)}
9617@itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9618Warn about features not present in ISO C11, but present in ISO C23.
d77de738
ML
9619For instance, warn about omitting the string in @code{_Static_assert},
9620use of @samp{[[]]} syntax for attributes, use of decimal
9621floating-point types, and so on. This option is independent of the
9622standards mode. Warnings are disabled in the expression that follows
fad61bf7
JM
9623@code{__extension__}. The name @option{-Wc11-c2x-compat} is
9624deprecated.
d77de738 9625
fad61bf7 9626When not compiling in C23 mode, these warnings are upgraded to errors
5fccebdb
JM
9627by @option{-pedantic-errors}.
9628
0cf68222
JM
9629@opindex Wc23-c2y-compat
9630@opindex Wno-c23-c2y-compat
9631@item -Wc23-c2y-compat @r{(C and Objective-C only)}
9632@itemx -Wc23-c2y-compat @r{(C and Objective-C only)}
9633Warn about features not present in ISO C23, but present in ISO C2Y.
9634For instance, warn about @code{_Generic} selecting with a type name
9635instead of an expression. This option is independent of the standards
9636mode. Warnings are disabled in the expression that follows
9637@code{__extension__}.
9638
9639When not compiling in C2Y mode, these warnings are upgraded to errors
9640by @option{-pedantic-errors}.
9641
d77de738
ML
9642@opindex Wc++-compat
9643@opindex Wno-c++-compat
ddf6fe37 9644@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
9645Warn about ISO C constructs that are outside of the common subset of
9646ISO C and ISO C++, e.g.@: request for implicit conversion from
9647@code{void *} to a pointer to non-@code{void} type.
9648
d77de738
ML
9649@opindex Wc++11-compat
9650@opindex Wno-c++11-compat
ddf6fe37 9651@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9652Warn about C++ constructs whose meaning differs between ISO C++ 1998
9653and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9654in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9655enabled by @option{-Wall}.
9656
d77de738
ML
9657@opindex Wc++14-compat
9658@opindex Wno-c++14-compat
ddf6fe37 9659@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9660Warn about C++ constructs whose meaning differs between ISO C++ 2011
9661and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9662
d77de738
ML
9663@opindex Wc++17-compat
9664@opindex Wno-c++17-compat
ddf6fe37 9665@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9666Warn about C++ constructs whose meaning differs between ISO C++ 2014
9667and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9668
d77de738
ML
9669@opindex Wc++20-compat
9670@opindex Wno-c++20-compat
ddf6fe37 9671@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9672Warn about C++ constructs whose meaning differs between ISO C++ 2017
9673and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9674
d77de738
ML
9675@opindex Wc++11-extensions
9676@opindex Wno-c++11-extensions
ddf6fe37 9677@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9678Do not warn about C++11 constructs in code being compiled using
9679an older C++ standard. Even without this option, some C++11 constructs
9680will only be diagnosed if @option{-Wpedantic} is used.
9681
d77de738
ML
9682@opindex Wc++14-extensions
9683@opindex Wno-c++14-extensions
ddf6fe37 9684@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9685Do not warn about C++14 constructs in code being compiled using
9686an older C++ standard. Even without this option, some C++14 constructs
9687will only be diagnosed if @option{-Wpedantic} is used.
9688
d77de738
ML
9689@opindex Wc++17-extensions
9690@opindex Wno-c++17-extensions
ddf6fe37 9691@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9692Do not warn about C++17 constructs in code being compiled using
9693an older C++ standard. Even without this option, some C++17 constructs
9694will only be diagnosed if @option{-Wpedantic} is used.
9695
d77de738
ML
9696@opindex Wc++20-extensions
9697@opindex Wno-c++20-extensions
ddf6fe37 9698@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9699Do not warn about C++20 constructs in code being compiled using
9700an older C++ standard. Even without this option, some C++20 constructs
9701will only be diagnosed if @option{-Wpedantic} is used.
9702
d77de738
ML
9703@opindex Wc++23-extensions
9704@opindex Wno-c++23-extensions
ddf6fe37 9705@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9706Do not warn about C++23 constructs in code being compiled using
9707an older C++ standard. Even without this option, some C++23 constructs
9708will only be diagnosed if @option{-Wpedantic} is used.
9709
6ce95218
JJ
9710@opindex Wc++26-extensions
9711@opindex Wno-c++26-extensions
9712@item -Wno-c++26-extensions @r{(C++ and Objective-C++ only)}
9713Do not warn about C++26 constructs in code being compiled using
9714an older C++ standard. Even without this option, some C++26 constructs
9715will only be diagnosed if @option{-Wpedantic} is used.
9716
d77de738
ML
9717@opindex Wcast-qual
9718@opindex Wno-cast-qual
ddf6fe37 9719@item -Wcast-qual
d77de738
ML
9720Warn whenever a pointer is cast so as to remove a type qualifier from
9721the target type. For example, warn if a @code{const char *} is cast
9722to an ordinary @code{char *}.
9723
9724Also warn when making a cast that introduces a type qualifier in an
9725unsafe way. For example, casting @code{char **} to @code{const char **}
9726is unsafe, as in this example:
9727
9728@smallexample
9729 /* p is char ** value. */
9730 const char **q = (const char **) p;
9731 /* Assignment of readonly string to const char * is OK. */
9732 *q = "string";
9733 /* Now char** pointer points to read-only memory. */
9734 **p = 'b';
9735@end smallexample
9736
d77de738
ML
9737@opindex Wcast-align
9738@opindex Wno-cast-align
ddf6fe37 9739@item -Wcast-align
d77de738
ML
9740Warn whenever a pointer is cast such that the required alignment of the
9741target is increased. For example, warn if a @code{char *} is cast to
9742an @code{int *} on machines where integers can only be accessed at
9743two- or four-byte boundaries.
9744
d77de738 9745@opindex Wcast-align=strict
ddf6fe37 9746@item -Wcast-align=strict
d77de738
ML
9747Warn whenever a pointer is cast such that the required alignment of the
9748target is increased. For example, warn if a @code{char *} is cast to
9749an @code{int *} regardless of the target machine.
9750
d77de738
ML
9751@opindex Wcast-function-type
9752@opindex Wno-cast-function-type
ddf6fe37 9753@item -Wcast-function-type
d77de738
ML
9754Warn when a function pointer is cast to an incompatible function pointer.
9755In a cast involving function types with a variable argument list only
9756the types of initial arguments that are provided are considered.
9757Any parameter of pointer-type matches any other pointer-type. Any benign
9758differences in integral types are ignored, like @code{int} vs.@: @code{long}
9759on ILP32 targets. Likewise type qualifiers are ignored. The function
9760type @code{void (*) (void)} is special and matches everything, which can
9761be used to suppress this warning.
9762In a cast involving pointer to member types this warning warns whenever
9763the type cast is changing the pointer to member type.
9764This warning is enabled by @option{-Wextra}.
9765
df7bfdb7
JM
9766@opindex Wcast-user-defined
9767@opindex Wno-cast-user-defined
9768@item -Wcast-user-defined
9769Warn when a cast to reference type does not involve a user-defined
9770conversion that the programmer might expect to be called.
9771
9772@smallexample
9773struct A @{ operator const int&(); @} a;
9774auto r = (int&)a; // warning
9775@end smallexample
9776
9777This warning is enabled by default.
9778
d77de738
ML
9779@opindex Wwrite-strings
9780@opindex Wno-write-strings
ddf6fe37 9781@item -Wwrite-strings
d77de738
ML
9782When compiling C, give string constants the type @code{const
9783char[@var{length}]} so that copying the address of one into a
9784non-@code{const} @code{char *} pointer produces a warning. These
9785warnings help you find at compile time code that can try to write
9786into a string constant, but only if you have been very careful about
9787using @code{const} in declarations and prototypes. Otherwise, it is
9788just a nuisance. This is why we did not make @option{-Wall} request
9789these warnings.
9790
9791When compiling C++, warn about the deprecated conversion from string
9792literals to @code{char *}. This warning is enabled by default for C++
9793programs.
9794
5fccebdb
JM
9795This warning is upgraded to an error by @option{-pedantic-errors} in
9796C++11 mode or later.
9797
d77de738
ML
9798@opindex Wclobbered
9799@opindex Wno-clobbered
f33d7a88 9800@item -Wclobbered
d77de738
ML
9801Warn for variables that might be changed by @code{longjmp} or
9802@code{vfork}. This warning is also enabled by @option{-Wextra}.
9803
320dc51c
TS
9804@opindex Wcomplain-wrong-lang
9805@opindex Wno-complain-wrong-lang
f33d7a88 9806@item -Wno-complain-wrong-lang
320dc51c
TS
9807By default, language front ends complain when a command-line option is
9808valid, but not applicable to that front end.
9809This may be disabled with @option{-Wno-complain-wrong-lang},
9810which is mostly useful when invoking a single compiler driver for
9811multiple source files written in different languages, for example:
9812
9813@smallexample
9814$ g++ -fno-rtti a.cc b.f90
9815@end smallexample
9816
9817The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9818and the Fortran front end to compile @file{b.f90}.
9819The latter front end diagnoses
9820@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9821which may be disabled with @option{-Wno-complain-wrong-lang}.
9822
e1f45bea
JM
9823@opindex Wcompare-distinct-pointer-types
9824@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9825Warn if pointers of distinct types are compared without a cast. This
9826warning is enabled by default.
9827
d77de738
ML
9828@opindex Wconversion
9829@opindex Wno-conversion
f33d7a88 9830@item -Wconversion
d77de738
ML
9831Warn for implicit conversions that may alter a value. This includes
9832conversions between real and integer, like @code{abs (x)} when
9833@code{x} is @code{double}; conversions between signed and unsigned,
9834like @code{unsigned ui = -1}; and conversions to smaller types, like
9835@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9836((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9837changed by the conversion like in @code{abs (2.0)}. Warnings about
9838conversions between signed and unsigned integers can be disabled by
9839using @option{-Wno-sign-conversion}.
9840
9841For C++, also warn for confusing overload resolution for user-defined
9842conversions; and conversions that never use a type conversion
9843operator: conversions to @code{void}, the same type, a base class or a
9844reference to them. Warnings about conversions between signed and
9845unsigned integers are disabled by default in C++ unless
9846@option{-Wsign-conversion} is explicitly enabled.
9847
9848Warnings about conversion from arithmetic on a small type back to that
9849type are only given with @option{-Warith-conversion}.
9850
d77de738
ML
9851@opindex Wdangling-else
9852@opindex Wno-dangling-else
ddf6fe37 9853@item -Wdangling-else
d77de738
ML
9854Warn about constructions where there may be confusion to which
9855@code{if} statement an @code{else} branch belongs. Here is an example of
9856such a case:
9857
9858@smallexample
9859@group
9860@{
9861 if (a)
9862 if (b)
9863 foo ();
9864 else
9865 bar ();
9866@}
9867@end group
9868@end smallexample
9869
9870In C/C++, every @code{else} branch belongs to the innermost possible
9871@code{if} statement, which in this example is @code{if (b)}. This is
9872often not what the programmer expected, as illustrated in the above
9873example by indentation the programmer chose. When there is the
9874potential for this confusion, GCC issues a warning when this flag
9875is specified. To eliminate the warning, add explicit braces around
9876the innermost @code{if} statement so there is no way the @code{else}
9877can belong to the enclosing @code{if}. The resulting code
9878looks like this:
9879
9880@smallexample
9881@group
9882@{
9883 if (a)
9884 @{
9885 if (b)
9886 foo ();
9887 else
9888 bar ();
9889 @}
9890@}
9891@end group
9892@end smallexample
9893
9894This warning is enabled by @option{-Wparentheses}.
9895
d77de738
ML
9896@opindex Wdangling-pointer
9897@opindex Wno-dangling-pointer
ddf6fe37
AA
9898@item -Wdangling-pointer
9899@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9900Warn about uses of pointers (or C++ references) to objects with automatic
9901storage duration after their lifetime has ended. This includes local
9902variables declared in nested blocks, compound literals and other unnamed
9903temporary objects. In addition, warn about storing the address of such
9904objects in escaped pointers. The warning is enabled at all optimization
9905levels but may yield different results with optimization than without.
9906
9907@table @gcctabopt
9908@item -Wdangling-pointer=1
29f931e3
SL
9909At level 1, the warning diagnoses only unconditional uses of dangling pointers.
9910
9911@item -Wdangling-pointer=2
9912At level 2, in addition to unconditional uses the warning also diagnoses
9913conditional uses of dangling pointers.
9914@end table
9915
9916The short form @option{-Wdangling-pointer} is equivalent to
9917@option{-Wdangling-pointer=2}, while @option{-Wno-dangling-pointer} and
9918@option{-Wdangling-pointer=0} have the same effect of disabling the warnings.
9919@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9920
9921This example triggers the warning at level 1; the address of the unnamed
9922temporary is unconditionally referenced outside of its scope.
9923
d77de738 9924@smallexample
29f931e3 9925char f (char c1, char c2, char c3)
d77de738 9926@{
29f931e3
SL
9927 char *p;
9928 @{
9929 p = (char[]) @{ c1, c2, c3 @};
9930 @}
9931 // warning: using dangling pointer 'p' to an unnamed temporary
9932 return *p;
d77de738
ML
9933@}
9934@end smallexample
29f931e3 9935
d77de738 9936In the following function the store of the address of the local variable
29f931e3
SL
9937@code{x} in the escaped pointer @code{*p} triggers the warning at
9938level 1.
9939
d77de738
ML
9940@smallexample
9941void g (int **p)
9942@{
9943 int x = 7;
29f931e3 9944 // warning: storing the address of local variable 'x' in '*p'
4ace81b6 9945 *p = &x;
d77de738
ML
9946@}
9947@end smallexample
9948
29f931e3
SL
9949In this example, the array @var{a} is out of
9950scope when the pointer @var{s} is used. Since the code that sets @code{s}
9951is conditional, the warning triggers at level 2.
d77de738
ML
9952
9953@smallexample
29f931e3
SL
9954extern void frob (const char *);
9955void h (char *s)
d77de738
ML
9956@{
9957 if (!s)
9958 @{
9959 char a[12] = "tmpname";
9960 s = a;
9961 @}
29f931e3
SL
9962 // warning: dangling pointer 's' to 'a' may be used
9963 frob (s);
d77de738
ML
9964@}
9965@end smallexample
d77de738 9966
d77de738
ML
9967@opindex Wdate-time
9968@opindex Wno-date-time
ddf6fe37 9969@item -Wdate-time
d77de738
ML
9970Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9971are encountered as they might prevent bit-wise-identical reproducible
9972compilations.
9973
d77de738
ML
9974@opindex Wempty-body
9975@opindex Wno-empty-body
ddf6fe37 9976@item -Wempty-body
d77de738
ML
9977Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9978while} statement. This warning is also enabled by @option{-Wextra}.
9979
d77de738
ML
9980@opindex Wendif-labels
9981@opindex Wno-endif-labels
ddf6fe37 9982@item -Wno-endif-labels
d77de738
ML
9983Do not warn about stray tokens after @code{#else} and @code{#endif}.
9984
d77de738
ML
9985@opindex Wenum-compare
9986@opindex Wno-enum-compare
ddf6fe37 9987@item -Wenum-compare
d77de738
ML
9988Warn about a comparison between values of different enumerated types.
9989In C++ enumerated type mismatches in conditional expressions are also
a0e64a04 9990diagnosed and the warning is enabled by default. In C this warning is
d77de738
ML
9991enabled by @option{-Wall}.
9992
d77de738
ML
9993@opindex Wenum-conversion
9994@opindex Wno-enum-conversion
ddf6fe37 9995@item -Wenum-conversion
a0e64a04 9996Warn when a value of enumerated type is implicitly converted to a
d77de738
ML
9997different enumerated type. This warning is enabled by @option{-Wextra}
9998in C@.
9999
d77de738
ML
10000@opindex Wenum-int-mismatch
10001@opindex Wno-enum-int-mismatch
ddf6fe37 10002@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
10003Warn about mismatches between an enumerated type and an integer type in
10004declarations. For example:
10005
10006@smallexample
10007enum E @{ l = -1, z = 0, g = 1 @};
10008int foo(void);
10009enum E foo(void);
10010@end smallexample
10011
10012In C, an enumerated type is compatible with @code{char}, a signed
10013integer type, or an unsigned integer type. However, since the choice
10014of the underlying type of an enumerated type is implementation-defined,
10015such mismatches may cause portability issues. In C++, such mismatches
10016are an error. In C, this warning is enabled by @option{-Wall} and
10017@option{-Wc++-compat}.
10018
d77de738
ML
10019@opindex Wjump-misses-init
10020@opindex Wno-jump-misses-init
ddf6fe37 10021@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
10022Warn if a @code{goto} statement or a @code{switch} statement jumps
10023forward across the initialization of a variable, or jumps backward to a
10024label after the variable has been initialized. This only warns about
10025variables that are initialized when they are declared. This warning is
10026only supported for C and Objective-C; in C++ this sort of branch is an
10027error in any case.
10028
10029@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
10030can be disabled with the @option{-Wno-jump-misses-init} option.
10031
d77de738
ML
10032@opindex Wsign-compare
10033@opindex Wno-sign-compare
10034@cindex warning for comparison of signed and unsigned values
10035@cindex comparison of signed and unsigned values, warning
10036@cindex signed and unsigned values, comparison warning
f33d7a88 10037@item -Wsign-compare
d77de738
ML
10038Warn when a comparison between signed and unsigned values could produce
10039an incorrect result when the signed value is converted to unsigned.
10040In C++, this warning is also enabled by @option{-Wall}. In C, it is
10041also enabled by @option{-Wextra}.
10042
d77de738
ML
10043@opindex Wsign-conversion
10044@opindex Wno-sign-conversion
ddf6fe37 10045@item -Wsign-conversion
d77de738
ML
10046Warn for implicit conversions that may change the sign of an integer
10047value, like assigning a signed integer expression to an unsigned
10048integer variable. An explicit cast silences the warning. In C, this
10049option is enabled also by @option{-Wconversion}.
10050
44e3f39a
QZ
10051@opindex Wflex-array-member-not-at-end
10052@opindex Wno-flex-array-member-not-at-end
10053@item -Wflex-array-member-not-at-end @r{(C and C++ only)}
10054Warn when a structure containing a C99 flexible array member as the last
10055field is not at the end of another structure.
10056This warning warns e.g. about
10057
10058@smallexample
10059struct flex @{ int length; char data[]; @};
10060struct mid_flex @{ int m; struct flex flex_data; int n; @};
10061@end smallexample
10062
d77de738
ML
10063@opindex Wfloat-conversion
10064@opindex Wno-float-conversion
ddf6fe37 10065@item -Wfloat-conversion
d77de738
ML
10066Warn for implicit conversions that reduce the precision of a real value.
10067This includes conversions from real to integer, and from higher precision
10068real to lower precision real values. This option is also enabled by
10069@option{-Wconversion}.
10070
d77de738
ML
10071@opindex Wno-scalar-storage-order
10072@opindex Wscalar-storage-order
ddf6fe37 10073@item -Wno-scalar-storage-order
d77de738
ML
10074Do not warn on suspicious constructs involving reverse scalar storage order.
10075
d77de738
ML
10076@opindex Wsizeof-array-div
10077@opindex Wno-sizeof-array-div
ddf6fe37 10078@item -Wsizeof-array-div
d77de738
ML
10079Warn about divisions of two sizeof operators when the first one is applied
10080to an array and the divisor does not equal the size of the array element.
10081In such a case, the computation will not yield the number of elements in the
10082array, which is likely what the user intended. This warning warns e.g. about
10083@smallexample
10084int fn ()
10085@{
10086 int arr[10];
10087 return sizeof (arr) / sizeof (short);
10088@}
10089@end smallexample
10090
10091This warning is enabled by @option{-Wall}.
10092
d77de738
ML
10093@opindex Wsizeof-pointer-div
10094@opindex Wno-sizeof-pointer-div
ddf6fe37 10095@item -Wsizeof-pointer-div
d77de738
ML
10096Warn for suspicious divisions of two sizeof expressions that divide
10097the pointer size by the element size, which is the usual way to compute
10098the array size but won't work out correctly with pointers. This warning
10099warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
10100not an array, but a pointer. This warning is enabled by @option{-Wall}.
10101
d77de738
ML
10102@opindex Wsizeof-pointer-memaccess
10103@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 10104@item -Wsizeof-pointer-memaccess
d77de738
ML
10105Warn for suspicious length parameters to certain string and memory built-in
10106functions if the argument uses @code{sizeof}. This warning triggers for
10107example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
10108an array, but a pointer, and suggests a possible fix, or about
10109@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
10110also warns about calls to bounded string copy functions like @code{strncat}
10111or @code{strncpy} that specify as the bound a @code{sizeof} expression of
10112the source array. For example, in the following function the call to
10113@code{strncat} specifies the size of the source string as the bound. That
10114is almost certainly a mistake and so the call is diagnosed.
10115@smallexample
10116void make_file (const char *name)
10117@{
10118 char path[PATH_MAX];
10119 strncpy (path, name, sizeof path - 1);
10120 strncat (path, ".text", sizeof ".text");
10121 @dots{}
10122@}
10123@end smallexample
10124
10125The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
10126
d77de738
ML
10127@opindex Wsizeof-array-argument
10128@opindex Wno-sizeof-array-argument
ddf6fe37 10129@item -Wno-sizeof-array-argument
d77de738
ML
10130Do not warn when the @code{sizeof} operator is applied to a parameter that is
10131declared as an array in a function definition. This warning is enabled by
10132default for C and C++ programs.
10133
d77de738
ML
10134@opindex Wmemset-elt-size
10135@opindex Wno-memset-elt-size
ddf6fe37 10136@item -Wmemset-elt-size
d77de738
ML
10137Warn for suspicious calls to the @code{memset} built-in function, if the
10138first argument references an array, and the third argument is a number
10139equal to the number of elements, but not equal to the size of the array
10140in memory. This indicates that the user has omitted a multiplication by
10141the element size. This warning is enabled by @option{-Wall}.
10142
d77de738
ML
10143@opindex Wmemset-transposed-args
10144@opindex Wno-memset-transposed-args
ddf6fe37 10145@item -Wmemset-transposed-args
d77de738
ML
10146Warn for suspicious calls to the @code{memset} built-in function where
10147the second argument is not zero and the third argument is zero. For
10148example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
10149@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
10150is only emitted if the third argument is a literal zero. Otherwise, if
10151it is an expression that is folded to zero, or a cast of zero to some
10152type, it is far less likely that the arguments have been mistakenly
10153transposed and no warning is emitted. This warning is enabled
10154by @option{-Wall}.
10155
d77de738
ML
10156@opindex Waddress
10157@opindex Wno-address
ddf6fe37 10158@item -Waddress
d77de738
ML
10159Warn about suspicious uses of address expressions. These include comparing
10160the address of a function or a declared object to the null pointer constant
10161such as in
10162@smallexample
10163void f (void);
10164void g (void)
10165@{
10166 if (!f) // warning: expression evaluates to false
10167 abort ();
10168@}
10169@end smallexample
10170comparisons of a pointer to a string literal, such as in
10171@smallexample
10172void f (const char *x)
10173@{
10174 if (x == "abc") // warning: expression evaluates to false
10175 puts ("equal");
10176@}
10177@end smallexample
10178and tests of the results of pointer addition or subtraction for equality
10179to null, such as in
10180@smallexample
10181void f (const int *p, int i)
10182@{
10183 return p + i == NULL;
10184@}
10185@end smallexample
10186Such uses typically indicate a programmer error: the address of most
10187functions and objects necessarily evaluates to true (the exception are
10188weak symbols), so their use in a conditional might indicate missing
10189parentheses in a function call or a missing dereference in an array
10190expression. The subset of the warning for object pointers can be
10191suppressed by casting the pointer operand to an integer type such
10192as @code{intptr_t} or @code{uintptr_t}.
10193Comparisons against string literals result in unspecified behavior
10194and are not portable, and suggest the intent was to call @code{strcmp}.
10195The warning is suppressed if the suspicious expression is the result
10196of macro expansion.
10197@option{-Waddress} warning is enabled by @option{-Wall}.
10198
d77de738
ML
10199@opindex Waddress-of-packed-member
10200@opindex Wno-address-of-packed-member
ddf6fe37 10201@item -Wno-address-of-packed-member
d77de738
ML
10202Do not warn when the address of packed member of struct or union is taken,
10203which usually results in an unaligned pointer value. This is
10204enabled by default.
10205
d77de738
ML
10206@opindex Wlogical-op
10207@opindex Wno-logical-op
ddf6fe37 10208@item -Wlogical-op
d77de738
ML
10209Warn about suspicious uses of logical operators in expressions.
10210This includes using logical operators in contexts where a
10211bit-wise operator is likely to be expected. Also warns when
10212the operands of a logical operator are the same:
10213@smallexample
10214extern int a;
10215if (a < 0 && a < 0) @{ @dots{} @}
10216@end smallexample
10217
d77de738
ML
10218@opindex Wlogical-not-parentheses
10219@opindex Wno-logical-not-parentheses
ddf6fe37 10220@item -Wlogical-not-parentheses
d77de738
ML
10221Warn about logical not used on the left hand side operand of a comparison.
10222This option does not warn if the right operand is considered to be a boolean
10223expression. Its purpose is to detect suspicious code like the following:
10224@smallexample
10225int a;
10226@dots{}
10227if (!a > 1) @{ @dots{} @}
10228@end smallexample
10229
10230It is possible to suppress the warning by wrapping the LHS into
10231parentheses:
10232@smallexample
10233if ((!a) > 1) @{ @dots{} @}
10234@end smallexample
10235
10236This warning is enabled by @option{-Wall}.
10237
d77de738
ML
10238@opindex Waggregate-return
10239@opindex Wno-aggregate-return
ddf6fe37 10240@item -Waggregate-return
d77de738
ML
10241Warn if any functions that return structures or unions are defined or
10242called. (In languages where you can return an array, this also elicits
10243a warning.)
10244
d77de738
ML
10245@opindex Wno-aggressive-loop-optimizations
10246@opindex Waggressive-loop-optimizations
ddf6fe37 10247@item -Wno-aggressive-loop-optimizations
13c9b353
SL
10248Do not warn if the compiler detects undefined behavior in a loop with
10249a constant number of iterations. @option{-Waggressive-loop-optimizations}
10250is enabled by default.
d77de738 10251
d77de738
ML
10252@opindex Wno-attributes
10253@opindex Wattributes
ddf6fe37 10254@item -Wno-attributes
d77de738
ML
10255Do not warn if an unexpected @code{__attribute__} is used, such as
10256unrecognized attributes, function attributes applied to variables,
10257etc. This does not stop errors for incorrect use of supported
10258attributes.
10259
5fccebdb
JM
10260Warnings about ill-formed uses of standard attributes are upgraded to
10261errors by @option{-pedantic-errors}.
10262
d77de738 10263Additionally, using @option{-Wno-attributes=}, it is possible to suppress
094a609c 10264warnings about unknown scoped attributes (in C++11 and C23). For example,
d77de738
ML
10265@option{-Wno-attributes=vendor::attr} disables warning about the following
10266declaration:
10267
10268@smallexample
10269[[vendor::attr]] void f();
10270@end smallexample
10271
10272It is also possible to disable warning about all attributes in a namespace
10273using @option{-Wno-attributes=vendor::} which prevents warning about both
10274of these declarations:
10275
10276@smallexample
10277[[vendor::safe]] void f();
10278[[vendor::unsafe]] void f2();
10279@end smallexample
10280
10281Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
10282
d77de738
ML
10283@opindex Wno-builtin-declaration-mismatch
10284@opindex Wbuiltin-declaration-mismatch
ddf6fe37 10285@item -Wno-builtin-declaration-mismatch
d77de738
ML
10286Warn if a built-in function is declared with an incompatible signature
10287or as a non-function, or when a built-in function declared with a type
10288that does not include a prototype is called with arguments whose promoted
10289types do not match those expected by the function. When @option{-Wextra}
10290is specified, also warn when a built-in function that takes arguments is
10291declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
10292warning is enabled by default. To avoid the warning include the appropriate
10293header to bring the prototypes of built-in functions into scope.
10294
10295For example, the call to @code{memset} below is diagnosed by the warning
10296because the function expects a value of type @code{size_t} as its argument
10297but the type of @code{32} is @code{int}. With @option{-Wextra},
10298the declaration of the function is diagnosed as well.
10299@smallexample
10300extern void* memset ();
10301void f (void *d)
10302@{
10303 memset (d, '\0', 32);
10304@}
10305@end smallexample
10306
d77de738
ML
10307@opindex Wno-builtin-macro-redefined
10308@opindex Wbuiltin-macro-redefined
ddf6fe37 10309@item -Wno-builtin-macro-redefined
d77de738
ML
10310Do not warn if certain built-in macros are redefined. This suppresses
10311warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
10312@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
10313
631cd92b
FW
10314@opindex Wfree-labels
10315@opindex Wno-free-labels
10316@item -Wfree-labels @r{(C and Objective-C only)}
10317Warn if a label is applied to a non-statement, or occurs at the end of a
10318compound statement. Such labels are allowed by C23 and later dialects
10319of C, and are available as a GCC extension in all other dialects.
10320
10321This warning is also enabled by @option{-Wc11-c23-compat}. It is turned
10322into an error if building for a C version before C23 by
10323@option{-pedantic-errors}.
10324
5943a2fa
JJ
10325@opindex Wheader-guard
10326@item -Wheader-guard
10327Warn if a valid preprocessor header multiple inclusion guard has
10328a @code{#define} directive right after @code{#ifndef} or @code{#if !defined}
10329directive for the multiple inclusion guard, which defines a different macro
10330from the guard macro with a similar name, the actual multiple inclusion guard
10331macro isn't defined at the corresponding @code{#ifndef} directive at the end
10332of the header, and the @code{#define} directive defines an object-like macro
10333with empty definition. In such case, it often is just a misspelled guard
10334name, either in the @code{#ifndef} or @code{#if !defined} directive or in the
10335subsequent @code{#define} directive. This warning is enabled
10336by @option{-Wall}.
10337
d77de738
ML
10338@opindex Wstrict-prototypes
10339@opindex Wno-strict-prototypes
ddf6fe37 10340@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
10341Warn if a function is declared or defined without specifying the
10342argument types. (An old-style function definition is permitted without
10343a warning if preceded by a declaration that specifies the argument
10344types.)
10345
d77de738
ML
10346@opindex Wold-style-declaration
10347@opindex Wno-old-style-declaration
ddf6fe37 10348@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
10349Warn for obsolescent usages, according to the C Standard, in a
10350declaration. For example, warn if storage-class specifiers like
10351@code{static} are not the first things in a declaration. This warning
10352is also enabled by @option{-Wextra}.
10353
d77de738
ML
10354@opindex Wold-style-definition
10355@opindex Wno-old-style-definition
ddf6fe37 10356@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
10357Warn if an old-style function definition is used. A warning is given
10358even if there is a previous prototype. A definition using @samp{()}
094a609c 10359is not considered an old-style definition in C23 mode, because it is
d77de738
ML
10360equivalent to @samp{(void)} in that case, but is considered an
10361old-style definition for older standards.
10362
701d8e7e
FW
10363@opindex Wdeprecated-non-prototype
10364@opindex Wno-deprecated-non-prototype
10365@item -Wdeprecated-non-prototype @r{(C and Objective-C only)}
b9857b78 10366Warn if a function declared with an empty parameter list @samp{()} is
701d8e7e
FW
10367called with one or more arguments, or if a function definition with one
10368or more parameters is encountered after such a declaration. Both cases
10369are errors in C23 and later dialects of C.
10370
10371This warning is also enabled by @option{-Wc11-c23-compat}.
10372
8833389e
FW
10373@opindex Wmissing-parameter-name
10374@opindex Wno-missing-parameter-name
10375@item -Wmissing-parameter-name @r{(C and Objective-C only)}
10376Warn if a function definition omits a parameter name, specifying only
10377its type. This can be used to document that a parameter is unused
10378in the definition. It is part of C23 and later dialects of C,
10379and available as a GCC extension in all other dialects.
10380
10381This warning is also enabled by @option{-Wc11-c23-compat}. It is turned
10382into an error if building for a C version before C23 by
10383@option{-pedantic-errors}.
10384
d77de738
ML
10385@opindex Wmissing-parameter-type
10386@opindex Wno-missing-parameter-type
ddf6fe37 10387@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
10388A function parameter is declared without a type specifier in K&R-style
10389functions:
10390
10391@smallexample
10392void foo(bar) @{ @}
10393@end smallexample
10394
10395This warning is also enabled by @option{-Wextra}.
10396
ff9efa3f
FW
10397@opindex Wno-declaration-missing-parameter-type
10398@opindex Wdeclaration-missing-parameter-type
10399@item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)}
10400Do not warn if a function declaration contains a parameter name without
10401a type. Such function declarations do not provide a function prototype
10402and prevent most type checking in function calls.
10403
10404This warning is enabled by default. In C99 and later dialects of C, it
10405is treated as an error. The error can be downgraded to a warning using
10406@option{-fpermissive} (along with certain other errors), or for this
10407error alone, with @option{-Wno-error=declaration-missing-parameter-type}.
10408
10409This warning is upgraded to an error by @option{-pedantic-errors}.
10410
d77de738
ML
10411@opindex Wmissing-prototypes
10412@opindex Wno-missing-prototypes
ddf6fe37 10413@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
10414Warn if a global function is defined without a previous prototype
10415declaration. This warning is issued even if the definition itself
10416provides a prototype. Use this option to detect global functions
10417that do not have a matching prototype declaration in a header file.
10418This option is not valid for C++ because all function declarations
10419provide prototypes and a non-matching declaration declares an
10420overload rather than conflict with an earlier declaration.
10421Use @option{-Wmissing-declarations} to detect missing declarations in C++.
10422
ffc74822
HM
10423@opindex Wmissing-variable-declarations
10424@opindex Wno-missing-variable-declarations
10425@item -Wmissing-variable-declarations @r{(C and Objective-C only)}
10426Warn if a global variable is defined without a previous declaration.
10427Use this option to detect global variables that do not have a matching
10428extern declaration in a header file.
10429
d77de738
ML
10430@opindex Wmissing-declarations
10431@opindex Wno-missing-declarations
ddf6fe37 10432@item -Wmissing-declarations
d77de738
ML
10433Warn if a global function is defined without a previous declaration.
10434Do so even if the definition itself provides a prototype.
10435Use this option to detect global functions that are not declared in
10436header files. In C, no warnings are issued for functions with previous
10437non-prototype declarations; use @option{-Wmissing-prototypes} to detect
10438missing prototypes. In C++, no warnings are issued for function templates,
10439or for inline functions, or for functions in anonymous namespaces.
10440
d77de738
ML
10441@opindex Wmissing-field-initializers
10442@opindex Wno-missing-field-initializers
10443@opindex W
10444@opindex Wextra
10445@opindex Wno-extra
ddf6fe37 10446@item -Wmissing-field-initializers
d77de738
ML
10447Warn if a structure's initializer has some fields missing. For
10448example, the following code causes such a warning, because
10449@code{x.h} is implicitly zero:
10450
10451@smallexample
10452struct s @{ int f, g, h; @};
10453struct s x = @{ 3, 4 @};
10454@end smallexample
10455
0f8f1dee
MP
10456@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
10457In C this option does not warn about designated initializers, so the
10458following modification does not trigger a warning:
d77de738
ML
10459
10460@smallexample
10461struct s @{ int f, g, h; @};
10462struct s x = @{ .f = 3, .g = 4 @};
10463@end smallexample
10464
10465In C this option does not warn about the universal zero initializer
10466@samp{@{ 0 @}}:
10467
10468@smallexample
10469struct s @{ int f, g, h; @};
10470struct s x = @{ 0 @};
10471@end smallexample
10472
10473Likewise, in C++ this option does not warn about the empty @{ @}
10474initializer, for example:
10475
10476@smallexample
10477struct s @{ int f, g, h; @};
10478s x = @{ @};
10479@end smallexample
10480
10481This warning is included in @option{-Wextra}. To get other @option{-Wextra}
10482warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
10483
d77de738
ML
10484@opindex Wmissing-requires
10485@opindex Wno-missing-requires
ddf6fe37 10486@item -Wno-missing-requires
d77de738
ML
10487
10488By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
10489
10490@smallexample
10491bool satisfied = requires @{ C<T> @};
10492@end smallexample
10493
10494Here @samp{satisfied} will be true if @samp{C<T>} is a valid
10495expression, which it is for all T. Presumably the user meant to write
10496
10497@smallexample
10498bool satisfied = requires @{ requires C<T> @};
10499@end smallexample
10500
10501so @samp{satisfied} is only true if concept @samp{C} is satisfied for
10502type @samp{T}.
10503
10504This warning can be disabled with @option{-Wno-missing-requires}.
10505
d77de738
ML
10506@opindex Wmissing-template-keyword
10507@opindex Wno-missing-template-keyword
ddf6fe37 10508@item -Wno-missing-template-keyword
d77de738
ML
10509
10510The member access tokens ., -> and :: must be followed by the @code{template}
10511keyword if the parent object is dependent and the member being named is a
10512template.
10513
10514@smallexample
10515template <class X>
10516void DoStuff (X x)
10517@{
10518 x.template DoSomeOtherStuff<X>(); // Good.
10519 x.DoMoreStuff<X>(); // Warning, x is dependent.
10520@}
10521@end smallexample
10522
10523In rare cases it is possible to get false positives. To silence this, wrap
10524the expression in parentheses. For example, the following is treated as a
10525template, even where m and N are integers:
10526
10527@smallexample
10528void NotATemplate (my_class t)
10529@{
10530 int N = 5;
10531
10532 bool test = t.m < N > (0); // Treated as a template.
10533 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
10534@}
10535@end smallexample
10536
10537This warning can be disabled with @option{-Wno-missing-template-keyword}.
10538
d77de738
ML
10539@opindex Wno-multichar
10540@opindex Wmultichar
ddf6fe37 10541@item -Wno-multichar
d77de738
ML
10542Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
10543Usually they indicate a typo in the user's code, as they have
10544implementation-defined values, and should not be used in portable code.
10545
d77de738
ML
10546@opindex Wnormalized=
10547@opindex Wnormalized
10548@opindex Wno-normalized
10549@cindex NFC
10550@cindex NFKC
10551@cindex character set, input normalization
f33d7a88 10552@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
10553In ISO C and ISO C++, two identifiers are different if they are
10554different sequences of characters. However, sometimes when characters
10555outside the basic ASCII character set are used, you can have two
10556different character sequences that look the same. To avoid confusion,
10557the ISO 10646 standard sets out some @dfn{normalization rules} which
10558when applied ensure that two sequences that look the same are turned into
10559the same sequence. GCC can warn you if you are using identifiers that
10560have not been normalized; this option controls that warning.
10561
10562There are four levels of warning supported by GCC@. The default is
10563@option{-Wnormalized=nfc}, which warns about any identifier that is
10564not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
10565recommended form for most uses. It is equivalent to
10566@option{-Wnormalized}.
10567
10568Unfortunately, there are some characters allowed in identifiers by
a0e64a04 10569ISO C and ISO C++ that, when turned into NFC, are not allowed in
d77de738
ML
10570identifiers. That is, there's no way to use these symbols in portable
10571ISO C or C++ and have all your identifiers in NFC@.
10572@option{-Wnormalized=id} suppresses the warning for these characters.
10573It is hoped that future versions of the standards involved will correct
10574this, which is why this option is not the default.
10575
10576You can switch the warning off for all characters by writing
10577@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
10578only do this if you are using some other normalization scheme (like
10579``D''), because otherwise you can easily create bugs that are
10580literally impossible to see.
10581
10582Some characters in ISO 10646 have distinct meanings but look identical
10583in some fonts or display methodologies, especially once formatting has
10584been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
10585LETTER N'', displays just like a regular @code{n} that has been
10586placed in a superscript. ISO 10646 defines the @dfn{NFKC}
10587normalization scheme to convert all these into a standard form as
10588well, and GCC warns if your code is not in NFKC if you use
10589@option{-Wnormalized=nfkc}. This warning is comparable to warning
10590about every identifier that contains the letter O because it might be
10591confused with the digit 0, and so is not the default, but may be
a0e64a04 10592useful as a local coding convention if the programming environment
d77de738
ML
10593cannot be fixed to display these characters distinctly.
10594
d77de738
ML
10595@opindex Wno-attribute-warning
10596@opindex Wattribute-warning
ddf6fe37 10597@item -Wno-attribute-warning
d77de738
ML
10598Do not warn about usage of functions (@pxref{Function Attributes})
10599declared with @code{warning} attribute. By default, this warning is
10600enabled. @option{-Wno-attribute-warning} can be used to disable the
10601warning or @option{-Wno-error=attribute-warning} can be used to
10602disable the error when compiled with @option{-Werror} flag.
10603
d77de738
ML
10604@opindex Wno-deprecated
10605@opindex Wdeprecated
ddf6fe37 10606@item -Wno-deprecated
d77de738
ML
10607Do not warn about usage of deprecated features. @xref{Deprecated Features}.
10608
dca2b479
JM
10609In C++, explicitly specifying @option{-Wdeprecated} also enables
10610warnings about some features that are deprecated in later language
10611standards, specifically @option{-Wcomma-subscript},
10612@option{-Wvolatile}, @option{-Wdeprecated-enum-float-conversion},
cc67d95d
JJ
10613@option{-Wdeprecated-enum-enum-conversion},
10614@option{-Wdeprecated-literal-operator}, and
10615@option{-Wdeprecated-variadic-comma-omission}.
dca2b479 10616
d77de738
ML
10617@opindex Wno-deprecated-declarations
10618@opindex Wdeprecated-declarations
ddf6fe37 10619@item -Wno-deprecated-declarations
d77de738
ML
10620Do not warn about uses of functions (@pxref{Function Attributes}),
10621variables (@pxref{Variable Attributes}), and types (@pxref{Type
10622Attributes}) marked as deprecated by using the @code{deprecated}
10623attribute.
10624
d77de738
ML
10625@opindex Wno-overflow
10626@opindex Woverflow
ddf6fe37 10627@item -Wno-overflow
d77de738
ML
10628Do not warn about compile-time overflow in constant expressions.
10629
d77de738
ML
10630@opindex Wno-odr
10631@opindex Wodr
ddf6fe37 10632@item -Wno-odr
d77de738
ML
10633Warn about One Definition Rule violations during link-time optimization.
10634Enabled by default.
10635
d77de738
ML
10636@opindex Wopenacc-parallelism
10637@opindex Wno-openacc-parallelism
10638@cindex OpenACC accelerator programming
f33d7a88 10639@item -Wopenacc-parallelism
d77de738
ML
10640Warn about potentially suboptimal choices related to OpenACC parallelism.
10641
449b6b81
TB
10642@opindex Wopenmp
10643@opindex Wno-openmp
10644@item -Wno-openmp
10645Warn about suspicious OpenMP code.
10646
d77de738
ML
10647@opindex Wopenmp-simd
10648@opindex Wno-openmp-simd
ddf6fe37 10649@item -Wopenmp-simd
d77de738
ML
10650Warn if the vectorizer cost model overrides the OpenMP
10651simd directive set by user. The @option{-fsimd-cost-model=unlimited}
10652option can be used to relax the cost model.
10653
d77de738
ML
10654@opindex Woverride-init
10655@opindex Wno-override-init
10656@opindex W
10657@opindex Wextra
10658@opindex Wno-extra
ddf6fe37 10659@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
10660Warn if an initialized field without side effects is overridden when
10661using designated initializers (@pxref{Designated Inits, , Designated
10662Initializers}).
10663
10664This warning is included in @option{-Wextra}. To get other
10665@option{-Wextra} warnings without this one, use @option{-Wextra
10666-Wno-override-init}.
10667
d77de738
ML
10668@opindex Woverride-init-side-effects
10669@opindex Wno-override-init-side-effects
ddf6fe37 10670@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
10671Do not warn if an initialized field with side effects is overridden when
10672using designated initializers (@pxref{Designated Inits, , Designated
10673Initializers}). This warning is enabled by default.
10674
d77de738
ML
10675@opindex Wpacked
10676@opindex Wno-packed
ddf6fe37 10677@item -Wpacked
d77de738
ML
10678Warn if a structure is given the packed attribute, but the packed
10679attribute has no effect on the layout or size of the structure.
10680Such structures may be mis-aligned for little benefit. For
10681instance, in this code, the variable @code{f.x} in @code{struct bar}
10682is misaligned even though @code{struct bar} does not itself
10683have the packed attribute:
10684
10685@smallexample
10686@group
10687struct foo @{
10688 int x;
10689 char a, b, c, d;
10690@} __attribute__((packed));
10691struct bar @{
10692 char z;
10693 struct foo f;
10694@};
10695@end group
10696@end smallexample
10697
d77de738
ML
10698@opindex Wpacked-bitfield-compat
10699@opindex Wno-packed-bitfield-compat
ddf6fe37 10700@item -Wnopacked-bitfield-compat
d77de738
ML
10701The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
10702on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
10703the change can lead to differences in the structure layout. GCC
10704informs you when the offset of such a field has changed in GCC 4.4.
10705For example there is no longer a 4-bit padding between field @code{a}
10706and @code{b} in this structure:
10707
10708@smallexample
10709struct foo
10710@{
10711 char a:4;
10712 char b:8;
10713@} __attribute__ ((packed));
10714@end smallexample
10715
10716This warning is enabled by default. Use
10717@option{-Wno-packed-bitfield-compat} to disable this warning.
10718
d77de738
ML
10719@opindex Wpacked-not-aligned
10720@opindex Wno-packed-not-aligned
ddf6fe37 10721@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10722Warn if a structure field with explicitly specified alignment in a
10723packed struct or union is misaligned. For example, a warning will
10724be issued on @code{struct S}, like, @code{warning: alignment 1 of
10725'struct S' is less than 8}, in this code:
10726
10727@smallexample
10728@group
10729struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10730struct __attribute__ ((packed)) S @{
10731 struct S8 s8;
10732@};
10733@end group
10734@end smallexample
10735
10736This warning is enabled by @option{-Wall}.
10737
d77de738
ML
10738@opindex Wpadded
10739@opindex Wno-padded
ddf6fe37 10740@item -Wpadded
d77de738
ML
10741Warn if padding is included in a structure, either to align an element
10742of the structure or to align the whole structure. Sometimes when this
10743happens it is possible to rearrange the fields of the structure to
10744reduce the padding and so make the structure smaller.
10745
d77de738
ML
10746@opindex Wredundant-decls
10747@opindex Wno-redundant-decls
ddf6fe37 10748@item -Wredundant-decls
d77de738
ML
10749Warn if anything is declared more than once in the same scope, even in
10750cases where multiple declaration is valid and changes nothing.
10751
d77de738
ML
10752@opindex Wrestrict
10753@opindex Wno-restrict
ddf6fe37 10754@item -Wrestrict
d77de738
ML
10755Warn when an object referenced by a @code{restrict}-qualified parameter
10756(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10757argument, or when copies between such objects overlap. For example,
10758the call to the @code{strcpy} function below attempts to truncate the string
10759by replacing its initial characters with the last four. However, because
10760the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10761the call is diagnosed.
10762
10763@smallexample
10764void foo (void)
10765@{
10766 char a[] = "abcd1234";
10767 strcpy (a, a + 4);
10768 @dots{}
10769@}
10770@end smallexample
10771The @option{-Wrestrict} option detects some instances of simple overlap
10772even without optimization but works best at @option{-O2} and above. It
10773is included in @option{-Wall}.
10774
d77de738
ML
10775@opindex Wnested-externs
10776@opindex Wno-nested-externs
ddf6fe37 10777@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
10778Warn if an @code{extern} declaration is encountered within a function.
10779
d77de738
ML
10780@opindex Winline
10781@opindex Wno-inline
ddf6fe37 10782@item -Winline
d77de738
ML
10783Warn if a function that is declared as inline cannot be inlined.
10784Even with this option, the compiler does not warn about failures to
10785inline functions declared in system headers.
10786
10787The compiler uses a variety of heuristics to determine whether or not
10788to inline a function. For example, the compiler takes into account
10789the size of the function being inlined and the amount of inlining
10790that has already been done in the current function. Therefore,
10791seemingly insignificant changes in the source program can cause the
10792warnings produced by @option{-Winline} to appear or disappear.
10793
d77de738 10794@opindex Winterference-size
ddf6fe37 10795@item -Winterference-size
d77de738
ML
10796Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10797without specifying its value with @option{--param destructive-interference-size}.
10798Also warn about questionable values for that option.
10799
10800This variable is intended to be used for controlling class layout, to
10801avoid false sharing in concurrent code:
10802
10803@smallexample
10804struct independent_fields @{
4ace81b6
SL
10805 alignas(std::hardware_destructive_interference_size)
10806 std::atomic<int> one;
10807 alignas(std::hardware_destructive_interference_size)
10808 std::atomic<int> two;
d77de738
ML
10809@};
10810@end smallexample
10811
10812Here @samp{one} and @samp{two} are intended to be far enough apart
10813that stores to one won't require accesses to the other to reload the
10814cache line.
10815
10816By default, @option{--param destructive-interference-size} and
10817@option{--param constructive-interference-size} are set based on the
10818current @option{-mtune} option, typically to the L1 cache line size
10819for the particular target CPU, sometimes to a range if tuning for a
10820generic target. So all translation units that depend on ABI
10821compatibility for the use of these variables must be compiled with
10822the same @option{-mtune} (or @option{-mcpu}).
10823
10824If ABI stability is important, such as if the use is in a header for a
10825library, you should probably not use the hardware interference size
10826variables at all. Alternatively, you can force a particular value
10827with @option{--param}.
10828
10829If you are confident that your use of the variable does not affect ABI
10830outside a single build of your project, you can turn off the warning
10831with @option{-Wno-interference-size}.
10832
d77de738
ML
10833@opindex Wint-in-bool-context
10834@opindex Wno-int-in-bool-context
ddf6fe37 10835@item -Wint-in-bool-context
d77de738
ML
10836Warn for suspicious use of integer values where boolean values are expected,
10837such as conditional expressions (?:) using non-boolean integer constants in
10838boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10839integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10840for all kinds of multiplications regardless of the data type.
10841This warning is enabled by @option{-Wall}.
10842
d77de738
ML
10843@opindex Wno-int-to-pointer-cast
10844@opindex Wint-to-pointer-cast
ddf6fe37 10845@item -Wno-int-to-pointer-cast
d77de738
ML
10846Suppress warnings from casts to pointer type of an integer of a
10847different size. In C++, casting to a pointer type of smaller size is
10848an error. @option{Wint-to-pointer-cast} is enabled by default.
10849
10850
d77de738
ML
10851@opindex Wno-pointer-to-int-cast
10852@opindex Wpointer-to-int-cast
ddf6fe37 10853@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
10854Suppress warnings from casts from a pointer to an integer type of a
10855different size.
10856
d77de738
ML
10857@opindex Winvalid-pch
10858@opindex Wno-invalid-pch
ddf6fe37 10859@item -Winvalid-pch
d77de738
ML
10860Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10861the search path but cannot be used.
10862
d77de738
ML
10863@opindex Winvalid-utf8
10864@opindex Wno-invalid-utf8
ddf6fe37 10865@item -Winvalid-utf8
d77de738
ML
10866Warn if an invalid UTF-8 character is found.
10867This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10868is used and turned into error with @option{-pedantic-errors}.
10869
d77de738
ML
10870@opindex Wunicode
10871@opindex Wno-unicode
ddf6fe37 10872@item -Wno-unicode
d77de738
ML
10873Don't diagnose invalid forms of delimited or named escape sequences which are
10874treated as separate tokens. @option{Wunicode} is enabled by default.
10875
d77de738
ML
10876@opindex Wlong-long
10877@opindex Wno-long-long
ddf6fe37 10878@item -Wlong-long
d77de738
ML
10879Warn if @code{long long} type is used. This is enabled by either
10880@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10881modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10882
5fccebdb
JM
10883This warning is upgraded to an error by @option{-pedantic-errors}.
10884
d77de738
ML
10885@opindex Wvariadic-macros
10886@opindex Wno-variadic-macros
ddf6fe37 10887@item -Wvariadic-macros
d77de738
ML
10888Warn if variadic macros are used in ISO C90 mode, or if the GNU
10889alternate syntax is used in ISO C99 mode. This is enabled by either
10890@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10891messages, use @option{-Wno-variadic-macros}.
10892
d77de738
ML
10893@opindex Wvarargs
10894@opindex Wno-varargs
ddf6fe37 10895@item -Wno-varargs
d77de738
ML
10896Do not warn upon questionable usage of the macros used to handle variable
10897arguments like @code{va_start}. These warnings are enabled by default.
10898
d77de738
ML
10899@opindex Wvector-operation-performance
10900@opindex Wno-vector-operation-performance
ddf6fe37 10901@item -Wvector-operation-performance
d77de738
ML
10902Warn if vector operation is not implemented via SIMD capabilities of the
10903architecture. Mainly useful for the performance tuning.
10904Vector operation can be implemented @code{piecewise}, which means that the
a0e64a04 10905scalar operation is performed on every vector element;
d77de738
ML
10906@code{in parallel}, which means that the vector operation is implemented
10907using scalars of wider type, which normally is more performance efficient;
10908and @code{as a single scalar}, which means that vector fits into a
10909scalar type.
10910
d77de738
ML
10911@opindex Wvla
10912@opindex Wno-vla
ddf6fe37 10913@item -Wvla
d77de738
ML
10914Warn if a variable-length array is used in the code.
10915@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10916the variable-length array.
10917
5fccebdb
JM
10918This warning is upgraded to an error by @option{-pedantic-errors}.
10919
d77de738
ML
10920@opindex Wvla-larger-than=
10921@opindex Wno-vla-larger-than
ddf6fe37 10922@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10923If this option is used, the compiler warns for declarations of
10924variable-length arrays whose size is either unbounded, or bounded
10925by an argument that allows the array size to exceed @var{byte-size}
10926bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10927works, but with variable-length arrays.
10928
10929Note that GCC may optimize small variable-length arrays of a known
10930value into plain arrays, so this warning may not get triggered for
10931such arrays.
10932
10933@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10934is typically only effective when @option{-ftree-vrp} is active (default
10935for @option{-O2} and above).
10936
10937See also @option{-Walloca-larger-than=@var{byte-size}}.
10938
d77de738 10939@opindex Wno-vla-larger-than
ddf6fe37 10940@item -Wno-vla-larger-than
d77de738
ML
10941Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10942to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10943
d77de738 10944@opindex Wno-vla-parameter
ddf6fe37 10945@item -Wvla-parameter
d77de738
ML
10946Warn about redeclarations of functions involving arguments of Variable
10947Length Array types of inconsistent kinds or forms, and enable the detection
10948of out-of-bounds accesses to such parameters by warnings such as
10949@option{-Warray-bounds}.
10950
10951If the first function declaration uses the VLA form the bound specified
10952in the array is assumed to be the minimum number of elements expected to
10953be provided in calls to the function and the maximum number of elements
10954accessed by it. Failing to provide arguments of sufficient size or
10955accessing more than the maximum number of elements may be diagnosed.
10956
10957For example, the warning triggers for the following redeclarations because
10958the first one allows an array of any size to be passed to @code{f} while
10959the second one specifies that the array argument must have at least @code{n}
10960elements. In addition, calling @code{f} with the associated VLA bound
10961parameter in excess of the actual VLA bound triggers a warning as well.
10962
10963@smallexample
10964void f (int n, int[n]);
4ace81b6
SL
10965// warning: argument 2 previously declared as a VLA
10966void f (int, int[]);
d77de738
ML
10967
10968void g (int n)
10969@{
10970 if (n > 4)
10971 return;
10972 int a[n];
4ace81b6
SL
10973 // warning: access to a by f may be out of bounds
10974 f (sizeof a, a);
d77de738
ML
10975 @dots{}
10976@}
10977
10978@end smallexample
10979
10980@option{-Wvla-parameter} is included in @option{-Wall}. The
10981@option{-Warray-parameter} option triggers warnings for similar problems
10982involving ordinary array arguments.
10983
d77de738
ML
10984@opindex Wvolatile-register-var
10985@opindex Wno-volatile-register-var
ddf6fe37 10986@item -Wvolatile-register-var
d77de738
ML
10987Warn if a register variable is declared volatile. The volatile
10988modifier does not inhibit all optimizations that may eliminate reads
10989and/or writes to register variables. This warning is enabled by
10990@option{-Wall}.
10991
d77de738
ML
10992@opindex Wxor-used-as-pow
10993@opindex Wno-xor-used-as-pow
9a5e8f9d
SL
10994@item -Wno-xor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
10995Disable warnings about uses of @code{^}, the exclusive or operator,
10996where it appears the code meant exponentiation.
10997Specifically, the warning occurs when the
d77de738
ML
10998left-hand side is the decimal constant 2 or 10 and the right-hand side
10999is also a decimal constant.
11000
11001In C and C++, @code{^} means exclusive or, whereas in some other languages
11002(e.g. TeX and some versions of BASIC) it means exponentiation.
11003
9a5e8f9d
SL
11004This warning can be silenced by converting one of the operands to
11005hexadecimal as well as by compiling with @option{-Wno-xor-used-as-pow}.
d77de738 11006
d77de738
ML
11007@opindex Wdisabled-optimization
11008@opindex Wno-disabled-optimization
ddf6fe37 11009@item -Wdisabled-optimization
d77de738
ML
11010Warn if a requested optimization pass is disabled. This warning does
11011not generally indicate that there is anything wrong with your code; it
11012merely indicates that GCC's optimizers are unable to handle the code
11013effectively. Often, the problem is that your code is too big or too
11014complex; GCC refuses to optimize programs when the optimization
11015itself is likely to take inordinate amounts of time.
11016
d77de738
ML
11017@opindex Wpointer-sign
11018@opindex Wno-pointer-sign
ddf6fe37 11019@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
11020Warn for pointer argument passing or assignment with different signedness.
11021This option is only supported for C and Objective-C@. It is implied by
11022@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
11023@option{-Wno-pointer-sign}.
11024
5fccebdb
JM
11025This warning is upgraded to an error by @option{-pedantic-errors}.
11026
d77de738
ML
11027@opindex Wstack-protector
11028@opindex Wno-stack-protector
ddf6fe37 11029@item -Wstack-protector
d77de738
ML
11030This option is only active when @option{-fstack-protector} is active. It
11031warns about functions that are not protected against stack smashing.
11032
d77de738
ML
11033@opindex Woverlength-strings
11034@opindex Wno-overlength-strings
ddf6fe37 11035@item -Woverlength-strings
d77de738
ML
11036Warn about string constants that are longer than the ``minimum
11037maximum'' length specified in the C standard. Modern compilers
11038generally allow string constants that are much longer than the
11039standard's minimum limit, but very portable programs should avoid
11040using longer strings.
11041
11042The limit applies @emph{after} string constant concatenation, and does
11043not count the trailing NUL@. In C90, the limit was 509 characters; in
11044C99, it was raised to 4095. C++98 does not specify a normative
11045minimum maximum, so we do not diagnose overlength strings in C++@.
11046
11047This option is implied by @option{-Wpedantic}, and can be disabled with
11048@option{-Wno-overlength-strings}.
11049
d77de738
ML
11050@opindex Wunsuffixed-float-constants
11051@opindex Wno-unsuffixed-float-constants
ddf6fe37 11052@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
11053
11054Issue a warning for any floating constant that does not have
11055a suffix. When used together with @option{-Wsystem-headers} it
11056warns about such constants in system header files. This can be useful
11057when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
11058from the decimal floating-point extension to C99.
11059
d77de738
ML
11060@opindex Wlto-type-mismatch
11061@opindex Wno-lto-type-mismatch
ddf6fe37 11062@item -Wno-lto-type-mismatch
d77de738
ML
11063
11064During the link-time optimization, do not warn about type mismatches in
11065global declarations from different compilation units.
11066Requires @option{-flto} to be enabled. Enabled by default.
11067
d77de738
ML
11068@opindex Wdesignated-init
11069@opindex Wno-designated-init
ddf6fe37 11070@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
11071Suppress warnings when a positional initializer is used to initialize
11072a structure that has been marked with the @code{designated_init}
11073attribute.
11074
11075@end table
11076
11077@node Static Analyzer Options
11078@section Options That Control Static Analysis
11079
11080@table @gcctabopt
d77de738
ML
11081@opindex analyzer
11082@opindex fanalyzer
11083@opindex fno-analyzer
ddf6fe37 11084@item -fanalyzer
d77de738
ML
11085This option enables an static analysis of program flow which looks
11086for ``interesting'' interprocedural paths through the
11087code, and issues warnings for problems found on them.
11088
11089This analysis is much more expensive than other GCC warnings.
11090
a90316c6
DM
11091In technical terms, it performs coverage-guided symbolic execution of
11092the code being compiled. It is neither sound nor complete: it can
11093have false positives and false negatives. It is a bug-finding tool,
11094rather than a tool for proving program correctness.
11095
11096The analyzer is only suitable for use on C code in this release.
11097
d77de738
ML
11098Enabling this option effectively enables the following warnings:
11099
43b72ede
AA
11100@gccoptlist{
11101-Wanalyzer-allocation-size
11102-Wanalyzer-deref-before-check
11103-Wanalyzer-double-fclose
11104-Wanalyzer-double-free
11105-Wanalyzer-exposure-through-output-file
11106-Wanalyzer-exposure-through-uninit-copy
11107-Wanalyzer-fd-access-mode-mismatch
11108-Wanalyzer-fd-double-close
11109-Wanalyzer-fd-leak
11110-Wanalyzer-fd-phase-mismatch
11111-Wanalyzer-fd-type-mismatch
11112-Wanalyzer-fd-use-after-close
11113-Wanalyzer-fd-use-without-check
11114-Wanalyzer-file-leak
11115-Wanalyzer-free-of-non-heap
11116-Wanalyzer-imprecise-fp-arithmetic
841008d3 11117-Wanalyzer-infinite-loop
43b72ede
AA
11118-Wanalyzer-infinite-recursion
11119-Wanalyzer-jump-through-null
11120-Wanalyzer-malloc-leak
11121-Wanalyzer-mismatching-deallocation
11122-Wanalyzer-null-argument
11123-Wanalyzer-null-dereference
11124-Wanalyzer-out-of-bounds
034d99e8 11125-Wanalyzer-overlapping-buffers
43b72ede
AA
11126-Wanalyzer-possible-null-argument
11127-Wanalyzer-possible-null-dereference
11128-Wanalyzer-putenv-of-auto-var
11129-Wanalyzer-shift-count-negative
11130-Wanalyzer-shift-count-overflow
11131-Wanalyzer-stale-setjmp-buffer
cfaaa8b1
DM
11132-Wanalyzer-tainted-allocation-size
11133-Wanalyzer-tainted-array-index
11134-Wanalyzer-tainted-assertion
11135-Wanalyzer-tainted-divisor
11136-Wanalyzer-tainted-offset
11137-Wanalyzer-tainted-size
7a39e0ca 11138-Wanalyzer-throw-of-unexpected-type
13dcaf1b 11139-Wanalyzer-undefined-behavior-ptrdiff
f65f63c4 11140-Wanalyzer-undefined-behavior-strtok
43b72ede
AA
11141-Wanalyzer-unsafe-call-within-signal-handler
11142-Wanalyzer-use-after-free
11143-Wanalyzer-use-of-pointer-in-stale-stack-frame
11144-Wanalyzer-use-of-uninitialized-value
11145-Wanalyzer-va-arg-type-mismatch
11146-Wanalyzer-va-list-exhausted
11147-Wanalyzer-va-list-leak
11148-Wanalyzer-va-list-use-after-va-end
11149-Wanalyzer-write-to-const
11150-Wanalyzer-write-to-string-literal
d77de738 11151}
d77de738
ML
11152
11153This option is only available if GCC was configured with analyzer
11154support enabled.
11155
08b7462d
DM
11156@opindex Wanalyzer-symbol-too-complex
11157@opindex Wno-analyzer-symbol-too-complex
11158@item -Wanalyzer-symbol-too-complex
11159If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
11160to attempt to track the state of memory, but these can be defeated by
11161sufficiently complicated code.
11162
11163By default, the analysis silently stops tracking values of expressions
11164if they exceed the threshold defined by
11165@option{--param analyzer-max-svalue-depth=@var{value}}, and falls back
11166to an imprecise representation for such expressions.
11167The @option{-Wanalyzer-symbol-too-complex} option warns if this occurs.
11168
d77de738
ML
11169@opindex Wanalyzer-too-complex
11170@opindex Wno-analyzer-too-complex
ddf6fe37 11171@item -Wanalyzer-too-complex
d77de738
ML
11172If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
11173to attempt to explore the control flow and data flow in the program,
11174but these can be defeated by sufficiently complicated code.
11175
11176By default, the analysis silently stops if the code is too
11177complicated for the analyzer to fully explore and it reaches an internal
11178limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
11179
d77de738
ML
11180@opindex Wanalyzer-allocation-size
11181@opindex Wno-analyzer-allocation-size
ddf6fe37 11182@item -Wno-analyzer-allocation-size
4ace81b6
SL
11183This warning requires @option{-fanalyzer}, which enables it;
11184to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
11185
11186This diagnostic warns for paths through the code in which a pointer to
11187a buffer is assigned to point at a buffer with a size that is not a
11188multiple of @code{sizeof (*pointer)}.
11189
11190See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
11191
ce51e843
ML
11192@opindex Wanalyzer-deref-before-check
11193@opindex Wno-analyzer-deref-before-check
ddf6fe37 11194@item -Wno-analyzer-deref-before-check
ce51e843
ML
11195This warning requires @option{-fanalyzer}, which enables it; use
11196@option{-Wno-analyzer-deref-before-check}
11197to disable it.
11198
11199This diagnostic warns for paths through the code in which a pointer
11200is checked for @code{NULL} *after* it has already been
11201dereferenced, suggesting that the pointer could have been NULL.
11202Such cases suggest that the check for NULL is either redundant,
11203or that it needs to be moved to before the pointer is dereferenced.
11204
11205This diagnostic also considers values passed to a function argument
11206marked with @code{__attribute__((nonnull))} as requiring a non-NULL
11207value, and thus will complain if such values are checked for @code{NULL}
11208after returning from such a function call.
11209
11210This diagnostic is unlikely to be reported when any level of optimization
11211is enabled, as GCC's optimization logic will typically consider such
11212checks for NULL as being redundant, and optimize them away before the
11213analyzer "sees" them. Hence optimization should be disabled when
11214attempting to trigger this diagnostic.
11215
d77de738
ML
11216@opindex Wanalyzer-double-fclose
11217@opindex Wno-analyzer-double-fclose
ddf6fe37 11218@item -Wno-analyzer-double-fclose
d77de738
ML
11219This warning requires @option{-fanalyzer}, which enables it; use
11220@option{-Wno-analyzer-double-fclose} to disable it.
11221
11222This diagnostic warns for paths through the code in which a @code{FILE *}
11223can have @code{fclose} called on it more than once.
11224
11225See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
11226
d77de738
ML
11227@opindex Wanalyzer-double-free
11228@opindex Wno-analyzer-double-free
ddf6fe37 11229@item -Wno-analyzer-double-free
d77de738
ML
11230This warning requires @option{-fanalyzer}, which enables it; use
11231@option{-Wno-analyzer-double-free} to disable it.
11232
11233This diagnostic warns for paths through the code in which a pointer
11234can have a deallocator called on it more than once, either @code{free},
11235or a deallocator referenced by attribute @code{malloc}.
11236
11237See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
11238
d77de738
ML
11239@opindex Wanalyzer-exposure-through-output-file
11240@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 11241@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
11242This warning requires @option{-fanalyzer}, which enables it; use
11243@option{-Wno-analyzer-exposure-through-output-file}
11244to disable it.
11245
11246This diagnostic warns for paths through the code in which a
11247security-sensitive value is written to an output file
11248(such as writing a password to a log file).
11249
11250See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
11251
d77de738
ML
11252@opindex Wanalyzer-exposure-through-uninit-copy
11253@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 11254@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
11255This warning requires both @option{-fanalyzer} and the use of a plugin
11256to specify a function that copies across a ``trust boundary''. Use
11257@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
11258
11259This diagnostic warns for ``infoleaks'' - paths through the code in which
11260uninitialized values are copied across a security boundary
11261(such as code within an OS kernel that copies a partially-initialized
11262struct on the stack to user space).
11263
11264See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
11265
d77de738
ML
11266@opindex Wanalyzer-fd-access-mode-mismatch
11267@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 11268@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
11269This warning requires @option{-fanalyzer}, which enables it; use
11270@option{-Wno-analyzer-fd-access-mode-mismatch}
11271to disable it.
11272
11273This diagnostic warns for paths through code in which a
11274@code{read} on a write-only file descriptor is attempted, or vice versa.
11275
11276This diagnostic also warns for code paths in a which a function with attribute
11277@code{fd_arg_read (N)} is called with a file descriptor opened with
11278@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
11279@code{fd_arg_write (N)} is called with a file descriptor opened with
11280@code{O_RDONLY} at referenced argument @var{N}.
11281
d77de738
ML
11282@opindex Wanalyzer-fd-double-close
11283@opindex Wno-analyzer-fd-double-close
ddf6fe37 11284@item -Wno-analyzer-fd-double-close
d77de738
ML
11285This warning requires @option{-fanalyzer}, which enables it; use
11286@option{-Wno-analyzer-fd-double-close}
11287to disable it.
11288
11289This diagnostic warns for paths through code in which a
11290file descriptor can be closed more than once.
11291
11292See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
11293
d77de738
ML
11294@opindex Wanalyzer-fd-leak
11295@opindex Wno-analyzer-fd-leak
ddf6fe37 11296@item -Wno-analyzer-fd-leak
d77de738
ML
11297This warning requires @option{-fanalyzer}, which enables it; use
11298@option{-Wno-analyzer-fd-leak}
11299to disable it.
11300
11301This diagnostic warns for paths through code in which an
11302open file descriptor is leaked.
11303
11304See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
11305
86a90006
DM
11306@opindex Wanalyzer-fd-phase-mismatch
11307@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 11308@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
11309This warning requires @option{-fanalyzer}, which enables it; use
11310@option{-Wno-analyzer-fd-phase-mismatch}
11311to disable it.
11312
11313This diagnostic warns for paths through code in which an operation is
11314attempted in the wrong phase of a file descriptor's lifetime.
11315For example, it will warn on attempts to call @code{accept} on a stream
11316socket that has not yet had @code{listen} successfully called on it.
11317
11318See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
11319
86a90006
DM
11320@opindex Wanalyzer-fd-type-mismatch
11321@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 11322@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
11323This warning requires @option{-fanalyzer}, which enables it; use
11324@option{-Wno-analyzer-fd-type-mismatch}
11325to disable it.
11326
11327This diagnostic warns for paths through code in which an
11328operation is attempted on the wrong type of file descriptor.
11329For example, it will warn on attempts to use socket operations
11330on a file descriptor obtained via @code{open}, or when attempting
11331to use a stream socket operation on a datagram socket.
11332
d77de738
ML
11333@opindex Wanalyzer-fd-use-after-close
11334@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 11335@item -Wno-analyzer-fd-use-after-close
d77de738
ML
11336This warning requires @option{-fanalyzer}, which enables it; use
11337@option{-Wno-analyzer-fd-use-after-close}
11338to disable it.
11339
11340This diagnostic warns for paths through code in which a
11341read or write is called on a closed file descriptor.
11342
11343This diagnostic also warns for paths through code in which
11344a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
11345or @code{fd_arg_write (N)} is called with a closed file descriptor at
11346referenced argument @code{N}.
11347
d77de738
ML
11348@opindex Wanalyzer-fd-use-without-check
11349@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 11350@item -Wno-analyzer-fd-use-without-check
d77de738
ML
11351This warning requires @option{-fanalyzer}, which enables it; use
11352@option{-Wno-analyzer-fd-use-without-check}
11353to disable it.
11354
11355This diagnostic warns for paths through code in which a
11356file descriptor is used without being checked for validity.
11357
11358This diagnostic also warns for paths through code in which
11359a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
11360or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
11361argument @code{N}, without being checked for validity.
11362
d77de738
ML
11363@opindex Wanalyzer-file-leak
11364@opindex Wno-analyzer-file-leak
ddf6fe37 11365@item -Wno-analyzer-file-leak
d77de738
ML
11366This warning requires @option{-fanalyzer}, which enables it; use
11367@option{-Wno-analyzer-file-leak}
11368to disable it.
11369
11370This diagnostic warns for paths through the code in which a
11371@code{<stdio.h>} @code{FILE *} stream object is leaked.
11372
11373See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
11374
d77de738
ML
11375@opindex Wanalyzer-free-of-non-heap
11376@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 11377@item -Wno-analyzer-free-of-non-heap
d77de738
ML
11378This warning requires @option{-fanalyzer}, which enables it; use
11379@option{-Wno-analyzer-free-of-non-heap}
11380to disable it.
11381
11382This diagnostic warns for paths through the code in which @code{free}
11383is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
11384
11385See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
11386
d77de738
ML
11387@opindex Wanalyzer-imprecise-fp-arithmetic
11388@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 11389@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
11390This warning requires @option{-fanalyzer}, which enables it; use
11391@option{-Wno-analyzer-imprecise-fp-arithmetic}
11392to disable it.
11393
11394This diagnostic warns for paths through the code in which floating-point
11395arithmetic is used in locations where precise computation is needed. This
11396diagnostic only warns on use of floating-point operands inside the
11397calculation of an allocation size at the moment.
11398
841008d3
DM
11399@opindex Wanalyzer-infinite-loop
11400@opindex Wno-analyzer-infinite-loop
11401@item -Wno-analyzer-infinite-loop
11402This warning requires @option{-fanalyzer}, which enables it; use
11403@option{-Wno-analyzer-infinite-loop} to disable it.
11404
11405This diagnostics warns for paths through the code which appear to
11406lead to an infinite loop.
11407
11408Specifically, the analyzer will issue this warning when it "sees" a loop
11409in which:
11410@itemize @bullet
11411@item
11412no externally-visible work could be being done within the loop
11413@item
11414there is no way to escape from the loop
11415@item
11416the analyzer is sufficiently confident about the program state
11417throughout the loop to know that the above are true
11418@end itemize
11419
11420One way for this warning to be emitted is when there is an execution
11421path through a loop for which taking the path on one iteration implies
11422that the same path will be taken on all subsequent iterations.
11423
11424For example, consider:
11425
11426@smallexample
11427 while (1)
11428 @{
11429 char opcode = *cpu_state.pc;
11430 switch (opcode)
11431 @{
11432 case OPCODE_FOO:
11433 handle_opcode_foo (&cpu_state);
11434 break;
11435 case OPCODE_BAR:
11436 handle_opcode_bar (&cpu_state);
11437 break;
11438 @}
11439 @}
11440@end smallexample
11441
11442The analyzer will complain for the above case because if @code{opcode}
11443ever matches none of the cases, the @code{switch} will follow the
11444implicit @code{default} case, making the body of the loop be a ``no-op''
11445with @code{cpu_state.pc} unchanged, and thus using the same value of
11446@code{opcode} on all subseqent iterations, leading to an infinite loop.
11447
11448See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}.
11449
ce51e843
ML
11450@opindex Wanalyzer-infinite-recursion
11451@opindex Wno-analyzer-infinite-recursion
ddf6fe37 11452@item -Wno-analyzer-infinite-recursion
ce51e843
ML
11453This warning requires @option{-fanalyzer}, which enables it; use
11454@option{-Wno-analyzer-infinite-recursion} to disable it.
11455
11456This diagnostics warns for paths through the code which appear to
11457lead to infinite recursion.
11458
11459Specifically, when the analyzer "sees" a recursive call, it will compare
11460the state of memory at the entry to the new frame with that at the entry
11461to the previous frame of that function on the stack. The warning is
11462issued if nothing in memory appears to be changing; any changes observed
11463to parameters or globals are assumed to lead to termination of the
11464recursion and thus suppress the warning.
11465
11466This diagnostic is likely to miss cases of infinite recursion that
11467are convered to iteration by the optimizer before the analyzer "sees"
11468them. Hence optimization should be disabled when attempting to trigger
11469this diagnostic.
11470
11471Compare with @option{-Winfinite-recursion}, which provides a similar
11472diagnostic, but is implemented in a different way.
11473
841008d3
DM
11474See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}.
11475
d77de738
ML
11476@opindex Wanalyzer-jump-through-null
11477@opindex Wno-analyzer-jump-through-null
ddf6fe37 11478@item -Wno-analyzer-jump-through-null
d77de738
ML
11479This warning requires @option{-fanalyzer}, which enables it; use
11480@option{-Wno-analyzer-jump-through-null}
11481to disable it.
11482
11483This diagnostic warns for paths through the code in which a @code{NULL}
11484function pointer is called.
11485
d77de738
ML
11486@opindex Wanalyzer-malloc-leak
11487@opindex Wno-analyzer-malloc-leak
ddf6fe37 11488@item -Wno-analyzer-malloc-leak
d77de738
ML
11489This warning requires @option{-fanalyzer}, which enables it; use
11490@option{-Wno-analyzer-malloc-leak}
11491to disable it.
11492
11493This diagnostic warns for paths through the code in which a
11494pointer allocated via an allocator is leaked: either @code{malloc},
11495or a function marked with attribute @code{malloc}.
11496
11497See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
11498
d77de738
ML
11499@opindex Wanalyzer-mismatching-deallocation
11500@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 11501@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
11502This warning requires @option{-fanalyzer}, which enables it; use
11503@option{-Wno-analyzer-mismatching-deallocation}
11504to disable it.
11505
11506This diagnostic warns for paths through the code in which the
11507wrong deallocation function is called on a pointer value, based on
11508which function was used to allocate the pointer value. The diagnostic
11509will warn about mismatches between @code{free}, scalar @code{delete}
11510and vector @code{delete[]}, and those marked as allocator/deallocator
11511pairs using attribute @code{malloc}.
11512
11513See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
11514
d77de738
ML
11515@opindex Wanalyzer-out-of-bounds
11516@opindex Wno-analyzer-out-of-bounds
ddf6fe37 11517@item -Wno-analyzer-out-of-bounds
4ace81b6 11518This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
11519@option{-Wno-analyzer-out-of-bounds} to disable it.
11520
4ace81b6 11521This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
11522definitely read or written out-of-bounds. The diagnostic applies for
11523cases where the analyzer is able to determine a constant offset and for
11524accesses past the end of a buffer, also a constant capacity. Further,
11525the diagnostic does limited checking for accesses past the end when the
11526offset as well as the capacity is symbolic.
11527
11528See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
11529
0e466e97
DM
11530For cases where the analyzer is able, it will emit a text art diagram
11531visualizing the spatial relationship between the memory region that the
11532analyzer predicts would be accessed, versus the range of memory that is
11533valid to access: whether they overlap, are touching, are close or far
11534apart; which one is before or after in memory, the relative sizes
11535involved, the direction of the access (read vs write), and, in some
11536cases, the values of data involved. This diagram can be suppressed
11537using @option{-fdiagnostics-text-art-charset=none}.
11538
034d99e8
DM
11539@opindex Wanalyzer-overlapping-buffers
11540@opindex Wno-analyzer-overlapping-buffers
11541@item -Wno-analyzer-overlapping-buffers
11542This warning requires @option{-fanalyzer}, which enables it; use
11543@option{-Wno-analyzer-overlapping-buffers} to disable it.
11544
11545This diagnostic warns for paths through the code in which overlapping
11546buffers are passed to an API for which the behavior on such buffers
11547is undefined.
11548
11549Specifically, the diagnostic occurs on calls to the following functions
11550@itemize @bullet
11551@item @code{memcpy}
11552@item @code{strcat}
11553@item @code{strcpy}
11554@end itemize
11555for cases where the buffers are known to overlap.
11556
d77de738
ML
11557@opindex Wanalyzer-possible-null-argument
11558@opindex Wno-analyzer-possible-null-argument
ddf6fe37 11559@item -Wno-analyzer-possible-null-argument
d77de738
ML
11560This warning requires @option{-fanalyzer}, which enables it; use
11561@option{-Wno-analyzer-possible-null-argument} to disable it.
11562
11563This diagnostic warns for paths through the code in which a
11564possibly-NULL value is passed to a function argument marked
11565with @code{__attribute__((nonnull))} as requiring a non-NULL
11566value.
11567
11568See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11569
d77de738
ML
11570@opindex Wanalyzer-possible-null-dereference
11571@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 11572@item -Wno-analyzer-possible-null-dereference
d77de738
ML
11573This warning requires @option{-fanalyzer}, which enables it; use
11574@option{-Wno-analyzer-possible-null-dereference} to disable it.
11575
11576This diagnostic warns for paths through the code in which a
11577possibly-NULL value is dereferenced.
11578
11579See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11580
d77de738
ML
11581@opindex Wanalyzer-null-argument
11582@opindex Wno-analyzer-null-argument
ddf6fe37 11583@item -Wno-analyzer-null-argument
d77de738
ML
11584This warning requires @option{-fanalyzer}, which enables it; use
11585@option{-Wno-analyzer-null-argument} to disable it.
11586
11587This diagnostic warns for paths through the code in which a
11588value known to be NULL is passed to a function argument marked
11589with @code{__attribute__((nonnull))} as requiring a non-NULL
11590value.
11591
11592See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11593
d77de738
ML
11594@opindex Wanalyzer-null-dereference
11595@opindex Wno-analyzer-null-dereference
ddf6fe37 11596@item -Wno-analyzer-null-dereference
d77de738
ML
11597This warning requires @option{-fanalyzer}, which enables it; use
11598@option{-Wno-analyzer-null-dereference} to disable it.
11599
11600This diagnostic warns for paths through the code in which a
11601value known to be NULL is dereferenced.
11602
11603See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11604
d77de738
ML
11605@opindex Wanalyzer-putenv-of-auto-var
11606@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 11607@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
11608This warning requires @option{-fanalyzer}, which enables it; use
11609@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
11610
11611This diagnostic warns for paths through the code in which a
11612call to @code{putenv} is passed a pointer to an automatic variable
11613or an on-stack buffer.
11614
11615See @uref{https://wiki.sei.cmu.edu/confluence/x/6NYxBQ, POS34-C. Do not call putenv() with a pointer to an automatic variable as the argument}.
11616
d77de738
ML
11617@opindex Wanalyzer-shift-count-negative
11618@opindex Wno-analyzer-shift-count-negative
ddf6fe37 11619@item -Wno-analyzer-shift-count-negative
d77de738
ML
11620This warning requires @option{-fanalyzer}, which enables it; use
11621@option{-Wno-analyzer-shift-count-negative} to disable it.
11622
11623This diagnostic warns for paths through the code in which a
11624shift is attempted with a negative count. It is analogous to
11625the @option{-Wshift-count-negative} diagnostic implemented in
11626the C/C++ front ends, but is implemented based on analyzing
11627interprocedural paths, rather than merely parsing the syntax tree.
11628However, the analyzer does not prioritize detection of such paths, so
11629false negatives are more likely relative to other warnings.
11630
d77de738
ML
11631@opindex Wanalyzer-shift-count-overflow
11632@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 11633@item -Wno-analyzer-shift-count-overflow
d77de738
ML
11634This warning requires @option{-fanalyzer}, which enables it; use
11635@option{-Wno-analyzer-shift-count-overflow} to disable it.
11636
11637This diagnostic warns for paths through the code in which a
11638shift is attempted with a count greater than or equal to the
11639precision of the operand's type. It is analogous to
11640the @option{-Wshift-count-overflow} diagnostic implemented in
11641the C/C++ front ends, but is implemented based on analyzing
11642interprocedural paths, rather than merely parsing the syntax tree.
11643However, the analyzer does not prioritize detection of such paths, so
11644false negatives are more likely relative to other warnings.
11645
d77de738
ML
11646@opindex Wanalyzer-stale-setjmp-buffer
11647@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 11648@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
11649This warning requires @option{-fanalyzer}, which enables it; use
11650@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
11651
11652This diagnostic warns for paths through the code in which
11653@code{longjmp} is called to rewind to a @code{jmp_buf} relating
11654to a @code{setjmp} call in a function that has returned.
11655
11656When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
11657location, it records the stack frame. The stack frame becomes invalid
11658when the function containing the @code{setjmp} call returns. Attempting
11659to rewind to it via @code{longjmp} would reference a stack frame that
11660no longer exists, and likely lead to a crash (or worse).
11661
d77de738
ML
11662@opindex Wanalyzer-tainted-allocation-size
11663@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 11664@item -Wno-analyzer-tainted-allocation-size
cfaaa8b1 11665This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11666use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
11667
11668This diagnostic warns for paths through the code in which a value
11669that could be under an attacker's control is used as the size
11670of an allocation without being sanitized, so that an attacker could
11671inject an excessively large allocation and potentially cause a denial
11672of service attack.
11673
11674See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
11675
ce51e843
ML
11676@opindex Wanalyzer-tainted-assertion
11677@opindex Wno-analyzer-tainted-assertion
ddf6fe37 11678@item -Wno-analyzer-tainted-assertion
ce51e843 11679
cfaaa8b1 11680This warning requires @option{-fanalyzer} which enables it;
ce51e843
ML
11681use @option{-Wno-analyzer-tainted-assertion} to disable it.
11682
11683This diagnostic warns for paths through the code in which a value
11684that could be under an attacker's control is used as part of a
11685condition without being first sanitized, and that condition guards a
11686call to a function marked with attribute @code{noreturn}
11687(such as the function @code{__builtin_unreachable}). Such functions
11688typically indicate abnormal termination of the program, such as for
11689assertion failure handlers. For example:
11690
11691@smallexample
11692assert (some_tainted_value < SOME_LIMIT);
11693@end smallexample
11694
11695In such cases:
11696
11697@itemize
11698@item
11699when assertion-checking is enabled: an attacker could trigger
11700a denial of service by injecting an assertion failure
11701
11702@item
11703when assertion-checking is disabled, such as by defining @code{NDEBUG},
11704an attacker could inject data that subverts the process, since it
11705presumably violates a precondition that is being assumed by the code.
11706
11707@end itemize
11708
11709Note that when assertion-checking is disabled, the assertions are
11710typically removed by the preprocessor before the analyzer has a chance
11711to "see" them, so this diagnostic can only generate warnings on builds
11712in which assertion-checking is enabled.
11713
11714For the purpose of this warning, any function marked with attribute
11715@code{noreturn} is considered as a possible assertion failure
11716handler, including @code{__builtin_unreachable}. Note that these functions
11717are sometimes removed by the optimizer before the analyzer "sees" them.
11718Hence optimization should be disabled when attempting to trigger this
11719diagnostic.
11720
11721See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
11722
11723The warning can also report problematic constructions such as
11724
11725@smallexample
11726switch (some_tainted_value) @{
11727case 0:
11728 /* [...etc; various valid cases omitted...] */
11729 break;
11730
11731default:
11732 __builtin_unreachable (); /* BUG: attacker can trigger this */
11733@}
11734@end smallexample
11735
11736despite the above not being an assertion failure, strictly speaking.
11737
d77de738
ML
11738@opindex Wanalyzer-tainted-array-index
11739@opindex Wno-analyzer-tainted-array-index
ddf6fe37 11740@item -Wno-analyzer-tainted-array-index
cfaaa8b1 11741This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11742use @option{-Wno-analyzer-tainted-array-index} to disable it.
11743
11744This diagnostic warns for paths through the code in which a value
11745that could be under an attacker's control is used as the index
11746of an array access without being sanitized, so that an attacker
11747could inject an out-of-bounds access.
11748
11749See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11750
d77de738
ML
11751@opindex Wanalyzer-tainted-divisor
11752@opindex Wno-analyzer-tainted-divisor
ddf6fe37 11753@item -Wno-analyzer-tainted-divisor
cfaaa8b1 11754This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11755use @option{-Wno-analyzer-tainted-divisor} to disable it.
11756
11757This diagnostic warns for paths through the code in which a value
11758that could be under an attacker's control is used as the divisor
11759in a division or modulus operation without being sanitized, so that
11760an attacker could inject a division-by-zero.
11761
11762See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
11763
d77de738
ML
11764@opindex Wanalyzer-tainted-offset
11765@opindex Wno-analyzer-tainted-offset
ddf6fe37 11766@item -Wno-analyzer-tainted-offset
cfaaa8b1 11767This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11768use @option{-Wno-analyzer-tainted-offset} to disable it.
11769
11770This diagnostic warns for paths through the code in which a value
11771that could be under an attacker's control is used as a pointer offset
11772without being sanitized, so that an attacker could inject an out-of-bounds
11773access.
11774
11775See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
11776
d77de738
ML
11777@opindex Wanalyzer-tainted-size
11778@opindex Wno-analyzer-tainted-size
ddf6fe37 11779@item -Wno-analyzer-tainted-size
cfaaa8b1 11780This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11781use @option{-Wno-analyzer-tainted-size} to disable it.
11782
11783This diagnostic warns for paths through the code in which a value
11784that could be under an attacker's control is used as the size of
11785an operation such as @code{memset} without being sanitized, so that an
11786attacker could inject an out-of-bounds access.
11787
11788See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11789
7a39e0ca
DM
11790@opindex Wanalyzer-throw-of-unexpected-type
11791@opindex Wno-analyzer-throw-of-unexpected-type
11792@item -Wno-analyzer-throw-of-unexpected-type
11793This warning requires @option{-fanalyzer} which enables it;
11794use @option{-Wno-analyzer-throw-of-unexpected-type} to disable it.
11795Dynamic exception specifications are only available in C++14 and earlier.
11796
11797This diagnostic warns for paths through the code in which a an exception
11798is thrown from a function with a dynamic exception specification where
11799the exception does not comply with the specification.
11800
13dcaf1b
DM
11801@opindex Wanalyzer-undefined-behavior-ptrdiff
11802@opindex Wno-analyzer-undefined-behavior-ptrdiff
11803@item -Wno-analyzer-undefined-behavior-ptrdiff
11804This warning requires @option{-fanalyzer}, which enables it; use
11805@option{-Wno-analyzer-undefined-behavior-ptrdiff} to disable it.
11806
11807This diagnostic warns for paths through the code in which a pointer
11808subtraction occurs where the pointers refer to different chunks of
11809memory. Such code relies on undefined behavior, as pointer subtraction
11810is only defined for cases where both pointers point to within (or just
11811after) the same array.
11812
11813See @uref{https://cwe.mitre.org/data/definitions/469.html, CWE-469: Use of Pointer Subtraction to Determine Size}.
11814
f65f63c4
DM
11815@opindex Wanalyzer-undefined-behavior-strtok
11816@opindex Wno-analyzer-undefined-behavior-strtok
11817@item -Wno-analyzer-undefined-behavior-strtok
11818This warning requires @option{-fanalyzer}, which enables it; use
11819@option{-Wno-analyzer-undefined-behavior-strtok} to disable it.
11820
11821This diagnostic warns for paths through the code in which a
11822call is made to @code{strtok} with undefined behavior.
11823
11824Specifically, passing NULL as the first parameter for the initial
11825call to @code{strtok} within a process has undefined behavior.
11826
d77de738
ML
11827@opindex Wanalyzer-unsafe-call-within-signal-handler
11828@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 11829@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
11830This warning requires @option{-fanalyzer}, which enables it; use
11831@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11832
11833This diagnostic warns for paths through the code in which a
11834function known to be async-signal-unsafe (such as @code{fprintf}) is
11835called from a signal handler.
11836
11837See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11838
d77de738
ML
11839@opindex Wanalyzer-use-after-free
11840@opindex Wno-analyzer-use-after-free
ddf6fe37 11841@item -Wno-analyzer-use-after-free
d77de738
ML
11842This warning requires @option{-fanalyzer}, which enables it; use
11843@option{-Wno-analyzer-use-after-free} to disable it.
11844
11845This diagnostic warns for paths through the code in which a
11846pointer is used after a deallocator is called on it: either @code{free},
11847or a deallocator referenced by attribute @code{malloc}.
11848
11849See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11850
d77de738
ML
11851@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11852@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 11853@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
11854This warning requires @option{-fanalyzer}, which enables it; use
11855@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11856to disable it.
11857
11858This diagnostic warns for paths through the code in which a pointer
11859is dereferenced that points to a variable in a stale stack frame.
11860
d77de738
ML
11861@opindex Wanalyzer-va-arg-type-mismatch
11862@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 11863@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
11864This warning requires @option{-fanalyzer}, which enables it; use
11865@option{-Wno-analyzer-va-arg-type-mismatch}
11866to disable it.
11867
11868This diagnostic warns for interprocedural paths through the code for which
11869the analyzer detects an attempt to use @code{va_arg} to extract a value
11870passed to a variadic call, but uses a type that does not match that of
11871the expression passed to the call.
11872
11873See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11874
d77de738
ML
11875@opindex Wanalyzer-va-list-exhausted
11876@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 11877@item -Wno-analyzer-va-list-exhausted
d77de738
ML
11878This warning requires @option{-fanalyzer}, which enables it; use
11879@option{-Wno-analyzer-va-list-exhausted}
11880to disable it.
11881
11882This diagnostic warns for interprocedural paths through the code for which
11883the analyzer detects an attempt to use @code{va_arg} to access the next
11884value passed to a variadic call, but all of the values in the
11885@code{va_list} have already been consumed.
11886
11887See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11888
d77de738
ML
11889@opindex Wanalyzer-va-list-leak
11890@opindex Wno-analyzer-va-list-leak
ddf6fe37 11891@item -Wno-analyzer-va-list-leak
d77de738
ML
11892This warning requires @option{-fanalyzer}, which enables it; use
11893@option{-Wno-analyzer-va-list-leak}
11894to disable it.
11895
11896This diagnostic warns for interprocedural paths through the code for which
11897the analyzer detects that @code{va_start} or @code{va_copy} has been called
11898on a @code{va_list} without a corresponding call to @code{va_end}.
11899
d77de738
ML
11900@opindex Wanalyzer-va-list-use-after-va-end
11901@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 11902@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
11903This warning requires @option{-fanalyzer}, which enables it; use
11904@option{-Wno-analyzer-va-list-use-after-va-end}
11905to disable it.
11906
11907This diagnostic warns for interprocedural paths through the code for which
11908the analyzer detects an attempt to use a @code{va_list} after
11909@code{va_end} has been called on it.
11910@code{va_list}.
11911
d77de738
ML
11912@opindex Wanalyzer-write-to-const
11913@opindex Wno-analyzer-write-to-const
ddf6fe37 11914@item -Wno-analyzer-write-to-const
d77de738
ML
11915This warning requires @option{-fanalyzer}, which enables it; use
11916@option{-Wno-analyzer-write-to-const}
11917to disable it.
11918
11919This diagnostic warns for paths through the code in which the analyzer
11920detects an attempt to write through a pointer to a @code{const} object.
11921However, the analyzer does not prioritize detection of such paths, so
11922false negatives are more likely relative to other warnings.
11923
d77de738
ML
11924@opindex Wanalyzer-write-to-string-literal
11925@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 11926@item -Wno-analyzer-write-to-string-literal
d77de738
ML
11927This warning requires @option{-fanalyzer}, which enables it; use
11928@option{-Wno-analyzer-write-to-string-literal}
11929to disable it.
11930
11931This diagnostic warns for paths through the code in which the analyzer
11932detects an attempt to write through a pointer to a string literal.
11933However, the analyzer does not prioritize detection of such paths, so
11934false negatives are more likely relative to other warnings.
11935
d77de738
ML
11936@opindex Wanalyzer-use-of-uninitialized-value
11937@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 11938@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
11939This warning requires @option{-fanalyzer}, which enables it; use
11940@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11941
11942This diagnostic warns for paths through the code in which an uninitialized
11943value is used.
11944
11945See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11946
11947@end table
11948
11949The analyzer has hardcoded knowledge about the behavior of the following
11950memory-management functions:
11951
11952@itemize @bullet
11953@item @code{alloca}
11954@item The built-in functions @code{__builtin_alloc},
11955@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11956@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11957@code{__builtin_memcpy_chk}, @code{__builtin_memset},
11958@code{__builtin_memset_chk}, @code{__builtin_realloc},
11959@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11960@item @code{calloc}
11961@item @code{free}
11962@item @code{malloc}
11963@item @code{memset}
11964@item @code{operator delete}
11965@item @code{operator delete []}
11966@item @code{operator new}
11967@item @code{operator new []}
11968@item @code{realloc}
11969@item @code{strdup}
11970@item @code{strndup}
11971@end itemize
11972
4ace81b6 11973@noindent
d77de738
ML
11974of the following functions for working with file descriptors:
11975
11976@itemize @bullet
11977@item @code{open}
11978@item @code{close}
11979@item @code{creat}
11980@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 11981@item @code{isatty}
d77de738
ML
11982@item @code{pipe}, and @code{pipe2}
11983@item @code{read}
11984@item @code{write}
86a90006 11985@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
11986@end itemize
11987
4ace81b6 11988@noindent
d77de738
ML
11989of the following functions for working with @code{<stdio.h>} streams:
11990@itemize @bullet
11991@item The built-in functions @code{__builtin_fprintf},
11992@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11993@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11994@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11995@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11996@code{__builtin_printf_unlocked}, @code{__builtin_putc},
11997@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11998@code{__builtin_putc_unlocked}, @code{__builtin_puts},
11999@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
12000@code{__builtin_vprintf}
12001@item @code{fopen}
12002@item @code{fclose}
78a17f44 12003@item @code{ferror}
d77de738
ML
12004@item @code{fgets}
12005@item @code{fgets_unlocked}
78a17f44 12006@item @code{fileno}
d77de738 12007@item @code{fread}
78a17f44 12008@item @code{getc}
d77de738
ML
12009@item @code{getchar}
12010@item @code{fprintf}
12011@item @code{printf}
12012@item @code{fwrite}
12013@end itemize
12014
4ace81b6 12015@noindent
d77de738
ML
12016and of the following functions:
12017
12018@itemize @bullet
12019@item The built-in functions @code{__builtin_expect},
12020@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
12021@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
12022@code{__builtin_strlen}, @code{__builtin_va_copy}, and
12023@code{__builtin_va_start}
12024@item The GNU extensions @code{error} and @code{error_at_line}
12025@item @code{getpass}
12026@item @code{longjmp}
12027@item @code{putenv}
12028@item @code{setjmp}
12029@item @code{siglongjmp}
12030@item @code{signal}
12031@item @code{sigsetjmp}
bbdc0e0d 12032@item @code{strcat}
d77de738
ML
12033@item @code{strchr}
12034@item @code{strlen}
12035@end itemize
12036
12037In addition, various functions with an @code{__analyzer_} prefix have
12038special meaning to the analyzer, described in the GCC Internals manual.
12039
12040Pertinent parameters for controlling the exploration are:
4ace81b6
SL
12041@itemize @bullet
12042@item @option{--param analyzer-bb-explosion-factor=@var{value}}
12043@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
12044@item @option{--param analyzer-max-recursion-depth=@var{value}}
12045@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
12046@end itemize
d77de738
ML
12047
12048The following options control the analyzer.
12049
12050@table @gcctabopt
12051
d77de738
ML
12052@opindex fanalyzer-call-summaries
12053@opindex fno-analyzer-call-summaries
ddf6fe37 12054@item -fanalyzer-call-summaries
d77de738
ML
12055Simplify interprocedural analysis by computing the effect of certain calls,
12056rather than exploring all paths through the function from callsite to each
12057possible return.
12058
12059If enabled, call summaries are only used for functions with more than one
12060call site, and that are sufficiently complicated (as per
12061@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
12062
d77de738 12063@opindex fanalyzer-checker
ddf6fe37 12064@item -fanalyzer-checker=@var{name}
d77de738
ML
12065Restrict the analyzer to run just the named checker, and enable it.
12066
0e466e97
DM
12067@opindex fanalyzer-debug-text-art
12068@opindex fno-analyzer-debug-text-art
12069@item -fanalyzer-debug-text-art-headings
12070This option is intended for analyzer developers. If enabled,
12071the analyzer will add extra annotations to any diagrams it generates.
12072
d77de738
ML
12073@opindex fanalyzer-feasibility
12074@opindex fno-analyzer-feasibility
ddf6fe37 12075@item -fno-analyzer-feasibility
d77de738
ML
12076This option is intended for analyzer developers.
12077
12078By default the analyzer verifies that there is a feasible control flow path
12079for each diagnostic it emits: that the conditions that hold are not mutually
12080exclusive. Diagnostics for which no feasible path can be found are rejected.
12081This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
12082debugging issues in this code.
12083
d77de738
ML
12084@opindex fanalyzer-fine-grained
12085@opindex fno-analyzer-fine-grained
ddf6fe37 12086@item -fanalyzer-fine-grained
d77de738
ML
12087This option is intended for analyzer developers.
12088
12089Internally the analyzer builds an ``exploded graph'' that combines
12090control flow graphs with data flow information.
12091
12092By default, an edge in this graph can contain the effects of a run
12093of multiple statements within a basic block. With
12094@option{-fanalyzer-fine-grained}, each statement gets its own edge.
12095
d77de738
ML
12096@opindex fanalyzer-show-duplicate-count
12097@opindex fno-analyzer-show-duplicate-count
ddf6fe37 12098@item -fanalyzer-show-duplicate-count
d77de738
ML
12099This option is intended for analyzer developers: if multiple diagnostics
12100have been detected as being duplicates of each other, it emits a note when
12101reporting the best diagnostic, giving the number of additional diagnostics
12102that were suppressed by the deduplication logic.
12103
ce8cdf5b 12104@opindex fanalyzer-show-events-in-system-headers
12105@opindex fno-analyzer-show-events-in-system-headers
12106@item -fanalyzer-show-events-in-system-headers
12107By default the analyzer emits simplified diagnostics paths by hiding
12108events fully located within a system header.
12109With @option{-fanalyzer-show-events-in-system-headers} such
12110events are no longer suppressed.
12111
d77de738
ML
12112@opindex fanalyzer-state-merge
12113@opindex fno-analyzer-state-merge
ddf6fe37 12114@item -fno-analyzer-state-merge
d77de738
ML
12115This option is intended for analyzer developers.
12116
12117By default the analyzer attempts to simplify analysis by merging
12118sufficiently similar states at each program point as it builds its
12119``exploded graph''. With @option{-fno-analyzer-state-merge} this
12120merging can be suppressed, for debugging state-handling issues.
12121
d77de738
ML
12122@opindex fanalyzer-state-purge
12123@opindex fno-analyzer-state-purge
ddf6fe37 12124@item -fno-analyzer-state-purge
d77de738
ML
12125This option is intended for analyzer developers.
12126
12127By default the analyzer attempts to simplify analysis by purging
12128aspects of state at a program point that appear to no longer be relevant
12129e.g. the values of locals that aren't accessed later in the function
12130and which aren't relevant to leak analysis.
12131
12132With @option{-fno-analyzer-state-purge} this purging of state can
12133be suppressed, for debugging state-handling issues.
12134
8f636915
DM
12135@opindex fanalyzer-suppress-followups
12136@opindex fno-analyzer-suppress-followups
f33d7a88 12137@item -fno-analyzer-suppress-followups
8f636915
DM
12138This option is intended for analyzer developers.
12139
12140By default the analyzer will stop exploring an execution path after
12141encountering certain diagnostics, in order to avoid potentially issuing a
12142cascade of follow-up diagnostics.
12143
12144The diagnostics that terminate analysis along a path are:
12145
12146@itemize
12147@item @option{-Wanalyzer-null-argument}
12148@item @option{-Wanalyzer-null-dereference}
12149@item @option{-Wanalyzer-use-after-free}
12150@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
12151@item @option{-Wanalyzer-use-of-uninitialized-value}
12152@end itemize
12153
12154With @option{-fno-analyzer-suppress-followups} the analyzer will
12155continue to explore such paths even after such diagnostics, which may
12156be helpful for debugging issues in the analyzer, or for microbenchmarks
12157for detecting undefined behavior.
12158
d77de738
ML
12159@opindex fanalyzer-transitivity
12160@opindex fno-analyzer-transitivity
ddf6fe37 12161@item -fanalyzer-transitivity
d77de738
ML
12162This option enables transitivity of constraints within the analyzer.
12163
d77de738
ML
12164@opindex fanalyzer-undo-inlining
12165@opindex fno-analyzer-undo-inlining
ddf6fe37 12166@item -fno-analyzer-undo-inlining
d77de738
ML
12167This option is intended for analyzer developers.
12168
12169@option{-fanalyzer} runs relatively late compared to other code analysis
12170tools, and some optimizations have already been applied to the code. In
12171particular function inlining may have occurred, leading to the
12172interprocedural execution paths emitted by the analyzer containing
12173function frames that don't correspond to those in the original source
12174code.
12175
12176By default the analyzer attempts to reconstruct the original function
12177frames, and to emit events showing the inlined calls.
12178
12179With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
64aa48ce 12180the original frame information can be disabled, which may be of help
d77de738
ML
12181when debugging issues in the analyzer.
12182
12183@item -fanalyzer-verbose-edges
12184This option is intended for analyzer developers. It enables more
12185verbose, lower-level detail in the descriptions of control flow
12186within diagnostic paths.
12187
12188@item -fanalyzer-verbose-state-changes
12189This option is intended for analyzer developers. It enables more
12190verbose, lower-level detail in the descriptions of events relating
12191to state machines within diagnostic paths.
12192
12193@item -fanalyzer-verbosity=@var{level}
12194This option controls the complexity of the control flow paths that are
12195emitted for analyzer diagnostics.
12196
12197The @var{level} can be one of:
12198
12199@table @samp
12200@item 0
12201At this level, interprocedural call and return events are displayed,
12202along with the most pertinent state-change events relating to
12203a diagnostic. For example, for a double-@code{free} diagnostic,
12204both calls to @code{free} will be shown.
12205
12206@item 1
12207As per the previous level, but also show events for the entry
12208to each function.
12209
12210@item 2
12211As per the previous level, but also show events relating to
12212control flow that are significant to triggering the issue
12213(e.g. ``true path taken'' at a conditional).
12214
12215This level is the default.
12216
12217@item 3
12218As per the previous level, but show all control flow events, not
12219just significant ones.
12220
12221@item 4
12222This level is intended for analyzer developers; it adds various
12223other events intended for debugging the analyzer.
12224
12225@end table
12226
d77de738 12227@opindex fdump-analyzer
ddf6fe37 12228@item -fdump-analyzer
d77de738
ML
12229Dump internal details about what the analyzer is doing to
12230@file{@var{file}.analyzer.txt}.
4ace81b6 12231@option{-fdump-analyzer-stderr} overrides this option.
d77de738 12232
d77de738 12233@opindex fdump-analyzer-stderr
ddf6fe37 12234@item -fdump-analyzer-stderr
d77de738
ML
12235Dump internal details about what the analyzer is doing to stderr.
12236This option overrides @option{-fdump-analyzer}.
12237
d77de738 12238@opindex fdump-analyzer-callgraph
ddf6fe37 12239@item -fdump-analyzer-callgraph
d77de738
ML
12240Dump a representation of the call graph suitable for viewing with
12241GraphViz to @file{@var{file}.callgraph.dot}.
12242
d77de738 12243@opindex fdump-analyzer-exploded-graph
ddf6fe37 12244@item -fdump-analyzer-exploded-graph
d77de738
ML
12245Dump a representation of the ``exploded graph'' suitable for viewing with
12246GraphViz to @file{@var{file}.eg.dot}.
12247Nodes are color-coded based on state-machine states to emphasize
12248state changes.
12249
d77de738 12250@opindex dump-analyzer-exploded-nodes
ddf6fe37 12251@item -fdump-analyzer-exploded-nodes
d77de738
ML
12252Emit diagnostics showing where nodes in the ``exploded graph'' are
12253in relation to the program source.
12254
d77de738 12255@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 12256@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
12257Dump a textual representation of the ``exploded graph'' to
12258@file{@var{file}.eg.txt}.
12259
d77de738 12260@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 12261@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
12262Dump a textual representation of the ``exploded graph'' to
12263one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
12264This is typically a large number of dump files.
12265
d77de738 12266@opindex fdump-analyzer-exploded-paths
ddf6fe37 12267@item -fdump-analyzer-exploded-paths
d77de738
ML
12268Dump a textual representation of the ``exploded path'' for each
12269diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
12270
d77de738 12271@opindex dump-analyzer-feasibility
ddf6fe37 12272@item -fdump-analyzer-feasibility
d77de738
ML
12273Dump internal details about the analyzer's search for feasible paths.
12274The details are written in a form suitable for viewing with GraphViz
12275to filenames of the form @file{@var{file}.*.fg.dot},
12276@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
12277
841008d3
DM
12278@opindex dump-analyzer-infinite-loop
12279@item -fdump-analyzer-infinite-loop
12280Dump internal details about the analyzer's search for infinite loops.
12281The details are written in a form suitable for viewing with GraphViz
12282to filenames of the form @file{@var{file}.*.infinite-loop.dot}.
12283
d77de738 12284@opindex fdump-analyzer-json
ddf6fe37 12285@item -fdump-analyzer-json
d77de738
ML
12286Dump a compressed JSON representation of analyzer internals to
12287@file{@var{file}.analyzer.json.gz}. The precise format is subject
12288to change.
12289
d77de738 12290@opindex fdump-analyzer-state-purge
ddf6fe37 12291@item -fdump-analyzer-state-purge
d77de738
ML
12292As per @option{-fdump-analyzer-supergraph}, dump a representation of the
12293``supergraph'' suitable for viewing with GraphViz, but annotate the
12294graph with information on what state will be purged at each node.
12295The graph is written to @file{@var{file}.state-purge.dot}.
12296
d77de738 12297@opindex fdump-analyzer-supergraph
ddf6fe37 12298@item -fdump-analyzer-supergraph
d77de738
ML
12299Dump representations of the ``supergraph'' suitable for viewing with
12300GraphViz to @file{@var{file}.supergraph.dot} and to
12301@file{@var{file}.supergraph-eg.dot}. These show all of the
12302control flow graphs in the program, with interprocedural edges for
12303calls and returns. The second dump contains annotations showing nodes
12304in the ``exploded graph'' and diagnostics associated with them.
12305
d77de738 12306@opindex fdump-analyzer-untracked
ddf6fe37 12307@item -fdump-analyzer-untracked
d77de738
ML
12308Emit custom warnings with internal details intended for analyzer developers.
12309
12310@end table
12311
12312@node Debugging Options
12313@section Options for Debugging Your Program
12314@cindex options, debugging
12315@cindex debugging information options
12316
a0e64a04 12317To tell GCC to emit extra information for use by a debugger, in almost
d77de738
ML
12318all cases you need only to add @option{-g} to your other options. Some debug
12319formats can co-exist (like DWARF with CTF) when each of them is enabled
12320explicitly by adding the respective command line option to your other options.
12321
12322GCC allows you to use @option{-g} with
12323@option{-O}. The shortcuts taken by optimized code may occasionally
12324be surprising: some variables you declared may not exist
12325at all; flow of control may briefly move where you did not expect it;
12326some statements may not be executed because they compute constant
12327results or their values are already at hand; some statements may
12328execute in different places because they have been moved out of loops.
12329Nevertheless it is possible to debug optimized output. This makes
12330it reasonable to use the optimizer for programs that might have bugs.
12331
12332If you are not using some other optimization option, consider
a0e64a04 12333using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
d77de738
ML
12334With no @option{-O} option at all, some compiler passes that collect
12335information useful for debugging do not run at all, so that
12336@option{-Og} may result in a better debugging experience.
12337
12338@table @gcctabopt
d77de738 12339@opindex g
ddf6fe37 12340@item -g
d77de738
ML
12341Produce debugging information in the operating system's native format
12342(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
12343information.
12344
12345On most systems that use stabs format, @option{-g} enables use of extra
12346debugging information that only GDB can use; this extra information
12347makes debugging work better in GDB but probably makes other debuggers
12348crash or refuse to read the program. If you want to control for certain whether
12349to generate the extra information, use @option{-gvms} (see below).
12350
d77de738 12351@opindex ggdb
ddf6fe37 12352@item -ggdb
d77de738
ML
12353Produce debugging information for use by GDB@. This means to use the
12354most expressive format available (DWARF, stabs, or the native format
12355if neither of those are supported), including GDB extensions if at all
12356possible.
12357
ddf6fe37 12358@opindex gdwarf
d77de738
ML
12359@item -gdwarf
12360@itemx -gdwarf-@var{version}
d77de738
ML
12361Produce debugging information in DWARF format (if that is supported).
12362The value of @var{version} may be either 2, 3, 4 or 5; the default
12363version for most targets is 5 (with the exception of VxWorks, TPF and
a335cf24 12364Darwin / macOS, which default to version 2, and AIX, which defaults
d77de738
ML
12365to version 4).
12366
12367Note that with DWARF Version 2, some ports require and always
12368use some non-conflicting DWARF 3 extensions in the unwind tables.
12369
12370Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
12371for maximum benefit. Version 5 requires GDB 8.0 or higher.
12372
12373GCC no longer supports DWARF Version 1, which is substantially
12374different than Version 2 and later. For historical reasons, some
12375other DWARF-related options such as
12376@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
12377in their names, but apply to all currently-supported versions of DWARF.
12378
d77de738 12379@opindex gbtf
ddf6fe37 12380@item -gbtf
d77de738
ML
12381Request BTF debug information. BTF is the default debugging format for the
12382eBPF target. On other targets, like x86, BTF debug information can be
12383generated along with DWARF debug information when both of the debug formats are
12384enabled explicitly via their respective command line options.
12385
b8977d92
DF
12386@opindex gprune-btf
12387@opindex gno-prune-btf
12388@item -gprune-btf
12389@itemx -gno-prune-btf
12390Prune BTF information before emission. When pruning, only type
12391information for types used by global variables and file-scope functions
12392will be emitted. If compiling for the BPF target with BPF CO-RE
12393enabled, type information will also be emitted for types used in BPF
12394CO-RE relocations. In addition, struct and union types which are only
12395referred to via pointers from members of other struct or union types
12396shall be pruned and replaced with BTF_KIND_FWD, as though those types
12397were only present in the input as forward declarations.
12398
12399This option substantially reduces the size of produced BTF information,
12400but at significant loss in the amount of detailed type information.
12401It is primarily useful when compiling for the BPF target, to minimize
12402the size of the resulting object, and to eliminate BTF information
12403which is not immediately relevant to the BPF program loading process.
12404
189d0f1f
DF
12405This option is enabled by default for the BPF target when generating
12406BTF information.
12407
ddf6fe37 12408@opindex gctf
d77de738
ML
12409@item -gctf
12410@itemx -gctf@var{level}
d77de738
ML
12411Request CTF debug information and use level to specify how much CTF debug
12412information should be produced. If @option{-gctf} is specified
12413without a value for level, the default level of CTF debug information is 2.
12414
12415CTF debug information can be generated along with DWARF debug information when
12416both of the debug formats are enabled explicitly via their respective command
12417line options.
12418
12419Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
12420negates @option{-gctf}.
12421
12422Level 1 produces CTF information for tracebacks only. This includes callsite
12423information, but does not include type information.
12424
12425Level 2 produces type information for entities (functions, data objects etc.)
12426at file-scope or global-scope only.
12427
d77de738 12428@opindex gvms
ddf6fe37 12429@item -gvms
d77de738
ML
12430Produce debugging information in Alpha/VMS debug format (if that is
12431supported). This is the format used by DEBUG on Alpha/VMS systems.
12432
2f7e7bfa
MH
12433@item -gcodeview
12434@opindex gcodeview
12435Produce debugging information in CodeView debug format (if that is
12436supported). This is the format used by Microsoft Visual C++ on
12437Windows.
12438
d77de738
ML
12439@item -g@var{level}
12440@itemx -ggdb@var{level}
12441@itemx -gvms@var{level}
12442Request debugging information and also use @var{level} to specify how
12443much information. The default level is 2.
12444
12445Level 0 produces no debug information at all. Thus, @option{-g0} negates
12446@option{-g}.
12447
12448Level 1 produces minimal information, enough for making backtraces in
12449parts of the program that you don't plan to debug. This includes
12450descriptions of functions and external variables, and line number
12451tables, but no information about local variables.
12452
12453Level 3 includes extra information, such as all the macro definitions
12454present in the program. Some debuggers support macro expansion when
12455you use @option{-g3}.
12456
12457If you use multiple @option{-g} options, with or without level numbers,
12458the last such option is the one that is effective.
12459
12460@option{-gdwarf} does not accept a concatenated debug level, to avoid
12461confusion with @option{-gdwarf-@var{level}}.
12462Instead use an additional @option{-g@var{level}} option to change the
12463debug level for DWARF.
12464
d77de738
ML
12465@opindex feliminate-unused-debug-symbols
12466@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 12467@item -fno-eliminate-unused-debug-symbols
d77de738
ML
12468By default, no debug information is produced for symbols that are not actually
12469used. Use this option if you want debug information for all symbols.
12470
d77de738 12471@opindex femit-class-debug-always
ddf6fe37 12472@item -femit-class-debug-always
d77de738
ML
12473Instead of emitting debugging information for a C++ class in only one
12474object file, emit it in all object files using the class. This option
12475should be used only with debuggers that are unable to handle the way GCC
12476normally emits debugging information for classes because using this
12477option increases the size of debugging information by as much as a
12478factor of two.
12479
d77de738
ML
12480@opindex fmerge-debug-strings
12481@opindex fno-merge-debug-strings
ddf6fe37 12482@item -fno-merge-debug-strings
d77de738
ML
12483Direct the linker to not merge together strings in the debugging
12484information that are identical in different object files. Merging is
12485not supported by all assemblers or linkers. Merging decreases the size
12486of the debug information in the output file at the cost of increasing
12487link processing time. Merging is enabled by default.
12488
d77de738 12489@opindex fdebug-prefix-map
ddf6fe37 12490@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
12491When compiling files residing in directory @file{@var{old}}, record
12492debugging information describing them as if the files resided in
12493directory @file{@var{new}} instead. This can be used to replace a
12494build-time path with an install-time path in the debug info. It can
12495also be used to change an absolute path to a relative path by using
12496@file{.} for @var{new}. This can give more reproducible builds, which
12497are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
12498where to find the source files. See also @option{-ffile-prefix-map}
12499and @option{-fcanon-prefix-map}.
d77de738 12500
d77de738 12501@opindex fvar-tracking
ddf6fe37 12502@item -fvar-tracking
d77de738
ML
12503Run variable tracking pass. It computes where variables are stored at each
12504position in code. Better debugging information is then generated
12505(if the debugging information format supports this information).
12506
12507It is enabled by default when compiling with optimization (@option{-Os},
12508@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
12509the debug info format supports it.
12510
d77de738
ML
12511@opindex fvar-tracking-assignments
12512@opindex fno-var-tracking-assignments
ddf6fe37 12513@item -fvar-tracking-assignments
d77de738
ML
12514Annotate assignments to user variables early in the compilation and
12515attempt to carry the annotations over throughout the compilation all the
12516way to the end, in an attempt to improve debug information while
12517optimizing. Use of @option{-gdwarf-4} is recommended along with it.
12518
12519It can be enabled even if var-tracking is disabled, in which case
12520annotations are created and maintained, but discarded at the end.
12521By default, this flag is enabled together with @option{-fvar-tracking},
12522except when selective scheduling is enabled.
12523
d77de738 12524@opindex gsplit-dwarf
ddf6fe37 12525@item -gsplit-dwarf
d77de738
ML
12526If DWARF debugging information is enabled, separate as much debugging
12527information as possible into a separate output file with the extension
12528@file{.dwo}. This option allows the build system to avoid linking files with
12529debug information. To be useful, this option requires a debugger capable of
12530reading @file{.dwo} files.
12531
d77de738
ML
12532@opindex gdwarf32
12533@opindex gdwarf64
ddf6fe37
AA
12534@item -gdwarf32
12535@itemx -gdwarf64
d77de738
ML
12536If DWARF debugging information is enabled, the @option{-gdwarf32} selects
12537the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
12538DWARF format. The default is target specific, on most targets it is
12539@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
12540can't support more than 2GiB of debug information in any of the DWARF
12541debug information sections. The 64-bit DWARF format allows larger debug
12542information and might not be well supported by all consumers yet.
12543
d77de738 12544@opindex gdescribe-dies
ddf6fe37 12545@item -gdescribe-dies
d77de738
ML
12546Add description attributes to some DWARF DIEs that have no name attribute,
12547such as artificial variables, external references and call site
12548parameter DIEs.
12549
d77de738 12550@opindex gpubnames
ddf6fe37 12551@item -gpubnames
d77de738
ML
12552Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
12553
d77de738 12554@opindex ggnu-pubnames
ddf6fe37 12555@item -ggnu-pubnames
d77de738
ML
12556Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
12557suitable for conversion into a GDB@ index. This option is only useful
12558with a linker that can produce GDB@ index version 7.
12559
d77de738
ML
12560@opindex fdebug-types-section
12561@opindex fno-debug-types-section
ddf6fe37 12562@item -fdebug-types-section
d77de738
ML
12563When using DWARF Version 4 or higher, type DIEs can be put into
12564their own @code{.debug_types} section instead of making them part of the
12565@code{.debug_info} section. It is more efficient to put them in a separate
12566comdat section since the linker can then remove duplicates.
12567But not all DWARF consumers support @code{.debug_types} sections yet
12568and on some objects @code{.debug_types} produces larger instead of smaller
12569debugging information.
12570
d77de738
ML
12571@opindex grecord-gcc-switches
12572@opindex gno-record-gcc-switches
ddf6fe37
AA
12573@item -grecord-gcc-switches
12574@itemx -gno-record-gcc-switches
d77de738
ML
12575This switch causes the command-line options used to invoke the
12576compiler that may affect code generation to be appended to the
12577DW_AT_producer attribute in DWARF debugging information. The options
12578are concatenated with spaces separating them from each other and from
a0e64a04 12579the compiler version.
d77de738
ML
12580It is enabled by default.
12581See also @option{-frecord-gcc-switches} for another
a0e64a04 12582way of storing compiler options into the object file.
d77de738 12583
d77de738 12584@opindex gstrict-dwarf
ddf6fe37 12585@item -gstrict-dwarf
d77de738
ML
12586Disallow using extensions of later DWARF standard version than selected
12587with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
12588DWARF extensions from later standard versions is allowed.
12589
d77de738 12590@opindex gno-strict-dwarf
ddf6fe37 12591@item -gno-strict-dwarf
d77de738
ML
12592Allow using extensions of later DWARF standard version than selected with
12593@option{-gdwarf-@var{version}}.
12594
d77de738 12595@opindex gas-loc-support
ddf6fe37 12596@item -gas-loc-support
d77de738
ML
12597Inform the compiler that the assembler supports @code{.loc} directives.
12598It may then use them for the assembler to generate DWARF2+ line number
12599tables.
12600
12601This is generally desirable, because assembler-generated line-number
12602tables are a lot more compact than those the compiler can generate
12603itself.
12604
12605This option will be enabled by default if, at GCC configure time, the
12606assembler was found to support such directives.
12607
d77de738 12608@opindex gno-as-loc-support
ddf6fe37 12609@item -gno-as-loc-support
d77de738
ML
12610Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
12611line number tables are to be generated.
12612
d77de738 12613@opindex gas-locview-support
ddf6fe37 12614@item -gas-locview-support
d77de738
ML
12615Inform the compiler that the assembler supports @code{view} assignment
12616and reset assertion checking in @code{.loc} directives.
12617
12618This option will be enabled by default if, at GCC configure time, the
12619assembler was found to support them.
12620
12621@item -gno-as-locview-support
12622Force GCC to assign view numbers internally, if
12623@option{-gvariable-location-views} are explicitly requested.
12624
d77de738
ML
12625@opindex gcolumn-info
12626@opindex gno-column-info
ddf6fe37
AA
12627@item -gcolumn-info
12628@itemx -gno-column-info
d77de738
ML
12629Emit location column information into DWARF debugging information, rather
12630than just file and line.
12631This option is enabled by default.
12632
d77de738
ML
12633@opindex gstatement-frontiers
12634@opindex gno-statement-frontiers
ddf6fe37
AA
12635@item -gstatement-frontiers
12636@itemx -gno-statement-frontiers
d77de738
ML
12637This option causes GCC to create markers in the internal representation
12638at the beginning of statements, and to keep them roughly in place
12639throughout compilation, using them to guide the output of @code{is_stmt}
12640markers in the line number table. This is enabled by default when
12641compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
12642@dots{}), and outputting DWARF 2 debug information at the normal level.
12643
d77de738
ML
12644@opindex gvariable-location-views
12645@opindex gvariable-location-views=incompat5
12646@opindex gno-variable-location-views
ddf6fe37
AA
12647@item -gvariable-location-views
12648@itemx -gvariable-location-views=incompat5
12649@itemx -gno-variable-location-views
d77de738
ML
12650Augment variable location lists with progressive view numbers implied
12651from the line number table. This enables debug information consumers to
12652inspect state at certain points of the program, even if no instructions
12653associated with the corresponding source locations are present at that
12654point. If the assembler lacks support for view numbers in line number
12655tables, this will cause the compiler to emit the line number table,
12656which generally makes them somewhat less compact. The augmented line
12657number tables and location lists are fully backward-compatible, so they
12658can be consumed by debug information consumers that are not aware of
12659these augmentations, but they won't derive any benefit from them either.
12660
12661This is enabled by default when outputting DWARF 2 debug information at
12662the normal level, as long as there is assembler support,
12663@option{-fvar-tracking-assignments} is enabled and
12664@option{-gstrict-dwarf} is not. When assembler support is not
12665available, this may still be enabled, but it will force GCC to output
12666internal line number tables, and if
12667@option{-ginternal-reset-location-views} is not enabled, that will most
12668certainly lead to silently mismatching location views.
12669
12670There is a proposed representation for view numbers that is not backward
12671compatible with the location list format introduced in DWARF 5, that can
12672be enabled with @option{-gvariable-location-views=incompat5}. This
12673option may be removed in the future, is only provided as a reference
12674implementation of the proposed representation. Debug information
12675consumers are not expected to support this extended format, and they
12676would be rendered unable to decode location lists using it.
12677
d77de738
ML
12678@opindex ginternal-reset-location-views
12679@opindex gno-internal-reset-location-views
ddf6fe37
AA
12680@item -ginternal-reset-location-views
12681@itemx -gno-internal-reset-location-views
d77de738
ML
12682Attempt to determine location views that can be omitted from location
12683view lists. This requires the compiler to have very accurate insn
12684length estimates, which isn't always the case, and it may cause
12685incorrect view lists to be generated silently when using an assembler
12686that does not support location view lists. The GNU assembler will flag
12687any such error as a @code{view number mismatch}. This is only enabled
12688on ports that define a reliable estimation function.
12689
d77de738
ML
12690@opindex ginline-points
12691@opindex gno-inline-points
ddf6fe37
AA
12692@item -ginline-points
12693@itemx -gno-inline-points
d77de738
ML
12694Generate extended debug information for inlined functions. Location
12695view tracking markers are inserted at inlined entry points, so that
12696address and view numbers can be computed and output in debug
12697information. This can be enabled independently of location views, in
12698which case the view numbers won't be output, but it can only be enabled
12699along with statement frontiers, and it is only enabled by default if
12700location views are enabled.
12701
d77de738 12702@opindex gz
ddf6fe37 12703@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
12704Produce compressed debug sections in DWARF format, if that is supported.
12705If @var{type} is not given, the default type depends on the capabilities
12706of the assembler and linker used. @var{type} may be one of
12707@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
12708compression in ELF gABI format). If the linker doesn't support writing
12709compressed debug sections, the option is rejected. Otherwise, if the
12710assembler does not support them, @option{-gz} is silently ignored when
12711producing object files.
12712
d77de738 12713@opindex femit-struct-debug-baseonly
ddf6fe37 12714@item -femit-struct-debug-baseonly
d77de738
ML
12715Emit debug information for struct-like types
12716only when the base name of the compilation source file
12717matches the base name of file in which the struct is defined.
12718
12719This option substantially reduces the size of debugging information,
12720but at significant potential loss in type information to the debugger.
12721See @option{-femit-struct-debug-reduced} for a less aggressive option.
12722See @option{-femit-struct-debug-detailed} for more detailed control.
12723
12724This option works only with DWARF debug output.
12725
d77de738 12726@opindex femit-struct-debug-reduced
ddf6fe37 12727@item -femit-struct-debug-reduced
d77de738
ML
12728Emit debug information for struct-like types
12729only when the base name of the compilation source file
12730matches the base name of file in which the type is defined,
12731unless the struct is a template or defined in a system header.
12732
12733This option significantly reduces the size of debugging information,
12734with some potential loss in type information to the debugger.
12735See @option{-femit-struct-debug-baseonly} for a more aggressive option.
12736See @option{-femit-struct-debug-detailed} for more detailed control.
12737
12738This option works only with DWARF debug output.
12739
d77de738 12740@opindex femit-struct-debug-detailed
ddf6fe37 12741@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
12742Specify the struct-like types
12743for which the compiler generates debug information.
12744The intent is to reduce duplicate struct debug information
12745between different object files within the same program.
12746
12747This option is a detailed version of
12748@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
12749which serves for most needs.
12750
12751A specification has the syntax@*
12752[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
12753
12754The optional first word limits the specification to
12755structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
12756A struct type is used directly when it is the type of a variable, member.
12757Indirect uses arise through pointers to structs.
12758That is, when use of an incomplete struct is valid, the use is indirect.
12759An example is
12760@samp{struct one direct; struct two * indirect;}.
12761
12762The optional second word limits the specification to
12763ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
12764Generic structs are a bit complicated to explain.
12765For C++, these are non-explicit specializations of template classes,
12766or non-template classes within the above.
12767Other programming languages have generics,
12768but @option{-femit-struct-debug-detailed} does not yet implement them.
12769
12770The third word specifies the source files for those
12771structs for which the compiler should emit debug information.
12772The values @samp{none} and @samp{any} have the normal meaning.
12773The value @samp{base} means that
12774the base of name of the file in which the type declaration appears
12775must match the base of the name of the main compilation file.
12776In practice, this means that when compiling @file{foo.c}, debug information
12777is generated for types declared in that file and @file{foo.h},
12778but not other header files.
12779The value @samp{sys} means those types satisfying @samp{base}
12780or declared in system or compiler headers.
12781
12782You may need to experiment to determine the best settings for your application.
12783
12784The default is @option{-femit-struct-debug-detailed=all}.
12785
12786This option works only with DWARF debug output.
12787
d77de738
ML
12788@opindex fdwarf2-cfi-asm
12789@opindex fno-dwarf2-cfi-asm
ddf6fe37 12790@item -fno-dwarf2-cfi-asm
d77de738
ML
12791Emit DWARF unwind info as compiler generated @code{.eh_frame} section
12792instead of using GAS @code{.cfi_*} directives.
12793
d77de738
ML
12794@opindex feliminate-unused-debug-types
12795@opindex fno-eliminate-unused-debug-types
ddf6fe37 12796@item -fno-eliminate-unused-debug-types
a0e64a04 12797Normally, when producing DWARF output, GCC avoids producing debug symbol
d77de738
ML
12798output for types that are nowhere used in the source file being compiled.
12799Sometimes it is useful to have GCC emit debugging
12800information for all types declared in a compilation
12801unit, regardless of whether or not they are actually used
a0e64a04 12802in that compilation unit, for example
d77de738
ML
12803if, in the debugger, you want to cast a value to a type that is
12804not actually used in your program (but is declared). More often,
12805however, this results in a significant amount of wasted space.
12806@end table
12807
12808@node Optimize Options
12809@section Options That Control Optimization
12810@cindex optimize options
12811@cindex options, optimization
12812
12813These options control various sorts of optimizations.
12814
12815Without any optimization option, the compiler's goal is to reduce the
12816cost of compilation and to make debugging produce the expected
12817results. Statements are independent: if you stop the program with a
12818breakpoint between statements, you can then assign a new value to any
12819variable or change the program counter to any other statement in the
12820function and get exactly the results you expect from the source
12821code.
12822
12823Turning on optimization flags makes the compiler attempt to improve
12824the performance and/or code size at the expense of compilation time
12825and possibly the ability to debug the program.
12826
12827The compiler performs optimization based on the knowledge it has of the
12828program. Compiling multiple files at once to a single output file mode allows
12829the compiler to use information gained from all of the files when compiling
12830each of them.
12831
12832Not all optimizations are controlled directly by a flag. Only
12833optimizations that have a flag are listed in this section.
12834
12835Most optimizations are completely disabled at @option{-O0} or if an
12836@option{-O} level is not set on the command line, even if individual
12837optimization flags are specified. Similarly, @option{-Og} suppresses
12838many optimization passes.
12839
12840Depending on the target and how GCC was configured, a slightly different
12841set of optimizations may be enabled at each @option{-O} level than
12842those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12843to find out the exact set of optimizations that are enabled at each level.
12844@xref{Overall Options}, for examples.
12845
12846@table @gcctabopt
d77de738
ML
12847@opindex O
12848@opindex O1
ddf6fe37
AA
12849@item -O
12850@itemx -O1
d77de738
ML
12851Optimize. Optimizing compilation takes somewhat more time, and a lot
12852more memory for a large function.
12853
12854With @option{-O}, the compiler tries to reduce code size and execution
12855time, without performing any optimizations that take a great deal of
12856compilation time.
12857
634eae5e
SJ
12858@option{-O} is the recommended optimization level for large machine-generated
12859code as a sensible balance between time taken to compile and memory use:
12860higher optimization levels perform optimizations with greater algorithmic
12861complexity than at @option{-O}.
12862
d77de738
ML
12863@c Note that in addition to the default_options_table list in opts.cc,
12864@c several optimization flags default to true but control optimization
12865@c passes that are explicitly disabled at -O0.
12866
12867@option{-O} turns on the following optimization flags:
12868
12869@c Please keep the following list alphabetized.
43b72ede
AA
12870@gccoptlist{-fauto-inc-dec
12871-fbranch-count-reg
12872-fcombine-stack-adjustments
12873-fcompare-elim
12874-fcprop-registers
12875-fdce
12876-fdefer-pop
12877-fdelayed-branch
12878-fdse
12879-fforward-propagate
12880-fguess-branch-probability
12881-fif-conversion
12882-fif-conversion2
12883-finline-functions-called-once
12884-fipa-modref
12885-fipa-profile
12886-fipa-pure-const
12887-fipa-reference
12888-fipa-reference-addressable
d91aab4d 12889-fivopts
43b72ede
AA
12890-fmerge-constants
12891-fmove-loop-invariants
12892-fmove-loop-stores
12893-fomit-frame-pointer
12894-freorder-blocks
12895-fshrink-wrap
12896-fshrink-wrap-separate
12897-fsplit-wide-types
12898-fssa-backprop
12899-fssa-phiopt
12900-ftree-bit-ccp
12901-ftree-ccp
12902-ftree-ch
12903-ftree-coalesce-vars
12904-ftree-copy-prop
12905-ftree-dce
12906-ftree-dominator-opts
12907-ftree-dse
12908-ftree-forwprop
12909-ftree-fre
12910-ftree-phiprop
12911-ftree-pta
12912-ftree-scev-cprop
12913-ftree-sink
12914-ftree-slsr
12915-ftree-sra
12916-ftree-ter
d77de738
ML
12917-funit-at-a-time}
12918
d77de738 12919@opindex O2
ddf6fe37 12920@item -O2
d77de738
ML
12921Optimize even more. GCC performs nearly all supported optimizations
12922that do not involve a space-speed tradeoff.
12923As compared to @option{-O}, this option increases both compilation time
12924and the performance of the generated code.
12925
12926@option{-O2} turns on all optimization flags specified by @option{-O1}. It
12927also turns on the following optimization flags:
12928
12929@c Please keep the following list alphabetized!
43b72ede
AA
12930@gccoptlist{-falign-functions -falign-jumps
12931-falign-labels -falign-loops
12932-fcaller-saves
12933-fcode-hoisting
12934-fcrossjumping
12935-fcse-follow-jumps -fcse-skip-blocks
12936-fdelete-null-pointer-checks
12937-fdevirtualize -fdevirtualize-speculatively
12938-fexpensive-optimizations
12939-ffinite-loops
12940-fgcse -fgcse-lm
12941-fhoist-adjacent-loads
12942-finline-functions
12943-finline-small-functions
12944-findirect-inlining
12945-fipa-bit-cp -fipa-cp -fipa-icf
12946-fipa-ra -fipa-sra -fipa-vrp
12947-fisolate-erroneous-paths-dereference
12948-flra-remat
062ad209 12949-foptimize-crc
43b72ede
AA
12950-foptimize-sibling-calls
12951-foptimize-strlen
12952-fpartial-inlining
12953-fpeephole2
12954-freorder-blocks-algorithm=stc
12955-freorder-blocks-and-partition -freorder-functions
12956-frerun-cse-after-loop
12957-fschedule-insns -fschedule-insns2
12958-fsched-interblock -fsched-spec
12959-fstore-merging
12960-fstrict-aliasing
12961-fthread-jumps
12962-ftree-builtin-call-dce
12963-ftree-loop-vectorize
12964-ftree-pre
12965-ftree-slp-vectorize
12966-ftree-switch-conversion -ftree-tail-merge
12967-ftree-vrp
d77de738
ML
12968-fvect-cost-model=very-cheap}
12969
12970Please note the warning under @option{-fgcse} about
12971invoking @option{-O2} on programs that use computed gotos.
12972
d77de738 12973@opindex O3
ddf6fe37 12974@item -O3
d77de738
ML
12975Optimize yet more. @option{-O3} turns on all optimizations specified
12976by @option{-O2} and also turns on the following optimization flags:
12977
12978@c Please keep the following list alphabetized!
43b72ede 12979@gccoptlist{-fgcse-after-reload
d77de738 12980-fipa-cp-clone
43b72ede
AA
12981-floop-interchange
12982-floop-unroll-and-jam
12983-fpeel-loops
12984-fpredictive-commoning
12985-fsplit-loops
12986-fsplit-paths
12987-ftree-loop-distribution
12988-ftree-partial-pre
12989-funswitch-loops
12990-fvect-cost-model=dynamic
d77de738
ML
12991-fversion-loops-for-strides}
12992
d77de738 12993@opindex O0
ddf6fe37 12994@item -O0
d77de738
ML
12995Reduce compilation time and make debugging produce the expected
12996results. This is the default.
12997
d91aab4d
SL
12998At @option{-O0}, GCC completely disables most optimization passes;
12999they are not run even if you explicitly enable them on the command
13000line, or are listed by @option{-Q --help=optimizers} as being enabled by
13001default. Many optimizations performed by GCC depend on code analysis
13002or canonicalization passes that are enabled by @option{-O}, and it would
13003not be useful to run individual optimization passes in isolation.
13004
d77de738 13005@opindex Os
ddf6fe37 13006@item -Os
a0e64a04 13007Optimize for size. @option{-Os} enables all @option{-O2} optimizations
d77de738
ML
13008except those that often increase code size:
13009
43b72ede
AA
13010@gccoptlist{-falign-functions -falign-jumps
13011-falign-labels -falign-loops
d77de738
ML
13012-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
13013
13014It also enables @option{-finline-functions}, causes the compiler to tune for
13015code size rather than execution speed, and performs further optimizations
13016designed to reduce code size.
13017
d77de738 13018@opindex Ofast
ddf6fe37 13019@item -Ofast
d77de738
ML
13020Disregard strict standards compliance. @option{-Ofast} enables all
13021@option{-O3} optimizations. It also enables optimizations that are not
13022valid for all standard-compliant programs.
13023It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
13024and the Fortran-specific @option{-fstack-arrays}, unless
13025@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
13026It turns off @option{-fsemantic-interposition}.
13027
d77de738 13028@opindex Og
ddf6fe37 13029@item -Og
3cf97980
RB
13030Optimize while keeping in mind debugging experience.
13031@option{-Og} should be the optimization
d77de738 13032level of choice for the standard edit-compile-debug cycle, offering
3cf97980
RB
13033a reasonable blend of optimization, fast compilation and debugging experience
13034especially for code with a high abstraction penalty. In contrast to
13035@option{-O0}, this enables @option{-fvar-tracking-assignments} and
13036@option{-fvar-tracking} which handle debug information in the prologue
13037and epilogue of functions better than @option{-O0}.
d77de738 13038
3cf97980 13039Like @option{-O0}, @option{-Og} completely skips a number of
d77de738 13040optimization passes so that individual options controlling them have
a0e64a04 13041no effect. Otherwise @option{-Og} enables all @option{-O1}
3cf97980 13042optimization flags except for those known to greatly interfere with debugging:
d77de738 13043
43b72ede
AA
13044@gccoptlist{-fbranch-count-reg -fdelayed-branch
13045-fdse -fif-conversion -fif-conversion2
13046-finline-functions-called-once
13047-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
13048-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
13049
d77de738 13050@opindex Oz
ddf6fe37 13051@item -Oz
d77de738
ML
13052Optimize aggressively for size rather than speed. This may increase
13053the number of instructions executed if those instructions require
13054fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
13055including enabling most @option{-O2} optimizations.
13056
13057@end table
13058
13059If you use multiple @option{-O} options, with or without level numbers,
13060the last such option is the one that is effective.
13061
13062Options of the form @option{-f@var{flag}} specify machine-independent
13063flags. Most flags have both positive and negative forms; the negative
13064form of @option{-ffoo} is @option{-fno-foo}. In the table
a0e64a04 13065below, only one of the forms is listed---the one you typically
d77de738
ML
13066use. You can figure out the other form by either removing @samp{no-}
13067or adding it.
13068
13069The following options control specific optimizations. They are either
13070activated by @option{-O} options or are related to ones that are. You
13071can use the following flags in the rare cases when ``fine-tuning'' of
13072optimizations to be performed is desired.
13073
13074@table @gcctabopt
d77de738
ML
13075@opindex fno-defer-pop
13076@opindex fdefer-pop
ddf6fe37 13077@item -fno-defer-pop
a0e64a04
PN
13078For machines that must pop arguments after a function call, always pop
13079the arguments as soon as each function returns.
d77de738
ML
13080At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
13081this allows the compiler to let arguments accumulate on the stack for several
13082function calls and pop them all at once.
13083
d77de738 13084@opindex fforward-propagate
ddf6fe37 13085@item -fforward-propagate
d77de738
ML
13086Perform a forward propagation pass on RTL@. The pass tries to combine two
13087instructions and checks if the result can be simplified. If loop unrolling
13088is active, two passes are performed and the second is scheduled after
13089loop unrolling.
13090
13091This option is enabled by default at optimization levels @option{-O1},
13092@option{-O2}, @option{-O3}, @option{-Os}.
13093
1d8de1e9
KE
13094@opindex favoid-store-forwarding
13095@item -favoid-store-forwarding
13096@itemx -fno-avoid-store-forwarding
13097Many CPUs will stall for many cycles when a load partially depends on previous
13098smaller stores. This pass tries to detect such cases and avoid the penalty by
13099changing the order of the load and store and then fixing up the loaded value.
13100
13101Disabled by default.
13102
d77de738 13103@opindex ffp-contract
ddf6fe37 13104@item -ffp-contract=@var{style}
d77de738
ML
13105@option{-ffp-contract=off} disables floating-point expression contraction.
13106@option{-ffp-contract=fast} enables floating-point expression contraction
13107such as forming of fused multiply-add operations if the target has
13108native support for them.
13109@option{-ffp-contract=on} enables floating-point expression contraction
1c1dd396
AM
13110if allowed by the language standard. This is implemented for C and C++,
13111where it enables contraction within one expression, but not across
13112different statements.
d77de738 13113
1c1dd396
AM
13114The default is @option{-ffp-contract=off} for C in a standards compliant mode
13115(@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
d77de738 13116
d77de738 13117@opindex fomit-frame-pointer
ddf6fe37 13118@item -fomit-frame-pointer
d77de738
ML
13119Omit the frame pointer in functions that don't need one. This avoids the
13120instructions to save, set up and restore the frame pointer; on many targets
13121it also makes an extra register available.
13122
13123On some targets this flag has no effect because the standard calling sequence
13124always uses a frame pointer, so it cannot be omitted.
13125
13126Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
13127is used in all functions. Several targets always omit the frame pointer in
13128leaf functions.
13129
13130Enabled by default at @option{-O1} and higher.
13131
062ad209
MA
13132@opindex foptimize-crc
13133@item -foptimize-crc
13134Detect loops calculating CRC (performing polynomial long division) and
13135replace them with a faster implementation. Detect 8, 16, 32, and 64 bit CRC,
13136with a constant polynomial without the leading 1 bit,
13137for both bit-forward and bit-reversed cases.
13138If the target supports a CRC instruction and the polynomial used in the source
13139code matches the polynomial used in the CRC instruction, generate that CRC
13140instruction. Otherwise, if the target supports a carry-less-multiplication
13141instruction, generate CRC using it; otherwise generate table-based CRC.
13142
13143Enabled by default at @option{-O2} and higher.
13144
d77de738 13145@opindex foptimize-sibling-calls
ddf6fe37 13146@item -foptimize-sibling-calls
d77de738
ML
13147Optimize sibling and tail recursive calls.
13148
13149Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13150
d77de738 13151@opindex foptimize-strlen
ddf6fe37 13152@item -foptimize-strlen
d77de738
ML
13153Optimize various standard C string functions (e.g.@: @code{strlen},
13154@code{strchr} or @code{strcpy}) and
13155their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
13156
13157Enabled at levels @option{-O2}, @option{-O3}.
13158
1ff6d9f7
AO
13159@opindex finline-stringops
13160@item -finline-stringops[=@var{fn}]
13161Expand memory and string operations (for now, only @code{memset})
13162inline, even when the length is variable or big enough as to require
13163looping. This is most useful along with @option{-ffreestanding} and
13164@option{-fno-builtin}.
13165
13166In some circumstances, it enables the compiler to generate code that
13167takes advantage of known alignment and length multipliers, but even then
13168it may be less efficient than optimized runtime implementations, and
13169grow code size so much that even a less performant but shared
13170implementation runs faster due to better use of code caches. This
13171option is disabled by default.
13172
d77de738
ML
13173@opindex fno-inline
13174@opindex finline
ddf6fe37 13175@item -fno-inline
d77de738
ML
13176Do not expand any functions inline apart from those marked with
13177the @code{always_inline} attribute. This is the default when not
13178optimizing.
13179
13180Single functions can be exempted from inlining by marking them
13181with the @code{noinline} attribute.
13182
d77de738 13183@opindex finline-small-functions
ddf6fe37 13184@item -finline-small-functions
d77de738
ML
13185Integrate functions into their callers when their body is smaller than expected
13186function call code (so overall size of program gets smaller). The compiler
13187heuristically decides which functions are simple enough to be worth integrating
13188in this way. This inlining applies to all functions, even those not declared
13189inline.
13190
13191Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13192
d77de738 13193@opindex findirect-inlining
ddf6fe37 13194@item -findirect-inlining
d77de738
ML
13195Inline also indirect calls that are discovered to be known at compile
13196time thanks to previous inlining. This option has any effect only
13197when inlining itself is turned on by the @option{-finline-functions}
13198or @option{-finline-small-functions} options.
13199
13200Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13201
d77de738 13202@opindex finline-functions
ddf6fe37 13203@item -finline-functions
d77de738
ML
13204Consider all functions for inlining, even if they are not declared inline.
13205The compiler heuristically decides which functions are worth integrating
13206in this way.
13207
13208If all calls to a given function are integrated, and the function is
13209declared @code{static}, then the function is normally not output as
13210assembler code in its own right.
13211
13212Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
13213by @option{-fprofile-use} and @option{-fauto-profile}.
13214
d77de738 13215@opindex finline-functions-called-once
ddf6fe37 13216@item -finline-functions-called-once
d77de738
ML
13217Consider all @code{static} functions called once for inlining into their
13218caller even if they are not marked @code{inline}. If a call to a given
13219function is integrated, then the function is not output as assembler code
13220in its own right.
13221
13222Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
13223but not @option{-Og}.
13224
d77de738 13225@opindex fearly-inlining
ddf6fe37 13226@item -fearly-inlining
d77de738
ML
13227Inline functions marked by @code{always_inline} and functions whose body seems
13228smaller than the function call overhead early before doing
13229@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
13230makes profiling significantly cheaper and usually inlining faster on programs
13231having large chains of nested wrapper functions.
13232
13233Enabled by default.
13234
d77de738 13235@opindex fipa-sra
ddf6fe37 13236@item -fipa-sra
d77de738
ML
13237Perform interprocedural scalar replacement of aggregates, removal of
13238unused parameters and replacement of parameters passed by reference
13239by parameters passed by value.
13240
13241Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
13242
d77de738 13243@opindex finline-limit
ddf6fe37 13244@item -finline-limit=@var{n}
d77de738
ML
13245By default, GCC limits the size of functions that can be inlined. This flag
13246allows coarse control of this limit. @var{n} is the size of functions that
13247can be inlined in number of pseudo instructions.
13248
13249Inlining is actually controlled by a number of parameters, which may be
13250specified individually by using @option{--param @var{name}=@var{value}}.
13251The @option{-finline-limit=@var{n}} option sets some of these parameters
13252as follows:
13253
13254@table @gcctabopt
13255@item max-inline-insns-single
13256is set to @var{n}/2.
13257@item max-inline-insns-auto
13258is set to @var{n}/2.
13259@end table
13260
13261See below for a documentation of the individual
13262parameters controlling inlining and for the defaults of these parameters.
13263
13264@emph{Note:} there may be no value to @option{-finline-limit} that results
13265in default behavior.
13266
13267@emph{Note:} pseudo instruction represents, in this particular context, an
13268abstract measurement of function's size. In no way does it represent a count
13269of assembly instructions and as such its exact meaning might change from one
13270release to an another.
13271
d77de738
ML
13272@opindex fno-keep-inline-dllexport
13273@opindex fkeep-inline-dllexport
ddf6fe37 13274@item -fno-keep-inline-dllexport
d77de738
ML
13275This is a more fine-grained version of @option{-fkeep-inline-functions},
13276which applies only to functions that are declared using the @code{dllexport}
13277attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
13278Functions}.
13279
d77de738 13280@opindex fkeep-inline-functions
ddf6fe37 13281@item -fkeep-inline-functions
d77de738
ML
13282In C, emit @code{static} functions that are declared @code{inline}
13283into the object file, even if the function has been inlined into all
13284of its callers. This switch does not affect functions using the
13285@code{extern inline} extension in GNU C90@. In C++, emit any and all
13286inline functions into the object file.
13287
d77de738 13288@opindex fkeep-static-functions
ddf6fe37 13289@item -fkeep-static-functions
d77de738
ML
13290Emit @code{static} functions into the object file, even if the function
13291is never used.
13292
d77de738 13293@opindex fkeep-static-consts
ddf6fe37 13294@item -fkeep-static-consts
d77de738
ML
13295Emit variables declared @code{static const} when optimization isn't turned
13296on, even if the variables aren't referenced.
13297
13298GCC enables this option by default. If you want to force the compiler to
13299check if a variable is referenced, regardless of whether or not
13300optimization is turned on, use the @option{-fno-keep-static-consts} option.
13301
d77de738 13302@opindex fmerge-constants
ddf6fe37 13303@item -fmerge-constants
d77de738
ML
13304Attempt to merge identical constants (string constants and floating-point
13305constants) across compilation units.
13306
13307This option is the default for optimized compilation if the assembler and
13308linker support it. Use @option{-fno-merge-constants} to inhibit this
13309behavior.
13310
13311Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13312
d77de738 13313@opindex fmerge-all-constants
ddf6fe37 13314@item -fmerge-all-constants
d77de738
ML
13315Attempt to merge identical constants and identical variables.
13316
13317This option implies @option{-fmerge-constants}. In addition to
13318@option{-fmerge-constants} this considers e.g.@: even constant initialized
13319arrays or initialized constant variables with integral or floating-point
13320types. Languages like C or C++ require each variable, including multiple
13321instances of the same variable in recursive calls, to have distinct locations,
13322so using this option results in non-conforming
13323behavior.
13324
d77de738 13325@opindex fmodulo-sched
ddf6fe37 13326@item -fmodulo-sched
d77de738
ML
13327Perform swing modulo scheduling immediately before the first scheduling
13328pass. This pass looks at innermost loops and reorders their
13329instructions by overlapping different iterations.
13330
d77de738 13331@opindex fmodulo-sched-allow-regmoves
ddf6fe37 13332@item -fmodulo-sched-allow-regmoves
d77de738
ML
13333Perform more aggressive SMS-based modulo scheduling with register moves
13334allowed. By setting this flag certain anti-dependences edges are
13335deleted, which triggers the generation of reg-moves based on the
13336life-range analysis. This option is effective only with
13337@option{-fmodulo-sched} enabled.
13338
d77de738
ML
13339@opindex fno-branch-count-reg
13340@opindex fbranch-count-reg
ddf6fe37 13341@item -fno-branch-count-reg
a0e64a04 13342Disable the optimization pass that scans for opportunities to use
d77de738
ML
13343``decrement and branch'' instructions on a count register instead of
13344instruction sequences that decrement a register, compare it against zero, and
13345then branch based upon the result. This option is only meaningful on
13346architectures that support such instructions, which include x86, PowerPC,
13347IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
13348doesn't remove the decrement and branch instructions from the generated
13349instruction stream introduced by other optimization passes.
13350
13351The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
13352except for @option{-Og}.
13353
d77de738
ML
13354@opindex fno-function-cse
13355@opindex ffunction-cse
ddf6fe37 13356@item -fno-function-cse
d77de738
ML
13357Do not put function addresses in registers; make each instruction that
13358calls a constant function contain the function's address explicitly.
13359
13360This option results in less efficient code, but some strange hacks
13361that alter the assembler output may be confused by the optimizations
13362performed when this option is not used.
13363
13364The default is @option{-ffunction-cse}
13365
d77de738
ML
13366@opindex fno-zero-initialized-in-bss
13367@opindex fzero-initialized-in-bss
ddf6fe37 13368@item -fno-zero-initialized-in-bss
d77de738
ML
13369If the target supports a BSS section, GCC by default puts variables that
13370are initialized to zero into BSS@. This can save space in the resulting
13371code.
13372
13373This option turns off this behavior because some programs explicitly
13374rely on variables going to the data section---e.g., so that the
13375resulting executable can find the beginning of that section and/or make
13376assumptions based on that.
13377
adb4f232 13378The default is @option{-fzero-initialized-in-bss} except in Ada.
d77de738 13379
d77de738 13380@opindex fthread-jumps
ddf6fe37 13381@item -fthread-jumps
d77de738
ML
13382Perform optimizations that check to see if a jump branches to a
13383location where another comparison subsumed by the first is found. If
13384so, the first branch is redirected to either the destination of the
13385second branch or a point immediately following it, depending on whether
13386the condition is known to be true or false.
13387
13388Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13389
d77de738 13390@opindex fsplit-wide-types
ddf6fe37 13391@item -fsplit-wide-types
d77de738
ML
13392When using a type that occupies multiple registers, such as @code{long
13393long} on a 32-bit system, split the registers apart and allocate them
13394independently. This normally generates better code for those types,
13395but may make debugging more difficult.
13396
13397Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
13398@option{-Os}.
13399
d77de738 13400@opindex fsplit-wide-types-early
ddf6fe37 13401@item -fsplit-wide-types-early
d77de738
ML
13402Fully split wide types early, instead of very late.
13403This option has no effect unless @option{-fsplit-wide-types} is turned on.
13404
13405This is the default on some targets.
13406
d77de738 13407@opindex fcse-follow-jumps
ddf6fe37 13408@item -fcse-follow-jumps
d77de738
ML
13409In common subexpression elimination (CSE), scan through jump instructions
13410when the target of the jump is not reached by any other path. For
13411example, when CSE encounters an @code{if} statement with an
13412@code{else} clause, CSE follows the jump when the condition
13413tested is false.
13414
13415Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13416
d77de738 13417@opindex fcse-skip-blocks
ddf6fe37 13418@item -fcse-skip-blocks
d77de738
ML
13419This is similar to @option{-fcse-follow-jumps}, but causes CSE to
13420follow jumps that conditionally skip over blocks. When CSE
13421encounters a simple @code{if} statement with no else clause,
13422@option{-fcse-skip-blocks} causes CSE to follow the jump around the
13423body of the @code{if}.
13424
13425Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13426
d77de738 13427@opindex frerun-cse-after-loop
ddf6fe37 13428@item -frerun-cse-after-loop
d77de738
ML
13429Re-run common subexpression elimination after loop optimizations are
13430performed.
13431
13432Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13433
d77de738 13434@opindex fgcse
ddf6fe37 13435@item -fgcse
d77de738
ML
13436Perform a global common subexpression elimination pass.
13437This pass also performs global constant and copy propagation.
13438
13439@emph{Note:} When compiling a program using computed gotos, a GCC
13440extension, you may get better run-time performance if you disable
13441the global common subexpression elimination pass by adding
13442@option{-fno-gcse} to the command line.
13443
13444Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13445
d77de738 13446@opindex fgcse-lm
ddf6fe37 13447@item -fgcse-lm
d77de738
ML
13448When @option{-fgcse-lm} is enabled, global common subexpression elimination
13449attempts to move loads that are only killed by stores into themselves. This
13450allows a loop containing a load/store sequence to be changed to a load outside
13451the loop, and a copy/store within the loop.
13452
13453Enabled by default when @option{-fgcse} is enabled.
13454
d77de738 13455@opindex fgcse-sm
ddf6fe37 13456@item -fgcse-sm
d77de738
ML
13457When @option{-fgcse-sm} is enabled, a store motion pass is run after
13458global common subexpression elimination. This pass attempts to move
13459stores out of loops. When used in conjunction with @option{-fgcse-lm},
13460loops containing a load/store sequence can be changed to a load before
13461the loop and a store after the loop.
13462
13463Not enabled at any optimization level.
13464
d77de738 13465@opindex fgcse-las
ddf6fe37 13466@item -fgcse-las
d77de738
ML
13467When @option{-fgcse-las} is enabled, the global common subexpression
13468elimination pass eliminates redundant loads that come after stores to the
13469same memory location (both partial and full redundancies).
13470
13471Not enabled at any optimization level.
13472
d77de738 13473@opindex fgcse-after-reload
ddf6fe37 13474@item -fgcse-after-reload
d77de738
ML
13475When @option{-fgcse-after-reload} is enabled, a redundant load elimination
13476pass is performed after reload. The purpose of this pass is to clean up
13477redundant spilling.
13478
13479Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
13480
d77de738 13481@opindex faggressive-loop-optimizations
ddf6fe37 13482@item -faggressive-loop-optimizations
d77de738
ML
13483This option tells the loop optimizer to use language constraints to
13484derive bounds for the number of iterations of a loop. This assumes that
13485loop code does not invoke undefined behavior by for example causing signed
13486integer overflows or out-of-bound array accesses. The bounds for the
13487number of iterations of a loop are used to guide loop unrolling and peeling
13488and loop exit test optimizations.
13489This option is enabled by default.
13490
d77de738 13491@opindex funconstrained-commons
ddf6fe37 13492@item -funconstrained-commons
d77de738
ML
13493This option tells the compiler that variables declared in common blocks
13494(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
13495prevents certain optimizations that depend on knowing the array bounds.
13496
d77de738 13497@opindex fcrossjumping
ddf6fe37 13498@item -fcrossjumping
d77de738
ML
13499Perform cross-jumping transformation.
13500This transformation unifies equivalent code and saves code size. The
13501resulting code may or may not perform better than without cross-jumping.
13502
13503Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13504
d77de738 13505@opindex fauto-inc-dec
ddf6fe37 13506@item -fauto-inc-dec
d77de738
ML
13507Combine increments or decrements of addresses with memory accesses.
13508This pass is always skipped on architectures that do not have
13509instructions to support this. Enabled by default at @option{-O1} and
13510higher on architectures that support this.
13511
d77de738 13512@opindex fdce
ddf6fe37 13513@item -fdce
d77de738
ML
13514Perform dead code elimination (DCE) on RTL@.
13515Enabled by default at @option{-O1} and higher.
13516
d77de738 13517@opindex fdse
ddf6fe37 13518@item -fdse
d77de738
ML
13519Perform dead store elimination (DSE) on RTL@.
13520Enabled by default at @option{-O1} and higher.
13521
d77de738 13522@opindex fif-conversion
ddf6fe37 13523@item -fif-conversion
d77de738
ML
13524Attempt to transform conditional jumps into branch-less equivalents. This
13525includes use of conditional moves, min, max, set flags and abs instructions, and
13526some tricks doable by standard arithmetics. The use of conditional execution
13527on chips where it is available is controlled by @option{-fif-conversion2}.
13528
13529Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
13530not with @option{-Og}.
13531
d77de738 13532@opindex fif-conversion2
ddf6fe37 13533@item -fif-conversion2
d77de738
ML
13534Use conditional execution (where available) to transform conditional jumps into
13535branch-less equivalents.
13536
13537Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
13538not with @option{-Og}.
13539
d77de738 13540@opindex fdeclone-ctor-dtor
ddf6fe37 13541@item -fdeclone-ctor-dtor
d77de738
ML
13542The C++ ABI requires multiple entry points for constructors and
13543destructors: one for a base subobject, one for a complete object, and
13544one for a virtual destructor that calls operator delete afterwards.
13545For a hierarchy with virtual bases, the base and complete variants are
13546clones, which means two copies of the function. With this option, the
13547base and complete variants are changed to be thunks that call a common
13548implementation.
13549
13550Enabled by @option{-Os}.
13551
d77de738 13552@opindex fdelete-null-pointer-checks
ddf6fe37 13553@item -fdelete-null-pointer-checks
d77de738
ML
13554Assume that programs cannot safely dereference null pointers, and that
13555no code or data element resides at address zero.
13556This option enables simple constant
13557folding optimizations at all optimization levels. In addition, other
13558optimization passes in GCC use this flag to control global dataflow
13559analyses that eliminate useless checks for null pointers; these assume
13560that a memory access to address zero always results in a trap, so
13561that if a pointer is checked after it has already been dereferenced,
13562it cannot be null.
13563
13564Note however that in some environments this assumption is not true.
13565Use @option{-fno-delete-null-pointer-checks} to disable this optimization
13566for programs that depend on that behavior.
13567
e876acab
SL
13568This option is enabled by default on most targets.
13569On AVR and MSP430, this option is completely disabled.
d77de738
ML
13570
13571Passes that use the dataflow information
13572are enabled independently at different optimization levels.
13573
d77de738 13574@opindex fdevirtualize
ddf6fe37 13575@item -fdevirtualize
d77de738
ML
13576Attempt to convert calls to virtual functions to direct calls. This
13577is done both within a procedure and interprocedurally as part of
13578indirect inlining (@option{-findirect-inlining}) and interprocedural constant
13579propagation (@option{-fipa-cp}).
13580Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13581
d77de738 13582@opindex fdevirtualize-speculatively
ddf6fe37 13583@item -fdevirtualize-speculatively
d77de738
ML
13584Attempt to convert calls to virtual functions to speculative direct calls.
13585Based on the analysis of the type inheritance graph, determine for a given call
13586the set of likely targets. If the set is small, preferably of size 1, change
13587the call into a conditional deciding between direct and indirect calls. The
13588speculative calls enable more optimizations, such as inlining. When they seem
13589useless after further optimization, they are converted back into original form.
13590
d77de738 13591@opindex fdevirtualize-at-ltrans
ddf6fe37 13592@item -fdevirtualize-at-ltrans
d77de738 13593Stream extra information needed for aggressive devirtualization when running
a0e64a04 13594the link-time optimizer in local transformation mode.
d77de738
ML
13595This option enables more devirtualization but
13596significantly increases the size of streamed data. For this reason it is
13597disabled by default.
13598
d77de738 13599@opindex fexpensive-optimizations
ddf6fe37 13600@item -fexpensive-optimizations
d77de738
ML
13601Perform a number of minor optimizations that are relatively expensive.
13602
13603Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13604
d77de738 13605@opindex free
ddf6fe37 13606@item -free
d77de738
ML
13607Attempt to remove redundant extension instructions. This is especially
13608helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
13609registers after writing to their lower 32-bit half.
13610
88ae53a3
LC
13611Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
13612levels @option{-O2}, @option{-O3}, @option{-Os}.
d77de738 13613
d77de738
ML
13614@opindex fno-lifetime-dse
13615@opindex flifetime-dse
ddf6fe37 13616@item -fno-lifetime-dse
d77de738
ML
13617In C++ the value of an object is only affected by changes within its
13618lifetime: when the constructor begins, the object has an indeterminate
13619value, and any changes during the lifetime of the object are dead when
13620the object is destroyed. Normally dead store elimination will take
13621advantage of this; if your code relies on the value of the object
13622storage persisting beyond the lifetime of the object, you can use this
13623flag to disable this optimization. To preserve stores before the
13624constructor starts (e.g.@: because your operator new clears the object
13625storage) but still treat the object as dead after the destructor, you
13626can use @option{-flifetime-dse=1}. The default behavior can be
13627explicitly selected with @option{-flifetime-dse=2}.
13628@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
13629
d77de738 13630@opindex flive-range-shrinkage
ddf6fe37 13631@item -flive-range-shrinkage
d77de738
ML
13632Attempt to decrease register pressure through register live range
13633shrinkage. This is helpful for fast processors with small or moderate
13634size register sets.
13635
d77de738 13636@opindex fira-algorithm
ddf6fe37 13637@item -fira-algorithm=@var{algorithm}
d77de738
ML
13638Use the specified coloring algorithm for the integrated register
13639allocator. The @var{algorithm} argument can be @samp{priority}, which
13640specifies Chow's priority coloring, or @samp{CB}, which specifies
13641Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
13642for all architectures, but for those targets that do support it, it is
13643the default because it generates better code.
13644
d77de738 13645@opindex fira-region
ddf6fe37 13646@item -fira-region=@var{region}
d77de738
ML
13647Use specified regions for the integrated register allocator. The
13648@var{region} argument should be one of the following:
13649
13650@table @samp
13651
13652@item all
13653Use all loops as register allocation regions.
13654This can give the best results for machines with a small and/or
13655irregular register set.
13656
13657@item mixed
a0e64a04 13658Use all loops except for loops with small register pressure
d77de738
ML
13659as the regions. This value usually gives
13660the best results in most cases and for most architectures,
13661and is enabled by default when compiling with optimization for speed
13662(@option{-O}, @option{-O2}, @dots{}).
13663
13664@item one
a0e64a04 13665Use all functions as a single region.
d77de738
ML
13666This typically results in the smallest code size, and is enabled by default for
13667@option{-Os} or @option{-O0}.
13668
13669@end table
13670
d77de738 13671@opindex fira-hoist-pressure
ddf6fe37 13672@item -fira-hoist-pressure
d77de738
ML
13673Use IRA to evaluate register pressure in the code hoisting pass for
13674decisions to hoist expressions. This option usually results in smaller
13675code, but it can slow the compiler down.
13676
13677This option is enabled at level @option{-Os} for all targets.
13678
d77de738 13679@opindex fira-loop-pressure
ddf6fe37 13680@item -fira-loop-pressure
d77de738
ML
13681Use IRA to evaluate register pressure in loops for decisions to move
13682loop invariants. This option usually results in generation
13683of faster and smaller code on machines with large register files (>= 32
13684registers), but it can slow the compiler down.
13685
13686This option is enabled at level @option{-O3} for some targets.
13687
d77de738
ML
13688@opindex fno-ira-share-save-slots
13689@opindex fira-share-save-slots
ddf6fe37 13690@item -fno-ira-share-save-slots
d77de738
ML
13691Disable sharing of stack slots used for saving call-used hard
13692registers living through a call. Each hard register gets a
13693separate stack slot, and as a result function stack frames are
13694larger.
13695
d77de738
ML
13696@opindex fno-ira-share-spill-slots
13697@opindex fira-share-spill-slots
ddf6fe37 13698@item -fno-ira-share-spill-slots
d77de738
ML
13699Disable sharing of stack slots allocated for pseudo-registers. Each
13700pseudo-register that does not get a hard register gets a separate
13701stack slot, and as a result function stack frames are larger.
13702
d77de738 13703@opindex flra-remat
ddf6fe37 13704@item -flra-remat
d77de738
ML
13705Enable CFG-sensitive rematerialization in LRA. Instead of loading
13706values of spilled pseudos, LRA tries to rematerialize (recalculate)
13707values if it is profitable.
13708
13709Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13710
d77de738 13711@opindex fdelayed-branch
ddf6fe37 13712@item -fdelayed-branch
d77de738
ML
13713If supported for the target machine, attempt to reorder instructions
13714to exploit instruction slots available after delayed branch
13715instructions.
13716
13717Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
13718but not at @option{-Og}.
13719
d77de738 13720@opindex fschedule-insns
ddf6fe37 13721@item -fschedule-insns
d77de738
ML
13722If supported for the target machine, attempt to reorder instructions to
13723eliminate execution stalls due to required data being unavailable. This
13724helps machines that have slow floating point or memory load instructions
13725by allowing other instructions to be issued until the result of the load
13726or floating-point instruction is required.
13727
f8703025
WD
13728Conventionally enabled at optimization levels @option{-O2} and @option{-O3}.
13729However, many targets override this behavior. For example, on x86, it is
13730disabled at all levels, while on AArch64, it is enabled only at @option{-O3}.
d77de738 13731
d77de738 13732@opindex fschedule-insns2
ddf6fe37 13733@item -fschedule-insns2
d77de738
ML
13734Similar to @option{-fschedule-insns}, but requests an additional pass of
13735instruction scheduling after register allocation has been done. This is
13736especially useful on machines with a relatively small number of
13737registers and where memory load instructions take more than one cycle.
13738
13739Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13740
d77de738
ML
13741@opindex fno-sched-interblock
13742@opindex fsched-interblock
ddf6fe37 13743@item -fno-sched-interblock
d77de738
ML
13744Disable instruction scheduling across basic blocks, which
13745is normally enabled when scheduling before register allocation, i.e.@:
13746with @option{-fschedule-insns} or at @option{-O2} or higher.
13747
d77de738
ML
13748@opindex fno-sched-spec
13749@opindex fsched-spec
ddf6fe37 13750@item -fno-sched-spec
d77de738
ML
13751Disable speculative motion of non-load instructions, which
13752is normally enabled when scheduling before register allocation, i.e.@:
13753with @option{-fschedule-insns} or at @option{-O2} or higher.
13754
d77de738 13755@opindex fsched-pressure
ddf6fe37 13756@item -fsched-pressure
d77de738
ML
13757Enable register pressure sensitive insn scheduling before register
13758allocation. This only makes sense when scheduling before register
13759allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
13760@option{-O2} or higher. Usage of this option can improve the
13761generated code and decrease its size by preventing register pressure
13762increase above the number of available hard registers and subsequent
13763spills in register allocation.
13764
d77de738 13765@opindex fsched-spec-load
ddf6fe37 13766@item -fsched-spec-load
d77de738
ML
13767Allow speculative motion of some load instructions. This only makes
13768sense when scheduling before register allocation, i.e.@: with
13769@option{-fschedule-insns} or at @option{-O2} or higher.
13770
d77de738 13771@opindex fsched-spec-load-dangerous
ddf6fe37 13772@item -fsched-spec-load-dangerous
d77de738
ML
13773Allow speculative motion of more load instructions. This only makes
13774sense when scheduling before register allocation, i.e.@: with
13775@option{-fschedule-insns} or at @option{-O2} or higher.
13776
ddf6fe37 13777@opindex fsched-stalled-insns
d77de738
ML
13778@item -fsched-stalled-insns
13779@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
13780Define how many insns (if any) can be moved prematurely from the queue
13781of stalled insns into the ready list during the second scheduling pass.
13782@option{-fno-sched-stalled-insns} means that no insns are moved
13783prematurely, @option{-fsched-stalled-insns=0} means there is no limit
13784on how many queued insns can be moved prematurely.
13785@option{-fsched-stalled-insns} without a value is equivalent to
13786@option{-fsched-stalled-insns=1}.
13787
ddf6fe37 13788@opindex fsched-stalled-insns-dep
d77de738
ML
13789@item -fsched-stalled-insns-dep
13790@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
13791Define how many insn groups (cycles) are examined for a dependency
13792on a stalled insn that is a candidate for premature removal from the queue
13793of stalled insns. This has an effect only during the second scheduling pass,
13794and only if @option{-fsched-stalled-insns} is used.
13795@option{-fno-sched-stalled-insns-dep} is equivalent to
13796@option{-fsched-stalled-insns-dep=0}.
13797@option{-fsched-stalled-insns-dep} without a value is equivalent to
13798@option{-fsched-stalled-insns-dep=1}.
13799
d77de738 13800@opindex fsched2-use-superblocks
ddf6fe37 13801@item -fsched2-use-superblocks
d77de738
ML
13802When scheduling after register allocation, use superblock scheduling.
13803This allows motion across basic block boundaries,
13804resulting in faster schedules. This option is experimental, as not all machine
13805descriptions used by GCC model the CPU closely enough to avoid unreliable
13806results from the algorithm.
13807
13808This only makes sense when scheduling after register allocation, i.e.@: with
13809@option{-fschedule-insns2} or at @option{-O2} or higher.
13810
d77de738 13811@opindex fsched-group-heuristic
ddf6fe37 13812@item -fsched-group-heuristic
d77de738
ML
13813Enable the group heuristic in the scheduler. This heuristic favors
13814the instruction that belongs to a schedule group. This is enabled
13815by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13816or @option{-fschedule-insns2} or at @option{-O2} or higher.
13817
d77de738 13818@opindex fsched-critical-path-heuristic
ddf6fe37 13819@item -fsched-critical-path-heuristic
d77de738
ML
13820Enable the critical-path heuristic in the scheduler. This heuristic favors
13821instructions on the critical path. This is enabled by default when
13822scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13823or @option{-fschedule-insns2} or at @option{-O2} or higher.
13824
d77de738 13825@opindex fsched-spec-insn-heuristic
ddf6fe37 13826@item -fsched-spec-insn-heuristic
d77de738
ML
13827Enable the speculative instruction heuristic in the scheduler. This
13828heuristic favors speculative instructions with greater dependency weakness.
13829This is enabled by default when scheduling is enabled, i.e.@:
13830with @option{-fschedule-insns} or @option{-fschedule-insns2}
13831or at @option{-O2} or higher.
13832
d77de738 13833@opindex fsched-rank-heuristic
ddf6fe37 13834@item -fsched-rank-heuristic
d77de738
ML
13835Enable the rank heuristic in the scheduler. This heuristic favors
13836the instruction belonging to a basic block with greater size or frequency.
13837This is enabled by default when scheduling is enabled, i.e.@:
13838with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13839at @option{-O2} or higher.
13840
d77de738 13841@opindex fsched-last-insn-heuristic
ddf6fe37 13842@item -fsched-last-insn-heuristic
d77de738
ML
13843Enable the last-instruction heuristic in the scheduler. This heuristic
13844favors the instruction that is less dependent on the last instruction
13845scheduled. This is enabled by default when scheduling is enabled,
13846i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13847at @option{-O2} or higher.
13848
d77de738 13849@opindex fsched-dep-count-heuristic
ddf6fe37 13850@item -fsched-dep-count-heuristic
d77de738
ML
13851Enable the dependent-count heuristic in the scheduler. This heuristic
13852favors the instruction that has more instructions depending on it.
13853This is enabled by default when scheduling is enabled, i.e.@:
13854with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13855at @option{-O2} or higher.
13856
d77de738 13857@opindex freschedule-modulo-scheduled-loops
ddf6fe37 13858@item -freschedule-modulo-scheduled-loops
d77de738 13859Modulo scheduling is performed before traditional scheduling. If a loop
a0e64a04 13860is modulo scheduled, later scheduling passes may change its schedule.
d77de738
ML
13861Use this option to control that behavior.
13862
d77de738 13863@opindex fselective-scheduling
ddf6fe37 13864@item -fselective-scheduling
d77de738
ML
13865Schedule instructions using selective scheduling algorithm. Selective
13866scheduling runs instead of the first scheduler pass.
13867
d77de738 13868@opindex fselective-scheduling2
ddf6fe37 13869@item -fselective-scheduling2
d77de738
ML
13870Schedule instructions using selective scheduling algorithm. Selective
13871scheduling runs instead of the second scheduler pass.
13872
d77de738 13873@opindex fsel-sched-pipelining
ddf6fe37 13874@item -fsel-sched-pipelining
d77de738
ML
13875Enable software pipelining of innermost loops during selective scheduling.
13876This option has no effect unless one of @option{-fselective-scheduling} or
13877@option{-fselective-scheduling2} is turned on.
13878
d77de738 13879@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 13880@item -fsel-sched-pipelining-outer-loops
d77de738
ML
13881When pipelining loops during selective scheduling, also pipeline outer loops.
13882This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13883
d77de738 13884@opindex fsemantic-interposition
ddf6fe37 13885@item -fsemantic-interposition
a0e64a04 13886Some object formats, like ELF, allow interposing of symbols by the
d77de738
ML
13887dynamic linker.
13888This means that for symbols exported from the DSO, the compiler cannot perform
13889interprocedural propagation, inlining and other optimizations in anticipation
13890that the function or variable in question may change. While this feature is
13891useful, for example, to rewrite memory allocation functions by a debugging
13892implementation, it is expensive in the terms of code quality.
a0e64a04
PN
13893With @option{-fno-semantic-interposition} the compiler assumes that
13894if interposition happens for functions the overwriting function will have
13895precisely the same semantics (and side effects).
d77de738
ML
13896Similarly if interposition happens
13897for variables, the constructor of the variable will be the same. The flag
a0e64a04
PN
13898has no effect for functions explicitly declared inline
13899(where it is never allowed for interposition to change semantics)
d77de738
ML
13900and for symbols explicitly declared weak.
13901
d77de738 13902@opindex fshrink-wrap
ddf6fe37 13903@item -fshrink-wrap
d77de738
ML
13904Emit function prologues only before parts of the function that need it,
13905rather than at the top of the function. This flag is enabled by default at
13906@option{-O} and higher.
13907
d77de738 13908@opindex fshrink-wrap-separate
ddf6fe37 13909@item -fshrink-wrap-separate
d77de738
ML
13910Shrink-wrap separate parts of the prologue and epilogue separately, so that
13911those parts are only executed when needed.
13912This option is on by default, but has no effect unless @option{-fshrink-wrap}
13913is also turned on and the target supports this.
13914
d77de738 13915@opindex fcaller-saves
ddf6fe37 13916@item -fcaller-saves
d77de738
ML
13917Enable allocation of values to registers that are clobbered by
13918function calls, by emitting extra instructions to save and restore the
13919registers around such calls. Such allocation is done only when it
13920seems to result in better code.
13921
13922This option is always enabled by default on certain machines, usually
13923those which have no call-preserved registers to use instead.
13924
13925Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13926
d77de738 13927@opindex fcombine-stack-adjustments
ddf6fe37 13928@item -fcombine-stack-adjustments
d77de738
ML
13929Tracks stack adjustments (pushes and pops) and stack memory references
13930and then tries to find ways to combine them.
13931
13932Enabled by default at @option{-O1} and higher.
13933
d77de738 13934@opindex fipa-ra
ddf6fe37 13935@item -fipa-ra
d77de738
ML
13936Use caller save registers for allocation if those registers are not used by
13937any called function. In that case it is not necessary to save and restore
13938them around calls. This is only possible if called functions are part of
13939same compilation unit as current function and they are compiled before it.
13940
13941Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13942is disabled if generated code will be instrumented for profiling
13943(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13944exactly (this happens on targets that do not expose prologues
13945and epilogues in RTL).
13946
d77de738 13947@opindex fconserve-stack
ddf6fe37 13948@item -fconserve-stack
d77de738
ML
13949Attempt to minimize stack usage. The compiler attempts to use less
13950stack space, even if that makes the program slower. This option
13951implies setting the @option{large-stack-frame} parameter to 100
13952and the @option{large-stack-frame-growth} parameter to 400.
13953
d77de738 13954@opindex ftree-reassoc
ddf6fe37 13955@item -ftree-reassoc
d77de738
ML
13956Perform reassociation on trees. This flag is enabled by default
13957at @option{-O1} and higher.
13958
d77de738 13959@opindex fcode-hoisting
ddf6fe37 13960@item -fcode-hoisting
d77de738
ML
13961Perform code hoisting. Code hoisting tries to move the
13962evaluation of expressions executed on all paths to the function exit
13963as early as possible. This is especially useful as a code size
13964optimization, but it often helps for code speed as well.
13965This flag is enabled by default at @option{-O2} and higher.
13966
d77de738 13967@opindex ftree-pre
ddf6fe37 13968@item -ftree-pre
d77de738
ML
13969Perform partial redundancy elimination (PRE) on trees. This flag is
13970enabled by default at @option{-O2} and @option{-O3}.
13971
d77de738 13972@opindex ftree-partial-pre
ddf6fe37 13973@item -ftree-partial-pre
d77de738
ML
13974Make partial redundancy elimination (PRE) more aggressive. This flag is
13975enabled by default at @option{-O3}.
13976
d77de738 13977@opindex ftree-forwprop
ddf6fe37 13978@item -ftree-forwprop
d77de738
ML
13979Perform forward propagation on trees. This flag is enabled by default
13980at @option{-O1} and higher.
13981
d77de738 13982@opindex ftree-fre
ddf6fe37 13983@item -ftree-fre
d77de738
ML
13984Perform full redundancy elimination (FRE) on trees. The difference
13985between FRE and PRE is that FRE only considers expressions
13986that are computed on all paths leading to the redundant computation.
13987This analysis is faster than PRE, though it exposes fewer redundancies.
13988This flag is enabled by default at @option{-O1} and higher.
13989
d77de738 13990@opindex ftree-phiprop
ddf6fe37 13991@item -ftree-phiprop
d77de738
ML
13992Perform hoisting of loads from conditional pointers on trees. This
13993pass is enabled by default at @option{-O1} and higher.
13994
d77de738 13995@opindex fhoist-adjacent-loads
ddf6fe37 13996@item -fhoist-adjacent-loads
d77de738
ML
13997Speculatively hoist loads from both branches of an if-then-else if the
13998loads are from adjacent locations in the same structure and the target
13999architecture has a conditional move instruction. This flag is enabled
14000by default at @option{-O2} and higher.
14001
d77de738 14002@opindex ftree-copy-prop
ddf6fe37 14003@item -ftree-copy-prop
d77de738
ML
14004Perform copy propagation on trees. This pass eliminates unnecessary
14005copy operations. This flag is enabled by default at @option{-O1} and
14006higher.
14007
d77de738 14008@opindex fipa-pure-const
ddf6fe37 14009@item -fipa-pure-const
d77de738
ML
14010Discover which functions are pure or constant.
14011Enabled by default at @option{-O1} and higher.
14012
d77de738 14013@opindex fipa-reference
ddf6fe37 14014@item -fipa-reference
d77de738
ML
14015Discover which static variables do not escape the
14016compilation unit.
14017Enabled by default at @option{-O1} and higher.
14018
d77de738 14019@opindex fipa-reference-addressable
ddf6fe37 14020@item -fipa-reference-addressable
d77de738
ML
14021Discover read-only, write-only and non-addressable static variables.
14022Enabled by default at @option{-O1} and higher.
14023
6d9fdf4b
KT
14024@opindex fipa-reorder-for-locality
14025@item -fipa-reorder-for-locality
14026Group call chains close together in the binary layout to improve code
14027locality and minimize jump distances between frequently called functions.
14028Unlike @option{-freorder-functions} this pass considers the call
14029chains between functions and groups them together, rather than grouping all
14030hot/normal/cold/never-executed functions into separate sections.
14031Unlike @option{-fprofile-reorder-functions} it aims to improve code locality
14032throughout the runtime of the program rather than focusing on program startup.
14033This option is incompatible with an explicit
14034@option{-flto-partition=} option since it enforces a custom partitioning
14035scheme.
14036If using this option it is recommended to also use profile feedback, but this
14037option is not enabled by default otherwise.
14038
d77de738 14039@opindex fipa-stack-alignment
ddf6fe37 14040@item -fipa-stack-alignment
d77de738
ML
14041Reduce stack alignment on call sites if possible.
14042Enabled by default.
14043
d77de738 14044@opindex fipa-pta
ddf6fe37 14045@item -fipa-pta
d77de738
ML
14046Perform interprocedural pointer analysis and interprocedural modification
14047and reference analysis. This option can cause excessive memory and
14048compile-time usage on large compilation units. It is not enabled by
14049default at any optimization level.
14050
d77de738 14051@opindex fipa-profile
ddf6fe37 14052@item -fipa-profile
d77de738
ML
14053Perform interprocedural profile propagation. The functions called only from
14054cold functions are marked as cold. Also functions executed once (such as
14055@code{cold}, @code{noreturn}, static constructors or destructors) are
14056identified. Cold functions and loop less parts of functions executed once are
14057then optimized for size.
14058Enabled by default at @option{-O1} and higher.
14059
d77de738 14060@opindex fipa-modref
ddf6fe37 14061@item -fipa-modref
d77de738
ML
14062Perform interprocedural mod/ref analysis. This optimization analyzes the side
14063effects of functions (memory locations that are modified or referenced) and
14064enables better optimization across the function call boundary. This flag is
14065enabled by default at @option{-O1} and higher.
14066
d77de738 14067@opindex fipa-cp
ddf6fe37 14068@item -fipa-cp
d77de738
ML
14069Perform interprocedural constant propagation.
14070This optimization analyzes the program to determine when values passed
14071to functions are constants and then optimizes accordingly.
14072This optimization can substantially increase performance
14073if the application has constants passed to functions.
14074This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
14075It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14076
d77de738 14077@opindex fipa-cp-clone
ddf6fe37 14078@item -fipa-cp-clone
d77de738
ML
14079Perform function cloning to make interprocedural constant propagation stronger.
14080When enabled, interprocedural constant propagation performs function cloning
14081when externally visible function can be called with constant arguments.
14082Because this optimization can create multiple copies of functions,
14083it may significantly increase code size
14084(see @option{--param ipa-cp-unit-growth=@var{value}}).
14085This flag is enabled by default at @option{-O3}.
14086It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14087
d77de738 14088@opindex fipa-bit-cp
ddf6fe37 14089@item -fipa-bit-cp
d77de738
ML
14090When enabled, perform interprocedural bitwise constant
14091propagation. This flag is enabled by default at @option{-O2} and
14092by @option{-fprofile-use} and @option{-fauto-profile}.
a0e64a04 14093It requires that @option{-fipa-cp} is enabled.
d77de738 14094
d77de738 14095@opindex fipa-vrp
ddf6fe37 14096@item -fipa-vrp
d77de738
ML
14097When enabled, perform interprocedural propagation of value
14098ranges. This flag is enabled by default at @option{-O2}. It requires
14099that @option{-fipa-cp} is enabled.
14100
d77de738 14101@opindex fipa-icf
ddf6fe37 14102@item -fipa-icf
d77de738
ML
14103Perform Identical Code Folding for functions and read-only variables.
14104The optimization reduces code size and may disturb unwind stacks by replacing
14105a function by equivalent one with a different name. The optimization works
14106more effectively with link-time optimization enabled.
14107
14108Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
14109works on different levels and thus the optimizations are not same - there are
14110equivalences that are found only by GCC and equivalences found only by Gold.
14111
14112This flag is enabled by default at @option{-O2} and @option{-Os}.
14113
792f97b4
RS
14114@opindex flate-combine-instructions
14115@item -flate-combine-instructions
14116Enable two instruction combination passes that run relatively late in the
14117compilation process. One of the passes runs before register allocation and
14118the other after register allocation. The main aim of the passes is to
14119substitute definitions into all uses.
14120
14121Most targets enable this flag by default at @option{-O2} and @option{-Os}.
14122
d77de738 14123@opindex flive-patching
ddf6fe37 14124@item -flive-patching=@var{level}
d77de738
ML
14125Control GCC's optimizations to produce output suitable for live-patching.
14126
14127If the compiler's optimization uses a function's body or information extracted
14128from its body to optimize/change another function, the latter is called an
14129impacted function of the former. If a function is patched, its impacted
14130functions should be patched too.
14131
14132The impacted functions are determined by the compiler's interprocedural
14133optimizations. For example, a caller is impacted when inlining a function
14134into its caller,
14135cloning a function and changing its caller to call this new clone,
14136or extracting a function's pureness/constness information to optimize
14137its direct or indirect callers, etc.
14138
14139Usually, the more IPA optimizations enabled, the larger the number of
14140impacted functions for each function. In order to control the number of
14141impacted functions and more easily compute the list of impacted function,
14142IPA optimizations can be partially enabled at two different levels.
14143
14144The @var{level} argument should be one of the following:
14145
14146@table @samp
14147
14148@item inline-clone
14149
14150Only enable inlining and cloning optimizations, which includes inlining,
14151cloning, interprocedural scalar replacement of aggregates and partial inlining.
14152As a result, when patching a function, all its callers and its clones'
14153callers are impacted, therefore need to be patched as well.
14154
14155@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
14156@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
14157-fipa-icf -fipa-icf-functions -fipa-icf-variables
14158-fipa-bit-cp -fipa-vrp -fipa-pure-const
14159-fipa-reference-addressable
d77de738
ML
14160-fipa-stack-alignment -fipa-modref}
14161
14162@item inline-only-static
14163
14164Only enable inlining of static functions.
14165As a result, when patching a static function, all its callers are impacted
14166and so need to be patched as well.
14167
14168In addition to all the flags that @option{-flive-patching=inline-clone}
14169disables,
14170@option{-flive-patching=inline-only-static} disables the following additional
14171optimization flags:
14172@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
14173
14174@end table
14175
14176When @option{-flive-patching} is specified without any value, the default value
14177is @var{inline-clone}.
14178
14179This flag is disabled by default.
14180
14181Note that @option{-flive-patching} is not supported with link-time optimization
14182(@option{-flto}).
14183
d77de738 14184@opindex fisolate-erroneous-paths-dereference
ddf6fe37 14185@item -fisolate-erroneous-paths-dereference
d77de738
ML
14186Detect paths that trigger erroneous or undefined behavior due to
14187dereferencing a null pointer. Isolate those paths from the main control
14188flow and turn the statement with erroneous or undefined behavior into a trap.
14189This flag is enabled by default at @option{-O2} and higher and depends on
14190@option{-fdelete-null-pointer-checks} also being enabled.
14191
d77de738 14192@opindex fisolate-erroneous-paths-attribute
ddf6fe37 14193@item -fisolate-erroneous-paths-attribute
d77de738
ML
14194Detect paths that trigger erroneous or undefined behavior due to a null value
14195being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
14196attribute. Isolate those paths from the main control flow and turn the
14197statement with erroneous or undefined behavior into a trap. This is not
14198currently enabled, but may be enabled by @option{-O2} in the future.
14199
d77de738 14200@opindex ftree-sink
ddf6fe37 14201@item -ftree-sink
d77de738
ML
14202Perform forward store motion on trees. This flag is
14203enabled by default at @option{-O1} and higher.
14204
d77de738 14205@opindex ftree-bit-ccp
ddf6fe37 14206@item -ftree-bit-ccp
d77de738
ML
14207Perform sparse conditional bit constant propagation on trees and propagate
14208pointer alignment information.
14209This pass only operates on local scalar variables and is enabled by default
14210at @option{-O1} and higher, except for @option{-Og}.
14211It requires that @option{-ftree-ccp} is enabled.
14212
d77de738 14213@opindex ftree-ccp
ddf6fe37 14214@item -ftree-ccp
d77de738
ML
14215Perform sparse conditional constant propagation (CCP) on trees. This
14216pass only operates on local scalar variables and is enabled by default
14217at @option{-O1} and higher.
14218
d77de738 14219@opindex fssa-backprop
ddf6fe37 14220@item -fssa-backprop
d77de738
ML
14221Propagate information about uses of a value up the definition chain
14222in order to simplify the definitions. For example, this pass strips
14223sign operations if the sign of a value never matters. The flag is
14224enabled by default at @option{-O1} and higher.
14225
d77de738 14226@opindex fssa-phiopt
ddf6fe37 14227@item -fssa-phiopt
d77de738
ML
14228Perform pattern matching on SSA PHI nodes to optimize conditional
14229code. This pass is enabled by default at @option{-O1} and higher,
14230except for @option{-Og}.
14231
d77de738 14232@opindex ftree-switch-conversion
ddf6fe37 14233@item -ftree-switch-conversion
d77de738
ML
14234Perform conversion of simple initializations in a switch to
14235initializations from a scalar array. This flag is enabled by default
14236at @option{-O2} and higher.
14237
d77de738 14238@opindex ftree-tail-merge
ddf6fe37 14239@item -ftree-tail-merge
d77de738
ML
14240Look for identical code sequences. When found, replace one with a jump to the
14241other. This optimization is known as tail merging or cross jumping. This flag
14242is enabled by default at @option{-O2} and higher. The compilation time
14243in this pass can
14244be limited using @option{max-tail-merge-comparisons} parameter and
14245@option{max-tail-merge-iterations} parameter.
14246
f6b0dc1b
SL
14247@opindex ftree-cselim
14248@item -ftree-cselim
14249Perform conditional store elimination on trees. This flag is enabled by
14250default at @option{-O1} and higher on targets that have conditional
14251move instructions.
14252
d77de738 14253@opindex ftree-dce
ddf6fe37 14254@item -ftree-dce
d77de738
ML
14255Perform dead code elimination (DCE) on trees. This flag is enabled by
14256default at @option{-O1} and higher.
14257
d77de738 14258@opindex ftree-builtin-call-dce
ddf6fe37 14259@item -ftree-builtin-call-dce
d77de738
ML
14260Perform conditional dead code elimination (DCE) for calls to built-in functions
14261that may set @code{errno} but are otherwise free of side effects. This flag is
14262enabled by default at @option{-O2} and higher if @option{-Os} is not also
14263specified.
14264
d77de738
ML
14265@opindex ffinite-loops
14266@opindex fno-finite-loops
ddf6fe37 14267@item -ffinite-loops
d77de738
ML
14268Assume that a loop with an exit will eventually take the exit and not loop
14269indefinitely. This allows the compiler to remove loops that otherwise have
14270no side-effects, not considering eventual endless looping as such.
14271
14272This option is enabled by default at @option{-O2} for C++ with -std=c++11
14273or higher.
14274
d77de738 14275@opindex ftree-dominator-opts
ddf6fe37 14276@item -ftree-dominator-opts
d77de738
ML
14277Perform a variety of simple scalar cleanups (constant/copy
14278propagation, redundancy elimination, range propagation and expression
14279simplification) based on a dominator tree traversal. This also
14280performs jump threading (to reduce jumps to jumps). This flag is
14281enabled by default at @option{-O1} and higher.
14282
d77de738 14283@opindex ftree-dse
ddf6fe37 14284@item -ftree-dse
d77de738
ML
14285Perform dead store elimination (DSE) on trees. A dead store is a store into
14286a memory location that is later overwritten by another store without
14287any intervening loads. In this case the earlier store can be deleted. This
14288flag is enabled by default at @option{-O1} and higher.
14289
d77de738 14290@opindex ftree-ch
ddf6fe37 14291@item -ftree-ch
d77de738
ML
14292Perform loop header copying on trees. This is beneficial since it increases
14293effectiveness of code motion optimizations. It also saves one jump. This flag
14294is enabled by default at @option{-O1} and higher. It is not enabled
14295for @option{-Os}, since it usually increases code size.
14296
d77de738 14297@opindex ftree-loop-optimize
ddf6fe37 14298@item -ftree-loop-optimize
d77de738
ML
14299Perform loop optimizations on trees. This flag is enabled by default
14300at @option{-O1} and higher.
14301
d77de738
ML
14302@opindex ftree-loop-linear
14303@opindex floop-strip-mine
14304@opindex floop-block
ddf6fe37
AA
14305@item -ftree-loop-linear
14306@itemx -floop-strip-mine
14307@itemx -floop-block
d77de738
ML
14308Perform loop nest optimizations. Same as
14309@option{-floop-nest-optimize}. To use this code transformation, GCC has
14310to be configured with @option{--with-isl} to enable the Graphite loop
14311transformation infrastructure.
14312
d77de738 14313@opindex fgraphite-identity
ddf6fe37 14314@item -fgraphite-identity
d77de738
ML
14315Enable the identity transformation for graphite. For every SCoP we generate
14316the polyhedral representation and transform it back to gimple. Using
14317@option{-fgraphite-identity} we can check the costs or benefits of the
14318GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
14319are also performed by the code generator isl, like index splitting and
14320dead code elimination in loops.
14321
d77de738 14322@opindex floop-nest-optimize
ddf6fe37 14323@item -floop-nest-optimize
d77de738
ML
14324Enable the isl based loop nest optimizer. This is a generic loop nest
14325optimizer based on the Pluto optimization algorithms. It calculates a loop
14326structure optimized for data-locality and parallelism. This option
14327is experimental.
14328
d77de738 14329@opindex floop-parallelize-all
ddf6fe37 14330@item -floop-parallelize-all
d77de738
ML
14331Use the Graphite data dependence analysis to identify loops that can
14332be parallelized. Parallelize all the loops that can be analyzed to
14333not contain loop carried dependences without checking that it is
14334profitable to parallelize the loops.
14335
d77de738 14336@opindex ftree-coalesce-vars
ddf6fe37 14337@item -ftree-coalesce-vars
d77de738
ML
14338While transforming the program out of the SSA representation, attempt to
14339reduce copying by coalescing versions of different user-defined
14340variables, instead of just compiler temporaries. This may severely
14341limit the ability to debug an optimized program compiled with
14342@option{-fno-var-tracking-assignments}. In the negated form, this flag
14343prevents SSA coalescing of user variables. This option is enabled by
14344default if optimization is enabled, and it does very little otherwise.
14345
d77de738 14346@opindex ftree-loop-if-convert
ddf6fe37 14347@item -ftree-loop-if-convert
d77de738
ML
14348Attempt to transform conditional jumps in the innermost loops to
14349branch-less equivalents. The intent is to remove control-flow from
14350the innermost loops in order to improve the ability of the
14351vectorization pass to handle these loops. This is enabled by default
14352if vectorization is enabled.
14353
d77de738 14354@opindex ftree-loop-distribution
ddf6fe37 14355@item -ftree-loop-distribution
d77de738
ML
14356Perform loop distribution. This flag can improve cache performance on
14357big loop bodies and allow further loop optimizations, like
14358parallelization or vectorization, to take place. For example, the loop
14359@smallexample
14360DO I = 1, N
14361 A(I) = B(I) + C
14362 D(I) = E(I) * F
14363ENDDO
14364@end smallexample
14365is transformed to
14366@smallexample
14367DO I = 1, N
14368 A(I) = B(I) + C
14369ENDDO
14370DO I = 1, N
14371 D(I) = E(I) * F
14372ENDDO
14373@end smallexample
14374This flag is enabled by default at @option{-O3}.
14375It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14376
d77de738 14377@opindex ftree-loop-distribute-patterns
ddf6fe37 14378@item -ftree-loop-distribute-patterns
d77de738
ML
14379Perform loop distribution of patterns that can be code generated with
14380calls to a library. This flag is enabled by default at @option{-O2} and
14381higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
14382
14383This pass distributes the initialization loops and generates a call to
14384memset zero. For example, the loop
14385@smallexample
14386DO I = 1, N
14387 A(I) = 0
14388 B(I) = A(I) + I
14389ENDDO
14390@end smallexample
14391is transformed to
14392@smallexample
14393DO I = 1, N
14394 A(I) = 0
14395ENDDO
14396DO I = 1, N
14397 B(I) = A(I) + I
14398ENDDO
14399@end smallexample
14400and the initialization loop is transformed into a call to memset zero.
d77de738 14401
d77de738 14402@opindex floop-interchange
ddf6fe37 14403@item -floop-interchange
d77de738
ML
14404Perform loop interchange outside of graphite. This flag can improve cache
14405performance on loop nest and allow further loop optimizations, like
14406vectorization, to take place. For example, the loop
14407@smallexample
14408for (int i = 0; i < N; i++)
14409 for (int j = 0; j < N; j++)
14410 for (int k = 0; k < N; k++)
14411 c[i][j] = c[i][j] + a[i][k]*b[k][j];
14412@end smallexample
14413is transformed to
14414@smallexample
14415for (int i = 0; i < N; i++)
14416 for (int k = 0; k < N; k++)
14417 for (int j = 0; j < N; j++)
14418 c[i][j] = c[i][j] + a[i][k]*b[k][j];
14419@end smallexample
14420This flag is enabled by default at @option{-O3}.
14421It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14422
d77de738 14423@opindex floop-unroll-and-jam
ddf6fe37 14424@item -floop-unroll-and-jam
d77de738
ML
14425Apply unroll and jam transformations on feasible loops. In a loop
14426nest this unrolls the outer loop by some factor and fuses the resulting
14427multiple inner loops. This flag is enabled by default at @option{-O3}.
14428It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14429
d77de738 14430@opindex ftree-loop-im
ddf6fe37 14431@item -ftree-loop-im
d77de738
ML
14432Perform loop invariant motion on trees. This pass moves only invariants that
14433are hard to handle at RTL level (function calls, operations that expand to
14434nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
14435operands of conditions that are invariant out of the loop, so that we can use
14436just trivial invariantness analysis in loop unswitching. The pass also includes
14437store motion.
14438
d77de738 14439@opindex ftree-loop-ivcanon
ddf6fe37 14440@item -ftree-loop-ivcanon
d77de738
ML
14441Create a canonical counter for number of iterations in loops for which
14442determining number of iterations requires complicated analysis. Later
14443optimizations then may determine the number easily. Useful especially
14444in connection with unrolling.
14445
d77de738 14446@opindex ftree-scev-cprop
ddf6fe37 14447@item -ftree-scev-cprop
d77de738
ML
14448Perform final value replacement. If a variable is modified in a loop
14449in such a way that its value when exiting the loop can be determined using
14450only its initial value and the number of loop iterations, replace uses of
14451the final value by such a computation, provided it is sufficiently cheap.
14452This reduces data dependencies and may allow further simplifications.
14453Enabled by default at @option{-O1} and higher.
14454
d77de738 14455@opindex fivopts
ddf6fe37 14456@item -fivopts
d77de738
ML
14457Perform induction variable optimizations (strength reduction, induction
14458variable merging and induction variable elimination) on trees.
d91aab4d 14459Enabled by default at @option{-O1} and higher.
d77de738 14460
d77de738 14461@opindex ftree-parallelize-loops
ddf6fe37 14462@item -ftree-parallelize-loops=n
d77de738
ML
14463Parallelize loops, i.e., split their iteration space to run in n threads.
14464This is only possible for loops whose iterations are independent
14465and can be arbitrarily reordered. The optimization is only
14466profitable on multiprocessor machines, for loops that are CPU-intensive,
14467rather than constrained e.g.@: by memory bandwidth. This option
14468implies @option{-pthread}, and thus is only supported on targets
14469that have support for @option{-pthread}.
14470
d77de738 14471@opindex ftree-pta
ddf6fe37 14472@item -ftree-pta
d77de738
ML
14473Perform function-local points-to analysis on trees. This flag is
14474enabled by default at @option{-O1} and higher, except for @option{-Og}.
14475
d77de738 14476@opindex ftree-sra
ddf6fe37 14477@item -ftree-sra
d77de738
ML
14478Perform scalar replacement of aggregates. This pass replaces structure
14479references with scalars to prevent committing structures to memory too
14480early. This flag is enabled by default at @option{-O1} and higher,
14481except for @option{-Og}.
14482
d77de738 14483@opindex fstore-merging
ddf6fe37 14484@item -fstore-merging
d77de738
ML
14485Perform merging of narrow stores to consecutive memory addresses. This pass
14486merges contiguous stores of immediate values narrower than a word into fewer
14487wider stores to reduce the number of instructions. This is enabled by default
14488at @option{-O2} and higher as well as @option{-Os}.
14489
d77de738 14490@opindex ftree-ter
ddf6fe37 14491@item -ftree-ter
d77de738
ML
14492Perform temporary expression replacement during the SSA->normal phase. Single
14493use/single def temporaries are replaced at their use location with their
14494defining expression. This results in non-GIMPLE code, but gives the expanders
14495much more complex trees to work on resulting in better RTL generation. This is
14496enabled by default at @option{-O1} and higher.
14497
d77de738 14498@opindex ftree-slsr
ddf6fe37 14499@item -ftree-slsr
d77de738
ML
14500Perform straight-line strength reduction on trees. This recognizes related
14501expressions involving multiplications and replaces them by less expensive
14502calculations when possible. This is enabled by default at @option{-O1} and
14503higher.
14504
d77de738 14505@opindex ftree-vectorize
ddf6fe37 14506@item -ftree-vectorize
d77de738
ML
14507Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
14508and @option{-ftree-slp-vectorize} if not explicitly specified.
14509
d77de738 14510@opindex ftree-loop-vectorize
ddf6fe37 14511@item -ftree-loop-vectorize
d77de738
ML
14512Perform loop vectorization on trees. This flag is enabled by default at
14513@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
14514and @option{-fauto-profile}.
14515
d77de738 14516@opindex ftree-slp-vectorize
ddf6fe37 14517@item -ftree-slp-vectorize
d77de738
ML
14518Perform basic block vectorization on trees. This flag is enabled by default at
14519@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
14520and @option{-fauto-profile}.
14521
d77de738 14522@opindex ftrivial-auto-var-init
ddf6fe37 14523@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
14524Initialize automatic variables with either a pattern or with zeroes to increase
14525the security and predictability of a program by preventing uninitialized memory
14526disclosure and use.
14527GCC still considers an automatic variable that doesn't have an explicit
14528initializer as uninitialized, @option{-Wuninitialized} and
14529@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
14530warning messages on such automatic variables and the compiler will
14531perform optimization as if the variable were uninitialized.
d77de738
ML
14532With this option, GCC will also initialize any padding of automatic variables
14533that have structure or union types to zeroes.
14534However, the current implementation cannot initialize automatic variables that
14535are declared between the controlling expression and the first case of a
14536@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
14537such cases.
14538
14539The three values of @var{choice} are:
14540
14541@itemize @bullet
14542@item
14543@samp{uninitialized} doesn't initialize any automatic variables.
14544This is C and C++'s default.
14545
14546@item
14547@samp{pattern} Initialize automatic variables with values which will likely
14548transform logic bugs into crashes down the line, are easily recognized in a
14549crash dump and without being values that programmers can rely on for useful
14550program semantics.
14551The current value is byte-repeatable pattern with byte "0xFE".
14552The values used for pattern initialization might be changed in the future.
14553
14554@item
14555@samp{zero} Initialize automatic variables with zeroes.
14556@end itemize
14557
14558The default is @samp{uninitialized}.
14559
862867ea
AO
14560Note that the initializer values, whether @samp{zero} or @samp{pattern},
14561refer to data representation (in memory or machine registers), rather
14562than to their interpretation as numerical values. This distinction may
14563be important in languages that support types with biases or implicit
14564multipliers, and with such extensions as @samp{hardbool} (@pxref{Type
14565Attributes}). For example, a variable that uses 8 bits to represent
14566(biased) quantities in the @code{range 160..400} will be initialized
14567with the bit patterns @code{0x00} or @code{0xFE}, depending on
14568@var{choice}, whether or not these representations stand for values in
14569that range, and even if they do, the interpretation of the value held by
14570the variable will depend on the bias. A @samp{hardbool} variable that
14571uses say @code{0X5A} and @code{0xA5} for @code{false} and @code{true},
14572respectively, will trap with either @samp{choice} of trivial
14573initializer, i.e., @samp{zero} initialization will not convert to the
14574representation for @code{false}, even if it would for a @code{static}
14575variable of the same type. This means the initializer pattern doesn't
14576generally depend on the type of the initialized variable. One notable
14577exception is that (non-hardened) boolean variables that fit in registers
14578are initialized with @code{false} (zero), even when @samp{pattern} is
14579requested.
14580
d77de738
ML
14581You can control this behavior for a specific variable by using the variable
14582attribute @code{uninitialized} (@pxref{Variable Attributes}).
14583
d77de738 14584@opindex fvect-cost-model
ddf6fe37 14585@item -fvect-cost-model=@var{model}
d77de738
ML
14586Alter the cost model used for vectorization. The @var{model} argument
14587should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
14588@samp{very-cheap}.
14589With the @samp{unlimited} model the vectorized code-path is assumed
14590to be profitable while with the @samp{dynamic} model a runtime check
14591guards the vectorized code-path to enable it only for iteration
14592counts that will likely execute faster than when executing the original
14593scalar loop. The @samp{cheap} model disables vectorization of
14594loops where doing so would be cost prohibitive for example due to
14595required runtime checks for data dependence or alignment but otherwise
70c3db51 14596is equal to the @samp{dynamic} model. The @samp{very-cheap} model disables
14597vectorization of loops when any runtime check for data dependence or alignment
14598is required, it also disables vectorization of epilogue loops but otherwise is
14599equal to the @samp{cheap} model.
d77de738
ML
14600
14601The default cost model depends on other optimization flags and is
14602either @samp{dynamic} or @samp{cheap}.
14603
d77de738 14604@opindex fsimd-cost-model
ddf6fe37 14605@item -fsimd-cost-model=@var{model}
d77de738
ML
14606Alter the cost model used for vectorization of loops marked with the OpenMP
14607simd directive. The @var{model} argument should be one of
14608@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
14609have the same meaning as described in @option{-fvect-cost-model} and by
14610default a cost model defined with @option{-fvect-cost-model} is used.
14611
d77de738 14612@opindex ftree-vrp
ddf6fe37 14613@item -ftree-vrp
d77de738
ML
14614Perform Value Range Propagation on trees. This is similar to the
14615constant propagation pass, but instead of values, ranges of values are
14616propagated. This allows the optimizers to remove unnecessary range
14617checks like array bound checks and null pointer checks. This is
14618enabled by default at @option{-O2} and higher. Null pointer check
14619elimination is only done if @option{-fdelete-null-pointer-checks} is
14620enabled.
14621
d77de738 14622@opindex fsplit-paths
ddf6fe37 14623@item -fsplit-paths
d77de738
ML
14624Split paths leading to loop backedges. This can improve dead code
14625elimination and common subexpression elimination. This is enabled by
14626default at @option{-O3} and above.
14627
d77de738 14628@opindex fsplit-ivs-in-unroller
ddf6fe37 14629@item -fsplit-ivs-in-unroller
d77de738
ML
14630Enables expression of values of induction variables in later iterations
14631of the unrolled loop using the value in the first iteration. This breaks
14632long dependency chains, thus improving efficiency of the scheduling passes.
14633
14634A combination of @option{-fweb} and CSE is often sufficient to obtain the
14635same effect. However, that is not reliable in cases where the loop body
14636is more complicated than a single basic block. It also does not work at all
14637on some architectures due to restrictions in the CSE pass.
14638
14639This optimization is enabled by default.
14640
d77de738 14641@opindex fvariable-expansion-in-unroller
ddf6fe37 14642@item -fvariable-expansion-in-unroller
d77de738
ML
14643With this option, the compiler creates multiple copies of some
14644local variables when unrolling a loop, which can result in superior code.
14645
14646This optimization is enabled by default for PowerPC targets, but disabled
14647by default otherwise.
14648
d77de738 14649@opindex fpartial-inlining
ddf6fe37 14650@item -fpartial-inlining
d77de738
ML
14651Inline parts of functions. This option has any effect only
14652when inlining itself is turned on by the @option{-finline-functions}
14653or @option{-finline-small-functions} options.
14654
14655Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14656
d77de738 14657@opindex fpredictive-commoning
ddf6fe37 14658@item -fpredictive-commoning
d77de738
ML
14659Perform predictive commoning optimization, i.e., reusing computations
14660(especially memory loads and stores) performed in previous
14661iterations of loops.
14662
14663This option is enabled at level @option{-O3}.
14664It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14665
d77de738 14666@opindex fprefetch-loop-arrays
ddf6fe37 14667@item -fprefetch-loop-arrays
d77de738
ML
14668If supported by the target machine, generate instructions to prefetch
14669memory to improve the performance of loops that access large arrays.
14670
14671This option may generate better or worse code; results are highly
14672dependent on the structure of loops within the source code.
14673
14674Disabled at level @option{-Os}.
14675
d77de738
ML
14676@opindex fno-printf-return-value
14677@opindex fprintf-return-value
ddf6fe37 14678@item -fno-printf-return-value
d77de738
ML
14679Do not substitute constants for known return value of formatted output
14680functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
14681@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
14682transformation allows GCC to optimize or even eliminate branches based
14683on the known return value of these functions called with arguments that
14684are either constant, or whose values are known to be in a range that
14685makes determining the exact return value possible. For example, when
14686@option{-fprintf-return-value} is in effect, both the branch and the
14687body of the @code{if} statement (but not the call to @code{snprint})
14688can be optimized away when @code{i} is a 32-bit or smaller integer
14689because the return value is guaranteed to be at most 8.
14690
14691@smallexample
14692char buf[9];
14693if (snprintf (buf, "%08x", i) >= sizeof buf)
14694 @dots{}
14695@end smallexample
14696
14697The @option{-fprintf-return-value} option relies on other optimizations
14698and yields best results with @option{-O2} and above. It works in tandem
14699with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
14700options. The @option{-fprintf-return-value} option is enabled by default.
14701
d77de738
ML
14702@opindex fno-peephole
14703@opindex fpeephole
14704@opindex fno-peephole2
14705@opindex fpeephole2
ddf6fe37
AA
14706@item -fno-peephole
14707@itemx -fno-peephole2
d77de738
ML
14708Disable any machine-specific peephole optimizations. The difference
14709between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
14710are implemented in the compiler; some targets use one, some use the
14711other, a few use both.
14712
14713@option{-fpeephole} is enabled by default.
14714@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14715
d77de738
ML
14716@opindex fno-guess-branch-probability
14717@opindex fguess-branch-probability
ddf6fe37 14718@item -fno-guess-branch-probability
d77de738
ML
14719Do not guess branch probabilities using heuristics.
14720
14721GCC uses heuristics to guess branch probabilities if they are
14722not provided by profiling feedback (@option{-fprofile-arcs}). These
14723heuristics are based on the control flow graph. If some branch probabilities
14724are specified by @code{__builtin_expect}, then the heuristics are
14725used to guess branch probabilities for the rest of the control flow graph,
14726taking the @code{__builtin_expect} info into account. The interactions
14727between the heuristics and @code{__builtin_expect} can be complex, and in
14728some cases, it may be useful to disable the heuristics so that the effects
14729of @code{__builtin_expect} are easier to understand.
14730
14731It is also possible to specify expected probability of the expression
14732with @code{__builtin_expect_with_probability} built-in function.
14733
14734The default is @option{-fguess-branch-probability} at levels
14735@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
14736
d77de738 14737@opindex freorder-blocks
ddf6fe37 14738@item -freorder-blocks
d77de738
ML
14739Reorder basic blocks in the compiled function in order to reduce number of
14740taken branches and improve code locality.
14741
14742Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14743
d77de738 14744@opindex freorder-blocks-algorithm
ddf6fe37 14745@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
14746Use the specified algorithm for basic block reordering. The
14747@var{algorithm} argument can be @samp{simple}, which does not increase
14748code size (except sometimes due to secondary effects like alignment),
14749or @samp{stc}, the ``software trace cache'' algorithm, which tries to
14750put all often executed code together, minimizing the number of branches
14751executed by making extra copies of code.
14752
14753The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
14754@samp{stc} at levels @option{-O2}, @option{-O3}.
14755
d77de738 14756@opindex freorder-blocks-and-partition
ddf6fe37 14757@item -freorder-blocks-and-partition
d77de738
ML
14758In addition to reordering basic blocks in the compiled function, in order
14759to reduce number of taken branches, partitions hot and cold basic blocks
14760into separate sections of the assembly and @file{.o} files, to improve
14761paging and cache locality performance.
14762
14763This optimization is automatically turned off in the presence of
14764exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
14765section attribute and on any architecture that does not support named
14766sections. When @option{-fsplit-stack} is used this option is not
14767enabled by default (to avoid linker errors), but may be enabled
14768explicitly (if using a working linker).
14769
14770Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
14771
d77de738 14772@opindex freorder-functions
ddf6fe37 14773@item -freorder-functions
d77de738 14774Reorder functions in the object file in order to
6d9fdf4b
KT
14775improve code locality. Unlike @option{-fipa-reorder-for-locality} this option
14776prioritises grouping all functions within a category
14777(hot/normal/cold/never-executed) together.
14778This is implemented by using special subsections @code{.text.hot} for most
14779frequently executed functions and @code{.text.unlikely} for unlikely executed
14780functions. Reordering is done by the linker so object file format must support
14781named sections and linker must place them in a reasonable way.
d77de738
ML
14782
14783This option isn't effective unless you either provide profile feedback
a0e64a04 14784(see @option{-fprofile-arcs} for details) or manually annotate functions with
d77de738
ML
14785@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
14786
14787Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14788
d77de738 14789@opindex fstrict-aliasing
ddf6fe37 14790@item -fstrict-aliasing
d77de738
ML
14791Allow the compiler to assume the strictest aliasing rules applicable to
14792the language being compiled. For C (and C++), this activates
7c47badc
SJ
14793optimizations based on the type of expressions. In particular, accessing
14794an object of one type via an expression of a different type is not allowed,
14795unless the types are @dfn{compatible types}, differ only in signedness or
14796qualifiers, or the expression has a character type. Accessing scalar
14797objects via a corresponding vector type is also allowed.
14798
14799For example, an @code{unsigned int} can alias an @code{int}, but not a
14800@code{void*} or a @code{double}. A character type may alias any other type.
d77de738
ML
14801
14802@anchor{Type-punning}Pay special attention to code like this:
14803@smallexample
14804union a_union @{
14805 int i;
14806 double d;
14807@};
14808
14809int f() @{
14810 union a_union t;
14811 t.d = 3.0;
14812 return t.i;
14813@}
14814@end smallexample
14815The practice of reading from a different union member than the one most
14816recently written to (called ``type-punning'') is common. Even with
14817@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
14818is accessed through the union type. So, the code above works as
14819expected. @xref{Structures unions enumerations and bit-fields
14820implementation}. However, this code might not:
14821@smallexample
14822int f() @{
14823 union a_union t;
14824 int* ip;
14825 t.d = 3.0;
14826 ip = &t.i;
14827 return *ip;
14828@}
14829@end smallexample
14830
14831Similarly, access by taking the address, casting the resulting pointer
14832and dereferencing the result has undefined behavior, even if the cast
14833uses a union type, e.g.:
14834@smallexample
14835int f() @{
14836 double d = 3.0;
14837 return ((union a_union *) &d)->i;
14838@}
14839@end smallexample
14840
14841The @option{-fstrict-aliasing} option is enabled at levels
14842@option{-O2}, @option{-O3}, @option{-Os}.
14843
d77de738 14844@opindex fipa-strict-aliasing
ddf6fe37 14845@item -fipa-strict-aliasing
d77de738
ML
14846Controls whether rules of @option{-fstrict-aliasing} are applied across
14847function boundaries. Note that if multiple functions gets inlined into a
14848single function the memory accesses are no longer considered to be crossing a
14849function boundary.
14850
14851The @option{-fipa-strict-aliasing} option is enabled by default and is
14852effective only in combination with @option{-fstrict-aliasing}.
14853
ddf6fe37 14854@opindex falign-functions
d77de738
ML
14855@item -falign-functions
14856@itemx -falign-functions=@var{n}
14857@itemx -falign-functions=@var{n}:@var{m}
14858@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
14859@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14860Align the start of functions to the next power-of-two greater than or
14861equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
14862least the first @var{m} bytes of the function can be fetched by the CPU
14863without crossing an @var{n}-byte alignment boundary.
0f5a9a00
JH
14864This is an optimization of code performance and alignment is ignored for
14865functions considered cold. If alignment is required for all functions,
14866use @option{-fmin-function-alignment}.
d77de738
ML
14867
14868If @var{m} is not specified, it defaults to @var{n}.
14869
14870Examples: @option{-falign-functions=32} aligns functions to the next
1487132-byte boundary, @option{-falign-functions=24} aligns to the next
1487232-byte boundary only if this can be done by skipping 23 bytes or less,
14873@option{-falign-functions=32:7} aligns to the next
1487432-byte boundary only if this can be done by skipping 6 bytes or less.
14875
14876The second pair of @var{n2}:@var{m2} values allows you to specify
14877a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
14878the next 64-byte boundary if this can be done by skipping 6 bytes or less,
14879otherwise aligns to the next 32-byte boundary if this can be done
14880by skipping 2 bytes or less.
14881If @var{m2} is not specified, it defaults to @var{n2}.
14882
14883Some assemblers only support this flag when @var{n} is a power of two;
14884in that case, it is rounded up.
14885
14886@option{-fno-align-functions} and @option{-falign-functions=1} are
14887equivalent and mean that functions are not aligned.
14888
14889If @var{n} is not specified or is zero, use a machine-dependent default.
14890The maximum allowed @var{n} option value is 65536.
14891
14892Enabled at levels @option{-O2}, @option{-O3}.
14893
14894@item -flimit-function-alignment
14895If this option is enabled, the compiler tries to avoid unnecessarily
14896overaligning functions. It attempts to instruct the assembler to align
14897by the amount specified by @option{-falign-functions}, but not to
14898skip more bytes than the size of the function.
14899
ddf6fe37 14900@opindex falign-labels
d77de738
ML
14901@item -falign-labels
14902@itemx -falign-labels=@var{n}
14903@itemx -falign-labels=@var{n}:@var{m}
14904@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
14905@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14906Align all branch targets to a power-of-two boundary.
14907
14908Parameters of this option are analogous to the @option{-falign-functions} option.
14909@option{-fno-align-labels} and @option{-falign-labels=1} are
14910equivalent and mean that labels are not aligned.
14911
14912If @option{-falign-loops} or @option{-falign-jumps} are applicable and
14913are greater than this value, then their values are used instead.
14914
14915If @var{n} is not specified or is zero, use a machine-dependent default
14916which is very likely to be @samp{1}, meaning no alignment.
14917The maximum allowed @var{n} option value is 65536.
14918
14919Enabled at levels @option{-O2}, @option{-O3}.
14920
ddf6fe37 14921@opindex falign-loops
d77de738
ML
14922@item -falign-loops
14923@itemx -falign-loops=@var{n}
14924@itemx -falign-loops=@var{n}:@var{m}
14925@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
14926@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14927Align loops to a power-of-two boundary. If the loops are executed
14928many times, this makes up for any execution of the dummy padding
14929instructions.
0f5a9a00
JH
14930This is an optimization of code performance and alignment is ignored for
14931loops considered cold.
d77de738
ML
14932
14933If @option{-falign-labels} is greater than this value, then its value
14934is used instead.
14935
14936Parameters of this option are analogous to the @option{-falign-functions} option.
14937@option{-fno-align-loops} and @option{-falign-loops=1} are
14938equivalent and mean that loops are not aligned.
14939The maximum allowed @var{n} option value is 65536.
14940
14941If @var{n} is not specified or is zero, use a machine-dependent default.
14942
14943Enabled at levels @option{-O2}, @option{-O3}.
14944
ddf6fe37 14945@opindex falign-jumps
d77de738
ML
14946@item -falign-jumps
14947@itemx -falign-jumps=@var{n}
14948@itemx -falign-jumps=@var{n}:@var{m}
14949@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14950@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14951Align branch targets to a power-of-two boundary, for branch targets
14952where the targets can only be reached by jumping. In this case,
14953no dummy operations need be executed.
0f5a9a00
JH
14954This is an optimization of code performance and alignment is ignored for
14955jumps considered cold.
d77de738
ML
14956
14957If @option{-falign-labels} is greater than this value, then its value
14958is used instead.
14959
14960Parameters of this option are analogous to the @option{-falign-functions} option.
14961@option{-fno-align-jumps} and @option{-falign-jumps=1} are
14962equivalent and mean that loops are not aligned.
14963
14964If @var{n} is not specified or is zero, use a machine-dependent default.
14965The maximum allowed @var{n} option value is 65536.
14966
14967Enabled at levels @option{-O2}, @option{-O3}.
14968
0f5a9a00
JH
14969@opindex fmin-function-alignment=@var{n}
14970@item -fmin-function-alignment
14971Specify minimal alignment of functions to the next power-of-two greater than or
14972equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied
14973also to all functions (even those considered cold). The alignment is also not
14974affected by @option{-flimit-function-alignment}
14975
14976
d77de738 14977@opindex fno-allocation-dce
7828dc07 14978@opindex fallocation-dce
ddf6fe37 14979@item -fno-allocation-dce
7828dc07
JH
14980Do not remove unused C++ allocations (using operator @code{new} and operator @code{delete})
14981in dead code elimination.
14982
14983See also @option{-fmalloc-dce}.
d77de738 14984
d77de738 14985@opindex fallow-store-data-races
ddf6fe37 14986@item -fallow-store-data-races
d77de738
ML
14987Allow the compiler to perform optimizations that may introduce new data races
14988on stores, without proving that the variable cannot be concurrently accessed
14989by other threads. Does not affect optimization of local data. It is safe to
14990use this option if it is known that global data will not be accessed by
14991multiple threads.
14992
14993Examples of optimizations enabled by @option{-fallow-store-data-races} include
14994hoisting or if-conversions that may cause a value that was already in memory
14995to be re-written with that same value. Such re-writing is safe in a single
14996threaded context but may be unsafe in a multi-threaded context. Note that on
14997some processors, if-conversions may be required in order to enable
14998vectorization.
14999
15000Enabled at level @option{-Ofast}.
15001
d77de738 15002@opindex funit-at-a-time
ddf6fe37 15003@item -funit-at-a-time
d77de738
ML
15004This option is left for compatibility reasons. @option{-funit-at-a-time}
15005has no effect, while @option{-fno-unit-at-a-time} implies
15006@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
15007
15008Enabled by default.
15009
d77de738
ML
15010@opindex fno-toplevel-reorder
15011@opindex ftoplevel-reorder
ddf6fe37 15012@item -fno-toplevel-reorder
d77de738
ML
15013Do not reorder top-level functions, variables, and @code{asm}
15014statements. Output them in the same order that they appear in the
15015input file. When this option is used, unreferenced static variables
15016are not removed. This option is intended to support existing code
15017that relies on a particular ordering. For new code, it is better to
15018use attributes when possible.
15019
15020@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
15021also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
15022Additionally @option{-fno-toplevel-reorder} implies
15023@option{-fno-section-anchors}.
15024
d77de738 15025@opindex funreachable-traps
ddf6fe37 15026@item -funreachable-traps
d77de738
ML
15027With this option, the compiler turns calls to
15028@code{__builtin_unreachable} into traps, instead of using them for
15029optimization. This also affects any such calls implicitly generated
15030by the compiler.
15031
15032This option has the same effect as @option{-fsanitize=unreachable
15033-fsanitize-trap=unreachable}, but does not affect the values of those
15034options. If @option{-fsanitize=unreachable} is enabled, that option
15035takes priority over this one.
15036
15037This option is enabled by default at @option{-O0} and @option{-Og}.
15038
d77de738 15039@opindex fweb
ddf6fe37 15040@item -fweb
d77de738
ML
15041Constructs webs as commonly used for register allocation purposes and assign
15042each web individual pseudo register. This allows the register allocation pass
15043to operate on pseudos directly, but also strengthens several other optimization
15044passes, such as CSE, loop optimizer and trivial dead code remover. It can,
15045however, make debugging impossible, since variables no longer stay in a
15046``home register''.
15047
15048Enabled by default with @option{-funroll-loops}.
15049
d77de738 15050@opindex fwhole-program
ddf6fe37 15051@item -fwhole-program
d77de738
ML
15052Assume that the current compilation unit represents the whole program being
15053compiled. All public functions and variables with the exception of @code{main}
15054and those merged by attribute @code{externally_visible} become static functions
15055and in effect are optimized more aggressively by interprocedural optimizers.
15056
39ebd3a9
JH
15057With @option{-flto} this option has a limited use. In most cases the
15058precise list of symbols used or exported from the binary is known the
15059resolution info passed to the link-time optimizer by the linker plugin. It is
15060still useful if no linker plugin is used or during incremental link step when
15061final code is produced (with @option{-flto}
15062@option{-flinker-output=nolto-rel}).
d77de738 15063
d77de738 15064@opindex flto
ddf6fe37 15065@item -flto[=@var{n}]
d77de738
ML
15066This option runs the standard link-time optimizer. When invoked
15067with source code, it generates GIMPLE (one of GCC's internal
15068representations) and writes it to special ELF sections in the object
15069file. When the object files are linked together, all the function
15070bodies are read from these ELF sections and instantiated as if they
15071had been part of the same translation unit.
15072
15073To use the link-time optimizer, @option{-flto} and optimization
15074options should be specified at compile time and during the final link.
15075It is recommended that you compile all the files participating in the
15076same link with the same options and also specify those options at
0f5a9a00 15077link time.
d77de738
ML
15078For example:
15079
15080@smallexample
15081gcc -c -O2 -flto foo.c
15082gcc -c -O2 -flto bar.c
15083gcc -o myprog -flto -O2 foo.o bar.o
15084@end smallexample
15085
15086The first two invocations to GCC save a bytecode representation
15087of GIMPLE into special ELF sections inside @file{foo.o} and
15088@file{bar.o}. The final invocation reads the GIMPLE bytecode from
15089@file{foo.o} and @file{bar.o}, merges the two files into a single
15090internal image, and compiles the result as usual. Since both
15091@file{foo.o} and @file{bar.o} are merged into a single image, this
15092causes all the interprocedural analyses and optimizations in GCC to
15093work across the two files as if they were a single one. This means,
15094for example, that the inliner is able to inline functions in
15095@file{bar.o} into functions in @file{foo.o} and vice-versa.
15096
15097Another (simpler) way to enable link-time optimization is:
15098
15099@smallexample
15100gcc -o myprog -flto -O2 foo.c bar.c
15101@end smallexample
15102
15103The above generates bytecode for @file{foo.c} and @file{bar.c},
15104merges them together into a single GIMPLE representation and optimizes
15105them as usual to produce @file{myprog}.
15106
15107The important thing to keep in mind is that to enable link-time
15108optimizations you need to use the GCC driver to perform the link step.
15109GCC automatically performs link-time optimization if any of the
a0e64a04 15110objects involved were compiled with the @option{-flto} command-line option.
d77de738
ML
15111You can always override
15112the automatic decision to do link-time optimization
15113by passing @option{-fno-lto} to the link command.
15114
15115To make whole program optimization effective, it is necessary to make
15116certain whole program assumptions. The compiler needs to know
15117what functions and variables can be accessed by libraries and runtime
15118outside of the link-time optimized unit. When supported by the linker,
15119the linker plugin (see @option{-fuse-linker-plugin}) passes information
15120to the compiler about used and externally visible symbols. When
15121the linker plugin is not available, @option{-fwhole-program} should be
15122used to allow the compiler to make these assumptions, which leads
15123to more aggressive optimization decisions.
15124
15125When a file is compiled with @option{-flto} without
15126@option{-fuse-linker-plugin}, the generated object file is larger than
15127a regular object file because it contains GIMPLE bytecodes and the usual
15128final code (see @option{-ffat-lto-objects}). This means that
15129object files with LTO information can be linked as normal object
15130files; if @option{-fno-lto} is passed to the linker, no
15131interprocedural optimizations are applied. Note that when
15132@option{-fno-fat-lto-objects} is enabled the compile stage is faster
15133but you cannot perform a regular, non-LTO link on them.
15134
15135When producing the final binary, GCC only
15136applies link-time optimizations to those files that contain bytecode.
15137Therefore, you can mix and match object files and libraries with
15138GIMPLE bytecodes and final object code. GCC automatically selects
15139which files to optimize in LTO mode and which files to link without
15140further processing.
15141
15142Generally, options specified at link time override those
15143specified at compile time, although in some cases GCC attempts to infer
15144link-time options from the settings used to compile the input files.
15145
15146If you do not specify an optimization level option @option{-O} at
a0e64a04
PN
15147link time, then GCC uses the highest optimization level
15148used when compiling the object files. Note that it is generally
15149ineffective to specify an optimization level option only at link time and
15150not at compile time, for two reasons. First, compiling without
15151optimization suppresses compiler passes that gather information
d77de738 15152needed for effective optimization at link time. Second, some early
a0e64a04 15153optimization passes can be performed only at compile time and
d77de738
ML
15154not at link time.
15155
15156There are some code generation flags preserved by GCC when
15157generating bytecodes, as they need to be used during the final link.
15158Currently, the following options and their settings are taken from
a0e64a04 15159the first object file that explicitly specifies them:
d77de738
ML
15160@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
15161@option{-fgnu-tm} and all the @option{-m} target flags.
15162
15163The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
15164@option{-fPIE} are combined based on the following scheme:
15165
15166@smallexample
15167@option{-fPIC} + @option{-fpic} = @option{-fpic}
15168@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
15169@option{-fpic/-fPIC} + (no option) = (no option)
15170@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
15171@option{-fpic} + @option{-fPIE} = @option{-fpie}
15172@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
15173@end smallexample
15174
15175Certain ABI-changing flags are required to match in all compilation units,
15176and trying to override this at link time with a conflicting value
15177is ignored. This includes options such as @option{-freg-struct-return}
a0e64a04 15178and @option{-fpcc-struct-return}.
d77de738
ML
15179
15180Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
15181@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
15182are passed through to the link stage and merged conservatively for
15183conflicting translation units. Specifically
15184@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
15185precedence; and for example @option{-ffp-contract=off} takes precedence
15186over @option{-ffp-contract=fast}. You can override them at link time.
15187
15188Diagnostic options such as @option{-Wstringop-overflow} are passed
15189through to the link stage and their setting matches that of the
15190compile-step at function granularity. Note that this matters only
15191for diagnostics emitted during optimization. Note that code
15192transforms such as inlining can lead to warnings being enabled
15193or disabled for regions if code not consistent with the setting
15194at compile time.
15195
15196When you need to pass options to the assembler via @option{-Wa} or
15197@option{-Xassembler} make sure to either compile such translation
15198units with @option{-fno-lto} or consistently use the same assembler
15199options on all translation units. You can alternatively also
15200specify assembler options at LTO link time.
15201
15202To enable debug info generation you need to supply @option{-g} at
15203compile time. If any of the input files at link time were built
15204with debug info generation enabled the link will enable debug info
15205generation as well. Any elaborate debug info settings
15206like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
15207at the linker command line and mixing different settings in different
15208translation units is discouraged.
15209
15210If LTO encounters objects with C linkage declared with incompatible
15211types in separate translation units to be linked together (undefined
15212behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
15213issued. The behavior is still undefined at run time. Similar
15214diagnostics may be raised for other languages.
15215
15216Another feature of LTO is that it is possible to apply interprocedural
15217optimizations on files written in different languages:
15218
15219@smallexample
15220gcc -c -flto foo.c
15221g++ -c -flto bar.cc
15222gfortran -c -flto baz.f90
15223g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
15224@end smallexample
15225
15226Notice that the final link is done with @command{g++} to get the C++
15227runtime libraries and @option{-lgfortran} is added to get the Fortran
15228runtime libraries. In general, when mixing languages in LTO mode, you
15229should use the same link command options as when mixing languages in a
15230regular (non-LTO) compilation.
15231
15232If object files containing GIMPLE bytecode are stored in a library archive, say
15233@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
15234are using a linker with plugin support. To create static libraries suitable
15235for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
a0e64a04 15236and @command{ranlib};
d77de738
ML
15237to show the symbols of object files with GIMPLE bytecode, use
15238@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
15239and @command{nm} have been compiled with plugin support. At link time, use the
15240flag @option{-fuse-linker-plugin} to ensure that the library participates in
15241the LTO optimization process:
15242
15243@smallexample
15244gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
15245@end smallexample
15246
15247With the linker plugin enabled, the linker extracts the needed
15248GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
15249to make them part of the aggregated GIMPLE image to be optimized.
15250
15251If you are not using a linker with plugin support and/or do not
15252enable the linker plugin, then the objects inside @file{libfoo.a}
15253are extracted and linked as usual, but they do not participate
15254in the LTO optimization process. In order to make a static library suitable
15255for both LTO optimization and usual linkage, compile its object files with
15256@option{-flto} @option{-ffat-lto-objects}.
15257
15258Link-time optimizations do not require the presence of the whole program to
15259operate. If the program does not require any symbols to be exported, it is
15260possible to combine @option{-flto} and @option{-fwhole-program} to allow
15261the interprocedural optimizers to use more aggressive assumptions which may
15262lead to improved optimization opportunities.
15263Use of @option{-fwhole-program} is not needed when linker plugin is
15264active (see @option{-fuse-linker-plugin}).
15265
15266The current implementation of LTO makes no
15267attempt to generate bytecode that is portable between different
15268types of hosts. The bytecode files are versioned and there is a
15269strict version check, so bytecode files generated in one version of
15270GCC do not work with an older or newer version of GCC.
15271
15272Link-time optimization does not work well with generation of debugging
15273information on systems other than those using a combination of ELF and
15274DWARF.
15275
15276If you specify the optional @var{n}, the optimization and code
15277generation done at link time is executed in parallel using @var{n}
15278parallel jobs by utilizing an installed @command{make} program. The
15279environment variable @env{MAKE} may be used to override the program
15280used.
15281
15282You can also specify @option{-flto=jobserver} to use GNU make's
15283job server mode to determine the number of parallel jobs. This
15284is useful when the Makefile calling GCC is already executing in parallel.
15285You must prepend a @samp{+} to the command recipe in the parent Makefile
15286for this to work. This option likely only works if @env{MAKE} is
15287GNU make. Even without the option value, GCC tries to automatically
15288detect a running GNU make's job server.
15289
15290Use @option{-flto=auto} to use GNU make's job server, if available,
15291or otherwise fall back to autodetection of the number of CPU threads
15292present in your system.
15293
d77de738 15294@opindex flto-partition
ddf6fe37 15295@item -flto-partition=@var{alg}
d77de738
ML
15296Specify the partitioning algorithm used by the link-time optimizer.
15297The value is either @samp{1to1} to specify a partitioning mirroring
15298the original source files or @samp{balanced} to specify partitioning
15299into equally sized chunks (whenever possible) or @samp{max} to create
63e7478d
MJ
15300new partition for every symbol where possible or @samp{cache} to
15301balance chunk sizes while keeping related symbols together for better
15302caching in incremental LTO. Specifying @samp{none} as an algorithm
15303disables partitioning and streaming completely.
d77de738
ML
15304The default value is @samp{balanced}. While @samp{1to1} can be used
15305as an workaround for various code ordering issues, the @samp{max}
15306partitioning is intended for internal testing only.
15307The value @samp{one} specifies that exactly one partition should be
15308used while the value @samp{none} bypasses partitioning and executes
15309the link-time optimization step directly from the WPA phase.
15310
63e7478d
MJ
15311@opindex flto-incremental
15312@item -flto-incremental=@var{path}
15313Enable incremental LTO, with its cache in given existing directory.
15314Can significantly shorten edit-compile cycles with LTO.
15315
15316When used with LTO (@option{-flto}), the output of translation units
15317inside LTO is cached. Cached translation units are likely to be
15318encountered again when recompiling with small code changes, leading to
15319recompile time reduction.
15320
15321Multiple GCC instances can use the same cache in parallel.
15322
15323@opindex flto-incremental-cache-size
15324@item -flto-incremental-cache-size=@var{n}
15325Specifies number of cache entries in incremental LTO after which to prune
15326old entries. This is a soft limit, temporarily there may be more entries.
15327
d77de738 15328@opindex flto-compression-level
ddf6fe37 15329@item -flto-compression-level=@var{n}
d77de738
ML
15330This option specifies the level of compression used for intermediate
15331language written to LTO object files, and is only meaningful in
15332conjunction with LTO mode (@option{-flto}). GCC currently supports two
15333LTO compression algorithms. For zstd, valid values are 0 (no compression)
15334to 19 (maximum compression), while zlib supports values from 0 to 9.
15335Values outside this range are clamped to either minimum or maximum
15336of the supported values. If the option is not given,
15337a default balanced compression setting is used.
15338
d77de738 15339@opindex fuse-linker-plugin
ddf6fe37 15340@item -fuse-linker-plugin
d77de738
ML
15341Enables the use of a linker plugin during link-time optimization. This
15342option relies on plugin support in the linker, which is available in gold
15343or in GNU ld 2.21 or newer.
15344
15345This option enables the extraction of object files with GIMPLE bytecode out
15346of library archives. This improves the quality of optimization by exposing
15347more code to the link-time optimizer. This information specifies what
15348symbols can be accessed externally (by non-LTO object or during dynamic
15349linking). Resulting code quality improvements on binaries (and shared
15350libraries that use hidden visibility) are similar to @option{-fwhole-program}.
15351See @option{-flto} for a description of the effect of this flag and how to
15352use it.
15353
15354This option is enabled by default when LTO support in GCC is enabled
15355and GCC was configured for use with
15356a linker supporting plugins (GNU ld 2.21 or newer or gold).
15357
d77de738 15358@opindex ffat-lto-objects
ddf6fe37 15359@item -ffat-lto-objects
d77de738
ML
15360Fat LTO objects are object files that contain both the intermediate language
15361and the object code. This makes them usable for both LTO linking and normal
15362linking. This option is effective only when compiling with @option{-flto}
15363and is ignored at link time.
15364
15365@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
15366requires the complete toolchain to be aware of LTO. It requires a linker with
15367linker plugin support for basic functionality. Additionally,
15368@command{nm}, @command{ar} and @command{ranlib}
15369need to support linker plugins to allow a full-featured build environment
15370(capable of building static libraries etc). GCC provides the @command{gcc-ar},
15371@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
15372to these tools. With non fat LTO makefiles need to be modified to use them.
15373
15374Note that modern binutils provide plugin auto-load mechanism.
15375Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
15376effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
15377@command{gcc-ranlib}).
15378
15379The default is @option{-fno-fat-lto-objects} on targets with linker plugin
15380support.
15381
d77de738 15382@opindex fcompare-elim
ddf6fe37 15383@item -fcompare-elim
d77de738
ML
15384After register allocation and post-register allocation instruction splitting,
15385identify arithmetic instructions that compute processor flags similar to a
15386comparison operation based on that arithmetic. If possible, eliminate the
15387explicit comparison operation.
15388
15389This pass only applies to certain targets that cannot explicitly represent
15390the comparison operation before register allocation is complete.
15391
15392Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
15393
04c9cf5c
MT
15394@opindex ffold-mem-offsets
15395@item -ffold-mem-offsets
15396@itemx -fno-fold-mem-offsets
15397Try to eliminate add instructions by folding them in memory loads/stores.
15398
15399Enabled at levels @option{-O2}, @option{-O3}.
15400
d77de738 15401@opindex fcprop-registers
ddf6fe37 15402@item -fcprop-registers
d77de738
ML
15403After register allocation and post-register allocation instruction splitting,
15404perform a copy-propagation pass to try to reduce scheduling dependencies
15405and occasionally eliminate the copy.
15406
15407Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
15408
d77de738 15409@opindex fprofile-correction
ddf6fe37 15410@item -fprofile-correction
d77de738
ML
15411Profiles collected using an instrumented binary for multi-threaded programs may
15412be inconsistent due to missed counter updates. When this option is specified,
15413GCC uses heuristics to correct or smooth out such inconsistencies. By
15414default, GCC emits an error message when an inconsistent profile is detected.
15415
15416This option is enabled by @option{-fauto-profile}.
15417
d77de738 15418@opindex fprofile-partial-training
ddf6fe37 15419@item -fprofile-partial-training
d77de738 15420With @code{-fprofile-use} all portions of programs not executed during train
b9857b78 15421run are optimized aggressively for size rather than speed. In some cases it is
d77de738
ML
15422not practical to train all possible hot paths in the program. (For
15423example, program may contain functions specific for a given hardware and
b9857b78
SL
15424training may not cover all hardware configurations program is run on.) With
15425@code{-fprofile-partial-training} profile feedback is ignored for all
15426functions not executed during the train run, leading them to be optimized as if
d77de738
ML
15427they were compiled without profile feedback. This leads to better performance
15428when train run is not representative but also leads to significantly bigger
15429code.
15430
ddf6fe37 15431@opindex fprofile-use
d77de738
ML
15432@item -fprofile-use
15433@itemx -fprofile-use=@var{path}
a0e64a04 15434Enable profile feedback-directed optimizations,
d77de738
ML
15435and the following optimizations, many of which
15436are generally profitable only with profile feedback available:
15437
43b72ede
AA
15438@gccoptlist{-fbranch-probabilities -fprofile-values
15439-funroll-loops -fpeel-loops -ftracer -fvpt
15440-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
15441-fpredictive-commoning -fsplit-loops -funswitch-loops
15442-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
15443-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
15444-fprofile-reorder-functions}
15445
15446Before you can use this option, you must first generate profiling information.
15447@xref{Instrumentation Options}, for information about the
15448@option{-fprofile-generate} option.
15449
15450By default, GCC emits an error message if the feedback profiles do not
15451match the source code. This error can be turned into a warning by using
15452@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
15453optimized code. Additionally, by default, GCC also emits a warning message if
15454the feedback profiles do not exist (see @option{-Wmissing-profile}).
15455
15456If @var{path} is specified, GCC looks at the @var{path} to find
15457the profile feedback data files. See @option{-fprofile-dir}.
15458
ddf6fe37 15459@opindex fauto-profile
d77de738
ML
15460@item -fauto-profile
15461@itemx -fauto-profile=@var{path}
a0e64a04 15462Enable sampling-based feedback-directed optimizations,
d77de738
ML
15463and the following optimizations,
15464many of which are generally profitable only with profile feedback available:
15465
43b72ede
AA
15466@gccoptlist{-fbranch-probabilities -fprofile-values
15467-funroll-loops -fpeel-loops -ftracer -fvpt
15468-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
15469-fpredictive-commoning -fsplit-loops -funswitch-loops
15470-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
15471-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
15472-fprofile-correction}
15473
15474@var{path} is the name of a file containing AutoFDO profile information.
15475If omitted, it defaults to @file{fbdata.afdo} in the current directory.
15476
15477Producing an AutoFDO profile data file requires running your program
15478with the @command{perf} utility on a supported GNU/Linux target system.
15479For more information, see @uref{https://perf.wiki.kernel.org/}.
15480
15481E.g.
15482@smallexample
15483perf record -e br_inst_retired:near_taken -b -o perf.data \
15484 -- your_program
15485@end smallexample
15486
15487Then use the @command{create_gcov} tool to convert the raw profile data
a0e64a04
PN
15488to a format that can be used by GCC.@ You must also supply the
15489unstripped binary for your program to this tool.
d77de738
ML
15490See @uref{https://github.com/google/autofdo}.
15491
15492E.g.
15493@smallexample
15494create_gcov --binary=your_program.unstripped --profile=perf.data \
15495 --gcov=profile.afdo
15496@end smallexample
aaf55e09
JH
15497
15498@opindex fauto-profile-inlining
15499@item -fauto-profile-inlining
15500When auto-profile is available inline all relevant functions which was
15501inlined in the tran run before reading the profile feedback. This improves
15502context sensitivity of the profile. Enabled by default.
d77de738
ML
15503@end table
15504
a0e64a04 15505The following options control compiler behavior regarding floating-point
d77de738
ML
15506arithmetic. These options trade off between speed and
15507correctness. All must be specifically enabled.
15508
15509@table @gcctabopt
d77de738 15510@opindex fexcess-precision
ddf6fe37 15511@item -fexcess-precision=@var{style}
0c210fbb 15512This option allows control over excess precision on machines
d77de738 15513where floating-point operations occur in a format with more precision or
0c210fbb
SL
15514range than the IEEE standard and interchange floating-point types.
15515An example of such a target is x87 floating point on x86 processors,
15516which uses an 80-bit representation internally instead of the 64-bit
15517IEEE format. For most programs, the excess precision is harmless,
15518but some programs may rely on the
15519requirements of the C or C++ language standards for handling IEEE values.
15520
15521By default, @option{-fexcess-precision=fast} is in effect; this means that
d77de738
ML
15522operations may be carried out in a wider precision than the types specified
15523in the source if that would result in faster code, and it is unpredictable
15524when rounding to the types specified in the source code takes place.
15525When compiling C or C++, if @option{-fexcess-precision=standard} is specified
0c210fbb
SL
15526then excess precision follows the rules specified in ISO C99 or C++;
15527in particular,
d77de738
ML
15528both casts and assignments cause values to be rounded to their
15529semantic types (whereas @option{-ffloat-store} only affects
15530assignments). This option is enabled by default for C or C++ if a strict
15531conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
15532@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
15533regardless of whether a strict conformance option is used.
415091f0 15534If @option{-fexcess-precision=16} is specified, constants and the
15535results of expressions with types @code{_Float16} and @code{__bf16}
15536are computed without excess precision.
d77de738
ML
15537
15538@opindex mfpmath
15539@option{-fexcess-precision=standard} is not implemented for languages
15540other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
15541or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
15542semantics apply without excess precision, and in the latter, rounding
15543is unpredictable.
15544
0c210fbb
SL
15545@opindex ffloat-store
15546@item -ffloat-store
15547Do not store floating-point variables in registers, and inhibit other
15548options that might change whether a floating-point value is taken from a
15549register or memory. This option has generally been subsumed by
15550@option{-fexcess-precision=standard}, which is more general. If you do use
15551@option{-ffloat-store}, you may need to modify your program to explicitly
15552store intermediate computations in temporary variables since
15553@option{-ffloat-store} handles rounding to IEEE format
15554only on assignments and not casts as @option{-fexcess-precision=standard}
15555does.
15556
d77de738 15557@opindex ffast-math
ddf6fe37 15558@item -ffast-math
d77de738
ML
15559Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
15560@option{-ffinite-math-only}, @option{-fno-rounding-math},
15561@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
15562@option{-fexcess-precision=fast}.
15563
15564This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
15565
15566This option is not turned on by any @option{-O} option besides
15567@option{-Ofast} since it can result in incorrect output for programs
15568that depend on an exact implementation of IEEE or ISO rules/specifications
15569for math functions. It may, however, yield faster code for programs
15570that do not require the guarantees of these specifications.
15571
d77de738
ML
15572@opindex fno-math-errno
15573@opindex fmath-errno
ddf6fe37 15574@item -fno-math-errno
d77de738
ML
15575Do not set @code{errno} after calling math functions that are executed
15576with a single instruction, e.g., @code{sqrt}. A program that relies on
15577IEEE exceptions for math error handling may want to use this flag
15578for speed while maintaining IEEE arithmetic compatibility.
15579
0920e64f
AP
15580This option is not turned on by any @option{-O} option besides
15581@option{-Ofast} since it can result in incorrect output for
15582programs that depend on an exact implementation of IEEE or
15583ISO rules/specifications for math functions. It may, however,
15584yield faster code for programs that do not require the guarantees
15585of these specifications.
d77de738
ML
15586
15587The default is @option{-fmath-errno}.
15588
15589On Darwin systems, the math library never sets @code{errno}. There is
15590therefore no reason for the compiler to consider the possibility that
15591it might, and @option{-fno-math-errno} is the default.
15592
d77de738 15593@opindex funsafe-math-optimizations
ddf6fe37 15594@item -funsafe-math-optimizations
d77de738
ML
15595
15596Allow optimizations for floating-point arithmetic that (a) assume
15597that arguments and results are valid and (b) may violate IEEE or
15598ANSI standards. When used at link time, it may include libraries
15599or startup files that change the default FPU control word or other
15600similar optimizations.
15601
0920e64f
AP
15602This option is not turned on by any @option{-O} option besides
15603@option{-Ofast} since it can result in incorrect output
15604for programs that depend on an exact implementation of IEEE
15605or ISO rules/specifications for math functions. It may, however,
15606yield faster code for programs that do not require the guarantees
15607of these specifications.
d77de738
ML
15608Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
15609@option{-fassociative-math} and @option{-freciprocal-math}.
15610
15611The default is @option{-fno-unsafe-math-optimizations}.
15612
d77de738 15613@opindex fassociative-math
ddf6fe37 15614@item -fassociative-math
d77de738
ML
15615
15616Allow re-association of operands in series of floating-point operations.
15617This violates the ISO C and C++ language standard by possibly changing
15618computation result. NOTE: re-ordering may change the sign of zero as
15619well as ignore NaNs and inhibit or create underflow or overflow (and
15620thus cannot be used on code that relies on rounding behavior like
15621@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
15622and thus may not be used when ordered comparisons are required.
15623This option requires that both @option{-fno-signed-zeros} and
15624@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
15625much sense with @option{-frounding-math}. For Fortran the option
15626is automatically enabled when both @option{-fno-signed-zeros} and
15627@option{-fno-trapping-math} are in effect.
15628
15629The default is @option{-fno-associative-math}.
15630
d77de738 15631@opindex freciprocal-math
ddf6fe37 15632@item -freciprocal-math
d77de738
ML
15633
15634Allow the reciprocal of a value to be used instead of dividing by
15635the value if this enables optimizations. For example @code{x / y}
15636can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
15637is subject to common subexpression elimination. Note that this loses
15638precision and increases the number of flops operating on the value.
15639
15640The default is @option{-fno-reciprocal-math}.
15641
d77de738 15642@opindex ffinite-math-only
ddf6fe37 15643@item -ffinite-math-only
d77de738
ML
15644Allow optimizations for floating-point arithmetic that assume
15645that arguments and results are not NaNs or +-Infs.
15646
0920e64f
AP
15647This option is not turned on by any @option{-O} option besides
15648@option{-Ofast} since it can result in incorrect output
15649for programs that depend on an exact implementation of IEEE or
15650ISO rules/specifications for math functions. It may, however,
15651yield faster code for programs that do not require the guarantees
15652of these specifications.
d77de738
ML
15653
15654The default is @option{-fno-finite-math-only}.
15655
d77de738
ML
15656@opindex fno-signed-zeros
15657@opindex fsigned-zeros
ddf6fe37 15658@item -fno-signed-zeros
d77de738
ML
15659Allow optimizations for floating-point arithmetic that ignore the
15660signedness of zero. IEEE arithmetic specifies the behavior of
15661distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
15662of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
15663This option implies that the sign of a zero result isn't significant.
15664
15665The default is @option{-fsigned-zeros}.
15666
d77de738
ML
15667@opindex fno-trapping-math
15668@opindex ftrapping-math
ddf6fe37 15669@item -fno-trapping-math
d77de738
ML
15670Compile code assuming that floating-point operations cannot generate
15671user-visible traps. These traps include division by zero, overflow,
15672underflow, inexact result and invalid operation. This option requires
15673that @option{-fno-signaling-nans} be in effect. Setting this option may
15674allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
15675
0920e64f
AP
15676This option is not turned on by any @option{-O} option besides
15677@option{-Ofast} since it can result in incorrect output for programs
15678that depend on an exact implementation of IEEE or ISO rules/specifications
15679for math functions.
d77de738
ML
15680
15681The default is @option{-ftrapping-math}.
15682
15683Future versions of GCC may provide finer control of this setting
15684using C99's @code{FENV_ACCESS} pragma. This command-line option
15685will be used along with @option{-frounding-math} to specify the
15686default state for @code{FENV_ACCESS}.
15687
d77de738 15688@opindex frounding-math
ddf6fe37 15689@item -frounding-math
d77de738 15690Disable transformations and optimizations that assume default floating-point
93f6ea83
SL
15691rounding behavior (round-to-nearest).
15692This option should be specified for programs that change
d77de738
ML
15693the FP rounding mode dynamically, or that may be executed with a
15694non-default rounding mode. This option disables constant folding of
15695floating-point expressions at compile time (which may be affected by
15696rounding mode) and arithmetic transformations that are unsafe in the
15697presence of sign-dependent rounding modes.
15698
15699The default is @option{-fno-rounding-math}.
15700
15701This option is experimental and does not currently guarantee to
15702disable all GCC optimizations that are affected by rounding mode.
15703Future versions of GCC may provide finer control of this setting
15704using C99's @code{FENV_ACCESS} pragma. This command-line option
15705will be used along with @option{-ftrapping-math} to specify the
15706default state for @code{FENV_ACCESS}.
15707
d77de738 15708@opindex fsignaling-nans
ddf6fe37 15709@item -fsignaling-nans
d77de738
ML
15710Compile code assuming that IEEE signaling NaNs may generate user-visible
15711traps during floating-point operations. Setting this option disables
15712optimizations that may change the number of exceptions visible with
15713signaling NaNs. This option implies @option{-ftrapping-math}.
15714
15715This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
15716be defined.
15717
15718The default is @option{-fno-signaling-nans}.
15719
15720This option is experimental and does not currently guarantee to
15721disable all GCC optimizations that affect signaling NaN behavior.
15722
d77de738
ML
15723@opindex fno-fp-int-builtin-inexact
15724@opindex ffp-int-builtin-inexact
ddf6fe37 15725@item -fno-fp-int-builtin-inexact
d77de738
ML
15726Do not allow the built-in functions @code{ceil}, @code{floor},
15727@code{round} and @code{trunc}, and their @code{float} and @code{long
15728double} variants, to generate code that raises the ``inexact''
15729floating-point exception for noninteger arguments. ISO C99 and C11
15730allow these functions to raise the ``inexact'' exception, but ISO/IEC
15731TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
094a609c 15732ISO C23, does not allow these functions to do so.
d77de738
ML
15733
15734The default is @option{-ffp-int-builtin-inexact}, allowing the
094a609c 15735exception to be raised, unless C23 or a later C standard is selected.
d77de738
ML
15736This option does nothing unless @option{-ftrapping-math} is in effect.
15737
15738Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
15739generate a call to a library function then the ``inexact'' exception
15740may be raised if the library implementation does not follow TS 18661.
15741
d77de738 15742@opindex fsingle-precision-constant
ddf6fe37 15743@item -fsingle-precision-constant
d77de738
ML
15744Treat floating-point constants as single precision instead of
15745implicitly converting them to double-precision constants.
15746
d77de738 15747@opindex fcx-limited-range
ddf6fe37 15748@item -fcx-limited-range
d77de738
ML
15749When enabled, this option states that a range reduction step is not
15750needed when performing complex division. Also, there is no checking
15751whether the result of a complex multiplication or division is @code{NaN
15752+ I*NaN}, with an attempt to rescue the situation in that case. The
e543eaa6 15753option is enabled by @option{-ffast-math}.
d77de738
ML
15754
15755This option controls the default setting of the ISO C99
15756@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
15757all languages.
15758
d77de738 15759@opindex fcx-fortran-rules
ddf6fe37 15760@item -fcx-fortran-rules
d77de738
ML
15761Complex multiplication and division follow Fortran rules. Range
15762reduction is done as part of complex division, but there is no checking
15763whether the result of a complex multiplication or division is @code{NaN
15764+ I*NaN}, with an attempt to rescue the situation in that case.
15765
e543eaa6
RB
15766@opindex fcx-method
15767@item -fcx-method=@var{method}
15768Complex multiplication and division follow the stated @var{method}. The
15769@var{method} argument should be one of @samp{limited-range}, @samp{fortran}
15770or @samp{stdc}.
15771
15772The default is to honor language specific constraints which means
15773@samp{fortran} for Fortran and @samp{stdc} otherwise.
d77de738
ML
15774
15775@end table
15776
15777The following options control optimizations that may improve
15778performance, but are not enabled by any @option{-O} options. This
15779section includes experimental options that may produce broken code.
15780
15781@table @gcctabopt
d77de738 15782@opindex fbranch-probabilities
ddf6fe37 15783@item -fbranch-probabilities
d77de738
ML
15784After running a program compiled with @option{-fprofile-arcs}
15785(@pxref{Instrumentation Options}),
15786you can compile it a second time using
15787@option{-fbranch-probabilities}, to improve optimizations based on
15788the number of times each branch was taken. When a program
15789compiled with @option{-fprofile-arcs} exits, it saves arc execution
15790counts to a file called @file{@var{sourcename}.gcda} for each source
15791file. The information in this data file is very dependent on the
15792structure of the generated code, so you must use the same source code
15793and the same optimization options for both compilations.
15794See details about the file naming in @option{-fprofile-arcs}.
15795
15796With @option{-fbranch-probabilities}, GCC puts a
15797@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
15798These can be used to improve optimization. Currently, they are only
15799used in one place: in @file{reorg.cc}, instead of guessing which path a
15800branch is most likely to take, the @samp{REG_BR_PROB} values are used to
15801exactly determine which path is taken more often.
15802
15803Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15804
d77de738 15805@opindex fprofile-values
ddf6fe37 15806@item -fprofile-values
d77de738
ML
15807If combined with @option{-fprofile-arcs}, it adds code so that some
15808data about values of expressions in the program is gathered.
15809
15810With @option{-fbranch-probabilities}, it reads back the data gathered
15811from profiling values of expressions for usage in optimizations.
15812
15813Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
15814@option{-fauto-profile}.
15815
d77de738 15816@opindex fprofile-reorder-functions
ddf6fe37 15817@item -fprofile-reorder-functions
d77de738
ML
15818Function reordering based on profile instrumentation collects
15819first time of execution of a function and orders these functions
6d9fdf4b
KT
15820in ascending order, aiming to optimize program startup through more
15821efficient loading of text segments.
d77de738
ML
15822
15823Enabled with @option{-fprofile-use}.
15824
d77de738 15825@opindex fvpt
ddf6fe37 15826@item -fvpt
d77de738
ML
15827If combined with @option{-fprofile-arcs}, this option instructs the compiler
15828to add code to gather information about values of expressions.
15829
15830With @option{-fbranch-probabilities}, it reads back the data gathered
15831and actually performs the optimizations based on them.
15832Currently the optimizations include specialization of division operations
15833using the knowledge about the value of the denominator.
15834
15835Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
15836
d77de738 15837@opindex frename-registers
ddf6fe37 15838@item -frename-registers
d77de738
ML
15839Attempt to avoid false dependencies in scheduled code by making use
15840of registers left over after register allocation. This optimization
15841most benefits processors with lots of registers. Depending on the
15842debug information format adopted by the target, however, it can
15843make debugging impossible, since variables no longer stay in
15844a ``home register''.
15845
15846Enabled by default with @option{-funroll-loops}.
15847
d77de738 15848@opindex fschedule-fusion
ddf6fe37 15849@item -fschedule-fusion
d77de738
ML
15850Performs a target dependent pass over the instruction stream to schedule
15851instructions of same type together because target machine can execute them
15852more efficiently if they are adjacent to each other in the instruction flow.
15853
15854Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
15855
d77de738 15856@opindex ftracer
ddf6fe37 15857@item -ftracer
d77de738
ML
15858Perform tail duplication to enlarge superblock size. This transformation
15859simplifies the control flow of the function allowing other optimizations to do
15860a better job.
15861
15862Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15863
d77de738 15864@opindex funroll-loops
ddf6fe37 15865@item -funroll-loops
d77de738
ML
15866Unroll loops whose number of iterations can be determined at compile time or
15867upon entry to the loop. @option{-funroll-loops} implies
15868@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
15869It also turns on complete loop peeling (i.e.@: complete removal of loops with
15870a small constant number of iterations). This option makes code larger, and may
15871or may not make it run faster.
15872
15873Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15874
d77de738 15875@opindex funroll-all-loops
ddf6fe37 15876@item -funroll-all-loops
d77de738
ML
15877Unroll all loops, even if their number of iterations is uncertain when
15878the loop is entered. This usually makes programs run more slowly.
15879@option{-funroll-all-loops} implies the same options as
15880@option{-funroll-loops}.
15881
d77de738 15882@opindex fpeel-loops
ddf6fe37 15883@item -fpeel-loops
d77de738
ML
15884Peels loops for which there is enough information that they do not
15885roll much (from profile feedback or static analysis). It also turns on
15886complete loop peeling (i.e.@: complete removal of loops with small constant
15887number of iterations).
15888
15889Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
15890
7828dc07
JH
15891@opindex fno-malloc-dce
15892@opindex fmalloc-dce
15893@item -fmalloc-dce
15894Control whether @code{malloc} (and its variants such as @code{calloc} or
15895@code{strdup}), can be optimized away provided its return value is only used
15896as a parameter of @code{free} call or compared with @code{NULL}. If
15897@option{-fmalloc-dce=1} is used, only calls to @code{free} are allowed while
b9857b78 15898with @option{-fmalloc-dce=2} also comparisons with @code{NULL} pointer are
7828dc07
JH
15899considered safe to remove.
15900
15901The default is @option{-fmalloc-dce=2}. See also @option{-fallocation-dce}.
15902
d77de738 15903@opindex fmove-loop-invariants
ddf6fe37 15904@item -fmove-loop-invariants
d77de738
ML
15905Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
15906at level @option{-O1} and higher, except for @option{-Og}.
15907
d77de738 15908@opindex fmove-loop-stores
ddf6fe37 15909@item -fmove-loop-stores
d77de738
ML
15910Enables the loop store motion pass in the GIMPLE loop optimizer. This
15911moves invariant stores to after the end of the loop in exchange for
15912carrying the stored value in a register across the iteration.
15913Note for this option to have an effect @option{-ftree-loop-im} has to
15914be enabled as well. Enabled at level @option{-O1} and higher, except
15915for @option{-Og}.
15916
d77de738 15917@opindex fsplit-loops
ddf6fe37 15918@item -fsplit-loops
d77de738
ML
15919Split a loop into two if it contains a condition that's always true
15920for one side of the iteration space and false for the other.
15921
15922Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15923
d77de738 15924@opindex funswitch-loops
ddf6fe37 15925@item -funswitch-loops
d77de738
ML
15926Move branches with loop invariant conditions out of the loop, with duplicates
15927of the loop on both branches (modified according to result of the condition).
15928
15929Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15930
d77de738 15931@opindex fversion-loops-for-strides
ddf6fe37 15932@item -fversion-loops-for-strides
d77de738
ML
15933If a loop iterates over an array with a variable stride, create another
15934version of the loop that assumes the stride is always one. For example:
15935
15936@smallexample
15937for (int i = 0; i < n; ++i)
15938 x[i * stride] = @dots{};
15939@end smallexample
15940
15941becomes:
15942
15943@smallexample
15944if (stride == 1)
15945 for (int i = 0; i < n; ++i)
15946 x[i] = @dots{};
15947else
15948 for (int i = 0; i < n; ++i)
15949 x[i * stride] = @dots{};
15950@end smallexample
15951
15952This is particularly useful for assumed-shape arrays in Fortran where
15953(for example) it allows better vectorization assuming contiguous accesses.
15954This flag is enabled by default at @option{-O3}.
15955It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15956
d77de738
ML
15957@opindex ffunction-sections
15958@opindex fdata-sections
ddf6fe37
AA
15959@item -ffunction-sections
15960@itemx -fdata-sections
d77de738
ML
15961Place each function or data item into its own section in the output
15962file if the target supports arbitrary sections. The name of the
15963function or the name of the data item determines the section's name
15964in the output file.
15965
15966Use these options on systems where the linker can perform optimizations to
15967improve locality of reference in the instruction space. Most systems using the
15968ELF object format have linkers with such optimizations. On AIX, the linker
15969rearranges sections (CSECTs) based on the call graph. The performance impact
15970varies.
15971
15972Together with a linker garbage collection (linker @option{--gc-sections}
15973option) these options may lead to smaller statically-linked executables (after
15974stripping).
15975
15976On ELF/DWARF systems these options do not degenerate the quality of the debug
15977information. There could be issues with other object files/debug info formats.
15978
15979Only use these options when there are significant benefits from doing so. When
15980you specify these options, the assembler and linker create larger object and
15981executable files and are also slower. These options affect code generation.
15982They prevent optimizations by the compiler and assembler using relative
15983locations inside a translation unit since the locations are unknown until
15984link time. An example of such an optimization is relaxing calls to short call
15985instructions.
15986
d77de738 15987@opindex fstdarg-opt
ddf6fe37 15988@item -fstdarg-opt
d77de738
ML
15989Optimize the prologue of variadic argument functions with respect to usage of
15990those arguments.
15991
d77de738 15992@opindex fsection-anchors
ddf6fe37 15993@item -fsection-anchors
d77de738
ML
15994Try to reduce the number of symbolic address calculations by using
15995shared ``anchor'' symbols to address nearby objects. This transformation
15996can help to reduce the number of GOT entries and GOT accesses on some
15997targets.
15998
15999For example, the implementation of the following function @code{foo}:
16000
16001@smallexample
16002static int a, b, c;
16003int foo (void) @{ return a + b + c; @}
16004@end smallexample
16005
16006@noindent
16007usually calculates the addresses of all three variables, but if you
16008compile it with @option{-fsection-anchors}, it accesses the variables
16009from a common anchor point instead. The effect is similar to the
16010following pseudocode (which isn't valid C):
16011
16012@smallexample
16013int foo (void)
16014@{
16015 register int *xr = &x;
16016 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
16017@}
16018@end smallexample
16019
16020Not all targets support this option.
16021
d77de738 16022@opindex fzero-call-used-regs
ddf6fe37 16023@item -fzero-call-used-regs=@var{choice}
d77de738
ML
16024Zero call-used registers at function return to increase program
16025security by either mitigating Return-Oriented Programming (ROP)
16026attacks or preventing information leakage through registers.
16027
16028The possible values of @var{choice} are the same as for the
16029@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
16030The default is @samp{skip}.
16031
16032You can control this behavior for a specific function by using the function
16033attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
16034
d77de738 16035@opindex param
ddf6fe37 16036@item --param @var{name}=@var{value}
d77de738
ML
16037In some places, GCC uses various constants to control the amount of
16038optimization that is done. For example, GCC does not inline functions
16039that contain more than a certain number of instructions. You can
16040control some of these constants on the command line using the
16041@option{--param} option.
16042
16043The names of specific parameters, and the meaning of the values, are
16044tied to the internals of the compiler, and are subject to change
16045without notice in future releases.
16046
c381327d
GP
16047In order to get the minimal, maximal and default values of a parameter,
16048use the @option{--help=param -Q} options.
d77de738
ML
16049
16050In each case, the @var{value} is an integer. The following choices
16051of @var{name} are recognized for all targets:
16052
16053@table @gcctabopt
8d6d6d53
AP
16054@item phiopt-factor-max-stmts-live
16055When factoring statements out of if/then/else, this is the max # of statements
16056after the defining statement to be allow to extend the lifetime of a name
16057
d77de738
ML
16058@item predictable-branch-outcome
16059When branch is predicted to be taken with probability lower than this threshold
16060(in percent), then it is considered well predictable.
16061
16062@item max-rtl-if-conversion-insns
16063RTL if-conversion tries to remove conditional branches around a block and
16064replace them with conditionally executed instructions. This parameter
16065gives the maximum number of instructions in a block which should be
16066considered for if-conversion. The compiler will
16067also use other heuristics to decide whether if-conversion is likely to be
16068profitable.
16069
29482d4e
AK
16070@item file-cache-files
16071Max number of files in the file cache.
16072The file cache is used to print source lines in diagnostics and do some
16073source checks like @option{-Wmisleading-indentation}.
16074
a42374b6 16075@item file-cache-lines
29482d4e
AK
16076Max number of lines to index into file cache. When 0 this is automatically sized.
16077The file cache is used to print source lines in diagnostics and do some
16078source checks like @option{-Wmisleading-indentation}.
16079
d77de738
ML
16080@item max-rtl-if-conversion-predictable-cost
16081RTL if-conversion will try to remove conditional branches around a block
16082and replace them with conditionally executed instructions. These parameters
16083give the maximum permissible cost for the sequence that would be generated
16084by if-conversion depending on whether the branch is statically determined
16085to be predictable or not. The units for this parameter are the same as
16086those for the GCC internal seq_cost metric. The compiler will try to
16087provide a reasonable default for this parameter using the BRANCH_COST
16088target macro.
16089
16090@item max-crossjump-edges
16091The maximum number of incoming edges to consider for cross-jumping.
16092The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
16093the number of edges incoming to each block. Increasing values mean
16094more aggressive optimization, making the compilation time increase with
16095probably small improvement in executable size.
16096
16097@item min-crossjump-insns
16098The minimum number of instructions that must be matched at the end
16099of two blocks before cross-jumping is performed on them. This
16100value is ignored in the case where all instructions in the block being
16101cross-jumped from are matched.
16102
16103@item max-grow-copy-bb-insns
16104The maximum code size expansion factor when copying basic blocks
16105instead of jumping. The expansion is relative to a jump instruction.
16106
16107@item max-goto-duplication-insns
16108The maximum number of instructions to duplicate to a block that jumps
16109to a computed goto. To avoid @math{O(N^2)} behavior in a number of
16110passes, GCC factors computed gotos early in the compilation process,
16111and unfactors them as late as possible. Only computed jumps at the
16112end of a basic blocks with no more than max-goto-duplication-insns are
16113unfactored.
16114
16115@item max-delay-slot-insn-search
16116The maximum number of instructions to consider when looking for an
16117instruction to fill a delay slot. If more than this arbitrary number of
16118instructions are searched, the time savings from filling the delay slot
16119are minimal, so stop searching. Increasing values mean more
16120aggressive optimization, making the compilation time increase with probably
16121small improvement in execution time.
16122
16123@item max-delay-slot-live-search
16124When trying to fill delay slots, the maximum number of instructions to
16125consider when searching for a block with valid live register
16126information. Increasing this arbitrarily chosen value means more
16127aggressive optimization, increasing the compilation time. This parameter
16128should be removed when the delay slot code is rewritten to maintain the
16129control-flow graph.
16130
16131@item max-gcse-memory
16132The approximate maximum amount of memory in @code{kB} that can be allocated in
16133order to perform the global common subexpression elimination
16134optimization. If more memory than specified is required, the
16135optimization is not done.
16136
16137@item max-gcse-insertion-ratio
16138If the ratio of expression insertions to deletions is larger than this value
16139for any expression, then RTL PRE inserts or removes the expression and thus
16140leaves partially redundant computations in the instruction stream.
16141
16142@item max-pending-list-length
16143The maximum number of pending dependencies scheduling allows
16144before flushing the current state and starting over. Large functions
16145with few branches or calls can create excessively large lists which
16146needlessly consume memory and resources.
16147
16148@item max-modulo-backtrack-attempts
16149The maximum number of backtrack attempts the scheduler should make
16150when modulo scheduling a loop. Larger values can exponentially increase
16151compilation time.
16152
16153@item max-inline-functions-called-once-loop-depth
16154Maximal loop depth of a call considered by inline heuristics that tries to
16155inline all functions called once.
16156
16157@item max-inline-functions-called-once-insns
16158Maximal estimated size of functions produced while inlining functions called
16159once.
16160
16161@item max-inline-insns-single
16162Several parameters control the tree inliner used in GCC@. This number sets the
16163maximum number of instructions (counted in GCC's internal representation) in a
16164single function that the tree inliner considers for inlining. This only
16165affects functions declared inline and methods implemented in a class
a0e64a04 16166declaration (C++).
d77de738
ML
16167
16168
16169@item max-inline-insns-auto
16170When you use @option{-finline-functions} (included in @option{-O3}),
16171a lot of functions that would otherwise not be considered for inlining
16172by the compiler are investigated. To those functions, a different
16173(more restrictive) limit compared to functions declared inline can
16174be applied (@option{--param max-inline-insns-auto}).
16175
16176@item max-inline-insns-small
b9857b78 16177This is the bound applied to calls that are considered relevant with
d77de738
ML
16178@option{-finline-small-functions}.
16179
16180@item max-inline-insns-size
b9857b78
SL
16181This is the bound applied to calls that are optimized for size. Small growth
16182may be desirable to anticipate optimization opportunities exposed by inlining.
d77de738
ML
16183
16184@item uninlined-function-insns
16185Number of instructions accounted by inliner for function overhead such as
16186function prologue and epilogue.
16187
16188@item uninlined-function-time
16189Extra time accounted by inliner for function overhead such as time needed to
16190execute function prologue and epilogue.
16191
16192@item inline-heuristics-hint-percent
16193The scale (in percents) applied to @option{inline-insns-single},
16194@option{inline-insns-single-O2}, @option{inline-insns-auto}
16195when inline heuristics hints that inlining is
16196very profitable (will enable later optimizations).
16197
16198@item uninlined-thunk-insns
16199@item uninlined-thunk-time
16200Same as @option{--param uninlined-function-insns} and
16201@option{--param uninlined-function-time} but applied to function thunks.
16202
16203@item inline-min-speedup
16204When estimated performance improvement of caller + callee runtime exceeds this
16205threshold (in percent), the function can be inlined regardless of the limit on
16206@option{--param max-inline-insns-single} and @option{--param
16207max-inline-insns-auto}.
16208
16209@item large-function-insns
16210The limit specifying really large functions. For functions larger than this
16211limit after inlining, inlining is constrained by
16212@option{--param large-function-growth}. This parameter is useful primarily
16213to avoid extreme compilation time caused by non-linear algorithms used by the
16214back end.
16215
16216@item large-function-growth
b9857b78 16217Specifies maximal growth of large functions caused by inlining in percents.
d77de738
ML
16218For example, parameter value 100 limits large function growth to 2.0 times
16219the original size.
16220
16221@item large-unit-insns
16222The limit specifying large translation unit. Growth caused by inlining of
16223units larger than this limit is limited by @option{--param inline-unit-growth}.
16224For small units this might be too tight.
16225For example, consider a unit consisting of function A
16226that is inline and B that just calls A three times. If B is small relative to
16227A, the growth of unit is 300\% and yet such inlining is very sane. For very
16228large units consisting of small inlineable functions, however, the overall unit
16229growth limit is needed to avoid exponential explosion of code size. Thus for
16230smaller units, the size is increased to @option{--param large-unit-insns}
16231before applying @option{--param inline-unit-growth}.
16232
16233@item lazy-modules
16234Maximum number of concurrently open C++ module files when lazy loading.
16235
16236@item inline-unit-growth
16237Specifies maximal overall growth of the compilation unit caused by inlining.
16238For example, parameter value 20 limits unit growth to 1.2 times the original
16239size. Cold functions (either marked cold via an attribute or by profile
16240feedback) are not accounted into the unit size.
16241
16242@item ipa-cp-unit-growth
16243Specifies maximal overall growth of the compilation unit caused by
16244interprocedural constant propagation. For example, parameter value 10 limits
16245unit growth to 1.1 times the original size.
16246
16247@item ipa-cp-large-unit-insns
16248The size of translation unit that IPA-CP pass considers large.
16249
16250@item large-stack-frame
16251The limit specifying large stack frames. While inlining the algorithm is trying
16252to not grow past this limit too much.
16253
16254@item large-stack-frame-growth
16255Specifies maximal growth of large stack frames caused by inlining in percents.
16256For example, parameter value 1000 limits large stack frame growth to 11 times
16257the original size.
16258
16259@item max-inline-insns-recursive
16260@itemx max-inline-insns-recursive-auto
16261Specifies the maximum number of instructions an out-of-line copy of a
16262self-recursive inline
16263function can grow into by performing recursive inlining.
16264
16265@option{--param max-inline-insns-recursive} applies to functions
16266declared inline.
16267For functions not declared inline, recursive inlining
16268happens only when @option{-finline-functions} (included in @option{-O3}) is
16269enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
16270
16271@item max-inline-recursive-depth
16272@itemx max-inline-recursive-depth-auto
16273Specifies the maximum recursion depth used for recursive inlining.
16274
16275@option{--param max-inline-recursive-depth} applies to functions
16276declared inline. For functions not declared inline, recursive inlining
16277happens only when @option{-finline-functions} (included in @option{-O3}) is
16278enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
16279
16280@item min-inline-recursive-probability
16281Recursive inlining is profitable only for function having deep recursion
16282in average and can hurt for function having little recursion depth by
16283increasing the prologue size or complexity of function body to other
16284optimizers.
16285
16286When profile feedback is available (see @option{-fprofile-generate}) the actual
16287recursion depth can be guessed from the probability that function recurses
16288via a given call expression. This parameter limits inlining only to call
16289expressions whose probability exceeds the given threshold (in percents).
16290
16291@item early-inlining-insns
16292Specify growth that the early inliner can make. In effect it increases
16293the amount of inlining for code having a large abstraction penalty.
16294
16295@item max-early-inliner-iterations
16296Limit of iterations of the early inliner. This basically bounds
16297the number of nested indirect calls the early inliner can resolve.
16298Deeper chains are still handled by late inlining.
16299
16300@item comdat-sharing-probability
16301Probability (in percent) that C++ inline function with comdat visibility
16302are shared across multiple compilation units.
16303
16304@item modref-max-bases
16305@item modref-max-refs
16306@item modref-max-accesses
16307Specifies the maximal number of base pointers, references and accesses stored
16308for a single function by mod/ref analysis.
16309
16310@item modref-max-tests
16311Specifies the maxmal number of tests alias oracle can perform to disambiguate
16312memory locations using the mod/ref information. This parameter ought to be
16313bigger than @option{--param modref-max-bases} and @option{--param
16314modref-max-refs}.
16315
16316@item modref-max-depth
16317Specifies the maximum depth of DFS walk used by modref escape analysis.
16318Setting to 0 disables the analysis completely.
16319
16320@item modref-max-escape-points
16321Specifies the maximum number of escape points tracked by modref per SSA-name.
16322
16323@item modref-max-adjustments
16324Specifies the maximum number the access range is enlarged during modref dataflow
16325analysis.
16326
16327@item profile-func-internal-id
16328A parameter to control whether to use function internal id in profile
16329database lookup. If the value is 0, the compiler uses an id that
16330is based on function assembler name and filename, which makes old profile
16331data more tolerant to source changes such as function reordering etc.
16332
16333@item min-vect-loop-bound
16334The minimum number of iterations under which loops are not vectorized
16335when @option{-ftree-vectorize} is used. The number of iterations after
16336vectorization needs to be greater than the value specified by this option
16337to allow vectorization.
16338
16339@item gcse-cost-distance-ratio
16340Scaling factor in calculation of maximum distance an expression
16341can be moved by GCSE optimizations. This is currently supported only in the
16342code hoisting pass. The bigger the ratio, the more aggressive code hoisting
16343is with simple expressions, i.e., the expressions that have cost
16344less than @option{gcse-unrestricted-cost}. Specifying 0 disables
16345hoisting of simple expressions.
16346
16347@item gcse-unrestricted-cost
16348Cost, roughly measured as the cost of a single typical machine
16349instruction, at which GCSE optimizations do not constrain
16350the distance an expression can travel. This is currently
16351supported only in the code hoisting pass. The lesser the cost,
a0e64a04 16352the more aggressive code hoisting is. Specifying 0
d77de738
ML
16353allows all expressions to travel unrestricted distances.
16354
16355@item max-hoist-depth
16356The depth of search in the dominator tree for expressions to hoist.
16357This is used to avoid quadratic behavior in hoisting algorithm.
16358The value of 0 does not limit on the search, but may slow down compilation
16359of huge functions.
16360
16361@item max-tail-merge-comparisons
16362The maximum amount of similar bbs to compare a bb with. This is used to
16363avoid quadratic behavior in tree tail merging.
16364
16365@item max-tail-merge-iterations
16366The maximum amount of iterations of the pass over the function. This is used to
16367limit compilation time in tree tail merging.
16368
16369@item store-merging-allow-unaligned
16370Allow the store merging pass to introduce unaligned stores if it is legal to
16371do so.
16372
16373@item max-stores-to-merge
16374The maximum number of stores to attempt to merge into wider stores in the store
16375merging pass.
16376
16377@item max-store-chains-to-track
16378The maximum number of store chains to track at the same time in the attempt
16379to merge them into wider stores in the store merging pass.
16380
16381@item max-stores-to-track
16382The maximum number of stores to track at the same time in the attemt to
16383to merge them into wider stores in the store merging pass.
16384
16385@item max-unrolled-insns
16386The maximum number of instructions that a loop may have to be unrolled.
16387If a loop is unrolled, this parameter also determines how many times
16388the loop code is unrolled.
16389
16390@item max-average-unrolled-insns
16391The maximum number of instructions biased by probabilities of their execution
16392that a loop may have to be unrolled. If a loop is unrolled,
16393this parameter also determines how many times the loop code is unrolled.
16394
16395@item max-unroll-times
16396The maximum number of unrollings of a single loop.
16397
16398@item max-peeled-insns
16399The maximum number of instructions that a loop may have to be peeled.
16400If a loop is peeled, this parameter also determines how many times
16401the loop code is peeled.
16402
16403@item max-peel-times
16404The maximum number of peelings of a single loop.
16405
16406@item max-peel-branches
16407The maximum number of branches on the hot path through the peeled sequence.
16408
16409@item max-completely-peeled-insns
16410The maximum number of insns of a completely peeled loop.
16411
16412@item max-completely-peel-times
16413The maximum number of iterations of a loop to be suitable for complete peeling.
16414
16415@item max-completely-peel-loop-nest-depth
16416The maximum depth of a loop nest suitable for complete peeling.
16417
16418@item max-unswitch-insns
16419The maximum number of insns of an unswitched loop.
16420
5b50850c
RB
16421@item max-unswitch-depth
16422The maximum depth of a loop nest to be unswitched.
16423
d77de738
ML
16424@item lim-expensive
16425The minimum cost of an expensive expression in the loop invariant motion.
16426
16427@item min-loop-cond-split-prob
16428When FDO profile information is available, @option{min-loop-cond-split-prob}
16429specifies minimum threshold for probability of semi-invariant condition
16430statement to trigger loop split.
16431
16432@item iv-consider-all-candidates-bound
16433Bound on number of candidates for induction variables, below which
16434all candidates are considered for each use in induction variable
16435optimizations. If there are more candidates than this,
16436only the most relevant ones are considered to avoid quadratic time complexity.
16437
16438@item iv-max-considered-uses
16439The induction variable optimizations give up on loops that contain more
16440induction variable uses.
16441
16442@item iv-always-prune-cand-set-bound
16443If the number of candidates in the set is smaller than this value,
16444always try to remove unnecessary ivs from the set
16445when adding a new one.
16446
16447@item avg-loop-niter
16448Average number of iterations of a loop.
16449
16450@item dse-max-object-size
16451Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
16452Larger values may result in larger compilation times.
16453
16454@item dse-max-alias-queries-per-store
16455Maximum number of queries into the alias oracle per store.
16456Larger values result in larger compilation times and may result in more
16457removed dead stores.
16458
16459@item scev-max-expr-size
16460Bound on size of expressions used in the scalar evolutions analyzer.
16461Large expressions slow the analyzer.
16462
16463@item scev-max-expr-complexity
16464Bound on the complexity of the expressions in the scalar evolutions analyzer.
16465Complex expressions slow the analyzer.
16466
16467@item max-tree-if-conversion-phi-args
16468Maximum number of arguments in a PHI supported by TREE if conversion
16469unless the loop is marked with simd pragma.
16470
16471@item vect-max-layout-candidates
16472The maximum number of possible vector layouts (such as permutations)
16473to consider when optimizing to-be-vectorized code.
16474
16475@item vect-max-version-for-alignment-checks
16476The maximum number of run-time checks that can be performed when
16477doing loop versioning for alignment in the vectorizer.
16478
16479@item vect-max-version-for-alias-checks
16480The maximum number of run-time checks that can be performed when
16481doing loop versioning for alias in the vectorizer.
16482
16483@item vect-max-peeling-for-alignment
16484The maximum number of loop peels to enhance access alignment
16485for vectorizer. Value -1 means no limit.
16486
16487@item max-iterations-to-track
16488The maximum number of iterations of a loop the brute-force algorithm
16489for analysis of the number of iterations of the loop tries to evaluate.
16490
16491@item hot-bb-count-fraction
16492The denominator n of fraction 1/n of the maximal execution count of a
16493basic block in the entire program that a basic block needs to at least
16494have in order to be considered hot. The default is 10000, which means
16495that a basic block is considered hot if its execution count is greater
16496than 1/10000 of the maximal execution count. 0 means that it is never
16497considered hot. Used in non-LTO mode.
16498
16499@item hot-bb-count-ws-permille
16500The number of most executed permilles, ranging from 0 to 1000, of the
16501profiled execution of the entire program to which the execution count
16502of a basic block must be part of in order to be considered hot. The
16503default is 990, which means that a basic block is considered hot if
16504its execution count contributes to the upper 990 permilles, or 99.0%,
16505of the profiled execution of the entire program. 0 means that it is
16506never considered hot. Used in LTO mode.
16507
16508@item hot-bb-frequency-fraction
16509The denominator n of fraction 1/n of the execution frequency of the
16510entry block of a function that a basic block of this function needs
16511to at least have in order to be considered hot. The default is 1000,
16512which means that a basic block is considered hot in a function if it
16513is executed more frequently than 1/1000 of the frequency of the entry
16514block of the function. 0 means that it is never considered hot.
16515
16516@item unlikely-bb-count-fraction
16517The denominator n of fraction 1/n of the number of profiled runs of
16518the entire program below which the execution count of a basic block
16519must be in order for the basic block to be considered unlikely executed.
16520The default is 20, which means that a basic block is considered unlikely
16521executed if it is executed in fewer than 1/20, or 5%, of the runs of
16522the program. 0 means that it is always considered unlikely executed.
16523
16524@item max-predicted-iterations
16525The maximum number of loop iterations we predict statically. This is useful
16526in cases where a function contains a single loop with known bound and
16527another loop with unknown bound.
16528The known number of iterations is predicted correctly, while
16529the unknown number of iterations average to roughly 10. This means that the
16530loop without bounds appears artificially cold relative to the other one.
16531
16532@item builtin-expect-probability
16533Control the probability of the expression having the specified value. This
16534parameter takes a percentage (i.e.@: 0 ... 100) as input.
16535
16536@item builtin-string-cmp-inline-length
a0e64a04 16537The maximum length of a constant string for a builtin string cmp call
d77de738
ML
16538eligible for inlining.
16539
16540@item align-threshold
16541
16542Select fraction of the maximal frequency of executions of a basic block in
16543a function to align the basic block.
16544
16545@item align-loop-iterations
16546
16547A loop expected to iterate at least the selected number of iterations is
16548aligned.
16549
16550@item tracer-dynamic-coverage
16551@itemx tracer-dynamic-coverage-feedback
16552
16553This value is used to limit superblock formation once the given percentage of
16554executed instructions is covered. This limits unnecessary code size
16555expansion.
16556
16557The @option{tracer-dynamic-coverage-feedback} parameter
16558is used only when profile
16559feedback is available. The real profiles (as opposed to statically estimated
16560ones) are much less balanced allowing the threshold to be larger value.
16561
16562@item tracer-max-code-growth
16563Stop tail duplication once code growth has reached given percentage. This is
16564a rather artificial limit, as most of the duplicates are eliminated later in
16565cross jumping, so it may be set to much higher values than is the desired code
16566growth.
16567
16568@item tracer-min-branch-ratio
16569
16570Stop reverse growth when the reverse probability of best edge is less than this
16571threshold (in percent).
16572
16573@item tracer-min-branch-probability
16574@itemx tracer-min-branch-probability-feedback
16575
16576Stop forward growth if the best edge has probability lower than this
16577threshold.
16578
16579Similarly to @option{tracer-dynamic-coverage} two parameters are
16580provided. @option{tracer-min-branch-probability-feedback} is used for
16581compilation with profile feedback and @option{tracer-min-branch-probability}
16582compilation without. The value for compilation with profile feedback
16583needs to be more conservative (higher) in order to make tracer
16584effective.
16585
16586@item stack-clash-protection-guard-size
16587Specify the size of the operating system provided stack guard as
165882 raised to @var{num} bytes. Higher values may reduce the
16589number of explicit probes, but a value larger than the operating system
16590provided guard will leave code vulnerable to stack clash style attacks.
16591
16592@item stack-clash-protection-probe-interval
16593Stack clash protection involves probing stack space as it is allocated. This
16594param controls the maximum distance between probes into the stack as 2 raised
16595to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
16596larger than the operating system provided guard will leave code vulnerable to
16597stack clash style attacks.
16598
16599@item max-cse-path-length
16600
16601The maximum number of basic blocks on path that CSE considers.
16602
16603@item max-cse-insns
16604The maximum number of instructions CSE processes before flushing.
16605
16606@item ggc-min-expand
16607
16608GCC uses a garbage collector to manage its own memory allocation. This
16609parameter specifies the minimum percentage by which the garbage
16610collector's heap should be allowed to expand between collections.
16611Tuning this may improve compilation speed; it has no effect on code
16612generation.
16613
16614The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
16615RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
16616the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
16617GCC is not able to calculate RAM on a particular platform, the lower
16618bound of 30% is used. Setting this parameter and
16619@option{ggc-min-heapsize} to zero causes a full collection to occur at
16620every opportunity. This is extremely slow, but can be useful for
16621debugging.
16622
16623@item ggc-min-heapsize
16624
16625Minimum size of the garbage collector's heap before it begins bothering
16626to collect garbage. The first collection occurs after the heap expands
16627by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
16628tuning this may improve compilation speed, and has no effect on code
16629generation.
16630
16631The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
16632tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
16633with a lower bound of 4096 (four megabytes) and an upper bound of
16634131072 (128 megabytes). If GCC is not able to calculate RAM on a
16635particular platform, the lower bound is used. Setting this parameter
16636very large effectively disables garbage collection. Setting this
16637parameter and @option{ggc-min-expand} to zero causes a full collection
16638to occur at every opportunity.
16639
16640@item max-reload-search-insns
16641The maximum number of instruction reload should look backward for equivalent
16642register. Increasing values mean more aggressive optimization, making the
16643compilation time increase with probably slightly better performance.
16644
16645@item max-cselib-memory-locations
16646The maximum number of memory locations cselib should take into account.
16647Increasing values mean more aggressive optimization, making the compilation time
16648increase with probably slightly better performance.
16649
16650@item max-sched-ready-insns
16651The maximum number of instructions ready to be issued the scheduler should
16652consider at any given time during the first scheduling pass. Increasing
16653values mean more thorough searches, making the compilation time increase
16654with probably little benefit.
16655
16656@item max-sched-region-blocks
16657The maximum number of blocks in a region to be considered for
16658interblock scheduling.
16659
16660@item max-pipeline-region-blocks
16661The maximum number of blocks in a region to be considered for
16662pipelining in the selective scheduler.
16663
16664@item max-sched-region-insns
16665The maximum number of insns in a region to be considered for
16666interblock scheduling.
16667
16668@item max-pipeline-region-insns
16669The maximum number of insns in a region to be considered for
16670pipelining in the selective scheduler.
16671
16672@item min-spec-prob
16673The minimum probability (in percents) of reaching a source block
16674for interblock speculative scheduling.
16675
16676@item max-sched-extend-regions-iters
16677The maximum number of iterations through CFG to extend regions.
16678A value of 0 disables region extensions.
16679
16680@item max-sched-insn-conflict-delay
16681The maximum conflict delay for an insn to be considered for speculative motion.
16682
16683@item sched-spec-prob-cutoff
16684The minimal probability of speculation success (in percents), so that
16685speculative insns are scheduled.
16686
16687@item sched-state-edge-prob-cutoff
16688The minimum probability an edge must have for the scheduler to save its
16689state across it.
16690
16691@item sched-mem-true-dep-cost
16692Minimal distance (in CPU cycles) between store and load targeting same
16693memory locations.
16694
16695@item selsched-max-lookahead
16696The maximum size of the lookahead window of selective scheduling. It is a
16697depth of search for available instructions.
16698
16699@item selsched-max-sched-times
16700The maximum number of times that an instruction is scheduled during
16701selective scheduling. This is the limit on the number of iterations
16702through which the instruction may be pipelined.
16703
16704@item selsched-insns-to-rename
16705The maximum number of best instructions in the ready list that are considered
16706for renaming in the selective scheduler.
16707
16708@item sms-min-sc
16709The minimum value of stage count that swing modulo scheduler
16710generates.
16711
16712@item max-last-value-rtl
16713The maximum size measured as number of RTLs that can be recorded in an expression
16714in combiner for a pseudo register as last known value of that register.
16715
16716@item max-combine-insns
16717The maximum number of instructions the RTL combiner tries to combine.
16718
a1a0026c
RS
16719@item max-combine-search-insns
16720The maximum number of instructions that the RTL combiner searches in order
16721to find the next use of a given register definition. If this limit is reached
16722without finding such a use, the combiner will stop trying to optimize the
16723definition.
16724
16725Currently this limit only applies after certain successful combination
16726attempts, but it could be extended to other cases in future.
16727
d77de738
ML
16728@item integer-share-limit
16729Small integer constants can use a shared data structure, reducing the
16730compiler's memory usage and increasing its speed. This sets the maximum
16731value of a shared integer constant.
16732
16733@item ssp-buffer-size
16734The minimum size of buffers (i.e.@: arrays) that receive stack smashing
16735protection when @option{-fstack-protector} is used.
16736
16737@item min-size-for-stack-sharing
16738The minimum size of variables taking part in stack slot sharing when not
16739optimizing.
16740
16741@item max-jump-thread-duplication-stmts
16742Maximum number of statements allowed in a block that needs to be
16743duplicated when threading jumps.
16744
16745@item max-jump-thread-paths
16746The maximum number of paths to consider when searching for jump threading
16747opportunities. When arriving at a block, incoming edges are only considered
16748if the number of paths to be searched so far multiplied by the number of
16749incoming edges does not exhaust the specified maximum number of paths to
16750consider.
16751
16752@item max-fields-for-field-sensitive
16753Maximum number of fields in a structure treated in
16754a field sensitive manner during pointer analysis.
16755
16756@item prefetch-latency
16757Estimate on average number of instructions that are executed before
16758prefetch finishes. The distance prefetched ahead is proportional
16759to this constant. Increasing this number may also lead to less
16760streams being prefetched (see @option{simultaneous-prefetches}).
16761
16762@item simultaneous-prefetches
16763Maximum number of prefetches that can run at the same time.
16764
16765@item l1-cache-line-size
16766The size of cache line in L1 data cache, in bytes.
16767
16768@item l1-cache-size
16769The size of L1 data cache, in kilobytes.
16770
16771@item l2-cache-size
16772The size of L2 data cache, in kilobytes.
16773
16774@item prefetch-dynamic-strides
16775Whether the loop array prefetch pass should issue software prefetch hints
16776for strides that are non-constant. In some cases this may be
16777beneficial, though the fact the stride is non-constant may make it
16778hard to predict when there is clear benefit to issuing these hints.
16779
16780Set to 1 if the prefetch hints should be issued for non-constant
16781strides. Set to 0 if prefetch hints should be issued only for strides that
16782are known to be constant and below @option{prefetch-minimum-stride}.
16783
16784@item prefetch-minimum-stride
16785Minimum constant stride, in bytes, to start using prefetch hints for. If
16786the stride is less than this threshold, prefetch hints will not be issued.
16787
16788This setting is useful for processors that have hardware prefetchers, in
16789which case there may be conflicts between the hardware prefetchers and
16790the software prefetchers. If the hardware prefetchers have a maximum
16791stride they can handle, it should be used here to improve the use of
16792software prefetchers.
16793
16794A value of -1 means we don't have a threshold and therefore
16795prefetch hints can be issued for any constant stride.
16796
16797This setting is only useful for strides that are known and constant.
16798
16799@item destructive-interference-size
16800@item constructive-interference-size
16801The values for the C++17 variables
16802@code{std::hardware_destructive_interference_size} and
16803@code{std::hardware_constructive_interference_size}. The destructive
16804interference size is the minimum recommended offset between two
16805independent concurrently-accessed objects; the constructive
16806interference size is the maximum recommended size of contiguous memory
16807accessed together. Typically both will be the size of an L1 cache
16808line for the target, in bytes. For a generic target covering a range of L1
16809cache line sizes, typically the constructive interference size will be
16810the small end of the range and the destructive size will be the large
16811end.
16812
16813The destructive interference size is intended to be used for layout,
16814and thus has ABI impact. The default value is not expected to be
16815stable, and on some targets varies with @option{-mtune}, so use of
16816this variable in a context where ABI stability is important, such as
16817the public interface of a library, is strongly discouraged; if it is
16818used in that context, users can stabilize the value using this
16819option.
16820
16821The constructive interference size is less sensitive, as it is
16822typically only used in a @samp{static_assert} to make sure that a type
16823fits within a cache line.
16824
16825See also @option{-Winterference-size}.
16826
16827@item loop-interchange-max-num-stmts
16828The maximum number of stmts in a loop to be interchanged.
16829
16830@item loop-interchange-stride-ratio
16831The minimum ratio between stride of two loops for interchange to be profitable.
16832
16833@item min-insn-to-prefetch-ratio
16834The minimum ratio between the number of instructions and the
16835number of prefetches to enable prefetching in a loop.
16836
16837@item prefetch-min-insn-to-mem-ratio
16838The minimum ratio between the number of instructions and the
16839number of memory references to enable prefetching in a loop.
16840
16841@item use-canonical-types
16842Whether the compiler should use the ``canonical'' type system.
16843Should always be 1, which uses a more efficient internal
16844mechanism for comparing types in C++ and Objective-C++. However, if
16845bugs in the canonical type system are causing compilation failures,
16846set this value to 0 to disable canonical types.
16847
16848@item switch-conversion-max-branch-ratio
16849Switch initialization conversion refuses to create arrays that are
16850bigger than @option{switch-conversion-max-branch-ratio} times the number of
16851branches in the switch.
16852
56946c80
FK
16853@item switch-lower-slow-alg-max-cases
16854Maximum number of cases for slow switch lowering algorithms to be used.
16855
d77de738
ML
16856@item max-partial-antic-length
16857Maximum length of the partial antic set computed during the tree
16858partial redundancy elimination optimization (@option{-ftree-pre}) when
16859optimizing at @option{-O3} and above. For some sorts of source code
16860the enhanced partial redundancy elimination optimization can run away,
16861consuming all of the memory available on the host machine. This
16862parameter sets a limit on the length of the sets that are computed,
16863which prevents the runaway behavior. Setting a value of 0 for
16864this parameter allows an unlimited set length.
16865
16866@item rpo-vn-max-loop-depth
16867Maximum loop depth that is value-numbered optimistically.
16868When the limit hits the innermost
16869@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
16870loop nest are value-numbered optimistically and the remaining ones not.
16871
16872@item sccvn-max-alias-queries-per-access
16873Maximum number of alias-oracle queries we perform when looking for
16874redundancies for loads and stores. If this limit is hit the search
16875is aborted and the load or store is not considered redundant. The
16876number of queries is algorithmically limited to the number of
16877stores on all paths from the load to the function entry.
16878
16879@item ira-max-loops-num
16880IRA uses regional register allocation by default. If a function
16881contains more loops than the number given by this parameter, only at most
16882the given number of the most frequently-executed loops form regions
16883for regional register allocation.
16884
a0e64a04 16885@item ira-max-conflict-table-size
d77de738
ML
16886Although IRA uses a sophisticated algorithm to compress the conflict
16887table, the table can still require excessive amounts of memory for
16888huge functions. If the conflict table for a function could be more
16889than the size in MB given by this parameter, the register allocator
16890instead uses a faster, simpler, and lower-quality
a0e64a04 16891algorithm that does not require building a pseudo-register conflict table.
d77de738
ML
16892
16893@item ira-loop-reserved-regs
16894IRA can be used to evaluate more accurate register pressure in loops
16895for decisions to move loop invariants (see @option{-O3}). The number
16896of available registers reserved for some other purposes is given
16897by this parameter. Default of the parameter
16898is the best found from numerous experiments.
16899
16900@item ira-consider-dup-in-all-alts
16901Make IRA to consider matching constraint (duplicated operand number)
16902heavily in all available alternatives for preferred register class.
16903If it is set as zero, it means IRA only respects the matching
16904constraint when it's in the only available alternative with an
16905appropriate register class. Otherwise, it means IRA will check all
16906available alternatives for preferred register class even if it has
16907found some choice with an appropriate register class and respect the
16908found qualified matching constraint.
16909
9847c753
ML
16910@item ira-simple-lra-insn-threshold
16911Approximate function insn number in 1K units triggering simple local RA.
16912
d77de738
ML
16913@item lra-inheritance-ebb-probability-cutoff
16914LRA tries to reuse values reloaded in registers in subsequent insns.
16915This optimization is called inheritance. EBB is used as a region to
16916do this optimization. The parameter defines a minimal fall-through
16917edge probability in percentage used to add BB to inheritance EBB in
16918LRA. The default value was chosen
16919from numerous runs of SPEC2000 on x86-64.
16920
16921@item loop-invariant-max-bbs-in-loop
16922Loop invariant motion can be very expensive, both in compilation time and
16923in amount of needed compile-time memory, with very large loops. Loops
16924with more basic blocks than this parameter won't have loop invariant
16925motion optimization performed on them.
16926
16927@item loop-max-datarefs-for-datadeps
16928Building data dependencies is expensive for very large loops. This
16929parameter limits the number of data references in loops that are
16930considered for data dependence analysis. These large loops are no
16931handled by the optimizations using loop data dependencies.
16932
16933@item max-vartrack-size
16934Sets a maximum number of hash table slots to use during variable
16935tracking dataflow analysis of any function. If this limit is exceeded
16936with variable tracking at assignments enabled, analysis for that
16937function is retried without it, after removing all debug insns from
16938the function. If the limit is exceeded even without debug insns, var
16939tracking analysis is completely disabled for the function. Setting
16940the parameter to zero makes it unlimited.
16941
16942@item max-vartrack-expr-depth
16943Sets a maximum number of recursion levels when attempting to map
16944variable names or debug temporaries to value expressions. This trades
16945compilation time for more complete debug information. If this is set too
16946low, value expressions that are available and could be represented in
16947debug information may end up not being used; setting this higher may
16948enable the compiler to find more complex debug expressions, but compile
16949time and memory use may grow.
16950
16951@item max-debug-marker-count
16952Sets a threshold on the number of debug markers (e.g.@: begin stmt
16953markers) to avoid complexity explosion at inlining or expanding to RTL.
16954If a function has more such gimple stmts than the set limit, such stmts
16955will be dropped from the inlined copy of a function, and from its RTL
16956expansion.
16957
16958@item min-nondebug-insn-uid
16959Use uids starting at this parameter for nondebug insns. The range below
16960the parameter is reserved exclusively for debug insns created by
16961@option{-fvar-tracking-assignments}, but debug insns may get
16962(non-overlapping) uids above it if the reserved range is exhausted.
16963
10478270
MJ
16964@item ipa-sra-deref-prob-threshold
16965IPA-SRA replaces a pointer which is known not be NULL with one or more
16966new parameters only when the probability (in percent, relative to
16967function entry) of it being dereferenced is higher than this parameter.
16968
d77de738
ML
16969@item ipa-sra-ptr-growth-factor
16970IPA-SRA replaces a pointer to an aggregate with one or more new
16971parameters only when their cumulative size is less or equal to
16972@option{ipa-sra-ptr-growth-factor} times the size of the original
16973pointer parameter.
16974
69363825
ML
16975@item ipa-sra-ptrwrap-growth-factor
16976Additional maximum allowed growth of total size of new parameters
16977that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
16978if it points to a local variable that the caller only writes to and
16979passes it as an argument to other functions.
69363825 16980
d77de738
ML
16981@item ipa-sra-max-replacements
16982Maximum pieces of an aggregate that IPA-SRA tracks. As a
16983consequence, it is also the maximum number of replacements of a formal
16984parameter.
16985
16986@item sra-max-scalarization-size-Ospeed
16987@itemx sra-max-scalarization-size-Osize
16988The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
16989replace scalar parts of aggregates with uses of independent scalar
16990variables. These parameters control the maximum size, in storage units,
16991of aggregate which is considered for replacement when compiling for
16992speed
16993(@option{sra-max-scalarization-size-Ospeed}) or size
16994(@option{sra-max-scalarization-size-Osize}) respectively.
16995
16996@item sra-max-propagations
16997The maximum number of artificial accesses that Scalar Replacement of
16998Aggregates (SRA) will track, per one local variable, in order to
16999facilitate copy propagation.
17000
17001@item tm-max-aggregate-size
17002When making copies of thread-local variables in a transaction, this
17003parameter specifies the size in bytes after which variables are
17004saved with the logging functions as opposed to save/restore code
17005sequence pairs. This option only applies when using
17006@option{-fgnu-tm}.
17007
17008@item graphite-max-nb-scop-params
17009To avoid exponential effects in the Graphite loop transforms, the
17010number of parameters in a Static Control Part (SCoP) is bounded.
17011A value of zero can be used to lift
17012the bound. A variable whose value is unknown at compilation time and
17013defined outside a SCoP is a parameter of the SCoP.
17014
551935d1
AO
17015@item hardcfr-max-blocks
17016Disable @option{-fharden-control-flow-redundancy} for functions with a
17017larger number of blocks than the specified value. Zero removes any
17018limit.
17019
17020@item hardcfr-max-inline-blocks
17021Force @option{-fharden-control-flow-redundancy} to use out-of-line
17022checking for functions with a larger number of basic blocks than the
17023specified value.
17024
d77de738
ML
17025@item loop-block-tile-size
17026Loop blocking or strip mining transforms, enabled with
17027@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
17028loop in the loop nest by a given number of iterations. The strip
17029length can be changed using the @option{loop-block-tile-size}
17030parameter.
17031
17032@item ipa-jump-function-lookups
17033Specifies number of statements visited during jump function offset discovery.
17034
17035@item ipa-cp-value-list-size
17036IPA-CP attempts to track all possible values and types passed to a function's
17037parameter in order to propagate them and perform devirtualization.
17038@option{ipa-cp-value-list-size} is the maximum number of values and types it
17039stores per one formal parameter of a function.
17040
17041@item ipa-cp-eval-threshold
17042IPA-CP calculates its own score of cloning profitability heuristics
17043and performs those cloning opportunities with scores that exceed
17044@option{ipa-cp-eval-threshold}.
17045
17046@item ipa-cp-max-recursive-depth
17047Maximum depth of recursive cloning for self-recursive function.
17048
17049@item ipa-cp-min-recursive-probability
17050Recursive cloning only when the probability of call being executed exceeds
17051the parameter.
17052
d77de738
ML
17053@item ipa-cp-recursive-freq-factor
17054The number of times interprocedural copy propagation expects recursive
17055functions to call themselves.
17056
17057@item ipa-cp-recursion-penalty
17058Percentage penalty the recursive functions will receive when they
17059are evaluated for cloning.
17060
17061@item ipa-cp-single-call-penalty
17062Percentage penalty functions containing a single call to another
17063function will receive when they are evaluated for cloning.
17064
17065@item ipa-max-agg-items
17066IPA-CP is also capable to propagate a number of scalar values passed
17067in an aggregate. @option{ipa-max-agg-items} controls the maximum
17068number of such values per one parameter.
17069
17070@item ipa-cp-loop-hint-bonus
17071When IPA-CP determines that a cloning candidate would make the number
17072of iterations of a loop known, it adds a bonus of
17073@option{ipa-cp-loop-hint-bonus} to the profitability score of
17074the candidate.
17075
17076@item ipa-max-loop-predicates
17077The maximum number of different predicates IPA will use to describe when
17078loops in a function have known properties.
17079
17080@item ipa-max-aa-steps
17081During its analysis of function bodies, IPA-CP employs alias analysis
17082in order to track values pointed to by function parameters. In order
17083not spend too much time analyzing huge functions, it gives up and
17084consider all memory clobbered after examining
17085@option{ipa-max-aa-steps} statements modifying memory.
17086
17087@item ipa-max-switch-predicate-bounds
17088Maximal number of boundary endpoints of case ranges of switch statement.
17089For switch exceeding this limit, IPA-CP will not construct cloning cost
17090predicate, which is used to estimate cloning benefit, for default case
17091of the switch statement.
17092
17093@item ipa-max-param-expr-ops
17094IPA-CP will analyze conditional statement that references some function
17095parameter to estimate benefit for cloning upon certain constant value.
17096But if number of operations in a parameter expression exceeds
17097@option{ipa-max-param-expr-ops}, the expression is treated as complicated
17098one, and is not handled by IPA analysis.
17099
17100@item lto-partitions
17101Specify desired number of partitions produced during WHOPR compilation.
17102The number of partitions should exceed the number of CPUs used for compilation.
17103
17104@item lto-min-partition
17105Size of minimal partition for WHOPR (in estimated instructions).
17106This prevents expenses of splitting very small programs into too many
17107partitions.
17108
17109@item lto-max-partition
17110Size of max partition for WHOPR (in estimated instructions).
17111to provide an upper bound for individual size of partition.
17112Meant to be used only with balanced partitioning.
17113
b7fb18dc
KT
17114@item lto-partition-locality-frequency-cutoff
17115The denominator n of fraction 1/n of the execution frequency of callee to be
17116cloned for a particular caller. Special value of 0 dictates to always clone
17117without a cut-off.
17118
17119@item lto-partition-locality-size-cutoff
17120Size cut-off for callee including inlined calls to be cloned for a particular
17121caller.
17122
17123@item lto-max-locality-partition
17124Maximal size of a locality partition for LTO (in estimated instructions).
17125Value of 0 results in default value being used.
17126
d77de738
ML
17127@item lto-max-streaming-parallelism
17128Maximal number of parallel processes used for LTO streaming.
17129
17130@item cxx-max-namespaces-for-diagnostic-help
17131The maximum number of namespaces to consult for suggestions when C++
17132name lookup fails for an identifier.
17133
17134@item sink-frequency-threshold
17135The maximum relative execution frequency (in percents) of the target block
17136relative to a statement's original block to allow statement sinking of a
17137statement. Larger numbers result in more aggressive statement sinking.
17138A small positive adjustment is applied for
17139statements with memory operands as those are even more profitable so sink.
17140
17141@item max-stores-to-sink
17142The maximum number of conditional store pairs that can be sunk. Set to 0
17143if either vectorization (@option{-ftree-vectorize}) or if-conversion
17144(@option{-ftree-loop-if-convert}) is disabled.
17145
17146@item case-values-threshold
17147The smallest number of different values for which it is best to use a
17148jump-table instead of a tree of conditional branches. If the value is
171490, use the default for the machine.
17150
17151@item jump-table-max-growth-ratio-for-size
17152The maximum code size growth ratio when expanding
17153into a jump table (in percent). The parameter is used when
17154optimizing for size.
17155
17156@item jump-table-max-growth-ratio-for-speed
17157The maximum code size growth ratio when expanding
17158into a jump table (in percent). The parameter is used when
17159optimizing for speed.
17160
17161@item tree-reassoc-width
17162Set the maximum number of instructions executed in parallel in
17163reassociated tree. This parameter overrides target dependent
17164heuristics used by default if has non zero value.
17165
17166@item sched-pressure-algorithm
17167Choose between the two available implementations of
17168@option{-fsched-pressure}. Algorithm 1 is the original implementation
17169and is the more likely to prevent instructions from being reordered.
17170Algorithm 2 was designed to be a compromise between the relatively
17171conservative approach taken by algorithm 1 and the rather aggressive
17172approach taken by the default scheduler. It relies more heavily on
17173having a regular register file and accurate register pressure classes.
17174See @file{haifa-sched.cc} in the GCC sources for more details.
17175
17176The default choice depends on the target.
17177
17178@item max-slsr-cand-scan
17179Set the maximum number of existing candidates that are considered when
17180seeking a basis for a new straight-line strength reduction candidate.
17181
17182@item asan-globals
17183Enable buffer overflow detection for global objects. This kind
17184of protection is enabled by default if you are using
17185@option{-fsanitize=address} option.
17186To disable global objects protection use @option{--param asan-globals=0}.
17187
17188@item asan-stack
17189Enable buffer overflow detection for stack objects. This kind of
17190protection is enabled by default when using @option{-fsanitize=address}.
17191To disable stack protection use @option{--param asan-stack=0} option.
17192
17193@item asan-instrument-reads
17194Enable buffer overflow detection for memory reads. This kind of
17195protection is enabled by default when using @option{-fsanitize=address}.
17196To disable memory reads protection use
17197@option{--param asan-instrument-reads=0}.
17198
17199@item asan-instrument-writes
17200Enable buffer overflow detection for memory writes. This kind of
17201protection is enabled by default when using @option{-fsanitize=address}.
17202To disable memory writes protection use
17203@option{--param asan-instrument-writes=0} option.
17204
17205@item asan-memintrin
17206Enable detection for built-in functions. This kind of protection
17207is enabled by default when using @option{-fsanitize=address}.
17208To disable built-in functions protection use
17209@option{--param asan-memintrin=0}.
17210
17211@item asan-use-after-return
17212Enable detection of use-after-return. This kind of protection
17213is enabled by default when using the @option{-fsanitize=address} option.
17214To disable it use @option{--param asan-use-after-return=0}.
17215
17216Note: By default the check is disabled at run time. To enable it,
17217add @code{detect_stack_use_after_return=1} to the environment variable
17218@env{ASAN_OPTIONS}.
17219
17220@item asan-instrumentation-with-call-threshold
17221If number of memory accesses in function being instrumented
17222is greater or equal to this number, use callbacks instead of inline checks.
17223E.g. to disable inline code use
17224@option{--param asan-instrumentation-with-call-threshold=0}.
17225
545c9f8b 17226@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
17227If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
17228with @samp{__asan_} or @samp{__hwasan_}
17229for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
17230respectively.
545c9f8b 17231
d77de738
ML
17232@item hwasan-instrument-stack
17233Enable hwasan instrumentation of statically sized stack-allocated variables.
17234This kind of instrumentation is enabled by default when using
17235@option{-fsanitize=hwaddress} and disabled by default when using
17236@option{-fsanitize=kernel-hwaddress}.
17237To disable stack instrumentation use
17238@option{--param hwasan-instrument-stack=0}, and to enable it use
17239@option{--param hwasan-instrument-stack=1}.
17240
17241@item hwasan-random-frame-tag
17242When using stack instrumentation, decide tags for stack variables using a
17243deterministic sequence beginning at a random tag for each frame. With this
17244parameter unset tags are chosen using the same sequence but beginning from 1.
17245This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
17246for @option{-fsanitize=kernel-hwaddress}.
17247To disable it use @option{--param hwasan-random-frame-tag=0}.
17248
17249@item hwasan-instrument-allocas
17250Enable hwasan instrumentation of dynamically sized stack-allocated variables.
17251This kind of instrumentation is enabled by default when using
17252@option{-fsanitize=hwaddress} and disabled by default when using
17253@option{-fsanitize=kernel-hwaddress}.
17254To disable instrumentation of such variables use
17255@option{--param hwasan-instrument-allocas=0}, and to enable it use
17256@option{--param hwasan-instrument-allocas=1}.
17257
17258@item hwasan-instrument-reads
17259Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
17260default for both @option{-fsanitize=hwaddress} and
17261@option{-fsanitize=kernel-hwaddress}.
17262To disable checking memory reads use
17263@option{--param hwasan-instrument-reads=0}.
17264
17265@item hwasan-instrument-writes
17266Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
17267default for both @option{-fsanitize=hwaddress} and
17268@option{-fsanitize=kernel-hwaddress}.
17269To disable checking memory writes use
17270@option{--param hwasan-instrument-writes=0}.
17271
17272@item hwasan-instrument-mem-intrinsics
17273Enable hwasan instrumentation of builtin functions. Instrumentation of these
17274builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
17275and @option{-fsanitize=kernel-hwaddress}.
17276To disable instrumentation of builtin functions use
17277@option{--param hwasan-instrument-mem-intrinsics=0}.
17278
17279@item use-after-scope-direct-emission-threshold
17280If the size of a local variable in bytes is smaller or equal to this
17281number, directly poison (or unpoison) shadow memory instead of using
17282run-time callbacks.
17283
17284@item tsan-distinguish-volatile
17285Emit special instrumentation for accesses to volatiles.
17286
17287@item tsan-instrument-func-entry-exit
17288Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
17289
17290@item max-fsm-thread-path-insns
17291Maximum number of instructions to copy when duplicating blocks on a
17292finite state automaton jump thread path.
17293
17294@item threader-debug
17295threader-debug=[none|all] Enables verbose dumping of the threader solver.
17296
17297@item parloops-chunk-size
17298Chunk size of omp schedule for loops parallelized by parloops.
17299
17300@item parloops-schedule
17301Schedule type of omp schedule for loops parallelized by parloops (static,
17302dynamic, guided, auto, runtime).
17303
17304@item parloops-min-per-thread
17305The minimum number of iterations per thread of an innermost parallelized
17306loop for which the parallelized variant is preferred over the single threaded
17307one. Note that for a parallelized loop nest the
17308minimum number of iterations of the outermost loop per thread is two.
17309
17310@item max-ssa-name-query-depth
17311Maximum depth of recursion when querying properties of SSA names in things
17312like fold routines. One level of recursion corresponds to following a
17313use-def chain.
17314
17315@item max-speculative-devirt-maydefs
17316The maximum number of may-defs we analyze when looking for a must-def
17317specifying the dynamic type of an object that invokes a virtual call
17318we may be able to devirtualize speculatively.
17319
d77de738
ML
17320@item ranger-debug
17321Specifies the type of debug output to be issued for ranges.
17322
d77de738
ML
17323@item unroll-jam-min-percent
17324The minimum percentage of memory references that must be optimized
17325away for the unroll-and-jam transformation to be considered profitable.
17326
17327@item unroll-jam-max-unroll
17328The maximum number of times the outer loop should be unrolled by
17329the unroll-and-jam transformation.
17330
17331@item max-rtl-if-conversion-unpredictable-cost
17332Maximum permissible cost for the sequence that would be generated
17333by the RTL if-conversion pass for a branch that is considered unpredictable.
17334
17335@item max-variable-expansions-in-unroller
17336If @option{-fvariable-expansion-in-unroller} is used, the maximum number
17337of times that an individual variable will be expanded during loop unrolling.
17338
17339@item partial-inlining-entry-probability
17340Maximum probability of the entry BB of split region
17341(in percent relative to entry BB of the function)
17342to make partial inlining happen.
17343
17344@item max-tracked-strlens
17345Maximum number of strings for which strlen optimization pass will
17346track string lengths.
17347
17348@item gcse-after-reload-partial-fraction
17349The threshold ratio for performing partial redundancy
17350elimination after reload.
17351
17352@item gcse-after-reload-critical-fraction
17353The threshold ratio of critical edges execution count that
17354permit performing redundancy elimination after reload.
17355
17356@item max-loop-header-insns
17357The maximum number of insns in loop header duplicated
17358by the copy loop headers pass.
17359
17360@item vect-epilogues-nomask
17361Enable loop epilogue vectorization using smaller vector size.
17362
17363@item vect-partial-vector-usage
17364Controls when the loop vectorizer considers using partial vector loads
17365and stores as an alternative to falling back to scalar code. 0 stops
17366the vectorizer from ever using partial vector loads and stores. 1 allows
17367partial vector loads and stores if vectorization removes the need for the
17368code to iterate. 2 allows partial vector loads and stores in all loops.
17369The parameter only has an effect on targets that support partial
17370vector loads and stores.
17371
17372@item vect-inner-loop-cost-factor
17373The maximum factor which the loop vectorizer applies to the cost of statements
17374in an inner loop relative to the loop being vectorized. The factor applied
17375is the maximum of the estimated number of iterations of the inner loop and
17376this parameter. The default value of this parameter is 50.
17377
17378@item vect-induction-float
17379Enable loop vectorization of floating point inductions.
17380
4238e347
TC
17381@item vect-scalar-cost-multiplier
17382Apply the given multiplier % to scalar loop costing during vectorization.
17383Increasing the cost multiplier will make vector loops more profitable.
17384
1ea95cc5
AM
17385@item vrp-block-limit
17386Maximum number of basic blocks before VRP switches to a lower memory algorithm.
17387
cbe32d38
ML
17388@item vrp-sparse-threshold
17389Maximum number of basic blocks before VRP uses a sparse bitmap cache.
17390
17391@item vrp-switch-limit
17392Maximum number of outgoing edges in a switch before VRP will not process it.
17393
17394@item vrp-vector-threshold
17395Maximum number of basic blocks for VRP to use a basic cache vector.
17396
d77de738
ML
17397@item avoid-fma-max-bits
17398Maximum number of bits for which we avoid creating FMAs.
17399
8afdbcdd
DZ
17400@item fully-pipelined-fma
17401Whether the target fully pipelines FMA instructions. If non-zero,
17402reassociation considers the benefit of parallelizing FMA's multiplication
17403part and addition part, assuming FMUL and FMA use the same units that can
17404also do FADD.
17405
d77de738
ML
17406@item sms-loop-average-count-threshold
17407A threshold on the average loop count considered by the swing modulo scheduler.
17408
17409@item sms-dfa-history
17410The number of cycles the swing modulo scheduler considers when checking
17411conflicts using DFA.
17412
17413@item graphite-allow-codegen-errors
17414Whether codegen errors should be ICEs when @option{-fchecking}.
17415
17416@item sms-max-ii-factor
17417A factor for tuning the upper bound that swing modulo scheduler
17418uses for scheduling a loop.
17419
17420@item lra-max-considered-reload-pseudos
17421The max number of reload pseudos which are considered during
17422spilling a non-reload pseudo.
17423
17424@item max-pow-sqrt-depth
17425Maximum depth of sqrt chains to use when synthesizing exponentiation
17426by a real constant.
17427
17428@item max-dse-active-local-stores
17429Maximum number of active local stores in RTL dead store elimination.
17430
17431@item asan-instrument-allocas
17432Enable asan allocas/VLAs protection.
17433
17434@item max-iterations-computation-cost
17435Bound on the cost of an expression to compute the number of iterations.
17436
17437@item max-isl-operations
17438Maximum number of isl operations, 0 means unlimited.
17439
17440@item graphite-max-arrays-per-scop
17441Maximum number of arrays per scop.
17442
17443@item max-vartrack-reverse-op-size
17444Max. size of loc list for which reverse ops should be added.
17445
17446@item fsm-scale-path-stmts
17447Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
17448crossing a loop backedge when comparing to
17449@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
17450
17451@item uninit-control-dep-attempts
17452Maximum number of nested calls to search for control dependencies
17453during uninitialized variable analysis.
17454
b8a2a124
RB
17455@item uninit-max-chain-len
17456Maximum number of predicates anded for each predicate ored in the normalized
17457predicate chain.
17458
17459@item uninit-max-num-chains
17460Maximum number of predicates ored in the normalized predicate chain.
17461
97044a47
RB
17462@item uninit-max-prune-work
17463Maximum amount of work done to prune paths where the variable is always initialized.
17464
d77de738
ML
17465@item sched-autopref-queue-depth
17466Hardware autoprefetcher scheduler model control flag.
17467Number of lookahead cycles the model looks into; at '
17468' only enable instruction sorting heuristic.
17469
17470@item loop-versioning-max-inner-insns
17471The maximum number of instructions that an inner loop can have
17472before the loop versioning pass considers it too big to copy.
17473
17474@item loop-versioning-max-outer-insns
17475The maximum number of instructions that an outer loop can have
17476before the loop versioning pass considers it too big to copy,
17477discounting any instructions in inner loops that directly benefit
17478from versioning.
17479
17480@item ssa-name-def-chain-limit
17481The maximum number of SSA_NAME assignments to follow in determining
17482a property of a variable such as its value. This limits the number
17483of iterations or recursive calls GCC performs when optimizing certain
17484statements or when determining their validity prior to issuing
17485diagnostics.
17486
17487@item store-merging-max-size
17488Maximum size of a single store merging region in bytes.
17489
9755f597
FK
17490@item store-forwarding-max-distance
17491Maximum number of instruction distance that a small store forwarded to a larger
17492load may stall. Value '0' disables the cost checks for the
17493avoid-store-forwarding pass.
17494
d77de738
ML
17495@item hash-table-verification-limit
17496The number of elements for which hash table verification is done
17497for each searched element.
17498
17499@item max-find-base-term-values
17500Maximum number of VALUEs handled during a single find_base_term call.
17501
17502@item analyzer-max-enodes-per-program-point
17503The maximum number of exploded nodes per program point within
17504the analyzer, before terminating analysis of that point.
17505
17506@item analyzer-max-constraints
17507The maximum number of constraints per state.
17508
17509@item analyzer-min-snodes-for-call-summary
17510The minimum number of supernodes within a function for the
17511analyzer to consider summarizing its effects at call sites.
17512
17513@item analyzer-max-enodes-for-full-dump
17514The maximum depth of exploded nodes that should appear in a dot dump
17515before switching to a less verbose format.
17516
17517@item analyzer-max-recursion-depth
17518The maximum number of times a callsite can appear in a call stack
17519within the analyzer, before terminating analysis of a call that would
17520recurse deeper.
17521
17522@item analyzer-max-svalue-depth
17523The maximum depth of a symbolic value, before approximating
17524the value as unknown.
17525
17526@item analyzer-max-infeasible-edges
17527The maximum number of infeasible edges to reject before declaring
17528a diagnostic as infeasible.
17529
17530@item gimple-fe-computed-hot-bb-threshold
17531The number of executions of a basic block which is considered hot.
17532The parameter is used only in GIMPLE FE.
17533
17534@item analyzer-bb-explosion-factor
17535The maximum number of 'after supernode' exploded nodes within the analyzer
17536per supernode, before terminating analysis.
17537
c0c5a57b
MJ
17538@item analyzer-text-art-string-ellipsis-threshold
17539The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
17540
17541@item analyzer-text-art-ideal-canvas-width
17542The ideal width in characters of text art diagrams generated by the analyzer.
17543
17544@item analyzer-text-art-string-ellipsis-head-len
17545The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
17546
17547@item analyzer-text-art-string-ellipsis-tail-len
17548The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
17549
d77de738
ML
17550@item ranger-logical-depth
17551Maximum depth of logical expression evaluation ranger will look through
17552when evaluating outgoing edge ranges.
17553
9fd6d83a
ML
17554@item ranger-recompute-depth
17555Maximum depth of instruction chains to consider for recomputation
17556in the outgoing range calculator.
17557
d77de738
ML
17558@item relation-block-limit
17559Maximum number of relations the oracle will register in a basic block.
17560
942bbb23
RB
17561@item transitive-relations-work-bound
17562Work bound when discovering transitive relations from existing relations.
17563
d77de738 17564@item min-pagesize
2427793a 17565Minimum page size for warning and early break vectorization purposes.
d77de738
ML
17566
17567@item openacc-kernels
17568Specify mode of OpenACC `kernels' constructs handling.
17569With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
17570constructs are decomposed into parts, a sequence of compute
17571constructs, each then handled individually.
17572This is work in progress.
17573With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
17574constructs are handled by the @samp{parloops} pass, en bloc.
17575This is the current default.
17576
17577@item openacc-privatization
4ace81b6
SL
17578Control whether the @option{-fopt-info-omp-note} and applicable
17579@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
17580With @option{--param=openacc-privatization=quiet}, don't diagnose.
17581This is the current default.
17582With @option{--param=openacc-privatization=noisy}, do diagnose.
17583
7bef3482
VG
17584@item cycle-accurate-model
17585Specifies whether GCC should assume that the scheduling description is mostly
b9857b78 17586a cycle-accurate model of the target processor the code is intended to
7bef3482
VG
17587run on, in the absence of cache misses. Nonzero means that the selected
17588scheduling model is accurate and likely describes an in-order processor,
b9857b78
SL
17589and that scheduling should aggressively spill to try and fill any pipeline
17590bubbles. This is the current default. Zero means the scheduling description
17591might not be available/accurate or perhaps not applicable at all, such as for
7bef3482
VG
17592modern out-of-order processors.
17593
d77de738
ML
17594@end table
17595
17596The following choices of @var{name} are available on AArch64 targets:
17597
17598@table @gcctabopt
7328faf8
RS
17599@item aarch64-vect-compare-costs
17600When vectorizing, consider using multiple different approaches and use
17601the cost model to choose the cheapest one. This includes:
17602
17603@itemize
17604@item
17605Trying both SVE and Advanced SIMD, when SVE is available.
17606
17607@item
17608Trying to use 64-bit Advanced SIMD vectors for the smallest data elements,
17609rather than using 128-bit vectors for everything.
17610
17611@item
17612Trying to use ``unpacked'' SVE vectors for smaller elements. This includes
17613storing smaller elements in larger containers and accessing elements with
17614extending loads and truncating stores.
17615@end itemize
d77de738
ML
17616
17617@item aarch64-float-recp-precision
17618The number of Newton iterations for calculating the reciprocal for float type.
17619The precision of division is proportional to this param when division
17620approximation is enabled. The default value is 1.
17621
17622@item aarch64-double-recp-precision
17623The number of Newton iterations for calculating the reciprocal for double type.
b9857b78 17624The precision of division is proportional to this param when division
d77de738
ML
17625approximation is enabled. The default value is 2.
17626
17627@item aarch64-autovec-preference
f60d3f5c
TC
17628An old alias for @option{-mautovec-preference}. If both
17629@option{-mautovec-preference} and @option{--param=aarch64-autovec-preference}
17630are passed, the @option{--param} value will be used.
d77de738 17631
834fc2bf
MA
17632@item aarch64-ldp-policy
17633Fine-grained policy for load pairs.
17634With @option{--param=aarch64-ldp-policy=default}, use the policy of the
17635tuning structure. This is the current default.
17636With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
17637of alignment.
17638With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
17639With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
17640source pointer is aligned to at least double the alignment of the type.
17641
17642@item aarch64-stp-policy
17643Fine-grained policy for store pairs.
17644With @option{--param=aarch64-stp-policy=default}, use the policy of the
17645tuning structure. This is the current default.
17646With @option{--param=aarch64-stp-policy=always}, emit stp regardless
17647of alignment.
17648With @option{--param=aarch64-stp-policy=never}, do not emit stp.
17649With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
17650source pointer is aligned to at least double the alignment of the type.
17651
c0911c6b
AC
17652@item aarch64-ldp-alias-check-limit
17653Limit on the number of alias checks performed by the AArch64 load/store pair
17654fusion pass when attempting to form an ldp/stp. Higher values make the pass
17655more aggressive at re-ordering loads over stores, at the expense of increased
17656compile time.
17657
17658@item aarch64-ldp-writeback
17659Param to control which writeback opportunities we try to handle in the AArch64
17660load/store pair fusion pass. A value of zero disables writeback handling. One
17661means we try to form pairs involving one or more existing individual writeback
17662accesses where possible. A value of two means we also try to opportunistically
17663form writeback opportunities by folding in trailing destructive updates of the
17664base register used by a pair.
17665
d77de738
ML
17666@item aarch64-loop-vect-issue-rate-niters
17667The tuning for some AArch64 CPUs tries to take both latencies and issue
17668rates into account when deciding whether a loop should be vectorized
17669using SVE, vectorized using Advanced SIMD, or not vectorized at all.
17670If this parameter is set to @var{n}, GCC will not use this heuristic
17671for loops that are known to execute in fewer than @var{n} Advanced
17672SIMD iterations.
17673
17674@item aarch64-vect-unroll-limit
17675The vectorizer will use available tuning information to determine whether it
17676would be beneficial to unroll the main vectorized loop and by how much. This
17677parameter set's the upper bound of how much the vectorizer will unroll the main
17678loop. The default value is four.
17679
17680@end table
df7625c3
TS
17681
17682The following choices of @var{name} are available on GCN targets:
17683
17684@table @gcctabopt
17685@item gcn-preferred-vectorization-factor
17686Preferred vectorization factor: @samp{default}, @samp{32}, @samp{64}.
17687
17688@end table
d77de738
ML
17689
17690The following choices of @var{name} are available on i386 and x86_64 targets:
17691
17692@table @gcctabopt
17693@item x86-stlf-window-ninsns
17694Instructions number above which STFL stall penalty can be compensated.
17695
60101899
RB
17696@item x86-stv-max-visits
17697The maximum number of use and def visits when discovering a STV chain before
17698the discovery is aborted.
17699
d77de738
ML
17700@end table
17701
17702@end table
17703
17704@node Instrumentation Options
17705@section Program Instrumentation Options
17706@cindex instrumentation options
17707@cindex program instrumentation options
17708@cindex run-time error checking options
17709@cindex profiling options
17710@cindex options, program instrumentation
17711@cindex options, run-time error checking
17712@cindex options, profiling
17713
17714GCC supports a number of command-line options that control adding
a0e64a04 17715run-time instrumentation to the code it normally generates.
d77de738
ML
17716For example, one purpose of instrumentation is collect profiling
17717statistics for use in finding program hot spots, code coverage
17718analysis, or profile-guided optimizations.
a0e64a04 17719Another class of program instrumentation is adding run-time checking
d77de738
ML
17720to detect programming errors like invalid pointer
17721dereferences or out-of-bounds array accesses, as well as deliberately
17722hostile attacks such as stack smashing or C++ vtable hijacking.
17723There is also a general hook which can be used to implement other
17724forms of tracing or function-level instrumentation for debug or
17725program analysis purposes.
17726
17727@table @gcctabopt
17728@cindex @command{prof}
17729@cindex @command{gprof}
d77de738
ML
17730@opindex p
17731@opindex pg
ddf6fe37
AA
17732@item -p
17733@itemx -pg
d77de738
ML
17734Generate extra code to write profile information suitable for the
17735analysis program @command{prof} (for @option{-p}) or @command{gprof}
17736(for @option{-pg}). You must use this option when compiling
17737the source files you want data about, and you must also use it when
17738linking.
17739
17740You can use the function attribute @code{no_instrument_function} to
17741suppress profiling of individual functions when compiling with these options.
17742@xref{Common Function Attributes}.
17743
d77de738 17744@opindex fprofile-arcs
ddf6fe37 17745@item -fprofile-arcs
d77de738
ML
17746Add code so that program flow @dfn{arcs} are instrumented. During
17747execution the program records how many times each branch and call is
17748executed and how many times it is taken or returns. On targets that support
17749constructors with priority support, profiling properly handles constructors,
17750destructors and C++ constructors (and destructors) of classes which are used
17751as a type of a global variable.
17752
17753When the compiled
17754program exits it saves this data to a file called
17755@file{@var{auxname}.gcda} for each source file. The data may be used for
17756profile-directed optimizations (@option{-fbranch-probabilities}), or for
17757test coverage analysis (@option{-ftest-coverage}). Each object file's
17758@var{auxname} is generated from the name of the output file, if
17759explicitly specified and it is not the final executable, otherwise it is
17760the basename of the source file. In both cases any suffix is removed
17761(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
17762@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
17763
17764Note that if a command line directly links source files, the corresponding
17765@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
17766E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
17767@file{binary-b.gcda} files.
17768
08a52331
JK
17769@item -fcondition-coverage
17770@opindex fcondition-coverage
17771Add code so that program conditions are instrumented. During execution the
17772program records what terms in a conditional contributes to a decision, which
17773can be used to verify that all terms in a Boolean function are tested and have
17774an independent effect on the outcome of a decision. The result can be read
17775with @code{gcov --conditions}.
17776
8ed2d5d2
JK
17777@item -fpath-coverage
17778@opindex fpath-coverage
17779Add code so that the paths taken are tracked. During execution the
17780program records the prime paths taken. The number of paths grows very
17781fast with complexity, and to avoid exploding compile times GCC will give
17782up instrumentation if the approximate number of paths exceeds the limit
17783controlled by @option{-fpath-coverage-limit}. The result can be read
17784with @code{gcov --prime-paths --prime-paths-lines --prime-paths-source},
17785@xref{gcov prime paths example}.
17786
17787@item -fpath-coverage-limit=@var{limit}
17788@opindex fpath-coverage-limit
17789The threshold at which point @option{-fpath-coverage} gives up on
17790instrumenting a function. This limit is approximate and conservative,
17791as GCC uses a pessimistic heuristic which slightly overcounts the
17792running number of paths, and gives up if the threshold is reached before
17793finding all the paths. This option is not for fine grained control over
17794which functions to instrument - rather it is intended to limit the
17795effect of path explosion and keep compile times reasonable. The default
17796is @var{250000}.
17797
d77de738
ML
17798@xref{Cross-profiling}.
17799
17800@cindex @command{gcov}
d77de738 17801@opindex coverage
ddf6fe37 17802@item --coverage
d77de738
ML
17803
17804This option is used to compile and link code instrumented for coverage
17805analysis. The option is a synonym for @option{-fprofile-arcs}
17806@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
17807linking). See the documentation for those options for more details.
17808
17809@itemize
17810
17811@item
17812Compile the source files with @option{-fprofile-arcs} plus optimization
17813and code generation options. For test coverage analysis, use the
17814additional @option{-ftest-coverage} option. You do not need to profile
17815every source file in a program.
17816
17817@item
17818Compile the source files additionally with @option{-fprofile-abs-path}
17819to create absolute path names in the @file{.gcno} files. This allows
17820@command{gcov} to find the correct sources in projects where compilations
17821occur with different working directories.
17822
17823@item
17824Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
17825(the latter implies the former).
17826
17827@item
17828Run the program on a representative workload to generate the arc profile
17829information. This may be repeated any number of times. You can run
17830concurrent instances of your program, and provided that the file system
17831supports locking, the data files will be correctly updated. Unless
17832a strict ISO C dialect option is in effect, @code{fork} calls are
17833detected and correctly handled without double counting.
17834
17835Moreover, an object file can be recompiled multiple times
17836and the corresponding @file{.gcda} file merges as long as
17837the source file and the compiler options are unchanged.
17838
17839@item
17840For profile-directed optimizations, compile the source files again with
17841the same optimization and code generation options plus
17842@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
17843Control Optimization}).
17844
17845@item
17846For test coverage analysis, use @command{gcov} to produce human readable
17847information from the @file{.gcno} and @file{.gcda} files. Refer to the
17848@command{gcov} documentation for further information.
17849
17850@end itemize
17851
17852With @option{-fprofile-arcs}, for each function of your program GCC
17853creates a program flow graph, then finds a spanning tree for the graph.
17854Only arcs that are not on the spanning tree have to be instrumented: the
17855compiler adds code to count the number of times that these arcs are
17856executed. When an arc is the only exit or only entrance to a block, the
17857instrumentation code can be added to the block; otherwise, a new basic
17858block must be created to hold the instrumentation code.
17859
08a52331
JK
17860With @option{-fcondition-coverage}, for each conditional in your program GCC
17861creates a bitset and records the exercised boolean values that have an
17862independent effect on the outcome of that expression.
17863
8ed2d5d2
JK
17864With @option{-fpath-coverage}, GCC finds and enumerates and records the
17865taken prime paths of each function, unless the number of paths would
17866exceed the limit controlled by @option{-fpath-coverage-limit}. If the
17867limit is exceeded the function is not instrumented as if
17868@option{-fpath-coverage} was not used. A prime path is the longest
17869sequence of unique blocks, except possibly the first and last, which is
17870not a subpath of any other path.
17871
d77de738 17872@need 2000
d77de738 17873@opindex ftest-coverage
ddf6fe37 17874@item -ftest-coverage
d77de738
ML
17875Produce a notes file that the @command{gcov} code-coverage utility
17876(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
17877show program coverage. Each source file's note file is called
17878@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
17879above for a description of @var{auxname} and instructions on how to
17880generate test coverage data. Coverage data matches the source files
17881more closely if you do not optimize.
17882
d77de738 17883@opindex fprofile-abs-path
ddf6fe37 17884@item -fprofile-abs-path
d77de738
ML
17885Automatically convert relative source file names to absolute path names
17886in the @file{.gcno} files. This allows @command{gcov} to find the correct
17887sources in projects where compilations occur with different working
17888directories.
17889
d77de738 17890@opindex fprofile-dir
ddf6fe37 17891@item -fprofile-dir=@var{path}
d77de738
ML
17892
17893Set the directory to search for the profile data files in to @var{path}.
17894This option affects only the profile data generated by
17895@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
17896and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
17897and its related options. Both absolute and relative paths can be used.
17898By default, GCC uses the current directory as @var{path}, thus the
17899profile data file appears in the same directory as the object file.
17900In order to prevent the file name clashing, if the object file name is
17901not an absolute path, we mangle the absolute path of the
17902@file{@var{sourcename}.gcda} file and use it as the file name of a
17903@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
17904See similar option @option{-fprofile-note}.
17905
17906When an executable is run in a massive parallel environment, it is recommended
17907to save profile to different folders. That can be done with variables
17908in @var{path} that are exported during run-time:
17909
17910@table @gcctabopt
17911
17912@item %p
17913process ID.
17914
17915@item %q@{VAR@}
17916value of environment variable @var{VAR}
17917
17918@end table
17919
ddf6fe37 17920@opindex fprofile-generate
d77de738
ML
17921@item -fprofile-generate
17922@itemx -fprofile-generate=@var{path}
d77de738
ML
17923
17924Enable options usually used for instrumenting application to produce
17925profile useful for later recompilation with profile feedback based
17926optimization. You must use @option{-fprofile-generate} both when
17927compiling and when linking your program.
17928
17929The following options are enabled:
17930@option{-fprofile-arcs}, @option{-fprofile-values},
17931@option{-finline-functions}, and @option{-fipa-bit-cp}.
17932
17933If @var{path} is specified, GCC looks at the @var{path} to find
17934the profile feedback data files. See @option{-fprofile-dir}.
17935
17936To optimize the program based on the collected profile information, use
17937@option{-fprofile-use}. @xref{Optimize Options}, for more information.
17938
ddf6fe37 17939@opindex fprofile-info-section
d77de738
ML
17940@item -fprofile-info-section
17941@itemx -fprofile-info-section=@var{name}
d77de738
ML
17942
17943Register the profile information in the specified section instead of using a
17944constructor/destructor. The section name is @var{name} if it is specified,
17945otherwise the section name defaults to @code{.gcov_info}. A pointer to the
17946profile information generated by @option{-fprofile-arcs} is placed in the
17947specified section for each translation unit. This option disables the profile
17948information registration through a constructor and it disables the profile
17949information processing through a destructor. This option is not intended to be
17950used in hosted environments such as GNU/Linux. It targets freestanding
17951environments (for example embedded systems) with limited resources which do not
17952support constructors/destructors or the C library file I/O.
17953
17954The linker could collect the input sections in a continuous memory block and
17955define start and end symbols. A GNU linker script example which defines a
17956linker output section follows:
17957
17958@smallexample
17959 .gcov_info :
17960 @{
17961 PROVIDE (__gcov_info_start = .);
17962 KEEP (*(.gcov_info))
17963 PROVIDE (__gcov_info_end = .);
17964 @}
17965@end smallexample
17966
17967The program could dump the profiling information registered in this linker set
17968for example like this:
17969
17970@smallexample
17971#include <gcov.h>
17972#include <stdio.h>
17973#include <stdlib.h>
17974
17975extern const struct gcov_info *const __gcov_info_start[];
17976extern const struct gcov_info *const __gcov_info_end[];
17977
17978static void
17979dump (const void *d, unsigned n, void *arg)
17980@{
17981 const unsigned char *c = d;
17982
17983 for (unsigned i = 0; i < n; ++i)
17984 printf ("%02x", c[i]);
17985@}
17986
17987static void
17988filename (const char *f, void *arg)
17989@{
17990 __gcov_filename_to_gcfn (f, dump, arg );
17991@}
17992
17993static void *
17994allocate (unsigned length, void *arg)
17995@{
17996 return malloc (length);
17997@}
17998
17999static void
18000dump_gcov_info (void)
18001@{
18002 const struct gcov_info *const *info = __gcov_info_start;
18003 const struct gcov_info *const *end = __gcov_info_end;
18004
18005 /* Obfuscate variable to prevent compiler optimizations. */
18006 __asm__ ("" : "+r" (info));
18007
18008 while (info != end)
18009 @{
18010 void *arg = NULL;
18011 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
18012 putchar ('\n');
18013 ++info;
18014 @}
18015@}
18016
18017int
18018main (void)
18019@{
18020 dump_gcov_info ();
18021 return 0;
18022@}
18023@end smallexample
18024
18025The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
18026deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
18027@code{__gcov_info_to_gcda} functions and merge the profile information into
18028@file{.gcda} files on the host filesystem.
18029
d77de738 18030@opindex fprofile-note
ddf6fe37 18031@item -fprofile-note=@var{path}
d77de738
ML
18032
18033If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
18034location. If you combine the option with multiple source files,
18035the @file{.gcno} file will be overwritten.
18036
d77de738 18037@opindex fprofile-prefix-path
ddf6fe37 18038@item -fprofile-prefix-path=@var{path}
d77de738
ML
18039
18040This option can be used in combination with
18041@option{profile-generate=}@var{profile_dir} and
18042@option{profile-use=}@var{profile_dir} to inform GCC where is the base
18043directory of built source tree. By default @var{profile_dir} will contain
18044files with mangled absolute paths of all object files in the built project.
18045This is not desirable when directory used to build the instrumented binary
18046differs from the directory used to build the binary optimized with profile
18047feedback because the profile data will not be found during the optimized build.
18048In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
18049pointing to the base directory of the build can be used to strip the irrelevant
18050part of the path and keep all file names relative to the main build directory.
18051
d77de738 18052@opindex fprofile-prefix-map
ddf6fe37 18053@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
18054When compiling files residing in directory @file{@var{old}}, record
18055profiling information (with @option{--coverage})
18056describing them as if the files resided in
18057directory @file{@var{new}} instead.
2eb0191a 18058See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 18059
d77de738 18060@opindex fprofile-update
ddf6fe37 18061@item -fprofile-update=@var{method}
d77de738
ML
18062
18063Alter the update method for an application instrumented for profile
18064feedback based optimization. The @var{method} argument should be one of
18065@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
18066The first one is useful for single-threaded applications,
18067while the second one prevents profile corruption by emitting thread-safe code.
18068
18069@strong{Warning:} When an application does not properly join all threads
18070(or creates an detached thread), a profile file can be still corrupted.
18071
18072Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
18073when supported by a target, or to @samp{single} otherwise. The GCC driver
18074automatically selects @samp{prefer-atomic} when @option{-pthread}
20a3c74c
SH
18075is present in the command line, otherwise the default method is @samp{single}.
18076
18077If @samp{atomic} is selected, then the profile information is updated using
18078atomic operations on a best-effort basis. Ideally, the profile information is
18079updated through atomic operations in hardware. If the target platform does not
18080support the required atomic operations in hardware, however, @file{libatomic}
18081is available, then the profile information is updated through calls to
18082@file{libatomic}. If the target platform neither supports the required atomic
18083operations in hardware nor @file{libatomic}, then the profile information is
18084not atomically updated and a warning is issued. In this case, the obtained
18085profiling information may be corrupt for multi-threaded applications.
18086
18087For performance reasons, if 64-bit counters are used for the profiling
18088information and the target platform only supports 32-bit atomic operations in
18089hardware, then the performance critical profiling updates are done using two
1809032-bit atomic operations for each counter update. If a signal interrupts these
18091two operations updating a counter, then the profiling information may be in an
18092inconsistent state.
d77de738 18093
d77de738 18094@opindex fprofile-filter-files
ddf6fe37 18095@item -fprofile-filter-files=@var{regex}
d77de738
ML
18096
18097Instrument only functions from files whose name matches
18098any of the regular expressions (separated by semi-colons).
18099
18100For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
18101only @file{main.c} and all C files starting with 'module'.
18102
d77de738 18103@opindex fprofile-exclude-files
ddf6fe37 18104@item -fprofile-exclude-files=@var{regex}
d77de738
ML
18105
18106Instrument only functions from files whose name does not match
18107any of the regular expressions (separated by semi-colons).
18108
18109For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
18110of all files that are located in the @file{/usr/} folder.
18111
d77de738 18112@opindex fprofile-reproducible
ddf6fe37 18113@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
18114Control level of reproducibility of profile gathered by
18115@code{-fprofile-generate}. This makes it possible to rebuild program
18116with same outcome which is useful, for example, for distribution
18117packages.
18118
18119With @option{-fprofile-reproducible=serial} the profile gathered by
18120@option{-fprofile-generate} is reproducible provided the trained program
18121behaves the same at each invocation of the train run, it is not
18122multi-threaded and profile data streaming is always done in the same
18123order. Note that profile streaming happens at the end of program run but
18124also before @code{fork} function is invoked.
18125
18126Note that it is quite common that execution counts of some part of
18127programs depends, for example, on length of temporary file names or
18128memory space randomization (that may affect hash-table collision rate).
18129Such non-reproducible part of programs may be annotated by
18130@code{no_instrument_function} function attribute. @command{gcov-dump} with
18131@option{-l} can be used to dump gathered data and verify that they are
18132indeed reproducible.
18133
18134With @option{-fprofile-reproducible=parallel-runs} collected profile
18135stays reproducible regardless the order of streaming of the data into
18136gcda files. This setting makes it possible to run multiple instances of
18137instrumented program in parallel (such as with @code{make -j}). This
18138reduces quality of gathered data, in particular of indirect call
18139profiling.
18140
d77de738 18141@opindex fsanitize=address
ddf6fe37 18142@item -fsanitize=address
d77de738
ML
18143Enable AddressSanitizer, a fast memory error detector.
18144Memory access instructions are instrumented to detect
18145out-of-bounds and use-after-free bugs.
18146The option enables @option{-fsanitize-address-use-after-scope}.
18147See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
18148more details. The run-time behavior can be influenced using the
18149@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
18150the available options are shown at startup of the instrumented program. See
18151@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
18152for a list of supported options.
18153The option cannot be combined with @option{-fsanitize=thread} or
2e958291
JJ
18154@option{-fsanitize=hwaddress}. Note that the only targets
18155@option{-fsanitize=hwaddress} is currently supported on are x86-64
18156(only with @code{-mlam=u48} or @code{-mlam=u57} options) and AArch64,
18157in both cases only in ABIs with 64-bit pointers.
d77de738 18158
85b46d07 18159When compiling with @option{-fsanitize=address}, you should also
313edeee 18160use @option{-g} to produce more meaningful output.
6a07798c
MP
18161To get more accurate stack traces, it is possible to use options such as
18162@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
18163most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
18164optimizing sibling and tail recursive calls; this option is implicit for
18165@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
313edeee
SL
18166disables Identical Code Folding for functions).
18167Using @option{-fno-omit-frame-pointer} also improves stack traces.
18168Since multiple runs of the
6a07798c
MP
18169program may yield backtraces with different addresses due to ASLR (Address
18170Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
18171this can be achieved with @samp{setarch `uname -m` -R ./prog}.
18172
d77de738 18173@opindex fsanitize=kernel-address
f33d7a88 18174@item -fsanitize=kernel-address
d77de738 18175Enable AddressSanitizer for Linux kernel.
a0bf71be 18176See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 18177
d77de738 18178@opindex fsanitize=hwaddress
f33d7a88 18179@item -fsanitize=hwaddress
d77de738
ML
18180Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
18181ignore the top byte of a pointer to allow the detection of memory errors with
18182a low memory overhead.
18183Memory access instructions are instrumented to detect out-of-bounds and
18184use-after-free bugs.
18185The option enables @option{-fsanitize-address-use-after-scope}.
18186See
18187@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
18188for more details. The run-time behavior can be influenced using the
18189@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
18190the available options are shown at startup of the instrumented program.
18191The option cannot be combined with @option{-fsanitize=thread} or
18192@option{-fsanitize=address}, and is currently only available on AArch64.
18193
d77de738 18194@opindex fsanitize=kernel-hwaddress
ddf6fe37 18195@item -fsanitize=kernel-hwaddress
d77de738
ML
18196Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
18197Similar to @option{-fsanitize=kernel-address} but using an alternate
18198instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
18199instrumentation differences necessary for compiling the Linux kernel.
18200These differences are to avoid hwasan library initialization calls and to
18201account for the stack pointer having a different value in its top byte.
18202
18203@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
18204Instrumenting the stack and alloca calls are not on by default but are still
18205possible by specifying the command-line options
18206@option{--param hwasan-instrument-stack=1} and
18207@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
18208tag is not implemented for kernel instrumentation.
18209
d77de738 18210@opindex fsanitize=pointer-compare
ddf6fe37 18211@item -fsanitize=pointer-compare
d77de738
ML
18212Instrument comparison operation (<, <=, >, >=) with pointer operands.
18213The option must be combined with either @option{-fsanitize=kernel-address} or
18214@option{-fsanitize=address}
18215The option cannot be combined with @option{-fsanitize=thread}.
18216Note: By default the check is disabled at run time. To enable it,
18217add @code{detect_invalid_pointer_pairs=2} to the environment variable
18218@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
18219invalid operation only when both pointers are non-null.
18220
d77de738 18221@opindex fsanitize=pointer-subtract
ddf6fe37 18222@item -fsanitize=pointer-subtract
d77de738
ML
18223Instrument subtraction with pointer operands.
18224The option must be combined with either @option{-fsanitize=kernel-address} or
18225@option{-fsanitize=address}
18226The option cannot be combined with @option{-fsanitize=thread}.
18227Note: By default the check is disabled at run time. To enable it,
18228add @code{detect_invalid_pointer_pairs=2} to the environment variable
18229@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
18230invalid operation only when both pointers are non-null.
18231
d77de738 18232@opindex fsanitize=shadow-call-stack
ddf6fe37 18233@item -fsanitize=shadow-call-stack
d77de738
ML
18234Enable ShadowCallStack, a security enhancement mechanism used to protect
18235programs against return address overwrites (e.g. stack buffer overflows.)
18236It works by saving a function's return address to a separately allocated
18237shadow call stack in the function prologue and restoring the return address
18238from the shadow call stack in the function epilogue. Instrumentation only
18239occurs in functions that need to save the return address to the stack.
18240
18241Currently it only supports the aarch64 platform. It is specifically
18242designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
18243For the user space programs, runtime support is not currently provided
18244in libc and libgcc. Users who want to use this feature in user space need
18245to provide their own support for the runtime. It should be noted that
18246this may cause the ABI rules to be broken.
18247
18248On aarch64, the instrumentation makes use of the platform register @code{x18}.
18249This generally means that any code that may run on the same thread as code
18250compiled with ShadowCallStack must be compiled with the flag
18251@option{-ffixed-x18}, otherwise functions compiled without
18252@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
18253stack pointer.
18254
18255Also, because there is no userspace runtime support, code compiled with
18256ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
18257to turn off exceptions.
18258
18259See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
18260details.
18261
d77de738 18262@opindex fsanitize=thread
ddf6fe37 18263@item -fsanitize=thread
d77de738
ML
18264Enable ThreadSanitizer, a fast data race detector.
18265Memory access instructions are instrumented to detect
18266data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
18267details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
18268environment variable; see
18269@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
18270supported options.
18271The option cannot be combined with @option{-fsanitize=address},
18272@option{-fsanitize=leak}.
18273
313edeee
SL
18274When compiling with @option{-fsanitize=thread}, you should also use
18275@option{-g} to produce more meaningful output.
18276
d77de738
ML
18277Note that sanitized atomic builtins cannot throw exceptions when
18278operating on invalid memory addresses with non-call exceptions
18279(@option{-fnon-call-exceptions}).
18280
d77de738 18281@opindex fsanitize=leak
ddf6fe37 18282@item -fsanitize=leak
d77de738 18283Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
18284This option only matters for linking of executables.
18285The executable is linked against a library that overrides @code{malloc}
d77de738
ML
18286and other allocator functions. See
18287@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
18288details. The run-time behavior can be influenced using the
18289@env{LSAN_OPTIONS} environment variable.
18290The option cannot be combined with @option{-fsanitize=thread}.
18291
d77de738 18292@opindex fsanitize=undefined
ddf6fe37 18293@item -fsanitize=undefined
d77de738
ML
18294Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
18295Various computations are instrumented to detect undefined behavior
18296at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
18297@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
18298
18299@table @gcctabopt
18300
d77de738 18301@opindex fsanitize=shift
ddf6fe37 18302@item -fsanitize=shift
d77de738
ML
18303This option enables checking that the result of a shift operation is
18304not undefined. Note that what exactly is considered undefined differs
18305slightly between C and C++, as well as between ISO C90 and C99, etc.
18306This option has two suboptions, @option{-fsanitize=shift-base} and
18307@option{-fsanitize=shift-exponent}.
18308
d77de738 18309@opindex fsanitize=shift-exponent
ddf6fe37 18310@item -fsanitize=shift-exponent
d77de738
ML
18311This option enables checking that the second argument of a shift operation
18312is not negative and is smaller than the precision of the promoted first
18313argument.
18314
d77de738 18315@opindex fsanitize=shift-base
ddf6fe37 18316@item -fsanitize=shift-base
d77de738
ML
18317If the second argument of a shift operation is within range, check that the
18318result of a shift operation is not undefined. Note that what exactly is
18319considered undefined differs slightly between C and C++, as well as between
18320ISO C90 and C99, etc.
18321
d77de738 18322@opindex fsanitize=integer-divide-by-zero
ddf6fe37 18323@item -fsanitize=integer-divide-by-zero
d77de738
ML
18324Detect integer division by zero.
18325
d77de738 18326@opindex fsanitize=unreachable
ddf6fe37 18327@item -fsanitize=unreachable
d77de738
ML
18328With this option, the compiler turns the @code{__builtin_unreachable}
18329call into a diagnostics message call instead. When reaching the
18330@code{__builtin_unreachable} call, the behavior is undefined.
18331
d77de738 18332@opindex fsanitize=vla-bound
ddf6fe37 18333@item -fsanitize=vla-bound
d77de738
ML
18334This option instructs the compiler to check that the size of a variable
18335length array is positive.
18336
d77de738 18337@opindex fsanitize=null
ddf6fe37 18338@item -fsanitize=null
d77de738
ML
18339This option enables pointer checking. Particularly, the application
18340built with this option turned on will issue an error message when it
18341tries to dereference a NULL pointer, or if a reference (possibly an
18342rvalue reference) is bound to a NULL pointer, or if a method is invoked
18343on an object pointed by a NULL pointer.
18344
d77de738 18345@opindex fsanitize=return
ddf6fe37 18346@item -fsanitize=return
d77de738
ML
18347This option enables return statement checking. Programs
18348built with this option turned on will issue an error message
18349when the end of a non-void function is reached without actually
18350returning a value. This option works in C++ only.
18351
d77de738 18352@opindex fsanitize=signed-integer-overflow
ddf6fe37 18353@item -fsanitize=signed-integer-overflow
d77de738
ML
18354This option enables signed integer overflow checking. We check that
18355the result of @code{+}, @code{*}, and both unary and binary @code{-}
18356does not overflow in the signed arithmetics. This also detects
18357@code{INT_MIN / -1} signed division. Note, integer promotion
18358rules must be taken into account. That is, the following is not an
18359overflow:
18360@smallexample
18361signed char a = SCHAR_MAX;
18362a++;
18363@end smallexample
18364
d77de738 18365@opindex fsanitize=bounds
ddf6fe37 18366@item -fsanitize=bounds
d77de738
ML
18367This option enables instrumentation of array bounds. Various out of bounds
18368accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
18369arrays, and initializers of variables with static storage are not
18370instrumented, with the exception of flexible array member-like arrays
18371for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
18372options or @code{strict_flex_array} attributes say they shouldn't be treated
18373like flexible array member-like arrays.
d77de738 18374
d77de738 18375@opindex fsanitize=bounds-strict
ddf6fe37 18376@item -fsanitize=bounds-strict
d77de738 18377This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
18378accesses are detected, including flexible array member-like arrays.
18379Initializers of variables with static storage are not instrumented.
d77de738 18380
d77de738 18381@opindex fsanitize=alignment
ddf6fe37 18382@item -fsanitize=alignment
d77de738
ML
18383
18384This option enables checking of alignment of pointers when they are
18385dereferenced, or when a reference is bound to insufficiently aligned target,
18386or when a method or constructor is invoked on insufficiently aligned object.
18387
d77de738 18388@opindex fsanitize=object-size
ddf6fe37 18389@item -fsanitize=object-size
d77de738 18390This option enables instrumentation of memory references using the
7283380a
SP
18391@code{__builtin_dynamic_object_size} function. Various out of bounds
18392pointer accesses are detected.
d77de738 18393
d77de738 18394@opindex fsanitize=float-divide-by-zero
ddf6fe37 18395@item -fsanitize=float-divide-by-zero
d77de738
ML
18396Detect floating-point division by zero. Unlike other similar options,
18397@option{-fsanitize=float-divide-by-zero} is not enabled by
18398@option{-fsanitize=undefined}, since floating-point division by zero can
18399be a legitimate way of obtaining infinities and NaNs.
18400
d77de738 18401@opindex fsanitize=float-cast-overflow
ddf6fe37 18402@item -fsanitize=float-cast-overflow
d77de738
ML
18403This option enables floating-point type to integer conversion checking.
18404We check that the result of the conversion does not overflow.
18405Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
18406not enabled by @option{-fsanitize=undefined}.
18407This option does not work well with @code{FE_INVALID} exceptions enabled.
18408
d77de738 18409@opindex fsanitize=nonnull-attribute
ddf6fe37 18410@item -fsanitize=nonnull-attribute
d77de738
ML
18411
18412This option enables instrumentation of calls, checking whether null values
18413are not passed to arguments marked as requiring a non-null value by the
18414@code{nonnull} function attribute.
18415
d77de738 18416@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 18417@item -fsanitize=returns-nonnull-attribute
d77de738
ML
18418
18419This option enables instrumentation of return statements in functions
18420marked with @code{returns_nonnull} function attribute, to detect returning
18421of null values from such functions.
18422
d77de738 18423@opindex fsanitize=bool
ddf6fe37 18424@item -fsanitize=bool
d77de738
ML
18425
18426This option enables instrumentation of loads from bool. If a value other
18427than 0/1 is loaded, a run-time error is issued.
18428
d77de738 18429@opindex fsanitize=enum
ddf6fe37 18430@item -fsanitize=enum
d77de738
ML
18431
18432This option enables instrumentation of loads from an enum type. If
18433a value outside the range of values for the enum type is loaded,
18434a run-time error is issued.
18435
d77de738 18436@opindex fsanitize=vptr
ddf6fe37 18437@item -fsanitize=vptr
d77de738
ML
18438
18439This option enables instrumentation of C++ member function calls, member
18440accesses and some conversions between pointers to base and derived classes,
18441to verify the referenced object has the correct dynamic type.
18442
d77de738 18443@opindex fsanitize=pointer-overflow
ddf6fe37 18444@item -fsanitize=pointer-overflow
d77de738
ML
18445
18446This option enables instrumentation of pointer arithmetics. If the pointer
18447arithmetics overflows, a run-time error is issued.
18448
d77de738 18449@opindex fsanitize=builtin
ddf6fe37 18450@item -fsanitize=builtin
d77de738
ML
18451
18452This option enables instrumentation of arguments to selected builtin
18453functions. If an invalid value is passed to such arguments, a run-time
18454error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
18455or @code{__builtin_clz} invokes undefined behavior and is diagnosed
18456by this option.
18457
18458@end table
18459
18460Note that sanitizers tend to increase the rate of false positive
18461warnings, most notably those around @option{-Wmaybe-uninitialized}.
18462We recommend against combining @option{-Werror} and [the use of]
18463sanitizers.
18464
18465While @option{-ftrapv} causes traps for signed overflows to be emitted,
18466@option{-fsanitize=undefined} gives a diagnostic message.
18467This currently works only for the C family of languages.
18468
d77de738 18469@opindex fno-sanitize=all
ddf6fe37 18470@item -fno-sanitize=all
d77de738
ML
18471
18472This option disables all previously enabled sanitizers.
18473@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
18474together.
18475
d77de738 18476@opindex fasan-shadow-offset
ddf6fe37 18477@item -fasan-shadow-offset=@var{number}
d77de738
ML
18478This option forces GCC to use custom shadow offset in AddressSanitizer checks.
18479It is useful for experimenting with different shadow memory layouts in
18480Kernel AddressSanitizer.
18481
d77de738 18482@opindex fsanitize-sections
ddf6fe37 18483@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
18484Sanitize global variables in selected user-defined sections. @var{si} may
18485contain wildcards.
18486
d77de738
ML
18487@opindex fsanitize-recover
18488@opindex fno-sanitize-recover
ddf6fe37 18489@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
18490@option{-fsanitize-recover=} controls error recovery mode for sanitizers
18491mentioned in comma-separated list of @var{opts}. Enabling this option
18492for a sanitizer component causes it to attempt to continue
18493running the program as if no error happened. This means multiple
18494runtime errors can be reported in a single program run, and the exit
18495code of the program may indicate success even when errors
18496have been reported. The @option{-fno-sanitize-recover=} option
18497can be used to alter
18498this behavior: only the first detected error is reported
18499and program then exits with a non-zero exit code.
18500
18501Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
18502except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
18503@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
18504@option{-fsanitize=bounds-strict},
18505@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
18506For these sanitizers error recovery is turned on by default,
18507except @option{-fsanitize=address}, for which this feature is experimental.
18508@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
18509accepted, the former enables recovery for all sanitizers that support it,
18510the latter disables recovery for all sanitizers that support it.
18511
18512Even if a recovery mode is turned on the compiler side, it needs to be also
18513enabled on the runtime library side, otherwise the failures are still fatal.
18514The runtime library defaults to @code{halt_on_error=0} for
18515ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
18516AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
18517setting the @code{halt_on_error} flag in the corresponding environment variable.
18518
18519Syntax without an explicit @var{opts} parameter is deprecated. It is
18520equivalent to specifying an @var{opts} list of:
18521
18522@smallexample
18523undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
18524@end smallexample
18525
d77de738 18526@opindex fsanitize-address-use-after-scope
ddf6fe37 18527@item -fsanitize-address-use-after-scope
d77de738
ML
18528Enable sanitization of local variables to detect use-after-scope bugs.
18529The option sets @option{-fstack-reuse} to @samp{none}.
18530
d77de738
ML
18531@opindex fsanitize-trap
18532@opindex fno-sanitize-trap
ddf6fe37 18533@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
18534The @option{-fsanitize-trap=} option instructs the compiler to
18535report for sanitizers mentioned in comma-separated list of @var{opts}
18536undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
18537library routine. If this option is enabled for certain sanitizer,
18538it takes precedence over the @option{-fsanitizer-recover=} for that
18539sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
18540of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
18541
18542The advantage of this is that the @code{libubsan} library is not needed
18543and is not linked in, so this is usable even in freestanding environments.
18544
18545Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
18546except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
18547@option{-fsanitize=float-divide-by-zero} and
18548@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
18549specified, which enables it for @code{undefined} suboptions,
18550@option{-fsanitize=float-cast-overflow},
18551@option{-fsanitize=float-divide-by-zero} and
18552@option{-fsanitize=bounds-strict}.
18553If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
18554and @code{-fsanitize=vptr} is enabled on the command line, the
18555instrumentation is silently ignored as the instrumentation always needs
18556@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
18557
d77de738 18558@opindex fsanitize-undefined-trap-on-error
ddf6fe37 18559@item -fsanitize-undefined-trap-on-error
d77de738
ML
18560The @option{-fsanitize-undefined-trap-on-error} option is deprecated
18561equivalent of @option{-fsanitize-trap=all}.
18562
d77de738 18563@opindex fsanitize-coverage=trace-pc
ddf6fe37 18564@item -fsanitize-coverage=trace-pc
d77de738
ML
18565Enable coverage-guided fuzzing code instrumentation.
18566Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
18567
d77de738 18568@opindex fsanitize-coverage=trace-cmp
ddf6fe37 18569@item -fsanitize-coverage=trace-cmp
d77de738
ML
18570Enable dataflow guided fuzzing code instrumentation.
18571Inserts a call to @code{__sanitizer_cov_trace_cmp1},
18572@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
18573@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
18574variable or @code{__sanitizer_cov_trace_const_cmp1},
18575@code{__sanitizer_cov_trace_const_cmp2},
18576@code{__sanitizer_cov_trace_const_cmp4} or
18577@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
18578operand constant, @code{__sanitizer_cov_trace_cmpf} or
18579@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
18580@code{__sanitizer_cov_trace_switch} for switch statements.
18581
d77de738 18582@opindex fcf-protection
ddf6fe37 18583@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
3026daa8
SL
18584@itemx -fcf-protection
18585Enable code instrumentation to increase
d77de738
ML
18586program security by checking that target addresses of control-flow
18587transfer instructions (such as indirect function call, function return,
18588indirect jump) are valid. This prevents diverting the flow of control
18589to an unexpected target. This is intended to protect against such
18590threats as Return-oriented Programming (ROP), and similarly
18591call/jmp-oriented programming (COP/JOP).
18592
3026daa8
SL
18593The @option{-fcf-protection=} keywords are interpreted as follows.
18594
d77de738
ML
18595The value @code{branch} tells the compiler to implement checking of
18596validity of control-flow transfer at the point of indirect branch
3026daa8
SL
18597instructions, i.e.@: call/jmp instructions.
18598
18599The value @code{return} implements checking of validity at the point of
18600returning from a function.
d77de738 18601
3026daa8
SL
18602The value @code{full} is an alias for specifying both
18603@code{branch} and @code{return}.
75ed4655 18604
d77de738
ML
18605The value @code{check} is used for the final link with link-time
18606optimization (LTO). An error is issued if LTO object files are
18607compiled with different @option{-fcf-protection} values. The
18608value @code{check} is ignored at the compile time.
18609
3026daa8
SL
18610The value @code{none} turns off instrumentation.
18611
18612@option{-fcf-protection} is an alias for @option{-fcf-protection=full}.
18613To override a previous @option{-fcf-protection} option on the command
18614line, add @option{-fcf-protection=none} and then
18615@option{-fcf-protection=@var{kind}}.
18616
d77de738
ML
18617The macro @code{__CET__} is defined when @option{-fcf-protection} is
18618used. The first bit of @code{__CET__} is set to 1 for the value
18619@code{branch} and the second bit of @code{__CET__} is set to 1 for
18620the @code{return}.
18621
18622You can also use the @code{nocf_check} attribute to identify
18623which functions and calls should be skipped from instrumentation
18624(@pxref{Function Attributes}).
18625
18626Currently the x86 GNU/Linux target provides an implementation based
18627on Intel Control-flow Enforcement Technology (CET) which works for
18628i686 processor or newer.
18629
d77de738 18630@opindex fharden-compares
ddf6fe37 18631@item -fharden-compares
d77de738
ML
18632For every logical test that survives gimple optimizations and is
18633@emph{not} the condition in a conditional branch (for example,
18634conditions tested for conditional moves, or to store in boolean
18635variables), emit extra code to compute and verify the reversed
18636condition, and to call @code{__builtin_trap} if the results do not
18637match. Use with @samp{-fharden-conditional-branches} to cover all
18638conditionals.
18639
d77de738 18640@opindex fharden-conditional-branches
ddf6fe37 18641@item -fharden-conditional-branches
d77de738
ML
18642For every non-vectorized conditional branch that survives gimple
18643optimizations, emit extra code to compute and verify the reversed
18644condition, and to call @code{__builtin_trap} if the result is
18645unexpected. Use with @samp{-fharden-compares} to cover all
18646conditionals.
18647
551935d1
AO
18648@opindex fharden-control-flow-redundancy
18649@item -fharden-control-flow-redundancy
18650Emit extra code to set booleans when entering basic blocks, and to
18651verify and trap, at function exits, when the booleans do not form an
18652execution path that is compatible with the control flow graph.
18653
18654Verification takes place before returns, before mandatory tail calls
18655(see below) and, optionally, before escaping exceptions with
18656@option{-fhardcfr-check-exceptions}, before returning calls with
18657@option{-fhardcfr-check-returning-calls}, and before noreturn calls with
18658@option{-fhardcfr-check-noreturn-calls}). Tuning options
18659@option{--param hardcfr-max-blocks} and @option{--param
18660hardcfr-max-inline-blocks} are available.
18661
18662Tail call optimization takes place too late to affect control flow
18663redundancy, but calls annotated as mandatory tail calls by language
18664front-ends, and any calls marked early enough as potential tail calls
18665would also have verification issued before the call, but these
18666possibilities are merely theoretical, as these conditions can only be
18667met when using custom compiler plugins.
18668
18669@opindex fhardcfr-skip-leaf
18670@item -fhardcfr-skip-leaf
18671Disable @option{-fharden-control-flow-redundancy} in leaf functions.
18672
18673@opindex fhardcfr-check-exceptions
18674@opindex fno-hardcfr-check-exceptions
18675@item -fhardcfr-check-exceptions
18676When @option{-fharden-control-flow-redundancy} is active, check the
18677recorded execution path against the control flow graph at exception
18678escape points, as if the function body was wrapped with a cleanup
18679handler that performed the check and reraised. This option is enabled
18680by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
18681
18682@opindex fhardcfr-check-returning-calls
18683@opindex fno-hardcfr-check-returning-calls
18684@item -fhardcfr-check-returning-calls
18685When @option{-fharden-control-flow-redundancy} is active, check the
18686recorded execution path against the control flow graph before any
18687function call immediately followed by a return of its result, if any, so
18688as to not prevent tail-call optimization, whether or not it is
18689ultimately optimized to a tail call.
18690
18691This option is enabled by default whenever sibling call optimizations
18692are enabled (see @option{-foptimize-sibling-calls}), but it can be
18693enabled (or disabled, using its negated form) explicitly, regardless of
18694the optimizations.
18695
18696@opindex fhardcfr-check-noreturn-calls
18697@item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
18698When @option{-fharden-control-flow-redundancy} is active, check the
18699recorded execution path against the control flow graph before
18700@code{noreturn} calls, either all of them (@option{always}), those that
18701aren't expected to return control to the caller through an exception
18702(@option{no-xthrow}, the default), those that may not return control to
18703the caller through an exception either (@option{nothrow}), or none of
18704them (@option{never}).
18705
18706Checking before a @code{noreturn} function that may return control to
18707the caller through an exception may cause checking to be performed more
18708than once, if the exception is caught in the caller, whether by a
18709handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
18710enabled, the compiler will avoid associating a @code{noreturn} call with
18711the implicitly-added cleanup handler, since it would be redundant with
18712the check performed before the call, but other handlers or cleanups in
18713the function, if activated, will modify the recorded execution path and
18714check it again when another checkpoint is hit. The checkpoint may even
18715be another @code{noreturn} call, so checking may end up performed
18716multiple times.
18717
18718Various optimizers may cause calls to be marked as @code{noreturn}
18719and/or @code{nothrow}, even in the absence of the corresponding
18720attributes, which may affect the placement of checks before calls, as
18721well as the addition of implicit cleanup handlers for them. This
18722unpredictability, and the fact that raising and reraising exceptions
18723frequently amounts to implicitly calling @code{noreturn} functions, have
18724made @option{no-xthrow} the default setting for this option: it excludes
18725from the @code{noreturn} treatment only internal functions used to
18726(re)raise exceptions, that are not affected by these optimizations.
18727
24592abd
MP
18728@opindex fhardened
18729@item -fhardened
18730Enable a set of flags for C and C++ that improve the security of the
18731generated code without affecting its ABI. The precise flags enabled
18732may change between major releases of GCC, but are currently:
18733
18734@c Keep this in sync with print_help_hardened!
18735@gccoptlist{
18736-D_FORTIFY_SOURCE=3
18737-D_GLIBCXX_ASSERTIONS
18738-ftrivial-auto-var-init=zero
18739-fPIE -pie -Wl,-z,relro,-z,now
18740-fstack-protector-strong
18741-fstack-clash-protection
18742-fcf-protection=full @r{(x86 GNU/Linux only)}
18743}
18744
18745The list of options enabled by @option{-fhardened} can be generated using
18746the @option{--help=hardened} option.
18747
18748When the system glibc is older than 2.35, @option{-D_FORTIFY_SOURCE=2}
18749is used instead.
18750
18751This option is intended to be used in production builds, not merely
18752in debug builds.
18753
18754Currently, @option{-fhardened} is only supported on GNU/Linux targets.
18755
18756@option{-fhardened} only enables a particular option if it wasn't
18757already specified anywhere on the command line. For instance,
18758@option{-fhardened} @option{-fstack-protector} will only enable
18759@option{-fstack-protector}, but not @option{-fstack-protector-strong}.
18760
d77de738 18761@opindex fstack-protector
ddf6fe37 18762@item -fstack-protector
d77de738
ML
18763Emit extra code to check for buffer overflows, such as stack smashing
18764attacks. This is done by adding a guard variable to functions with
18765vulnerable objects. This includes functions that call @code{alloca}, and
18766functions with buffers larger than or equal to 8 bytes. The guards are
18767initialized when a function is entered and then checked when the function
18768exits. If a guard check fails, an error message is printed and the program
18769exits. Only variables that are actually allocated on the stack are
18770considered, optimized away variables or variables allocated in registers
18771don't count.
18772
d77de738 18773@opindex fstack-protector-all
ddf6fe37 18774@item -fstack-protector-all
d77de738
ML
18775Like @option{-fstack-protector} except that all functions are protected.
18776
d77de738 18777@opindex fstack-protector-strong
ddf6fe37 18778@item -fstack-protector-strong
d77de738
ML
18779Like @option{-fstack-protector} but includes additional functions to
18780be protected --- those that have local array definitions, or have
18781references to local frame addresses. Only variables that are actually
18782allocated on the stack are considered, optimized away variables or variables
18783allocated in registers don't count.
18784
d77de738 18785@opindex fstack-protector-explicit
ddf6fe37 18786@item -fstack-protector-explicit
d77de738
ML
18787Like @option{-fstack-protector} but only protects those functions which
18788have the @code{stack_protect} attribute.
18789
d77de738 18790@opindex fstack-check
ddf6fe37 18791@item -fstack-check
d77de738
ML
18792Generate code to verify that you do not go beyond the boundary of the
18793stack. You should specify this flag if you are running in an
18794environment with multiple threads, but you only rarely need to specify it in
18795a single-threaded environment since stack overflow is automatically
18796detected on nearly all systems if there is only one stack.
18797
18798Note that this switch does not actually cause checking to be done; the
18799operating system or the language runtime must do that. The switch causes
18800generation of code to ensure that they see the stack being extended.
18801
18802You can additionally specify a string parameter: @samp{no} means no
18803checking, @samp{generic} means force the use of old-style checking,
18804@samp{specific} means use the best checking method and is equivalent
18805to bare @option{-fstack-check}.
18806
18807Old-style checking is a generic mechanism that requires no specific
18808target support in the compiler but comes with the following drawbacks:
18809
18810@enumerate
18811@item
18812Modified allocation strategy for large objects: they are always
18813allocated dynamically if their size exceeds a fixed threshold. Note this
18814may change the semantics of some code.
18815
18816@item
18817Fixed limit on the size of the static frame of functions: when it is
18818topped by a particular function, stack checking is not reliable and
18819a warning is issued by the compiler.
18820
18821@item
18822Inefficiency: because of both the modified allocation strategy and the
18823generic implementation, code performance is hampered.
18824@end enumerate
18825
18826Note that old-style stack checking is also the fallback method for
18827@samp{specific} if no target support has been added in the compiler.
18828
18829@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
18830and stack overflows. @samp{specific} is an excellent choice when compiling
18831Ada code. It is not generally sufficient to protect against stack-clash
18832attacks. To protect against those you want @samp{-fstack-clash-protection}.
18833
d77de738 18834@opindex fstack-clash-protection
ddf6fe37 18835@item -fstack-clash-protection
d77de738
ML
18836Generate code to prevent stack clash style attacks. When this option is
18837enabled, the compiler will only allocate one page of stack space at a time
18838and each page is accessed immediately after allocation. Thus, it prevents
18839allocations from jumping over any stack guard page provided by the
18840operating system.
18841
18842Most targets do not fully support stack clash protection. However, on
18843those targets @option{-fstack-clash-protection} will protect dynamic stack
18844allocations. @option{-fstack-clash-protection} may also provide limited
18845protection for static stack allocations if the target supports
18846@option{-fstack-check=specific}.
18847
d77de738
ML
18848@opindex fstack-limit-register
18849@opindex fstack-limit-symbol
18850@opindex fno-stack-limit
ddf6fe37
AA
18851@item -fstack-limit-register=@var{reg}
18852@itemx -fstack-limit-symbol=@var{sym}
18853@itemx -fno-stack-limit
d77de738
ML
18854Generate code to ensure that the stack does not grow beyond a certain value,
18855either the value of a register or the address of a symbol. If a larger
18856stack is required, a signal is raised at run time. For most targets,
18857the signal is raised before the stack overruns the boundary, so
18858it is possible to catch the signal without taking special precautions.
18859
18860For instance, if the stack starts at absolute address @samp{0x80000000}
18861and grows downwards, you can use the flags
18862@option{-fstack-limit-symbol=__stack_limit} and
18863@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
18864of 128KB@. Note that this may only work with the GNU linker.
18865
18866You can locally override stack limit checking by using the
18867@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
18868
d77de738 18869@opindex fsplit-stack
ddf6fe37 18870@item -fsplit-stack
d77de738
ML
18871Generate code to automatically split the stack before it overflows.
18872The resulting program has a discontiguous stack which can only
18873overflow if the program is unable to allocate any more memory. This
18874is most useful when running threaded programs, as it is no longer
18875necessary to calculate a good stack size to use for each thread. This
18876is currently only implemented for the x86 targets running
18877GNU/Linux.
18878
18879When code compiled with @option{-fsplit-stack} calls code compiled
18880without @option{-fsplit-stack}, there may not be much stack space
18881available for the latter code to run. If compiling all code,
18882including library code, with @option{-fsplit-stack} is not an option,
18883then the linker can fix up these calls so that the code compiled
18884without @option{-fsplit-stack} always has a large stack. Support for
18885this is implemented in the gold linker in GNU binutils release 2.21
18886and later.
18887
a0d60660 18888@opindex fstrub=disable
f0a90c7d
AO
18889@item -fstrub=disable
18890Disable stack scrubbing entirely, ignoring any @code{strub} attributes.
18891See @xref{Common Type Attributes}.
18892
18893@opindex fstrub=strict
18894@item -fstrub=strict
18895Functions default to @code{strub} mode @code{disabled}, and apply
18896@option{strict}ly the restriction that only functions associated with
18897@code{strub}-@code{callable} modes (@code{at-calls}, @code{callable} and
18898@code{always_inline} @code{internal}) are @code{callable} by functions
18899with @code{strub}-enabled modes (@code{at-calls} and @code{internal}).
18900
18901@opindex fstrub=relaxed
18902@item -fstrub=relaxed
18903Restore the default stack scrub (@code{strub}) setting, namely,
18904@code{strub} is only enabled as required by @code{strub} attributes
18905associated with function and data types. @code{Relaxed} means that
18906strub contexts are only prevented from calling functions explicitly
18907associated with @code{strub} mode @code{disabled}. This option is only
18908useful to override other @option{-fstrub=*} options that precede it in
18909the command line.
18910
18911@opindex fstrub=at-calls
18912@item -fstrub=at-calls
18913Enable @code{at-calls} @code{strub} mode where viable. The primary use
18914of this option is for testing. It exercises the @code{strub} machinery
18915in scenarios strictly local to a translation unit. This @code{strub}
18916mode modifies function interfaces, so any function that is visible to
18917other translation units, or that has its address taken, will @emph{not}
18918be affected by this option. Optimization options may also affect
18919viability. See the @code{strub} attribute documentation for details on
18920viability and eligibility requirements.
18921
18922@opindex fstrub=internal
18923@item -fstrub=internal
18924Enable @code{internal} @code{strub} mode where viable. The primary use
18925of this option is for testing. This option is intended to exercise
18926thoroughly parts of the @code{strub} machinery that implement the less
18927efficient, but interface-preserving @code{strub} mode. Functions that
18928would not be affected by this option are quite uncommon.
18929
18930@opindex fstrub=all
18931@item -fstrub=all
18932Enable some @code{strub} mode where viable. When both strub modes are
18933viable, @code{at-calls} is preferred. @option{-fdump-ipa-strubm} adds
18934function attributes that tell which mode was selected for each function.
18935The primary use of this option is for testing, to exercise thoroughly
18936the @code{strub} machinery.
18937
d77de738 18938@opindex fvtable-verify
ddf6fe37 18939@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
18940This option is only available when compiling C++ code.
18941It turns on (or off, if using @option{-fvtable-verify=none}) the security
18942feature that verifies at run time, for every virtual call, that
18943the vtable pointer through which the call is made is valid for the type of
18944the object, and has not been corrupted or overwritten. If an invalid vtable
18945pointer is detected at run time, an error is reported and execution of the
18946program is immediately halted.
18947
18948This option causes run-time data structures to be built at program startup,
a0e64a04 18949which are used for verifying the vtable pointers.
d77de738
ML
18950The options @samp{std} and @samp{preinit}
18951control the timing of when these data structures are built. In both cases the
18952data structures are built before execution reaches @code{main}. Using
18953@option{-fvtable-verify=std} causes the data structures to be built after
18954shared libraries have been loaded and initialized.
18955@option{-fvtable-verify=preinit} causes them to be built before shared
18956libraries have been loaded and initialized.
18957
18958If this option appears multiple times in the command line with different
18959values specified, @samp{none} takes highest priority over both @samp{std} and
18960@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
18961
d77de738 18962@opindex fvtv-debug
ddf6fe37 18963@item -fvtv-debug
a0e64a04
PN
18964When used in conjunction with @option{-fvtable-verify=std} or
18965@option{-fvtable-verify=preinit}, causes debug versions of the
18966runtime functions for the vtable verification feature to be called.
18967This flag also causes the compiler to log information about which
d77de738 18968vtable pointers it finds for each class.
a0e64a04
PN
18969This information is written to a file named @file{vtv_set_ptr_data.log}
18970in the directory named by the environment variable @env{VTV_LOGS_DIR}
d77de738
ML
18971if that is defined or the current working directory otherwise.
18972
18973Note: This feature @emph{appends} data to the log file. If you want a fresh log
18974file, be sure to delete any existing one.
18975
d77de738 18976@opindex fvtv-counts
ddf6fe37 18977@item -fvtv-counts
d77de738
ML
18978This is a debugging flag. When used in conjunction with
18979@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
18980causes the compiler to keep track of the total number of virtual calls
18981it encounters and the number of verifications it inserts. It also
18982counts the number of calls to certain run-time library functions
18983that it inserts and logs this information for each compilation unit.
18984The compiler writes this information to a file named
18985@file{vtv_count_data.log} in the directory named by the environment
18986variable @env{VTV_LOGS_DIR} if that is defined or the current working
18987directory otherwise. It also counts the size of the vtable pointer sets
18988for each class, and writes this information to @file{vtv_class_set_sizes.log}
18989in the same directory.
18990
18991Note: This feature @emph{appends} data to the log files. To get fresh log
18992files, be sure to delete any existing ones.
18993
d77de738 18994@opindex finstrument-functions
ddf6fe37 18995@item -finstrument-functions
d77de738
ML
18996Generate instrumentation calls for entry and exit to functions. Just
18997after function entry and just before function exit, the following
18998profiling functions are called with the address of the current
18999function and its call site. (On some platforms,
19000@code{__builtin_return_address} does not work beyond the current
19001function, so the call site information may not be available to the
19002profiling functions otherwise.)
19003
19004@smallexample
19005void __cyg_profile_func_enter (void *this_fn,
19006 void *call_site);
19007void __cyg_profile_func_exit (void *this_fn,
19008 void *call_site);
19009@end smallexample
19010
19011The first argument is the address of the start of the current function,
19012which may be looked up exactly in the symbol table.
19013
19014This instrumentation is also done for functions expanded inline in other
19015functions. The profiling calls indicate where, conceptually, the
19016inline function is entered and exited. This means that addressable
19017versions of such functions must be available. If all your uses of a
19018function are expanded inline, this may mean an additional expansion of
19019code size. If you use @code{extern inline} in your C code, an
19020addressable version of such functions must be provided. (This is
19021normally the case anyway, but if you get lucky and the optimizer always
19022expands the functions inline, you might have gotten away without
19023providing static copies.)
19024
19025A function may be given the attribute @code{no_instrument_function}, in
19026which case this instrumentation is not done. This can be used, for
19027example, for the profiling functions listed above, high-priority
19028interrupt routines, and any functions from which the profiling functions
19029cannot safely be called (perhaps signal handlers, if the profiling
19030routines generate output or allocate memory).
19031@xref{Common Function Attributes}.
19032
9c19597c 19033@opindex finstrument-functions-once
ddf6fe37 19034@item -finstrument-functions-once
d77de738
ML
19035This is similar to @option{-finstrument-functions}, but the profiling
19036functions are called only once per instrumented function, i.e. the first
19037profiling function is called after the first entry into the instrumented
19038function and the second profiling function is called before the exit
19039corresponding to this first entry.
19040
19041The definition of @code{once} for the purpose of this option is a little
19042vague because the implementation is not protected against data races.
19043As a result, the implementation only guarantees that the profiling
19044functions are called at @emph{least} once per process and at @emph{most}
19045once per thread, but the calls are always paired, that is to say, if a
19046thread calls the first function, then it will call the second function,
19047unless it never reaches the exit of the instrumented function.
19048
d77de738 19049@opindex finstrument-functions-exclude-file-list
ddf6fe37 19050@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
19051
19052Set the list of functions that are excluded from instrumentation (see
19053the description of @option{-finstrument-functions}). If the file that
19054contains a function definition matches with one of @var{file}, then
19055that function is not instrumented. The match is done on substrings:
19056if the @var{file} parameter is a substring of the file name, it is
19057considered to be a match.
19058
19059For example:
19060
19061@smallexample
19062-finstrument-functions-exclude-file-list=/bits/stl,include/sys
19063@end smallexample
19064
19065@noindent
19066excludes any inline function defined in files whose pathnames
19067contain @file{/bits/stl} or @file{include/sys}.
19068
19069If, for some reason, you want to include letter @samp{,} in one of
19070@var{sym}, write @samp{\,}. For example,
19071@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
19072(note the single quote surrounding the option).
19073
d77de738 19074@opindex finstrument-functions-exclude-function-list
ddf6fe37 19075@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
19076
19077This is similar to @option{-finstrument-functions-exclude-file-list},
19078but this option sets the list of function names to be excluded from
19079instrumentation. The function name to be matched is its user-visible
19080name, such as @code{vector<int> blah(const vector<int> &)}, not the
19081internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
19082match is done on substrings: if the @var{sym} parameter is a substring
19083of the function name, it is considered to be a match. For C99 and C++
19084extended identifiers, the function name must be given in UTF-8, not
19085using universal character names.
19086
d77de738 19087@opindex fpatchable-function-entry
ddf6fe37 19088@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
19089Generate @var{N} NOPs right at the beginning
19090of each function, with the function entry point before the @var{M}th NOP.
19091If @var{M} is omitted, it defaults to @code{0} so the
19092function entry points to the address just at the first NOP.
19093The NOP instructions reserve extra space which can be used to patch in
19094any desired instrumentation at run time, provided that the code segment
19095is writable. The amount of space is controllable indirectly via
19096the number of NOPs; the NOP instruction used corresponds to the instruction
19097emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
19098is target-specific and may also depend on the architecture variant and/or
19099other compilation options.
19100
19101For run-time identification, the starting addresses of these areas,
19102which correspond to their respective function entries minus @var{M},
19103are additionally collected in the @code{__patchable_function_entries}
19104section of the resulting binary.
19105
19106Note that the value of @code{__attribute__ ((patchable_function_entry
19107(N,M)))} takes precedence over command-line option
19108@option{-fpatchable-function-entry=N,M}. This can be used to increase
19109the area size or to remove it completely on a single function.
19110If @code{N=0}, no pad location is recorded.
19111
19112The NOP instructions are inserted at---and maybe before, depending on
19113@var{M}---the function entry address, even before the prologue. On
19114PowerPC with the ELFv2 ABI, for a function with dual entry points,
96698551
MM
19115the local entry point is this function entry address by default. See
19116the @option{-msplit-patch-nops} option to change this.
d77de738
ML
19117
19118The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
19119ELFv2 ABI, for a function with dual entry points, the supported values
96698551 19120for @var{M} are 0, 2, 6 and 14 when not using @option{-msplit-patch-nops}.
d77de738
ML
19121@end table
19122
19123
19124@node Preprocessor Options
19125@section Options Controlling the Preprocessor
19126@cindex preprocessor options
19127@cindex options, preprocessor
19128
19129These options control the C preprocessor, which is run on each C source
19130file before actual compilation.
19131
19132If you use the @option{-E} option, nothing is done except preprocessing.
19133Some of these options make sense only together with @option{-E} because
19134they cause the preprocessor output to be unsuitable for actual
19135compilation.
19136
a0e64a04
PN
19137In addition to the options listed here, there are a number of options
19138to control search paths for include files documented in
19139@ref{Directory Options}.
19140Options to control preprocessor diagnostics are listed in
d77de738
ML
19141@ref{Warning Options}.
19142
19143@table @gcctabopt
19144@include cppopts.texi
19145
d77de738 19146@opindex Wp
ddf6fe37 19147@item -Wp,@var{option}
d77de738
ML
19148You can use @option{-Wp,@var{option}} to bypass the compiler driver
19149and pass @var{option} directly through to the preprocessor. If
19150@var{option} contains commas, it is split into multiple options at the
19151commas. However, many options are modified, translated or interpreted
19152by the compiler driver before being passed to the preprocessor, and
19153@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
19154interface is undocumented and subject to change, so whenever possible
19155you should avoid using @option{-Wp} and let the driver handle the
19156options instead.
19157
d77de738 19158@opindex Xpreprocessor
ddf6fe37 19159@item -Xpreprocessor @var{option}
d77de738 19160Pass @var{option} as an option to the preprocessor. You can use this to
a0e64a04 19161supply system-specific preprocessor options that GCC does not
d77de738
ML
19162recognize.
19163
19164If you want to pass an option that takes an argument, you must use
19165@option{-Xpreprocessor} twice, once for the option and once for the argument.
19166
d77de738 19167@opindex no-integrated-cpp
ddf6fe37 19168@item -no-integrated-cpp
d77de738
ML
19169Perform preprocessing as a separate pass before compilation.
19170By default, GCC performs preprocessing as an integrated part of
19171input tokenization and parsing.
19172If this option is provided, the appropriate language front end
19173(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
19174and Objective-C, respectively) is instead invoked twice,
19175once for preprocessing only and once for actual compilation
19176of the preprocessed input.
19177This option may be useful in conjunction with the @option{-B} or
19178@option{-wrapper} options to specify an alternate preprocessor or
19179perform additional processing of the program source between
19180normal preprocessing and compilation.
19181
d77de738
ML
19182@end table
19183
19184@node Assembler Options
19185@section Passing Options to the Assembler
19186
19187@c prevent bad page break with this line
19188You can pass options to the assembler.
19189
19190@table @gcctabopt
d77de738 19191@opindex Wa
ddf6fe37 19192@item -Wa,@var{option}
d77de738
ML
19193Pass @var{option} as an option to the assembler. If @var{option}
19194contains commas, it is split into multiple options at the commas.
19195
d77de738 19196@opindex Xassembler
ddf6fe37 19197@item -Xassembler @var{option}
d77de738
ML
19198Pass @var{option} as an option to the assembler. You can use this to
19199supply system-specific assembler options that GCC does not
19200recognize.
19201
19202If you want to pass an option that takes an argument, you must use
19203@option{-Xassembler} twice, once for the option and once for the argument.
19204
19205@end table
19206
19207@node Link Options
19208@section Options for Linking
19209@cindex link options
19210@cindex options, linking
19211
19212These options come into play when the compiler links object files into
19213an executable output file. They are meaningless if the compiler is
19214not doing a link step.
19215
19216@table @gcctabopt
19217@cindex file names
19218@item @var{object-file-name}
19219A file name that does not end in a special recognized suffix is
19220considered to name an object file or library. (Object files are
19221distinguished from libraries by the linker according to the file
19222contents.) If linking is done, these object files are used as input
19223to the linker.
19224
d77de738
ML
19225@opindex c
19226@opindex S
19227@opindex E
ddf6fe37
AA
19228@item -c
19229@itemx -S
19230@itemx -E
d77de738
ML
19231If any of these options is used, then the linker is not run, and
19232object file names should not be used as arguments. @xref{Overall
19233Options}.
19234
d77de738 19235@opindex flinker-output
ddf6fe37 19236@item -flinker-output=@var{type}
d77de738
ML
19237This option controls code generation of the link-time optimizer. By
19238default the linker output is automatically determined by the linker
a0e64a04 19239plugin. For debugging the compiler and if incremental linking with a
d77de738
ML
19240non-LTO object file is desired, it may be useful to control the type
19241manually.
19242
19243If @var{type} is @samp{exec}, code generation produces a static
19244binary. In this case @option{-fpic} and @option{-fpie} are both
19245disabled.
19246
19247If @var{type} is @samp{dyn}, code generation produces a shared
19248library. In this case @option{-fpic} or @option{-fPIC} is preserved,
19249but not enabled automatically. This allows to build shared libraries
19250without position-independent code on architectures where this is
19251possible, i.e.@: on x86.
19252
19253If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
19254executable. This results in similar optimizations as @samp{exec}
19255except that @option{-fpie} is not disabled if specified at compilation
19256time.
19257
19258If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
19259done. The sections containing intermediate code for link-time optimization are
19260merged, pre-optimized, and output to the resulting object file. In addition, if
19261@option{-ffat-lto-objects} is specified, binary code is produced for future
19262non-LTO linking. The object file produced by incremental linking is smaller
19263than a static library produced from the same object files. At link time the
19264result of incremental linking also loads faster than a static
19265library assuming that the majority of objects in the library are used.
19266
19267Finally @samp{nolto-rel} configures the compiler for incremental linking where
19268code generation is forced, a final binary is produced, and the intermediate
19269code for later link-time optimization is stripped. When multiple object files
19270are linked together the resulting code is better optimized than with
a0e64a04
PN
19271link-time optimizations disabled (for example, cross-module inlining
19272happens), but most of benefits of whole program optimizations are lost.
d77de738
ML
19273
19274During the incremental link (by @option{-r}) the linker plugin defaults to
19275@option{rel}. With current interfaces to GNU Binutils it is however not
19276possible to incrementally link LTO objects and non-LTO objects into a single
19277mixed object file. If any of object files in incremental link cannot
19278be used for link-time optimization, the linker plugin issues a warning and
19279uses @samp{nolto-rel}. To maintain whole program optimization, it is
19280recommended to link such objects into static library instead. Alternatively it
19281is possible to use H.J. Lu's binutils with support for mixed objects.
19282
d77de738 19283@opindex fuse-ld=bfd
ddf6fe37 19284@item -fuse-ld=bfd
d77de738
ML
19285Use the @command{bfd} linker instead of the default linker.
19286
d77de738 19287@opindex fuse-ld=gold
ddf6fe37 19288@item -fuse-ld=gold
d77de738
ML
19289Use the @command{gold} linker instead of the default linker.
19290
d77de738 19291@opindex fuse-ld=lld
ddf6fe37 19292@item -fuse-ld=lld
d77de738
ML
19293Use the LLVM @command{lld} linker instead of the default linker.
19294
d77de738 19295@opindex fuse-ld=mold
ddf6fe37 19296@item -fuse-ld=mold
d77de738
ML
19297Use the Modern Linker (@command{mold}) instead of the default linker.
19298
19299@cindex Libraries
ddf6fe37 19300@opindex l
d77de738
ML
19301@item -l@var{library}
19302@itemx -l @var{library}
d77de738
ML
19303Search the library named @var{library} when linking. (The second
19304alternative with the library as a separate argument is only for
19305POSIX compliance and is not recommended.)
19306
19307The @option{-l} option is passed directly to the linker by GCC. Refer
19308to your linker documentation for exact details. The general
a0e64a04 19309description below applies to the GNU linker.
d77de738
ML
19310
19311The linker searches a standard list of directories for the library.
19312The directories searched include several standard system directories
19313plus any that you specify with @option{-L}.
19314
19315Static libraries are archives of object files, and have file names
19316like @file{lib@var{library}.a}. Some targets also support shared
19317libraries, which typically have names like @file{lib@var{library}.so}.
19318If both static and shared libraries are found, the linker gives
19319preference to linking with the shared library unless the
19320@option{-static} option is used.
19321
19322It makes a difference where in the command you write this option; the
19323linker searches and processes libraries and object files in the order they
19324are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
19325after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
19326to functions in @samp{z}, those functions may not be loaded.
19327
d77de738 19328@opindex lobjc
ddf6fe37 19329@item -lobjc
d77de738
ML
19330You need this special case of the @option{-l} option in order to
19331link an Objective-C or Objective-C++ program.
19332
d77de738 19333@opindex nostartfiles
ddf6fe37 19334@item -nostartfiles
d77de738
ML
19335Do not use the standard system startup files when linking.
19336The standard system libraries are used normally, unless @option{-nostdlib},
19337@option{-nolibc}, or @option{-nodefaultlibs} is used.
19338
d77de738 19339@opindex nodefaultlibs
ddf6fe37 19340@item -nodefaultlibs
d77de738
ML
19341Do not use the standard system libraries when linking.
19342Only the libraries you specify are passed to the linker, and options
19343specifying linkage of the system libraries, such as @option{-static-libgcc}
a0e64a04 19344or @option{-shared-libgcc}, are ignored.
d77de738 19345The standard startup files are used normally, unless @option{-nostartfiles}
a0e64a04 19346is used.
d77de738
ML
19347
19348The compiler may generate calls to @code{memcmp},
19349@code{memset}, @code{memcpy} and @code{memmove}.
19350These entries are usually resolved by entries in
19351libc. These entry points should be supplied through some other
19352mechanism when this option is specified.
19353
d77de738 19354@opindex nolibc
ddf6fe37 19355@item -nolibc
d77de738
ML
19356Do not use the C library or system libraries tightly coupled with it when
19357linking. Still link with the startup files, @file{libgcc} or toolchain
19358provided language support libraries such as @file{libgnat}, @file{libgfortran}
19359or @file{libstdc++} unless options preventing their inclusion are used as
19360well. This typically removes @option{-lc} from the link command line, as well
19361as system libraries that normally go with it and become meaningless when
19362absence of a C library is assumed, for example @option{-lpthread} or
19363@option{-lm} in some configurations. This is intended for bare-board
19364targets when there is indeed no C library available.
19365
d77de738 19366@opindex nostdlib
ddf6fe37 19367@item -nostdlib
d77de738
ML
19368Do not use the standard system startup files or libraries when linking.
19369No startup files and only the libraries you specify are passed to
19370the linker, and options specifying linkage of the system libraries, such as
19371@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
19372
19373The compiler may generate calls to @code{memcmp}, @code{memset},
19374@code{memcpy} and @code{memmove}.
19375These entries are usually resolved by entries in
19376libc. These entry points should be supplied through some other
19377mechanism when this option is specified.
19378
19379@cindex @option{-lgcc}, use with @option{-nostdlib}
19380@cindex @option{-nostdlib} and unresolved references
19381@cindex unresolved references and @option{-nostdlib}
19382@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
19383@cindex @option{-nodefaultlibs} and unresolved references
19384@cindex unresolved references and @option{-nodefaultlibs}
19385One of the standard libraries bypassed by @option{-nostdlib} and
19386@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
19387which GCC uses to overcome shortcomings of particular machines, or special
19388needs for some languages.
19389(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
19390Collection (GCC) Internals},
19391for more discussion of @file{libgcc.a}.)
19392In most cases, you need @file{libgcc.a} even when you want to avoid
19393other standard libraries. In other words, when you specify @option{-nostdlib}
19394or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
19395This ensures that you have no unresolved references to internal GCC
19396library subroutines.
19397(An example of such an internal subroutine is @code{__main}, used to ensure C++
19398constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
19399GNU Compiler Collection (GCC) Internals}.)
19400
d77de738 19401@opindex nostdlib++
ddf6fe37 19402@item -nostdlib++
d77de738
ML
19403Do not implicitly link with standard C++ libraries.
19404
d77de738
ML
19405@opindex e
19406@opindex entry
ddf6fe37
AA
19407@item -e @var{entry}
19408@itemx --entry=@var{entry}
d77de738
ML
19409
19410Specify that the program entry point is @var{entry}. The argument is
19411interpreted by the linker; the GNU linker accepts either a symbol name
19412or an address.
19413
d77de738 19414@opindex pie
ddf6fe37 19415@item -pie
d77de738
ML
19416Produce a dynamically linked position independent executable on targets
19417that support it. For predictable results, you must also specify the same
19418set of options used for compilation (@option{-fpie}, @option{-fPIE},
19419or model suboptions) when you specify this linker option.
19420
d77de738 19421@opindex no-pie
ddf6fe37 19422@item -no-pie
d77de738
ML
19423Don't produce a dynamically linked position independent executable.
19424
d77de738 19425@opindex static-pie
ddf6fe37 19426@item -static-pie
d77de738
ML
19427Produce a static position independent executable on targets that support
19428it. A static position independent executable is similar to a static
19429executable, but can be loaded at any address without a dynamic linker.
19430For predictable results, you must also specify the same set of options
19431used for compilation (@option{-fpie}, @option{-fPIE}, or model
19432suboptions) when you specify this linker option.
19433
d77de738 19434@opindex pthread
ddf6fe37 19435@item -pthread
a0e64a04
PN
19436Link with the POSIX threads library. This option is supported on
19437GNU/Linux targets, most other Unix derivatives, and also on
19438x86 Cygwin and MinGW targets. On some targets this option also sets
d77de738
ML
19439flags for the preprocessor, so it should be used consistently for both
19440compilation and linking.
19441
d77de738 19442@opindex r
ddf6fe37 19443@item -r
d77de738
ML
19444Produce a relocatable object as output. This is also known as partial
19445linking.
19446
d77de738 19447@opindex rdynamic
ddf6fe37 19448@item -rdynamic
d77de738
ML
19449Pass the flag @option{-export-dynamic} to the ELF linker, on targets
19450that support it. This instructs the linker to add all symbols, not
19451only used ones, to the dynamic symbol table. This option is needed
19452for some uses of @code{dlopen} or to allow obtaining backtraces
19453from within a program.
19454
d77de738 19455@opindex s
ddf6fe37 19456@item -s
d77de738
ML
19457Remove all symbol table and relocation information from the executable.
19458
d77de738 19459@opindex static
ddf6fe37 19460@item -static
d77de738
ML
19461On systems that support dynamic linking, this overrides @option{-pie}
19462and prevents linking with the shared libraries. On other systems, this
19463option has no effect.
19464
d77de738 19465@opindex shared
ddf6fe37 19466@item -shared
d77de738
ML
19467Produce a shared object which can then be linked with other objects to
19468form an executable. Not all systems support this option. For predictable
19469results, you must also specify the same set of options used for compilation
19470(@option{-fpic}, @option{-fPIC}, or model suboptions) when
19471you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
19472needs to build supplementary stub code for constructors to work. On
19473multi-libbed systems, @samp{gcc -shared} must select the correct support
19474libraries to link against. Failing to supply the correct flags may lead
19475to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
19476is innocuous. @option{-shared} suppresses the addition of startup code
19477to alter the floating-point environment as done with @option{-ffast-math},
19478@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 19479
d77de738
ML
19480@opindex shared-libgcc
19481@opindex static-libgcc
ddf6fe37
AA
19482@item -shared-libgcc
19483@itemx -static-libgcc
d77de738
ML
19484On systems that provide @file{libgcc} as a shared library, these options
19485force the use of either the shared or static version, respectively.
19486If no shared version of @file{libgcc} was built when the compiler was
19487configured, these options have no effect.
19488
19489There are several situations in which an application should use the
19490shared @file{libgcc} instead of the static version. The most common
19491of these is when the application wishes to throw and catch exceptions
19492across different shared libraries. In that case, each of the libraries
19493as well as the application itself should use the shared @file{libgcc}.
19494
19495Therefore, the G++ driver automatically adds @option{-shared-libgcc}
19496whenever you build a shared library or a main executable, because C++
19497programs typically use exceptions, so this is the right thing to do.
19498
19499If, instead, you use the GCC driver to create shared libraries, you may
19500find that they are not always linked with the shared @file{libgcc}.
19501If GCC finds, at its configuration time, that you have a non-GNU linker
19502or a GNU linker that does not support option @option{--eh-frame-hdr},
19503it links the shared version of @file{libgcc} into shared libraries
19504by default. Otherwise, it takes advantage of the linker and optimizes
19505away the linking with the shared version of @file{libgcc}, linking with
19506the static version of libgcc by default. This allows exceptions to
19507propagate through such shared libraries, without incurring relocation
19508costs at library load time.
19509
19510However, if a library or main executable is supposed to throw or catch
19511exceptions, you must link it using the G++ driver, or using the option
19512@option{-shared-libgcc}, such that it is linked with the shared
19513@file{libgcc}.
19514
d77de738 19515@opindex static-libasan
ddf6fe37 19516@item -static-libasan
d77de738
ML
19517When the @option{-fsanitize=address} option is used to link a program,
19518the GCC driver automatically links against @option{libasan}. If
19519@file{libasan} is available as a shared library, and the @option{-static}
19520option is not used, then this links against the shared version of
19521@file{libasan}. The @option{-static-libasan} option directs the GCC
19522driver to link @file{libasan} statically, without necessarily linking
19523other libraries statically.
19524
d77de738 19525@opindex static-libtsan
ddf6fe37 19526@item -static-libtsan
d77de738
ML
19527When the @option{-fsanitize=thread} option is used to link a program,
19528the GCC driver automatically links against @option{libtsan}. If
19529@file{libtsan} is available as a shared library, and the @option{-static}
19530option is not used, then this links against the shared version of
19531@file{libtsan}. The @option{-static-libtsan} option directs the GCC
19532driver to link @file{libtsan} statically, without necessarily linking
19533other libraries statically.
19534
d77de738 19535@opindex static-liblsan
ddf6fe37 19536@item -static-liblsan
d77de738
ML
19537When the @option{-fsanitize=leak} option is used to link a program,
19538the GCC driver automatically links against @option{liblsan}. If
19539@file{liblsan} is available as a shared library, and the @option{-static}
19540option is not used, then this links against the shared version of
19541@file{liblsan}. The @option{-static-liblsan} option directs the GCC
19542driver to link @file{liblsan} statically, without necessarily linking
19543other libraries statically.
19544
d77de738 19545@opindex static-libubsan
ddf6fe37 19546@item -static-libubsan
d77de738
ML
19547When the @option{-fsanitize=undefined} option is used to link a program,
19548the GCC driver automatically links against @option{libubsan}. If
19549@file{libubsan} is available as a shared library, and the @option{-static}
19550option is not used, then this links against the shared version of
19551@file{libubsan}. The @option{-static-libubsan} option directs the GCC
19552driver to link @file{libubsan} statically, without necessarily linking
19553other libraries statically.
19554
d77de738 19555@opindex static-libstdc++
ddf6fe37 19556@item -static-libstdc++
d77de738
ML
19557When the @command{g++} program is used to link a C++ program, it
19558normally automatically links against @option{libstdc++}. If
19559@file{libstdc++} is available as a shared library, and the
19560@option{-static} option is not used, then this links against the
19561shared version of @file{libstdc++}. That is normally fine. However, it
19562is sometimes useful to freeze the version of @file{libstdc++} used by
19563the program without going all the way to a fully static link. The
19564@option{-static-libstdc++} option directs the @command{g++} driver to
19565link @file{libstdc++} statically, without necessarily linking other
19566libraries statically.
19567
d77de738 19568@opindex symbolic
ddf6fe37 19569@item -symbolic
d77de738
ML
19570Bind references to global symbols when building a shared object. Warn
19571about any unresolved references (unless overridden by the link editor
19572option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
19573this option.
19574
d77de738
ML
19575@opindex T
19576@cindex linker script
f33d7a88 19577@item -T @var{script}
d77de738
ML
19578Use @var{script} as the linker script. This option is supported by most
19579systems using the GNU linker. On some targets, such as bare-board
19580targets without an operating system, the @option{-T} option may be required
19581when linking to avoid references to undefined symbols.
19582
d77de738 19583@opindex Xlinker
ddf6fe37 19584@item -Xlinker @var{option}
d77de738
ML
19585Pass @var{option} as an option to the linker. You can use this to
19586supply system-specific linker options that GCC does not recognize.
19587
19588If you want to pass an option that takes a separate argument, you must use
19589@option{-Xlinker} twice, once for the option and once for the argument.
19590For example, to pass @option{-assert definitions}, you must write
19591@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
19592@option{-Xlinker "-assert definitions"}, because this passes the entire
19593string as a single argument, which is not what the linker expects.
19594
19595When using the GNU linker, it is usually more convenient to pass
19596arguments to linker options using the @option{@var{option}=@var{value}}
19597syntax than as separate arguments. For example, you can specify
19598@option{-Xlinker -Map=output.map} rather than
19599@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
19600this syntax for command-line options.
19601
d77de738 19602@opindex Wl
ddf6fe37 19603@item -Wl,@var{option}
d77de738
ML
19604Pass @var{option} as an option to the linker. If @var{option} contains
19605commas, it is split into multiple options at the commas. You can use this
19606syntax to pass an argument to the option.
19607For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
19608linker. When using the GNU linker, you can also get the same effect with
19609@option{-Wl,-Map=output.map}.
19610
d77de738 19611@opindex u
ddf6fe37 19612@item -u @var{symbol}
d77de738
ML
19613Pretend the symbol @var{symbol} is undefined, to force linking of
19614library modules to define it. You can use @option{-u} multiple times with
19615different symbols to force loading of additional library modules.
19616
d77de738 19617@opindex z
ddf6fe37 19618@item -z @var{keyword}
d77de738
ML
19619@option{-z} is passed directly on to the linker along with the keyword
19620@var{keyword}. See the section in the documentation of your linker for
19621permitted values and their meanings.
19622@end table
19623
19624@node Directory Options
19625@section Options for Directory Search
19626@cindex directory options
19627@cindex options, directory search
19628@cindex search path
19629
19630These options specify directories to search for header files, for
19631libraries and for parts of the compiler:
19632
19633@table @gcctabopt
19634@include cppdiropts.texi
19635
d77de738 19636@opindex iplugindir=
ddf6fe37 19637@item -iplugindir=@var{dir}
d77de738
ML
19638Set the directory to search for plugins that are passed
19639by @option{-fplugin=@var{name}} instead of
19640@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
19641to be used by the user, but only passed by the driver.
19642
d77de738 19643@opindex L
ddf6fe37 19644@item -L@var{dir}
d77de738
ML
19645Add directory @var{dir} to the list of directories to be searched
19646for @option{-l}.
19647
d77de738 19648@opindex B
ddf6fe37 19649@item -B@var{prefix}
d77de738
ML
19650This option specifies where to find the executables, libraries,
19651include files, and data files of the compiler itself.
19652
19653The compiler driver program runs one or more of the subprograms
19654@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
19655@var{prefix} as a prefix for each program it tries to run, both with and
19656without @samp{@var{machine}/@var{version}/} for the corresponding target
19657machine and compiler version.
19658
19659For each subprogram to be run, the compiler driver first tries the
19660@option{-B} prefix, if any. If that name is not found, or if @option{-B}
a0e64a04 19661is not specified, the driver tries two standard prefixes,
d77de738
ML
19662@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
19663those results in a file name that is found, the unmodified program
19664name is searched for using the directories specified in your
19665@env{PATH} environment variable.
19666
19667The compiler checks to see if the path provided by @option{-B}
19668refers to a directory, and if necessary it adds a directory
19669separator character at the end of the path.
19670
19671@option{-B} prefixes that effectively specify directory names also apply
19672to libraries in the linker, because the compiler translates these
19673options into @option{-L} options for the linker. They also apply to
19674include files in the preprocessor, because the compiler translates these
19675options into @option{-isystem} options for the preprocessor. In this case,
19676the compiler appends @samp{include} to the prefix.
19677
19678The runtime support file @file{libgcc.a} can also be searched for using
19679the @option{-B} prefix, if needed. If it is not found there, the two
19680standard prefixes above are tried, and that is all. The file is left
19681out of the link if it is not found by those means.
19682
19683Another way to specify a prefix much like the @option{-B} prefix is to use
19684the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
19685Variables}.
19686
19687As a special kludge, if the path provided by @option{-B} is
19688@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
196899, then it is replaced by @file{[dir/]include}. This is to help
19690with boot-strapping the compiler.
19691
d77de738 19692@opindex no-canonical-prefixes
ddf6fe37 19693@item -no-canonical-prefixes
d77de738
ML
19694Do not expand any symbolic links, resolve references to @samp{/../}
19695or @samp{/./}, or make the path absolute when generating a relative
19696prefix.
19697
d77de738 19698@opindex sysroot
ddf6fe37 19699@item --sysroot=@var{dir}
d77de738
ML
19700Use @var{dir} as the logical root directory for headers and libraries.
19701For example, if the compiler normally searches for headers in
19702@file{/usr/include} and libraries in @file{/usr/lib}, it instead
19703searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
19704
19705If you use both this option and the @option{-isysroot} option, then
19706the @option{--sysroot} option applies to libraries, but the
19707@option{-isysroot} option applies to header files.
19708
19709The GNU linker (beginning with version 2.16) has the necessary support
19710for this option. If your linker does not support this option, the
19711header file aspect of @option{--sysroot} still works, but the
19712library aspect does not.
19713
d77de738 19714@opindex no-sysroot-suffix
ddf6fe37 19715@item --no-sysroot-suffix
d77de738
ML
19716For some targets, a suffix is added to the root directory specified
19717with @option{--sysroot}, depending on the other options used, so that
19718headers may for example be found in
19719@file{@var{dir}/@var{suffix}/usr/include} instead of
19720@file{@var{dir}/usr/include}. This option disables the addition of
19721such a suffix.
19722
19723@end table
19724
19725@node Code Gen Options
19726@section Options for Code Generation Conventions
19727@cindex code generation conventions
19728@cindex options, code generation
19729@cindex run-time options
19730
19731These machine-independent options control the interface conventions
19732used in code generation.
19733
19734Most of them have both positive and negative forms; the negative form
19735of @option{-ffoo} is @option{-fno-foo}. In the table below, only
19736one of the forms is listed---the one that is not the default. You
19737can figure out the other form by either removing @samp{no-} or adding
19738it.
19739
19740@table @gcctabopt
d77de738 19741@opindex fstack_reuse
ddf6fe37 19742@item -fstack-reuse=@var{reuse-level}
d77de738
ML
19743This option controls stack space reuse for user declared local/auto variables
19744and compiler generated temporaries. @var{reuse_level} can be @samp{all},
19745@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
19746local variables and temporaries, @samp{named_vars} enables the reuse only for
19747user defined local variables with names, and @samp{none} disables stack reuse
19748completely. The default value is @samp{all}. The option is needed when the
19749program extends the lifetime of a scoped local variable or a compiler generated
19750temporary beyond the end point defined by the language. When a lifetime of
19751a variable ends, and if the variable lives in memory, the optimizing compiler
19752has the freedom to reuse its stack space with other temporaries or scoped
19753local variables whose live range does not overlap with it. Legacy code extending
19754local lifetime is likely to break with the stack reuse optimization.
19755
19756For example,
19757
19758@smallexample
19759 int *p;
19760 @{
19761 int local1;
19762
19763 p = &local1;
19764 local1 = 10;
19765 ....
19766 @}
19767 @{
19768 int local2;
19769 local2 = 20;
19770 ...
19771 @}
19772
19773 if (*p == 10) // out of scope use of local1
19774 @{
19775
19776 @}
19777@end smallexample
19778
19779Another example:
19780@smallexample
19781
19782 struct A
19783 @{
19784 A(int k) : i(k), j(k) @{ @}
19785 int i;
19786 int j;
19787 @};
19788
19789 A *ap;
19790
19791 void foo(const A& ar)
19792 @{
19793 ap = &ar;
19794 @}
19795
19796 void bar()
19797 @{
19798 foo(A(10)); // temp object's lifetime ends when foo returns
19799
19800 @{
19801 A a(20);
19802 ....
19803 @}
19804 ap->i+= 10; // ap references out of scope temp whose space
19805 // is reused with a. What is the value of ap->i?
19806 @}
19807
19808@end smallexample
19809
19810The lifetime of a compiler generated temporary is well defined by the C++
19811standard. When a lifetime of a temporary ends, and if the temporary lives
19812in memory, the optimizing compiler has the freedom to reuse its stack
19813space with other temporaries or scoped local variables whose live range
19814does not overlap with it. However some of the legacy code relies on
19815the behavior of older compilers in which temporaries' stack space is
19816not reused, the aggressive stack reuse can lead to runtime errors. This
19817option is used to control the temporary stack reuse optimization.
19818
d77de738 19819@opindex ftrapv
ddf6fe37 19820@item -ftrapv
d77de738
ML
19821This option generates traps for signed overflow on addition, subtraction,
19822multiplication operations.
19823The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19824@option{-ftrapv} @option{-fwrapv} on the command-line results in
19825@option{-fwrapv} being effective. Note that only active options override, so
19826using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19827results in @option{-ftrapv} being effective.
19828
d77de738 19829@opindex fwrapv
ddf6fe37 19830@item -fwrapv
d77de738
ML
19831This option instructs the compiler to assume that signed arithmetic
19832overflow of addition, subtraction and multiplication wraps around
19833using twos-complement representation. This flag enables some optimizations
19834and disables others.
19835The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19836@option{-ftrapv} @option{-fwrapv} on the command-line results in
19837@option{-fwrapv} being effective. Note that only active options override, so
19838using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19839results in @option{-ftrapv} being effective.
19840
d77de738 19841@opindex fwrapv-pointer
ddf6fe37 19842@item -fwrapv-pointer
d77de738
ML
19843This option instructs the compiler to assume that pointer arithmetic
19844overflow on addition and subtraction wraps around using twos-complement
19845representation. This flag disables some optimizations which assume
19846pointer overflow is invalid.
19847
d77de738 19848@opindex fstrict-overflow
ddf6fe37 19849@item -fstrict-overflow
d77de738
ML
19850This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
19851negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
19852
d77de738 19853@opindex fexceptions
ddf6fe37 19854@item -fexceptions
d77de738
ML
19855Enable exception handling. Generates extra code needed to propagate
19856exceptions. For some targets, this implies GCC generates frame
19857unwind information for all functions, which can produce significant data
19858size overhead, although it does not affect execution. If you do not
19859specify this option, GCC enables it by default for languages like
19860C++ that normally require exception handling, and disables it for
19861languages like C that do not normally require it. However, you may need
19862to enable this option when compiling C code that needs to interoperate
19863properly with exception handlers written in C++. You may also wish to
19864disable this option if you are compiling older C++ programs that don't
19865use exception handling.
19866
d77de738 19867@opindex fnon-call-exceptions
ddf6fe37 19868@item -fnon-call-exceptions
d77de738
ML
19869Generate code that allows trapping instructions to throw exceptions.
19870Note that this requires platform-specific runtime support that does
19871not exist everywhere. Moreover, it only allows @emph{trapping}
19872instructions to throw exceptions, i.e.@: memory references or floating-point
19873instructions. It does not allow exceptions to be thrown from
19874arbitrary signal handlers such as @code{SIGALRM}. This enables
19875@option{-fexceptions}.
19876
d77de738 19877@opindex fdelete-dead-exceptions
ddf6fe37 19878@item -fdelete-dead-exceptions
d77de738
ML
19879Consider that instructions that may throw exceptions but don't otherwise
19880contribute to the execution of the program can be optimized away.
19881This does not affect calls to functions except those with the
19882@code{pure} or @code{const} attributes.
19883This option is enabled by default for the Ada and C++ compilers, as permitted by
19884the language specifications.
19885Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
19886
d77de738 19887@opindex funwind-tables
ddf6fe37 19888@item -funwind-tables
d77de738
ML
19889Similar to @option{-fexceptions}, except that it just generates any needed
19890static data, but does not affect the generated code in any other way.
19891You normally do not need to enable this option; instead, a language processor
19892that needs this handling enables it on your behalf.
19893
d77de738 19894@opindex fasynchronous-unwind-tables
ddf6fe37 19895@item -fasynchronous-unwind-tables
d77de738
ML
19896Generate unwind table in DWARF format, if supported by target machine. The
19897table is exact at each instruction boundary, so it can be used for stack
19898unwinding from asynchronous events (such as debugger or garbage collector).
19899
d77de738
ML
19900@opindex fno-gnu-unique
19901@opindex fgnu-unique
ddf6fe37 19902@item -fno-gnu-unique
d77de738
ML
19903On systems with recent GNU assembler and C library, the C++ compiler
19904uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
19905of template static data members and static local variables in inline
19906functions are unique even in the presence of @code{RTLD_LOCAL}; this
19907is necessary to avoid problems with a library used by two different
19908@code{RTLD_LOCAL} plugins depending on a definition in one of them and
19909therefore disagreeing with the other one about the binding of the
19910symbol. But this causes @code{dlclose} to be ignored for affected
19911DSOs; if your program relies on reinitialization of a DSO via
19912@code{dlclose} and @code{dlopen}, you can use
19913@option{-fno-gnu-unique}.
19914
d77de738 19915@opindex fpcc-struct-return
ddf6fe37 19916@item -fpcc-struct-return
d77de738
ML
19917Return ``short'' @code{struct} and @code{union} values in memory like
19918longer ones, rather than in registers. This convention is less
19919efficient, but it has the advantage of allowing intercallability between
19920GCC-compiled files and files compiled with other compilers, particularly
19921the Portable C Compiler (pcc).
19922
19923The precise convention for returning structures in memory depends
19924on the target configuration macros.
19925
19926Short structures and unions are those whose size and alignment match
19927that of some integer type.
19928
19929@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
19930switch is not binary compatible with code compiled with the
19931@option{-freg-struct-return} switch.
19932Use it to conform to a non-default application binary interface.
19933
d77de738 19934@opindex freg-struct-return
ddf6fe37 19935@item -freg-struct-return
d77de738
ML
19936Return @code{struct} and @code{union} values in registers when possible.
19937This is more efficient for small structures than
19938@option{-fpcc-struct-return}.
19939
19940If you specify neither @option{-fpcc-struct-return} nor
19941@option{-freg-struct-return}, GCC defaults to whichever convention is
19942standard for the target. If there is no standard convention, GCC
19943defaults to @option{-fpcc-struct-return}, except on targets where GCC is
19944the principal compiler. In those cases, we can choose the standard, and
19945we chose the more efficient register return alternative.
19946
19947@strong{Warning:} code compiled with the @option{-freg-struct-return}
19948switch is not binary compatible with code compiled with the
19949@option{-fpcc-struct-return} switch.
19950Use it to conform to a non-default application binary interface.
19951
d77de738 19952@opindex fshort-enums
ddf6fe37 19953@item -fshort-enums
d77de738
ML
19954Allocate to an @code{enum} type only as many bytes as it needs for the
19955declared range of possible values. Specifically, the @code{enum} type
19956is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
19957This option has no effect for an enumeration type with a fixed underlying
19958type.
d77de738
ML
19959
19960@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
19961code that is not binary compatible with code generated without that switch.
19962Use it to conform to a non-default application binary interface.
19963
d77de738 19964@opindex fshort-wchar
ddf6fe37 19965@item -fshort-wchar
d77de738
ML
19966Override the underlying type for @code{wchar_t} to be @code{short
19967unsigned int} instead of the default for the target. This option is
19968useful for building programs to run under WINE@.
19969
19970@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
19971code that is not binary compatible with code generated without that switch.
19972Use it to conform to a non-default application binary interface.
19973
d77de738
ML
19974@opindex fcommon
19975@opindex fno-common
19976@cindex tentative definitions
f33d7a88 19977@item -fcommon
d77de738
ML
19978In C code, this option controls the placement of global variables
19979defined without an initializer, known as @dfn{tentative definitions}
19980in the C standard. Tentative definitions are distinct from declarations
19981of a variable with the @code{extern} keyword, which do not allocate storage.
19982
19983The default is @option{-fno-common}, which specifies that the compiler places
19984uninitialized global variables in the BSS section of the object file.
19985This inhibits the merging of tentative definitions by the linker so you get a
19986multiple-definition error if the same variable is accidentally defined in more
19987than one compilation unit.
19988
19989The @option{-fcommon} places uninitialized global variables in a common block.
19990This allows the linker to resolve all tentative definitions of the same variable
19991in different compilation units to the same object, or to a non-tentative
19992definition. This behavior is inconsistent with C++, and on many targets implies
19993a speed and code size penalty on global variable references. It is mainly
19994useful to enable legacy code to link without errors.
19995
d77de738
ML
19996@opindex fno-ident
19997@opindex fident
ddf6fe37 19998@item -fno-ident
d77de738
ML
19999Ignore the @code{#ident} directive.
20000
d77de738 20001@opindex finhibit-size-directive
ddf6fe37 20002@item -finhibit-size-directive
d77de738
ML
20003Don't output a @code{.size} assembler directive, or anything else that
20004would cause trouble if the function is split in the middle, and the
20005two halves are placed at locations far apart in memory. This option is
20006used when compiling @file{crtstuff.c}; you should not need to use it
20007for anything else.
20008
d77de738 20009@opindex fverbose-asm
ddf6fe37 20010@item -fverbose-asm
d77de738
ML
20011Put extra commentary information in the generated assembly code to
20012make it more readable. This option is generally only of use to those
20013who actually need to read the generated assembly code (perhaps while
20014debugging the compiler itself).
20015
20016@option{-fno-verbose-asm}, the default, causes the
20017extra information to be omitted and is useful when comparing two assembler
20018files.
20019
20020The added comments include:
20021
20022@itemize @bullet
20023
20024@item
20025information on the compiler version and command-line options,
20026
20027@item
20028the source code lines associated with the assembly instructions,
20029in the form FILENAME:LINENUMBER:CONTENT OF LINE,
20030
20031@item
20032hints on which high-level expressions correspond to
20033the various assembly instruction operands.
20034
20035@end itemize
20036
20037For example, given this C source file:
20038
20039@smallexample
20040int test (int n)
20041@{
20042 int i;
20043 int total = 0;
20044
20045 for (i = 0; i < n; i++)
20046 total += i * i;
20047
20048 return total;
20049@}
20050@end smallexample
20051
20052compiling to (x86_64) assembly via @option{-S} and emitting the result
20053direct to stdout via @option{-o} @option{-}
20054
20055@smallexample
20056gcc -S test.c -fverbose-asm -Os -o -
20057@end smallexample
20058
20059gives output similar to this:
20060
20061@smallexample
20062 .file "test.c"
20063# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
20064 [...snip...]
20065# options passed:
20066 [...snip...]
20067
20068 .text
20069 .globl test
20070 .type test, @@function
20071test:
20072.LFB0:
20073 .cfi_startproc
20074# test.c:4: int total = 0;
20075 xorl %eax, %eax # <retval>
20076# test.c:6: for (i = 0; i < n; i++)
20077 xorl %edx, %edx # i
20078.L2:
20079# test.c:6: for (i = 0; i < n; i++)
20080 cmpl %edi, %edx # n, i
20081 jge .L5 #,
20082# test.c:7: total += i * i;
20083 movl %edx, %ecx # i, tmp92
20084 imull %edx, %ecx # i, tmp92
20085# test.c:6: for (i = 0; i < n; i++)
20086 incl %edx # i
20087# test.c:7: total += i * i;
20088 addl %ecx, %eax # tmp92, <retval>
20089 jmp .L2 #
20090.L5:
20091# test.c:10: @}
20092 ret
20093 .cfi_endproc
20094.LFE0:
20095 .size test, .-test
20096 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
20097 .section .note.GNU-stack,"",@@progbits
20098@end smallexample
20099
20100The comments are intended for humans rather than machines and hence the
20101precise format of the comments is subject to change.
20102
d77de738 20103@opindex frecord-gcc-switches
ddf6fe37 20104@item -frecord-gcc-switches
d77de738
ML
20105This switch causes the command line used to invoke the
20106compiler to be recorded into the object file that is being created.
20107This switch is only implemented on some targets and the exact format
20108of the recording is target and binary file format dependent, but it
20109usually takes the form of a section containing ASCII text. This
20110switch is related to the @option{-fverbose-asm} switch, but that
20111switch only records information in the assembler output file as
20112comments, so it never reaches the object file.
20113See also @option{-grecord-gcc-switches} for another
20114way of storing compiler options into the object file.
20115
d77de738
ML
20116@opindex fpic
20117@cindex global offset table
20118@cindex PIC
f33d7a88 20119@item -fpic
d77de738
ML
20120Generate position-independent code (PIC) suitable for use in a shared
20121library, if supported for the target machine. Such code accesses all
20122constant addresses through a global offset table (GOT)@. The dynamic
20123loader resolves the GOT entries when the program starts (the dynamic
20124loader is not part of GCC; it is part of the operating system). If
20125the GOT size for the linked executable exceeds a machine-specific
20126maximum size, you get an error message from the linker indicating that
20127@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
20128instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
20129on the m68k and RS/6000. The x86 has no such limit.)
20130
20131Position-independent code requires special support, and therefore works
20132only on certain machines. For the x86, GCC supports PIC for System V
20133but not for the Sun 386i. Code generated for the IBM RS/6000 is always
20134position-independent.
20135
20136When this flag is set, the macros @code{__pic__} and @code{__PIC__}
20137are defined to 1.
20138
d77de738 20139@opindex fPIC
ddf6fe37 20140@item -fPIC
d77de738
ML
20141If supported for the target machine, emit position-independent code,
20142suitable for dynamic linking and avoiding any limit on the size of the
20143global offset table. This option makes a difference on AArch64, m68k,
20144PowerPC and SPARC@.
20145
20146Position-independent code requires special support, and therefore works
20147only on certain machines.
20148
20149When this flag is set, the macros @code{__pic__} and @code{__PIC__}
20150are defined to 2.
20151
d77de738
ML
20152@opindex fpie
20153@opindex fPIE
ddf6fe37
AA
20154@item -fpie
20155@itemx -fPIE
d77de738
ML
20156These options are similar to @option{-fpic} and @option{-fPIC}, but the
20157generated position-independent code can be only linked into executables.
20158Usually these options are used to compile code that will be linked using
20159the @option{-pie} GCC option.
20160
20161@option{-fpie} and @option{-fPIE} both define the macros
20162@code{__pie__} and @code{__PIE__}. The macros have the value 1
20163for @option{-fpie} and 2 for @option{-fPIE}.
20164
d77de738
ML
20165@opindex fno-plt
20166@opindex fplt
ddf6fe37 20167@item -fno-plt
d77de738
ML
20168Do not use the PLT for external function calls in position-independent code.
20169Instead, load the callee address at call sites from the GOT and branch to it.
20170This leads to more efficient code by eliminating PLT stubs and exposing
20171GOT loads to optimizations. On architectures such as 32-bit x86 where
20172PLT stubs expect the GOT pointer in a specific register, this gives more
20173register allocation freedom to the compiler.
a0e64a04 20174Lazy binding requires use of the PLT;
d77de738
ML
20175with @option{-fno-plt} all external symbols are resolved at load time.
20176
20177Alternatively, the function attribute @code{noplt} can be used to avoid calls
20178through the PLT for specific external functions.
20179
20180In position-dependent code, a few targets also convert calls to
20181functions that are marked to not use the PLT to use the GOT instead.
20182
d77de738
ML
20183@opindex fno-jump-tables
20184@opindex fjump-tables
ddf6fe37 20185@item -fno-jump-tables
d77de738
ML
20186Do not use jump tables for switch statements even where it would be
20187more efficient than other code generation strategies. This option is
20188of use in conjunction with @option{-fpic} or @option{-fPIC} for
20189building code that forms part of a dynamic linker and cannot
20190reference the address of a jump table. On some targets, jump tables
20191do not require a GOT and this option is not needed.
20192
d77de738
ML
20193@opindex fno-bit-tests
20194@opindex fbit-tests
ddf6fe37 20195@item -fno-bit-tests
d77de738
ML
20196Do not use bit tests for switch statements even where it would be
20197more efficient than other code generation strategies.
20198
d77de738 20199@opindex ffixed
ddf6fe37 20200@item -ffixed-@var{reg}
d77de738
ML
20201Treat the register named @var{reg} as a fixed register; generated code
20202should never refer to it (except perhaps as a stack pointer, frame
20203pointer or in some other fixed role).
20204
20205@var{reg} must be the name of a register. The register names accepted
20206are machine-specific and are defined in the @code{REGISTER_NAMES}
20207macro in the machine description macro file.
20208
20209This flag does not have a negative form, because it specifies a
20210three-way choice.
20211
d77de738 20212@opindex fcall-used
ddf6fe37 20213@item -fcall-used-@var{reg}
d77de738
ML
20214Treat the register named @var{reg} as an allocable register that is
20215clobbered by function calls. It may be allocated for temporaries or
20216variables that do not live across a call. Functions compiled this way
20217do not save and restore the register @var{reg}.
20218
20219It is an error to use this flag with the frame pointer or stack pointer.
20220Use of this flag for other registers that have fixed pervasive roles in
20221the machine's execution model produces disastrous results.
20222
20223This flag does not have a negative form, because it specifies a
20224three-way choice.
20225
d77de738 20226@opindex fcall-saved
ddf6fe37 20227@item -fcall-saved-@var{reg}
d77de738
ML
20228Treat the register named @var{reg} as an allocable register saved by
20229functions. It may be allocated even for temporaries or variables that
20230live across a call. Functions compiled this way save and restore
20231the register @var{reg} if they use it.
20232
20233It is an error to use this flag with the frame pointer or stack pointer.
20234Use of this flag for other registers that have fixed pervasive roles in
20235the machine's execution model produces disastrous results.
20236
20237A different sort of disaster results from the use of this flag for
20238a register in which function values may be returned.
20239
20240This flag does not have a negative form, because it specifies a
20241three-way choice.
20242
d77de738 20243@opindex fpack-struct
ddf6fe37 20244@item -fpack-struct[=@var{n}]
d77de738
ML
20245Without a value specified, pack all structure members together without
20246holes. When a value is specified (which must be a small power of two), pack
20247structure members according to this value, representing the maximum
20248alignment (that is, objects with default alignment requirements larger than
20249this are output potentially unaligned at the next fitting location.
20250
20251@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
20252code that is not binary compatible with code generated without that switch.
20253Additionally, it makes the code suboptimal.
20254Use it to conform to a non-default application binary interface.
20255
d77de738 20256@opindex fleading-underscore
ddf6fe37 20257@item -fleading-underscore
d77de738
ML
20258This option and its counterpart, @option{-fno-leading-underscore}, forcibly
20259change the way C symbols are represented in the object file. One use
20260is to help link with legacy assembly code.
20261
20262@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
20263generate code that is not binary compatible with code generated without that
20264switch. Use it to conform to a non-default application binary interface.
20265Not all targets provide complete support for this switch.
20266
d77de738 20267@opindex ftls-model
ddf6fe37 20268@item -ftls-model=@var{model}
d77de738
ML
20269Alter the thread-local storage model to be used (@pxref{Thread-Local}).
20270The @var{model} argument should be one of @samp{global-dynamic},
20271@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
20272Note that the choice is subject to optimization: the compiler may use
20273a more efficient model for symbols not visible outside of the translation
20274unit, or if @option{-fpic} is not given on the command line.
20275
20276The default without @option{-fpic} is @samp{initial-exec}; with
20277@option{-fpic} the default is @samp{global-dynamic}.
20278
d77de738 20279@opindex ftrampolines
ddf6fe37 20280@item -ftrampolines
d77de738
ML
20281For targets that normally need trampolines for nested functions, always
20282generate them instead of using descriptors. Otherwise, for targets that
20283do not need them, like for example HP-PA or IA-64, do nothing.
20284
20285A trampoline is a small piece of code that is created at run time on the
20286stack when the address of a nested function is taken, and is used to call
20287the nested function indirectly. Therefore, it requires the stack to be
20288made executable in order for the program to work properly.
20289
20290@option{-fno-trampolines} is enabled by default on a language by language
20291basis to let the compiler avoid generating them, if it computes that this
20292is safe, and replace them with descriptors. Descriptors are made up of data
20293only, but the generated code must be prepared to deal with them. As of this
20294writing, @option{-fno-trampolines} is enabled by default only for Ada.
20295
20296Moreover, code compiled with @option{-ftrampolines} and code compiled with
20297@option{-fno-trampolines} are not binary compatible if nested functions are
20298present. This option must therefore be used on a program-wide basis and be
20299manipulated with extreme care.
20300
20301For languages other than Ada, the @code{-ftrampolines} and
20302@code{-fno-trampolines} options currently have no effect, and
20303trampolines are always generated on platforms that need them
20304for nested functions.
20305
28d8c680
AB
20306@opindex ftrampoline-impl
20307@item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
20308By default, trampolines are generated on stack. However, certain platforms
20309(such as the Apple M1) do not permit an executable stack. Compiling with
20310@option{-ftrampoline-impl=heap} generate calls to
837827f8
IS
20311@code{__gcc_nested_func_ptr_created} and
20312@code{__gcc_nested_func_ptr_deleted} in order to allocate and
28d8c680
AB
20313deallocate trampoline space on the executable heap. These functions are
20314implemented in libgcc, and will only be provided on specific targets:
20315x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
20316trampolines are @emph{not} guaranteed to be correctly deallocated if you
20317@code{setjmp}, instantiate nested functions, and then @code{longjmp} back
20318to a state prior to having allocated those nested functions.
20319
d77de738 20320@opindex fvisibility
ddf6fe37 20321@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
20322Set the default ELF image symbol visibility to the specified option---all
20323symbols are marked with this unless overridden within the code.
20324Using this feature can very substantially improve linking and
20325load times of shared object libraries, produce more optimized
20326code, provide near-perfect API export and prevent symbol clashes.
20327It is @strong{strongly} recommended that you use this in any shared objects
20328you distribute.
20329
20330Despite the nomenclature, @samp{default} always means public; i.e.,
20331available to be linked against from outside the shared object.
20332@samp{protected} and @samp{internal} are pretty useless in real-world
20333usage so the only other commonly used option is @samp{hidden}.
20334The default if @option{-fvisibility} isn't specified is
20335@samp{default}, i.e., make every symbol public.
20336
20337A good explanation of the benefits offered by ensuring ELF
20338symbols have the correct visibility is given by ``How To Write
20339Shared Libraries'' by Ulrich Drepper (which can be found at
20340@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
20341solution made possible by this option to marking things hidden when
20342the default is public is to make the default hidden and mark things
20343public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
20344and @code{__attribute__ ((visibility("default")))} instead of
20345@code{__declspec(dllexport)} you get almost identical semantics with
20346identical syntax. This is a great boon to those working with
20347cross-platform projects.
20348
20349For those adding visibility support to existing code, you may find
20350@code{#pragma GCC visibility} of use. This works by you enclosing
20351the declarations you wish to set visibility for with (for example)
20352@code{#pragma GCC visibility push(hidden)} and
20353@code{#pragma GCC visibility pop}.
20354Bear in mind that symbol visibility should be viewed @strong{as
20355part of the API interface contract} and thus all new code should
20356always specify visibility when it is not the default; i.e., declarations
20357only for use within the local DSO should @strong{always} be marked explicitly
20358as hidden as so to avoid PLT indirection overheads---making this
20359abundantly clear also aids readability and self-documentation of the code.
20360Note that due to ISO C++ specification requirements, @code{operator new} and
20361@code{operator delete} must always be of default visibility.
20362
20363Be aware that headers from outside your project, in particular system
20364headers and headers from any other library you use, may not be
20365expecting to be compiled with visibility other than the default. You
20366may need to explicitly say @code{#pragma GCC visibility push(default)}
20367before including any such headers.
20368
20369@code{extern} declarations are not affected by @option{-fvisibility}, so
20370a lot of code can be recompiled with @option{-fvisibility=hidden} with
20371no modifications. However, this means that calls to @code{extern}
20372functions with no explicit visibility use the PLT, so it is more
20373effective to use @code{__attribute ((visibility))} and/or
20374@code{#pragma GCC visibility} to tell the compiler which @code{extern}
20375declarations should be treated as hidden.
20376
20377Note that @option{-fvisibility} does affect C++ vague linkage
20378entities. This means that, for instance, an exception class that is
20379be thrown between DSOs must be explicitly marked with default
20380visibility so that the @samp{type_info} nodes are unified between
20381the DSOs.
20382
20383An overview of these techniques, their benefits and how to use them
20384is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
20385
d77de738 20386@opindex fstrict-volatile-bitfields
ddf6fe37 20387@item -fstrict-volatile-bitfields
d77de738
ML
20388This option should be used if accesses to volatile bit-fields (or other
20389structure fields, although the compiler usually honors those types
20390anyway) should use a single access of the width of the
20391field's type, aligned to a natural alignment if possible. For
20392example, targets with memory-mapped peripheral registers might require
20393all such accesses to be 16 bits wide; with this flag you can
20394declare all peripheral bit-fields as @code{unsigned short} (assuming short
20395is 16 bits on these targets) to force GCC to use 16-bit accesses
20396instead of, perhaps, a more efficient 32-bit access.
20397
20398If this option is disabled, the compiler uses the most efficient
20399instruction. In the previous example, that might be a 32-bit load
20400instruction, even though that accesses bytes that do not contain
20401any portion of the bit-field, or memory-mapped registers unrelated to
20402the one being updated.
20403
a0e64a04 20404In some cases, such as when the @code{packed} attribute is applied to a
d77de738
ML
20405structure field, it may not be possible to access the field with a single
20406read or write that is correctly aligned for the target machine. In this
a0e64a04 20407case GCC falls back to generating multiple accesses rather than code that
d77de738
ML
20408will fault or truncate the result at run time.
20409
20410Note: Due to restrictions of the C/C++11 memory model, write accesses are
20411not allowed to touch non bit-field members. It is therefore recommended
20412to define all bits of the field's type as bit-field members.
20413
20414The default value of this option is determined by the application binary
20415interface for the target processor.
20416
d77de738 20417@opindex fsync-libcalls
ddf6fe37 20418@item -fsync-libcalls
d77de738
ML
20419This option controls whether any out-of-line instance of the @code{__sync}
20420family of functions may be used to implement the C++11 @code{__atomic}
20421family of functions.
20422
20423The default value of this option is enabled, thus the only useful form
20424of the option is @option{-fno-sync-libcalls}. This option is used in
20425the implementation of the @file{libatomic} runtime library.
20426
0547dbb7
JJ
20427@opindex fzero-init-padding-bits=@var{value}
20428@item -fzero-init-padding-bits=@var{value}
b9857b78 20429Guarantee zero initialization of padding bits in automatic variable
0547dbb7
JJ
20430initializers.
20431Certain languages guarantee zero initialization of padding bits in
20432certain cases, e.g. C23 when using empty initializers (@code{@{@}}),
20433or C++ when using zero-initialization or C guarantees that fields
20434not specified in an initializer have their padding bits zero initialized.
20435This option allows to change when padding bits in initializers are
20436guaranteed to be zero initialized.
20437The default is @code{-fzero-init-padding-bits=standard}, which makes
20438no further guarantees than the corresponding standard. E.g.@:
20439
20440@smallexample
20441 struct A @{ char a; unsigned long long b; char c; @};
20442 union B @{ char a; unsigned long long b; @};
20443 struct A a = @{@}; // C23 guarantees padding bits are zero.
20444 struct A b = @{ 1, 2, 3 @}; // No guarantees.
20445 union B c = @{@}; // C23 guarantees padding bits are zero.
20446 union B d = @{ 1 @}; // No guarantees.
20447@end smallexample
20448
20449@code{-fzero-init-padding-bits=unions} guarantees zero initialization
20450of padding bits in unions on top of what the standards guarantee,
20451if the initializer of an union is empty (then all bits of the union
20452are zero initialized) or if the initialized member of the union is
20453smaller than the size of the union (in that case guarantees padding
20454bits outside of the initialized member to be zero initialized).
20455This was the GCC behavior before GCC 15 and in the above example guarantees
20456zero initialization of last @code{sizeof (unsigned long long) - 1}
20457bytes in the union.
20458
20459@code{-fzero-init-padding-bits=all} guarantees additionally
20460zero initialization of padding bits of other aggregates, so
20461the padding in between @code{b.a} and @code{b.b} (if any) and
20462tail padding in the structure (if any).
20463
d77de738
ML
20464@end table
20465
20466@node Developer Options
20467@section GCC Developer Options
20468@cindex developer options
20469@cindex debugging GCC
20470@cindex debug dump options
20471@cindex dump options
20472@cindex compilation statistics
20473
20474This section describes command-line options that are primarily of
20475interest to GCC developers, including options to support compiler
20476testing and investigation of compiler bugs and compile-time
20477performance problems. This includes options that produce debug dumps
20478at various points in the compilation; that print statistics such as
20479memory use and execution time; and that print information about GCC's
20480configuration, such as where it searches for libraries. You should
20481rarely need to use any of these options for ordinary compilation and
20482linking tasks.
20483
20484Many developer options that cause GCC to dump output to a file take an
20485optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
20486or @samp{-} to dump to standard output, and @samp{stderr} for standard
20487error.
20488
20489If @samp{=@var{filename}} is omitted, a default dump file name is
20490constructed by concatenating the base dump file name, a pass number,
20491phase letter, and pass name. The base dump file name is the name of
20492output file produced by the compiler if explicitly specified and not
20493an executable; otherwise it is the source file name.
20494The pass number is determined by the order passes are registered with
a0e64a04 20495the compiler's pass manager.
d77de738
ML
20496This is generally the same as the order of execution, but passes
20497registered by plugins, target-specific passes, or passes that are
20498otherwise registered late are numbered higher than the pass named
20499@samp{final}, even if they are executed earlier. The phase letter is
20500one of @samp{i} (inter-procedural analysis), @samp{l}
a0e64a04
PN
20501(language-specific), @samp{r} (RTL), or @samp{t} (tree).
20502The files are created in the directory of the output file.
d77de738
ML
20503
20504@table @gcctabopt
20505
ddf6fe37 20506@opindex fcallgraph-info
d77de738
ML
20507@item -fcallgraph-info
20508@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
20509Makes the compiler output callgraph information for the program, on a
20510per-object-file basis. The information is generated in the common VCG
20511format. It can be decorated with additional, per-node and/or per-edge
20512information, if a list of comma-separated markers is additionally
20513specified. When the @code{su} marker is specified, the callgraph is
20514decorated with stack usage information; it is equivalent to
20515@option{-fstack-usage}. When the @code{da} marker is specified, the
20516callgraph is decorated with information about dynamically allocated
20517objects.
20518
20519When compiling with @option{-flto}, no callgraph information is output
20520along with the object file. At LTO link time, @option{-fcallgraph-info}
20521may generate multiple callgraph information files next to intermediate
20522LTO output files.
20523
ddf6fe37
AA
20524@opindex d
20525@opindex fdump-rtl-@var{pass}
d77de738
ML
20526@item -d@var{letters}
20527@itemx -fdump-rtl-@var{pass}
20528@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
20529Says to make debugging dumps during compilation at times specified by
20530@var{letters}. This is used for debugging the RTL-based passes of the
20531compiler.
20532
20533Some @option{-d@var{letters}} switches have different meaning when
20534@option{-E} is used for preprocessing. @xref{Preprocessor Options},
20535for information about preprocessor-specific dump options.
20536
20537Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
20538@option{-d} option @var{letters}. Here are the possible
20539letters for use in @var{pass} and @var{letters}, and their meanings:
20540
20541@table @gcctabopt
20542
d77de738 20543@opindex fdump-rtl-alignments
ddf6fe37 20544@item -fdump-rtl-alignments
d77de738
ML
20545Dump after branch alignments have been computed.
20546
d77de738 20547@opindex fdump-rtl-asmcons
ddf6fe37 20548@item -fdump-rtl-asmcons
d77de738
ML
20549Dump after fixing rtl statements that have unsatisfied in/out constraints.
20550
d77de738 20551@opindex fdump-rtl-auto_inc_dec
ddf6fe37 20552@item -fdump-rtl-auto_inc_dec
d77de738
ML
20553Dump after auto-inc-dec discovery. This pass is only run on
20554architectures that have auto inc or auto dec instructions.
20555
d77de738 20556@opindex fdump-rtl-barriers
ddf6fe37 20557@item -fdump-rtl-barriers
d77de738
ML
20558Dump after cleaning up the barrier instructions.
20559
d77de738 20560@opindex fdump-rtl-bbpart
ddf6fe37 20561@item -fdump-rtl-bbpart
d77de738
ML
20562Dump after partitioning hot and cold basic blocks.
20563
d77de738 20564@opindex fdump-rtl-bbro
ddf6fe37 20565@item -fdump-rtl-bbro
d77de738
ML
20566Dump after block reordering.
20567
d77de738
ML
20568@opindex fdump-rtl-btl2
20569@opindex fdump-rtl-btl2
ddf6fe37
AA
20570@item -fdump-rtl-btl1
20571@itemx -fdump-rtl-btl2
d77de738
ML
20572@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
20573after the two branch
20574target load optimization passes.
20575
d77de738 20576@opindex fdump-rtl-bypass
ddf6fe37 20577@item -fdump-rtl-bypass
d77de738
ML
20578Dump after jump bypassing and control flow optimizations.
20579
d77de738 20580@opindex fdump-rtl-combine
ddf6fe37 20581@item -fdump-rtl-combine
d77de738
ML
20582Dump after the RTL instruction combination pass.
20583
d77de738 20584@opindex fdump-rtl-compgotos
ddf6fe37 20585@item -fdump-rtl-compgotos
d77de738
ML
20586Dump after duplicating the computed gotos.
20587
d77de738
ML
20588@opindex fdump-rtl-ce1
20589@opindex fdump-rtl-ce2
20590@opindex fdump-rtl-ce3
ddf6fe37
AA
20591@item -fdump-rtl-ce1
20592@itemx -fdump-rtl-ce2
20593@itemx -fdump-rtl-ce3
d77de738
ML
20594@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
20595@option{-fdump-rtl-ce3} enable dumping after the three
20596if conversion passes.
20597
d77de738 20598@opindex fdump-rtl-cprop_hardreg
ddf6fe37 20599@item -fdump-rtl-cprop_hardreg
d77de738
ML
20600Dump after hard register copy propagation.
20601
d77de738 20602@opindex fdump-rtl-csa
ddf6fe37 20603@item -fdump-rtl-csa
d77de738
ML
20604Dump after combining stack adjustments.
20605
d77de738
ML
20606@opindex fdump-rtl-cse1
20607@opindex fdump-rtl-cse2
ddf6fe37
AA
20608@item -fdump-rtl-cse1
20609@itemx -fdump-rtl-cse2
d77de738
ML
20610@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
20611the two common subexpression elimination passes.
20612
d77de738 20613@opindex fdump-rtl-dce
ddf6fe37 20614@item -fdump-rtl-dce
d77de738
ML
20615Dump after the standalone dead code elimination passes.
20616
d77de738 20617@opindex fdump-rtl-dbr
ddf6fe37 20618@item -fdump-rtl-dbr
d77de738
ML
20619Dump after delayed branch scheduling.
20620
d77de738
ML
20621@opindex fdump-rtl-dce1
20622@opindex fdump-rtl-dce2
ddf6fe37
AA
20623@item -fdump-rtl-dce1
20624@itemx -fdump-rtl-dce2
d77de738
ML
20625@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
20626the two dead store elimination passes.
20627
d77de738 20628@opindex fdump-rtl-eh
ddf6fe37 20629@item -fdump-rtl-eh
d77de738
ML
20630Dump after finalization of EH handling code.
20631
d77de738 20632@opindex fdump-rtl-eh_ranges
ddf6fe37 20633@item -fdump-rtl-eh_ranges
d77de738
ML
20634Dump after conversion of EH handling range regions.
20635
d77de738 20636@opindex fdump-rtl-expand
ddf6fe37 20637@item -fdump-rtl-expand
d77de738
ML
20638Dump after RTL generation.
20639
d77de738
ML
20640@opindex fdump-rtl-fwprop1
20641@opindex fdump-rtl-fwprop2
ddf6fe37
AA
20642@item -fdump-rtl-fwprop1
20643@itemx -fdump-rtl-fwprop2
d77de738
ML
20644@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
20645dumping after the two forward propagation passes.
20646
d77de738
ML
20647@opindex fdump-rtl-gcse1
20648@opindex fdump-rtl-gcse2
ddf6fe37
AA
20649@item -fdump-rtl-gcse1
20650@itemx -fdump-rtl-gcse2
d77de738
ML
20651@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
20652after global common subexpression elimination.
20653
d77de738 20654@opindex fdump-rtl-init-regs
ddf6fe37 20655@item -fdump-rtl-init-regs
d77de738
ML
20656Dump after the initialization of the registers.
20657
d77de738 20658@opindex fdump-rtl-initvals
ddf6fe37 20659@item -fdump-rtl-initvals
d77de738
ML
20660Dump after the computation of the initial value sets.
20661
d77de738 20662@opindex fdump-rtl-into_cfglayout
ddf6fe37 20663@item -fdump-rtl-into_cfglayout
d77de738
ML
20664Dump after converting to cfglayout mode.
20665
d77de738 20666@opindex fdump-rtl-ira
ddf6fe37 20667@item -fdump-rtl-ira
d77de738
ML
20668Dump after iterated register allocation.
20669
d77de738 20670@opindex fdump-rtl-jump
ddf6fe37 20671@item -fdump-rtl-jump
d77de738
ML
20672Dump after the second jump optimization.
20673
d77de738 20674@opindex fdump-rtl-loop2
ddf6fe37 20675@item -fdump-rtl-loop2
d77de738
ML
20676@option{-fdump-rtl-loop2} enables dumping after the rtl
20677loop optimization passes.
20678
d77de738 20679@opindex fdump-rtl-mach
ddf6fe37 20680@item -fdump-rtl-mach
d77de738
ML
20681Dump after performing the machine dependent reorganization pass, if that
20682pass exists.
20683
d77de738 20684@opindex fdump-rtl-mode_sw
ddf6fe37 20685@item -fdump-rtl-mode_sw
d77de738
ML
20686Dump after removing redundant mode switches.
20687
d77de738 20688@opindex fdump-rtl-rnreg
ddf6fe37 20689@item -fdump-rtl-rnreg
d77de738
ML
20690Dump after register renumbering.
20691
d77de738 20692@opindex fdump-rtl-outof_cfglayout
ddf6fe37 20693@item -fdump-rtl-outof_cfglayout
d77de738
ML
20694Dump after converting from cfglayout mode.
20695
d77de738 20696@opindex fdump-rtl-peephole2
ddf6fe37 20697@item -fdump-rtl-peephole2
d77de738
ML
20698Dump after the peephole pass.
20699
d77de738 20700@opindex fdump-rtl-postreload
ddf6fe37 20701@item -fdump-rtl-postreload
d77de738
ML
20702Dump after post-reload optimizations.
20703
d77de738 20704@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 20705@item -fdump-rtl-pro_and_epilogue
d77de738
ML
20706Dump after generating the function prologues and epilogues.
20707
d77de738
ML
20708@opindex fdump-rtl-sched1
20709@opindex fdump-rtl-sched2
ddf6fe37
AA
20710@item -fdump-rtl-sched1
20711@itemx -fdump-rtl-sched2
d77de738
ML
20712@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
20713after the basic block scheduling passes.
20714
d77de738 20715@opindex fdump-rtl-ree
ddf6fe37 20716@item -fdump-rtl-ree
d77de738
ML
20717Dump after sign/zero extension elimination.
20718
d77de738 20719@opindex fdump-rtl-seqabstr
ddf6fe37 20720@item -fdump-rtl-seqabstr
d77de738
ML
20721Dump after common sequence discovery.
20722
d77de738 20723@opindex fdump-rtl-shorten
ddf6fe37 20724@item -fdump-rtl-shorten
d77de738
ML
20725Dump after shortening branches.
20726
d77de738
ML
20727@opindex fdump-rtl-split1
20728@opindex fdump-rtl-split2
20729@opindex fdump-rtl-split3
20730@opindex fdump-rtl-split4
20731@opindex fdump-rtl-split5
ddf6fe37
AA
20732@item -fdump-rtl-split1
20733@itemx -fdump-rtl-split2
20734@itemx -fdump-rtl-split3
20735@itemx -fdump-rtl-split4
20736@itemx -fdump-rtl-split5
d77de738
ML
20737These options enable dumping after five rounds of
20738instruction splitting.
20739
d77de738 20740@opindex fdump-rtl-sms
ddf6fe37 20741@item -fdump-rtl-sms
d77de738
ML
20742Dump after modulo scheduling. This pass is only run on some
20743architectures.
20744
d77de738 20745@opindex fdump-rtl-stack
ddf6fe37 20746@item -fdump-rtl-stack
d77de738
ML
20747Dump after conversion from GCC's ``flat register file'' registers to the
20748x87's stack-like registers. This pass is only run on x86 variants.
20749
d77de738
ML
20750@opindex fdump-rtl-subreg1
20751@opindex fdump-rtl-subreg2
ddf6fe37
AA
20752@item -fdump-rtl-subreg1
20753@itemx -fdump-rtl-subreg2
d77de738
ML
20754@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
20755the two subreg expansion passes.
20756
d77de738 20757@opindex fdump-rtl-vartrack
ddf6fe37 20758@item -fdump-rtl-vartrack
d77de738
ML
20759Dump after variable tracking.
20760
d77de738 20761@opindex fdump-rtl-vregs
ddf6fe37 20762@item -fdump-rtl-vregs
d77de738
ML
20763Dump after converting virtual registers to hard registers.
20764
d77de738 20765@opindex fdump-rtl-web
ddf6fe37 20766@item -fdump-rtl-web
d77de738
ML
20767Dump after live range splitting.
20768
d77de738
ML
20769@opindex fdump-rtl-regclass
20770@opindex fdump-rtl-subregs_of_mode_init
20771@opindex fdump-rtl-subregs_of_mode_finish
20772@opindex fdump-rtl-dfinit
20773@opindex fdump-rtl-dfinish
ddf6fe37
AA
20774@item -fdump-rtl-regclass
20775@itemx -fdump-rtl-subregs_of_mode_init
20776@itemx -fdump-rtl-subregs_of_mode_finish
20777@itemx -fdump-rtl-dfinit
20778@itemx -fdump-rtl-dfinish
d77de738
ML
20779These dumps are defined but always produce empty files.
20780
d77de738
ML
20781@opindex da
20782@opindex fdump-rtl-all
ddf6fe37
AA
20783@item -da
20784@itemx -fdump-rtl-all
d77de738
ML
20785Produce all the dumps listed above.
20786
d77de738 20787@opindex dA
ddf6fe37 20788@item -dA
d77de738
ML
20789Annotate the assembler output with miscellaneous debugging information.
20790
d77de738 20791@opindex dD
ddf6fe37 20792@item -dD
d77de738
ML
20793Dump all macro definitions, at the end of preprocessing, in addition to
20794normal output.
20795
d77de738 20796@opindex dH
ddf6fe37 20797@item -dH
d77de738
ML
20798Produce a core dump whenever an error occurs.
20799
d77de738 20800@opindex dp
ddf6fe37 20801@item -dp
d77de738
ML
20802Annotate the assembler output with a comment indicating which
20803pattern and alternative is used. The length and cost of each instruction are
20804also printed.
20805
d77de738 20806@opindex dP
ddf6fe37 20807@item -dP
d77de738
ML
20808Dump the RTL in the assembler output as a comment before each instruction.
20809Also turns on @option{-dp} annotation.
20810
d77de738 20811@opindex dx
ddf6fe37 20812@item -dx
d77de738
ML
20813Just generate RTL for a function instead of compiling it. Usually used
20814with @option{-fdump-rtl-expand}.
20815@end table
20816
d77de738 20817@opindex fdump-debug
ddf6fe37 20818@item -fdump-debug
d77de738
ML
20819Dump debugging information generated during the debug
20820generation phase.
20821
d77de738 20822@opindex fdump-earlydebug
ddf6fe37 20823@item -fdump-earlydebug
d77de738
ML
20824Dump debugging information generated during the early debug
20825generation phase.
20826
d77de738 20827@opindex fdump-noaddr
ddf6fe37 20828@item -fdump-noaddr
d77de738
ML
20829When doing debugging dumps, suppress address output. This makes it more
20830feasible to use diff on debugging dumps for compiler invocations with
20831different compiler binaries and/or different
20832text / bss / data / heap / stack / dso start locations.
20833
d77de738 20834@opindex freport-bug
ddf6fe37 20835@item -freport-bug
d77de738
ML
20836Collect and dump debug information into a temporary file if an
20837internal compiler error (ICE) occurs.
20838
d77de738 20839@opindex fdump-unnumbered
ddf6fe37 20840@item -fdump-unnumbered
d77de738
ML
20841When doing debugging dumps, suppress instruction numbers and address output.
20842This makes it more feasible to use diff on debugging dumps for compiler
20843invocations with different options, in particular with and without
20844@option{-g}.
20845
d77de738 20846@opindex fdump-unnumbered-links
ddf6fe37 20847@item -fdump-unnumbered-links
d77de738
ML
20848When doing debugging dumps (see @option{-d} option above), suppress
20849instruction numbers for the links to the previous and next instructions
20850in a sequence.
20851
ddf6fe37 20852@opindex fdump-ipa
d77de738
ML
20853@item -fdump-ipa-@var{switch}
20854@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
20855Control the dumping at various stages of inter-procedural analysis
20856language tree to a file. The file name is generated by appending a
20857switch specific suffix to the source file name, and the file is created
20858in the same directory as the output file. The following dumps are
20859possible:
20860
20861@table @samp
20862@item all
20863Enables all inter-procedural analysis dumps.
20864
20865@item cgraph
20866Dumps information about call-graph optimization, unused function removal,
20867and inlining decisions.
20868
20869@item inline
20870Dump after function inlining.
20871
f0a90c7d
AO
20872@item strubm
20873Dump after selecting @code{strub} modes, and recording the selections as
20874function attributes.
20875
20876@item strub
20877Dump @code{strub} transformations: interface changes, function wrapping,
20878and insertion of builtin calls for stack scrubbing and watermarking.
20879
d77de738
ML
20880@end table
20881
20882Additionally, the options @option{-optimized}, @option{-missed},
20883@option{-note}, and @option{-all} can be provided, with the same meaning
20884as for @option{-fopt-info}, defaulting to @option{-optimized}.
20885
20886For example, @option{-fdump-ipa-inline-optimized-missed} will emit
20887information on callsites that were inlined, along with callsites
20888that were not inlined.
20889
20890By default, the dump will contain messages about successful
20891optimizations (equivalent to @option{-optimized}) together with
20892low-level details about the analysis.
20893
6ecc2fee
MJ
20894@opindex fdump-ipa-clones
20895@item -fdump-ipa-clones
20896
20897Create a dump file containing information about creation of call graph
20898node clones and removals of call graph nodes during inter-procedural
20899optimizations and transformations. Its main intended use is that tools
20900that create live-patches can determine the set of functions that need to
20901be live-patched to completely replace a particular function (see
20902@option{-flive-patching}). The file name is generated by appending
20903suffix @code{ipa-clones} to the source file name, and the file is
20904created in the same directory as the output file. Each entry in the
20905file is on a separate line containing semicolon separated fields.
20906
20907In the case of call graph clone creation, the individual fields are:
20908
20909@enumerate
20910@item
20911String @code{Callgraph clone}.
20912
20913@item
20914Name of the function being cloned as it is presented to the assembler.
20915
20916@item
20917A number that uniquely represents the function being cloned in the call
20918graph. Note that the number is unique only within a compilation unit or
20919within whole-program analysis but is likely to be different in the two
20920phases.
20921
20922@item
20923The file name of the source file where the function is defined.
20924
20925@item
20926The line on which the function definition is located.
20927
20928@item
20929The column where the function definition is located.
20930
20931@item
20932Name of the new function clone as it is presented to the assembler.
20933
20934@item
20935A number that uniquely represents the new function clone in the call
20936graph. Note that the number is unique only within a compilation unit or
20937within whole-program analysis but is likely to be different in the two
20938phases.
20939
20940@item
20941The file name of the source file where the source code location of the
20942new clone points to.
20943
20944@item
20945The line to which the source code location of the new clone points to.
20946
20947@item
20948The column to which the source code location of the new clone points to.
20949
20950@item
20951A string that determines the reason for cloning.
20952
20953@end enumerate
20954
20955In the case of call graph clone removal, the individual fields are:
20956
20957@enumerate
20958@item
20959String @code{Callgraph removal}.
20960
20961@item
20962Name of the function being removed as it would be presented to the assembler.
20963
20964@item
20965A number that uniquely represents the function being cloned in the call
20966graph. Note that the number is unique only within a compilation unit or
20967within whole-program analysis but is likely to be different in the two
20968phases.
20969
20970@item
20971The file name of the source file where the function is defined.
20972
20973@item
20974The line on which the function definition is located.
20975
20976@item
20977The column where the function definition is located.
20978
20979@end enumerate
20980
d77de738 20981@opindex fdump-lang
ddf6fe37 20982@item -fdump-lang
d77de738
ML
20983Dump language-specific information. The file name is made by appending
20984@file{.lang} to the source file name.
20985
ddf6fe37
AA
20986@opindex fdump-lang-all
20987@opindex fdump-lang
d77de738
ML
20988@item -fdump-lang-all
20989@itemx -fdump-lang-@var{switch}
20990@itemx -fdump-lang-@var{switch}-@var{options}
20991@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
20992Control the dumping of language-specific information. The @var{options}
20993and @var{filename} portions behave as described in the
f59ff19b
JM
20994@option{-fdump-tree} option. @option{-fdump-tree-all} enables all
20995language-specific dumps; other options vary with the language. For
20996instance, see @xref{C++ Dialect Options} for the @option{-fdump-lang}
20997flags supported by the C++ front-end.
d77de738 20998
d77de738 20999@opindex fdump-passes
ddf6fe37 21000@item -fdump-passes
d77de738
ML
21001Print on @file{stderr} the list of optimization passes that are turned
21002on and off by the current command-line options.
21003
d77de738 21004@opindex fdump-statistics
ddf6fe37 21005@item -fdump-statistics-@var{option}
d77de738
ML
21006Enable and control dumping of pass statistics in a separate file. The
21007file name is generated by appending a suffix ending in
21008@samp{.statistics} to the source file name, and the file is created in
21009the same directory as the output file. If the @samp{-@var{option}}
21010form is used, @samp{-stats} causes counters to be summed over the
21011whole compilation unit while @samp{-details} dumps every event as
21012the passes generate them. The default with no option is to sum
21013counters for each function compiled.
21014
ddf6fe37
AA
21015@opindex fdump-tree-all
21016@opindex fdump-tree
d77de738
ML
21017@item -fdump-tree-all
21018@itemx -fdump-tree-@var{switch}
21019@itemx -fdump-tree-@var{switch}-@var{options}
21020@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
21021Control the dumping at various stages of processing the intermediate
21022language tree to a file. If the @samp{-@var{options}}
21023form is used, @var{options} is a list of @samp{-} separated options
21024which control the details of the dump. Not all options are applicable
21025to all dumps; those that are not meaningful are ignored. The
21026following options are available
21027
21028@table @samp
21029@item address
21030Print the address of each node. Usually this is not meaningful as it
21031changes according to the environment and source file. Its primary use
21032is for tying up a dump file with a debug environment.
21033@item asmname
21034If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
21035in the dump instead of @code{DECL_NAME}. Its primary use is ease of
21036use working backward from mangled names in the assembly file.
21037@item slim
21038When dumping front-end intermediate representations, inhibit dumping
21039of members of a scope or body of a function merely because that scope
21040has been reached. Only dump such items when they are directly reachable
21041by some other path.
21042
21043When dumping pretty-printed trees, this option inhibits dumping the
21044bodies of control structures.
21045
21046When dumping RTL, print the RTL in slim (condensed) form instead of
21047the default LISP-like representation.
21048@item raw
21049Print a raw representation of the tree. By default, trees are
21050pretty-printed into a C-like representation.
21051@item details
21052Enable more detailed dumps (not honored by every dump option). Also
21053include information from the optimization passes.
21054@item stats
21055Enable dumping various statistics about the pass (not honored by every dump
21056option).
21057@item blocks
21058Enable showing basic block boundaries (disabled in raw dumps).
21059@item graph
21060For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
21061dump a representation of the control flow graph suitable for viewing with
21062GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
21063the file is pretty-printed as a subgraph, so that GraphViz can render them
21064all in a single plot.
21065
21066This option currently only works for RTL dumps, and the RTL is always
21067dumped in slim form.
21068@item vops
21069Enable showing virtual operands for every statement.
21070@item lineno
21071Enable showing line numbers for statements.
21072@item uid
21073Enable showing the unique ID (@code{DECL_UID}) for each variable.
21074@item verbose
21075Enable showing the tree dump for each statement.
21076@item eh
21077Enable showing the EH region number holding each statement.
21078@item scev
21079Enable showing scalar evolution analysis details.
21080@item optimized
21081Enable showing optimization information (only available in certain
21082passes).
21083@item missed
21084Enable showing missed optimization information (only available in certain
21085passes).
21086@item note
21087Enable other detailed optimization information (only available in
21088certain passes).
21089@item all
21090Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
21091and @option{lineno}.
21092@item optall
21093Turn on all optimization options, i.e., @option{optimized},
21094@option{missed}, and @option{note}.
21095@end table
21096
21097To determine what tree dumps are available or find the dump for a pass
21098of interest follow the steps below.
21099
21100@enumerate
21101@item
21102Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
21103look for a code that corresponds to the pass you are interested in.
21104For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
21105@code{tree-vrp2} correspond to the three Value Range Propagation passes.
21106The number at the end distinguishes distinct invocations of the same pass.
21107@item
21108To enable the creation of the dump file, append the pass code to
21109the @option{-fdump-} option prefix and invoke GCC with it. For example,
21110to enable the dump from the Early Value Range Propagation pass, invoke
21111GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
21112specify the name of the dump file. If you don't specify one, GCC
21113creates as described below.
21114@item
21115Find the pass dump in a file whose name is composed of three components
21116separated by a period: the name of the source file GCC was invoked to
21117compile, a numeric suffix indicating the pass number followed by the
21118letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
21119and finally the pass code. For example, the Early VRP pass dump might
21120be in a file named @file{myfile.c.038t.evrp} in the current working
21121directory. Note that the numeric codes are not stable and may change
21122from one version of GCC to another.
21123@end enumerate
21124
ddf6fe37 21125@opindex fopt-info
d77de738
ML
21126@item -fopt-info
21127@itemx -fopt-info-@var{options}
21128@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
21129Controls optimization dumps from various optimization passes. If the
21130@samp{-@var{options}} form is used, @var{options} is a list of
21131@samp{-} separated option keywords to select the dump details and
a0e64a04 21132optimizations.
d77de738
ML
21133
21134The @var{options} can be divided into three groups:
21135@enumerate
21136@item
21137options describing what kinds of messages should be emitted,
21138@item
21139options describing the verbosity of the dump, and
21140@item
21141options describing which optimizations should be included.
21142@end enumerate
21143The options from each group can be freely mixed as they are
21144non-overlapping. However, in case of any conflicts,
21145the later options override the earlier options on the command
a0e64a04 21146line.
d77de738
ML
21147
21148The following options control which kinds of messages should be emitted:
21149
21150@table @samp
21151@item optimized
21152Print information when an optimization is successfully applied. It is
21153up to a pass to decide which information is relevant. For example, the
21154vectorizer passes print the source location of loops which are
21155successfully vectorized.
21156@item missed
21157Print information about missed optimizations. Individual passes
a0e64a04 21158control which information to include in the output.
d77de738
ML
21159@item note
21160Print verbose information about optimizations, such as certain
21161transformations, more detailed messages about decisions etc.
21162@item all
21163Print detailed optimization information. This includes
21164@samp{optimized}, @samp{missed}, and @samp{note}.
21165@end table
21166
21167The following option controls the dump verbosity:
21168
21169@table @samp
21170@item internals
21171By default, only ``high-level'' messages are emitted. This option enables
21172additional, more detailed, messages, which are likely to only be of interest
21173to GCC developers.
21174@end table
21175
21176One or more of the following option keywords can be used to describe a
21177group of optimizations:
21178
21179@table @samp
21180@item ipa
21181Enable dumps from all interprocedural optimizations.
21182@item loop
21183Enable dumps from all loop optimizations.
21184@item inline
21185Enable dumps from all inlining optimizations.
21186@item omp
21187Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
21188@item vec
21189Enable dumps from all vectorization optimizations.
21190@item optall
21191Enable dumps from all optimizations. This is a superset of
21192the optimization groups listed above.
21193@end table
21194
21195If @var{options} is
21196omitted, it defaults to @samp{optimized-optall}, which means to dump messages
21197about successful optimizations from all the passes, omitting messages
21198that are treated as ``internals''.
21199
21200If the @var{filename} is provided, then the dumps from all the
21201applicable optimizations are concatenated into the @var{filename}.
21202Otherwise the dump is output onto @file{stderr}. Though multiple
21203@option{-fopt-info} options are accepted, only one of them can include
21204a @var{filename}. If other filenames are provided then all but the
21205first such option are ignored.
21206
21207Note that the output @var{filename} is overwritten
21208in case of multiple translation units. If a combined output from
21209multiple translation units is desired, @file{stderr} should be used
21210instead.
21211
21212In the following example, the optimization info is output to
21213@file{stderr}:
21214
21215@smallexample
21216gcc -O3 -fopt-info
21217@end smallexample
21218
21219This example:
21220@smallexample
21221gcc -O3 -fopt-info-missed=missed.all
21222@end smallexample
21223
21224@noindent
21225outputs missed optimization report from all the passes into
21226@file{missed.all}, and this one:
21227
21228@smallexample
21229gcc -O2 -ftree-vectorize -fopt-info-vec-missed
21230@end smallexample
21231
21232@noindent
21233prints information about missed optimization opportunities from
a0e64a04
PN
21234vectorization passes on @file{stderr}.
21235Note that @option{-fopt-info-vec-missed} is equivalent to
d77de738
ML
21236@option{-fopt-info-missed-vec}. The order of the optimization group
21237names and message types listed after @option{-fopt-info} does not matter.
21238
21239As another example,
21240@smallexample
21241gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
21242@end smallexample
21243
21244@noindent
21245outputs information about missed optimizations as well as
21246optimized locations from all the inlining passes into
21247@file{inline.txt}.
21248
21249Finally, consider:
21250
21251@smallexample
21252gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
21253@end smallexample
21254
21255@noindent
21256Here the two output filenames @file{vec.miss} and @file{loop.opt} are
21257in conflict since only one output file is allowed. In this case, only
21258the first option takes effect and the subsequent options are
21259ignored. Thus only @file{vec.miss} is produced which contains
21260dumps from the vectorizer about missed opportunities.
21261
d77de738 21262@opindex fsave-optimization-record
ddf6fe37 21263@item -fsave-optimization-record
d77de738
ML
21264Write a SRCFILE.opt-record.json.gz file detailing what optimizations
21265were performed, for those optimizations that support @option{-fopt-info}.
21266
21267This option is experimental and the format of the data within the
21268compressed JSON file is subject to change.
21269
21270It is roughly equivalent to a machine-readable version of
21271@option{-fopt-info-all}, as a collection of messages with source file,
21272line number and column number, with the following additional data for
21273each message:
21274
21275@itemize @bullet
21276
21277@item
21278the execution count of the code being optimized, along with metadata about
21279whether this was from actual profile data, or just an estimate, allowing
21280consumers to prioritize messages by code hotness,
21281
21282@item
21283the function name of the code being optimized, where applicable,
21284
21285@item
21286the ``inlining chain'' for the code being optimized, so that when
21287a function is inlined into several different places (which might
21288themselves be inlined), the reader can distinguish between the copies,
21289
21290@item
21291objects identifying those parts of the message that refer to expressions,
21292statements or symbol-table nodes, which of these categories they are, and,
21293when available, their source code location,
21294
21295@item
21296the GCC pass that emitted the message, and
21297
21298@item
21299the location in GCC's own code from which the message was emitted
21300
21301@end itemize
21302
21303Additionally, some messages are logically nested within other
21304messages, reflecting implementation details of the optimization
21305passes.
21306
d77de738 21307@opindex fsched-verbose
ddf6fe37 21308@item -fsched-verbose=@var{n}
d77de738
ML
21309On targets that use instruction scheduling, this option controls the
21310amount of debugging output the scheduler prints to the dump files.
21311
21312For @var{n} greater than zero, @option{-fsched-verbose} outputs the
21313same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
21314For @var{n} greater than one, it also output basic block probabilities,
21315detailed ready list information and unit/insn info. For @var{n} greater
21316than two, it includes RTL at abort point, control-flow and regions info.
21317And for @var{n} over four, @option{-fsched-verbose} also includes
21318dependence info.
21319
21320
21321
d77de738
ML
21322@opindex fdisable-
21323@opindex fenable-
ddf6fe37
AA
21324@item -fenable-@var{kind}-@var{pass}
21325@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
21326
21327This is a set of options that are used to explicitly disable/enable
21328optimization passes. These options are intended for use for debugging GCC.
21329Compiler users should use regular options for enabling/disabling
21330passes instead.
21331
21332@table @gcctabopt
21333
21334@item -fdisable-ipa-@var{pass}
21335Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
21336statically invoked in the compiler multiple times, the pass name should be
21337appended with a sequential number starting from 1.
21338
21339@item -fdisable-rtl-@var{pass}
21340@itemx -fdisable-rtl-@var{pass}=@var{range-list}
21341Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
21342statically invoked in the compiler multiple times, the pass name should be
a0e64a04 21343appended with a sequential number starting from 1. @var{range-list} is a
d77de738
ML
21344comma-separated list of function ranges or assembler names. Each range is a number
21345pair separated by a colon. The range is inclusive in both ends. If the range
21346is trivial, the number pair can be simplified as a single number. If the
21347function's call graph node's @var{uid} falls within one of the specified ranges,
21348the @var{pass} is disabled for that function. The @var{uid} is shown in the
21349function header of a dump file, and the pass names can be dumped by using
21350option @option{-fdump-passes}.
21351
21352@item -fdisable-tree-@var{pass}
21353@itemx -fdisable-tree-@var{pass}=@var{range-list}
21354Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
21355option arguments.
21356
21357@item -fenable-ipa-@var{pass}
21358Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
21359statically invoked in the compiler multiple times, the pass name should be
21360appended with a sequential number starting from 1.
21361
21362@item -fenable-rtl-@var{pass}
21363@itemx -fenable-rtl-@var{pass}=@var{range-list}
21364Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
21365description and examples.
21366
21367@item -fenable-tree-@var{pass}
21368@itemx -fenable-tree-@var{pass}=@var{range-list}
21369Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
21370of option arguments.
21371
21372@end table
21373
21374Here are some examples showing uses of these options.
21375
21376@smallexample
21377
21378# disable ccp1 for all functions
21379 -fdisable-tree-ccp1
21380# disable complete unroll for function whose cgraph node uid is 1
21381 -fenable-tree-cunroll=1
21382# disable gcse2 for functions at the following ranges [1,1],
21383# [300,400], and [400,1000]
21384# disable gcse2 for functions foo and foo2
21385 -fdisable-rtl-gcse2=foo,foo2
21386# disable early inlining
21387 -fdisable-tree-einline
21388# disable ipa inlining
21389 -fdisable-ipa-inline
21390# enable tree full unroll
21391 -fenable-tree-unroll
21392
21393@end smallexample
21394
d77de738
ML
21395@opindex fchecking
21396@opindex fno-checking
ddf6fe37
AA
21397@item -fchecking
21398@itemx -fchecking=@var{n}
d77de738
ML
21399Enable internal consistency checking. The default depends on
21400the compiler configuration. @option{-fchecking=2} enables further
21401internal consistency checking that might affect code generation.
21402
d77de738 21403@opindex frandom-seed
ddf6fe37 21404@item -frandom-seed=@var{string}
d77de738
ML
21405This option provides a seed that GCC uses in place of
21406random numbers in generating certain symbol names
21407that have to be different in every compiled file. It is also used to
21408place unique stamps in coverage data files and the object files that
21409produce them. You can use the @option{-frandom-seed} option to produce
21410reproducibly identical object files.
21411
21412The @var{string} can either be a number (decimal, octal or hex) or an
21413arbitrary string (in which case it's converted to a number by
21414computing CRC32).
21415
21416The @var{string} should be different for every file you compile.
21417
d77de738 21418@opindex save-temps
ddf6fe37 21419@item -save-temps
d77de738
ML
21420Store the usual ``temporary'' intermediate files permanently; name them
21421as auxiliary output files, as specified described under
21422@option{-dumpbase} and @option{-dumpdir}.
21423
21424When used in combination with the @option{-x} command-line option,
21425@option{-save-temps} is sensible enough to avoid overwriting an
21426input source file with the same extension as an intermediate file.
21427The corresponding intermediate file may be obtained by renaming the
21428source file before using @option{-save-temps}.
21429
d77de738 21430@opindex save-temps=cwd
ddf6fe37 21431@item -save-temps=cwd
d77de738
ML
21432Equivalent to @option{-save-temps -dumpdir ./}.
21433
d77de738 21434@opindex save-temps=obj
ddf6fe37 21435@item -save-temps=obj
d77de738
ML
21436Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
21437@file{outdir/} is the directory of the output file specified after the
21438@option{-o} option, including any directory separators. If the
21439@option{-o} option is not used, the @option{-save-temps=obj} switch
21440behaves like @option{-save-temps=cwd}.
21441
d77de738 21442@opindex time
ddf6fe37 21443@item -time@r{[}=@var{file}@r{]}
d77de738
ML
21444Report the CPU time taken by each subprocess in the compilation
21445sequence. For C source files, this is the compiler proper and assembler
21446(plus the linker if linking is done).
21447
21448Without the specification of an output file, the output looks like this:
21449
21450@smallexample
21451# cc1 0.12 0.01
21452# as 0.00 0.01
21453@end smallexample
21454
21455The first number on each line is the ``user time'', that is time spent
21456executing the program itself. The second number is ``system time'',
21457time spent executing operating system routines on behalf of the program.
21458Both numbers are in seconds.
21459
21460With the specification of an output file, the output is appended to the
21461named file, and it looks like this:
21462
21463@smallexample
214640.12 0.01 cc1 @var{options}
214650.00 0.01 as @var{options}
21466@end smallexample
21467
21468The ``user time'' and the ``system time'' are moved before the program
21469name, and the options passed to the program are displayed, so that one
21470can later tell what file was being compiled, and with which options.
21471
d77de738 21472@opindex fdump-final-insns
ddf6fe37 21473@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
21474Dump the final internal representation (RTL) to @var{file}. If the
21475optional argument is omitted (or if @var{file} is @code{.}), the name
21476of the dump file is determined by appending @code{.gkd} to the
21477dump base name, see @option{-dumpbase}.
21478
d77de738
ML
21479@opindex fcompare-debug
21480@opindex fno-compare-debug
ddf6fe37 21481@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
21482If no error occurs during compilation, run the compiler a second time,
21483adding @var{opts} and @option{-fcompare-debug-second} to the arguments
21484passed to the second compilation. Dump the final internal
21485representation in both compilations, and print an error if they differ.
21486
21487If the equal sign is omitted, the default @option{-gtoggle} is used.
21488
21489The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
21490and nonzero, implicitly enables @option{-fcompare-debug}. If
21491@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
21492then it is used for @var{opts}, otherwise the default @option{-gtoggle}
21493is used.
21494
21495@option{-fcompare-debug=}, with the equal sign but without @var{opts},
21496is equivalent to @option{-fno-compare-debug}, which disables the dumping
21497of the final representation and the second compilation, preventing even
21498@env{GCC_COMPARE_DEBUG} from taking effect.
21499
21500To verify full coverage during @option{-fcompare-debug} testing, set
21501@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
21502which GCC rejects as an invalid option in any actual compilation
21503(rather than preprocessing, assembly or linking). To get just a
21504warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
21505not overridden} will do.
21506
d77de738 21507@opindex fcompare-debug-second
ddf6fe37 21508@item -fcompare-debug-second
d77de738
ML
21509This option is implicitly passed to the compiler for the second
21510compilation requested by @option{-fcompare-debug}, along with options to
21511silence warnings, and omitting other options that would cause the compiler
21512to produce output to files or to standard output as a side effect. Dump
21513files and preserved temporary files are renamed so as to contain the
21514@code{.gk} additional extension during the second compilation, to avoid
21515overwriting those generated by the first.
21516
21517When this option is passed to the compiler driver, it causes the
21518@emph{first} compilation to be skipped, which makes it useful for little
21519other than debugging the compiler proper.
21520
d77de738 21521@opindex gtoggle
ddf6fe37 21522@item -gtoggle
d77de738
ML
21523Turn off generation of debug info, if leaving out this option
21524generates it, or turn it on at level 2 otherwise. The position of this
21525argument in the command line does not matter; it takes effect after all
21526other options are processed, and it does so only once, no matter how
21527many times it is given. This is mainly intended to be used with
21528@option{-fcompare-debug}.
21529
d77de738
ML
21530@opindex fvar-tracking-assignments-toggle
21531@opindex fno-var-tracking-assignments-toggle
ddf6fe37 21532@item -fvar-tracking-assignments-toggle
d77de738
ML
21533Toggle @option{-fvar-tracking-assignments}, in the same way that
21534@option{-gtoggle} toggles @option{-g}.
21535
d77de738 21536@opindex Q
ddf6fe37 21537@item -Q
a5212edf
SL
21538When used on the command line prior to @option{--help=}, @option{-Q}
21539acts as a modifier to the help output. @xref{Overall Options},
21540for details about @option{--help=}.
21541
21542Otherwise, this option makes the compiler print out each function name
21543as it is compiled, and print some statistics about each pass when it
21544finishes.
d77de738 21545
d77de738 21546@opindex ftime-report
ddf6fe37 21547@item -ftime-report
75d62394
DM
21548Makes the compiler print some statistics to stderr about the time consumed
21549by each pass when it finishes.
21550
21551If SARIF output of diagnostics was requested via
21552@option{-fdiagnostics-format=sarif-file} or
21553@option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
21554information is instead emitted in JSON form as part of SARIF output. The
21555precise format of this JSON data is subject to change, and the values may
21556not exactly match those emitted to stderr due to being written out at a
21557slightly different place within the compiler.
d77de738 21558
d77de738 21559@opindex ftime-report-details
ddf6fe37 21560@item -ftime-report-details
d77de738
ML
21561Record the time consumed by infrastructure parts separately for each pass.
21562
d77de738 21563@opindex fira-verbose
ddf6fe37 21564@item -fira-verbose=@var{n}
d77de738
ML
21565Control the verbosity of the dump file for the integrated register allocator.
21566The default value is 5. If the value @var{n} is greater or equal to 10,
21567the dump output is sent to stderr using the same format as @var{n} minus 10.
21568
d77de738 21569@opindex flto-report
ddf6fe37 21570@item -flto-report
d77de738
ML
21571Prints a report with internal details on the workings of the link-time
21572optimizer. The contents of this report vary from version to version.
21573It is meant to be useful to GCC developers when processing object
21574files in LTO mode (via @option{-flto}).
21575
21576Disabled by default.
21577
d77de738 21578@opindex flto-report-wpa
ddf6fe37 21579@item -flto-report-wpa
d77de738
ML
21580Like @option{-flto-report}, but only print for the WPA phase of link-time
21581optimization.
21582
d77de738 21583@opindex fmem-report
ddf6fe37 21584@item -fmem-report
d77de738
ML
21585Makes the compiler print some statistics about permanent memory
21586allocation when it finishes.
21587
d77de738 21588@opindex fmem-report-wpa
ddf6fe37 21589@item -fmem-report-wpa
d77de738
ML
21590Makes the compiler print some statistics about permanent memory
21591allocation for the WPA phase only.
21592
d77de738 21593@opindex fpre-ipa-mem-report
d77de738 21594@opindex fpost-ipa-mem-report
ddf6fe37
AA
21595@item -fpre-ipa-mem-report
21596@item -fpost-ipa-mem-report
d77de738
ML
21597Makes the compiler print some statistics about permanent memory
21598allocation before or after interprocedural optimization.
21599
d77de738 21600@opindex fmultiflags
ddf6fe37 21601@item -fmultiflags
d77de738
ML
21602This option enables multilib-aware @code{TFLAGS} to be used to build
21603target libraries with options different from those the compiler is
8e0568d8
AO
21604configured to use by default, through the use of specs (@pxref{Spec
21605Files}) set up by compiler internals, by the target, or by builders at
d77de738
ML
21606configure time.
21607
21608Like @code{TFLAGS}, this allows the target libraries to be built for
21609portable baseline environments, while the compiler defaults to more
21610demanding ones. That's useful because users can easily override the
21611defaults the compiler is configured to use to build their own programs,
21612if the defaults are not ideal for their target environment, whereas
21613rebuilding the runtime libraries is usually not as easy or desirable.
21614
21615Unlike @code{TFLAGS}, the use of specs enables different flags to be
21616selected for different multilibs. The way to accomplish that is to
21617build with @samp{make TFLAGS=-fmultiflags}, after configuring
21618@samp{--with-specs=%@{fmultiflags:...@}}.
21619
21620This option is discarded by the driver once it's done processing driver
21621self spec.
21622
21623It is also useful to check that @code{TFLAGS} are being used to build
21624all target libraries, by configuring a non-bootstrap compiler
21625@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
21626the compiler and target libraries.
21627
d77de738 21628@opindex fprofile-report
ddf6fe37 21629@item -fprofile-report
d77de738
ML
21630Makes the compiler print some statistics about consistency of the
21631(estimated) profile and effect of individual passes.
21632
d77de738 21633@opindex fstack-usage
ddf6fe37 21634@item -fstack-usage
d77de738
ML
21635Makes the compiler output stack usage information for the program, on a
21636per-function basis. The filename for the dump is made by appending
21637@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
21638the output file, if explicitly specified and it is not an executable,
21639otherwise it is the basename of the source file. An entry is made up
21640of three fields:
21641
21642@itemize
21643@item
21644The name of the function.
21645@item
21646A number of bytes.
21647@item
21648One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
21649@end itemize
21650
21651The qualifier @code{static} means that the function manipulates the stack
21652statically: a fixed number of bytes are allocated for the frame on function
21653entry and released on function exit; no stack adjustments are otherwise made
21654in the function. The second field is this fixed number of bytes.
21655
21656The qualifier @code{dynamic} means that the function manipulates the stack
21657dynamically: in addition to the static allocation described above, stack
21658adjustments are made in the body of the function, for example to push/pop
21659arguments around function calls. If the qualifier @code{bounded} is also
21660present, the amount of these adjustments is bounded at compile time and
21661the second field is an upper bound of the total amount of stack used by
21662the function. If it is not present, the amount of these adjustments is
21663not bounded at compile time and the second field only represents the
21664bounded part.
21665
d77de738 21666@opindex fstats
ddf6fe37 21667@item -fstats
d77de738
ML
21668Emit statistics about front-end processing at the end of the compilation.
21669This option is supported only by the C++ front end, and
21670the information is generally only useful to the G++ development team.
21671
d77de738 21672@opindex fdbg-cnt-list
ddf6fe37 21673@item -fdbg-cnt-list
d77de738
ML
21674Print the name and the counter upper bound for all debug counters.
21675
21676
d77de738 21677@opindex fdbg-cnt
ddf6fe37 21678@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
21679Set the internal debug counter lower and upper bound. @var{counter-value-list}
21680is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
21681[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
21682the name of the counter and list of closed intervals.
21683The @var{lower_bound} is optional and is zero
21684initialized if not set.
21685For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
21686@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
21687eleventh invocation.
21688For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
21689
d77de738 21690@opindex print-file-name
ddf6fe37 21691@item -print-file-name=@var{library}
d77de738
ML
21692Print the full absolute name of the library file @var{library} that
21693would be used when linking---and don't do anything else. With this
21694option, GCC does not compile or link anything; it just prints the
21695file name.
21696
d77de738 21697@opindex print-multi-directory
ddf6fe37 21698@item -print-multi-directory
d77de738
ML
21699Print the directory name corresponding to the multilib selected by any
21700other switches present in the command line. This directory is supposed
21701to exist in @env{GCC_EXEC_PREFIX}.
21702
d77de738 21703@opindex print-multi-lib
ddf6fe37 21704@item -print-multi-lib
d77de738
ML
21705Print the mapping from multilib directory names to compiler switches
21706that enable them. The directory name is separated from the switches by
21707@samp{;}, and each switch starts with an @samp{@@} instead of the
21708@samp{-}, without spaces between multiple switches. This is supposed to
21709ease shell processing.
21710
d77de738 21711@opindex print-multi-os-directory
ddf6fe37 21712@item -print-multi-os-directory
d77de738
ML
21713Print the path to OS libraries for the selected
21714multilib, relative to some @file{lib} subdirectory. If OS libraries are
21715present in the @file{lib} subdirectory and no multilibs are used, this is
21716usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
21717sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
21718@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
21719subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
21720
d77de738 21721@opindex print-multiarch
ddf6fe37 21722@item -print-multiarch
d77de738
ML
21723Print the path to OS libraries for the selected multiarch,
21724relative to some @file{lib} subdirectory.
21725
d77de738 21726@opindex print-prog-name
ddf6fe37 21727@item -print-prog-name=@var{program}
d77de738
ML
21728Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
21729
d77de738 21730@opindex print-libgcc-file-name
ddf6fe37 21731@item -print-libgcc-file-name
d77de738
ML
21732Same as @option{-print-file-name=libgcc.a}.
21733
21734This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
21735but you do want to link with @file{libgcc.a}. You can do:
21736
21737@smallexample
21738gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
21739@end smallexample
21740
d77de738 21741@opindex print-search-dirs
ddf6fe37 21742@item -print-search-dirs
d77de738
ML
21743Print the name of the configured installation directory and a list of
21744program and library directories @command{gcc} searches---and don't do anything else.
21745
21746This is useful when @command{gcc} prints the error message
21747@samp{installation problem, cannot exec cpp0: No such file or directory}.
21748To resolve this you either need to put @file{cpp0} and the other compiler
21749components where @command{gcc} expects to find them, or you can set the environment
21750variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
21751Don't forget the trailing @samp{/}.
21752@xref{Environment Variables}.
21753
d77de738 21754@opindex print-sysroot
ddf6fe37 21755@item -print-sysroot
d77de738
ML
21756Print the target sysroot directory that is used during
21757compilation. This is the target sysroot specified either at configure
21758time or using the @option{--sysroot} option, possibly with an extra
21759suffix that depends on compilation options. If no target sysroot is
21760specified, the option prints nothing.
21761
d77de738 21762@opindex print-sysroot-headers-suffix
ddf6fe37 21763@item -print-sysroot-headers-suffix
d77de738
ML
21764Print the suffix added to the target sysroot when searching for
21765headers, or give an error if the compiler is not configured with such
21766a suffix---and don't do anything else.
21767
d77de738 21768@opindex dumpmachine
ddf6fe37 21769@item -dumpmachine
d77de738
ML
21770Print the compiler's target machine (for example,
21771@samp{i686-pc-linux-gnu})---and don't do anything else.
21772
d77de738 21773@opindex dumpversion
ddf6fe37 21774@item -dumpversion
d77de738
ML
21775Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
21776anything else. This is the compiler version used in filesystem paths and
21777specs. Depending on how the compiler has been configured it can be just
21778a single number (major version), two numbers separated by a dot (major and
21779minor version) or three numbers separated by dots (major, minor and patchlevel
21780version).
21781
d77de738 21782@opindex dumpfullversion
ddf6fe37 21783@item -dumpfullversion
d77de738
ML
21784Print the full compiler version---and don't do anything else. The output is
21785always three numbers separated by dots, major, minor and patchlevel version.
21786
d77de738 21787@opindex dumpspecs
ddf6fe37 21788@item -dumpspecs
d77de738
ML
21789Print the compiler's built-in specs---and don't do anything else. (This
21790is used when GCC itself is being built.) @xref{Spec Files}.
21791@end table
21792
21793@node Submodel Options
21794@section Machine-Dependent Options
21795@cindex submodel options
21796@cindex specifying hardware config
21797@cindex hardware models and configurations, specifying
21798@cindex target-dependent options
21799@cindex machine-dependent options
21800
21801Each target machine supported by GCC can have its own options---for
21802example, to allow you to compile for a particular processor variant or
21803ABI, or to control optimizations specific to that machine. By
21804convention, the names of machine-specific options start with
21805@samp{-m}.
21806
21807Some configurations of the compiler also support additional target-specific
21808options, usually for compatibility with other compilers on the same
21809platform.
21810
21811@c This list is ordered alphanumerically by subsection name.
21812@c It should be the same order and spelling as these options are listed
21813@c in Machine Dependent Options
21814
21815@menu
21816* AArch64 Options::
21817* Adapteva Epiphany Options::
21818* AMD GCN Options::
21819* ARC Options::
21820* ARM Options::
21821* AVR Options::
21822* Blackfin Options::
21823* C6X Options::
21824* CRIS Options::
21825* C-SKY Options::
e8d00373 21826* Cygwin and MinGW Options::
d77de738
ML
21827* Darwin Options::
21828* DEC Alpha Options::
21829* eBPF Options::
21830* FR30 Options::
21831* FT32 Options::
21832* FRV Options::
21833* GNU/Linux Options::
21834* H8/300 Options::
21835* HPPA Options::
21836* IA-64 Options::
21837* LM32 Options::
21838* LoongArch Options::
21839* M32C Options::
21840* M32R/D Options::
21841* M680x0 Options::
21842* MCore Options::
d77de738
ML
21843* MicroBlaze Options::
21844* MIPS Options::
21845* MMIX Options::
21846* MN10300 Options::
21847* Moxie Options::
21848* MSP430 Options::
21849* NDS32 Options::
d77de738
ML
21850* Nvidia PTX Options::
21851* OpenRISC Options::
21852* PDP-11 Options::
d77de738
ML
21853* PowerPC Options::
21854* PRU Options::
21855* RISC-V Options::
21856* RL78 Options::
21857* RS/6000 and PowerPC Options::
21858* RX Options::
21859* S/390 and zSeries Options::
d77de738
ML
21860* SH Options::
21861* Solaris 2 Options::
21862* SPARC Options::
21863* System V Options::
21864* V850 Options::
21865* VAX Options::
21866* Visium Options::
21867* VMS Options::
21868* VxWorks Options::
21869* x86 Options::
21870* x86 Windows Options::
21871* Xstormy16 Options::
21872* Xtensa Options::
21873* zSeries Options::
21874@end menu
21875
21876@node AArch64 Options
21877@subsection AArch64 Options
21878@cindex AArch64 Options
21879
21880These options are defined for AArch64 implementations:
21881
21882@table @gcctabopt
21883
d77de738 21884@opindex mabi
ddf6fe37 21885@item -mabi=@var{name}
d77de738
ML
21886Generate code for the specified data model. Permissible values
21887are @samp{ilp32} for SysV-like data model where int, long int and pointers
21888are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
21889but long int and pointers are 64 bits.
21890
21891The default depends on the specific target configuration. Note that
21892the LP64 and ILP32 ABIs are not link-compatible; you must compile your
21893entire program with the same ABI, and link with a compatible set of libraries.
21894
625ea3c6
WD
21895The @samp{ilp32} model is deprecated.
21896
d77de738 21897@opindex mbig-endian
ddf6fe37 21898@item -mbig-endian
d77de738
ML
21899Generate big-endian code. This is the default when GCC is configured for an
21900@samp{aarch64_be-*-*} target.
21901
d77de738 21902@opindex mgeneral-regs-only
ddf6fe37 21903@item -mgeneral-regs-only
d77de738
ML
21904Generate code which uses only the general-purpose registers. This will prevent
21905the compiler from using floating-point and Advanced SIMD registers but will not
21906impose any restrictions on the assembler.
21907
d77de738 21908@opindex mlittle-endian
ddf6fe37 21909@item -mlittle-endian
d77de738
ML
21910Generate little-endian code. This is the default when GCC is configured for an
21911@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
21912
a0d60660 21913@opindex mcmodel=
d77de738 21914@opindex mcmodel=tiny
ddf6fe37 21915@item -mcmodel=tiny
d77de738
ML
21916Generate code for the tiny code model. The program and its statically defined
21917symbols must be within 1MB of each other. Programs can be statically or
21918dynamically linked.
21919
d77de738 21920@opindex mcmodel=small
ddf6fe37 21921@item -mcmodel=small
d77de738
ML
21922Generate code for the small code model. The program and its statically defined
21923symbols must be within 4GB of each other. Programs can be statically or
21924dynamically linked. This is the default code model.
21925
d77de738 21926@opindex mcmodel=large
ddf6fe37 21927@item -mcmodel=large
d77de738
ML
21928Generate code for the large code model. This makes no assumptions about
21929addresses and sizes of sections. Programs can be statically linked only. The
21930@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
21931@option{-fpic} and @option{-fPIC}.
21932
573624ec
KT
21933@item -mtp=@var{name}
21934@opindex mtp
21935Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
21936are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
21937@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
21938@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
21939The default setting is @samp{tpidr_el0}. It is recommended to compile all
21940code intended to interoperate with the same value of this option to avoid
21941accessing a different thread pointer from the wrong exception level.
573624ec 21942
d77de738
ML
21943@opindex mstrict-align
21944@opindex mno-strict-align
ddf6fe37
AA
21945@item -mstrict-align
21946@itemx -mno-strict-align
d77de738
ML
21947Avoid or allow generating memory accesses that may not be aligned on a natural
21948object boundary as described in the architecture specification.
21949
d77de738
ML
21950@opindex momit-leaf-frame-pointer
21951@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
21952@item -momit-leaf-frame-pointer
21953@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
21954Omit or keep the frame pointer in leaf functions. The former behavior is the
21955default.
21956
d77de738
ML
21957@opindex mstack-protector-guard
21958@opindex mstack-protector-guard-reg
21959@opindex mstack-protector-guard-offset
ddf6fe37
AA
21960@item -mstack-protector-guard=@var{guard}
21961@itemx -mstack-protector-guard-reg=@var{reg}
21962@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
21963Generate stack protection code using canary at @var{guard}. Supported
21964locations are @samp{global} for a global canary or @samp{sysreg} for a
21965canary in an appropriate system register.
21966
21967With the latter choice the options
21968@option{-mstack-protector-guard-reg=@var{reg}} and
21969@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
21970which system register to use as base register for reading the canary,
21971and from what offset from that base register. There is no default
21972register or offset as this is entirely for use within the Linux
21973kernel.
21974
d77de738 21975@opindex mtls-dialect=desc
ddf6fe37 21976@item -mtls-dialect=desc
d77de738
ML
21977Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
21978of TLS variables. This is the default.
21979
d77de738 21980@opindex mtls-dialect=traditional
ddf6fe37 21981@item -mtls-dialect=traditional
d77de738
ML
21982Use traditional TLS as the thread-local storage mechanism for dynamic accesses
21983of TLS variables.
21984
d77de738 21985@opindex mtls-size
ddf6fe37 21986@item -mtls-size=@var{size}
d77de738
ML
21987Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
21988This option requires binutils 2.26 or newer.
21989
d77de738
ML
21990@opindex mfix-cortex-a53-835769
21991@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
21992@item -mfix-cortex-a53-835769
21993@itemx -mno-fix-cortex-a53-835769
d77de738
ML
21994Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
21995This involves inserting a NOP instruction between memory instructions and
5b0e4ed3
TC
2199664-bit integer multiply-accumulate instructions. This flag will be ignored if
21997an architecture or cpu is specified on the command line which does not need the
21998workaround.
d77de738 21999
d77de738
ML
22000@opindex mfix-cortex-a53-843419
22001@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
22002@item -mfix-cortex-a53-843419
22003@itemx -mno-fix-cortex-a53-843419
d77de738
ML
22004Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
22005This erratum workaround is made at link time and this will only pass the
5b0e4ed3
TC
22006corresponding flag to the linker. This flag will be ignored if
22007an architecture or cpu is specified on the command line which does not need the
22008workaround.
22009
d77de738 22010
d77de738
ML
22011@opindex mlow-precision-recip-sqrt
22012@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
22013@item -mlow-precision-recip-sqrt
22014@itemx -mno-low-precision-recip-sqrt
d77de738
ML
22015Enable or disable the reciprocal square root approximation.
22016This option only has an effect if @option{-ffast-math} or
22017@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22018precision of reciprocal square root results to about 16 bits for
22019single precision and to 32 bits for double precision.
22020
d77de738
ML
22021@opindex mlow-precision-sqrt
22022@opindex mno-low-precision-sqrt
ddf6fe37
AA
22023@item -mlow-precision-sqrt
22024@itemx -mno-low-precision-sqrt
d77de738
ML
22025Enable or disable the square root approximation.
22026This option only has an effect if @option{-ffast-math} or
22027@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22028precision of square root results to about 16 bits for
22029single precision and to 32 bits for double precision.
22030If enabled, it implies @option{-mlow-precision-recip-sqrt}.
22031
d77de738
ML
22032@opindex mlow-precision-div
22033@opindex mno-low-precision-div
ddf6fe37
AA
22034@item -mlow-precision-div
22035@itemx -mno-low-precision-div
d77de738
ML
22036Enable or disable the division approximation.
22037This option only has an effect if @option{-ffast-math} or
22038@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22039precision of division results to about 16 bits for
22040single precision and to 32 bits for double precision.
22041
22042@item -mtrack-speculation
22043@itemx -mno-track-speculation
22044Enable or disable generation of additional code to track speculative
22045execution through conditional branches. The tracking state can then
22046be used by the compiler when expanding calls to
22047@code{__builtin_speculation_safe_copy} to permit a more efficient code
22048sequence to be generated.
22049
22050@item -moutline-atomics
22051@itemx -mno-outline-atomics
22052Enable or disable calls to out-of-line helpers to implement atomic operations.
22053These helpers will, at runtime, determine if the LSE instructions from
22054ARMv8.1-A can be used; if not, they will use the load/store-exclusive
22055instructions that are present in the base ARMv8.0 ISA.
22056
22057This option is only applicable when compiling for the base ARMv8.0
22058instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
22059or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
22060used directly. The same applies when using @option{-mcpu=} when the
22061selected cpu supports the @samp{lse} feature.
22062This option is on by default.
22063
8e802876
TC
22064@item -mmax-vectorization
22065@itemx -mno-max-vectorization
22066Enable or disable an override to vectorizer cost model making vectorization
22067always appear profitable. This option can be combined with
22068@option{-mautovec-preference} allowing precise control over which ISA will be
22069used for auto-vectorization. Unlike @option{-fno-vect-cost-model} or
22070@option{-fvect-cost-model=unlimited} this option does not turn off cost
22071comparison between different vector modes.
22072
f60d3f5c
TC
22073@item -mautovec-preference=@var{name}
22074Force an ISA selection strategy for auto-vectorization. The possible
22075values of @var{name} are:
22076@table @samp
22077@item default
22078Use the default heuristics.
22079@item asimd-only
22080Use only Advanced SIMD for auto-vectorization.
22081@item sve-only
22082Use only SVE for auto-vectorization.
22083@item prefer-asimd
22084Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
22085deemed equal.
22086@item prefer-sve
22087Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
22088@end table
22089
22090For best performance it is highly recommended to use @option{-mcpu} or
22091@option{-mtune} instead. This parameter should only be used for code
22092exploration.
22093
d77de738 22094@opindex march
ddf6fe37 22095@item -march=@var{name}
d77de738
ML
22096Specify the name of the target architecture and, optionally, one or
22097more feature modifiers. This option has the form
22098@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
22099
22100The table below summarizes the permissible values for @var{arch}
22101and the features that they enable by default:
22102
22103@multitable @columnfractions 0.20 0.20 0.60
22104@headitem @var{arch} value @tab Architecture @tab Includes by default
22105@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
22106@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
22107@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
abbe2905
AC
22108@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}, @samp{+fcma}, @samp{+jscvt}
22109@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}, @samp{+rcpc2}
22110@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}, @samp{+frintts}, @samp{+flagm2}
d77de738 22111@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
abbe2905 22112@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+wfxt}, @samp{+xs}
d77de738 22113@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
16a05fac 22114@item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a}
d77de738
ML
22115@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
22116@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
25464e79 22117@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+wfxt}, @samp{+xs}
d77de738 22118@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
d46be332 22119@item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a}, @samp{+sve2p1}
12b7220d 22120@item @samp{armv9.5-a} @tab Armv9.4-A @tab @samp{armv9.4-a}, @samp{cpa}, @samp{+faminmax}, @samp{+lut}
d77de738
ML
22121@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
22122@end multitable
22123
22124The value @samp{native} is available on native AArch64 GNU/Linux and
22125causes the compiler to pick the architecture of the host system. This
22126option has no effect if the compiler is unable to recognize the
a2cb656c
KT
22127architecture of the host system. When @option{-march=native} is given and
22128no other @option{-mcpu} or @option{-mtune} is given then GCC will pick
22129the host CPU as the CPU to tune for as well as select the architecture features
22130from. That is, @option{-march=native} is treated as @option{-mcpu=native}.
d77de738
ML
22131
22132The permissible values for @var{feature} are listed in the sub-section
22133on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
22134Feature Modifiers}. Where conflicting feature modifiers are
22135specified, the right-most feature is used.
22136
22137GCC uses @var{name} to determine what kind of instructions it can emit
22138when generating assembly code. If @option{-march} is specified
22139without either of @option{-mtune} or @option{-mcpu} also being
22140specified, the code is tuned to perform well across a range of target
22141processors implementing the target architecture.
22142
d77de738 22143@opindex mtune
ddf6fe37 22144@item -mtune=@var{name}
d77de738
ML
22145Specify the name of the target processor for which GCC should tune the
22146performance of the code. Permissible values for this option are:
22147@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22148@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22149@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22150@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
22151@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
22152@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
01cfd601 22153@samp{oryon-1},
d77de738 22154@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
7fada36c 22155@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{grace},
1aa49fe0 22156@samp{neoverse-v3}, @samp{neoverse-v3ae}, @samp{neoverse-n3}, @samp{olympus},
1f53319c 22157@samp{cortex-a725}, @samp{cortex-x925},
7fada36c 22158@samp{qdf24xx}, @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
d77de738
ML
22159@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
22160@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
22161@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
22162@samp{octeontx2f95mm},
d413a2c4 22163@samp{a64fx}, @samp{fujitsu-monaka},
d77de738
ML
22164@samp{thunderx}, @samp{thunderxt88},
22165@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
22166@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
22167@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22168@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
22169@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
77505661
VDN
22170@samp{cortex-r82}, @samp{cortex-r82ae}, @samp{cortex-x1}, @samp{cortex-x1c},
22171@samp{cortex-x2}, @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510},
22172@samp{cortex-a520}, @samp{cortex-a520ae}, @samp{cortex-a710}, @samp{cortex-a715},
22173@samp{cortex-a720}, @samp{cortex-a720ae}, @samp{ampere1}, @samp{ampere1a},
3a77a567
IS
22174@samp{ampere1b}, @samp{cobalt-100}, @samp{apple-m1}, @samp{apple-m2},
22175@samp{apple-m3} and @samp{native}.
d77de738
ML
22176
22177The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22178@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
3a77a567 22179@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
9ff6ade2 22180@samp{apple-m1}, @samp{apple-m2}, @samp{apple-m3}, @samp{gb10} specify that GCC
d77de738
ML
22181should tune for a big.LITTLE system.
22182
22183The value @samp{neoverse-512tvb} specifies that GCC should tune
22184for Neoverse cores that (a) implement SVE and (b) have a total vector
22185bandwidth of 512 bits per cycle. In other words, the option tells GCC to
22186tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
22187instructions a cycle and that can execute an equivalent number of SVE
22188arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
22189This is more general than tuning for a specific core like Neoverse V1
22190but is more specific than the default tuning described below.
22191
22192Additionally on native AArch64 GNU/Linux systems the value
22193@samp{native} tunes performance to the host system. This option has no effect
22194if the compiler is unable to recognize the processor of the host system.
22195
22196Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
22197are specified, the code is tuned to perform well across a range
22198of target processors.
22199
22200This option cannot be suffixed by feature modifiers.
22201
d77de738 22202@opindex mcpu
ddf6fe37 22203@item -mcpu=@var{name}
d77de738
ML
22204Specify the name of the target processor, optionally suffixed by one
22205or more feature modifiers. This option has the form
22206@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
22207the permissible values for @var{cpu} are the same as those available
22208for @option{-mtune}. The permissible values for @var{feature} are
22209documented in the sub-section on
22210@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
22211Feature Modifiers}. Where conflicting feature modifiers are
22212specified, the right-most feature is used.
22213
22214GCC uses @var{name} to determine what kind of instructions it can emit when
22215generating assembly code (as if by @option{-march}) and to determine
22216the target processor for which to tune for performance (as if
22217by @option{-mtune}). Where this option is used in conjunction
22218with @option{-march} or @option{-mtune}, those options take precedence
22219over the appropriate part of this option.
22220
22221@option{-mcpu=neoverse-512tvb} is special in that it does not refer
22222to a specific core, but instead refers to all Neoverse cores that
22223(a) implement SVE and (b) have a total vector bandwidth of 512 bits
22224a cycle. Unless overridden by @option{-march},
22225@option{-mcpu=neoverse-512tvb} generates code that can run on a
22226Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
22227these properties. Unless overridden by @option{-mtune},
22228@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
22229@option{-mtune=neoverse-512tvb}.
22230
d77de738 22231@opindex moverride
ddf6fe37 22232@item -moverride=@var{string}
d77de738
ML
22233Override tuning decisions made by the back-end in response to a
22234@option{-mtune=} switch. The syntax, semantics, and accepted values
22235for @var{string} in this option are not guaranteed to be consistent
22236across releases.
22237
22238This option is only intended to be useful when developing GCC.
22239
d77de738 22240@opindex mverbose-cost-dump
ddf6fe37 22241@item -mverbose-cost-dump
d77de738
ML
22242Enable verbose cost model dumping in the debug dump files. This option is
22243provided for use in debugging the compiler.
22244
d77de738
ML
22245@opindex mpc-relative-literal-loads
22246@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
22247@item -mpc-relative-literal-loads
22248@itemx -mno-pc-relative-literal-loads
d77de738
ML
22249Enable or disable PC-relative literal loads. With this option literal pools are
22250accessed using a single instruction and emitted after each function. This
22251limits the maximum size of functions to 1MB. This is enabled by default for
22252@option{-mcmodel=tiny}.
22253
d77de738 22254@opindex msign-return-address
ddf6fe37 22255@item -msign-return-address=@var{scope}
d77de738
ML
22256Select the function scope on which return address signing will be applied.
22257Permissible values are @samp{none}, which disables return address signing,
22258@samp{non-leaf}, which enables pointer signing for functions which are not leaf
22259functions, and @samp{all}, which enables pointer signing for all functions. The
22260default value is @samp{none}. This option has been deprecated by
22261-mbranch-protection.
22262
d77de738 22263@opindex mbranch-protection
56ded80b 22264@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}|@var{gcs}
d77de738
ML
22265Select the branch protection features to use.
22266@samp{none} is the default and turns off all types of branch protection.
22267@samp{standard} turns on all types of branch protection features. If a feature
22268has additional tuning options, then @samp{standard} sets it to its standard
22269level.
22270@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
22271level: signing functions that save the return address to memory (non-leaf
22272functions will practically always do this) using the a-key. The optional
22273argument @samp{leaf} can be used to extend the signing to include leaf
22274functions. The optional argument @samp{b-key} can be used to sign the functions
22275with the B-key instead of the A-key.
22276@samp{bti} turns on branch target identification mechanism.
56ded80b 22277@samp{gcs} turns on guarded control stack compatible code generation.
d77de738 22278
d77de738 22279@opindex mharden-sls
ddf6fe37 22280@item -mharden-sls=@var{opts}
d77de738
ML
22281Enable compiler hardening against straight line speculation (SLS).
22282@var{opts} is a comma-separated list of the following options:
22283@table @samp
22284@item retbr
22285@item blr
22286@end table
22287In addition, @samp{-mharden-sls=all} enables all SLS hardening while
22288@samp{-mharden-sls=none} disables all SLS hardening.
22289
9f0f7d80
RS
22290@opindex mearly-ra
22291@item -mearly-ra=@var{scope}
22292Determine when to enable an early register allocation pass. This pass runs
22293before instruction scheduling and tries to find a spill-free allocation of
22294floating-point and vector code. It also tries to make use of strided
22295multi-register instructions, such as SME2's strided LD1 and ST1.
22296
22297The possible values of @var{scope} are: @var{all}, which runs the pass on
22298all functions; @var{strided}, which runs the pass on functions that have
22299access to strided multi-register instructions; and @var{none}, which
22300disables the pass.
22301
22302@option{-mearly-ra=all} is the default for @option{-O2} and above, and for
22303@option{-Os}. @option{-mearly-ra=none} is the default otherwise.
22304
c0911c6b
AC
22305@opindex mearly-ldp-fusion
22306@item -mearly-ldp-fusion
22307Enable the copy of the AArch64 load/store pair fusion pass that runs before
22308register allocation. Enabled by default at @samp{-O} and above.
22309
22310@opindex mlate-ldp-fusion
22311@item -mlate-ldp-fusion
22312Enable the copy of the AArch64 load/store pair fusion pass that runs after
22313register allocation. Enabled by default at @samp{-O} and above.
22314
d77de738 22315@opindex msve-vector-bits
ddf6fe37 22316@item -msve-vector-bits=@var{bits}
d77de738
ML
22317Specify the number of bits in an SVE vector register. This option only has
22318an effect when SVE is enabled.
22319
22320GCC supports two forms of SVE code generation: ``vector-length
22321agnostic'' output that works with any size of vector register and
22322``vector-length specific'' output that allows GCC to make assumptions
22323about the vector length when it is useful for optimization reasons.
22324The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
22325@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
22326Specifying @samp{scalable} selects vector-length agnostic
22327output. At present @samp{-msve-vector-bits=128} also generates vector-length
22328agnostic output for big-endian targets. All other values generate
22329vector-length specific code. The behavior of these values may change
22330in future releases and no value except @samp{scalable} should be
22331relied on for producing code that is portable across different
22332hardware SVE vector lengths.
22333
22334The default is @samp{-msve-vector-bits=scalable}, which produces
22335vector-length agnostic code.
e5798872
AR
22336
22337@opindex Wexperimental-fmv-target
22338@opindex Wno-experimental-fmv-target
22339@item -Wexperimental-fmv-target
22340Warn about use of experimental Function Multi Versioning.
22341The Arm C Language Extension specification for Function Multi Versioning
22342is beta and subject to change. Any usage of FMV is caveated that future
22343behavior change and incompatibility is likely.
d77de738
ML
22344@end table
22345
22346@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
22347@anchor{aarch64-feature-modifiers}
22348@cindex @option{-march} feature modifiers
22349@cindex @option{-mcpu} feature modifiers
22350Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
22351the following and their inverses @option{no@var{feature}}:
22352
22353@table @samp
22354@item crc
22355Enable CRC extension. This is on by default for
22356@option{-march=armv8.1-a}.
22357@item crypto
22358Enable Crypto extension. This also enables Advanced SIMD and floating-point
22359instructions.
22360@item fp
22361Enable floating-point instructions. This is on by default for all possible
22362values for options @option{-march} and @option{-mcpu}.
22363@item simd
22364Enable Advanced SIMD instructions. This also enables floating-point
22365instructions. This is on by default for all possible values for options
22366@option{-march} and @option{-mcpu}.
22367@item sve
22368Enable Scalable Vector Extension instructions. This also enables Advanced
22369SIMD and floating-point instructions.
22370@item lse
22371Enable Large System Extension instructions. This is on by default for
22372@option{-march=armv8.1-a}.
22373@item rdma
22374Enable Round Double Multiply Accumulate instructions. This is on by default
22375for @option{-march=armv8.1-a}.
22376@item fp16
22377Enable FP16 extension. This also enables floating-point instructions.
22378@item fp16fml
22379Enable FP16 fmla extension. This also enables FP16 extensions and
22380floating-point instructions. This option is enabled by default for @option{-march=armv8.4-a}. Use of this option with architectures prior to Armv8.2-A is not supported.
22381
22382@item rcpc
0431e8ae
AV
22383Enable the RCpc extension. This enables the use of the LDAPR instructions for
22384load-acquire atomic semantics, and passes it on to the assembler, enabling
22385inline asm statements to use instructions from the RCpc extension.
d77de738
ML
22386@item dotprod
22387Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22388@item aes
22389Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
22390SIMD instructions.
22391@item sha2
22392Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
22393@item sha3
22394Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
22395instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
22396@item sm4
22397Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
22398Use of this option with architectures prior to Armv8.2-A is not supported.
22399@item profile
22400Enable the Statistical Profiling extension. This option is only to enable the
22401extension at the assembler level and does not affect code generation.
22402@item rng
22403Enable the Armv8.5-a Random Number instructions. This option is only to
22404enable the extension at the assembler level and does not affect code
22405generation.
22406@item memtag
22407Enable the Armv8.5-a Memory Tagging Extensions.
22408Use of this option with architectures prior to Armv8.5-A is not supported.
22409@item sb
22410Enable the Armv8-a Speculation Barrier instruction. This option is only to
22411enable the extension at the assembler level and does not affect code
22412generation. This option is enabled by default for @option{-march=armv8.5-a}.
22413@item ssbs
22414Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
22415is only to enable the extension at the assembler level and does not affect code
22416generation. This option is enabled by default for @option{-march=armv8.5-a}.
22417@item predres
22418Enable the Armv8-a Execution and Data Prediction Restriction instructions.
22419This option is only to enable the extension at the assembler level and does
22420not affect code generation. This option is enabled by default for
22421@option{-march=armv8.5-a}.
22422@item sve2
22423Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
22424instructions.
22425@item sve2-bitperm
22426Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
22427@item sve2-sm4
22428Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
22429@item sve2-aes
22430Enable SVE2 aes instructions. This also enables SVE2 instructions.
22431@item sve2-sha3
22432Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
f13e0138
RS
22433@item sve2p1
22434Enable SVE2.1 instructions. This also enables SVE2 instructions.
d77de738
ML
22435@item tme
22436Enable the Transactional Memory Extension.
22437@item i8mm
22438Enable 8-bit Integer Matrix Multiply instructions. This also enables
22439Advanced SIMD and floating-point instructions. This option is enabled by
22440default for @option{-march=armv8.6-a}. Use of this option with architectures
22441prior to Armv8.2-A is not supported.
22442@item f32mm
22443Enable 32-bit Floating point Matrix Multiply instructions. This also enables
22444SVE instructions. Use of this option with architectures prior to Armv8.2-A is
22445not supported.
22446@item f64mm
22447Enable 64-bit Floating point Matrix Multiply instructions. This also enables
22448SVE instructions. Use of this option with architectures prior to Armv8.2-A is
22449not supported.
22450@item bf16
22451Enable brain half-precision floating-point instructions. This also enables
22452Advanced SIMD and floating-point instructions. This option is enabled by
22453default for @option{-march=armv8.6-a}. Use of this option with architectures
22454prior to Armv8.2-A is not supported.
22455@item ls64
22456Enable the 64-byte atomic load and store instructions for accelerators.
d77de738
ML
22457@item mops
22458Enable the instructions to accelerate memory operations like @code{memcpy},
22459@code{memmove}, @code{memset}. This option is enabled by default for
22460@option{-march=armv8.8-a}
22461@item flagm
22462Enable the Flag Manipulation instructions Extension.
abbe2905
AC
22463@item flagm2
22464Enable the FlagM2 flag conversion instructions.
d77de738
ML
22465@item pauth
22466Enable the Pointer Authentication Extension.
d758d190
KT
22467@item cssc
22468Enable the Common Short Sequence Compression instructions.
2e021e34
KM
22469@item cmpbr
22470Enable the shorter compare and branch instructions, @code{cbb}, @code{cbh} and
22471@code{cb}.
7e04bd1f 22472@item sme
432f0dd6
ASDV
22473Enable the Scalable Matrix Extension. This is only supported when SVE2 is also
22474enabled.
4f6ab953 22475@item sme-i16i64
e6751e1d
RS
22476Enable the FEAT_SME_I16I64 extension to SME. This also enables SME
22477instructions.
4f6ab953 22478@item sme-f64f64
e6751e1d
RS
22479Enable the FEAT_SME_F64F64 extension to SME. This also enables SME
22480instructions.
c880fca6 22481@item sme2
3b58b220 22482Enable the Scalable Matrix Extension 2. This also enables SME instructions.
cdacb32b
RS
22483@item sme-b16b16
22484Enable the FEAT_SME_B16B16 extension to SME. This also enables SME2
22485and SVE_B16B16 instructions.
e6751e1d
RS
22486@item sme-f16f16
22487Enable the FEAT_SME_F16F16 extension to SME. This also enables SME2
22488instructions.
70ec3d20
RS
22489@item sme2p1
22490Enable the Scalable Matrix Extension version 2.1. This also enables SME2
22491instructions.
abbe2905
AC
22492@item fcma
22493Enable the complex number SIMD extensions.
22494@item jscvt
22495Enable the @code{fjcvtzs} JavaScript conversion instruction.
22496@item frintts
22497Enable floating-point round to integral value instructions.
22498@item wfxt
22499Enable @code{wfet} and @code{wfit} instructions.
22500@item xs
22501Enable the XS memory attribute extension.
d9ea5181
VDN
22502@item lse128
22503Enable the LSE128 128-bit atomic instructions extension. This also
22504enables LSE instructions.
16a05fac
VDN
22505@item d128
22506Enable support for 128-bit system register read/write instructions.
d9ea5181 22507This also enables the LSE128 extension.
3aba0458
VDN
22508@item gcs
22509Enable support for Armv9.4-a Guarded Control Stack extension.
16a05fac
VDN
22510@item the
22511Enable support for Armv8.9-a/9.4-a translation hardening extension.
abbe2905
AC
22512@item rcpc2
22513Enable the RCpc2 extension.
df193bda
VDN
22514@item rcpc3
22515Enable the RCpc3 (Release Consistency) extension.
72ebbc3b
CB
22516@item fp8
22517Enable the fp8 (8-bit floating point) extension.
53820407
CB
22518@item fp8fma
22519Enable the fp8 (8-bit floating point) multiply accumulate extension.
22520@item ssve-fp8fma
22521Enable the fp8 (8-bit floating point) multiply accumulate extension in streaming
22522mode.
441f8d63
CB
22523@item fp8dot4
22524Enable the fp8 (8-bit floating point) to single-precision 4-way dot product
22525extension.
22526@item ssve-fp8dot4
22527Enable the fp8 (8-bit floating point) to single-precision 4-way dot product
22528extension in streaming mode.
22529@item fp8dot2
22530Enable the fp8 (8-bit floating point) to half-precision 2-way dot product
22531extension.
22532@item ssve-fp8dot2
22533Enable the fp8 (8-bit floating point) to half-precision 2-way dot product
22534extension in streaming mode.
bfefed6c
SJ
22535@item faminmax
22536Enable the Floating Point Absolute Maximum/Minimum extension.
a07a2b8c
SJ
22537@item lut
22538Enable the Lookup Table extension.
12b7220d
AC
22539@item cpa
22540Enable the Checked Pointer Arithmetic instructions.
648fc673
RS
22541@item sve-b16b16
22542Enable the SVE non-widening brain floating-point (@code{bf16}) extension.
22543This only has an effect when @code{sve2} or @code{sme2} are also enabled.
16a05fac 22544
d77de738
ML
22545@end table
22546
22547Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
22548which implies @option{fp}.
22549Conversely, @option{nofp} implies @option{nosimd}, which implies
22550@option{nocrypto}, @option{noaes} and @option{nosha2}.
22551
22552@node Adapteva Epiphany Options
22553@subsection Adapteva Epiphany Options
22554
22555These @samp{-m} options are defined for Adapteva Epiphany:
22556
22557@table @gcctabopt
d77de738 22558@opindex mhalf-reg-file
ddf6fe37 22559@item -mhalf-reg-file
d77de738
ML
22560Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
22561That allows code to run on hardware variants that lack these registers.
22562
d77de738 22563@opindex mprefer-short-insn-regs
ddf6fe37 22564@item -mprefer-short-insn-regs
d77de738
ML
22565Preferentially allocate registers that allow short instruction generation.
22566This can result in increased instruction count, so this may either reduce or
22567increase overall code size.
22568
d77de738 22569@opindex mbranch-cost
ddf6fe37 22570@item -mbranch-cost=@var{num}
d77de738
ML
22571Set the cost of branches to roughly @var{num} ``simple'' instructions.
22572This cost is only a heuristic and is not guaranteed to produce
22573consistent results across releases.
22574
d77de738 22575@opindex mcmove
ddf6fe37 22576@item -mcmove
d77de738
ML
22577Enable the generation of conditional moves.
22578
d77de738 22579@opindex mnops
ddf6fe37 22580@item -mnops=@var{num}
d77de738
ML
22581Emit @var{num} NOPs before every other generated instruction.
22582
d77de738
ML
22583@opindex mno-soft-cmpsf
22584@opindex msoft-cmpsf
ddf6fe37 22585@item -mno-soft-cmpsf
d77de738
ML
22586For single-precision floating-point comparisons, emit an @code{fsub} instruction
22587and test the flags. This is faster than a software comparison, but can
22588get incorrect results in the presence of NaNs, or when two different small
22589numbers are compared such that their difference is calculated as zero.
22590The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
22591software comparisons.
22592
d77de738 22593@opindex mstack-offset
ddf6fe37 22594@item -mstack-offset=@var{num}
d77de738
ML
22595Set the offset between the top of the stack and the stack pointer.
22596E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
22597can be used by leaf functions without stack allocation.
22598Values other than @samp{8} or @samp{16} are untested and unlikely to work.
22599Note also that this option changes the ABI; compiling a program with a
22600different stack offset than the libraries have been compiled with
22601generally does not work.
22602This option can be useful if you want to evaluate if a different stack
22603offset would give you better code, but to actually use a different stack
22604offset to build working programs, it is recommended to configure the
22605toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
22606
d77de738
ML
22607@opindex mno-round-nearest
22608@opindex mround-nearest
ddf6fe37 22609@item -mno-round-nearest
d77de738
ML
22610Make the scheduler assume that the rounding mode has been set to
22611truncating. The default is @option{-mround-nearest}.
22612
d77de738 22613@opindex mlong-calls
ddf6fe37 22614@item -mlong-calls
d77de738
ML
22615If not otherwise specified by an attribute, assume all calls might be beyond
22616the offset range of the @code{b} / @code{bl} instructions, and therefore load the
22617function address into a register before performing a (otherwise direct) call.
22618This is the default.
22619
d77de738 22620@opindex short-calls
ddf6fe37 22621@item -mshort-calls
d77de738
ML
22622If not otherwise specified by an attribute, assume all direct calls are
22623in the range of the @code{b} / @code{bl} instructions, so use these instructions
22624for direct calls. The default is @option{-mlong-calls}.
22625
d77de738 22626@opindex msmall16
ddf6fe37 22627@item -msmall16
d77de738
ML
22628Assume addresses can be loaded as 16-bit unsigned values. This does not
22629apply to function addresses for which @option{-mlong-calls} semantics
22630are in effect.
22631
d77de738 22632@opindex mfp-mode
ddf6fe37 22633@item -mfp-mode=@var{mode}
d77de738
ML
22634Set the prevailing mode of the floating-point unit.
22635This determines the floating-point mode that is provided and expected
22636at function call and return time. Making this mode match the mode you
22637predominantly need at function start can make your programs smaller and
22638faster by avoiding unnecessary mode switches.
22639
22640@var{mode} can be set to one the following values:
22641
22642@table @samp
22643@item caller
22644Any mode at function entry is valid, and retained or restored when
22645the function returns, and when it calls other functions.
22646This mode is useful for compiling libraries or other compilation units
22647you might want to incorporate into different programs with different
22648prevailing FPU modes, and the convenience of being able to use a single
22649object file outweighs the size and speed overhead for any extra
22650mode switching that might be needed, compared with what would be needed
22651with a more specific choice of prevailing FPU mode.
22652
22653@item truncate
22654This is the mode used for floating-point calculations with
22655truncating (i.e.@: round towards zero) rounding mode. That includes
22656conversion from floating point to integer.
22657
22658@item round-nearest
22659This is the mode used for floating-point calculations with
22660round-to-nearest-or-even rounding mode.
22661
22662@item int
22663This is the mode used to perform integer calculations in the FPU, e.g.@:
22664integer multiply, or integer multiply-and-accumulate.
22665@end table
22666
22667The default is @option{-mfp-mode=caller}
22668
d77de738
ML
22669@opindex mno-split-lohi
22670@opindex msplit-lohi
22671@opindex mno-postinc
22672@opindex mpostinc
22673@opindex mno-postmodify
22674@opindex mpostmodify
ddf6fe37
AA
22675@item -mno-split-lohi
22676@itemx -mno-postinc
22677@itemx -mno-postmodify
d77de738
ML
22678Code generation tweaks that disable, respectively, splitting of 32-bit
22679loads, generation of post-increment addresses, and generation of
22680post-modify addresses. The defaults are @option{msplit-lohi},
22681@option{-mpost-inc}, and @option{-mpost-modify}.
22682
d77de738
ML
22683@opindex mno-vect-double
22684@opindex mvect-double
ddf6fe37 22685@item -mnovect-double
d77de738
ML
22686Change the preferred SIMD mode to SImode. The default is
22687@option{-mvect-double}, which uses DImode as preferred SIMD mode.
22688
d77de738 22689@opindex max-vect-align
ddf6fe37 22690@item -max-vect-align=@var{num}
d77de738
ML
22691The maximum alignment for SIMD vector mode types.
22692@var{num} may be 4 or 8. The default is 8.
22693Note that this is an ABI change, even though many library function
22694interfaces are unaffected if they don't use SIMD vector modes
22695in places that affect size and/or alignment of relevant types.
22696
d77de738 22697@opindex msplit-vecmove-early
ddf6fe37 22698@item -msplit-vecmove-early
d77de738
ML
22699Split vector moves into single word moves before reload. In theory this
22700can give better register allocation, but so far the reverse seems to be
22701generally the case.
22702
d77de738 22703@opindex m1reg-
ddf6fe37 22704@item -m1reg-@var{reg}
d77de738
ML
22705Specify a register to hold the constant @minus{}1, which makes loading small negative
22706constants and certain bitmasks faster.
22707Allowable values for @var{reg} are @samp{r43} and @samp{r63},
22708which specify use of that register as a fixed register,
22709and @samp{none}, which means that no register is used for this
22710purpose. The default is @option{-m1reg-none}.
22711
22712@end table
22713
22714@node AMD GCN Options
22715@subsection AMD GCN Options
22716@cindex AMD GCN Options
22717
22718These options are defined specifically for the AMD GCN port.
22719
22720@table @gcctabopt
22721
d77de738 22722@opindex march
d77de738 22723@opindex mtune
ddf6fe37
AA
22724@item -march=@var{gpu}
22725@itemx -mtune=@var{gpu}
d77de738
ML
22726Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
22727are
22728
22729@table @samp
d77de738
ML
22730@item gfx900
22731Compile for GCN5 Vega 10 devices (gfx900).
22732
b5a29a93
TB
22733@item gfx902
22734Compile for GCN5 Vega gfx902 devices. (Experimental)
22735
22736@item gfx904
22737Compile for GCN5 Vega gfx904 devices. (Experimental)
22738
d77de738
ML
22739@item gfx906
22740Compile for GCN5 Vega 20 devices (gfx906).
22741
22742@item gfx908
22743Compile for CDNA1 Instinct MI100 series devices (gfx908).
22744
b5a29a93
TB
22745@item gfx909
22746Compile for GCN5 Vega gfx909 devices. (Experimental)
22747
d77de738
ML
22748@item gfx90a
22749Compile for CDNA2 Instinct MI200 series devices (gfx90a).
22750
b8e9fd53
FH
22751@item gfx90c
22752Compile for GCN5 Vega 7 devices (gfx90c).
22753
37b454b7
TB
22754@item gfx942
22755Compile for CDNA3 Instinct MI300 series devices (gfx942). (Experimental)
22756
22757@item gfx950
22758Compile for the CDNA3 gfx950 devices. (Experimental)
22759
b5a29a93
TB
22760@item gfx9-generic
22761Compile generic code for Vega devices, executable on the following subset of
22762GFX9 devices: gfx900, gfx902, gfx904, gfx906, gfx909 and gfx90c. (Experimental)
22763
37b454b7
TB
22764@item gfx9-4-generic
22765Compile generic code for CDNA3 devices, executable on the following subset of
22766GFX9 devices: gfx942 and gfx950. (Experimental)
22767
56d0aba1
TB
22768@item gfx1030
22769Compile for RDNA2 gfx1030 devices (GFX10 series).
22770
b5a29a93
TB
22771@item gfx1031
22772Compile for RDNA2 gfx1031 devices (GFX10 series). (Experimental)
22773
22774@item gfx1032
22775Compile for RDNA2 gfx1032 devices (GFX10 series). (Experimental)
22776
22777@item gfx1033
22778Compile for RDNA2 gfx1033 devices (GFX10 series). (Experimental)
22779
22780@item gfx1034
22781Compile for RDNA2 gfx1034 devices (GFX10 series). (Experimental)
22782
22783@item gfx1035
22784Compile for RDNA2 gfx1035 devices (GFX10 series). (Experimental)
22785
78b56a12
RB
22786@item gfx1036
22787Compile for RDNA2 gfx1036 devices (GFX10 series).
22788
b5a29a93
TB
22789@item gfx10-3-generic
22790Compile generic code for GFX10-3 devices, executable on gfx1030,
22791gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, and gfx1036. (Experimental)
22792
56d0aba1
TB
22793@item gfx1100
22794Compile for RDNA3 gfx1100 devices (GFX11 series).
22795
b5a29a93
TB
22796@item gfx1101
22797Compile for RDNA3 gfx1101 devices (GFX11 series). (Experimental)
22798
22799@item gfx1102
22800Compile for RDNA3 gfx1102 devices (GFX11 series). (Experimental)
22801
1bf18629
AS
22802@item gfx1103
22803Compile for RDNA3 gfx1103 devices (GFX11 series).
22804
b5a29a93
TB
22805@item gfx1150
22806Compile for RDNA3 gfx1150 devices (GFX11 series). (Experimental)
22807
22808@item gfx1151
22809Compile for RDNA3 gfx1151 devices (GFX11 series). (Experimental)
22810
22811@item gfx1152
22812Compile for RDNA3 gfx1152 devices (GFX11 series). (Experimental)
22813
22814@item gfx1153
22815Compile for RDNA3 gfx1153 devices (GFX11 series). (Experimental)
22816
22817@item gfx11-generic
22818Compile generic code for GFX11 devices, executable on gfx1100, gfx1101,
22819gfx1102, gfx1103, gfx1150, gfx1151, gfx1152, and gfx1153. (Experimental)
d77de738
ML
22820@end table
22821
ddf6fe37 22822@opindex msram-ecc
d77de738
ML
22823@item -msram-ecc=on
22824@itemx -msram-ecc=off
22825@itemx -msram-ecc=any
d77de738
ML
22826Compile binaries suitable for devices with the SRAM-ECC feature enabled,
22827disabled, or either mode. This feature can be enabled per-process on some
22828devices. The compiled code must match the device mode. The default is
22829@samp{any}, for devices that support it.
22830
d77de738 22831@opindex mstack-size
ddf6fe37 22832@item -mstack-size=@var{bytes}
d77de738
ML
22833Specify how many @var{bytes} of stack space will be requested for each GPU
22834thread (wave-front). Beware that there may be many threads and limited memory
22835available. The size of the stack allocation may also have an impact on
22836run-time performance. The default is 32KB when using OpenACC or OpenMP, and
228371MB otherwise.
22838
d77de738 22839@opindex mxnack
366e3d30
TB
22840@item -mxnack=on
22841@itemx -mxnack=off
22842@itemx -mxnack=any
22843Compile binaries suitable for devices with the XNACK feature enabled, disabled,
22844or either mode. Some devices always require XNACK and some allow the user to
22845configure XNACK. The compiled code must match the device mode.
4c12bcbe
AS
22846The default is @samp{-mxnack=any} on devices that support Unified Shared
22847Memory, and @samp{-mxnack=no} otherwise.
d77de738
ML
22848
22849@end table
22850
22851@node ARC Options
22852@subsection ARC Options
22853@cindex ARC options
22854
22855The following options control the architecture variant for which code
22856is being compiled:
22857
22858@c architecture variants
22859@table @gcctabopt
22860
d77de738 22861@opindex mbarrel-shifter
ddf6fe37 22862@item -mbarrel-shifter
d77de738
ML
22863Generate instructions supported by barrel shifter. This is the default
22864unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
22865
d77de738 22866@opindex mjli-always
ddf6fe37 22867@item -mjli-always
d77de738
ML
22868Force to call a function using jli_s instruction. This option is
22869valid only for ARCv2 architecture.
22870
d77de738 22871@opindex mcpu
ddf6fe37 22872@item -mcpu=@var{cpu}
d77de738
ML
22873Set architecture type, register usage, and instruction scheduling
22874parameters for @var{cpu}. There are also shortcut alias options
22875available for backward compatibility and convenience. Supported
22876values for @var{cpu} are
22877
22878@table @samp
22879@opindex mA6
22880@opindex mARC600
22881@item arc600
22882Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
22883
d77de738 22884@opindex mARC601
ddf6fe37 22885@item arc601
d77de738
ML
22886Compile for ARC601. Alias: @option{-mARC601}.
22887
d77de738
ML
22888@opindex mA7
22889@opindex mARC700
ddf6fe37 22890@item arc700
d77de738
ML
22891Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
22892This is the default when configured with @option{--with-cpu=arc700}@.
22893
22894@item arcem
22895Compile for ARC EM.
22896
22897@item archs
22898Compile for ARC HS.
22899
22900@item em
22901Compile for ARC EM CPU with no hardware extensions.
22902
22903@item em4
22904Compile for ARC EM4 CPU.
22905
22906@item em4_dmips
22907Compile for ARC EM4 DMIPS CPU.
22908
22909@item em4_fpus
22910Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
22911extension.
22912
22913@item em4_fpuda
22914Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
22915double assist instructions.
22916
22917@item hs
22918Compile for ARC HS CPU with no hardware extensions except the atomic
22919instructions.
22920
22921@item hs34
22922Compile for ARC HS34 CPU.
22923
22924@item hs38
22925Compile for ARC HS38 CPU.
22926
22927@item hs38_linux
22928Compile for ARC HS38 CPU with all hardware extensions on.
22929
22930@item hs4x
22931Compile for ARC HS4x CPU.
22932
22933@item hs4xd
22934Compile for ARC HS4xD CPU.
22935
22936@item hs4x_rel31
22937Compile for ARC HS4x CPU release 3.10a.
22938
22939@item arc600_norm
22940Compile for ARC 600 CPU with @code{norm} instructions enabled.
22941
22942@item arc600_mul32x16
a0e64a04 22943Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
d77de738
ML
22944instructions enabled.
22945
22946@item arc600_mul64
a0e64a04 22947Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
d77de738
ML
22948instructions enabled.
22949
22950@item arc601_norm
22951Compile for ARC 601 CPU with @code{norm} instructions enabled.
22952
22953@item arc601_mul32x16
22954Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
22955instructions enabled.
22956
22957@item arc601_mul64
22958Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
22959instructions enabled.
22960
22961@item nps400
22962Compile for ARC 700 on NPS400 chip.
22963
22964@item em_mini
22965Compile for ARC EM minimalist configuration featuring reduced register
22966set.
22967
22968@end table
22969
d77de738 22970@opindex mdpfp
d77de738 22971@opindex mdpfp-compact
ddf6fe37
AA
22972@item -mdpfp
22973@itemx -mdpfp-compact
d77de738
ML
22974Generate double-precision FPX instructions, tuned for the compact
22975implementation.
22976
d77de738 22977@opindex mdpfp-fast
ddf6fe37 22978@item -mdpfp-fast
d77de738
ML
22979Generate double-precision FPX instructions, tuned for the fast
22980implementation.
22981
d77de738 22982@opindex mno-dpfp-lrsr
ddf6fe37 22983@item -mno-dpfp-lrsr
d77de738
ML
22984Disable @code{lr} and @code{sr} instructions from using FPX extension
22985aux registers.
22986
d77de738 22987@opindex mea
ddf6fe37 22988@item -mea
d77de738
ML
22989Generate extended arithmetic instructions. Currently only
22990@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
22991supported. Only valid for @option{-mcpu=ARC700}.
22992
d77de738
ML
22993@opindex mno-mpy
22994@opindex mmpy
ddf6fe37 22995@item -mno-mpy
d77de738
ML
22996Do not generate @code{mpy}-family instructions for ARC700. This option is
22997deprecated.
22998
d77de738 22999@opindex mmul32x16
ddf6fe37 23000@item -mmul32x16
d77de738
ML
23001Generate 32x16-bit multiply and multiply-accumulate instructions.
23002
d77de738 23003@opindex mmul64
ddf6fe37 23004@item -mmul64
a0e64a04 23005Generate @code{mul64} and @code{mulu64} instructions.
d77de738
ML
23006Only valid for @option{-mcpu=ARC600}.
23007
d77de738 23008@opindex mnorm
ddf6fe37 23009@item -mnorm
d77de738
ML
23010Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
23011is in effect.
23012
d77de738 23013@opindex mspfp
d77de738 23014@opindex mspfp-compact
ddf6fe37
AA
23015@item -mspfp
23016@itemx -mspfp-compact
d77de738
ML
23017Generate single-precision FPX instructions, tuned for the compact
23018implementation.
23019
d77de738 23020@opindex mspfp-fast
ddf6fe37 23021@item -mspfp-fast
d77de738
ML
23022Generate single-precision FPX instructions, tuned for the fast
23023implementation.
23024
d77de738 23025@opindex msimd
ddf6fe37 23026@item -msimd
d77de738
ML
23027Enable generation of ARC SIMD instructions via target-specific
23028builtins. Only valid for @option{-mcpu=ARC700}.
23029
d77de738 23030@opindex msoft-float
ddf6fe37 23031@item -msoft-float
d77de738
ML
23032This option ignored; it is provided for compatibility purposes only.
23033Software floating-point code is emitted by default, and this default
23034can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
23035@option{-mspfp-fast} for single precision, and @option{-mdpfp},
23036@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
23037
d77de738 23038@opindex mswap
ddf6fe37 23039@item -mswap
d77de738
ML
23040Generate @code{swap} instructions.
23041
d77de738 23042@opindex matomic
ddf6fe37 23043@item -matomic
d77de738
ML
23044This enables use of the locked load/store conditional extension to implement
23045atomic memory built-in functions. Not available for ARC 6xx or ARC
23046EM cores.
23047
d77de738 23048@opindex mdiv-rem
ddf6fe37 23049@item -mdiv-rem
d77de738
ML
23050Enable @code{div} and @code{rem} instructions for ARCv2 cores.
23051
d77de738 23052@opindex mcode-density
ddf6fe37 23053@item -mcode-density
a0e64a04 23054Enable code density instructions for ARC EM.
d77de738
ML
23055This option is on by default for ARC HS.
23056
d77de738 23057@opindex mll64
ddf6fe37 23058@item -mll64
d77de738
ML
23059Enable double load/store operations for ARC HS cores.
23060
d77de738 23061@opindex mtp-regno
ddf6fe37 23062@item -mtp-regno=@var{regno}
d77de738
ML
23063Specify thread pointer register number.
23064
d77de738 23065@opindex mmpy-option
ddf6fe37 23066@item -mmpy-option=@var{multo}
a0e64a04
PN
23067Compile ARCv2 code with a multiplier design option. You can specify
23068the option using either a string or numeric value for @var{multo}.
d77de738
ML
23069@samp{wlh1} is the default value. The recognized values are:
23070
23071@table @samp
23072@item 0
23073@itemx none
23074No multiplier available.
23075
23076@item 1
23077@itemx w
2307816x16 multiplier, fully pipelined.
23079The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
23080
23081@item 2
23082@itemx wlh1
2308332x32 multiplier, fully
23084pipelined (1 stage). The following instructions are additionally
23085enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23086
23087@item 3
23088@itemx wlh2
2308932x32 multiplier, fully pipelined
23090(2 stages). The following instructions are additionally enabled: @code{mpy},
23091@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23092
23093@item 4
23094@itemx wlh3
23095Two 16x16 multipliers, blocking,
23096sequential. The following instructions are additionally enabled: @code{mpy},
23097@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23098
23099@item 5
23100@itemx wlh4
23101One 16x16 multiplier, blocking,
23102sequential. The following instructions are additionally enabled: @code{mpy},
23103@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23104
23105@item 6
23106@itemx wlh5
23107One 32x4 multiplier, blocking,
23108sequential. The following instructions are additionally enabled: @code{mpy},
23109@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23110
23111@item 7
23112@itemx plus_dmpy
23113ARC HS SIMD support.
23114
23115@item 8
23116@itemx plus_macd
23117ARC HS SIMD support.
23118
23119@item 9
23120@itemx plus_qmacw
23121ARC HS SIMD support.
23122
23123@end table
23124
23125This option is only available for ARCv2 cores@.
23126
d77de738 23127@opindex mfpu
ddf6fe37 23128@item -mfpu=@var{fpu}
d77de738
ML
23129Enables support for specific floating-point hardware extensions for ARCv2
23130cores. Supported values for @var{fpu} are:
23131
23132@table @samp
23133
23134@item fpus
23135Enables support for single-precision floating-point hardware
23136extensions@.
23137
23138@item fpud
23139Enables support for double-precision floating-point hardware
23140extensions. The single-precision floating-point extension is also
23141enabled. Not available for ARC EM@.
23142
23143@item fpuda
23144Enables support for double-precision floating-point hardware
23145extensions using double-precision assist instructions. The single-precision
23146floating-point extension is also enabled. This option is
23147only available for ARC EM@.
23148
23149@item fpuda_div
23150Enables support for double-precision floating-point hardware
23151extensions using double-precision assist instructions.
a0e64a04 23152The single-precision floating-point, square-root, and divide
d77de738
ML
23153extensions are also enabled. This option is
23154only available for ARC EM@.
23155
23156@item fpuda_fma
23157Enables support for double-precision floating-point hardware
23158extensions using double-precision assist instructions.
a0e64a04 23159The single-precision floating-point and fused multiply and add
d77de738
ML
23160hardware extensions are also enabled. This option is
23161only available for ARC EM@.
23162
23163@item fpuda_all
23164Enables support for double-precision floating-point hardware
23165extensions using double-precision assist instructions.
23166All single-precision floating-point hardware extensions are also
23167enabled. This option is only available for ARC EM@.
23168
23169@item fpus_div
a0e64a04 23170Enables support for single-precision floating-point, square-root and divide
d77de738
ML
23171hardware extensions@.
23172
23173@item fpud_div
a0e64a04 23174Enables support for double-precision floating-point, square-root and divide
d77de738
ML
23175hardware extensions. This option
23176includes option @samp{fpus_div}. Not available for ARC EM@.
23177
23178@item fpus_fma
a0e64a04 23179Enables support for single-precision floating-point and
d77de738
ML
23180fused multiply and add hardware extensions@.
23181
23182@item fpud_fma
a0e64a04 23183Enables support for double-precision floating-point and
d77de738
ML
23184fused multiply and add hardware extensions. This option
23185includes option @samp{fpus_fma}. Not available for ARC EM@.
23186
23187@item fpus_all
23188Enables support for all single-precision floating-point hardware
23189extensions@.
23190
23191@item fpud_all
23192Enables support for all single- and double-precision floating-point
23193hardware extensions. Not available for ARC EM@.
23194
23195@end table
23196
d77de738 23197@opindex mirq-ctrl-saved
ddf6fe37 23198@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
23199Specifies general-purposes registers that the processor automatically
23200saves/restores on interrupt entry and exit. @var{register-range} is
23201specified as two registers separated by a dash. The register range
23202always starts with @code{r0}, the upper limit is @code{fp} register.
23203@var{blink} and @var{lp_count} are optional. This option is only
23204valid for ARC EM and ARC HS cores.
23205
d77de738 23206@opindex mrgf-banked-regs
ddf6fe37 23207@item -mrgf-banked-regs=@var{number}
d77de738
ML
23208Specifies the number of registers replicated in second register bank
23209on entry to fast interrupt. Fast interrupts are interrupts with the
23210highest priority level P0. These interrupts save only PC and STATUS32
23211registers to avoid memory transactions during interrupt entry and exit
23212sequences. Use this option when you are using fast interrupts in an
23213ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
23214
d77de738 23215@opindex mlpc-width
ddf6fe37 23216@item -mlpc-width=@var{width}
d77de738
ML
23217Specify the width of the @code{lp_count} register. Valid values for
23218@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
23219fixed to 32 bits. If the width is less than 32, the compiler does not
23220attempt to transform loops in your program to use the zero-delay loop
23221mechanism unless it is known that the @code{lp_count} register can
23222hold the required loop-counter value. Depending on the width
23223specified, the compiler and run-time library might continue to use the
23224loop mechanism for various needs. This option defines macro
23225@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
23226
d77de738 23227@opindex mrf16
ddf6fe37 23228@item -mrf16
d77de738
ML
23229This option instructs the compiler to generate code for a 16-entry
23230register file. This option defines the @code{__ARC_RF16__}
23231preprocessor macro.
23232
d77de738 23233@opindex mbranch-index
ddf6fe37 23234@item -mbranch-index
d77de738
ML
23235Enable use of @code{bi} or @code{bih} instructions to implement jump
23236tables.
23237
23238@end table
23239
23240The following options are passed through to the assembler, and also
23241define preprocessor macro symbols.
23242
23243@c Flags used by the assembler, but for which we define preprocessor
23244@c macro symbols as well.
23245@table @gcctabopt
d77de738 23246@opindex mdsp-packa
ddf6fe37 23247@item -mdsp-packa
d77de738
ML
23248Passed down to the assembler to enable the DSP Pack A extensions.
23249Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
23250deprecated.
23251
d77de738 23252@opindex mdvbf
ddf6fe37 23253@item -mdvbf
d77de738
ML
23254Passed down to the assembler to enable the dual Viterbi butterfly
23255extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
23256option is deprecated.
23257
23258@c ARC700 4.10 extension instruction
d77de738 23259@opindex mlock
ddf6fe37 23260@item -mlock
d77de738
ML
23261Passed down to the assembler to enable the locked load/store
23262conditional extension. Also sets the preprocessor symbol
23263@code{__Xlock}.
23264
d77de738 23265@opindex mmac-d16
ddf6fe37 23266@item -mmac-d16
d77de738
ML
23267Passed down to the assembler. Also sets the preprocessor symbol
23268@code{__Xxmac_d16}. This option is deprecated.
23269
d77de738 23270@opindex mmac-24
ddf6fe37 23271@item -mmac-24
d77de738
ML
23272Passed down to the assembler. Also sets the preprocessor symbol
23273@code{__Xxmac_24}. This option is deprecated.
23274
23275@c ARC700 4.10 extension instruction
d77de738 23276@opindex mrtsc
ddf6fe37 23277@item -mrtsc
d77de738
ML
23278Passed down to the assembler to enable the 64-bit time-stamp counter
23279extension instruction. Also sets the preprocessor symbol
23280@code{__Xrtsc}. This option is deprecated.
23281
23282@c ARC700 4.10 extension instruction
d77de738 23283@opindex mswape
ddf6fe37 23284@item -mswape
d77de738
ML
23285Passed down to the assembler to enable the swap byte ordering
23286extension instruction. Also sets the preprocessor symbol
23287@code{__Xswape}.
23288
d77de738 23289@opindex mtelephony
ddf6fe37 23290@item -mtelephony
d77de738
ML
23291Passed down to the assembler to enable dual- and single-operand
23292instructions for telephony. Also sets the preprocessor symbol
23293@code{__Xtelephony}. This option is deprecated.
23294
d77de738 23295@opindex mxy
ddf6fe37 23296@item -mxy
d77de738
ML
23297Passed down to the assembler to enable the XY memory extension. Also
23298sets the preprocessor symbol @code{__Xxy}.
23299
23300@end table
23301
23302The following options control how the assembly code is annotated:
23303
23304@c Assembly annotation options
23305@table @gcctabopt
d77de738 23306@opindex misize
ddf6fe37 23307@item -misize
d77de738
ML
23308Annotate assembler instructions with estimated addresses.
23309
d77de738 23310@opindex mannotate-align
ddf6fe37 23311@item -mannotate-align
e4b19406 23312Does nothing. Preserved for backward compatibility.
d77de738
ML
23313
23314@end table
23315
23316The following options are passed through to the linker:
23317
23318@c options passed through to the linker
23319@table @gcctabopt
d77de738 23320@opindex marclinux
ddf6fe37 23321@item -marclinux
d77de738
ML
23322Passed through to the linker, to specify use of the @code{arclinux} emulation.
23323This option is enabled by default in tool chains built for
23324@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
23325when profiling is not requested.
23326
d77de738 23327@opindex marclinux_prof
ddf6fe37 23328@item -marclinux_prof
d77de738
ML
23329Passed through to the linker, to specify use of the
23330@code{arclinux_prof} emulation. This option is enabled by default in
23331tool chains built for @w{@code{arc-linux-uclibc}} and
23332@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
23333
23334@end table
23335
23336The following options control the semantics of generated code:
23337
23338@c semantically relevant code generation options
23339@table @gcctabopt
d77de738 23340@opindex mlong-calls
ddf6fe37 23341@item -mlong-calls
d77de738
ML
23342Generate calls as register indirect calls, thus providing access
23343to the full 32-bit address range.
23344
d77de738 23345@opindex mmedium-calls
ddf6fe37 23346@item -mmedium-calls
d77de738
ML
23347Don't use less than 25-bit addressing range for calls, which is the
23348offset available for an unconditional branch-and-link
23349instruction. Conditional execution of function calls is suppressed, to
23350allow use of the 25-bit range, rather than the 21-bit range with
23351conditional branch-and-link. This is the default for tool chains built
23352for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
23353
d77de738 23354@opindex G
ddf6fe37 23355@item -G @var{num}
d77de738
ML
23356Put definitions of externally-visible data in a small data section if
23357that data is no bigger than @var{num} bytes. The default value of
23358@var{num} is 4 for any ARC configuration, or 8 when we have double
23359load/store operations.
23360
d77de738
ML
23361@opindex mno-sdata
23362@opindex msdata
ddf6fe37 23363@item -mno-sdata
d77de738
ML
23364Do not generate sdata references. This is the default for tool chains
23365built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
23366targets.
23367
d77de738 23368@opindex mvolatile-cache
ddf6fe37 23369@item -mvolatile-cache
d77de738
ML
23370Use ordinarily cached memory accesses for volatile references. This is the
23371default.
23372
d77de738
ML
23373@opindex mno-volatile-cache
23374@opindex mvolatile-cache
ddf6fe37 23375@item -mno-volatile-cache
d77de738
ML
23376Enable cache bypass for volatile references.
23377
23378@end table
23379
23380The following options fine tune code generation:
23381@c code generation tuning options
23382@table @gcctabopt
d77de738 23383@opindex malign-call
ddf6fe37 23384@item -malign-call
d77de738
ML
23385Does nothing. Preserved for backward compatibility.
23386
d77de738 23387@opindex mauto-modify-reg
ddf6fe37 23388@item -mauto-modify-reg
d77de738
ML
23389Enable the use of pre/post modify with register displacement.
23390
d77de738 23391@opindex mbbit-peephole
ddf6fe37 23392@item -mbbit-peephole
07f7615c 23393Does nothing. Preserved for backward compatibility.
d77de738 23394
d77de738 23395@opindex mno-brcc
ddf6fe37 23396@item -mno-brcc
d77de738 23397This option disables a target-specific pass in @file{arc_reorg} to
a0e64a04 23398generate compare-and-branch (@code{br@var{cc}}) instructions.
d77de738
ML
23399It has no effect on
23400generation of these instructions driven by the combiner pass.
23401
d77de738 23402@opindex mcase-vector-pcrel
ddf6fe37 23403@item -mcase-vector-pcrel
d77de738
ML
23404Use PC-relative switch case tables to enable case table shortening.
23405This is the default for @option{-Os}.
23406
d77de738 23407@opindex mcompact-casesi
ddf6fe37 23408@item -mcompact-casesi
d77de738
ML
23409Enable compact @code{casesi} pattern. This is the default for @option{-Os},
23410and only available for ARCv1 cores. This option is deprecated.
23411
d77de738 23412@opindex mno-cond-exec
ddf6fe37 23413@item -mno-cond-exec
a0e64a04 23414Disable the ARCompact-specific pass to generate conditional
d77de738
ML
23415execution instructions.
23416
23417Due to delay slot scheduling and interactions between operand numbers,
23418literal sizes, instruction lengths, and the support for conditional execution,
23419the target-independent pass to generate conditional execution is often lacking,
23420so the ARC port has kept a special pass around that tries to find more
23421conditional execution generation opportunities after register allocation,
23422branch shortening, and delay slot scheduling have been done. This pass
23423generally, but not always, improves performance and code size, at the cost of
23424extra compilation time, which is why there is an option to switch it off.
23425If you have a problem with call instructions exceeding their allowable
23426offset range because they are conditionalized, you should consider using
23427@option{-mmedium-calls} instead.
23428
d77de738 23429@opindex mearly-cbranchsi
ddf6fe37 23430@item -mearly-cbranchsi
d77de738
ML
23431Enable pre-reload use of the @code{cbranchsi} pattern.
23432
d77de738 23433@opindex mexpand-adddi
ddf6fe37 23434@item -mexpand-adddi
d77de738
ML
23435Expand @code{adddi3} and @code{subdi3} at RTL generation time into
23436@code{add.f}, @code{adc} etc. This option is deprecated.
23437
d77de738 23438@opindex mindexed-loads
ddf6fe37 23439@item -mindexed-loads
d77de738
ML
23440Enable the use of indexed loads. This can be problematic because some
23441optimizers then assume that indexed stores exist, which is not
23442the case.
23443
d77de738 23444@opindex mlra
ddf6fe37 23445@item -mlra
ffd861c8 23446Does nothing. Preserved for backward compatibility.
d77de738 23447
d77de738 23448@opindex mlra-priority-none
ddf6fe37 23449@item -mlra-priority-none
d77de738
ML
23450Don't indicate any priority for target registers.
23451
d77de738 23452@opindex mlra-priority-compact
ddf6fe37 23453@item -mlra-priority-compact
d77de738
ML
23454Indicate target register priority for r0..r3 / r12..r15.
23455
d77de738 23456@opindex mlra-priority-noncompact
ddf6fe37 23457@item -mlra-priority-noncompact
d77de738
ML
23458Reduce target register priority for r0..r3 / r12..r15.
23459
d77de738 23460@opindex mmillicode
ddf6fe37 23461@item -mmillicode
d77de738
ML
23462When optimizing for size (using @option{-Os}), prologues and epilogues
23463that have to save or restore a large number of registers are often
23464shortened by using call to a special function in libgcc; this is
23465referred to as a @emph{millicode} call. As these calls can pose
23466performance issues, and/or cause linking issues when linking in a
23467nonstandard way, this option is provided to turn on or off millicode
23468call generation.
23469
d77de738 23470@opindex mcode-density-frame
ddf6fe37 23471@item -mcode-density-frame
d77de738
ML
23472This option enable the compiler to emit @code{enter} and @code{leave}
23473instructions. These instructions are only valid for CPUs with
23474code-density feature.
23475
d77de738 23476@opindex mmixed-code
ddf6fe37 23477@item -mmixed-code
d77de738
ML
23478Does nothing. Preserved for backward compatibility.
23479
d77de738 23480@opindex mq-class
ddf6fe37 23481@item -mq-class
d77de738
ML
23482Ths option is deprecated. Enable @samp{q} instruction alternatives.
23483This is the default for @option{-Os}.
23484
d77de738 23485@opindex mRcq
ddf6fe37 23486@item -mRcq
d77de738
ML
23487Does nothing. Preserved for backward compatibility.
23488
d77de738 23489@opindex mRcw
ddf6fe37 23490@item -mRcw
d77de738
ML
23491Does nothing. Preserved for backward compatibility.
23492
d77de738 23493@opindex msize-level
ddf6fe37 23494@item -msize-level=@var{level}
d77de738
ML
23495Fine-tune size optimization with regards to instruction lengths and alignment.
23496The recognized values for @var{level} are:
23497@table @samp
23498@item 0
23499No size optimization. This level is deprecated and treated like @samp{1}.
23500
23501@item 1
23502Short instructions are used opportunistically.
23503
23504@item 2
23505In addition, alignment of loops and of code after barriers are dropped.
23506
23507@item 3
23508In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
23509
23510@end table
23511
23512This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
23513the behavior when this is not set is equivalent to level @samp{1}.
23514
d77de738 23515@opindex mtune
ddf6fe37 23516@item -mtune=@var{cpu}
d77de738
ML
23517Set instruction scheduling parameters for @var{cpu}, overriding any implied
23518by @option{-mcpu=}.
23519
23520Supported values for @var{cpu} are
23521
23522@table @samp
23523@item ARC600
23524Tune for ARC600 CPU.
23525
23526@item ARC601
23527Tune for ARC601 CPU.
23528
23529@item ARC700
23530Tune for ARC700 CPU with standard multiplier block.
23531
23532@item ARC700-xmac
23533Tune for ARC700 CPU with XMAC block.
23534
23535@item ARC725D
23536Tune for ARC725D CPU.
23537
23538@item ARC750D
23539Tune for ARC750D CPU.
23540
23541@item core3
23542Tune for ARCv2 core3 type CPU. This option enable usage of
23543@code{dbnz} instruction.
23544
23545@item release31a
23546Tune for ARC4x release 3.10a.
23547
23548@end table
23549
d77de738 23550@opindex mmultcost
ddf6fe37 23551@item -mmultcost=@var{num}
d77de738
ML
23552Cost to assume for a multiply instruction, with @samp{4} being equal to a
23553normal instruction.
23554
d77de738 23555@opindex munalign-prob-threshold
ddf6fe37 23556@item -munalign-prob-threshold=@var{probability}
d77de738
ML
23557Does nothing. Preserved for backward compatibility.
23558
23559@end table
23560
23561The following options are maintained for backward compatibility, but
23562are now deprecated and will be removed in a future release:
23563
23564@c Deprecated options
23565@table @gcctabopt
23566
d77de738 23567@opindex margonaut
ddf6fe37 23568@item -margonaut
d77de738
ML
23569Obsolete FPX.
23570
d77de738 23571@opindex mbig-endian
d77de738 23572@opindex EB
ddf6fe37
AA
23573@item -mbig-endian
23574@itemx -EB
d77de738
ML
23575Compile code for big-endian targets. Use of these options is now
23576deprecated. Big-endian code is supported by configuring GCC to build
23577@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
23578for which big endian is the default.
23579
d77de738 23580@opindex mlittle-endian
d77de738 23581@opindex EL
ddf6fe37
AA
23582@item -mlittle-endian
23583@itemx -EL
d77de738 23584Compile code for little-endian targets. Use of these options is now
a0e64a04 23585deprecated. Little-endian code is supported by configuring GCC to build
d77de738
ML
23586@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
23587for which little endian is the default.
23588
d77de738 23589@opindex mbarrel_shifter
ddf6fe37 23590@item -mbarrel_shifter
d77de738
ML
23591Replaced by @option{-mbarrel-shifter}.
23592
d77de738 23593@opindex mdpfp_compact
ddf6fe37 23594@item -mdpfp_compact
d77de738
ML
23595Replaced by @option{-mdpfp-compact}.
23596
d77de738 23597@opindex mdpfp_fast
ddf6fe37 23598@item -mdpfp_fast
d77de738
ML
23599Replaced by @option{-mdpfp-fast}.
23600
d77de738 23601@opindex mdsp_packa
ddf6fe37 23602@item -mdsp_packa
d77de738
ML
23603Replaced by @option{-mdsp-packa}.
23604
d77de738 23605@opindex mEA
ddf6fe37 23606@item -mEA
d77de738
ML
23607Replaced by @option{-mea}.
23608
d77de738 23609@opindex mmac_24
ddf6fe37 23610@item -mmac_24
d77de738
ML
23611Replaced by @option{-mmac-24}.
23612
d77de738 23613@opindex mmac_d16
ddf6fe37 23614@item -mmac_d16
d77de738
ML
23615Replaced by @option{-mmac-d16}.
23616
d77de738 23617@opindex mspfp_compact
ddf6fe37 23618@item -mspfp_compact
d77de738
ML
23619Replaced by @option{-mspfp-compact}.
23620
d77de738 23621@opindex mspfp_fast
ddf6fe37 23622@item -mspfp_fast
d77de738
ML
23623Replaced by @option{-mspfp-fast}.
23624
d77de738 23625@opindex mtune
ddf6fe37 23626@item -mtune=@var{cpu}
d77de738
ML
23627Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
23628@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
23629@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
23630
d77de738 23631@opindex multcost
ddf6fe37 23632@item -multcost=@var{num}
d77de738
ML
23633Replaced by @option{-mmultcost}.
23634
23635@end table
23636
23637@node ARM Options
23638@subsection ARM Options
23639@cindex ARM options
23640
23641These @samp{-m} options are defined for the ARM port:
23642
23643@table @gcctabopt
d77de738 23644@opindex mabi
ddf6fe37 23645@item -mabi=@var{name}
d77de738 23646Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
5314f159 23647@samp{atpcs}, @samp{aapcs} and @samp{aapcs-linux}.
d77de738 23648
d77de738 23649@opindex mapcs-frame
ddf6fe37 23650@item -mapcs-frame
d77de738
ML
23651Generate a stack frame that is compliant with the ARM Procedure Call
23652Standard for all functions, even if this is not strictly necessary for
23653correct execution of the code. Specifying @option{-fomit-frame-pointer}
23654with this option causes the stack frames not to be generated for
23655leaf functions. The default is @option{-mno-apcs-frame}.
23656This option is deprecated.
23657
d77de738 23658@opindex mapcs
ddf6fe37 23659@item -mapcs
d77de738
ML
23660This is a synonym for @option{-mapcs-frame} and is deprecated.
23661
23662@ignore
23663@c not currently implemented
d77de738 23664@opindex mapcs-stack-check
ddf6fe37 23665@item -mapcs-stack-check
d77de738
ML
23666Generate code to check the amount of stack space available upon entry to
23667every function (that actually uses some stack space). If there is
23668insufficient space available then either the function
23669@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
23670called, depending upon the amount of stack space required. The runtime
23671system is required to provide these functions. The default is
23672@option{-mno-apcs-stack-check}, since this produces smaller code.
23673
23674@c not currently implemented
d77de738 23675@opindex mapcs-reentrant
ddf6fe37 23676@item -mapcs-reentrant
d77de738
ML
23677Generate reentrant, position-independent code. The default is
23678@option{-mno-apcs-reentrant}.
23679@end ignore
23680
d77de738 23681@opindex mthumb-interwork
ddf6fe37 23682@item -mthumb-interwork
d77de738
ML
23683Generate code that supports calling between the ARM and Thumb
23684instruction sets. Without this option, on pre-v5 architectures, the
23685two instruction sets cannot be reliably used inside one program. The
23686default is @option{-mno-thumb-interwork}, since slightly larger code
23687is generated when @option{-mthumb-interwork} is specified. In AAPCS
23688configurations this option is meaningless.
23689
d77de738
ML
23690@opindex mno-sched-prolog
23691@opindex msched-prolog
ddf6fe37 23692@item -mno-sched-prolog
d77de738
ML
23693Prevent the reordering of instructions in the function prologue, or the
23694merging of those instruction with the instructions in the function's
23695body. This means that all functions start with a recognizable set
23696of instructions (or in fact one of a choice from a small set of
23697different function prologues), and this information can be used to
23698locate the start of functions inside an executable piece of code. The
23699default is @option{-msched-prolog}.
23700
d77de738 23701@opindex mfloat-abi
ddf6fe37 23702@item -mfloat-abi=@var{name}
d77de738
ML
23703Specifies which floating-point ABI to use. Permissible values
23704are: @samp{soft}, @samp{softfp} and @samp{hard}.
23705
23706Specifying @samp{soft} causes GCC to generate output containing
23707library calls for floating-point operations.
23708@samp{softfp} allows the generation of code using hardware floating-point
23709instructions, but still uses the soft-float calling conventions.
23710@samp{hard} allows generation of floating-point instructions
23711and uses FPU-specific calling conventions.
23712
23713The default depends on the specific target configuration. Note that
23714the hard-float and soft-float ABIs are not link-compatible; you must
23715compile your entire program with the same ABI, and link with a
23716compatible set of libraries.
23717
d77de738 23718@opindex mgeneral-regs-only
ddf6fe37 23719@item -mgeneral-regs-only
d77de738
ML
23720Generate code which uses only the general-purpose registers. This will prevent
23721the compiler from using floating-point and Advanced SIMD registers but will not
23722impose any restrictions on the assembler.
23723
d77de738 23724@opindex mlittle-endian
ddf6fe37 23725@item -mlittle-endian
d77de738
ML
23726Generate code for a processor running in little-endian mode. This is
23727the default for all standard configurations.
23728
d77de738 23729@opindex mbig-endian
ddf6fe37 23730@item -mbig-endian
d77de738
ML
23731Generate code for a processor running in big-endian mode; the default is
23732to compile code for a little-endian processor.
23733
ddf6fe37 23734@opindex mbe8
d77de738
ML
23735@item -mbe8
23736@itemx -mbe32
d77de738
ML
23737When linking a big-endian image select between BE8 and BE32 formats.
23738The option has no effect for little-endian images and is ignored. The
23739default is dependent on the selected target architecture. For ARMv6
23740and later architectures the default is BE8, for older architectures
23741the default is BE32. BE32 format has been deprecated by ARM.
23742
d77de738 23743@opindex march
ddf6fe37 23744@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
23745This specifies the name of the target ARM architecture. GCC uses this
23746name to determine what kind of instructions it can emit when generating
23747assembly code. This option can be used in conjunction with or instead
23748of the @option{-mcpu=} option.
23749
23750Permissible names are:
23751@samp{armv4t},
23752@samp{armv5t}, @samp{armv5te},
23753@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
23754@samp{armv6z}, @samp{armv6zk},
a0e64a04 23755@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
d77de738
ML
23756@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
23757@samp{armv8.4-a},
23758@samp{armv8.5-a},
23759@samp{armv8.6-a},
23760@samp{armv9-a},
23761@samp{armv7-r},
23762@samp{armv8-r},
23763@samp{armv6-m}, @samp{armv6s-m},
23764@samp{armv7-m}, @samp{armv7e-m},
23765@samp{armv8-m.base}, @samp{armv8-m.main},
23766@samp{armv8.1-m.main},
d77de738
ML
23767@samp{iwmmxt} and @samp{iwmmxt2}.
23768
23769Additionally, the following architectures, which lack support for the
23770Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
23771
23772Many of the architectures support extensions. These can be added by
23773appending @samp{+@var{extension}} to the architecture name. Extension
23774options are processed in order and capabilities accumulate. An extension
23775will also enable any necessary base extensions
23776upon which it depends. For example, the @samp{+crypto} extension
23777will always enable the @samp{+simd} extension. The exception to the
23778additive construction is for extensions that are prefixed with
23779@samp{+no@dots{}}: these extensions disable the specified option and
23780any other extensions that may depend on the presence of that
23781extension.
23782
23783For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
23784writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
23785entirely disabled by the @samp{+nofp} option that follows it.
23786
23787Most extension names are generically named, but have an effect that is
23788dependent upon the architecture to which it is applied. For example,
23789the @samp{+simd} option can be applied to both @samp{armv7-a} and
23790@samp{armv8-a} architectures, but will enable the original ARMv7-A
23791Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
23792variant for @samp{armv8-a}.
23793
23794The table below lists the supported extensions for each architecture.
23795Architectures not mentioned do not support any extensions.
23796
23797@table @samp
23798@item armv5te
23799@itemx armv6
23800@itemx armv6j
23801@itemx armv6k
23802@itemx armv6kz
23803@itemx armv6t2
23804@itemx armv6z
23805@itemx armv6zk
23806@table @samp
23807@item +fp
23808The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
23809used as an alias for this extension.
23810
23811@item +nofp
23812Disable the floating-point instructions.
23813@end table
23814
23815@item armv7
23816The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
23817@table @samp
23818@item +fp
23819The VFPv3 floating-point instructions, with 16 double-precision
23820registers. The extension @samp{+vfpv3-d16} can be used as an alias
23821for this extension. Note that floating-point is not supported by the
23822base ARMv7-M architecture, but is compatible with both the ARMv7-A and
23823ARMv7-R architectures.
23824
23825@item +nofp
23826Disable the floating-point instructions.
23827@end table
23828
23829@item armv7-a
23830@table @samp
23831@item +mp
23832The multiprocessing extension.
23833
23834@item +sec
23835The security extension.
23836
23837@item +fp
23838The VFPv3 floating-point instructions, with 16 double-precision
23839registers. The extension @samp{+vfpv3-d16} can be used as an alias
23840for this extension.
23841
23842@item +simd
23843The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
23844The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
23845for this extension.
23846
23847@item +vfpv3
23848The VFPv3 floating-point instructions, with 32 double-precision
23849registers.
23850
23851@item +vfpv3-d16-fp16
23852The VFPv3 floating-point instructions, with 16 double-precision
23853registers and the half-precision floating-point conversion operations.
23854
23855@item +vfpv3-fp16
23856The VFPv3 floating-point instructions, with 32 double-precision
23857registers and the half-precision floating-point conversion operations.
23858
23859@item +vfpv4-d16
23860The VFPv4 floating-point instructions, with 16 double-precision
23861registers.
23862
23863@item +vfpv4
23864The VFPv4 floating-point instructions, with 32 double-precision
23865registers.
23866
23867@item +neon-fp16
23868The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
23869the half-precision floating-point conversion operations.
23870
23871@item +neon-vfpv4
23872The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
23873
23874@item +nosimd
23875Disable the Advanced SIMD instructions (does not disable floating point).
23876
23877@item +nofp
23878Disable the floating-point and Advanced SIMD instructions.
23879@end table
23880
23881@item armv7ve
23882The extended version of the ARMv7-A architecture with support for
23883virtualization.
23884@table @samp
23885@item +fp
23886The VFPv4 floating-point instructions, with 16 double-precision registers.
23887The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
23888
23889@item +simd
23890The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
23891extension @samp{+neon-vfpv4} can be used as an alias for this extension.
23892
23893@item +vfpv3-d16
23894The VFPv3 floating-point instructions, with 16 double-precision
23895registers.
23896
23897@item +vfpv3
23898The VFPv3 floating-point instructions, with 32 double-precision
23899registers.
23900
23901@item +vfpv3-d16-fp16
23902The VFPv3 floating-point instructions, with 16 double-precision
23903registers and the half-precision floating-point conversion operations.
23904
23905@item +vfpv3-fp16
23906The VFPv3 floating-point instructions, with 32 double-precision
23907registers and the half-precision floating-point conversion operations.
23908
23909@item +vfpv4-d16
23910The VFPv4 floating-point instructions, with 16 double-precision
23911registers.
23912
23913@item +vfpv4
23914The VFPv4 floating-point instructions, with 32 double-precision
23915registers.
23916
23917@item +neon
23918The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
23919The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
23920
23921@item +neon-fp16
23922The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
23923the half-precision floating-point conversion operations.
23924
23925@item +nosimd
23926Disable the Advanced SIMD instructions (does not disable floating point).
23927
23928@item +nofp
23929Disable the floating-point and Advanced SIMD instructions.
23930@end table
23931
23932@item armv8-a
23933@table @samp
23934@item +crc
23935The Cyclic Redundancy Check (CRC) instructions.
23936@item +simd
23937The ARMv8-A Advanced SIMD and floating-point instructions.
23938@item +crypto
23939The cryptographic instructions.
23940@item +nocrypto
23941Disable the cryptographic instructions.
23942@item +nofp
23943Disable the floating-point, Advanced SIMD and cryptographic instructions.
23944@item +sb
23945Speculation Barrier Instruction.
23946@item +predres
23947Execution and Data Prediction Restriction Instructions.
23948@end table
23949
23950@item armv8.1-a
23951@table @samp
23952@item +simd
23953The ARMv8.1-A Advanced SIMD and floating-point instructions.
23954
23955@item +crypto
23956The cryptographic instructions. This also enables the Advanced SIMD and
23957floating-point instructions.
23958
23959@item +nocrypto
23960Disable the cryptographic instructions.
23961
23962@item +nofp
23963Disable the floating-point, Advanced SIMD and cryptographic instructions.
23964
23965@item +sb
23966Speculation Barrier Instruction.
23967
23968@item +predres
23969Execution and Data Prediction Restriction Instructions.
23970@end table
23971
23972@item armv8.2-a
23973@itemx armv8.3-a
23974@table @samp
23975@item +fp16
23976The half-precision floating-point data processing instructions.
23977This also enables the Advanced SIMD and floating-point instructions.
23978
23979@item +fp16fml
23980The half-precision floating-point fmla extension. This also enables
23981the half-precision floating-point extension and Advanced SIMD and
23982floating-point instructions.
23983
23984@item +simd
23985The ARMv8.1-A Advanced SIMD and floating-point instructions.
23986
23987@item +crypto
23988The cryptographic instructions. This also enables the Advanced SIMD and
23989floating-point instructions.
23990
23991@item +dotprod
23992Enable the Dot Product extension. This also enables Advanced SIMD instructions.
23993
23994@item +nocrypto
23995Disable the cryptographic extension.
23996
23997@item +nofp
23998Disable the floating-point, Advanced SIMD and cryptographic instructions.
23999
24000@item +sb
24001Speculation Barrier Instruction.
24002
24003@item +predres
24004Execution and Data Prediction Restriction Instructions.
24005
24006@item +i8mm
240078-bit Integer Matrix Multiply instructions.
24008This also enables Advanced SIMD and floating-point instructions.
24009
24010@item +bf16
24011Brain half-precision floating-point instructions.
24012This also enables Advanced SIMD and floating-point instructions.
24013@end table
24014
24015@item armv8.4-a
24016@table @samp
24017@item +fp16
24018The half-precision floating-point data processing instructions.
24019This also enables the Advanced SIMD and floating-point instructions as well
24020as the Dot Product extension and the half-precision floating-point fmla
24021extension.
24022
24023@item +simd
24024The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24025Dot Product extension.
24026
24027@item +crypto
24028The cryptographic instructions. This also enables the Advanced SIMD and
24029floating-point instructions as well as the Dot Product extension.
24030
24031@item +nocrypto
24032Disable the cryptographic extension.
24033
24034@item +nofp
24035Disable the floating-point, Advanced SIMD and cryptographic instructions.
24036
24037@item +sb
24038Speculation Barrier Instruction.
24039
24040@item +predres
24041Execution and Data Prediction Restriction Instructions.
24042
24043@item +i8mm
240448-bit Integer Matrix Multiply instructions.
24045This also enables Advanced SIMD and floating-point instructions.
24046
24047@item +bf16
24048Brain half-precision floating-point instructions.
24049This also enables Advanced SIMD and floating-point instructions.
24050@end table
24051
24052@item armv8.5-a
24053@table @samp
24054@item +fp16
24055The half-precision floating-point data processing instructions.
24056This also enables the Advanced SIMD and floating-point instructions as well
24057as the Dot Product extension and the half-precision floating-point fmla
24058extension.
24059
24060@item +simd
24061The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24062Dot Product extension.
24063
24064@item +crypto
24065The cryptographic instructions. This also enables the Advanced SIMD and
24066floating-point instructions as well as the Dot Product extension.
24067
24068@item +nocrypto
24069Disable the cryptographic extension.
24070
24071@item +nofp
24072Disable the floating-point, Advanced SIMD and cryptographic instructions.
24073
24074@item +i8mm
240758-bit Integer Matrix Multiply instructions.
24076This also enables Advanced SIMD and floating-point instructions.
24077
24078@item +bf16
24079Brain half-precision floating-point instructions.
24080This also enables Advanced SIMD and floating-point instructions.
24081@end table
24082
24083@item armv8.6-a
24084@table @samp
24085@item +fp16
24086The half-precision floating-point data processing instructions.
24087This also enables the Advanced SIMD and floating-point instructions as well
24088as the Dot Product extension and the half-precision floating-point fmla
24089extension.
24090
24091@item +simd
24092The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24093Dot Product extension.
24094
24095@item +crypto
24096The cryptographic instructions. This also enables the Advanced SIMD and
24097floating-point instructions as well as the Dot Product extension.
24098
24099@item +nocrypto
24100Disable the cryptographic extension.
24101
24102@item +nofp
24103Disable the floating-point, Advanced SIMD and cryptographic instructions.
24104
24105@item +i8mm
241068-bit Integer Matrix Multiply instructions.
24107This also enables Advanced SIMD and floating-point instructions.
24108
24109@item +bf16
24110Brain half-precision floating-point instructions.
24111This also enables Advanced SIMD and floating-point instructions.
24112@end table
24113
24114@item armv7-r
24115@table @samp
24116@item +fp.sp
24117The single-precision VFPv3 floating-point instructions. The extension
24118@samp{+vfpv3xd} can be used as an alias for this extension.
24119
24120@item +fp
24121The VFPv3 floating-point instructions with 16 double-precision registers.
24122The extension +vfpv3-d16 can be used as an alias for this extension.
24123
24124@item +vfpv3xd-d16-fp16
24125The single-precision VFPv3 floating-point instructions with 16 double-precision
24126registers and the half-precision floating-point conversion operations.
24127
24128@item +vfpv3-d16-fp16
24129The VFPv3 floating-point instructions with 16 double-precision
24130registers and the half-precision floating-point conversion operations.
24131
24132@item +nofp
24133Disable the floating-point extension.
24134
24135@item +idiv
24136The ARM-state integer division instructions.
24137
24138@item +noidiv
24139Disable the ARM-state integer division extension.
24140@end table
24141
24142@item armv7e-m
24143@table @samp
24144@item +fp
24145The single-precision VFPv4 floating-point instructions.
24146
24147@item +fpv5
24148The single-precision FPv5 floating-point instructions.
24149
24150@item +fp.dp
24151The single- and double-precision FPv5 floating-point instructions.
24152
24153@item +nofp
24154Disable the floating-point extensions.
24155@end table
24156
24157@item armv8.1-m.main
24158@table @samp
24159
24160@item +dsp
24161The DSP instructions.
24162
24163@item +mve
24164The M-Profile Vector Extension (MVE) integer instructions.
24165
24166@item +mve.fp
24167The M-Profile Vector Extension (MVE) integer and single precision
24168floating-point instructions.
24169
24170@item +fp
24171The single-precision floating-point instructions.
24172
24173@item +fp.dp
24174The single- and double-precision floating-point instructions.
24175
24176@item +nofp
24177Disable the floating-point extension.
24178
24179@item +cdecp0, +cdecp1, ... , +cdecp7
24180Enable the Custom Datapath Extension (CDE) on selected coprocessors according
24181to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
24182
24183@item +pacbti
24184Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
24185@end table
24186
24187@item armv8-m.main
24188@table @samp
24189@item +dsp
24190The DSP instructions.
24191
24192@item +nodsp
24193Disable the DSP extension.
24194
24195@item +fp
24196The single-precision floating-point instructions.
24197
24198@item +fp.dp
24199The single- and double-precision floating-point instructions.
24200
24201@item +nofp
24202Disable the floating-point extension.
24203
24204@item +cdecp0, +cdecp1, ... , +cdecp7
24205Enable the Custom Datapath Extension (CDE) on selected coprocessors according
24206to the numbers given in the options in the range 0 to 7.
24207@end table
24208
24209@item armv8-r
24210@table @samp
24211@item +crc
24212The Cyclic Redundancy Check (CRC) instructions.
24213@item +fp.sp
24214The single-precision FPv5 floating-point instructions.
24215@item +simd
24216The ARMv8-A Advanced SIMD and floating-point instructions.
24217@item +crypto
24218The cryptographic instructions.
24219@item +nocrypto
24220Disable the cryptographic instructions.
24221@item +nofp
24222Disable the floating-point, Advanced SIMD and cryptographic instructions.
24223@end table
24224
24225@end table
24226
24227@option{-march=native} causes the compiler to auto-detect the architecture
24228of the build computer. At present, this feature is only supported on
24229GNU/Linux, and not all architectures are recognized. If the auto-detect
24230is unsuccessful the option has no effect.
24231
7d6c6a0d
RE
24232@option{-march=unset} causes the compiler to ignore any
24233@option{-march=@dots{}} options that appear earlier on the command line
24234and behave as if the option was never passed. This is useful to avoid
24235warnings about conflicting CPU and architecture options when the two
24236produce different architecture specifications.
24237
d77de738 24238@opindex mtune
ddf6fe37 24239@item -mtune=@var{name}
d77de738
ML
24240This option specifies the name of the target ARM processor for
24241which GCC should tune the performance of the code.
24242For some ARM implementations better performance can be obtained by using
24243this option.
24244Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
24245@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
24246@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
24247@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
24248@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
24249@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
24250@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
24251@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
24252@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
24253@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
24254@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
24255@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
24256@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
24257@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
24258@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
24259@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
24260@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
24261@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
24262@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
43c4f982 24263@samp{cortex-m35p}, @samp{cortex-m52}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
ccfd1e7f 24264@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
24265@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
24266@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
24267@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
24268@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
24269@samp{xgene1}.
24270
24271Additionally, this option can specify that GCC should tune the performance
24272of the code for a big.LITTLE system. Permissible names are:
24273@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
24274@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
24275@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
24276@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
24277
24278@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
24279performance for a blend of processors within architecture @var{arch}.
24280The aim is to generate code that run well on the current most popular
24281processors, balancing between optimizations that benefit some CPUs in the
24282range, and avoiding performance pitfalls of other CPUs. The effects of
24283this option may change in future GCC versions as CPU models come and go.
24284
24285@option{-mtune} permits the same extension options as @option{-mcpu}, but
24286the extension options do not affect the tuning of the generated code.
24287
24288@option{-mtune=native} causes the compiler to auto-detect the CPU
24289of the build computer. At present, this feature is only supported on
24290GNU/Linux, and not all architectures are recognized. If the auto-detect is
24291unsuccessful the option has no effect.
24292
d77de738 24293@opindex mcpu
ddf6fe37 24294@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
24295This specifies the name of the target ARM processor. GCC uses this name
24296to derive the name of the target ARM architecture (as if specified
24297by @option{-march}) and the ARM processor type for which to tune for
24298performance (as if specified by @option{-mtune}). Where this option
24299is used in conjunction with @option{-march} or @option{-mtune},
24300those options take precedence over the appropriate part of this option.
24301
24302Many of the supported CPUs implement optional architectural
24303extensions. Where this is so the architectural extensions are
24304normally enabled by default. If implementations that lack the
24305extension exist, then the extension syntax can be used to disable
24306those extensions that have been omitted. For floating-point and
24307Advanced SIMD (Neon) instructions, the settings of the options
24308@option{-mfloat-abi} and @option{-mfpu} must also be considered:
24309floating-point and Advanced SIMD instructions will only be used if
24310@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
24311@option{-mfpu} other than @samp{auto} will override the available
24312floating-point and SIMD extension instructions.
24313
24314For example, @samp{cortex-a9} can be found in three major
24315configurations: integer only, with just a floating-point unit or with
24316floating-point and Advanced SIMD. The default is to enable all the
24317instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
24318be used to disable just the SIMD or both the SIMD and floating-point
24319instructions respectively.
24320
24321Permissible names for this option are the same as those for
24322@option{-mtune}.
24323
24324The following extension options are common to the listed CPUs:
24325
24326@table @samp
24327@item +nodsp
ccfd1e7f 24328Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
43c4f982
CJW
24329@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
24330Also disable the M-Profile Vector Extension (MVE) integer and
24331single precision floating-point instructions on
24332@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
ccfd1e7f
SP
24333
24334@item +nopacbti
24335Disable the Pointer Authentication and Branch Target Identification Extension
43c4f982 24336on @samp{cortex-m52} and @samp{cortex-m85}.
d77de738
ML
24337
24338@item +nomve
24339Disable the M-Profile Vector Extension (MVE) integer and single precision
237fdf51
AZ
24340floating-point instructions on @samp{cortex-m52}, @samp{cortex-m55} and
24341@samp{cortex-m85}.
d77de738
ML
24342
24343@item +nomve.fp
24344Disable the M-Profile Vector Extension (MVE) single precision floating-point
43c4f982 24345instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 24346
798a0d05
SP
24347@item +cdecp0, +cdecp1, ... , +cdecp7
24348Enable the Custom Datapath Extension (CDE) on selected coprocessors according
237fdf51
AZ
24349to the numbers given in the options in the range 0 to 7 on @samp{cortex-m52},
24350@samp{cortex-m55} and @samp{star-mc1}.
798a0d05 24351
d77de738
ML
24352@item +nofp
24353Disables the floating-point instructions on @samp{arm9e},
24354@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
24355@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
24356@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
ccfd1e7f 24357@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
43c4f982 24358@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
24359Disables the floating-point and SIMD instructions on
24360@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
24361@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
24362@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
24363@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
24364@samp{cortex-a53} and @samp{cortex-a55}.
24365
24366@item +nofp.dp
24367Disables the double-precision component of the floating-point instructions
24368on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
24369@samp{cortex-r52plus} and @samp{cortex-m7}.
24370
24371@item +nosimd
24372Disables the SIMD (but not floating-point) instructions on
24373@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
24374and @samp{cortex-a9}.
24375
24376@item +crypto
24377Enables the cryptographic instructions on @samp{cortex-a32},
24378@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
24379@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
24380@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
24381@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
24382@samp{cortex-a75.cortex-a55}.
24383@end table
24384
24385Additionally the @samp{generic-armv7-a} pseudo target defaults to
24386VFPv3 with 16 double-precision registers. It supports the following
24387extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
24388@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
24389@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
24390@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
24391the extensions to @option{-march=armv7-a}.
24392
24393@option{-mcpu=generic-@var{arch}} is also permissible, and is
24394equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
24395See @option{-mtune} for more information.
24396
24397@option{-mcpu=native} causes the compiler to auto-detect the CPU
24398of the build computer. At present, this feature is only supported on
24399GNU/Linux, and not all architectures are recognized. If the auto-detect
24400is unsuccessful the option has no effect.
24401
7d6c6a0d
RE
24402@option{-mcpu=unset} causes the compiler to ignore any
24403@option{-mcpu=@dots{}} options that appear earlier on the command line
24404and behave as if the option was never passed. This is useful to avoid
24405warnings about conflicting CPU and architecture options when the two
24406produce different architecture specifications.
24407
d77de738 24408@opindex mfpu
ddf6fe37 24409@item -mfpu=@var{name}
d77de738
ML
24410This specifies what floating-point hardware (or hardware emulation) is
24411available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
24412@samp{vfpv3},
24413@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
24414@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
24415@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
24416@samp{fpv5-d16}, @samp{fpv5-sp-d16},
24417@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
24418Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
24419is an alias for @samp{vfpv2}.
24420
24421The setting @samp{auto} is the default and is special. It causes the
24422compiler to select the floating-point and Advanced SIMD instructions
24423based on the settings of @option{-mcpu} and @option{-march}.
24424
24425If the selected floating-point hardware includes the NEON extension
24426(e.g.@: @option{-mfpu=neon}), note that floating-point
24427operations are not generated by GCC's auto-vectorization pass unless
24428@option{-funsafe-math-optimizations} is also specified. This is
24429because NEON hardware does not fully implement the IEEE 754 standard for
24430floating-point arithmetic (in particular denormal values are treated as
24431zero), so the use of NEON instructions may lead to a loss of precision.
24432
24433You can also set the fpu name at function level by using the @code{target("fpu=")} function attributes (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
24434
d77de738 24435@opindex mfp16-format
ddf6fe37 24436@item -mfp16-format=@var{name}
d77de738
ML
24437Specify the format of the @code{__fp16} half-precision floating-point type.
24438Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
24439the default is @samp{none}, in which case the @code{__fp16} type is not
24440defined. @xref{Half-Precision}, for more information.
24441
d77de738 24442@opindex mstructure-size-boundary
ddf6fe37 24443@item -mstructure-size-boundary=@var{n}
d77de738
ML
24444The sizes of all structures and unions are rounded up to a multiple
24445of the number of bits set by this option. Permissible values are 8, 32
24446and 64. The default value varies for different toolchains. For the COFF
24447targeted toolchain the default value is 8. A value of 64 is only allowed
24448if the underlying ABI supports it.
24449
24450Specifying a larger number can produce faster, more efficient code, but
24451can also increase the size of the program. Different values are potentially
24452incompatible. Code compiled with one value cannot necessarily expect to
24453work with code or libraries compiled with another value, if they exchange
24454information using structures or unions.
24455
24456This option is deprecated.
24457
d77de738 24458@opindex mabort-on-noreturn
ddf6fe37 24459@item -mabort-on-noreturn
d77de738
ML
24460Generate a call to the function @code{abort} at the end of a
24461@code{noreturn} function. It is executed if the function tries to
24462return.
24463
d77de738
ML
24464@opindex mlong-calls
24465@opindex mno-long-calls
ddf6fe37
AA
24466@item -mlong-calls
24467@itemx -mno-long-calls
d77de738
ML
24468Tells the compiler to perform function calls by first loading the
24469address of the function into a register and then performing a subroutine
24470call on this register. This switch is needed if the target function
24471lies outside of the 64-megabyte addressing range of the offset-based
24472version of subroutine call instruction.
24473
24474Even if this switch is enabled, not all function calls are turned
24475into long calls. The heuristic is that static functions, functions
24476that have the @code{short_call} attribute, functions that are inside
24477the scope of a @code{#pragma no_long_calls} directive, and functions whose
24478definitions have already been compiled within the current compilation
24479unit are not turned into long calls. The exceptions to this rule are
24480that weak function definitions, functions with the @code{long_call}
24481attribute or the @code{section} attribute, and functions that are within
24482the scope of a @code{#pragma long_calls} directive are always
24483turned into long calls.
24484
24485This feature is not enabled by default. Specifying
24486@option{-mno-long-calls} restores the default behavior, as does
24487placing the function calls within the scope of a @code{#pragma
24488long_calls_off} directive. Note these switches have no effect on how
24489the compiler generates code to handle function calls via function
24490pointers.
24491
d77de738 24492@opindex msingle-pic-base
ddf6fe37 24493@item -msingle-pic-base
d77de738
ML
24494Treat the register used for PIC addressing as read-only, rather than
24495loading it in the prologue for each function. The runtime system is
24496responsible for initializing this register with an appropriate value
24497before execution begins.
24498
d77de738 24499@opindex mpic-register
ddf6fe37 24500@item -mpic-register=@var{reg}
d77de738
ML
24501Specify the register to be used for PIC addressing.
24502For standard PIC base case, the default is any suitable register
24503determined by compiler. For single PIC base case, the default is
24504@samp{R9} if target is EABI based or stack-checking is enabled,
24505otherwise the default is @samp{R10}.
24506
d77de738 24507@opindex mpic-data-is-text-relative
ddf6fe37 24508@item -mpic-data-is-text-relative
d77de738
ML
24509Assume that the displacement between the text and data segments is fixed
24510at static link time. This permits using PC-relative addressing
24511operations to access data known to be in the data segment. For
24512non-VxWorks RTP targets, this option is enabled by default. When
24513disabled on such targets, it will enable @option{-msingle-pic-base} by
24514default.
24515
d77de738 24516@opindex mpoke-function-name
ddf6fe37 24517@item -mpoke-function-name
d77de738
ML
24518Write the name of each function into the text section, directly
24519preceding the function prologue. The generated code is similar to this:
24520
24521@smallexample
24522 t0
24523 .ascii "arm_poke_function_name", 0
24524 .align
24525 t1
24526 .word 0xff000000 + (t1 - t0)
24527 arm_poke_function_name
24528 mov ip, sp
24529 stmfd sp!, @{fp, ip, lr, pc@}
24530 sub fp, ip, #4
24531@end smallexample
24532
24533When performing a stack backtrace, code can inspect the value of
24534@code{pc} stored at @code{fp + 0}. If the trace function then looks at
24535location @code{pc - 12} and the top 8 bits are set, then we know that
24536there is a function name embedded immediately preceding this location
24537and has length @code{((pc[-3]) & 0xff000000)}.
24538
d77de738
ML
24539@opindex marm
24540@opindex mthumb
ddf6fe37
AA
24541@item -mthumb
24542@itemx -marm
d77de738
ML
24543
24544Select between generating code that executes in ARM and Thumb
24545states. The default for most configurations is to generate code
24546that executes in ARM state, but the default can be changed by
24547configuring GCC with the @option{--with-mode=}@var{state}
24548configure option.
24549
24550You can also override the ARM and Thumb mode for each function
24551by using the @code{target("thumb")} and @code{target("arm")} function attributes
24552(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
24553
d77de738 24554@opindex mflip-thumb
a0e64a04 24555@item -mflip-thumb
d77de738
ML
24556Switch ARM/Thumb modes on alternating functions.
24557This option is provided for regression testing of mixed Thumb/ARM code
24558generation, and is not intended for ordinary use in compiling code.
24559
d77de738 24560@opindex mtpcs-frame
ddf6fe37 24561@item -mtpcs-frame
d77de738
ML
24562Generate a stack frame that is compliant with the Thumb Procedure Call
24563Standard for all non-leaf functions. (A leaf function is one that does
24564not call any other functions.) The default is @option{-mno-tpcs-frame}.
24565
d77de738 24566@opindex mtpcs-leaf-frame
ddf6fe37 24567@item -mtpcs-leaf-frame
d77de738
ML
24568Generate a stack frame that is compliant with the Thumb Procedure Call
24569Standard for all leaf functions. (A leaf function is one that does
24570not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
24571
d77de738 24572@opindex mcallee-super-interworking
ddf6fe37 24573@item -mcallee-super-interworking
d77de738
ML
24574Gives all externally visible functions in the file being compiled an ARM
24575instruction set header which switches to Thumb mode before executing the
24576rest of the function. This allows these functions to be called from
24577non-interworking code. This option is not valid in AAPCS configurations
24578because interworking is enabled by default.
24579
d77de738 24580@opindex mcaller-super-interworking
ddf6fe37 24581@item -mcaller-super-interworking
d77de738
ML
24582Allows calls via function pointers (including virtual functions) to
24583execute correctly regardless of whether the target code has been
24584compiled for interworking or not. There is a small overhead in the cost
24585of executing a function pointer if this option is enabled. This option
24586is not valid in AAPCS configurations because interworking is enabled
24587by default.
24588
d77de738 24589@opindex mtp
ddf6fe37 24590@item -mtp=@var{name}
cca8d9e5
KT
24591Specify the access model for the thread local storage pointer. The model
24592@samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
24593models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
24594the thread pointer from the corresponding system register directly
24595(supported from the arm6k architecture and later). These system registers
24596are accessed through the CP15 co-processor interface and the argument
24597@samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
24598The argument @samp{auto} uses the best available method for the selected
24599processor. The default setting is @samp{auto}.
d77de738 24600
d77de738 24601@opindex mtls-dialect
ddf6fe37 24602@item -mtls-dialect=@var{dialect}
d77de738
ML
24603Specify the dialect to use for accessing thread local storage. Two
24604@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
24605@samp{gnu} dialect selects the original GNU scheme for supporting
24606local and global dynamic TLS models. The @samp{gnu2} dialect
24607selects the GNU descriptor scheme, which provides better performance
24608for shared libraries. The GNU descriptor scheme is compatible with
24609the original scheme, but does require new assembler, linker and
24610library support. Initial and local exec TLS models are unaffected by
24611this option and always use the original scheme.
24612
d77de738 24613@opindex mword-relocations
ddf6fe37 24614@item -mword-relocations
d77de738
ML
24615Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
24616This is enabled by default on targets (uClinux, SymbianOS) where the runtime
24617loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
24618is specified. This option conflicts with @option{-mslow-flash-data}.
24619
d77de738 24620@opindex mfix-cortex-m3-ldrd
ddf6fe37 24621@item -mfix-cortex-m3-ldrd
d77de738
ML
24622Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
24623with overlapping destination and base registers are used. This option avoids
24624generating these instructions. This option is enabled by default when
24625@option{-mcpu=cortex-m3} is specified.
24626
24627@item -mfix-cortex-a57-aes-1742098
24628@itemx -mno-fix-cortex-a57-aes-1742098
24629@itemx -mfix-cortex-a72-aes-1655431
24630@itemx -mno-fix-cortex-a72-aes-1655431
24631Enable (disable) mitigation for an erratum on Cortex-A57 and
24632Cortex-A72 that affects the AES cryptographic instructions. This
24633option is enabled by default when either @option{-mcpu=cortex-a57} or
24634@option{-mcpu=cortex-a72} is specified.
24635
d77de738
ML
24636@opindex munaligned-access
24637@opindex mno-unaligned-access
ddf6fe37
AA
24638@item -munaligned-access
24639@itemx -mno-unaligned-access
d77de738
ML
24640Enables (or disables) reading and writing of 16- and 32- bit values
24641from addresses that are not 16- or 32- bit aligned. By default
24642unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
24643ARMv8-M Baseline architectures, and enabled for all other
24644architectures. If unaligned access is not enabled then words in packed
24645data structures are accessed a byte at a time.
24646
24647The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
24648generated object file to either true or false, depending upon the
24649setting of this option. If unaligned access is enabled then the
24650preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
24651defined.
24652
d77de738 24653@opindex mneon-for-64bits
ddf6fe37 24654@item -mneon-for-64bits
d77de738
ML
24655This option is deprecated and has no effect.
24656
d77de738 24657@opindex mslow-flash-data
ddf6fe37 24658@item -mslow-flash-data
d77de738
ML
24659Assume loading data from flash is slower than fetching instruction.
24660Therefore literal load is minimized for better performance.
24661This option is only supported when compiling for ARMv7 M-profile and
24662off by default. It conflicts with @option{-mword-relocations}.
24663
d77de738 24664@opindex masm-syntax-unified
ddf6fe37 24665@item -masm-syntax-unified
d77de738
ML
24666Assume inline assembler is using unified asm syntax. The default is
24667currently off which implies divided syntax. This option has no impact
24668on Thumb2. However, this may change in future releases of GCC.
24669Divided syntax should be considered deprecated.
24670
d77de738 24671@opindex mrestrict-it
ddf6fe37 24672@item -mrestrict-it
d77de738
ML
24673Restricts generation of IT blocks to conform to the rules of ARMv8-A.
24674IT blocks can only contain a single 16-bit instruction from a select
24675set of instructions. This option is on by default for ARMv8-A Thumb mode.
24676
d77de738 24677@opindex mprint-tune-info
ddf6fe37 24678@item -mprint-tune-info
d77de738
ML
24679Print CPU tuning information as comment in assembler file. This is
24680an option used only for regression testing of the compiler and not
24681intended for ordinary use in compiling code. This option is disabled
24682by default.
24683
d77de738 24684@opindex mverbose-cost-dump
ddf6fe37 24685@item -mverbose-cost-dump
d77de738
ML
24686Enable verbose cost model dumping in the debug dump files. This option is
24687provided for use in debugging the compiler.
24688
d77de738 24689@opindex mpure-code
ddf6fe37 24690@item -mpure-code
d77de738
ML
24691Do not allow constant data to be placed in code sections.
24692Additionally, when compiling for ELF object format give all text sections the
24693ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
24694is only available when generating non-pic code for M-profile targets.
24695
d77de738 24696@opindex mcmse
ddf6fe37 24697@item -mcmse
d77de738
ML
24698Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
24699Development Tools Engineering Specification", which can be found on
24700@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
24701
d77de738 24702@opindex mfix-cmse-cve-2021-35465
ddf6fe37 24703@item -mfix-cmse-cve-2021-35465
d77de738
ML
24704Mitigate against a potential security issue with the @code{VLLDM} instruction
24705in some M-profile devices when using CMSE (CVE-2021-365465). This option is
24706enabled by default when the option @option{-mcpu=} is used with
43c4f982
CJW
24707@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m52}, @code{cortex-m55},
24708@code{cortex-m85} or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465}
24709can be used to disable the mitigation.
d77de738 24710
d77de738
ML
24711@opindex mstack-protector-guard
24712@opindex mstack-protector-guard-offset
ddf6fe37
AA
24713@item -mstack-protector-guard=@var{guard}
24714@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
24715Generate stack protection code using canary at @var{guard}. Supported
24716locations are @samp{global} for a global canary or @samp{tls} for a
24717canary accessible via the TLS register. The option
24718@option{-mstack-protector-guard-offset=} is for use with
24719@option{-fstack-protector-guard=tls} and not for use in user-land code.
24720
d77de738
ML
24721@opindex mfdpic
24722@opindex mno-fdpic
ddf6fe37
AA
24723@item -mfdpic
24724@itemx -mno-fdpic
d77de738
ML
24725Select the FDPIC ABI, which uses 64-bit function descriptors to
24726represent pointers to functions. When the compiler is configured for
24727@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
24728and implies @option{-fPIE} if none of the PIC/PIE-related options is
24729provided. On other targets, it only enables the FDPIC-specific code
24730generation features, and the user should explicitly provide the
24731PIC/PIE-related options as needed.
24732
24733Note that static linking is not supported because it would still
24734involve the dynamic linker when the program self-relocates. If such
24735behavior is acceptable, use -static and -Wl,-dynamic-linker options.
24736
24737The opposite @option{-mno-fdpic} option is useful (and required) to
24738build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
24739toolchain as the one used to build the userland programs.
24740
14fab5fb 24741@opindex mbranch-protection
ddf6fe37 24742@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
24743Enable branch protection features (armv8.1-m.main only).
24744@samp{none} generate code without branch protection or return address
24745signing.
24746@samp{standard[+@var{leaf}]} generate code with all branch protection
24747features enabled at their standard level.
24748@samp{pac-ret[+@var{leaf}]} generate code with return address signing
24749set to its standard level, which is to sign all functions that save
24750the return address to memory.
24751@samp{leaf} When return address signing is enabled, also sign leaf
24752functions even if they do not write the return address to memory.
24753+@samp{bti} Add landing-pad instructions at the permitted targets of
24754indirect branch instructions.
24755
24756If the @samp{+pacbti} architecture extension is not enabled, then all
24757branch protection and return address signing operations are
24758constrained to use only the instructions defined in the
24759architectural-NOP space. The generated code will remain
24760backwards-compatible with earlier versions of the architecture, but
24761the additional security can be enabled at run time on processors that
24762support the @samp{PACBTI} extension.
24763
24764Branch target enforcement using BTI can only be enabled at runtime if
24765all code in the application has been compiled with at least
24766@samp{-mbranch-protection=bti}.
24767
24768Any setting other than @samp{none} is supported only on armv8-m.main
24769or later.
24770
24771The default is to generate code without branch protection or return
24772address signing.
24773
d77de738
ML
24774@end table
24775
24776@node AVR Options
24777@subsection AVR Options
24778@cindex AVR Options
24779
24780These options are defined for AVR implementations:
24781
24782@table @gcctabopt
d77de738 24783@opindex mmcu
ddf6fe37 24784@item -mmcu=@var{mcu}
e63ae908
GJL
24785Specify the AVR instruction set architecture (ISA) or device type.
24786The default for this option is@tie{}@code{avr2}.
24787
24788The following AVR devices and ISAs are supported.
24789@emph{Note:} A complete device support consists of
24790startup code @code{crt@var{mcu}.o}, a device header @code{avr/io*.h},
24791a device library @code{lib@var{mcu}.a} and a
24792@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device-specs} file
24793@code{specs-@var{mcu}}. Only the latter is provided by the compiler
24794according the supported @code{@var{mcu}}s below. The rest is supported
f5448384 24795by @w{@uref{https://github.com/avrdudes/avr-libc/,AVR-LibC}}, or by means of
e63ae908
GJL
24796@uref{https://gcc.gnu.org/wiki/avr-gcc#atpack,@code{atpack}} files
24797from the hardware manufacturer.
24798
24799@c Auto-generated. Re-build when new devices are added to avr-mcus.def
24800@c by running "make avr-mcus" in $builddir/gcc.
d77de738
ML
24801@include avr-mmcu.texi
24802
d77de738 24803@opindex mabsdata
ddf6fe37 24804@item -mabsdata
d77de738
ML
24805
24806Assume that all data in static storage can be accessed by LDS / STS
24807instructions. This option has only an effect on reduced Tiny devices like
24808ATtiny40. See also the @code{absdata}
24809@ref{AVR Variable Attributes,variable attribute}.
24810
cb27337f
GJL
24811@opindex mcvt
24812@item -mcvt
24813Use a @emph{compact vector table}. Some devices support a CVT
24814with only four entries: 0=Reset, 1=NMI, 2=Prio1 IRQ, 3=Prio0 IRQs.
24815This option will link startup code from @code{crt@var{mcu}-cvt.o}
24816instead of the usual @code{crt@var{mcu}.o}.
24817Apart from providing a compact vector table, the startup code will set bit
24818@code{CPUINT_CTRLA.CPUINT_CVT} which enables the CVT on the device.
24819
24820When you do not want the startup code to set @code{CPUINT_CTRLA.CPUINT_CVT},
0c7109ab 24821then you can satisfy symbol @code{__init_cvt} so that the respective
cb27337f 24822code is no more pulled in from @code{lib@var{mcu}.a}.
0c7109ab 24823For example, you can link with @code{-Wl,--defsym,__init_cvt=0}.
cb27337f
GJL
24824
24825The CVT startup code is available since
0c7109ab 24826@w{@uref{https://github.com/avrdudes/avr-libc/issues/1010,AVR-LibC v2.3}}.
cb27337f 24827
d77de738
ML
24828@opindex mdouble
24829@opindex mlong-double
ddf6fe37
AA
24830@item -mdouble=@var{bits}
24831@itemx -mlong-double=@var{bits}
d77de738
ML
24832Set the size (in bits) of the @code{double} or @code{long double} type,
24833respectively. Possible values for @var{bits} are 32 and 64.
24834Whether or not a specific value for @var{bits} is allowed depends on
24835the @code{--with-double=} and @code{--with-long-double=}
24836@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
24837and the same applies for the default values of the options.
24838
d77de738 24839@opindex mgas-isr-prologues
ddf6fe37 24840@item -mgas-isr-prologues
d77de738
ML
24841Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
24842instruction supported by GNU Binutils.
24843If this option is on, the feature can still be disabled for individual
24844ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
24845function attribute. This feature is activated per default
24846if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
24847and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
24848
d77de738 24849@opindex mint8
ddf6fe37 24850@item -mint8
d77de738
ML
24851Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
24852@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
24853and @code{long long} is 4 bytes. Please note that this option does not
24854conform to the C standards, but it results in smaller code
24855size.
24856
d77de738 24857@opindex mmain-is-OS_task
ddf6fe37 24858@item -mmain-is-OS_task
d77de738
ML
24859Do not save registers in @code{main}. The effect is the same like
24860attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
24861to @code{main}. It is activated per default if optimization is on.
24862
0fa06d7f
GJL
24863@opindex mno-call-main
24864@opindex mcall-main
24865@item -mno-call-main
24866Don't run @code{main} by means of
24867@example
24868XCALL main
24869XJMP exit
24870@end example
24871Instead, put @code{main} in section
24872@w{@uref{https://avrdudes.github.io/avr-libc/avr-libc-user-manual/mem_sections.html#sec_dot_init,@code{.init9}}}
24873so that no call is required.
22a0cba3 24874By setting this option the user asserts that @code{main} will not return.
0fa06d7f
GJL
24875
24876This option can be used for devices with very limited resources in order
24877to save a few bytes of code and stack space. It will work as expected since
24878@w{@uref{https://github.com/avrdudes/avr-libc/issues/1012,AVR-LibC v2.3}}.
24879With older versions, there will be no performance gain.
24880
d77de738 24881@opindex mno-interrupts
ddf6fe37 24882@item -mno-interrupts
d77de738
ML
24883Generated code is not compatible with hardware interrupts.
24884Code size is smaller.
24885
d77de738 24886@opindex mrelax
ddf6fe37 24887@item -mrelax
d77de738
ML
24888Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
24889@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
24890Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
24891the assembler's command line and the @option{--relax} option to the
24892linker's command line.
24893
24894Jump relaxing is performed by the linker because jump offsets are not
24895known before code is located. Therefore, the assembler code generated by the
24896compiler is the same, but the instructions in the executable may
24897differ from instructions in the assembler code.
24898
24899Relaxing must be turned on if linker stubs are needed, see the
24900section on @code{EIND} and linker stubs below.
24901
48448055
GJL
24902@opindex mrodata-in-ram
24903@item -mrodata-in-ram
24904@itemx -mno-rodata-in-ram
24905Locate the @code{.rodata} sections for read-only data in RAM resp.@:
24906in program memory.
24907For most devices, there is no choice and this option acts rather
24908like an assertion.
24909
24910Since v14 and for the AVR64* and AVR128* devices, @code{.rodata}
24911is located in flash memory per default, provided the required GNU Binutils
24912support (@w{@uref{https://sourceware.org/PR31124,PR31124}}) is available.
24913In that case, @option{-mrodata-in-ram} can be used to return to the old
24914layout with @code{.rodata} in RAM.
24915
d77de738 24916@opindex mtiny-stack
ddf6fe37 24917@item -mtiny-stack
d77de738
ML
24918Only change the lower 8@tie{}bits of the stack pointer.
24919
d77de738 24920@opindex mfract-convert-truncate
ddf6fe37 24921@item -mfract-convert-truncate
d77de738
ML
24922Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
24923
d77de738 24924@opindex nodevicelib
ddf6fe37 24925@item -nodevicelib
0fa06d7f
GJL
24926Don't link against AVR-LibC's device specific library @code{lib@var{mcu}.a}.
24927
24928Notice that since AVR-LibC v2.3, that library contains code that is
24929essential for the correct functioning of a program. In particular,
24930it contains parts of the startup code like:
24931@w{@uref{https://github.com/avrdudes/avr-libc/issues/1011,@code{__init_sp}}}
24932to initialize the stack pointer with symbol @code{__stack},
24933@w{@uref{https://github.com/avrdudes/avr-libc/issues/1010,@code{__init_cvt}}}
24934to set up the hardware to use a compact vector table with @option{-mcvt},
24935@w{@uref{https://github.com/avrdudes/avr-libc/issues/1012,@code{__call_main}}}
24936to call @code{main} and @code{exit}, and
24937@w{@uref{https://github.com/avrdudes/avr-libc/issues/931,@code{__do_flmap_init}}}
24938to set up FLMAP according to symbol @code{__flmap}.
d77de738 24939
d77de738 24940@opindex nodevicespecs
ddf6fe37 24941@item -nodevicespecs
d77de738
ML
24942Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
24943command line. The user takes responsibility for supplying the sub-processes
24944like compiler proper, assembler and linker with appropriate command line
24945options. This means that the user has to supply her private device specs
24946file by means of @option{-specs=@var{path-to-specs-file}}. There is no
24947more need for option @option{-mmcu=@var{mcu}}.
24948
24949This option can also serve as a replacement for the older way of
24950specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
24951which contains a folder named @code{device-specs} which contains a specs file named
24952@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
24953
d77de738
ML
24954@opindex Waddr-space-convert
24955@opindex Wno-addr-space-convert
ddf6fe37 24956@item -Waddr-space-convert
d77de738
ML
24957Warn about conversions between address spaces in the case where the
24958resulting address space is not contained in the incoming address space.
24959
d77de738
ML
24960@opindex Wmisspelled-isr
24961@opindex Wno-misspelled-isr
ddf6fe37 24962@item -Wmisspelled-isr
d77de738
ML
24963Warn if the ISR is misspelled, i.e.@: without __vector prefix.
24964Enabled by default.
24965@end table
24966
9ee39fcb
GJL
24967
24968@subsubsection AVR Optimization Options
24969The following options are pure optimization options.
24970Options @option{-mgas-isr-prologues}, @option{-mmain-is-OS_task},
24971@option{-mno-call-main} and @option{-mrelax} from above are only
24972@emph{almost} optimization options, since there are rare occasions
24973where their different code generation matters.
24974
24975@table @gcctabopt
24976@opindex maccumulate-args
24977@item -maccumulate-args
24978Accumulate outgoing function arguments and acquire/release the needed
24979stack space for outgoing function arguments once in function
24980prologue/epilogue. Without this option, outgoing arguments are pushed
24981before calling a function and popped afterwards.
070bbc58
GJL
24982See also the @option{-fdefer-pop}
24983@ref{Optimize Options,,optimization option}.
9ee39fcb
GJL
24984
24985Popping the arguments after the function call can be expensive on
24986AVR so that accumulating the stack space might lead to smaller
24987executables because arguments need not be removed from the
24988stack after such a function call.
24989
24990This option can lead to reduced code size for functions that perform
24991several calls to functions that get their arguments on the stack like
24992calls to printf-like functions.
24993
24994@opindex mbranch-cost
24995@item -mbranch-cost=@var{cost}
24996Set the branch costs for conditional branch instructions to
24997@var{cost}. Reasonable values for @var{cost} are small, non-negative
24998integers. The default branch cost is 0.
24999
25000@opindex mcall-prologues
25001@item -mcall-prologues
25002Functions prologues/epilogues are expanded as calls to appropriate
25003subroutines. Code size is smaller.
25004
25005@opindex mfuse-add
25006@item -mfuse-add
25007@itemx -mno-fuse-add
25008@itemx -mfuse-add=@var{level}
25009Optimize indirect memory accesses on reduced Tiny devices.
25010The default uses @code{@var{level}=1} for optimizations @option{-Og}
25011and @option{-O1}, and @code{@var{level}=2} for higher optimizations.
25012Valid values for @var{level} are @code{0}, @code{1} and @code{2}.
25013
25014@opindex mfuse-move
25015@item -mfuse-move
25016@itemx -mno-fuse-move
25017@itemx -mfuse-move=@var{level}
25018Run a post reload optimization pass that tries to fuse move instructions
25019and to split multi-byte instructions into 8-bit operations.
25020The default uses @code{@var{level}=3} for optimization @option{-O1},
25021and @code{@var{level}=23} for higher optimizations.
25022Valid values for @var{level} are in the range @code{0} @dots{} @code{23}
25023which is a 3:2:2:2 mixed radix value. Each digit controls some
25024aspect of the optimization.
25025
25026@opindex mstrict-X
25027@item -mstrict-X
25028Use address register @code{X} in a way proposed by the hardware. This means
25029that @code{X} is only used in indirect, post-increment or
25030pre-decrement addressing.
25031
25032Without this option, the @code{X} register may be used in the same way
25033as @code{Y} or @code{Z} which then is emulated by additional
25034instructions.
25035For example, loading a value with @code{X+const} addressing with a
25036small non-negative @code{const < 64} to a register @var{Rn} is
25037performed as
25038
25039@example
25040adiw r26, const ; X += const
25041ld @var{Rn}, X ; @var{Rn} = *X
25042sbiw r26, const ; X -= const
25043@end example
25044
25045@opindex msplit-bit-shift
25046@item -msplit-bit-shift
25047Split multi-byte shifts with a constant offset into a shift with
25048a byte offset and a residual shift with a non-byte offset.
25049This optimization is turned on per default for @option{-O2} and higher,
25050including @option{-Os} but excluding @option{-Oz}.
25051Splitting of shifts with a constant offset that is
25052a multiple of 8 is controlled by @option{-mfuse-move}.
25053
25054@opindex msplit-ldst
25055@item -msplit-ldst
25056Split multi-byte loads and stores into several byte loads and stores.
25057This optimization is turned on per default for @option{-O2} and higher.
25058
94355acc
GJL
25059@opindex muse-nonzero-bits
25060@item -muse-nonzero-bits
070bbc58
GJL
25061Enable optimizations that are only possible when some bits in a
25062register are always zero.
94355acc
GJL
25063This optimization is turned on per default for @option{-O2} and higher.
25064
9ee39fcb
GJL
25065@end table
25066
b793c218 25067@anchor{eind}
d77de738
ML
25068@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
25069@cindex @code{EIND}
25070Pointers in the implementation are 16@tie{}bits wide.
25071The address of a function or label is represented as word address so
25072that indirect jumps and calls can target any code address in the
25073range of 64@tie{}Ki words.
25074
25075In order to facilitate indirect jump on devices with more than 128@tie{}Ki
25076bytes of program memory space, there is a special function register called
25077@code{EIND} that serves as most significant part of the target address
25078when @code{EICALL} or @code{EIJMP} instructions are used.
25079
25080Indirect jumps and calls on these devices are handled as follows by
25081the compiler and are subject to some limitations:
25082
25083@itemize @bullet
25084
25085@item
25086The compiler never sets @code{EIND}.
25087
25088@item
25089The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
25090instructions or might read @code{EIND} directly in order to emulate an
25091indirect call/jump by means of a @code{RET} instruction.
25092
25093@item
25094The compiler assumes that @code{EIND} never changes during the startup
25095code or during the application. In particular, @code{EIND} is not
25096saved/restored in function or interrupt service routine
25097prologue/epilogue.
25098
25099@item
25100For indirect calls to functions and computed goto, the linker
25101generates @emph{stubs}. Stubs are jump pads sometimes also called
25102@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
25103The stub contains a direct jump to the desired address.
25104
25105@item
25106Linker relaxation must be turned on so that the linker generates
25107the stubs correctly in all situations. See the compiler option
25108@option{-mrelax} and the linker option @option{--relax}.
25109There are corner cases where the linker is supposed to generate stubs
25110but aborts without relaxation and without a helpful error message.
25111
25112@item
25113The default linker script is arranged for code with @code{EIND = 0}.
25114If code is supposed to work for a setup with @code{EIND != 0}, a custom
25115linker script has to be used in order to place the sections whose
25116name start with @code{.trampolines} into the segment where @code{EIND}
25117points to.
25118
25119@item
25120The startup code from libgcc never sets @code{EIND}.
25121Notice that startup code is a blend of code from libgcc and AVR-LibC.
25122For the impact of AVR-LibC on @code{EIND}, see the
f5448384 25123@w{@uref{https://avrdudes.github.io/avr-libc/avr-libc-user-manual/,AVR-LibC user manual}}.
d77de738
ML
25124
25125@item
25126It is legitimate for user-specific startup code to set up @code{EIND}
25127early, for example by means of initialization code located in
25128section @code{.init3}. Such code runs prior to general startup code
25129that initializes RAM and calls constructors, but after the bit
25130of startup code from AVR-LibC that sets @code{EIND} to the segment
25131where the vector table is located.
25132@example
25133#include <avr/io.h>
25134
25135static void
25136__attribute__((section(".init3"),naked,used,no_instrument_function))
25137init3_set_eind (void)
25138@{
25139 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
25140 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
25141@}
25142@end example
25143
25144@noindent
25145The @code{__trampolines_start} symbol is defined in the linker script.
25146
25147@item
25148Stubs are generated automatically by the linker if
25149the following two conditions are met:
25150@itemize @minus
25151
25152@item The address of a label is taken by means of the @code{gs} modifier
25153(short for @emph{generate stubs}) like so:
25154@example
25155LDI r24, lo8(gs(@var{func}))
25156LDI r25, hi8(gs(@var{func}))
25157@end example
25158@item The final location of that label is in a code segment
25159@emph{outside} the segment where the stubs are located.
25160@end itemize
25161
25162@item
25163The compiler emits such @code{gs} modifiers for code labels in the
25164following situations:
25165@itemize @minus
25166@item Taking address of a function or code label.
25167@item Computed goto.
25168@item If prologue-save function is used, see @option{-mcall-prologues}
25169command-line option.
25170@item Switch/case dispatch tables. If you do not want such dispatch
25171tables you can specify the @option{-fno-jump-tables} command-line option.
25172@item C and C++ constructors/destructors called during startup/shutdown.
25173@item If the tools hit a @code{gs()} modifier explained above.
25174@end itemize
25175
25176@item
25177Jumping to non-symbolic addresses like so is @emph{not} supported:
25178
25179@example
25180int main (void)
25181@{
25182 /* Call function at word address 0x2 */
25183 return ((int(*)(void)) 0x2)();
25184@}
25185@end example
25186
25187Instead, a stub has to be set up, i.e.@: the function has to be called
25188through a symbol (@code{func_4} in the example):
25189
25190@example
25191int main (void)
25192@{
25193 extern int func_4 (void);
25194
25195 /* Call function at byte address 0x4 */
25196 return func_4();
25197@}
25198@end example
25199
25200and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
25201Alternatively, @code{func_4} can be defined in the linker script.
25202@end itemize
25203
b793c218 25204@anchor{ramp}
d77de738
ML
25205@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
25206@cindex @code{RAMPD}
25207@cindex @code{RAMPX}
25208@cindex @code{RAMPY}
25209@cindex @code{RAMPZ}
25210Some AVR devices support memories larger than the 64@tie{}KiB range
25211that can be accessed with 16-bit pointers. To access memory locations
25212outside this 64@tie{}KiB range, the content of a @code{RAMP}
25213register is used as high part of the address:
25214The @code{X}, @code{Y}, @code{Z} address register is concatenated
25215with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
25216register, respectively, to get a wide address. Similarly,
25217@code{RAMPD} is used together with direct addressing.
25218
25219@itemize
25220@item
25221The startup code initializes the @code{RAMP} special function
25222registers with zero.
25223
25224@item
25225If a @ref{AVR Named Address Spaces,named address space} other than
25226generic or @code{__flash} is used, then @code{RAMPZ} is set
25227as needed before the operation.
25228
25229@item
25230If the device supports RAM larger than 64@tie{}KiB and the compiler
25231needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
25232is reset to zero after the operation.
25233
25234@item
25235If the device comes with a specific @code{RAMP} register, the ISR
25236prologue/epilogue saves/restores that SFR and initializes it with
25237zero in case the ISR code might (implicitly) use it.
25238
25239@item
25240RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
25241If you use inline assembler to read from locations outside the
2524216-bit address range and change one of the @code{RAMP} registers,
25243you must reset it to zero after the access.
25244
25245@end itemize
25246
b793c218 25247@anchor{avr-macros}
d77de738
ML
25248@subsubsection AVR Built-in Macros
25249
25250GCC defines several built-in macros so that the user code can test
25251for the presence or absence of features. Almost any of the following
25252built-in macros are deduced from device capabilities and thus
25253triggered by the @option{-mmcu=} command-line option.
25254
25255For even more AVR-specific built-in macros see
25256@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
25257
25258@table @code
25259
25260@item __AVR_ARCH__
25261Build-in macro that resolves to a decimal number that identifies the
25262architecture and depends on the @option{-mmcu=@var{mcu}} option.
25263Possible values are:
25264
25265@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
25266@code{4}, @code{5}, @code{51}, @code{6}
25267
25268for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
25269@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
25270
25271respectively and
25272
25273@code{100},
25274@code{102}, @code{103}, @code{104},
25275@code{105}, @code{106}, @code{107}
25276
25277for @var{mcu}=@code{avrtiny},
25278@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
25279@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
25280If @var{mcu} specifies a device, this built-in macro is set
25281accordingly. For example, with @option{-mmcu=atmega8} the macro is
25282defined to @code{4}.
25283
25284@item __AVR_@var{Device}__
25285Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
25286the device's name. For example, @option{-mmcu=atmega8} defines the
25287built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
25288@code{__AVR_ATtiny261A__}, etc.
25289
25290The built-in macros' names follow
25291the scheme @code{__AVR_@var{Device}__} where @var{Device} is
25292the device name as from the AVR user manual. The difference between
25293@var{Device} in the built-in macro and @var{device} in
25294@option{-mmcu=@var{device}} is that the latter is always lowercase.
25295
25296If @var{device} is not a device but only a core architecture like
25297@samp{avr51}, this macro is not defined.
25298
25299@item __AVR_DEVICE_NAME__
25300Setting @option{-mmcu=@var{device}} defines this built-in macro to
25301the device's name. For example, with @option{-mmcu=atmega8} the macro
25302is defined to @code{atmega8}.
25303
25304If @var{device} is not a device but only a core architecture like
25305@samp{avr51}, this macro is not defined.
25306
22a0cba3
GJL
25307@item __AVR_CVT__
25308The code is being compiled with option @code{-mcvt} to use a
25309@emph{compact vector table}.
25310
d77de738
ML
25311@item __AVR_XMEGA__
25312The device / architecture belongs to the XMEGA family of devices.
25313
5cff288c
GJL
25314@item __AVR_HAVE_ADIW__
25315The device has the @code{ADIW} and @code{SBIW} instructions.
25316
d77de738
ML
25317@item __AVR_HAVE_ELPM__
25318The device has the @code{ELPM} instruction.
25319
25320@item __AVR_HAVE_ELPMX__
25321The device has the @code{ELPM R@var{n},Z} and @code{ELPM
25322R@var{n},Z+} instructions.
25323
d77de738
ML
25324@item __AVR_HAVE_LPMX__
25325The device has the @code{LPM R@var{n},Z} and
25326@code{LPM R@var{n},Z+} instructions.
25327
5cff288c
GJL
25328@item __AVR_HAVE_MOVW__
25329The device has the @code{MOVW} instruction to perform 16-bit
25330register-register moves.
25331
d77de738 25332@item __AVR_HAVE_MUL__
a0e64a04 25333The device has a hardware multiplier.
d77de738
ML
25334
25335@item __AVR_HAVE_JMP_CALL__
25336The device has the @code{JMP} and @code{CALL} instructions.
25337This is the case for devices with more than 8@tie{}KiB of program
25338memory.
25339
25340@item __AVR_HAVE_EIJMP_EICALL__
25341@itemx __AVR_3_BYTE_PC__
25342The device has the @code{EIJMP} and @code{EICALL} instructions.
25343This is the case for devices with more than 128@tie{}KiB of program memory.
25344This also means that the program counter
25345(PC) is 3@tie{}bytes wide.
25346
25347@item __AVR_2_BYTE_PC__
25348The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
25349with up to 128@tie{}KiB of program memory.
25350
25351@item __AVR_HAVE_8BIT_SP__
25352@itemx __AVR_HAVE_16BIT_SP__
25353The stack pointer (SP) register is treated as 8-bit respectively
2535416-bit register by the compiler.
25355The definition of these macros is affected by @option{-mtiny-stack}.
25356
25357@item __AVR_HAVE_SPH__
25358@itemx __AVR_SP8__
25359The device has the SPH (high part of stack pointer) special function
25360register or has an 8-bit stack pointer, respectively.
25361The definition of these macros is affected by @option{-mmcu=} and
25362in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
25363by @option{-msp8}.
25364
25365@item __AVR_HAVE_RAMPD__
25366@itemx __AVR_HAVE_RAMPX__
25367@itemx __AVR_HAVE_RAMPY__
25368@itemx __AVR_HAVE_RAMPZ__
25369The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
25370@code{RAMPZ} special function register, respectively.
25371
25372@item __NO_INTERRUPTS__
25373This macro reflects the @option{-mno-interrupts} command-line option.
25374
25375@item __AVR_ERRATA_SKIP__
25376@itemx __AVR_ERRATA_SKIP_JMP_CALL__
25377Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
25378instructions because of a hardware erratum. Skip instructions are
25379@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
25380The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
25381set.
25382
25383@item __AVR_ISA_RMW__
25384The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
25385
25386@item __AVR_SFR_OFFSET__=@var{offset}
25387Instructions that can address I/O special function registers directly
25388like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
25389address as if addressed by an instruction to access RAM like @code{LD}
25390or @code{STS}. This offset depends on the device architecture and has
25391to be subtracted from the RAM address in order to get the
25392respective I/O@tie{}address.
25393
25394@item __AVR_SHORT_CALLS__
25395The @option{-mshort-calls} command line option is set.
25396
25397@item __AVR_PM_BASE_ADDRESS__=@var{addr}
25398Some devices support reading from flash memory by means of @code{LD*}
25399instructions. The flash memory is seen in the data address space
25400at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
25401is not defined, this feature is not available. If defined,
25402the address space is linear and there is no need to put
25403@code{.rodata} into RAM. This is handled by the default linker
25404description file, and is currently available for
25405@code{avrtiny} and @code{avrxmega3}. Even more convenient,
25406there is no need to use address spaces like @code{__flash} or
25407features like attribute @code{progmem} and @code{pgm_read_*}.
25408
48448055
GJL
25409@item __AVR_HAVE_FLMAP__
25410This macro is defined provided the following conditions are met:
25411@itemize @bullet
25412@item The device has the @code{NVMCTRL_CTRLB.FLMAP} bitfield.
25413This applies to the AVR64* and AVR128* devices.
25414@item It's not known at assembler-time which emulation will be used.
25415@end itemize
25416This implies the compiler was configured with GNU Binutils that implement
25417@w{@uref{https://sourceware.org/PR31124,PR31124}}.
25418
25419@item __AVR_RODATA_IN_RAM__
25420This macro is undefined when the code is compiled for a core architecture.
25421
25422When the code is compiled for a device, the macro is defined to@tie{}1
25423when the @code{.rodata} sections for read-only data is located in RAM;
25424and defined to@tie{}0, otherwise.
25425
d77de738 25426@item __WITH_AVRLIBC__
9ee39fcb 25427The compiler is configured to be used together with AVR-LibC.
d77de738
ML
25428See the @option{--with-avrlibc} configure option.
25429
0f1de0c4
GJL
25430@item __HAVE_SIGNAL_N__
25431The compiler supports the @code{signal(@var{num})} and
25432@code{interrupt(@var{num})}
25433@ref{AVR Function Attributes,,function attributes}
25434with an argument @var{num} that specifies the number of the
25435interrupt service routine.
25436
d77de738
ML
25437@item __HAVE_DOUBLE_MULTILIB__
25438Defined if @option{-mdouble=} acts as a multilib option.
25439
25440@item __HAVE_DOUBLE32__
25441@itemx __HAVE_DOUBLE64__
25442Defined if the compiler supports 32-bit double resp. 64-bit double.
25443The actual layout is specified by option @option{-mdouble=}.
25444
25445@item __DEFAULT_DOUBLE__
25446The size in bits of @code{double} if @option{-mdouble=} is not set.
25447To test the layout of @code{double} in a program, use the built-in
25448macro @code{__SIZEOF_DOUBLE__}.
25449
25450@item __HAVE_LONG_DOUBLE32__
25451@itemx __HAVE_LONG_DOUBLE64__
25452@itemx __HAVE_LONG_DOUBLE_MULTILIB__
25453@itemx __DEFAULT_LONG_DOUBLE__
25454Same as above, but for @code{long double} instead of @code{double}.
25455
25456@item __WITH_DOUBLE_COMPARISON__
25457Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
25458@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
25459and is defined to @code{2} or @code{3}.
25460
25461@item __WITH_LIBF7_LIBGCC__
25462@itemx __WITH_LIBF7_MATH__
25463@itemx __WITH_LIBF7_MATH_SYMBOLS__
25464Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
25465@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
25466
25467@end table
25468
31461d2b
GJL
25469@subsubsection AVR Internal Options
25470The following options are used internally by the compiler and to communicate
25471between device specs files and the compiler proper. You don't need to set these
25472options by hand, in particular they are not optimization options.
25473Using these options in the wrong way may lead to sub-optimal or wrong code.
25474They are documented for completeness, and in order to get a better
25475understanding of
25476@w{@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device specs}}
25477files.
25478
25479@table @gcctabopt
25480
25481@opindex mn-flash
25482@item -mn-flash=@var{num}
25483Assume that the flash memory has a size of @var{num} times 64@tie{}KiB.
25484This determines which @code{__flash@var{N}} address spaces are available.
25485
48448055
GJL
25486@opindex mflmap
25487@item -mflmap
25488The device has the @code{FLMAP} bit field located in special function
25489register @code{NVMCTRL_CTRLB}.
25490
31461d2b
GJL
25491@opindex mrmw
25492@item -mrmw
25493Assume that the device supports the Read-Modify-Write
25494instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
25495
25496@opindex mshort-calls
25497@item -mshort-calls
25498
25499Assume that @code{RJMP} and @code{RCALL} can target the whole
25500program memory. This option is used for multilib generation and selection
25501for the devices from architecture @code{avrxmega3}.
25502
42503cc2
GJL
25503@opindex mskip-bug
25504@item -mskip-bug
25505
25506Generate code without skips (@code{CPSE}, @code{SBRS},
25507@code{SBRC}, @code{SBIS}, @code{SBIC}) over 32-bit instructions.
25508
31461d2b
GJL
25509@opindex msp8
25510@item -msp8
25511Treat the stack pointer register as an 8-bit register,
25512i.e.@: assume the high byte of the stack pointer is zero.
25513This option is used by the compiler to select and
25514build multilibs for architectures @code{avr2} and @code{avr25}.
25515These architectures mix devices with and without @code{SPH}.
25516
25517@end table
25518
d77de738
ML
25519@node Blackfin Options
25520@subsection Blackfin Options
25521@cindex Blackfin Options
25522
25523@table @gcctabopt
d77de738 25524@opindex mcpu=
ddf6fe37 25525@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
25526Specifies the name of the target Blackfin processor. Currently, @var{cpu}
25527can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
25528@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
25529@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
25530@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
25531@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
25532@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
25533@samp{bf561}, @samp{bf592}.
25534
25535The optional @var{sirevision} specifies the silicon revision of the target
25536Blackfin processor. Any workarounds available for the targeted silicon revision
25537are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
25538If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
25539are enabled. The @code{__SILICON_REVISION__} macro is defined to two
25540hexadecimal digits representing the major and minor numbers in the silicon
25541revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
25542is not defined. If @var{sirevision} is @samp{any}, the
25543@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
25544If this optional @var{sirevision} is not used, GCC assumes the latest known
25545silicon revision of the targeted Blackfin processor.
25546
25547GCC defines a preprocessor macro for the specified @var{cpu}.
25548For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
25549provided by libgloss to be linked in if @option{-msim} is not given.
25550
25551Without this option, @samp{bf532} is used as the processor by default.
25552
25553Note that support for @samp{bf561} is incomplete. For @samp{bf561},
25554only the preprocessor macro is defined.
25555
d77de738 25556@opindex msim
ddf6fe37 25557@item -msim
d77de738
ML
25558Specifies that the program will be run on the simulator. This causes
25559the simulator BSP provided by libgloss to be linked in. This option
25560has effect only for @samp{bfin-elf} toolchain.
25561Certain other options, such as @option{-mid-shared-library} and
25562@option{-mfdpic}, imply @option{-msim}.
25563
d77de738 25564@opindex momit-leaf-frame-pointer
ddf6fe37 25565@item -momit-leaf-frame-pointer
d77de738
ML
25566Don't keep the frame pointer in a register for leaf functions. This
25567avoids the instructions to save, set up and restore frame pointers and
25568makes an extra register available in leaf functions.
25569
d77de738 25570@opindex mspecld-anomaly
ddf6fe37 25571@item -mspecld-anomaly
d77de738
ML
25572When enabled, the compiler ensures that the generated code does not
25573contain speculative loads after jump instructions. If this option is used,
25574@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
25575
d77de738
ML
25576@opindex mno-specld-anomaly
25577@opindex mspecld-anomaly
ddf6fe37 25578@item -mno-specld-anomaly
d77de738
ML
25579Don't generate extra code to prevent speculative loads from occurring.
25580
d77de738 25581@opindex mcsync-anomaly
ddf6fe37 25582@item -mcsync-anomaly
d77de738
ML
25583When enabled, the compiler ensures that the generated code does not
25584contain CSYNC or SSYNC instructions too soon after conditional branches.
25585If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
25586
d77de738
ML
25587@opindex mno-csync-anomaly
25588@opindex mcsync-anomaly
ddf6fe37 25589@item -mno-csync-anomaly
d77de738
ML
25590Don't generate extra code to prevent CSYNC or SSYNC instructions from
25591occurring too soon after a conditional branch.
25592
d77de738 25593@opindex mlow64k
ddf6fe37 25594@item -mlow64k
d77de738
ML
25595When enabled, the compiler is free to take advantage of the knowledge that
25596the entire program fits into the low 64k of memory.
25597
d77de738 25598@opindex mno-low64k
ddf6fe37 25599@item -mno-low64k
d77de738
ML
25600Assume that the program is arbitrarily large. This is the default.
25601
d77de738 25602@opindex mstack-check-l1
ddf6fe37 25603@item -mstack-check-l1
d77de738
ML
25604Do stack checking using information placed into L1 scratchpad memory by the
25605uClinux kernel.
25606
d77de738 25607@opindex mid-shared-library
ddf6fe37 25608@item -mid-shared-library
d77de738
ML
25609Generate code that supports shared libraries via the library ID method.
25610This allows for execute in place and shared libraries in an environment
25611without virtual memory management. This option implies @option{-fPIC}.
25612With a @samp{bfin-elf} target, this option implies @option{-msim}.
25613
d77de738
ML
25614@opindex mno-id-shared-library
25615@opindex mid-shared-library
ddf6fe37 25616@item -mno-id-shared-library
d77de738
ML
25617Generate code that doesn't assume ID-based shared libraries are being used.
25618This is the default.
25619
d77de738 25620@opindex mleaf-id-shared-library
ddf6fe37 25621@item -mleaf-id-shared-library
d77de738
ML
25622Generate code that supports shared libraries via the library ID method,
25623but assumes that this library or executable won't link against any other
25624ID shared libraries. That allows the compiler to use faster code for jumps
25625and calls.
25626
d77de738
ML
25627@opindex mno-leaf-id-shared-library
25628@opindex mleaf-id-shared-library
ddf6fe37 25629@item -mno-leaf-id-shared-library
d77de738
ML
25630Do not assume that the code being compiled won't link against any ID shared
25631libraries. Slower code is generated for jump and call insns.
25632
d77de738 25633@opindex mshared-library-id
ddf6fe37 25634@item -mshared-library-id=n
d77de738
ML
25635Specifies the identification number of the ID-based shared library being
25636compiled. Specifying a value of 0 generates more compact code; specifying
25637other values forces the allocation of that number to the current
25638library but is no more space- or time-efficient than omitting this option.
25639
d77de738 25640@opindex msep-data
ddf6fe37 25641@item -msep-data
d77de738
ML
25642Generate code that allows the data segment to be located in a different
25643area of memory from the text segment. This allows for execute in place in
25644an environment without virtual memory management by eliminating relocations
25645against the text section.
25646
d77de738
ML
25647@opindex mno-sep-data
25648@opindex msep-data
ddf6fe37 25649@item -mno-sep-data
d77de738
ML
25650Generate code that assumes that the data segment follows the text segment.
25651This is the default.
25652
d77de738
ML
25653@opindex mlong-calls
25654@opindex mno-long-calls
ddf6fe37
AA
25655@item -mlong-calls
25656@itemx -mno-long-calls
d77de738
ML
25657Tells the compiler to perform function calls by first loading the
25658address of the function into a register and then performing a subroutine
25659call on this register. This switch is needed if the target function
25660lies outside of the 24-bit addressing range of the offset-based
25661version of subroutine call instruction.
25662
25663This feature is not enabled by default. Specifying
25664@option{-mno-long-calls} restores the default behavior. Note these
25665switches have no effect on how the compiler generates code to handle
25666function calls via function pointers.
25667
d77de738 25668@opindex mfast-fp
ddf6fe37 25669@item -mfast-fp
d77de738
ML
25670Link with the fast floating-point library. This library relaxes some of
25671the IEEE floating-point standard's rules for checking inputs against
25672Not-a-Number (NAN), in the interest of performance.
25673
d77de738 25674@opindex minline-plt
ddf6fe37 25675@item -minline-plt
d77de738
ML
25676Enable inlining of PLT entries in function calls to functions that are
25677not known to bind locally. It has no effect without @option{-mfdpic}.
25678
d77de738 25679@opindex mmulticore
ddf6fe37 25680@item -mmulticore
a0e64a04
PN
25681Build a standalone application for multicore Blackfin processors.
25682This option causes proper start files and link scripts supporting
25683multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
25684It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
d77de738
ML
25685
25686This option can be used with @option{-mcorea} or @option{-mcoreb}, which
25687selects the one-application-per-core programming model. Without
25688@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
25689programming model is used. In this model, the main function of Core B
25690should be named as @code{coreb_main}.
25691
25692If this option is not used, the single-core application programming
25693model is used.
25694
d77de738 25695@opindex mcorea
ddf6fe37 25696@item -mcorea
d77de738
ML
25697Build a standalone application for Core A of BF561 when using
25698the one-application-per-core programming model. Proper start files
25699and link scripts are used to support Core A, and the macro
25700@code{__BFIN_COREA} is defined.
25701This option can only be used in conjunction with @option{-mmulticore}.
25702
d77de738 25703@opindex mcoreb
ddf6fe37 25704@item -mcoreb
d77de738
ML
25705Build a standalone application for Core B of BF561 when using
25706the one-application-per-core programming model. Proper start files
25707and link scripts are used to support Core B, and the macro
25708@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
a0e64a04 25709should be used instead of @code{main}.
d77de738
ML
25710This option can only be used in conjunction with @option{-mmulticore}.
25711
d77de738 25712@opindex msdram
ddf6fe37 25713@item -msdram
d77de738
ML
25714Build a standalone application for SDRAM. Proper start files and
25715link scripts are used to put the application into SDRAM, and the macro
25716@code{__BFIN_SDRAM} is defined.
25717The loader should initialize SDRAM before loading the application.
25718
d77de738 25719@opindex micplb
ddf6fe37 25720@item -micplb
d77de738
ML
25721Assume that ICPLBs are enabled at run time. This has an effect on certain
25722anomaly workarounds. For Linux targets, the default is to assume ICPLBs
25723are enabled; for standalone applications the default is off.
25724@end table
25725
25726@node C6X Options
25727@subsection C6X Options
25728@cindex C6X Options
25729
25730@table @gcctabopt
d77de738 25731@opindex march
ddf6fe37 25732@item -march=@var{name}
d77de738
ML
25733This specifies the name of the target architecture. GCC uses this
25734name to determine what kind of instructions it can emit when generating
25735assembly code. Permissible names are: @samp{c62x},
25736@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
25737
d77de738 25738@opindex mbig-endian
ddf6fe37 25739@item -mbig-endian
d77de738
ML
25740Generate code for a big-endian target.
25741
d77de738 25742@opindex mlittle-endian
ddf6fe37 25743@item -mlittle-endian
d77de738
ML
25744Generate code for a little-endian target. This is the default.
25745
d77de738 25746@opindex msim
ddf6fe37 25747@item -msim
d77de738
ML
25748Choose startup files and linker script suitable for the simulator.
25749
d77de738 25750@opindex msdata=default
ddf6fe37 25751@item -msdata=default
d77de738
ML
25752Put small global and static data in the @code{.neardata} section,
25753which is pointed to by register @code{B14}. Put small uninitialized
25754global and static data in the @code{.bss} section, which is adjacent
25755to the @code{.neardata} section. Put small read-only data into the
25756@code{.rodata} section. The corresponding sections used for large
25757pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
25758
d77de738 25759@opindex msdata=all
ddf6fe37 25760@item -msdata=all
d77de738
ML
25761Put all data, not just small objects, into the sections reserved for
25762small data, and use addressing relative to the @code{B14} register to
25763access them.
25764
d77de738 25765@opindex msdata=none
ddf6fe37 25766@item -msdata=none
d77de738
ML
25767Make no use of the sections reserved for small data, and use absolute
25768addresses to access all data. Put all initialized global and static
25769data in the @code{.fardata} section, and all uninitialized data in the
25770@code{.far} section. Put all constant data into the @code{.const}
25771section.
25772@end table
25773
25774@node CRIS Options
25775@subsection CRIS Options
25776@cindex CRIS Options
25777
25778These options are defined specifically for the CRIS ports.
25779
25780@table @gcctabopt
d77de738
ML
25781@opindex march
25782@opindex mcpu
ddf6fe37
AA
25783@item -march=@var{architecture-type}
25784@itemx -mcpu=@var{architecture-type}
d77de738
ML
25785Generate code for the specified architecture. The choices for
25786@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
25787respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
25788Default is @samp{v0}.
25789
d77de738 25790@opindex mtune
ddf6fe37 25791@item -mtune=@var{architecture-type}
d77de738
ML
25792Tune to @var{architecture-type} everything applicable about the generated
25793code, except for the ABI and the set of available instructions. The
25794choices for @var{architecture-type} are the same as for
25795@option{-march=@var{architecture-type}}.
25796
d77de738 25797@opindex mmax-stack-frame
ddf6fe37 25798@item -mmax-stack-frame=@var{n}
d77de738
ML
25799Warn when the stack frame of a function exceeds @var{n} bytes.
25800
d77de738
ML
25801@opindex metrax4
25802@opindex metrax100
ddf6fe37
AA
25803@item -metrax4
25804@itemx -metrax100
d77de738
ML
25805The options @option{-metrax4} and @option{-metrax100} are synonyms for
25806@option{-march=v3} and @option{-march=v8} respectively.
25807
d77de738
ML
25808@opindex mmul-bug-workaround
25809@opindex mno-mul-bug-workaround
ddf6fe37
AA
25810@item -mmul-bug-workaround
25811@itemx -mno-mul-bug-workaround
d77de738
ML
25812Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
25813models where it applies. This option is disabled by default.
25814
d77de738 25815@opindex mpdebug
ddf6fe37 25816@item -mpdebug
d77de738
ML
25817Enable CRIS-specific verbose debug-related information in the assembly
25818code. This option also has the effect of turning off the @samp{#NO_APP}
25819formatted-code indicator to the assembler at the beginning of the
25820assembly file.
25821
d77de738 25822@opindex mcc-init
ddf6fe37 25823@item -mcc-init
d77de738
ML
25824Do not use condition-code results from previous instruction; always emit
25825compare and test instructions before use of condition codes.
25826
d77de738
ML
25827@opindex mno-side-effects
25828@opindex mside-effects
ddf6fe37 25829@item -mno-side-effects
d77de738
ML
25830Do not emit instructions with side effects in addressing modes other than
25831post-increment.
25832
d77de738
ML
25833@opindex mstack-align
25834@opindex mno-stack-align
25835@opindex mdata-align
25836@opindex mno-data-align
25837@opindex mconst-align
25838@opindex mno-const-align
ddf6fe37
AA
25839@item -mstack-align
25840@itemx -mno-stack-align
25841@itemx -mdata-align
25842@itemx -mno-data-align
25843@itemx -mconst-align
25844@itemx -mno-const-align
d77de738
ML
25845These options (@samp{no-} options) arrange (eliminate arrangements) for the
25846stack frame, individual data and constants to be aligned for the maximum
25847single data access size for the chosen CPU model. The default is to
25848arrange for 32-bit alignment. ABI details such as structure layout are
25849not affected by these options.
25850
d77de738
ML
25851@opindex m32-bit
25852@opindex m16-bit
25853@opindex m8-bit
ddf6fe37
AA
25854@item -m32-bit
25855@itemx -m16-bit
25856@itemx -m8-bit
d77de738
ML
25857Similar to the stack- data- and const-align options above, these options
25858arrange for stack frame, writable data and constants to all be 32-bit,
2585916-bit or 8-bit aligned. The default is 32-bit alignment.
25860
d77de738
ML
25861@opindex mno-prologue-epilogue
25862@opindex mprologue-epilogue
ddf6fe37
AA
25863@item -mno-prologue-epilogue
25864@itemx -mprologue-epilogue
d77de738
ML
25865With @option{-mno-prologue-epilogue}, the normal function prologue and
25866epilogue which set up the stack frame are omitted and no return
25867instructions or return sequences are generated in the code. Use this
25868option only together with visual inspection of the compiled code: no
25869warnings or errors are generated when call-saved registers must be saved,
25870or storage for local variables needs to be allocated.
25871
d77de738 25872@opindex melf
ddf6fe37 25873@item -melf
d77de738
ML
25874Legacy no-op option.
25875
d77de738 25876@opindex sim
ddf6fe37 25877@item -sim
d77de738
ML
25878This option arranges
25879to link with input-output functions from a simulator library. Code,
25880initialized data and zero-initialized data are allocated consecutively.
25881
d77de738 25882@opindex sim2
ddf6fe37 25883@item -sim2
d77de738
ML
25884Like @option{-sim}, but pass linker options to locate initialized data at
258850x40000000 and zero-initialized data at 0x80000000.
25886@end table
25887
25888@node C-SKY Options
25889@subsection C-SKY Options
25890@cindex C-SKY Options
25891
25892GCC supports these options when compiling for C-SKY V2 processors.
25893
25894@table @gcctabopt
25895
d77de738 25896@opindex march=
ddf6fe37 25897@item -march=@var{arch}
d77de738
ML
25898Specify the C-SKY target architecture. Valid values for @var{arch} are:
25899@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
25900The default is @samp{ck810}.
25901
d77de738 25902@opindex mcpu=
ddf6fe37 25903@item -mcpu=@var{cpu}
d77de738
ML
25904Specify the C-SKY target processor. Valid values for @var{cpu} are:
25905@samp{ck801}, @samp{ck801t},
25906@samp{ck802}, @samp{ck802t}, @samp{ck802j},
25907@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
25908@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
25909@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
25910@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
25911@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
25912@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
25913@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
25914@samp{ck803eftr1}, @samp{ck803efhtr1},
25915@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
25916@samp{ck803sef}, @samp{ck803seft},
25917@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
25918@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
25919@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
25920@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
25921
d77de738 25922@opindex mbig-endian
d77de738 25923@opindex EB
d77de738 25924@opindex mlittle-endian
d77de738 25925@opindex EL
ddf6fe37
AA
25926@item -mbig-endian
25927@itemx -EB
25928@itemx -mlittle-endian
25929@itemx -EL
d77de738
ML
25930
25931Select big- or little-endian code. The default is little-endian.
25932
d77de738 25933@opindex mfloat-abi
ddf6fe37 25934@item -mfloat-abi=@var{name}
d77de738
ML
25935Specifies which floating-point ABI to use. Permissible values
25936are: @samp{soft}, @samp{softfp} and @samp{hard}.
25937
25938Specifying @samp{soft} causes GCC to generate output containing
25939library calls for floating-point operations.
25940@samp{softfp} allows the generation of code using hardware floating-point
25941instructions, but still uses the soft-float calling conventions.
25942@samp{hard} allows generation of floating-point instructions
25943and uses FPU-specific calling conventions.
25944
25945The default depends on the specific target configuration. Note that
25946the hard-float and soft-float ABIs are not link-compatible; you must
25947compile your entire program with the same ABI, and link with a
25948compatible set of libraries.
25949
d77de738 25950@opindex mhard-float
d77de738 25951@opindex msoft-float
ddf6fe37
AA
25952@item -mhard-float
25953@itemx -msoft-float
d77de738
ML
25954
25955Select hardware or software floating-point implementations.
25956The default is soft float.
25957
ddf6fe37 25958@opindex mdouble-float
d77de738
ML
25959@item -mdouble-float
25960@itemx -mno-double-float
d77de738
ML
25961When @option{-mhard-float} is in effect, enable generation of
25962double-precision float instructions. This is the default except
25963when compiling for CK803.
25964
ddf6fe37 25965@opindex mfdivdu
d77de738
ML
25966@item -mfdivdu
25967@itemx -mno-fdivdu
d77de738
ML
25968When @option{-mhard-float} is in effect, enable generation of
25969@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
25970This is the default except when compiling for CK803.
25971
d77de738 25972@opindex mfpu=
ddf6fe37 25973@item -mfpu=@var{fpu}
d77de738
ML
25974Select the floating-point processor. This option can only be used with
25975@option{-mhard-float}.
25976Values for @var{fpu} are
25977@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
25978@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
25979@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
25980
ddf6fe37 25981@opindex melrw
d77de738
ML
25982@item -melrw
25983@itemx -mno-elrw
d77de738
ML
25984Enable the extended @code{lrw} instruction. This option defaults to on
25985for CK801 and off otherwise.
25986
ddf6fe37 25987@opindex mistack
d77de738
ML
25988@item -mistack
25989@itemx -mno-istack
d77de738
ML
25990Enable interrupt stack instructions; the default is off.
25991
25992The @option{-mistack} option is required to handle the
25993@code{interrupt} and @code{isr} function attributes
25994(@pxref{C-SKY Function Attributes}).
25995
d77de738 25996@opindex mmp
ddf6fe37 25997@item -mmp
d77de738
ML
25998Enable multiprocessor instructions; the default is off.
25999
d77de738 26000@opindex mcp
ddf6fe37 26001@item -mcp
d77de738
ML
26002Enable coprocessor instructions; the default is off.
26003
d77de738 26004@opindex mcache
ddf6fe37 26005@item -mcache
d77de738
ML
26006Enable coprocessor instructions; the default is off.
26007
d77de738 26008@opindex msecurity
ddf6fe37 26009@item -msecurity
d77de738
ML
26010Enable C-SKY security instructions; the default is off.
26011
d77de738 26012@opindex mtrust
ddf6fe37 26013@item -mtrust
d77de738
ML
26014Enable C-SKY trust instructions; the default is off.
26015
d77de738 26016@opindex mdsp
d77de738 26017@opindex medsp
d77de738 26018@opindex mvdsp
ddf6fe37
AA
26019@item -mdsp
26020@itemx -medsp
26021@itemx -mvdsp
d77de738
ML
26022Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
26023All of these options default to off.
26024
ddf6fe37 26025@opindex mdiv
d77de738
ML
26026@item -mdiv
26027@itemx -mno-div
d77de738
ML
26028Generate divide instructions. Default is off.
26029
ddf6fe37 26030@opindex msmart
d77de738
ML
26031@item -msmart
26032@itemx -mno-smart
d77de738
ML
26033Generate code for Smart Mode, using only registers numbered 0-7 to allow
26034use of 16-bit instructions. This option is ignored for CK801 where this
26035is the required behavior, and it defaults to on for CK802.
26036For other targets, the default is off.
26037
ddf6fe37 26038@opindex mhigh-registers
d77de738
ML
26039@item -mhigh-registers
26040@itemx -mno-high-registers
d77de738
ML
26041Generate code using the high registers numbered 16-31. This option
26042is not supported on CK801, CK802, or CK803, and is enabled by default
26043for other processors.
26044
ddf6fe37 26045@opindex manchor
d77de738
ML
26046@item -manchor
26047@itemx -mno-anchor
d77de738
ML
26048Generate code using global anchor symbol addresses.
26049
ddf6fe37 26050@opindex mpushpop
d77de738
ML
26051@item -mpushpop
26052@itemx -mno-pushpop
d77de738
ML
26053Generate code using @code{push} and @code{pop} instructions. This option
26054defaults to on.
26055
ddf6fe37 26056@opindex mmultiple-stld
d77de738
ML
26057@item -mmultiple-stld
26058@itemx -mstm
26059@itemx -mno-multiple-stld
26060@itemx -mno-stm
d77de738
ML
26061Generate code using @code{stm} and @code{ldm} instructions. This option
26062isn't supported on CK801 but is enabled by default on other processors.
26063
ddf6fe37 26064@opindex mconstpool
d77de738
ML
26065@item -mconstpool
26066@itemx -mno-constpool
d77de738
ML
26067Create constant pools in the compiler instead of deferring it to the
26068assembler. This option is the default and required for correct code
26069generation on CK801 and CK802, and is optional on other processors.
26070
ddf6fe37 26071@opindex mstack-size
d77de738
ML
26072@item -mstack-size
26073@item -mno-stack-size
d77de738
ML
26074Emit @code{.stack_size} directives for each function in the assembly
26075output. This option defaults to off.
26076
ddf6fe37 26077@opindex mccrt
d77de738
ML
26078@item -mccrt
26079@itemx -mno-ccrt
d77de738
ML
26080Generate code for the C-SKY compiler runtime instead of libgcc. This
26081option defaults to off.
26082
d77de738 26083@opindex mbranch-cost=
ddf6fe37 26084@item -mbranch-cost=@var{n}
d77de738
ML
26085Set the branch costs to roughly @code{n} instructions. The default is 1.
26086
ddf6fe37 26087@opindex msched-prolog
d77de738
ML
26088@item -msched-prolog
26089@itemx -mno-sched-prolog
d77de738
ML
26090Permit scheduling of function prologue and epilogue sequences. Using
26091this option can result in code that is not compliant with the C-SKY V2 ABI
26092prologue requirements and that cannot be debugged or backtraced.
26093It is disabled by default.
26094
d77de738 26095@opindex msim
ddf6fe37 26096@item -msim
d77de738
ML
26097Links the library libsemi.a which is in compatible with simulator. Applicable
26098to ELF compiler only.
26099
26100@end table
26101
26226ace
SL
26102@node Cygwin and MinGW Options
26103@subsection Cygwin and MinGW Options
26104@cindex Cygwin and MinGW Options
26105@cindex Options for Cygwin and MinGW
26106
26107These additional options are available for Microsoft Windows targets:
26108
26109@table @gcctabopt
26110@opindex mconsole
26111@item -mconsole
26112This option
26113specifies that a console application is to be generated, by
26114instructing the linker to set the PE header subsystem type
26115required for console applications.
26116This option is available for Cygwin and MinGW targets and is
26117enabled by default on those targets.
26118
26119@opindex mcrtdll
26120@item -mcrtdll=@var{library}
26121Preprocess, compile or link with specified C RunTime DLL @var{library}.
26122This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__},
26123@code{_UCRT} and @code{__MSVCRT_VERSION__} for specified CRT @var{library},
26124choose start file for CRT @var{library} and link with CRT @var{library}.
26125Recognized CRT library names for proprocessor are:
26126@code{crtdll*}, @code{msvcrt10*}, @code{msvcrt20*}, @code{msvcrt40*},
26127@code{msvcr40*}, @code{msvcrtd*}, @code{msvcrt-os*},
26128@code{msvcr70*}, @code{msvcr71*}, @code{msvcr80*}, @code{msvcr90*},
26129@code{msvcr100*}, @code{msvcr110*}, @code{msvcr120*} and @code{ucrt*}.
26130If this options is not specified then the default MinGW import library
26131@code{msvcrt} is used for linking and no other adjustment for
26132preprocessor is done. MinGW import library @code{msvcrt} is just a
26133symlink to (or a copy of) another MinGW CRT import library
26134chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
26135is for Windows system CRT DLL library @code{msvcrt.dll} and
26136in most cases is the default MinGW import library.
26137Generally speaking, changing the CRT DLL requires recompiling
26138the entire MinGW CRT. This option is for experimental and testing
26139purposes only.
26140This option is available for MinGW targets.
26141
26142@opindex mdll
26143@item -mdll
26144This option is available for Cygwin and MinGW targets. It
26145specifies that a DLL---a dynamic link library---is to be
26146generated, enabling the selection of the required runtime
26147startup object and entry point.
26148
26149@opindex mnop-fun-dllimport
26150@item -mnop-fun-dllimport
26151This option is available for Cygwin and MinGW targets. It
26152specifies that the @code{dllimport} attribute should be ignored.
26153
26154@opindex mthreads
26155@item -mthreads
26156This option is available for MinGW targets. It specifies
26157that MinGW-specific thread support is to be used.
26158
26159@opindex municode
26160@item -municode
26161This option is available for MinGW-w64 targets. It causes
26162the @code{UNICODE} preprocessor macro to be predefined, and
26163chooses Unicode-capable runtime startup code.
26164
26165@opindex mwin32
26166@item -mwin32
26167This option is available for Cygwin and MinGW targets. It
26168specifies that the typical Microsoft Windows predefined macros are to
26169be set in the pre-processor, but does not influence the choice
26170of runtime library/startup code.
26171
26172@opindex mwindows
26173@item -mwindows
26174This option is available for Cygwin and MinGW targets. It
26175specifies that a GUI application is to be generated by
26176instructing the linker to set the PE header subsystem type
26177appropriately.
26178
26179@opindex fno-set-stack-executable
26180@opindex fset-stack-executable
26181@item -fno-set-stack-executable
26182This option is available for MinGW targets. It specifies that
26183the executable flag for the stack used by nested functions isn't
26184set. This is necessary for binaries running in kernel mode of
26185Microsoft Windows, as there the User32 API, which is used to set executable
26186privileges, isn't available.
26187
26188@opindex fno-writable-relocated-rdata
26189@opindex fwritable-relocated-rdata
26190@item -fwritable-relocated-rdata
26191This option is available for MinGW and Cygwin targets. It specifies
26192that relocated-data in read-only section is put into the @code{.data}
26193section. This is a necessary for older runtimes not supporting
26194modification of @code{.rdata} sections for pseudo-relocation.
26195
26196@opindex mpe-aligned-commons
26197@item -mpe-aligned-commons
26198This option is available for Cygwin and MinGW targets. It
26199specifies that the GNU extension to the PE file format that
26200permits the correct alignment of COMMON variables should be
26201used when generating code. It is enabled by default if
26202GCC detects that the target assembler found during configuration
26203supports the feature.
26204@end table
26205
26206See also under @ref{x86 Options} for standard options.
26207
d77de738
ML
26208@node Darwin Options
26209@subsection Darwin Options
26210@cindex Darwin options
26211
26212These options are defined for all architectures running the Darwin operating
26213system.
26214
26215FSF GCC on Darwin does not create ``fat'' object files; it creates
26216an object file for the single architecture that GCC was built to
26217target. Apple's GCC on Darwin does create ``fat'' files if multiple
26218@option{-arch} options are used; it does so by running the compiler or
26219linker multiple times and joining the results together with
26220@file{lipo}.
26221
26222The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
26223@samp{i686}) is determined by the flags that specify the ISA
26224that GCC is targeting, like @option{-mcpu} or @option{-march}. The
26225@option{-force_cpusubtype_ALL} option can be used to override this.
26226
26227The Darwin tools vary in their behavior when presented with an ISA
26228mismatch. The assembler, @file{as}, only permits instructions to
26229be used that are valid for the subtype of the file it is generating,
26230so you cannot put 64-bit instructions in a @samp{ppc750} object file.
26231The linker for shared libraries, @file{/usr/bin/libtool}, fails
26232and prints an error if asked to create a shared library with a less
26233restrictive subtype than its input files (for instance, trying to put
26234a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
26235for executables, @command{ld}, quietly gives the executable the most
26236restrictive subtype of any of its input files.
26237
26238@table @gcctabopt
d77de738 26239@opindex F
ddf6fe37 26240@item -F@var{dir}
d77de738
ML
26241Add the framework directory @var{dir} to the head of the list of
26242directories to be searched for header files. These directories are
26243interleaved with those specified by @option{-I} options and are
26244scanned in a left-to-right order.
26245
26246A framework directory is a directory with frameworks in it. A
26247framework is a directory with a @file{Headers} and/or
26248@file{PrivateHeaders} directory contained directly in it that ends
26249in @file{.framework}. The name of a framework is the name of this
26250directory excluding the @file{.framework}. Headers associated with
26251the framework are found in one of those two directories, with
26252@file{Headers} being searched first. A subframework is a framework
26253directory that is in a framework's @file{Frameworks} directory.
26254Includes of subframework headers can only appear in a header of a
26255framework that contains the subframework, or in a sibling subframework
26256header. Two subframeworks are siblings if they occur in the same
26257framework. A subframework should not have the same name as a
26258framework; a warning is issued if this is violated. Currently a
26259subframework cannot have subframeworks; in the future, the mechanism
26260may be extended to support this. The standard frameworks can be found
26261in @file{/System/Library/Frameworks} and
26262@file{/Library/Frameworks}. An example include looks like
26263@code{#include <Framework/header.h>}, where @file{Framework} denotes
26264the name of the framework and @file{header.h} is found in the
26265@file{PrivateHeaders} or @file{Headers} directory.
26266
d77de738 26267@opindex iframework
ddf6fe37 26268@item -iframework@var{dir}
d77de738
ML
26269Like @option{-F} except the directory is a treated as a system
26270directory. The main difference between this @option{-iframework} and
26271@option{-F} is that with @option{-iframework} the compiler does not
26272warn about constructs contained within header files found via
26273@var{dir}. This option is valid only for the C family of languages.
26274
d77de738 26275@opindex gused
ddf6fe37 26276@item -gused
d77de738
ML
26277Emit debugging information for symbols that are used. For stabs
26278debugging format, this enables @option{-feliminate-unused-debug-symbols}.
26279This is by default ON@.
26280
d77de738 26281@opindex gfull
ddf6fe37 26282@item -gfull
d77de738
ML
26283Emit debugging information for all symbols and types.
26284
cdd4b3c0
IS
26285@opindex fconstant-cfstrings
26286@item -fconstant-cfstrings
26287The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
26288
26289@opindex mconstant-cfstrings
26290@item -mconstant-cfstrings
26291When the NeXT runtime is being used (the default on these systems), override
26292any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
26293literals to be laid out as constant CoreFoundation strings.
26294
26295@opindex mmacosx-version-min
d77de738 26296@item -mmacosx-version-min=@var{version}
cdd4b3c0
IS
26297The earliest version of MacOS X that this executable will run on is
26298@var{version}. Typical values supported for @var{version} include @code{12},
26299@code{10.12}, and @code{10.5.8}.
d77de738
ML
26300
26301If the compiler was built to use the system's headers by default,
26302then the default for this option is the system version on which the
26303compiler is running, otherwise the default is to make choices that
26304are compatible with as many systems and code bases as possible.
26305
d77de738 26306@opindex mkernel
ddf6fe37 26307@item -mkernel
d77de738
ML
26308Enable kernel development mode. The @option{-mkernel} option sets
26309@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
26310@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
26311@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
26312applicable. This mode also sets @option{-mno-altivec},
26313@option{-msoft-float}, @option{-fno-builtin} and
26314@option{-mlong-branch} for PowerPC targets.
26315
d77de738 26316@opindex mone-byte-bool
ddf6fe37 26317@item -mone-byte-bool
d77de738
ML
26318Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
26319By default @code{sizeof(bool)} is @code{4} when compiling for
26320Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
26321option has no effect on x86.
26322
26323@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
26324to generate code that is not binary compatible with code generated
26325without that switch. Using this switch may require recompiling all
26326other modules in a program, including system libraries. Use this
26327switch to conform to a non-default data model.
26328
d77de738
ML
26329@opindex mfix-and-continue
26330@opindex ffix-and-continue
26331@opindex findirect-data
ddf6fe37
AA
26332@item -mfix-and-continue
26333@itemx -ffix-and-continue
26334@itemx -findirect-data
d77de738
ML
26335Generate code suitable for fast turnaround development, such as to
26336allow GDB to dynamically load @file{.o} files into already-running
26337programs. @option{-findirect-data} and @option{-ffix-and-continue}
26338are provided for backwards compatibility.
26339
d77de738 26340@opindex all_load
ddf6fe37 26341@item -all_load
d77de738
ML
26342Loads all members of static archive libraries.
26343See man ld(1) for more information.
26344
d77de738 26345@opindex arch_errors_fatal
ddf6fe37 26346@item -arch_errors_fatal
d77de738
ML
26347Cause the errors having to do with files that have the wrong architecture
26348to be fatal.
26349
d77de738 26350@opindex bind_at_load
ddf6fe37 26351@item -bind_at_load
d77de738
ML
26352Causes the output file to be marked such that the dynamic linker will
26353bind all undefined references when the file is loaded or launched.
26354
d77de738 26355@opindex bundle
ddf6fe37 26356@item -bundle
d77de738
ML
26357Produce a Mach-o bundle format file.
26358See man ld(1) for more information.
26359
d77de738 26360@opindex bundle_loader
ddf6fe37 26361@item -bundle_loader @var{executable}
d77de738
ML
26362This option specifies the @var{executable} that will load the build
26363output file being linked. See man ld(1) for more information.
26364
d77de738 26365@opindex dynamiclib
ddf6fe37 26366@item -dynamiclib
d77de738
ML
26367When passed this option, GCC produces a dynamic library instead of
26368an executable when linking, using the Darwin @file{libtool} command.
26369
d77de738 26370@opindex force_cpusubtype_ALL
ddf6fe37 26371@item -force_cpusubtype_ALL
d77de738
ML
26372This causes GCC's output file to have the @samp{ALL} subtype, instead of
26373one controlled by the @option{-mcpu} or @option{-march} option.
26374
47b634a3
FXC
26375@opindex nodefaultrpaths
26376@item -nodefaultrpaths
26377Do not add default run paths for the compiler library directories to
26378executables, modules or dynamic libraries. On macOS 10.5 and later,
26379the embedded runpath is added by default unless the user adds
26380@option{-nodefaultrpaths} to the link line. Run paths are needed
26381(and therefore enforced) to build on macOS version 10.11 or later.
26382
d77de738
ML
26383@item -allowable_client @var{client_name}
26384@itemx -client_name
26385@itemx -compatibility_version
26386@itemx -current_version
26387@itemx -dead_strip
26388@itemx -dependency-file
26389@itemx -dylib_file
26390@itemx -dylinker_install_name
26391@itemx -dynamic
26392@itemx -exported_symbols_list
26393@itemx -filelist
26394@need 800
26395@itemx -flat_namespace
26396@itemx -force_flat_namespace
26397@itemx -headerpad_max_install_names
26398@itemx -image_base
26399@itemx -init
26400@itemx -install_name
26401@itemx -keep_private_externs
26402@itemx -multi_module
26403@itemx -multiply_defined
26404@itemx -multiply_defined_unused
26405@need 800
26406@itemx -noall_load
26407@itemx -no_dead_strip_inits_and_terms
26408@itemx -nofixprebinding
26409@itemx -nomultidefs
26410@itemx -noprebind
26411@itemx -noseglinkedit
26412@itemx -pagezero_size
26413@itemx -prebind
26414@itemx -prebind_all_twolevel_modules
26415@itemx -private_bundle
26416@need 800
26417@itemx -read_only_relocs
26418@itemx -sectalign
26419@itemx -sectobjectsymbols
26420@itemx -whyload
26421@itemx -seg1addr
26422@itemx -sectcreate
26423@itemx -sectobjectsymbols
26424@itemx -sectorder
26425@itemx -segaddr
26426@itemx -segs_read_only_addr
26427@need 800
26428@itemx -segs_read_write_addr
26429@itemx -seg_addr_table
26430@itemx -seg_addr_table_filename
26431@itemx -seglinkedit
26432@itemx -segprot
26433@itemx -segs_read_only_addr
26434@itemx -segs_read_write_addr
26435@itemx -single_module
26436@itemx -static
26437@itemx -sub_library
26438@need 800
d77de738
ML
26439@opindex allowable_client
26440@opindex client_name
26441@opindex compatibility_version
26442@opindex current_version
26443@opindex dead_strip
26444@opindex dependency-file
26445@opindex dylib_file
26446@opindex dylinker_install_name
26447@opindex dynamic
26448@opindex exported_symbols_list
26449@opindex filelist
26450@opindex flat_namespace
26451@opindex force_flat_namespace
26452@opindex headerpad_max_install_names
26453@opindex image_base
26454@opindex init
26455@opindex install_name
26456@opindex keep_private_externs
26457@opindex multi_module
26458@opindex multiply_defined
26459@opindex multiply_defined_unused
26460@opindex noall_load
26461@opindex no_dead_strip_inits_and_terms
26462@opindex nofixprebinding
26463@opindex nomultidefs
26464@opindex noprebind
26465@opindex noseglinkedit
26466@opindex pagezero_size
26467@opindex prebind
26468@opindex prebind_all_twolevel_modules
26469@opindex private_bundle
26470@opindex read_only_relocs
26471@opindex sectalign
26472@opindex sectobjectsymbols
26473@opindex whyload
26474@opindex seg1addr
26475@opindex sectcreate
26476@opindex sectobjectsymbols
26477@opindex sectorder
26478@opindex segaddr
26479@opindex segs_read_only_addr
26480@opindex segs_read_write_addr
26481@opindex seg_addr_table
26482@opindex seg_addr_table_filename
26483@opindex seglinkedit
26484@opindex segprot
26485@opindex segs_read_only_addr
26486@opindex segs_read_write_addr
26487@opindex single_module
26488@opindex static
26489@opindex sub_library
26490@opindex sub_umbrella
26491@opindex twolevel_namespace
26492@opindex umbrella
26493@opindex undefined
26494@opindex unexported_symbols_list
26495@opindex weak_reference_mismatches
26496@opindex whatsloaded
ddf6fe37
AA
26497@itemx -sub_umbrella
26498@itemx -twolevel_namespace
26499@itemx -umbrella
26500@itemx -undefined
26501@itemx -unexported_symbols_list
26502@itemx -weak_reference_mismatches
26503@itemx -whatsloaded
d77de738
ML
26504These options are passed to the Darwin linker. The Darwin linker man page
26505describes them in detail.
26506@end table
26507
26508@node DEC Alpha Options
26509@subsection DEC Alpha Options
26510
26511These @samp{-m} options are defined for the DEC Alpha implementations:
26512
26513@table @gcctabopt
d77de738
ML
26514@opindex mno-soft-float
26515@opindex msoft-float
ddf6fe37
AA
26516@item -mno-soft-float
26517@itemx -msoft-float
d77de738
ML
26518Use (do not use) the hardware floating-point instructions for
26519floating-point operations. When @option{-msoft-float} is specified,
26520functions in @file{libgcc.a} are used to perform floating-point
26521operations. Unless they are replaced by routines that emulate the
26522floating-point operations, or compiled in such a way as to call such
26523emulations routines, these routines issue floating-point
26524operations. If you are compiling for an Alpha without floating-point
26525operations, you must ensure that the library is built so as not to call
26526them.
26527
26528Note that Alpha implementations without floating-point operations are
26529required to have floating-point registers.
26530
d77de738
ML
26531@opindex mfp-reg
26532@opindex mno-fp-regs
ddf6fe37
AA
26533@item -mfp-reg
26534@itemx -mno-fp-regs
d77de738
ML
26535Generate code that uses (does not use) the floating-point register set.
26536@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
26537register set is not used, floating-point operands are passed in integer
26538registers as if they were integers and floating-point results are passed
26539in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
26540so any function with a floating-point argument or return value called by code
26541compiled with @option{-mno-fp-regs} must also be compiled with that
26542option.
26543
26544A typical use of this option is building a kernel that does not use,
26545and hence need not save and restore, any floating-point registers.
26546
d77de738 26547@opindex mieee
ddf6fe37 26548@item -mieee
d77de738
ML
26549The Alpha architecture implements floating-point hardware optimized for
26550maximum performance. It is mostly compliant with the IEEE floating-point
26551standard. However, for full compliance, software assistance is
26552required. This option generates code fully IEEE-compliant code
26553@emph{except} that the @var{inexact-flag} is not maintained (see below).
26554If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
26555defined during compilation. The resulting code is less efficient but is
26556able to correctly support denormalized numbers and exceptional IEEE
26557values such as not-a-number and plus/minus infinity. Other Alpha
26558compilers call this option @option{-ieee_with_no_inexact}.
26559
d77de738 26560@opindex mieee-with-inexact
ddf6fe37 26561@item -mieee-with-inexact
d77de738
ML
26562This is like @option{-mieee} except the generated code also maintains
26563the IEEE @var{inexact-flag}. Turning on this option causes the
26564generated code to implement fully-compliant IEEE math. In addition to
26565@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
26566macro. On some Alpha implementations the resulting code may execute
26567significantly slower than the code generated by default. Since there is
26568very little code that depends on the @var{inexact-flag}, you should
26569normally not specify this option. Other Alpha compilers call this
26570option @option{-ieee_with_inexact}.
26571
d77de738 26572@opindex mfp-trap-mode
ddf6fe37 26573@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
26574This option controls what floating-point related traps are enabled.
26575Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
26576The trap mode can be set to one of four values:
26577
26578@table @samp
26579@item n
26580This is the default (normal) setting. The only traps that are enabled
26581are the ones that cannot be disabled in software (e.g., division by zero
26582trap).
26583
26584@item u
26585In addition to the traps enabled by @samp{n}, underflow traps are enabled
26586as well.
26587
26588@item su
26589Like @samp{u}, but the instructions are marked to be safe for software
26590completion (see Alpha architecture manual for details).
26591
26592@item sui
26593Like @samp{su}, but inexact traps are enabled as well.
26594@end table
26595
d77de738 26596@opindex mfp-rounding-mode
ddf6fe37 26597@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
26598Selects the IEEE rounding mode. Other Alpha compilers call this option
26599@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
26600of:
26601
26602@table @samp
26603@item n
26604Normal IEEE rounding mode. Floating-point numbers are rounded towards
26605the nearest machine number or towards the even machine number in case
26606of a tie.
26607
26608@item m
26609Round towards minus infinity.
26610
26611@item c
26612Chopped rounding mode. Floating-point numbers are rounded towards zero.
26613
26614@item d
26615Dynamic rounding mode. A field in the floating-point control register
26616(@var{fpcr}, see Alpha architecture reference manual) controls the
26617rounding mode in effect. The C library initializes this register for
26618rounding towards plus infinity. Thus, unless your program modifies the
26619@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
26620@end table
26621
d77de738 26622@opindex mtrap-precision
ddf6fe37 26623@item -mtrap-precision=@var{trap-precision}
d77de738
ML
26624In the Alpha architecture, floating-point traps are imprecise. This
26625means without software assistance it is impossible to recover from a
26626floating trap and program execution normally needs to be terminated.
26627GCC can generate code that can assist operating system trap handlers
26628in determining the exact location that caused a floating-point trap.
26629Depending on the requirements of an application, different levels of
26630precisions can be selected:
26631
26632@table @samp
26633@item p
26634Program precision. This option is the default and means a trap handler
26635can only identify which program caused a floating-point exception.
26636
26637@item f
26638Function precision. The trap handler can determine the function that
26639caused a floating-point exception.
26640
26641@item i
26642Instruction precision. The trap handler can determine the exact
26643instruction that caused a floating-point exception.
26644@end table
26645
26646Other Alpha compilers provide the equivalent options called
26647@option{-scope_safe} and @option{-resumption_safe}.
26648
d77de738 26649@opindex mieee-conformant
ddf6fe37 26650@item -mieee-conformant
d77de738
ML
26651This option marks the generated code as IEEE conformant. You must not
26652use this option unless you also specify @option{-mtrap-precision=i} and either
26653@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
26654is to emit the line @samp{.eflag 48} in the function prologue of the
26655generated assembly file.
26656
d77de738 26657@opindex mbuild-constants
ddf6fe37 26658@item -mbuild-constants
d77de738
ML
26659Normally GCC examines a 32- or 64-bit integer constant to
26660see if it can construct it from smaller constants in two or three
26661instructions. If it cannot, it outputs the constant as a literal and
26662generates code to load it from the data segment at run time.
26663
26664Use this option to require GCC to construct @emph{all} integer constants
26665using code, even if it takes more instructions (the maximum is six).
26666
26667You typically use this option to build a shared library dynamic
26668loader. Itself a shared library, it must relocate itself in memory
26669before it can find the variables and constants in its own data segment.
26670
d77de738
ML
26671@opindex mbwx
26672@opindex mno-bwx
26673@opindex mcix
26674@opindex mno-cix
26675@opindex mfix
26676@opindex mno-fix
26677@opindex mmax
26678@opindex mno-max
ddf6fe37
AA
26679@item -mbwx
26680@itemx -mno-bwx
26681@itemx -mcix
26682@itemx -mno-cix
26683@itemx -mfix
26684@itemx -mno-fix
26685@itemx -mmax
26686@itemx -mno-max
d77de738
ML
26687Indicate whether GCC should generate code to use the optional BWX,
26688CIX, FIX and MAX instruction sets. The default is to use the instruction
26689sets supported by the CPU type specified via @option{-mcpu=} option or that
26690of the CPU on which GCC was built if none is specified.
26691
3d4d8221
MR
26692@opindex msafe-bwa
26693@opindex mno-safe-bwa
26694@item -msafe-bwa
26695@itemx -mno-safe-bwa
26696Indicate whether in the absence of the optional BWX instruction set
26697GCC should generate multi-thread and async-signal safe code for byte
26698and aligned word memory accesses.
26699
1b85c548
MR
26700@opindex msafe-partial
26701@opindex mno-safe-partial
26702@item -msafe-partial
26703@itemx -mno-safe-partial
26704Indicate whether GCC should generate multi-thread and async-signal
26705safe code for partial memory accesses, including piecemeal accesses
26706to unaligned data as well as block accesses to leading and trailing
26707parts of aggregate types or other objects in memory that do not
26708respectively start and end on an aligned 64-bit data boundary.
26709
d77de738
ML
26710@opindex mfloat-vax
26711@opindex mfloat-ieee
ddf6fe37
AA
26712@item -mfloat-vax
26713@itemx -mfloat-ieee
d77de738
ML
26714Generate code that uses (does not use) VAX F and G floating-point
26715arithmetic instead of IEEE single and double precision.
26716
d77de738
ML
26717@opindex mexplicit-relocs
26718@opindex mno-explicit-relocs
ddf6fe37
AA
26719@item -mexplicit-relocs
26720@itemx -mno-explicit-relocs
d77de738
ML
26721Older Alpha assemblers provided no way to generate symbol relocations
26722except via assembler macros. Use of these macros does not allow
26723optimal instruction scheduling. GNU binutils as of version 2.12
26724supports a new syntax that allows the compiler to explicitly mark
26725which relocations should apply to which instructions. This option
26726is mostly useful for debugging, as GCC detects the capabilities of
26727the assembler when it is built and sets the default accordingly.
26728
d77de738
ML
26729@opindex msmall-data
26730@opindex mlarge-data
ddf6fe37
AA
26731@item -msmall-data
26732@itemx -mlarge-data
d77de738
ML
26733When @option{-mexplicit-relocs} is in effect, static data is
26734accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
26735is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
26736(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2673716-bit relocations off of the @code{$gp} register. This limits the
26738size of the small data area to 64KB, but allows the variables to be
26739directly accessed via a single instruction.
26740
26741The default is @option{-mlarge-data}. With this option the data area
26742is limited to just below 2GB@. Programs that require more than 2GB of
26743data must use @code{malloc} or @code{mmap} to allocate the data in the
26744heap instead of in the program's data segment.
26745
26746When generating code for shared libraries, @option{-fpic} implies
26747@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
26748
d77de738
ML
26749@opindex msmall-text
26750@opindex mlarge-text
ddf6fe37
AA
26751@item -msmall-text
26752@itemx -mlarge-text
d77de738
ML
26753When @option{-msmall-text} is used, the compiler assumes that the
26754code of the entire program (or shared library) fits in 4MB, and is
26755thus reachable with a branch instruction. When @option{-msmall-data}
26756is used, the compiler can assume that all local symbols share the
26757same @code{$gp} value, and thus reduce the number of instructions
26758required for a function call from 4 to 1.
26759
26760The default is @option{-mlarge-text}.
26761
d77de738 26762@opindex mcpu
ddf6fe37 26763@item -mcpu=@var{cpu_type}
d77de738
ML
26764Set the instruction set and instruction scheduling parameters for
26765machine type @var{cpu_type}. You can specify either the @samp{EV}
26766style name or the corresponding chip number. GCC supports scheduling
26767parameters for the EV4, EV5 and EV6 family of processors and
26768chooses the default values for the instruction set from the processor
26769you specify. If you do not specify a processor type, GCC defaults
26770to the processor on which the compiler was built.
26771
26772Supported values for @var{cpu_type} are
26773
26774@table @samp
26775@item ev4
26776@itemx ev45
26777@itemx 21064
26778Schedules as an EV4 and has no instruction set extensions.
26779
26780@item ev5
26781@itemx 21164
26782Schedules as an EV5 and has no instruction set extensions.
26783
26784@item ev56
26785@itemx 21164a
26786Schedules as an EV5 and supports the BWX extension.
26787
26788@item pca56
26789@itemx 21164pc
26790@itemx 21164PC
26791Schedules as an EV5 and supports the BWX and MAX extensions.
26792
26793@item ev6
26794@itemx 21264
26795Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
26796
26797@item ev67
26798@itemx 21264a
26799Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
26800@end table
26801
26802Native toolchains also support the value @samp{native},
26803which selects the best architecture option for the host processor.
26804@option{-mcpu=native} has no effect if GCC does not recognize
26805the processor.
26806
d77de738 26807@opindex mtune
ddf6fe37 26808@item -mtune=@var{cpu_type}
d77de738
ML
26809Set only the instruction scheduling parameters for machine type
26810@var{cpu_type}. The instruction set is not changed.
26811
26812Native toolchains also support the value @samp{native},
26813which selects the best architecture option for the host processor.
26814@option{-mtune=native} has no effect if GCC does not recognize
26815the processor.
26816
d77de738 26817@opindex mmemory-latency
ddf6fe37 26818@item -mmemory-latency=@var{time}
d77de738
ML
26819Sets the latency the scheduler should assume for typical memory
26820references as seen by the application. This number is highly
26821dependent on the memory access patterns used by the application
26822and the size of the external cache on the machine.
26823
26824Valid options for @var{time} are
26825
26826@table @samp
26827@item @var{number}
26828A decimal number representing clock cycles.
26829
26830@item L1
26831@itemx L2
26832@itemx L3
26833@itemx main
26834The compiler contains estimates of the number of clock cycles for
26835``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
26836(also called Dcache, Scache, and Bcache), as well as to main memory.
26837Note that L3 is only valid for EV5.
26838
26839@end table
26840@end table
26841
26842@node eBPF Options
26843@subsection eBPF Options
26844@cindex eBPF Options
26845
26846@table @gcctabopt
26847@item -mframe-limit=@var{bytes}
26848This specifies the hard limit for frame sizes, in bytes. Currently,
26849the value that can be specified should be less than or equal to
26850@samp{32767}. Defaults to whatever limit is imposed by the version of
26851the Linux kernel targeted.
26852
d77de738 26853@opindex mbig-endian
ddf6fe37 26854@item -mbig-endian
d77de738
ML
26855Generate code for a big-endian target.
26856
d77de738 26857@opindex mlittle-endian
ddf6fe37 26858@item -mlittle-endian
d77de738
ML
26859Generate code for a little-endian target. This is the default.
26860
d77de738 26861@opindex mjmpext
ddf6fe37 26862@item -mjmpext
9cbf4286
DF
26863@itemx -mno-jmpext
26864Enable or disable generation of extra conditional-branch instructions.
d77de738
ML
26865Enabled for CPU v2 and above.
26866
d77de738 26867@opindex mjmp32
ddf6fe37 26868@item -mjmp32
9cbf4286
DF
26869@itemx -mno-jmp32
26870Enable or disable generation of 32-bit jump instructions.
26871Enabled for CPU v3 and above.
d77de738 26872
d77de738 26873@opindex malu32
ddf6fe37 26874@item -malu32
9cbf4286
DF
26875@itemx -mno-alu32
26876Enable or disable generation of 32-bit ALU instructions.
26877Enabled for CPU v3 and above.
26878
26879@opindex mv3-atomics
26880@item -mv3-atomics
26881@itemx -mno-v3-atomics
26882Enable or disable instructions for general atomic operations introduced
26883in CPU v3. Enabled for CPU v3 and above.
d77de738 26884
f1e34551
JM
26885@opindex mbswap
26886@item -mbswap
9cbf4286
DF
26887@itemx -mno-bswap
26888Enable or disable byte swap instructions. Enabled for CPU v4 and above.
f1e34551 26889
4be3919f
JM
26890@opindex msdiv
26891@item -msdiv
9cbf4286
DF
26892@itemx -mno-sdiv
26893Enable or disable signed division and modulus instructions. Enabled for
26894CPU v4 and above.
db189d02 26895
14dab1a1
DF
26896@opindex msmov
26897@item -msmov
26898@itemx -mno-smov
26899Enable or disable sign-extending move and memory load instructions.
26900Enabled for CPU v4 and above.
26901
d77de738 26902@opindex mcpu
ddf6fe37 26903@item -mcpu=@var{version}
d77de738 26904This specifies which version of the eBPF ISA to target. Newer versions
f1e34551 26905may not be supported by all kernels. The default is @samp{v4}.
d77de738
ML
26906
26907Supported values for @var{version} are:
26908
26909@table @samp
26910@item v1
26911The first stable eBPF ISA with no special features or extensions.
26912
26913@item v2
26914Supports the jump extensions, as in @option{-mjmpext}.
26915
26916@item v3
26917All features of v2, plus:
26918@itemize @minus
26919@item 32-bit jump operations, as in @option{-mjmp32}
26920@item 32-bit ALU operations, as in @option{-malu32}
db189d02 26921@item general atomic operations, as in @option{-mv3-atomics}
d77de738
ML
26922@end itemize
26923
f1e34551
JM
26924@item v4
26925All features of v3, plus:
26926@itemize @minus
26927@item Byte swap instructions, as in @option{-mbswap}
9cbf4286 26928@item Signed division and modulus instructions, as in @option{-msdiv}
14dab1a1 26929@item Sign-extending move and memory load instructions, as in @option{-msmov}
f1e34551 26930@end itemize
d77de738
ML
26931@end table
26932
d77de738 26933@opindex mco-re
ddf6fe37 26934@item -mco-re
d77de738
ML
26935Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
26936is implied by @option{-gbtf}.
26937
d77de738 26938@opindex mno-co-re
ddf6fe37 26939@item -mno-co-re
d77de738
ML
26940Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
26941support is enabled by default when generating BTF debug information for
26942the BPF target.
26943
26944@item -mxbpf
26945Generate code for an expanded version of BPF, which relaxes some of
26946the restrictions imposed by the BPF architecture:
26947@itemize @minus
26948@item Save and restore callee-saved registers at function entry and
26949exit, respectively.
26950@end itemize
77d0f9ec
CM
26951
26952@opindex masm=@var{dialect}
26953@item -masm=@var{dialect}
26954Outputs assembly instructions using eBPF selected @var{dialect}. The default
c96c2a30 26955is @samp{pseudoc}.
77d0f9ec
CM
26956
26957Supported values for @var{dialect} are:
26958
26959@table @samp
26960@item normal
26961Outputs normal assembly dialect.
26962
26963@item pseudoc
26964Outputs pseudo-c assembly dialect.
26965
26966@end table
26967
a0d60660 26968@opindex minline-memops-threshold
0e850eff
DF
26969@item -minline-memops-threshold=@var{bytes}
26970Specifies a size threshold in bytes at or below which memmove, memcpy
26971and memset shall always be expanded inline. Operations dealing with
64aa48ce 26972sizes larger than this threshold would have to be implemented using
0e850eff
DF
26973a library call instead of being expanded inline, but since BPF doesn't
26974allow libcalls, exceeding this threshold results in a compile-time
26975error. The default is @samp{1024} bytes.
26976
d77de738
ML
26977@end table
26978
26979@node FR30 Options
26980@subsection FR30 Options
26981@cindex FR30 Options
26982
26983These options are defined specifically for the FR30 port.
26984
26985@table @gcctabopt
26986
d77de738 26987@opindex msmall-model
ddf6fe37 26988@item -msmall-model
d77de738
ML
26989Use the small address space model. This can produce smaller code, but
26990it does assume that all symbolic values and addresses fit into a
2699120-bit range.
26992
d77de738 26993@opindex mno-lsim
ddf6fe37 26994@item -mno-lsim
d77de738
ML
26995Assume that runtime support has been provided and so there is no need
26996to include the simulator library (@file{libsim.a}) on the linker
26997command line.
26998
26999@end table
27000
27001@node FT32 Options
27002@subsection FT32 Options
27003@cindex FT32 Options
27004
27005These options are defined specifically for the FT32 port.
27006
27007@table @gcctabopt
27008
d77de738 27009@opindex msim
ddf6fe37 27010@item -msim
d77de738
ML
27011Specifies that the program will be run on the simulator. This causes
27012an alternate runtime startup and library to be linked.
27013You must not use this option when generating programs that will run on
27014real hardware; you must provide your own runtime library for whatever
27015I/O functions are needed.
27016
d77de738 27017@opindex mlra
ddf6fe37 27018@item -mlra
4a5a6359 27019Does nothing. Preserved for backward compatibility.
d77de738 27020
d77de738 27021@opindex mnodiv
ddf6fe37 27022@item -mnodiv
d77de738
ML
27023Do not use div and mod instructions.
27024
d77de738 27025@opindex mft32b
ddf6fe37 27026@item -mft32b
d77de738
ML
27027Enable use of the extended instructions of the FT32B processor.
27028
d77de738 27029@opindex mcompress
ddf6fe37 27030@item -mcompress
d77de738
ML
27031Compress all code using the Ft32B code compression scheme.
27032
d77de738 27033@opindex mnopm
ddf6fe37 27034@item -mnopm
d77de738
ML
27035Do not generate code that reads program memory.
27036
27037@end table
27038
27039@node FRV Options
27040@subsection FRV Options
27041@cindex FRV Options
27042
27043@table @gcctabopt
d77de738 27044@opindex mgpr-32
ddf6fe37 27045@item -mgpr-32
d77de738
ML
27046
27047Only use the first 32 general-purpose registers.
27048
d77de738 27049@opindex mgpr-64
ddf6fe37 27050@item -mgpr-64
d77de738
ML
27051
27052Use all 64 general-purpose registers.
27053
d77de738 27054@opindex mfpr-32
ddf6fe37 27055@item -mfpr-32
d77de738
ML
27056
27057Use only the first 32 floating-point registers.
27058
d77de738 27059@opindex mfpr-64
ddf6fe37 27060@item -mfpr-64
d77de738
ML
27061
27062Use all 64 floating-point registers.
27063
d77de738 27064@opindex mhard-float
ddf6fe37 27065@item -mhard-float
d77de738
ML
27066
27067Use hardware instructions for floating-point operations.
27068
d77de738 27069@opindex msoft-float
ddf6fe37 27070@item -msoft-float
d77de738
ML
27071
27072Use library routines for floating-point operations.
27073
d77de738 27074@opindex malloc-cc
ddf6fe37 27075@item -malloc-cc
d77de738
ML
27076
27077Dynamically allocate condition code registers.
27078
d77de738 27079@opindex mfixed-cc
ddf6fe37 27080@item -mfixed-cc
d77de738
ML
27081
27082Do not try to dynamically allocate condition code registers, only
27083use @code{icc0} and @code{fcc0}.
27084
d77de738 27085@opindex mdword
ddf6fe37 27086@item -mdword
d77de738
ML
27087
27088Change ABI to use double word insns.
27089
d77de738
ML
27090@opindex mno-dword
27091@opindex mdword
ddf6fe37 27092@item -mno-dword
d77de738
ML
27093
27094Do not use double word instructions.
27095
d77de738 27096@opindex mdouble
ddf6fe37 27097@item -mdouble
d77de738
ML
27098
27099Use floating-point double instructions.
27100
d77de738 27101@opindex mno-double
ddf6fe37 27102@item -mno-double
d77de738
ML
27103
27104Do not use floating-point double instructions.
27105
d77de738 27106@opindex mmedia
ddf6fe37 27107@item -mmedia
d77de738
ML
27108
27109Use media instructions.
27110
d77de738 27111@opindex mno-media
ddf6fe37 27112@item -mno-media
d77de738
ML
27113
27114Do not use media instructions.
27115
d77de738 27116@opindex mmuladd
ddf6fe37 27117@item -mmuladd
d77de738
ML
27118
27119Use multiply and add/subtract instructions.
27120
d77de738 27121@opindex mno-muladd
ddf6fe37 27122@item -mno-muladd
d77de738
ML
27123
27124Do not use multiply and add/subtract instructions.
27125
d77de738 27126@opindex mfdpic
ddf6fe37 27127@item -mfdpic
d77de738
ML
27128
27129Select the FDPIC ABI, which uses function descriptors to represent
27130pointers to functions. Without any PIC/PIE-related options, it
27131implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
27132assumes GOT entries and small data are within a 12-bit range from the
27133GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
27134are computed with 32 bits.
27135With a @samp{bfin-elf} target, this option implies @option{-msim}.
27136
d77de738 27137@opindex minline-plt
ddf6fe37 27138@item -minline-plt
d77de738
ML
27139
27140Enable inlining of PLT entries in function calls to functions that are
27141not known to bind locally. It has no effect without @option{-mfdpic}.
27142It's enabled by default if optimizing for speed and compiling for
27143shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
27144optimization option such as @option{-O3} or above is present in the
27145command line.
27146
d77de738 27147@opindex mTLS
ddf6fe37 27148@item -mTLS
d77de738
ML
27149
27150Assume a large TLS segment when generating thread-local code.
27151
d77de738 27152@opindex mtls
ddf6fe37 27153@item -mtls
d77de738
ML
27154
27155Do not assume a large TLS segment when generating thread-local code.
27156
d77de738 27157@opindex mgprel-ro
ddf6fe37 27158@item -mgprel-ro
d77de738
ML
27159
27160Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
27161that is known to be in read-only sections. It's enabled by default,
27162except for @option{-fpic} or @option{-fpie}: even though it may help
27163make the global offset table smaller, it trades 1 instruction for 4.
27164With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
27165one of which may be shared by multiple symbols, and it avoids the need
27166for a GOT entry for the referenced symbol, so it's more likely to be a
27167win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
27168
d77de738 27169@opindex multilib-library-pic
ddf6fe37 27170@item -multilib-library-pic
d77de738
ML
27171
27172Link with the (library, not FD) pic libraries. It's implied by
27173@option{-mlibrary-pic}, as well as by @option{-fPIC} and
27174@option{-fpic} without @option{-mfdpic}. You should never have to use
27175it explicitly.
27176
d77de738 27177@opindex mlinked-fp
ddf6fe37 27178@item -mlinked-fp
d77de738
ML
27179
27180Follow the EABI requirement of always creating a frame pointer whenever
27181a stack frame is allocated. This option is enabled by default and can
27182be disabled with @option{-mno-linked-fp}.
27183
d77de738 27184@opindex mlong-calls
ddf6fe37 27185@item -mlong-calls
d77de738
ML
27186
27187Use indirect addressing to call functions outside the current
27188compilation unit. This allows the functions to be placed anywhere
27189within the 32-bit address space.
27190
d77de738 27191@opindex malign-labels
ddf6fe37 27192@item -malign-labels
d77de738
ML
27193
27194Try to align labels to an 8-byte boundary by inserting NOPs into the
27195previous packet. This option only has an effect when VLIW packing
27196is enabled. It doesn't create new packets; it merely adds NOPs to
27197existing ones.
27198
d77de738 27199@opindex mlibrary-pic
ddf6fe37 27200@item -mlibrary-pic
d77de738
ML
27201
27202Generate position-independent EABI code.
27203
d77de738 27204@opindex macc-4
ddf6fe37 27205@item -macc-4
d77de738
ML
27206
27207Use only the first four media accumulator registers.
27208
d77de738 27209@opindex macc-8
ddf6fe37 27210@item -macc-8
d77de738
ML
27211
27212Use all eight media accumulator registers.
27213
d77de738 27214@opindex mpack
ddf6fe37 27215@item -mpack
d77de738
ML
27216
27217Pack VLIW instructions.
27218
d77de738 27219@opindex mno-pack
ddf6fe37 27220@item -mno-pack
d77de738
ML
27221
27222Do not pack VLIW instructions.
27223
d77de738 27224@opindex mno-eflags
ddf6fe37 27225@item -mno-eflags
d77de738
ML
27226
27227Do not mark ABI switches in e_flags.
27228
d77de738 27229@opindex mcond-move
ddf6fe37 27230@item -mcond-move
d77de738
ML
27231
27232Enable the use of conditional-move instructions (default).
27233
27234This switch is mainly for debugging the compiler and will likely be removed
27235in a future version.
27236
d77de738 27237@opindex mno-cond-move
ddf6fe37 27238@item -mno-cond-move
d77de738
ML
27239
27240Disable the use of conditional-move instructions.
27241
27242This switch is mainly for debugging the compiler and will likely be removed
27243in a future version.
27244
d77de738 27245@opindex mscc
ddf6fe37 27246@item -mscc
d77de738
ML
27247
27248Enable the use of conditional set instructions (default).
27249
27250This switch is mainly for debugging the compiler and will likely be removed
27251in a future version.
27252
d77de738 27253@opindex mno-scc
ddf6fe37 27254@item -mno-scc
d77de738
ML
27255
27256Disable the use of conditional set instructions.
27257
27258This switch is mainly for debugging the compiler and will likely be removed
27259in a future version.
27260
d77de738 27261@opindex mcond-exec
ddf6fe37 27262@item -mcond-exec
d77de738
ML
27263
27264Enable the use of conditional execution (default).
27265
27266This switch is mainly for debugging the compiler and will likely be removed
27267in a future version.
27268
d77de738 27269@opindex mno-cond-exec
ddf6fe37 27270@item -mno-cond-exec
d77de738
ML
27271
27272Disable the use of conditional execution.
27273
27274This switch is mainly for debugging the compiler and will likely be removed
27275in a future version.
27276
d77de738 27277@opindex mvliw-branch
ddf6fe37 27278@item -mvliw-branch
d77de738
ML
27279
27280Run a pass to pack branches into VLIW instructions (default).
27281
27282This switch is mainly for debugging the compiler and will likely be removed
27283in a future version.
27284
d77de738 27285@opindex mno-vliw-branch
ddf6fe37 27286@item -mno-vliw-branch
d77de738
ML
27287
27288Do not run a pass to pack branches into VLIW instructions.
27289
27290This switch is mainly for debugging the compiler and will likely be removed
27291in a future version.
27292
d77de738 27293@opindex mmulti-cond-exec
ddf6fe37 27294@item -mmulti-cond-exec
d77de738
ML
27295
27296Enable optimization of @code{&&} and @code{||} in conditional execution
27297(default).
27298
27299This switch is mainly for debugging the compiler and will likely be removed
27300in a future version.
27301
d77de738 27302@opindex mno-multi-cond-exec
ddf6fe37 27303@item -mno-multi-cond-exec
d77de738
ML
27304
27305Disable optimization of @code{&&} and @code{||} in conditional execution.
27306
27307This switch is mainly for debugging the compiler and will likely be removed
27308in a future version.
27309
d77de738 27310@opindex mnested-cond-exec
ddf6fe37 27311@item -mnested-cond-exec
d77de738
ML
27312
27313Enable nested conditional execution optimizations (default).
27314
27315This switch is mainly for debugging the compiler and will likely be removed
27316in a future version.
27317
d77de738 27318@opindex mno-nested-cond-exec
ddf6fe37 27319@item -mno-nested-cond-exec
d77de738
ML
27320
27321Disable nested conditional execution optimizations.
27322
27323This switch is mainly for debugging the compiler and will likely be removed
27324in a future version.
27325
d77de738 27326@opindex moptimize-membar
ddf6fe37 27327@item -moptimize-membar
d77de738
ML
27328
27329This switch removes redundant @code{membar} instructions from the
27330compiler-generated code. It is enabled by default.
27331
d77de738
ML
27332@opindex mno-optimize-membar
27333@opindex moptimize-membar
ddf6fe37 27334@item -mno-optimize-membar
d77de738
ML
27335
27336This switch disables the automatic removal of redundant @code{membar}
27337instructions from the generated code.
27338
d77de738 27339@opindex mtomcat-stats
ddf6fe37 27340@item -mtomcat-stats
d77de738
ML
27341
27342Cause gas to print out tomcat statistics.
27343
d77de738 27344@opindex mcpu
ddf6fe37 27345@item -mcpu=@var{cpu}
d77de738
ML
27346
27347Select the processor type for which to generate code. Possible values are
27348@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
27349@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
27350
27351@end table
27352
27353@node GNU/Linux Options
27354@subsection GNU/Linux Options
27355
27356These @samp{-m} options are defined for GNU/Linux targets:
27357
27358@table @gcctabopt
d77de738 27359@opindex mglibc
ddf6fe37 27360@item -mglibc
d77de738
ML
27361Use the GNU C library. This is the default except
27362on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
27363@samp{*-*-linux-*android*} targets.
27364
d77de738 27365@opindex muclibc
ddf6fe37 27366@item -muclibc
d77de738
ML
27367Use uClibc C library. This is the default on
27368@samp{*-*-linux-*uclibc*} targets.
27369
d77de738 27370@opindex mmusl
ddf6fe37 27371@item -mmusl
d77de738
ML
27372Use the musl C library. This is the default on
27373@samp{*-*-linux-*musl*} targets.
27374
d77de738 27375@opindex mbionic
ddf6fe37 27376@item -mbionic
d77de738
ML
27377Use Bionic C library. This is the default on
27378@samp{*-*-linux-*android*} targets.
27379
d77de738 27380@opindex mandroid
ddf6fe37 27381@item -mandroid
d77de738
ML
27382Compile code compatible with Android platform. This is the default on
27383@samp{*-*-linux-*android*} targets.
27384
27385When compiling, this option enables @option{-mbionic}, @option{-fPIC},
27386@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
27387this option makes the GCC driver pass Android-specific options to the linker.
27388Finally, this option causes the preprocessor macro @code{__ANDROID__}
27389to be defined.
27390
d77de738 27391@opindex tno-android-cc
ddf6fe37 27392@item -tno-android-cc
d77de738
ML
27393Disable compilation effects of @option{-mandroid}, i.e., do not enable
27394@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
27395@option{-fno-rtti} by default.
27396
d77de738 27397@opindex tno-android-ld
ddf6fe37 27398@item -tno-android-ld
d77de738
ML
27399Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
27400linking options to the linker.
27401
27402@end table
27403
27404@node H8/300 Options
27405@subsection H8/300 Options
27406
27407These @samp{-m} options are defined for the H8/300 implementations:
27408
27409@table @gcctabopt
d77de738 27410@opindex mrelax
ddf6fe37 27411@item -mrelax
d77de738
ML
27412Shorten some address references at link time, when possible; uses the
27413linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
27414ld, Using ld}, for a fuller description.
27415
d77de738 27416@opindex mh
ddf6fe37 27417@item -mh
d77de738
ML
27418Generate code for the H8/300H@.
27419
d77de738 27420@opindex ms
ddf6fe37 27421@item -ms
d77de738
ML
27422Generate code for the H8S@.
27423
d77de738 27424@opindex mn
ddf6fe37 27425@item -mn
d77de738
ML
27426Generate code for the H8S and H8/300H in the normal mode. This switch
27427must be used either with @option{-mh} or @option{-ms}.
27428
d77de738 27429@opindex ms2600
ddf6fe37 27430@item -ms2600
d77de738
ML
27431Generate code for the H8S/2600. This switch must be used with @option{-ms}.
27432
d77de738 27433@opindex mexr
ddf6fe37 27434@item -mexr
d77de738
ML
27435Extended registers are stored on stack before execution of function
27436with monitor attribute. Default option is @option{-mexr}.
27437This option is valid only for H8S targets.
27438
d77de738
ML
27439@opindex mno-exr
27440@opindex mexr
ddf6fe37 27441@item -mno-exr
a0e64a04
PN
27442Extended registers are not stored on stack before execution of function
27443with monitor attribute. Default option is @option{-mno-exr}.
d77de738
ML
27444This option is valid only for H8S targets.
27445
d77de738 27446@opindex mint32
ddf6fe37 27447@item -mint32
d77de738
ML
27448Make @code{int} data 32 bits by default.
27449
d77de738 27450@opindex malign-300
ddf6fe37 27451@item -malign-300
d77de738
ML
27452On the H8/300H and H8S, use the same alignment rules as for the H8/300.
27453The default for the H8/300H and H8S is to align longs and floats on
274544-byte boundaries.
27455@option{-malign-300} causes them to be aligned on 2-byte boundaries.
27456This option has no effect on the H8/300.
27457@end table
27458
27459@node HPPA Options
27460@subsection HPPA Options
27461@cindex HPPA Options
27462
27463These @samp{-m} options are defined for the HPPA family of computers:
27464
27465@table @gcctabopt
d77de738 27466@opindex march
ddf6fe37 27467@item -march=@var{architecture-type}
d77de738
ML
27468Generate code for the specified architecture. The choices for
27469@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
274701.1, and @samp{2.0} for PA 2.0 processors. Refer to
27471@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
27472architecture option for your machine. Code compiled for lower numbered
27473architectures runs on higher numbered architectures, but not the
27474other way around.
27475
d77de738
ML
27476@opindex mpa-risc-1-0
27477@opindex mpa-risc-1-1
27478@opindex mpa-risc-2-0
ddf6fe37
AA
27479@item -mpa-risc-1-0
27480@itemx -mpa-risc-1-1
27481@itemx -mpa-risc-2-0
d77de738
ML
27482Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
27483
cf467fb9
JDA
27484@opindex matomic-libcalls
27485@opindex mno-atomic-libcalls
ddf6fe37 27486@item -matomic-libcalls
cf467fb9
JDA
27487Generate libcalls for atomic loads and stores when sync libcalls are disabled.
27488This option is enabled by default. It only affects the generation of
27489atomic libcalls by the HPPA backend.
27490
27491Both the sync and @file{libatomic} libcall implementations use locking.
27492As a result, processor stores are not atomic with respect to other
27493atomic operations. Processor loads up to DImode are atomic with
27494respect to other atomic operations provided they are implemented as
27495a single access.
27496
27497The PA-RISC architecture does not support any atomic operations in
27498hardware except for the @code{ldcw} instruction. Thus, all atomic
27499support is implemented using sync and atomic libcalls. Sync libcall
27500support is in @file{libgcc.a}. Atomic libcall support is in
27501@file{libatomic}.
27502
27503This option generates @code{__atomic_exchange} calls for atomic stores.
27504It also provides special handling for atomic DImode accesses on 32-bit
27505targets.
27506
cf467fb9 27507@opindex mbig-switch
ddf6fe37 27508@item -mbig-switch
cf467fb9
JDA
27509Does nothing. Preserved for backward compatibility.
27510
d77de738 27511@opindex mcaller-copies
ddf6fe37 27512@item -mcaller-copies
d77de738
ML
27513The caller copies function arguments passed by hidden reference. This
27514option should be used with care as it is not compatible with the default
2751532-bit runtime. However, only aggregates larger than eight bytes are
27516passed by hidden reference and the option provides better compatibility
27517with OpenMP.
27518
cf467fb9 27519@opindex mcoherent-ldcw
ddf6fe37 27520@item -mcoherent-ldcw
cf467fb9 27521Use ldcw/ldcd coherent cache-control hint.
d77de738 27522
d77de738 27523@opindex mdisable-fpregs
ddf6fe37 27524@item -mdisable-fpregs
cf467fb9 27525Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 27526
d77de738 27527@opindex mdisable-indexing
ddf6fe37 27528@item -mdisable-indexing
d77de738
ML
27529Prevent the compiler from using indexing address modes. This avoids some
27530rather obscure problems when compiling MIG generated code under MACH@.
27531
d77de738 27532@opindex mfast-indirect-calls
ddf6fe37 27533@item -mfast-indirect-calls
d77de738
ML
27534Generate code that assumes calls never cross space boundaries. This
27535allows GCC to emit code that performs faster indirect calls.
27536
27537This option does not work in the presence of shared libraries or nested
27538functions.
27539
d77de738 27540@opindex mfixed-range
ddf6fe37 27541@item -mfixed-range=@var{register-range}
d77de738
ML
27542Generate code treating the given register range as fixed registers.
27543A fixed register is one that the register allocator cannot use. This is
27544useful when compiling kernel code. A register range is specified as
27545two registers separated by a dash. Multiple register ranges can be
27546specified separated by a comma.
27547
d77de738 27548@opindex mgas
ddf6fe37 27549@item -mgas
d77de738
ML
27550Enable the use of assembler directives only GAS understands.
27551
d77de738 27552@opindex mgnu-ld
ddf6fe37 27553@item -mgnu-ld
d77de738
ML
27554Use options specific to GNU @command{ld}.
27555This passes @option{-shared} to @command{ld} when
27556building a shared library. It is the default when GCC is configured,
27557explicitly or implicitly, with the GNU linker. This option does not
27558affect which @command{ld} is called; it only changes what parameters
27559are passed to that @command{ld}.
27560The @command{ld} that is called is determined by the
27561@option{--with-ld} configure option, GCC's program search path, and
27562finally by the user's @env{PATH}. The linker used by GCC can be printed
27563using @samp{which `gcc -print-prog-name=ld`}. This option is only available
27564on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
27565
d77de738 27566@opindex mhp-ld
ddf6fe37 27567@item -mhp-ld
d77de738
ML
27568Use options specific to HP @command{ld}.
27569This passes @option{-b} to @command{ld} when building
27570a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
27571links. It is the default when GCC is configured, explicitly or
27572implicitly, with the HP linker. This option does not affect
27573which @command{ld} is called; it only changes what parameters are passed to that
27574@command{ld}.
27575The @command{ld} that is called is determined by the @option{--with-ld}
27576configure option, GCC's program search path, and finally by the user's
27577@env{PATH}. The linker used by GCC can be printed using @samp{which
27578`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
27579HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
27580
cf467fb9 27581@opindex mlinker-opt
ddf6fe37 27582@item -mlinker-opt
cf467fb9 27583Enable the optimization pass in the HP-UX linker. Note this makes symbolic
6b09d5e7 27584debugging impossible.
cf467fb9 27585
d77de738
ML
27586@opindex mno-long-calls
27587@opindex mlong-calls
ddf6fe37 27588@item -mlong-calls
d77de738
ML
27589Generate code that uses long call sequences. This ensures that a call
27590is always able to reach linker generated stubs. The default is to generate
27591long calls only when the distance from the call site to the beginning
27592of the function or translation unit, as the case may be, exceeds a
27593predefined limit set by the branch type being used. The limits for
27594normal calls are 7,600,000 and 240,000 bytes, respectively for the
27595PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
27596240,000 bytes.
27597
27598Distances are measured from the beginning of functions when using the
27599@option{-ffunction-sections} option, or when using the @option{-mgas}
27600and @option{-mno-portable-runtime} options together under HP-UX with
27601the SOM linker.
27602
27603It is normally not desirable to use this option as it degrades
27604performance. However, it may be useful in large applications,
27605particularly when partial linking is used to build the application.
27606
27607The types of long calls used depends on the capabilities of the
27608assembler and linker, and the type of code being generated. The
27609impact on systems that support long absolute calls, and long pic
27610symbol-difference or pc-relative calls should be relatively small.
27611However, an indirect call is used on 32-bit ELF systems in pic code
27612and it is quite long.
27613
cf467fb9 27614@opindex mlong-load-store
ddf6fe37 27615@item -mlong-load-store
cf467fb9
JDA
27616Generate 3-instruction load and store sequences as sometimes required by
27617the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
27618the HP compilers.
27619
cf467fb9 27620@opindex mjump-in-delay
ddf6fe37 27621@item -mjump-in-delay
cf467fb9
JDA
27622This option is ignored and provided for compatibility purposes only.
27623
cf467fb9
JDA
27624@opindex mno-space-regs
27625@opindex mspace-regs
ddf6fe37 27626@item -mno-space-regs
cf467fb9
JDA
27627Generate code that assumes the target has no space registers. This allows
27628GCC to generate faster indirect calls and use unscaled index address modes.
27629
27630Such code is suitable for level 0 PA systems and kernels.
27631
cf467fb9 27632@opindex mordered
ddf6fe37 27633@item -mordered
cf467fb9
JDA
27634Assume memory references are ordered and barriers are not needed.
27635
cf467fb9 27636@opindex mportable-runtime
ddf6fe37 27637@item -mportable-runtime
cf467fb9
JDA
27638Use the portable calling conventions proposed by HP for ELF systems.
27639
cf467fb9 27640@opindex mschedule
ddf6fe37 27641@item -mschedule=@var{cpu-type}
cf467fb9
JDA
27642Schedule code according to the constraints for the machine type
27643@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
27644@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
27645to @file{/usr/lib/sched.models} on an HP-UX system to determine the
27646proper scheduling option for your machine. The default scheduling is
27647@samp{8000}.
27648
cf467fb9 27649@opindex msio
ddf6fe37 27650@item -msio
cf467fb9
JDA
27651Generate the predefine, @code{_SIO}, for server IO@. The default is
27652@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
27653@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
27654options are available under HP-UX and HI-UX@.
27655
cf467fb9 27656@opindex msoft-float
ddf6fe37 27657@item -msoft-float
cf467fb9
JDA
27658Generate output containing library calls for floating point.
27659@strong{Warning:} the requisite libraries are not available for all HPPA
27660targets. Normally the facilities of the machine's usual C compiler are
27661used, but this cannot be done directly in cross-compilation. You must make
27662your own arrangements to provide suitable library functions for
27663cross-compilation.
27664
27665@option{-msoft-float} changes the calling convention in the output file;
27666therefore, it is only useful if you compile @emph{all} of a program with
27667this option. In particular, you need to compile @file{libgcc.a}, the
27668library that comes with GCC, with @option{-msoft-float} in order for
27669this to work.
27670
cf467fb9 27671@opindex msoft-mult
ddf6fe37 27672@item -msoft-mult
cf467fb9
JDA
27673Use software integer multiplication.
27674
27675This disables the use of the @code{xmpyu} instruction.
27676
d77de738 27677@opindex march
ddf6fe37 27678@item -munix=@var{unix-std}
d77de738
ML
27679Generate compiler predefines and select a startfile for the specified
27680UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
27681and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
27682is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2768311.11 and later. The default values are @samp{93} for HP-UX 10.00,
27684@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
27685and later.
27686
27687@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
27688@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
27689and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
27690@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
27691@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
27692@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
27693
27694It is @emph{important} to note that this option changes the interfaces
27695for various library routines. It also affects the operational behavior
27696of the C library. Thus, @emph{extreme} care is needed in using this
27697option.
27698
27699Library code that is intended to operate with more than one UNIX
27700standard must test, set and restore the variable @code{__xpg4_extended_mask}
27701as appropriate. Most GNU software doesn't provide this capability.
27702
d77de738 27703@opindex nolibdld
ddf6fe37 27704@item -nolibdld
d77de738
ML
27705Suppress the generation of link options to search libdld.sl when the
27706@option{-static} option is specified on HP-UX 10 and later.
27707
d77de738 27708@opindex static
ddf6fe37 27709@item -static
d77de738
ML
27710The HP-UX implementation of setlocale in libc has a dependency on
27711libdld.sl. There isn't an archive version of libdld.sl. Thus,
27712when the @option{-static} option is specified, special link options
27713are needed to resolve this dependency.
27714
27715On HP-UX 10 and later, the GCC driver adds the necessary options to
27716link with libdld.sl when the @option{-static} option is specified.
27717This causes the resulting binary to be dynamic. On the 64-bit port,
27718the linkers generate dynamic binaries by default in any case. The
27719@option{-nolibdld} option can be used to prevent the GCC driver from
27720adding these link options.
27721
d77de738 27722@opindex threads
ddf6fe37 27723@item -threads
d77de738
ML
27724Add support for multithreading with the @dfn{dce thread} library
27725under HP-UX@. This option sets flags for both the preprocessor and
27726linker.
27727@end table
27728
27729@node IA-64 Options
27730@subsection IA-64 Options
27731@cindex IA-64 Options
27732
27733These are the @samp{-m} options defined for the Intel IA-64 architecture.
27734
27735@table @gcctabopt
d77de738 27736@opindex mbig-endian
ddf6fe37 27737@item -mbig-endian
d77de738
ML
27738Generate code for a big-endian target. This is the default for HP-UX@.
27739
d77de738 27740@opindex mlittle-endian
ddf6fe37 27741@item -mlittle-endian
d77de738
ML
27742Generate code for a little-endian target. This is the default for AIX5
27743and GNU/Linux.
27744
d77de738
ML
27745@opindex mgnu-as
27746@opindex mno-gnu-as
ddf6fe37
AA
27747@item -mgnu-as
27748@itemx -mno-gnu-as
d77de738
ML
27749Generate (or don't) code for the GNU assembler. This is the default.
27750@c Also, this is the default if the configure option @option{--with-gnu-as}
27751@c is used.
27752
d77de738
ML
27753@opindex mgnu-ld
27754@opindex mno-gnu-ld
ddf6fe37
AA
27755@item -mgnu-ld
27756@itemx -mno-gnu-ld
d77de738
ML
27757Generate (or don't) code for the GNU linker. This is the default.
27758@c Also, this is the default if the configure option @option{--with-gnu-ld}
27759@c is used.
27760
d77de738 27761@opindex mno-pic
ddf6fe37 27762@item -mno-pic
d77de738
ML
27763Generate code that does not use a global pointer register. The result
27764is not position independent code, and violates the IA-64 ABI@.
27765
d77de738
ML
27766@opindex mvolatile-asm-stop
27767@opindex mno-volatile-asm-stop
ddf6fe37
AA
27768@item -mvolatile-asm-stop
27769@itemx -mno-volatile-asm-stop
d77de738
ML
27770Generate (or don't) a stop bit immediately before and after volatile asm
27771statements.
27772
d77de738
ML
27773@opindex mregister-names
27774@opindex mno-register-names
ddf6fe37
AA
27775@item -mregister-names
27776@itemx -mno-register-names
d77de738
ML
27777Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
27778the stacked registers. This may make assembler output more readable.
27779
d77de738
ML
27780@opindex mno-sdata
27781@opindex msdata
ddf6fe37
AA
27782@item -mno-sdata
27783@itemx -msdata
d77de738
ML
27784Disable (or enable) optimizations that use the small data section. This may
27785be useful for working around optimizer bugs.
27786
d77de738 27787@opindex mconstant-gp
ddf6fe37 27788@item -mconstant-gp
d77de738
ML
27789Generate code that uses a single constant global pointer value. This is
27790useful when compiling kernel code.
27791
d77de738 27792@opindex mauto-pic
ddf6fe37 27793@item -mauto-pic
d77de738
ML
27794Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
27795This is useful when compiling firmware code.
27796
d77de738 27797@opindex minline-float-divide-min-latency
ddf6fe37 27798@item -minline-float-divide-min-latency
d77de738
ML
27799Generate code for inline divides of floating-point values
27800using the minimum latency algorithm.
27801
d77de738 27802@opindex minline-float-divide-max-throughput
ddf6fe37 27803@item -minline-float-divide-max-throughput
d77de738
ML
27804Generate code for inline divides of floating-point values
27805using the maximum throughput algorithm.
27806
d77de738 27807@opindex mno-inline-float-divide
ddf6fe37 27808@item -mno-inline-float-divide
d77de738
ML
27809Do not generate inline code for divides of floating-point values.
27810
d77de738 27811@opindex minline-int-divide-min-latency
ddf6fe37 27812@item -minline-int-divide-min-latency
d77de738
ML
27813Generate code for inline divides of integer values
27814using the minimum latency algorithm.
27815
d77de738 27816@opindex minline-int-divide-max-throughput
ddf6fe37 27817@item -minline-int-divide-max-throughput
d77de738
ML
27818Generate code for inline divides of integer values
27819using the maximum throughput algorithm.
27820
d77de738
ML
27821@opindex mno-inline-int-divide
27822@opindex minline-int-divide
ddf6fe37 27823@item -mno-inline-int-divide
d77de738
ML
27824Do not generate inline code for divides of integer values.
27825
d77de738 27826@opindex minline-sqrt-min-latency
ddf6fe37 27827@item -minline-sqrt-min-latency
d77de738
ML
27828Generate code for inline square roots
27829using the minimum latency algorithm.
27830
d77de738 27831@opindex minline-sqrt-max-throughput
ddf6fe37 27832@item -minline-sqrt-max-throughput
d77de738
ML
27833Generate code for inline square roots
27834using the maximum throughput algorithm.
27835
d77de738 27836@opindex mno-inline-sqrt
ddf6fe37 27837@item -mno-inline-sqrt
d77de738
ML
27838Do not generate inline code for @code{sqrt}.
27839
d77de738
ML
27840@opindex mfused-madd
27841@opindex mno-fused-madd
ddf6fe37
AA
27842@item -mfused-madd
27843@itemx -mno-fused-madd
d77de738
ML
27844Do (don't) generate code that uses the fused multiply/add or multiply/subtract
27845instructions. The default is to use these instructions.
27846
d77de738
ML
27847@opindex mno-dwarf2-asm
27848@opindex mdwarf2-asm
ddf6fe37
AA
27849@item -mno-dwarf2-asm
27850@itemx -mdwarf2-asm
d77de738
ML
27851Don't (or do) generate assembler code for the DWARF line number debugging
27852info. This may be useful when not using the GNU assembler.
27853
d77de738
ML
27854@opindex mearly-stop-bits
27855@opindex mno-early-stop-bits
ddf6fe37
AA
27856@item -mearly-stop-bits
27857@itemx -mno-early-stop-bits
d77de738
ML
27858Allow stop bits to be placed earlier than immediately preceding the
27859instruction that triggered the stop bit. This can improve instruction
27860scheduling, but does not always do so.
27861
d77de738 27862@opindex mfixed-range
ddf6fe37 27863@item -mfixed-range=@var{register-range}
d77de738
ML
27864Generate code treating the given register range as fixed registers.
27865A fixed register is one that the register allocator cannot use. This is
27866useful when compiling kernel code. A register range is specified as
27867two registers separated by a dash. Multiple register ranges can be
27868specified separated by a comma.
27869
d77de738 27870@opindex mtls-size
ddf6fe37 27871@item -mtls-size=@var{tls-size}
d77de738
ML
27872Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2787364.
27874
d77de738 27875@opindex mtune
ddf6fe37 27876@item -mtune=@var{cpu-type}
d77de738
ML
27877Tune the instruction scheduling for a particular CPU, Valid values are
27878@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
27879and @samp{mckinley}.
27880
d77de738
ML
27881@opindex milp32
27882@opindex mlp64
ddf6fe37
AA
27883@item -milp32
27884@itemx -mlp64
d77de738
ML
27885Generate code for a 32-bit or 64-bit environment.
27886The 32-bit environment sets int, long and pointer to 32 bits.
27887The 64-bit environment sets int to 32 bits and long and pointer
27888to 64 bits. These are HP-UX specific flags.
27889
d77de738
ML
27890@opindex mno-sched-br-data-spec
27891@opindex msched-br-data-spec
ddf6fe37
AA
27892@item -mno-sched-br-data-spec
27893@itemx -msched-br-data-spec
d77de738
ML
27894(Dis/En)able data speculative scheduling before reload.
27895This results in generation of @code{ld.a} instructions and
27896the corresponding check instructions (@code{ld.c} / @code{chk.a}).
27897The default setting is disabled.
27898
d77de738
ML
27899@opindex msched-ar-data-spec
27900@opindex mno-sched-ar-data-spec
ddf6fe37
AA
27901@item -msched-ar-data-spec
27902@itemx -mno-sched-ar-data-spec
d77de738
ML
27903(En/Dis)able data speculative scheduling after reload.
27904This results in generation of @code{ld.a} instructions and
27905the corresponding check instructions (@code{ld.c} / @code{chk.a}).
27906The default setting is enabled.
27907
d77de738
ML
27908@opindex mno-sched-control-spec
27909@opindex msched-control-spec
ddf6fe37
AA
27910@item -mno-sched-control-spec
27911@itemx -msched-control-spec
d77de738
ML
27912(Dis/En)able control speculative scheduling. This feature is
27913available only during region scheduling (i.e.@: before reload).
27914This results in generation of the @code{ld.s} instructions and
27915the corresponding check instructions @code{chk.s}.
27916The default setting is disabled.
27917
d77de738
ML
27918@opindex msched-br-in-data-spec
27919@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
27920@item -msched-br-in-data-spec
27921@itemx -mno-sched-br-in-data-spec
d77de738
ML
27922(En/Dis)able speculative scheduling of the instructions that
27923are dependent on the data speculative loads before reload.
27924This is effective only with @option{-msched-br-data-spec} enabled.
27925The default setting is enabled.
27926
d77de738
ML
27927@opindex msched-ar-in-data-spec
27928@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
27929@item -msched-ar-in-data-spec
27930@itemx -mno-sched-ar-in-data-spec
d77de738
ML
27931(En/Dis)able speculative scheduling of the instructions that
27932are dependent on the data speculative loads after reload.
27933This is effective only with @option{-msched-ar-data-spec} enabled.
27934The default setting is enabled.
27935
d77de738
ML
27936@opindex msched-in-control-spec
27937@opindex mno-sched-in-control-spec
ddf6fe37
AA
27938@item -msched-in-control-spec
27939@itemx -mno-sched-in-control-spec
d77de738
ML
27940(En/Dis)able speculative scheduling of the instructions that
27941are dependent on the control speculative loads.
27942This is effective only with @option{-msched-control-spec} enabled.
27943The default setting is enabled.
27944
d77de738
ML
27945@opindex mno-sched-prefer-non-data-spec-insns
27946@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
27947@item -mno-sched-prefer-non-data-spec-insns
27948@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
27949If enabled, data-speculative instructions are chosen for schedule
27950only if there are no other choices at the moment. This makes
27951the use of the data speculation much more conservative.
27952The default setting is disabled.
27953
d77de738
ML
27954@opindex mno-sched-prefer-non-control-spec-insns
27955@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
27956@item -mno-sched-prefer-non-control-spec-insns
27957@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
27958If enabled, control-speculative instructions are chosen for schedule
27959only if there are no other choices at the moment. This makes
27960the use of the control speculation much more conservative.
27961The default setting is disabled.
27962
d77de738
ML
27963@opindex mno-sched-count-spec-in-critical-path
27964@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
27965@item -mno-sched-count-spec-in-critical-path
27966@itemx -msched-count-spec-in-critical-path
d77de738
ML
27967If enabled, speculative dependencies are considered during
27968computation of the instructions priorities. This makes the use of the
27969speculation a bit more conservative.
27970The default setting is disabled.
27971
d77de738 27972@opindex msched-spec-ldc
ddf6fe37 27973@item -msched-spec-ldc
d77de738
ML
27974Use a simple data speculation check. This option is on by default.
27975
d77de738 27976@opindex msched-spec-ldc
ddf6fe37 27977@item -msched-control-spec-ldc
d77de738
ML
27978Use a simple check for control speculation. This option is on by default.
27979
d77de738 27980@opindex msched-stop-bits-after-every-cycle
ddf6fe37 27981@item -msched-stop-bits-after-every-cycle
d77de738
ML
27982Place a stop bit after every cycle when scheduling. This option is on
27983by default.
27984
d77de738 27985@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 27986@item -msched-fp-mem-deps-zero-cost
d77de738
ML
27987Assume that floating-point stores and loads are not likely to cause a conflict
27988when placed into the same instruction group. This option is disabled by
27989default.
27990
d77de738 27991@opindex msel-sched-dont-check-control-spec
ddf6fe37 27992@item -msel-sched-dont-check-control-spec
d77de738
ML
27993Generate checks for control speculation in selective scheduling.
27994This flag is disabled by default.
27995
d77de738 27996@opindex msched-max-memory-insns
ddf6fe37 27997@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
27998Limit on the number of memory insns per instruction group, giving lower
27999priority to subsequent memory insns attempting to schedule in the same
28000instruction group. Frequently useful to prevent cache bank conflicts.
28001The default value is 1.
28002
d77de738 28003@opindex msched-max-memory-insns-hard-limit
ddf6fe37 28004@item -msched-max-memory-insns-hard-limit
d77de738
ML
28005Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
28006disallowing more than that number in an instruction group.
28007Otherwise, the limit is ``soft'', meaning that non-memory operations
28008are preferred when the limit is reached, but memory operations may still
28009be scheduled.
28010
28011@end table
28012
28013@node LM32 Options
28014@subsection LM32 Options
28015@cindex LM32 options
28016
28017These @option{-m} options are defined for the LatticeMico32 architecture:
28018
28019@table @gcctabopt
d77de738 28020@opindex mbarrel-shift-enabled
ddf6fe37 28021@item -mbarrel-shift-enabled
d77de738
ML
28022Enable barrel-shift instructions.
28023
d77de738 28024@opindex mdivide-enabled
ddf6fe37 28025@item -mdivide-enabled
d77de738
ML
28026Enable divide and modulus instructions.
28027
d77de738 28028@opindex multiply-enabled
ddf6fe37 28029@item -mmultiply-enabled
d77de738
ML
28030Enable multiply instructions.
28031
d77de738 28032@opindex msign-extend-enabled
ddf6fe37 28033@item -msign-extend-enabled
d77de738
ML
28034Enable sign extend instructions.
28035
d77de738 28036@opindex muser-enabled
ddf6fe37 28037@item -muser-enabled
d77de738
ML
28038Enable user-defined instructions.
28039
28040@end table
28041
28042@node LoongArch Options
28043@subsection LoongArch Options
28044@cindex LoongArch Options
28045
28046These command-line options are defined for LoongArch targets:
28047
28048@table @gcctabopt
9c19597c 28049@opindex march
b4ebdd15
YY
28050@item -march=@var{arch-type}
28051Generate instructions for the machine type @var{arch-type}.
28052@option{-march=@var{arch-type}} allows GCC to generate code that
28053may not run at all on processors other than the one indicated.
d77de738 28054
b4ebdd15 28055The choices for @var{arch-type} are:
d77de738
ML
28056
28057@table @samp
28058@item native
b4ebdd15 28059Local processor type detected by the native compiler.
d77de738 28060@item loongarch64
b4ebdd15 28061Generic LoongArch 64-bit processor.
d77de738 28062@item la464
b4ebdd15
YY
28063LoongArch LA464-based processor with LSX, LASX.
28064@item la664
28065LoongArch LA664-based processor with LSX, LASX
28066and all LoongArch v1.1 instructions.
28067@item la64v1.0
28068LoongArch64 ISA version 1.0.
28069@item la64v1.1
28070LoongArch64 ISA version 1.1.
d77de738
ML
28071@end table
28072
b4ebdd15
YY
28073More information about LoongArch ISA versions can be found at
28074@uref{https://github.com/loongson/la-toolchain-conventions}.
28075
d77de738 28076@opindex mtune
b4ebdd15
YY
28077@item -mtune=@var{tune-type}
28078Optimize the generated code for the given processor target.
28079
28080The choices for @var{tune-type} are:
28081
28082@table @samp
28083@item native
28084Local processor type detected by the native compiler.
28085@item generic
28086Generic LoongArch processor.
28087@item loongarch64
28088Generic LoongArch 64-bit processor.
28089@item la464
28090LoongArch LA464 core.
28091@item la664
28092LoongArch LA664 core.
28093@end table
28094
d77de738 28095
d77de738 28096@opindex mabi
ddf6fe37 28097@item -mabi=@var{base-abi-type}
d77de738
ML
28098Generate code for the specified calling convention.
28099@var{base-abi-type} can be one of:
28100@table @samp
28101@item lp64d
28102Uses 64-bit general purpose registers and 32/64-bit floating-point
28103registers for parameter passing. Data model is LP64, where @samp{int}
28104is 32 bits, while @samp{long int} and pointers are 64 bits.
28105@item lp64f
28106Uses 64-bit general purpose registers and 32-bit floating-point
28107registers for parameter passing. Data model is LP64, where @samp{int}
28108is 32 bits, while @samp{long int} and pointers are 64 bits.
28109@item lp64s
28110Uses 64-bit general purpose registers and no floating-point
28111registers for parameter passing. Data model is LP64, where @samp{int}
28112is 32 bits, while @samp{long int} and pointers are 64 bits.
28113@end table
28114
d77de738 28115@opindex mfpu
ddf6fe37 28116@item -mfpu=@var{fpu-type}
d77de738
ML
28117Generate code for the specified FPU type, which can be one of:
28118@table @samp
28119@item 64
28120Allow the use of hardware floating-point instructions for 32-bit
28121and 64-bit operations.
28122@item 32
28123Allow the use of hardware floating-point instructions for 32-bit
28124operations.
28125@item none
28126@item 0
28127Prevent the use of hardware floating-point instructions.
28128@end table
28129
bb4a8198
YY
28130@opindex msimd
28131@item -msimd=@var{simd-type}
28132Enable generation of LoongArch SIMD instructions for vectorization
28133and via builtin functions. The value can be one of:
28134@table @samp
28135@item lasx
28136Enable generating instructions from the 256-bit LoongArch Advanced
28137SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
28138@item lsx
28139Enable generating instructions from the 128-bit LoongArch SIMD
28140Extension (LSX).
28141@item none
28142No LoongArch SIMD instruction may be generated.
28143@end table
28144
d77de738 28145@opindex msoft-float
ddf6fe37 28146@item -msoft-float
d77de738
ML
28147Force @option{-mfpu=none} and prevents the use of floating-point
28148registers for parameter passing. This option may change the target
28149ABI.
28150
9c19597c 28151@opindex msingle-float
ddf6fe37 28152@item -msingle-float
d77de738
ML
28153Force @option{-mfpu=32} and allow the use of 32-bit floating-point
28154registers for parameter passing. This option may change the target
28155ABI.
28156
9c19597c 28157@opindex mdouble-float
ddf6fe37 28158@item -mdouble-float
d77de738
ML
28159Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
28160registers for parameter passing. This option may change the target
28161ABI.
28162
bb4a8198
YY
28163@opindex ml[a]sx
28164@item -mlasx
28165@itemx -mno-lasx
28166@item -mlsx
28167@itemx -mno-lsx
28168Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
28169that can be used by the compiler for code generation. Enabling LASX with
28170@option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
28171automatically disables LASX. These driver-only options act upon the final
b9857b78 28172@option{msimd} configuration state and make incremental changes in the order
bb4a8198
YY
28173they appear on the GCC driver's command line, deriving the final / canonicalized
28174@option{msimd} option that is passed to the compiler proper.
28175
9c19597c 28176@opindex mbranch-cost
ddf6fe37 28177@item -mbranch-cost=@var{n}
d77de738
ML
28178Set the cost of branches to roughly @var{n} instructions.
28179
7c50f954
LC
28180@opindex maddr-reg-reg-cost
28181@item -maddr-reg-reg-cost=@var{n}
28182Set the cost of ADDRESS_REG_REG to the value calculated by @var{n}.
28183
ddf6fe37 28184@opindex mcheck-zero-division
d77de738
ML
28185@item -mcheck-zero-division
28186@itemx -mno-check-zero-divison
d77de738
ML
28187Trap (do not trap) on integer division by zero. The default is
28188@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
28189@option{-mno-check-zero-division} for other optimization levels.
28190
ddf6fe37 28191@opindex mcond-move-int
d77de738
ML
28192@item -mcond-move-int
28193@itemx -mno-cond-move-int
d77de738
ML
28194Conditional moves for integral data in general-purpose registers
28195are enabled (disabled). The default is @option{-mcond-move-int}.
28196
ddf6fe37 28197@opindex mcond-move-float
d77de738
ML
28198@item -mcond-move-float
28199@itemx -mno-cond-move-float
d77de738
ML
28200Conditional moves for floating-point registers are enabled (disabled).
28201The default is @option{-mcond-move-float}.
28202
ddf6fe37 28203@opindex mmemcpy
d77de738
ML
28204@item -mmemcpy
28205@itemx -mno-memcpy
d77de738
ML
28206Force (do not force) the use of @code{memcpy} for non-trivial block moves.
28207The default is @option{-mno-memcpy}, which allows GCC to inline most
28208constant-sized copies. Setting optimization level to @option{-Os} also
28209forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
28210behavior if explicitly specified, regardless of the order these options on
28211the command line.
28212
ddf6fe37 28213@opindex mstrict-align
d77de738
ML
28214@item -mstrict-align
28215@itemx -mno-strict-align
d77de738
ML
28216Avoid or allow generating memory accesses that may not be aligned on a natural
28217object boundary as described in the architecture specification. The default is
28218@option{-mno-strict-align}.
28219
92864116
LC
28220@opindex G
28221@item -G @var{num}
28222Put global and static data smaller than @var{num} bytes into a small data
28223section. The default value is 0.
d77de738 28224
9c19597c 28225@opindex mmax-inline-memcpy-size
ddf6fe37 28226@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
28227Inline all block moves (such as calls to @code{memcpy} or structure copies)
28228less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
28229
a0d60660 28230@opindex mcmodel=
d77de738
ML
28231@item -mcmodel=@var{code-model}
28232Set the code model to one of:
28233@table @samp
28234@item tiny-static (Not implemented yet)
28235@item tiny (Not implemented yet)
28236
28237@item normal
28238The text segment must be within 128MB addressing space. The data segment must
28239be within 2GB addressing space.
28240
28241@item medium
28242The text segment and data segment must be within 2GB addressing space.
28243
28244@item large (Not implemented yet)
28245
28246@item extreme
28247This mode does not limit the size of the code segment and data segment.
8c8b40e1
XR
28248The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}
28249and/or @option{-mexplicit-relocs=none}.
d77de738
ML
28250@end table
28251The default code model is @code{normal}.
28252
e1b1cba1
XR
28253@item -mexplicit-relocs=@var{style}
28254Set when to use assembler relocation operators when dealing with symbolic
d77de738 28255addresses. The alternative is to use assembler macros instead, which may
e1b1cba1
XR
28256limit instruction scheduling but allow linker relaxation.
28257with @option{-mexplicit-relocs=none} the assembler macros are always used,
28258with @option{-mexplicit-relocs=always} the assembler relocation operators
28259are always used, with @option{-mexplicit-relocs=auto} the compiler will
28260use the relocation operators where the linker relaxation is impossible to
28261improve the code quality, and macros elsewhere. The default
fe23a2ff
XR
28262value for the option is determined with the assembler capability detected
28263during GCC build-time and the setting of @option{-mrelax}:
e1b1cba1
XR
28264@option{-mexplicit-relocs=none} if the assembler does not support
28265relocation operators at all,
28266@option{-mexplicit-relocs=always} if the assembler supports relocation
fe23a2ff
XR
28267operators but @option{-mrelax} is not enabled,
28268@option{-mexplicit-relocs=auto} if the assembler supports relocation
28269operators and @option{-mrelax} is enabled.
d77de738 28270
e1b1cba1
XR
28271@opindex mexplicit-relocs
28272@item -mexplicit-relocs
28273An alias of @option{-mexplicit-relocs=always} for backward compatibility.
28274
28275@opindex mno-explicit-relocs
28276@item -mno-explicit-relocs
28277An alias of @option{-mexplicit-relocs=none} for backward compatibility.
28278
ddf6fe37 28279@opindex mdirect-extern-access
d77de738
ML
28280@item -mdirect-extern-access
28281@itemx -mno-direct-extern-access
d77de738
ML
28282Do not use or use GOT to access external symbols. The default is
28283@option{-mno-direct-extern-access}: GOT is used for external symbols with
28284default visibility, but not used for other external symbols.
28285
28286With @option{-mdirect-extern-access}, GOT is not used and all external
28287symbols are PC-relatively addressed. It is @strong{only} suitable for
28288environments where no dynamic link is performed, like firmwares, OS
28289kernels, executables linked with @option{-static} or @option{-static-pie}.
28290@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
28291@option{-fpic}.
8f4bbdc2 28292
46d914d0
LC
28293@opindex mrelax
28294@opindex mno-relax
fe23a2ff
XR
28295@item -mrelax
28296@itemx -mno-relax
28297Take (do not take) advantage of linker relaxations. If
28298@option{-mpass-mrelax-to-as} is enabled, this option is also passed to
28299the assembler. The default is determined during GCC build-time by
28300detecting corresponding assembler support:
28301@option{-mrelax} if the assembler supports both the @option{-mrelax}
28302option and the conditional branch relaxation (it's required or the
28303@code{.align} directives and conditional branch instructions in the
28304assembly code outputted by GCC may be rejected by the assembler because
28305of a relocation overflow), @option{-mno-relax} otherwise.
28306
46d914d0
LC
28307@opindex mpass-mrelax-to-as
28308@opindex mno-pass-mrelax-to-as
fe23a2ff
XR
28309@item -mpass-mrelax-to-as
28310@itemx -mno-pass-mrelax-to-as
28311Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option
28312to the assembler. The default is determined during GCC build-time by
28313detecting corresponding assembler support:
28314@option{-mpass-mrelax-to-as} if the assembler supports the
28315@option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise.
28316This option is mostly useful for debugging, or interoperation with
28317assemblers different from the build-time one.
28318
9a07bc47
JX
28319@opindex mrecip
28320@item -mrecip
28321This option enables use of the reciprocal estimate and reciprocal square
28322root estimate instructions with additional Newton-Raphson steps to increase
28323precision instead of doing a divide or square root and divide for
28324floating-point arguments.
28325These instructions are generated only when @option{-funsafe-math-optimizations}
28326is enabled together with @option{-ffinite-math-only} and
28327@option{-fno-trapping-math}.
28328This option is off by default. Before you can use this option, you must sure the
28329target CPU supports frecipe and frsqrte instructions.
28330Note that while the throughput of the sequence is higher than the throughput of
28331the non-reciprocal instruction, the precision of the sequence can be decreased
28332by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994).
28333
28334@opindex mrecip=opt
28335@item -mrecip=@var{opt}
28336This option controls which reciprocal estimate instructions
28337may be used. @var{opt} is a comma-separated list of options, which may
28338be preceded by a @samp{!} to invert the option:
28339
28340@table @samp
28341@item all
28342Enable all estimate instructions.
28343
28344@item default
28345Enable the default instructions, equivalent to @option{-mrecip}.
28346
28347@item none
28348Disable all estimate instructions, equivalent to @option{-mno-recip}.
28349
28350@item div
28351Enable the approximation for scalar division.
28352
28353@item vec-div
28354Enable the approximation for vectorized division.
28355
28356@item sqrt
28357Enable the approximation for scalar square root.
28358
28359@item vec-sqrt
28360Enable the approximation for vectorized square root.
28361
28362@item rsqrt
28363Enable the approximation for scalar reciprocal square root.
28364
28365@item vec-rsqrt
28366Enable the approximation for vectorized reciprocal square root.
28367@end table
28368
28369So, for example, @option{-mrecip=all,!sqrt} enables
28370all of the reciprocal approximations, except for scalar square root.
28371
7f424c31
LC
28372@opindex mfrecipe
28373@opindex mno-frecipe
28374@item -mfrecipe
28375@itemx -mno-frecipe
28376Use (do not use) @code{frecipe.@{s/d@}} and @code{frsqrte.@{s/d@}}
28377instructions. When build with @option{-march=la664}, it is enabled by default.
28378The default is @option{-mno-frecipe}.
28379
28380@opindex mdiv32
28381@opindex mno-div32
28382@item -mdiv32
28383@itemx -mno-div32
28384Use (do not use) @code{div.w[u]} and @code{mod.w[u]} instructions with input
28385not sign-extended. When build with @option{-march=la664}, it is enabled by
28386default. The default is @option{-mno-div32}.
28387
28388@opindex mlam-bh
28389@opindex mno-lam-bh
28390@item -mlam-bh
28391@itemx -mno-lam-bh
28392Use (do not use) @code{am@{swap/add@}[_db].@{b/h@}} instructions. When build
28393with @option{-march=la664}, it is enabled by default. The default is
28394@option{-mno-lam-bh}.
28395
28396@opindex mlamcas
28397@opindex mno-lamcas
28398@item -mlamcas
28399@itemx -mno-lamcas
28400Use (do not use) @code{amcas[_db].@{b/h/w/d@}} instructions. When build with
28401@option{-march=la664}, it is enabled by default. The default is
28402@option{-mno-lamcas}.
28403
28404@opindex mld-seq-sa
28405@opindex mno-ld-seq-sa
28406@item -mld-seq-sa
28407@itemx -mno-ld-seq-sa
8ad8f749
LC
28408Whether a same-address load-load barrier (@code{dbar 0x700}) is needed. When
28409build with @option{-march=la664}, it is enabled by default. The default is
7f424c31
LC
28410@option{-mno-ld-seq-sa}, the load-load barrier is needed.
28411
b253b469 28412@opindex mtls-dialect
28413@item -mtls-dialect=@var{opt}
28414This option controls which tls dialect may be used for general dynamic and
28415local dynamic TLS models.
28416
f6da8c5b
LC
28417@table @samp
28418@item trad
28419Use traditional TLS. This is the default.
28420
28421@item desc
28422Use TLS descriptors.
28423@end table
28424
0ee028f5
XR
28425@opindex mannotate-tablejump
28426@opindex mno-annotate-tablejump
28427@item -mannotate-tablejump
28428@itemx -mno-annotate-tablejump
28429Create an annotation section @code{.discard.tablejump_annotate} to
28430correlate the @code{jirl} instruction and the jump table when a jump
28431table is used to optimize the @code{switch} statement. Some external
28432tools, for example @file{objtool} of the Linux kernel building system,
28433need the annotation to analysis the control flow. The default is
28434@option{-mno-annotate-tablejump}.
28435
46d914d0 28436@item --param loongarch-vect-unroll-limit=@var{n}
8f4bbdc2
JX
28437The vectorizer will use available tuning information to determine whether it
28438would be beneficial to unroll the main vectorized loop and by how much. This
28439parameter set's the upper bound of how much the vectorizer will unroll the main
28440loop. The default value is six.
28441
d77de738
ML
28442@end table
28443
bb4a8198 28444
d77de738
ML
28445@node M32C Options
28446@subsection M32C Options
28447@cindex M32C options
28448
28449@table @gcctabopt
d77de738 28450@opindex mcpu=
ddf6fe37 28451@item -mcpu=@var{name}
d77de738
ML
28452Select the CPU for which code is generated. @var{name} may be one of
28453@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
28454/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
28455the M32C/80 series.
28456
d77de738 28457@opindex msim
ddf6fe37 28458@item -msim
d77de738
ML
28459Specifies that the program will be run on the simulator. This causes
28460an alternate runtime library to be linked in which supports, for
28461example, file I/O@. You must not use this option when generating
28462programs that will run on real hardware; you must provide your own
28463runtime library for whatever I/O functions are needed.
28464
d77de738 28465@opindex memregs=
ddf6fe37 28466@item -memregs=@var{number}
d77de738
ML
28467Specifies the number of memory-based pseudo-registers GCC uses
28468during code generation. These pseudo-registers are used like real
28469registers, so there is a tradeoff between GCC's ability to fit the
28470code into available registers, and the performance penalty of using
28471memory instead of registers. Note that all modules in a program must
28472be compiled with the same value for this option. Because of that, you
28473must not use this option with GCC's default runtime libraries.
28474
28475@end table
28476
28477@node M32R/D Options
28478@subsection M32R/D Options
28479@cindex M32R/D options
28480
28481These @option{-m} options are defined for Renesas M32R/D architectures:
28482
28483@table @gcctabopt
d77de738 28484@opindex m32r2
ddf6fe37 28485@item -m32r2
d77de738
ML
28486Generate code for the M32R/2@.
28487
d77de738 28488@opindex m32rx
ddf6fe37 28489@item -m32rx
d77de738
ML
28490Generate code for the M32R/X@.
28491
d77de738 28492@opindex m32r
ddf6fe37 28493@item -m32r
d77de738
ML
28494Generate code for the M32R@. This is the default.
28495
d77de738 28496@opindex mmodel=small
ddf6fe37 28497@item -mmodel=small
d77de738
ML
28498Assume all objects live in the lower 16MB of memory (so that their addresses
28499can be loaded with the @code{ld24} instruction), and assume all subroutines
28500are reachable with the @code{bl} instruction.
28501This is the default.
28502
28503The addressability of a particular object can be set with the
28504@code{model} attribute.
28505
d77de738 28506@opindex mmodel=medium
ddf6fe37 28507@item -mmodel=medium
d77de738
ML
28508Assume objects may be anywhere in the 32-bit address space (the compiler
28509generates @code{seth/add3} instructions to load their addresses), and
28510assume all subroutines are reachable with the @code{bl} instruction.
28511
d77de738 28512@opindex mmodel=large
ddf6fe37 28513@item -mmodel=large
d77de738
ML
28514Assume objects may be anywhere in the 32-bit address space (the compiler
28515generates @code{seth/add3} instructions to load their addresses), and
28516assume subroutines may not be reachable with the @code{bl} instruction
28517(the compiler generates the much slower @code{seth/add3/jl}
28518instruction sequence).
28519
d77de738 28520@opindex msdata=none
ddf6fe37 28521@item -msdata=none
d77de738
ML
28522Disable use of the small data area. Variables are put into
28523one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
28524@code{section} attribute has been specified).
28525This is the default.
28526
28527The small data area consists of sections @code{.sdata} and @code{.sbss}.
28528Objects may be explicitly put in the small data area with the
28529@code{section} attribute using one of these sections.
28530
d77de738 28531@opindex msdata=sdata
ddf6fe37 28532@item -msdata=sdata
d77de738
ML
28533Put small global and static data in the small data area, but do not
28534generate special code to reference them.
28535
d77de738 28536@opindex msdata=use
ddf6fe37 28537@item -msdata=use
d77de738
ML
28538Put small global and static data in the small data area, and generate
28539special instructions to reference them.
28540
d77de738
ML
28541@opindex G
28542@cindex smaller data references
f33d7a88 28543@item -G @var{num}
d77de738
ML
28544Put global and static objects less than or equal to @var{num} bytes
28545into the small data or BSS sections instead of the normal data or BSS
28546sections. The default value of @var{num} is 8.
28547The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
28548for this option to have any effect.
28549
28550All modules should be compiled with the same @option{-G @var{num}} value.
28551Compiling with different values of @var{num} may or may not work; if it
28552doesn't the linker gives an error message---incorrect code is not
28553generated.
28554
d77de738 28555@opindex mdebug
ddf6fe37 28556@item -mdebug
d77de738
ML
28557Makes the M32R-specific code in the compiler display some statistics
28558that might help in debugging programs.
28559
d77de738 28560@opindex malign-loops
ddf6fe37 28561@item -malign-loops
d77de738
ML
28562Align all loops to a 32-byte boundary.
28563
d77de738 28564@opindex mno-align-loops
ddf6fe37 28565@item -mno-align-loops
d77de738
ML
28566Do not enforce a 32-byte alignment for loops. This is the default.
28567
d77de738 28568@opindex missue-rate=@var{number}
ddf6fe37 28569@item -missue-rate=@var{number}
d77de738
ML
28570Issue @var{number} instructions per cycle. @var{number} can only be 1
28571or 2.
28572
d77de738 28573@opindex mbranch-cost=@var{number}
ddf6fe37 28574@item -mbranch-cost=@var{number}
d77de738
ML
28575@var{number} can only be 1 or 2. If it is 1 then branches are
28576preferred over conditional code, if it is 2, then the opposite applies.
28577
d77de738 28578@opindex mflush-trap=@var{number}
ddf6fe37 28579@item -mflush-trap=@var{number}
d77de738
ML
28580Specifies the trap number to use to flush the cache. The default is
2858112. Valid numbers are between 0 and 15 inclusive.
28582
d77de738 28583@opindex mno-flush-trap
ddf6fe37 28584@item -mno-flush-trap
d77de738
ML
28585Specifies that the cache cannot be flushed by using a trap.
28586
d77de738 28587@opindex mflush-func=@var{name}
ddf6fe37 28588@item -mflush-func=@var{name}
d77de738
ML
28589Specifies the name of the operating system function to call to flush
28590the cache. The default is @samp{_flush_cache}, but a function call
28591is only used if a trap is not available.
28592
d77de738 28593@opindex mno-flush-func
ddf6fe37 28594@item -mno-flush-func
d77de738
ML
28595Indicates that there is no OS function for flushing the cache.
28596
28597@end table
28598
28599@node M680x0 Options
28600@subsection M680x0 Options
28601@cindex M680x0 options
28602
28603These are the @samp{-m} options defined for M680x0 and ColdFire processors.
28604The default settings depend on which architecture was selected when
28605the compiler was configured; the defaults for the most common choices
28606are given below.
28607
28608@table @gcctabopt
d77de738 28609@opindex march
ddf6fe37 28610@item -march=@var{arch}
d77de738
ML
28611Generate code for a specific M680x0 or ColdFire instruction set
28612architecture. Permissible values of @var{arch} for M680x0
28613architectures are: @samp{68000}, @samp{68010}, @samp{68020},
28614@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
28615architectures are selected according to Freescale's ISA classification
28616and the permissible values are: @samp{isaa}, @samp{isaaplus},
28617@samp{isab} and @samp{isac}.
28618
28619GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
28620code for a ColdFire target. The @var{arch} in this macro is one of the
28621@option{-march} arguments given above.
28622
28623When used together, @option{-march} and @option{-mtune} select code
28624that runs on a family of similar processors but that is optimized
28625for a particular microarchitecture.
28626
d77de738 28627@opindex mcpu
ddf6fe37 28628@item -mcpu=@var{cpu}
d77de738
ML
28629Generate code for a specific M680x0 or ColdFire processor.
28630The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
28631@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
28632and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
28633below, which also classifies the CPUs into families:
28634
28635@multitable @columnfractions 0.20 0.80
28636@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
28637@item @samp{51} @tab @samp{51} @samp{51ac} @samp{51ag} @samp{51cn} @samp{51em} @samp{51je} @samp{51jf} @samp{51jg} @samp{51jm} @samp{51mm} @samp{51qe} @samp{51qm}
28638@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
28639@item @samp{5206e} @tab @samp{5206e}
28640@item @samp{5208} @tab @samp{5207} @samp{5208}
28641@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
28642@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
28643@item @samp{5216} @tab @samp{5214} @samp{5216}
28644@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
28645@item @samp{5225} @tab @samp{5224} @samp{5225}
28646@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
28647@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
28648@item @samp{5249} @tab @samp{5249}
28649@item @samp{5250} @tab @samp{5250}
28650@item @samp{5271} @tab @samp{5270} @samp{5271}
28651@item @samp{5272} @tab @samp{5272}
28652@item @samp{5275} @tab @samp{5274} @samp{5275}
28653@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
28654@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
28655@item @samp{5307} @tab @samp{5307}
28656@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
28657@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
28658@item @samp{5407} @tab @samp{5407}
28659@item @samp{5475} @tab @samp{5470} @samp{5471} @samp{5472} @samp{5473} @samp{5474} @samp{5475} @samp{547x} @samp{5480} @samp{5481} @samp{5482} @samp{5483} @samp{5484} @samp{5485}
28660@end multitable
28661
28662@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
28663@var{arch} is compatible with @var{cpu}. Other combinations of
28664@option{-mcpu} and @option{-march} are rejected.
28665
28666GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
28667@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
28668where the value of @var{family} is given by the table above.
28669
d77de738 28670@opindex mtune
ddf6fe37 28671@item -mtune=@var{tune}
d77de738
ML
28672Tune the code for a particular microarchitecture within the
28673constraints set by @option{-march} and @option{-mcpu}.
28674The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
28675@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
28676and @samp{cpu32}. The ColdFire microarchitectures
28677are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
28678
28679You can also use @option{-mtune=68020-40} for code that needs
28680to run relatively well on 68020, 68030 and 68040 targets.
28681@option{-mtune=68020-60} is similar but includes 68060 targets
28682as well. These two options select the same tuning decisions as
28683@option{-m68020-40} and @option{-m68020-60} respectively.
28684
28685GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
28686when tuning for 680x0 architecture @var{arch}. It also defines
28687@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
28688option is used. If GCC is tuning for a range of architectures,
28689as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
28690it defines the macros for every architecture in the range.
28691
28692GCC also defines the macro @code{__m@var{uarch}__} when tuning for
28693ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
28694of the arguments given above.
28695
d77de738
ML
28696@opindex m68000
28697@opindex mc68000
ddf6fe37
AA
28698@item -m68000
28699@itemx -mc68000
d77de738
ML
28700Generate output for a 68000. This is the default
28701when the compiler is configured for 68000-based systems.
28702It is equivalent to @option{-march=68000}.
28703
28704Use this option for microcontrollers with a 68000 or EC000 core,
28705including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
28706
d77de738 28707@opindex m68010
ddf6fe37 28708@item -m68010
d77de738
ML
28709Generate output for a 68010. This is the default
28710when the compiler is configured for 68010-based systems.
28711It is equivalent to @option{-march=68010}.
28712
d77de738
ML
28713@opindex m68020
28714@opindex mc68020
ddf6fe37
AA
28715@item -m68020
28716@itemx -mc68020
d77de738
ML
28717Generate output for a 68020. This is the default
28718when the compiler is configured for 68020-based systems.
28719It is equivalent to @option{-march=68020}.
28720
d77de738 28721@opindex m68030
ddf6fe37 28722@item -m68030
d77de738
ML
28723Generate output for a 68030. This is the default when the compiler is
28724configured for 68030-based systems. It is equivalent to
28725@option{-march=68030}.
28726
d77de738 28727@opindex m68040
ddf6fe37 28728@item -m68040
d77de738
ML
28729Generate output for a 68040. This is the default when the compiler is
28730configured for 68040-based systems. It is equivalent to
28731@option{-march=68040}.
28732
28733This option inhibits the use of 68881/68882 instructions that have to be
28734emulated by software on the 68040. Use this option if your 68040 does not
28735have code to emulate those instructions.
28736
d77de738 28737@opindex m68060
ddf6fe37 28738@item -m68060
d77de738
ML
28739Generate output for a 68060. This is the default when the compiler is
28740configured for 68060-based systems. It is equivalent to
28741@option{-march=68060}.
28742
28743This option inhibits the use of 68020 and 68881/68882 instructions that
28744have to be emulated by software on the 68060. Use this option if your 68060
28745does not have code to emulate those instructions.
28746
d77de738 28747@opindex mcpu32
ddf6fe37 28748@item -mcpu32
d77de738
ML
28749Generate output for a CPU32. This is the default
28750when the compiler is configured for CPU32-based systems.
28751It is equivalent to @option{-march=cpu32}.
28752
28753Use this option for microcontrollers with a
28754CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2875568336, 68340, 68341, 68349 and 68360.
28756
d77de738 28757@opindex m5200
ddf6fe37 28758@item -m5200
d77de738
ML
28759Generate output for a 520X ColdFire CPU@. This is the default
28760when the compiler is configured for 520X-based systems.
28761It is equivalent to @option{-mcpu=5206}, and is now deprecated
28762in favor of that option.
28763
28764Use this option for microcontroller with a 5200 core, including
28765the MCF5202, MCF5203, MCF5204 and MCF5206.
28766
d77de738 28767@opindex m5206e
ddf6fe37 28768@item -m5206e
d77de738
ML
28769Generate output for a 5206e ColdFire CPU@. The option is now
28770deprecated in favor of the equivalent @option{-mcpu=5206e}.
28771
d77de738 28772@opindex m528x
ddf6fe37 28773@item -m528x
d77de738
ML
28774Generate output for a member of the ColdFire 528X family.
28775The option is now deprecated in favor of the equivalent
28776@option{-mcpu=528x}.
28777
d77de738 28778@opindex m5307
ddf6fe37 28779@item -m5307
d77de738
ML
28780Generate output for a ColdFire 5307 CPU@. The option is now deprecated
28781in favor of the equivalent @option{-mcpu=5307}.
28782
d77de738 28783@opindex m5407
ddf6fe37 28784@item -m5407
d77de738
ML
28785Generate output for a ColdFire 5407 CPU@. The option is now deprecated
28786in favor of the equivalent @option{-mcpu=5407}.
28787
d77de738 28788@opindex mcfv4e
ddf6fe37 28789@item -mcfv4e
d77de738
ML
28790Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
28791This includes use of hardware floating-point instructions.
28792The option is equivalent to @option{-mcpu=547x}, and is now
28793deprecated in favor of that option.
28794
d77de738 28795@opindex m68020-40
ddf6fe37 28796@item -m68020-40
d77de738
ML
28797Generate output for a 68040, without using any of the new instructions.
28798This results in code that can run relatively efficiently on either a
2879968020/68881 or a 68030 or a 68040. The generated code does use the
2880068881 instructions that are emulated on the 68040.
28801
28802The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
28803
d77de738 28804@opindex m68020-60
ddf6fe37 28805@item -m68020-60
d77de738
ML
28806Generate output for a 68060, without using any of the new instructions.
28807This results in code that can run relatively efficiently on either a
2880868020/68881 or a 68030 or a 68040. The generated code does use the
2880968881 instructions that are emulated on the 68060.
28810
28811The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
28812
d77de738
ML
28813@opindex mhard-float
28814@opindex m68881
ddf6fe37
AA
28815@item -mhard-float
28816@itemx -m68881
d77de738
ML
28817Generate floating-point instructions. This is the default for 68020
28818and above, and for ColdFire devices that have an FPU@. It defines the
28819macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
28820on ColdFire targets.
28821
d77de738 28822@opindex msoft-float
ddf6fe37 28823@item -msoft-float
d77de738
ML
28824Do not generate floating-point instructions; use library calls instead.
28825This is the default for 68000, 68010, and 68832 targets. It is also
28826the default for ColdFire devices that have no FPU.
28827
d77de738
ML
28828@opindex mdiv
28829@opindex mno-div
ddf6fe37
AA
28830@item -mdiv
28831@itemx -mno-div
d77de738
ML
28832Generate (do not generate) ColdFire hardware divide and remainder
28833instructions. If @option{-march} is used without @option{-mcpu},
28834the default is ``on'' for ColdFire architectures and ``off'' for M680x0
28835architectures. Otherwise, the default is taken from the target CPU
28836(either the default CPU, or the one specified by @option{-mcpu}). For
28837example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
28838@option{-mcpu=5206e}.
28839
28840GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
28841
d77de738 28842@opindex mshort
ddf6fe37 28843@item -mshort
d77de738
ML
28844Consider type @code{int} to be 16 bits wide, like @code{short int}.
28845Additionally, parameters passed on the stack are also aligned to a
2884616-bit boundary even on targets whose API mandates promotion to 32-bit.
28847
d77de738 28848@opindex mno-short
ddf6fe37 28849@item -mno-short
d77de738
ML
28850Do not consider type @code{int} to be 16 bits wide. This is the default.
28851
d77de738
ML
28852@opindex mnobitfield
28853@opindex mno-bitfield
ddf6fe37
AA
28854@item -mnobitfield
28855@itemx -mno-bitfield
d77de738
ML
28856Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
28857and @option{-m5200} options imply @w{@option{-mnobitfield}}.
28858
d77de738 28859@opindex mbitfield
ddf6fe37 28860@item -mbitfield
d77de738
ML
28861Do use the bit-field instructions. The @option{-m68020} option implies
28862@option{-mbitfield}. This is the default if you use a configuration
28863designed for a 68020.
28864
d77de738 28865@opindex mrtd
ddf6fe37 28866@item -mrtd
d77de738
ML
28867Use a different function-calling convention, in which functions
28868that take a fixed number of arguments return with the @code{rtd}
28869instruction, which pops their arguments while returning. This
28870saves one instruction in the caller since there is no need to pop
28871the arguments there.
28872
28873This calling convention is incompatible with the one normally
28874used on Unix, so you cannot use it if you need to call libraries
28875compiled with the Unix compiler.
28876
28877Also, you must provide function prototypes for all functions that
28878take variable numbers of arguments (including @code{printf});
28879otherwise incorrect code is generated for calls to those
28880functions.
28881
28882In addition, seriously incorrect code results if you call a
28883function with too many arguments. (Normally, extra arguments are
28884harmlessly ignored.)
28885
28886The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2888768040, 68060 and CPU32 processors, but not by the 68000 or 5200.
28888
28889The default is @option{-mno-rtd}.
28890
d77de738
ML
28891@opindex malign-int
28892@opindex mno-align-int
ddf6fe37
AA
28893@item -malign-int
28894@itemx -mno-align-int
d77de738
ML
28895Control whether GCC aligns @code{int}, @code{long}, @code{long long},
28896@code{float}, @code{double}, and @code{long double} variables on a 32-bit
28897boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
28898Aligning variables on 32-bit boundaries produces code that runs somewhat
28899faster on processors with 32-bit busses at the expense of more memory.
28900
28901@strong{Warning:} if you use the @option{-malign-int} switch, GCC
28902aligns structures containing the above types differently than
28903most published application binary interface specifications for the m68k.
28904
28905@opindex mpcrel
28906Use the pc-relative addressing mode of the 68000 directly, instead of
28907using a global offset table. At present, this option implies @option{-fpic},
28908allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
28909not presently supported with @option{-mpcrel}, though this could be supported for
2891068020 and higher processors.
28911
d77de738
ML
28912@opindex mno-strict-align
28913@opindex mstrict-align
ddf6fe37
AA
28914@item -mno-strict-align
28915@itemx -mstrict-align
d77de738
ML
28916Do not (do) assume that unaligned memory references are handled by
28917the system.
28918
28919@item -msep-data
28920Generate code that allows the data segment to be located in a different
28921area of memory from the text segment. This allows for execute-in-place in
28922an environment without virtual memory management. This option implies
28923@option{-fPIC}.
28924
28925@item -mno-sep-data
28926Generate code that assumes that the data segment follows the text segment.
28927This is the default.
28928
28929@item -mid-shared-library
28930Generate code that supports shared libraries via the library ID method.
28931This allows for execute-in-place and shared libraries in an environment
28932without virtual memory management. This option implies @option{-fPIC}.
28933
28934@item -mno-id-shared-library
28935Generate code that doesn't assume ID-based shared libraries are being used.
28936This is the default.
28937
28938@item -mshared-library-id=n
28939Specifies the identification number of the ID-based shared library being
28940compiled. Specifying a value of 0 generates more compact code; specifying
28941other values forces the allocation of that number to the current
28942library, but is no more space- or time-efficient than omitting this option.
28943
d77de738
ML
28944@opindex mxgot
28945@opindex mno-xgot
ddf6fe37
AA
28946@item -mxgot
28947@itemx -mno-xgot
d77de738
ML
28948When generating position-independent code for ColdFire, generate code
28949that works if the GOT has more than 8192 entries. This code is
28950larger and slower than code generated without this option. On M680x0
28951processors, this option is not needed; @option{-fPIC} suffices.
28952
28953GCC normally uses a single instruction to load values from the GOT@.
28954While this is relatively efficient, it only works if the GOT
28955is smaller than about 64k. Anything larger causes the linker
28956to report an error such as:
28957
28958@cindex relocation truncated to fit (ColdFire)
28959@smallexample
28960relocation truncated to fit: R_68K_GOT16O foobar
28961@end smallexample
28962
28963If this happens, you should recompile your code with @option{-mxgot}.
28964It should then work with very large GOTs. However, code generated with
28965@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
28966the value of a global symbol.
28967
28968Note that some linkers, including newer versions of the GNU linker,
28969can create multiple GOTs and sort GOT entries. If you have such a linker,
28970you should only need to use @option{-mxgot} when compiling a single
28971object file that accesses more than 8192 GOT entries. Very few do.
28972
28973These options have no effect unless GCC is generating
28974position-independent code.
28975
d77de738 28976@opindex mlong-jump-table-offsets
ddf6fe37 28977@item -mlong-jump-table-offsets
d77de738
ML
28978Use 32-bit offsets in @code{switch} tables. The default is to use
2897916-bit offsets.
28980
28981@end table
28982
28983@node MCore Options
28984@subsection MCore Options
28985@cindex MCore options
28986
28987These are the @samp{-m} options defined for the Motorola M*Core
28988processors.
28989
28990@table @gcctabopt
28991
d77de738
ML
28992@opindex mhardlit
28993@opindex mno-hardlit
ddf6fe37
AA
28994@item -mhardlit
28995@itemx -mno-hardlit
d77de738
ML
28996Inline constants into the code stream if it can be done in two
28997instructions or less.
28998
d77de738
ML
28999@opindex mdiv
29000@opindex mno-div
ddf6fe37
AA
29001@item -mdiv
29002@itemx -mno-div
d77de738
ML
29003Use the divide instruction. (Enabled by default).
29004
d77de738
ML
29005@opindex mrelax-immediate
29006@opindex mno-relax-immediate
ddf6fe37
AA
29007@item -mrelax-immediate
29008@itemx -mno-relax-immediate
d77de738
ML
29009Allow arbitrary-sized immediates in bit operations.
29010
d77de738
ML
29011@opindex mwide-bitfields
29012@opindex mno-wide-bitfields
ddf6fe37
AA
29013@item -mwide-bitfields
29014@itemx -mno-wide-bitfields
d77de738
ML
29015Always treat bit-fields as @code{int}-sized.
29016
d77de738
ML
29017@opindex m4byte-functions
29018@opindex mno-4byte-functions
ddf6fe37
AA
29019@item -m4byte-functions
29020@itemx -mno-4byte-functions
d77de738
ML
29021Force all functions to be aligned to a 4-byte boundary.
29022
d77de738
ML
29023@opindex mcallgraph-data
29024@opindex mno-callgraph-data
ddf6fe37
AA
29025@item -mcallgraph-data
29026@itemx -mno-callgraph-data
d77de738
ML
29027Emit callgraph information.
29028
d77de738
ML
29029@opindex mslow-bytes
29030@opindex mno-slow-bytes
ddf6fe37
AA
29031@item -mslow-bytes
29032@itemx -mno-slow-bytes
d77de738
ML
29033Prefer word access when reading byte quantities.
29034
d77de738
ML
29035@opindex mlittle-endian
29036@opindex mbig-endian
ddf6fe37
AA
29037@item -mlittle-endian
29038@itemx -mbig-endian
d77de738
ML
29039Generate code for a little-endian target.
29040
d77de738
ML
29041@opindex m210
29042@opindex m340
ddf6fe37
AA
29043@item -m210
29044@itemx -m340
d77de738
ML
29045Generate code for the 210 processor.
29046
d77de738 29047@opindex mno-lsim
ddf6fe37 29048@item -mno-lsim
d77de738
ML
29049Assume that runtime support has been provided and so omit the
29050simulator library (@file{libsim.a)} from the linker command line.
29051
d77de738 29052@opindex mstack-increment
ddf6fe37 29053@item -mstack-increment=@var{size}
d77de738
ML
29054Set the maximum amount for a single stack increment operation. Large
29055values can increase the speed of programs that contain functions
29056that need a large amount of stack space, but they can also trigger a
29057segmentation fault if the stack is extended too much. The default
29058value is 0x1000.
29059
29060@end table
29061
d77de738
ML
29062@node MicroBlaze Options
29063@subsection MicroBlaze Options
29064@cindex MicroBlaze Options
29065
29066@table @gcctabopt
29067
d77de738 29068@opindex msoft-float
ddf6fe37 29069@item -msoft-float
d77de738
ML
29070Use software emulation for floating point (default).
29071
d77de738 29072@opindex mhard-float
ddf6fe37 29073@item -mhard-float
d77de738
ML
29074Use hardware floating-point instructions.
29075
d77de738 29076@opindex mmemcpy
ddf6fe37 29077@item -mmemcpy
d77de738
ML
29078Do not optimize block moves, use @code{memcpy}.
29079
d77de738 29080@opindex mno-clearbss
ddf6fe37 29081@item -mno-clearbss
d77de738
ML
29082This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
29083
d77de738 29084@opindex mcpu=
ddf6fe37 29085@item -mcpu=@var{cpu-type}
d77de738
ML
29086Use features of, and schedule code for, the given CPU.
29087Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
29088where @var{X} is a major version, @var{YY} is the minor version, and
29089@var{Z} is compatibility code. Example values are @samp{v3.00.a},
29090@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
29091
d77de738 29092@opindex mxl-soft-mul
ddf6fe37 29093@item -mxl-soft-mul
d77de738
ML
29094Use software multiply emulation (default).
29095
d77de738 29096@opindex mxl-soft-div
ddf6fe37 29097@item -mxl-soft-div
d77de738
ML
29098Use software emulation for divides (default).
29099
d77de738 29100@opindex mxl-barrel-shift
ddf6fe37 29101@item -mxl-barrel-shift
d77de738
ML
29102Use the hardware barrel shifter.
29103
d77de738 29104@opindex mxl-pattern-compare
ddf6fe37 29105@item -mxl-pattern-compare
d77de738
ML
29106Use pattern compare instructions.
29107
d77de738 29108@opindex msmall-divides
ddf6fe37 29109@item -msmall-divides
d77de738
ML
29110Use table lookup optimization for small signed integer divisions.
29111
d77de738 29112@opindex mxl-stack-check
ddf6fe37 29113@item -mxl-stack-check
d77de738
ML
29114This option is deprecated. Use @option{-fstack-check} instead.
29115
d77de738 29116@opindex mxl-gp-opt
ddf6fe37 29117@item -mxl-gp-opt
d77de738
ML
29118Use GP-relative @code{.sdata}/@code{.sbss} sections.
29119
d77de738 29120@opindex mxl-multiply-high
ddf6fe37 29121@item -mxl-multiply-high
d77de738
ML
29122Use multiply high instructions for high part of 32x32 multiply.
29123
d77de738 29124@opindex mxl-float-convert
ddf6fe37 29125@item -mxl-float-convert
d77de738
ML
29126Use hardware floating-point conversion instructions.
29127
d77de738 29128@opindex mxl-float-sqrt
ddf6fe37 29129@item -mxl-float-sqrt
d77de738
ML
29130Use hardware floating-point square root instruction.
29131
d77de738 29132@opindex mbig-endian
ddf6fe37 29133@item -mbig-endian
d77de738
ML
29134Generate code for a big-endian target.
29135
d77de738 29136@opindex mlittle-endian
ddf6fe37 29137@item -mlittle-endian
d77de738
ML
29138Generate code for a little-endian target.
29139
d77de738 29140@opindex mxl-reorder
ddf6fe37 29141@item -mxl-reorder
d77de738
ML
29142Use reorder instructions (swap and byte reversed load/store).
29143
29144@item -mxl-mode-@var{app-model}
29145Select application model @var{app-model}. Valid models are
29146@table @samp
29147@item executable
29148normal executable (default), uses startup code @file{crt0.o}.
29149
29150@item xmdstub
29151for use with Xilinx Microprocessor Debugger (XMD) based
29152software intrusive debug agent called xmdstub. This uses startup file
29153@file{crt1.o} and sets the start address of the program to 0x800.
29154
29155@item bootstrap
29156for applications that are loaded using a bootloader.
29157This model uses startup file @file{crt2.o} which does not contain a processor
29158reset vector handler. This is suitable for transferring control on a
29159processor reset to the bootloader rather than the application.
29160
29161@item novectors
29162for applications that do not require any of the
29163MicroBlaze vectors. This option may be useful for applications running
29164within a monitoring application. This model uses @file{crt3.o} as a startup file.
29165@end table
29166
29167Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
29168@option{-mxl-mode-@var{app-model}}.
29169
d77de738 29170@opindex mpic-data-is-text-relative
ddf6fe37 29171@item -mpic-data-is-text-relative
d77de738
ML
29172Assume that the displacement between the text and data segments is fixed
29173at static link time. This allows data to be referenced by offset from start of
29174text address instead of GOT since PC-relative addressing is not supported.
29175
29176@end table
29177
29178@node MIPS Options
29179@subsection MIPS Options
29180@cindex MIPS options
29181
29182@table @gcctabopt
29183
d77de738 29184@opindex EB
ddf6fe37 29185@item -EB
d77de738
ML
29186Generate big-endian code.
29187
d77de738 29188@opindex EL
ddf6fe37 29189@item -EL
d77de738
ML
29190Generate little-endian code. This is the default for @samp{mips*el-*-*}
29191configurations.
29192
d77de738 29193@opindex march
ddf6fe37 29194@item -march=@var{arch}
d77de738
ML
29195Generate code that runs on @var{arch}, which can be the name of a
29196generic MIPS ISA, or the name of a particular processor.
29197The ISA names are:
29198@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
29199@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
29200@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
29201@samp{mips64r5} and @samp{mips64r6}.
29202The processor names are:
29203@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
29204@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
29205@samp{5kc}, @samp{5kf},
29206@samp{20kc},
29207@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
29208@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
29209@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
29210@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
29211@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
29212@samp{i6400}, @samp{i6500},
29213@samp{interaptiv},
29214@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
29215@samp{gs464e}, @samp{gs264e},
29216@samp{m4k},
29217@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
29218@samp{m5100}, @samp{m5101},
29219@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
29220@samp{orion},
29221@samp{p5600}, @samp{p6600},
29222@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
29223@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
29224@samp{r6000}, @samp{r8000},
29225@samp{rm7000}, @samp{rm9000},
29226@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
29227@samp{sb1},
29228@samp{sr71000},
29229@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
29230@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
29231@samp{xlr} and @samp{xlp}.
29232The special value @samp{from-abi} selects the
29233most compatible architecture for the selected ABI (that is,
29234@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
29235
29236The native Linux/GNU toolchain also supports the value @samp{native},
29237which selects the best architecture option for the host processor.
29238@option{-march=native} has no effect if GCC does not recognize
29239the processor.
29240
29241In processor names, a final @samp{000} can be abbreviated as @samp{k}
29242(for example, @option{-march=r2k}). Prefixes are optional, and
29243@samp{vr} may be written @samp{r}.
29244
29245Names of the form @samp{@var{n}f2_1} refer to processors with
29246FPUs clocked at half the rate of the core, names of the form
29247@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
29248rate as the core, and names of the form @samp{@var{n}f3_2} refer to
29249processors with FPUs clocked a ratio of 3:2 with respect to the core.
29250For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
29251for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
29252accepted as synonyms for @samp{@var{n}f1_1}.
29253
29254GCC defines two macros based on the value of this option. The first
29255is @code{_MIPS_ARCH}, which gives the name of target architecture, as
29256a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
29257where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
29258For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
29259to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
29260
29261Note that the @code{_MIPS_ARCH} macro uses the processor names given
29262above. In other words, it has the full prefix and does not
29263abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
29264the macro names the resolved architecture (either @code{"mips1"} or
29265@code{"mips3"}). It names the default architecture when no
29266@option{-march} option is given.
29267
d77de738 29268@opindex mtune
ddf6fe37 29269@item -mtune=@var{arch}
d77de738
ML
29270Optimize for @var{arch}. Among other things, this option controls
29271the way instructions are scheduled, and the perceived cost of arithmetic
29272operations. The list of @var{arch} values is the same as for
29273@option{-march}.
29274
29275When this option is not used, GCC optimizes for the processor
29276specified by @option{-march}. By using @option{-march} and
29277@option{-mtune} together, it is possible to generate code that
29278runs on a family of processors, but optimize the code for one
29279particular member of that family.
29280
29281@option{-mtune} defines the macros @code{_MIPS_TUNE} and
29282@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
29283@option{-march} ones described above.
29284
d77de738 29285@opindex mips1
ddf6fe37 29286@item -mips1
d77de738
ML
29287Equivalent to @option{-march=mips1}.
29288
d77de738 29289@opindex mips2
ddf6fe37 29290@item -mips2
d77de738
ML
29291Equivalent to @option{-march=mips2}.
29292
d77de738 29293@opindex mips3
ddf6fe37 29294@item -mips3
d77de738
ML
29295Equivalent to @option{-march=mips3}.
29296
d77de738 29297@opindex mips4
ddf6fe37 29298@item -mips4
d77de738
ML
29299Equivalent to @option{-march=mips4}.
29300
d77de738 29301@opindex mips32
ddf6fe37 29302@item -mips32
d77de738
ML
29303Equivalent to @option{-march=mips32}.
29304
d77de738 29305@opindex mips32r3
ddf6fe37 29306@item -mips32r3
d77de738
ML
29307Equivalent to @option{-march=mips32r3}.
29308
d77de738 29309@opindex mips32r5
ddf6fe37 29310@item -mips32r5
d77de738
ML
29311Equivalent to @option{-march=mips32r5}.
29312
d77de738 29313@opindex mips32r6
ddf6fe37 29314@item -mips32r6
d77de738
ML
29315Equivalent to @option{-march=mips32r6}.
29316
d77de738 29317@opindex mips64
ddf6fe37 29318@item -mips64
d77de738
ML
29319Equivalent to @option{-march=mips64}.
29320
d77de738 29321@opindex mips64r2
ddf6fe37 29322@item -mips64r2
d77de738
ML
29323Equivalent to @option{-march=mips64r2}.
29324
d77de738 29325@opindex mips64r3
ddf6fe37 29326@item -mips64r3
d77de738
ML
29327Equivalent to @option{-march=mips64r3}.
29328
d77de738 29329@opindex mips64r5
ddf6fe37 29330@item -mips64r5
d77de738
ML
29331Equivalent to @option{-march=mips64r5}.
29332
d77de738 29333@opindex mips64r6
ddf6fe37 29334@item -mips64r6
d77de738
ML
29335Equivalent to @option{-march=mips64r6}.
29336
d77de738
ML
29337@opindex mips16
29338@opindex mno-mips16
ddf6fe37
AA
29339@item -mips16
29340@itemx -mno-mips16
d77de738
ML
29341Generate (do not generate) MIPS16 code. If GCC is targeting a
29342MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
29343
29344MIPS16 code generation can also be controlled on a per-function basis
29345by means of @code{mips16} and @code{nomips16} attributes.
29346@xref{Function Attributes}, for more information.
29347
926f2d09
JM
29348@opindex mmips16e2
29349@opindex mno-mips16e2
29350@item -mmips16e2
29351@itemx -mno-mips16e2
29352Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
29353of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
29354
d77de738 29355@opindex mflip-mips16
ddf6fe37 29356@item -mflip-mips16
d77de738
ML
29357Generate MIPS16 code on alternating functions. This option is provided
29358for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
29359not intended for ordinary use in compiling user code.
29360
d77de738
ML
29361@opindex minterlink-compressed
29362@opindex mno-interlink-compressed
ddf6fe37
AA
29363@item -minterlink-compressed
29364@itemx -mno-interlink-compressed
d77de738
ML
29365Require (do not require) that code using the standard (uncompressed) MIPS ISA
29366be link-compatible with MIPS16 and microMIPS code, and vice versa.
29367
29368For example, code using the standard ISA encoding cannot jump directly
29369to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
29370@option{-minterlink-compressed} therefore disables direct jumps unless GCC
29371knows that the target of the jump is not compressed.
29372
d77de738
ML
29373@opindex minterlink-mips16
29374@opindex mno-interlink-mips16
ddf6fe37
AA
29375@item -minterlink-mips16
29376@itemx -mno-interlink-mips16
d77de738
ML
29377Aliases of @option{-minterlink-compressed} and
29378@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
29379and are retained for backwards compatibility.
29380
00bc8c09 29381@opindex mabi
ddf6fe37
AA
29382@item -mabi=32
29383@itemx -mabi=o64
29384@itemx -mabi=n32
29385@itemx -mabi=64
29386@itemx -mabi=eabi
d77de738
ML
29387Generate code for the given ABI@.
29388
29389Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
29390generates 64-bit code when you select a 64-bit architecture, but you
29391can use @option{-mgp32} to get 32-bit code instead.
29392
29393For information about the O64 ABI, see
29394@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
29395
29396GCC supports a variant of the o32 ABI in which floating-point registers
29397are 64 rather than 32 bits wide. You can select this combination with
29398@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
29399and @code{mfhc1} instructions and is therefore only supported for
29400MIPS32R2, MIPS32R3 and MIPS32R5 processors.
29401
29402The register assignments for arguments and return values remain the
29403same, but each scalar value is passed in a single 64-bit register
29404rather than a pair of 32-bit registers. For example, scalar
29405floating-point values are returned in @samp{$f0} only, not a
29406@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
29407remains the same in that the even-numbered double-precision registers
29408are saved.
29409
29410Two additional variants of the o32 ABI are supported to enable
29411a transition from 32-bit to 64-bit registers. These are FPXX
29412(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
29413The FPXX extension mandates that all code must execute correctly
29414when run using 32-bit or 64-bit registers. The code can be interlinked
29415with either FP32 or FP64, but not both.
29416The FP64A extension is similar to the FP64 extension but forbids the
29417use of odd-numbered single-precision registers. This can be used
29418in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
29419processors and allows both FP32 and FP64A code to interlink and
29420run in the same process without changing FPU modes.
29421
d77de738
ML
29422@opindex mabicalls
29423@opindex mno-abicalls
ddf6fe37
AA
29424@item -mabicalls
29425@itemx -mno-abicalls
d77de738
ML
29426Generate (do not generate) code that is suitable for SVR4-style
29427dynamic objects. @option{-mabicalls} is the default for SVR4-based
29428systems.
29429
29430@item -mshared
29431@itemx -mno-shared
29432Generate (do not generate) code that is fully position-independent,
29433and that can therefore be linked into shared libraries. This option
29434only affects @option{-mabicalls}.
29435
29436All @option{-mabicalls} code has traditionally been position-independent,
29437regardless of options like @option{-fPIC} and @option{-fpic}. However,
29438as an extension, the GNU toolchain allows executables to use absolute
29439accesses for locally-binding symbols. It can also use shorter GP
29440initialization sequences and generate direct calls to locally-defined
29441functions. This mode is selected by @option{-mno-shared}.
29442
29443@option{-mno-shared} depends on binutils 2.16 or higher and generates
29444objects that can only be linked by the GNU linker. However, the option
29445does not affect the ABI of the final executable; it only affects the ABI
29446of relocatable objects. Using @option{-mno-shared} generally makes
29447executables both smaller and quicker.
29448
29449@option{-mshared} is the default.
29450
d77de738
ML
29451@opindex mplt
29452@opindex mno-plt
ddf6fe37
AA
29453@item -mplt
29454@itemx -mno-plt
d77de738
ML
29455Assume (do not assume) that the static and dynamic linkers
29456support PLTs and copy relocations. This option only affects
29457@option{-mno-shared -mabicalls}. For the n64 ABI, this option
29458has no effect without @option{-msym32}.
29459
29460You can make @option{-mplt} the default by configuring
29461GCC with @option{--with-mips-plt}. The default is
29462@option{-mno-plt} otherwise.
29463
d77de738
ML
29464@opindex mxgot
29465@opindex mno-xgot
ddf6fe37
AA
29466@item -mxgot
29467@itemx -mno-xgot
d77de738
ML
29468Lift (do not lift) the usual restrictions on the size of the global
29469offset table.
29470
29471GCC normally uses a single instruction to load values from the GOT@.
29472While this is relatively efficient, it only works if the GOT
29473is smaller than about 64k. Anything larger causes the linker
29474to report an error such as:
29475
29476@cindex relocation truncated to fit (MIPS)
29477@smallexample
29478relocation truncated to fit: R_MIPS_GOT16 foobar
29479@end smallexample
29480
29481If this happens, you should recompile your code with @option{-mxgot}.
29482This works with very large GOTs, although the code is also
29483less efficient, since it takes three instructions to fetch the
29484value of a global symbol.
29485
29486Note that some linkers can create multiple GOTs. If you have such a
29487linker, you should only need to use @option{-mxgot} when a single object
29488file accesses more than 64k's worth of GOT entries. Very few do.
29489
29490These options have no effect unless GCC is generating position
29491independent code.
29492
d77de738 29493@opindex mgp32
ddf6fe37 29494@item -mgp32
d77de738
ML
29495Assume that general-purpose registers are 32 bits wide.
29496
d77de738 29497@opindex mgp64
ddf6fe37 29498@item -mgp64
d77de738
ML
29499Assume that general-purpose registers are 64 bits wide.
29500
d77de738 29501@opindex mfp32
ddf6fe37 29502@item -mfp32
d77de738
ML
29503Assume that floating-point registers are 32 bits wide.
29504
d77de738 29505@opindex mfp64
ddf6fe37 29506@item -mfp64
d77de738
ML
29507Assume that floating-point registers are 64 bits wide.
29508
d77de738 29509@opindex mfpxx
ddf6fe37 29510@item -mfpxx
d77de738
ML
29511Do not assume the width of floating-point registers.
29512
d77de738 29513@opindex mhard-float
ddf6fe37 29514@item -mhard-float
d77de738
ML
29515Use floating-point coprocessor instructions.
29516
d77de738 29517@opindex msoft-float
ddf6fe37 29518@item -msoft-float
d77de738
ML
29519Do not use floating-point coprocessor instructions. Implement
29520floating-point calculations using library calls instead.
29521
d77de738 29522@opindex mno-float
ddf6fe37 29523@item -mno-float
d77de738
ML
29524Equivalent to @option{-msoft-float}, but additionally asserts that the
29525program being compiled does not perform any floating-point operations.
29526This option is presently supported only by some bare-metal MIPS
29527configurations, where it may select a special set of libraries
29528that lack all floating-point support (including, for example, the
a0e64a04 29529floating-point @code{printf} formats).
d77de738
ML
29530If code compiled with @option{-mno-float} accidentally contains
29531floating-point operations, it is likely to suffer a link-time
29532or run-time failure.
29533
d77de738 29534@opindex msingle-float
ddf6fe37 29535@item -msingle-float
d77de738
ML
29536Assume that the floating-point coprocessor only supports single-precision
29537operations.
29538
d77de738 29539@opindex mdouble-float
ddf6fe37 29540@item -mdouble-float
d77de738
ML
29541Assume that the floating-point coprocessor supports double-precision
29542operations. This is the default.
29543
d77de738
ML
29544@opindex modd-spreg
29545@opindex mno-odd-spreg
ddf6fe37
AA
29546@item -modd-spreg
29547@itemx -mno-odd-spreg
d77de738
ML
29548Enable the use of odd-numbered single-precision floating-point registers
29549for the o32 ABI. This is the default for processors that are known to
29550support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
29551is set by default.
29552
d77de738
ML
29553@opindex mabs=2008
29554@opindex mabs=legacy
ddf6fe37
AA
29555@item -mabs=2008
29556@itemx -mabs=legacy
d77de738
ML
29557These options control the treatment of the special not-a-number (NaN)
29558IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
29559@code{neg.@i{fmt}} machine instructions.
29560
29561By default or when @option{-mabs=legacy} is used the legacy
29562treatment is selected. In this case these instructions are considered
29563arithmetic and avoided where correct operation is required and the
29564input operand might be a NaN. A longer sequence of instructions that
29565manipulate the sign bit of floating-point datum manually is used
29566instead unless the @option{-ffinite-math-only} option has also been
29567specified.
29568
29569The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
29570this case these instructions are considered non-arithmetic and therefore
29571operating correctly in all cases, including in particular where the
29572input operand is a NaN. These instructions are therefore always used
29573for the respective operations.
29574
d77de738
ML
29575@opindex mnan=2008
29576@opindex mnan=legacy
ddf6fe37
AA
29577@item -mnan=2008
29578@itemx -mnan=legacy
d77de738
ML
29579These options control the encoding of the special not-a-number (NaN)
29580IEEE 754 floating-point data.
29581
29582The @option{-mnan=legacy} option selects the legacy encoding. In this
29583case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
29584significand field being 0, whereas signaling NaNs (sNaNs) are denoted
29585by the first bit of their trailing significand field being 1.
29586
29587The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
29588this case qNaNs are denoted by the first bit of their trailing
29589significand field being 1, whereas sNaNs are denoted by the first bit of
29590their trailing significand field being 0.
29591
29592The default is @option{-mnan=legacy} unless GCC has been configured with
29593@option{--with-nan=2008}.
29594
d77de738
ML
29595@opindex mllsc
29596@opindex mno-llsc
ddf6fe37
AA
29597@item -mllsc
29598@itemx -mno-llsc
d77de738
ML
29599Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
29600implement atomic memory built-in functions. When neither option is
29601specified, GCC uses the instructions if the target architecture
29602supports them.
29603
29604@option{-mllsc} is useful if the runtime environment can emulate the
29605instructions and @option{-mno-llsc} can be useful when compiling for
29606nonstandard ISAs. You can make either option the default by
29607configuring GCC with @option{--with-llsc} and @option{--without-llsc}
29608respectively. @option{--with-llsc} is the default for some
29609configurations; see the installation documentation for details.
29610
d77de738
ML
29611@opindex mdsp
29612@opindex mno-dsp
ddf6fe37
AA
29613@item -mdsp
29614@itemx -mno-dsp
d77de738
ML
29615Use (do not use) revision 1 of the MIPS DSP ASE@.
29616@xref{MIPS DSP Built-in Functions}. This option defines the
29617preprocessor macro @code{__mips_dsp}. It also defines
29618@code{__mips_dsp_rev} to 1.
29619
d77de738
ML
29620@opindex mdspr2
29621@opindex mno-dspr2
ddf6fe37
AA
29622@item -mdspr2
29623@itemx -mno-dspr2
d77de738
ML
29624Use (do not use) revision 2 of the MIPS DSP ASE@.
29625@xref{MIPS DSP Built-in Functions}. This option defines the
29626preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
29627It also defines @code{__mips_dsp_rev} to 2.
29628
d77de738
ML
29629@opindex msmartmips
29630@opindex mno-smartmips
ddf6fe37
AA
29631@item -msmartmips
29632@itemx -mno-smartmips
d77de738
ML
29633Use (do not use) the MIPS SmartMIPS ASE.
29634
d77de738
ML
29635@opindex mpaired-single
29636@opindex mno-paired-single
ddf6fe37
AA
29637@item -mpaired-single
29638@itemx -mno-paired-single
d77de738
ML
29639Use (do not use) paired-single floating-point instructions.
29640@xref{MIPS Paired-Single Support}. This option requires
29641hardware floating-point support to be enabled.
29642
d77de738
ML
29643@opindex mdmx
29644@opindex mno-mdmx
ddf6fe37
AA
29645@item -mdmx
29646@itemx -mno-mdmx
d77de738
ML
29647Use (do not use) MIPS Digital Media Extension instructions.
29648This option can only be used when generating 64-bit code and requires
29649hardware floating-point support to be enabled.
29650
d77de738
ML
29651@opindex mips3d
29652@opindex mno-mips3d
ddf6fe37
AA
29653@item -mips3d
29654@itemx -mno-mips3d
d77de738
ML
29655Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
29656The option @option{-mips3d} implies @option{-mpaired-single}.
29657
d77de738
ML
29658@opindex mmicromips
29659@opindex mno-mmicromips
ddf6fe37
AA
29660@item -mmicromips
29661@itemx -mno-micromips
d77de738
ML
29662Generate (do not generate) microMIPS code.
29663
29664MicroMIPS code generation can also be controlled on a per-function basis
29665by means of @code{micromips} and @code{nomicromips} attributes.
29666@xref{Function Attributes}, for more information.
29667
d77de738
ML
29668@opindex mmt
29669@opindex mno-mt
ddf6fe37
AA
29670@item -mmt
29671@itemx -mno-mt
d77de738
ML
29672Use (do not use) MT Multithreading instructions.
29673
d77de738
ML
29674@opindex mmcu
29675@opindex mno-mcu
ddf6fe37
AA
29676@item -mmcu
29677@itemx -mno-mcu
d77de738
ML
29678Use (do not use) the MIPS MCU ASE instructions.
29679
d77de738
ML
29680@opindex meva
29681@opindex mno-eva
ddf6fe37
AA
29682@item -meva
29683@itemx -mno-eva
d77de738
ML
29684Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
29685
d77de738
ML
29686@opindex mvirt
29687@opindex mno-virt
ddf6fe37
AA
29688@item -mvirt
29689@itemx -mno-virt
d77de738
ML
29690Use (do not use) the MIPS Virtualization (VZ) instructions.
29691
d77de738
ML
29692@opindex mxpa
29693@opindex mno-xpa
ddf6fe37
AA
29694@item -mxpa
29695@itemx -mno-xpa
d77de738
ML
29696Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
29697
d77de738
ML
29698@opindex mcrc
29699@opindex mno-crc
ddf6fe37
AA
29700@item -mcrc
29701@itemx -mno-crc
d77de738
ML
29702Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
29703
d77de738
ML
29704@opindex mginv
29705@opindex mno-ginv
ddf6fe37
AA
29706@item -mginv
29707@itemx -mno-ginv
d77de738
ML
29708Use (do not use) the MIPS Global INValidate (GINV) instructions.
29709
d77de738
ML
29710@opindex mloongson-mmi
29711@opindex mno-loongson-mmi
ddf6fe37
AA
29712@item -mloongson-mmi
29713@itemx -mno-loongson-mmi
d77de738
ML
29714Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
29715
d77de738
ML
29716@opindex mloongson-ext
29717@opindex mno-loongson-ext
ddf6fe37
AA
29718@item -mloongson-ext
29719@itemx -mno-loongson-ext
d77de738
ML
29720Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
29721
d77de738
ML
29722@opindex mloongson-ext2
29723@opindex mno-loongson-ext2
ddf6fe37
AA
29724@item -mloongson-ext2
29725@itemx -mno-loongson-ext2
d77de738
ML
29726Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
29727
d77de738 29728@opindex mlong64
ddf6fe37 29729@item -mlong64
d77de738
ML
29730Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
29731an explanation of the default and the way that the pointer size is
29732determined.
29733
d77de738 29734@opindex mlong32
ddf6fe37 29735@item -mlong32
d77de738
ML
29736Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
29737
29738The default size of @code{int}s, @code{long}s and pointers depends on
29739the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
29740uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2974132-bit @code{long}s. Pointers are the same size as @code{long}s,
29742or the same size as integer registers, whichever is smaller.
29743
d77de738
ML
29744@opindex msym32
29745@opindex mno-sym32
ddf6fe37
AA
29746@item -msym32
29747@itemx -mno-sym32
d77de738
ML
29748Assume (do not assume) that all symbols have 32-bit values, regardless
29749of the selected ABI@. This option is useful in combination with
29750@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
29751to generate shorter and faster references to symbolic addresses.
29752
d77de738 29753@opindex G
ddf6fe37 29754@item -G @var{num}
d77de738
ML
29755Put definitions of externally-visible data in a small data section
29756if that data is no bigger than @var{num} bytes. GCC can then generate
29757more efficient accesses to the data; see @option{-mgpopt} for details.
29758
29759The default @option{-G} option depends on the configuration.
29760
d77de738
ML
29761@opindex mlocal-sdata
29762@opindex mno-local-sdata
ddf6fe37
AA
29763@item -mlocal-sdata
29764@itemx -mno-local-sdata
d77de738
ML
29765Extend (do not extend) the @option{-G} behavior to local data too,
29766such as to static variables in C@. @option{-mlocal-sdata} is the
29767default for all configurations.
29768
29769If the linker complains that an application is using too much small data,
29770you might want to try rebuilding the less performance-critical parts with
29771@option{-mno-local-sdata}. You might also want to build large
29772libraries with @option{-mno-local-sdata}, so that the libraries leave
29773more room for the main program.
29774
d77de738
ML
29775@opindex mextern-sdata
29776@opindex mno-extern-sdata
ddf6fe37
AA
29777@item -mextern-sdata
29778@itemx -mno-extern-sdata
d77de738
ML
29779Assume (do not assume) that externally-defined data is in
29780a small data section if the size of that data is within the @option{-G} limit.
29781@option{-mextern-sdata} is the default for all configurations.
29782
29783If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
29784@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
29785that is no bigger than @var{num} bytes, you must make sure that @var{Var}
29786is placed in a small data section. If @var{Var} is defined by another
29787module, you must either compile that module with a high-enough
29788@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
29789definition. If @var{Var} is common, you must link the application
29790with a high-enough @option{-G} setting.
29791
29792The easiest way of satisfying these restrictions is to compile
29793and link every module with the same @option{-G} option. However,
29794you may wish to build a library that supports several different
29795small data limits. You can do this by compiling the library with
29796the highest supported @option{-G} setting and additionally using
29797@option{-mno-extern-sdata} to stop the library from making assumptions
29798about externally-defined data.
29799
d77de738
ML
29800@opindex mgpopt
29801@opindex mno-gpopt
ddf6fe37
AA
29802@item -mgpopt
29803@itemx -mno-gpopt
d77de738
ML
29804Use (do not use) GP-relative accesses for symbols that are known to be
29805in a small data section; see @option{-G}, @option{-mlocal-sdata} and
29806@option{-mextern-sdata}. @option{-mgpopt} is the default for all
29807configurations.
29808
29809@option{-mno-gpopt} is useful for cases where the @code{$gp} register
29810might not hold the value of @code{_gp}. For example, if the code is
29811part of a library that might be used in a boot monitor, programs that
29812call boot monitor routines pass an unknown value in @code{$gp}.
29813(In such situations, the boot monitor itself is usually compiled
29814with @option{-G0}.)
29815
29816@option{-mno-gpopt} implies @option{-mno-local-sdata} and
29817@option{-mno-extern-sdata}.
29818
d77de738
ML
29819@opindex membedded-data
29820@opindex mno-embedded-data
ddf6fe37
AA
29821@item -membedded-data
29822@itemx -mno-embedded-data
d77de738
ML
29823Allocate variables to the read-only data section first if possible, then
29824next in the small data section if possible, otherwise in data. This gives
29825slightly slower code than the default, but reduces the amount of RAM required
29826when executing, and thus may be preferred for some embedded systems.
29827
d77de738
ML
29828@opindex muninit-const-in-rodata
29829@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
29830@item -muninit-const-in-rodata
29831@itemx -mno-uninit-const-in-rodata
d77de738
ML
29832Put uninitialized @code{const} variables in the read-only data section.
29833This option is only meaningful in conjunction with @option{-membedded-data}.
29834
d77de738 29835@opindex mcode-readable
ddf6fe37 29836@item -mcode-readable=@var{setting}
d77de738
ML
29837Specify whether GCC may generate code that reads from executable sections.
29838There are three possible settings:
29839
29840@table @gcctabopt
29841@item -mcode-readable=yes
29842Instructions may freely access executable sections. This is the
29843default setting.
29844
29845@item -mcode-readable=pcrel
29846MIPS16 PC-relative load instructions can access executable sections,
29847but other instructions must not do so. This option is useful on 4KSc
29848and 4KSd processors when the code TLBs have the Read Inhibit bit set.
29849It is also useful on processors that can be configured to have a dual
29850instruction/data SRAM interface and that, like the M4K, automatically
29851redirect PC-relative loads to the instruction RAM.
29852
29853@item -mcode-readable=no
29854Instructions must not access executable sections. This option can be
29855useful on targets that are configured to have a dual instruction/data
29856SRAM interface but that (unlike the M4K) do not automatically redirect
29857PC-relative loads to the instruction RAM.
29858@end table
29859
d77de738
ML
29860@opindex msplit-addresses
29861@opindex mno-split-addresses
ddf6fe37
AA
29862@item -msplit-addresses
29863@itemx -mno-split-addresses
d77de738
ML
29864Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
29865relocation operators. This option has been superseded by
29866@option{-mexplicit-relocs} but is retained for backwards compatibility.
29867
00bc8c09
YS
29868@opindex mexplicit-relocs
29869@opindex mno-explicit-relocs
46df1369
YS
29870@item -mexplicit-relocs=none
29871@itemx -mexplicit-relocs=base
29872@itemx -mexplicit-relocs=pcrel
29873@itemx -mexplicit-relocs
ddf6fe37 29874@itemx -mno-explicit-relocs
b9857b78 29875These options control whether explicit relocs (such as @code{%gp_rel}) are used.
46df1369 29876The default value depends on the version of GAS when GCC itself was built.
d77de738 29877
b9857b78
SL
29878The @code{base} explicit-relocs support was introduced into GAS in 2001.
29879The @code{pcrel} explicit-relocs support was introduced into GAS in 2014,
46df1369 29880which supports @code{%pcrel_hi} and @code{%pcrel_lo}.
d77de738 29881
d77de738
ML
29882@opindex mcheck-zero-division
29883@opindex mno-check-zero-division
ddf6fe37
AA
29884@item -mcheck-zero-division
29885@itemx -mno-check-zero-division
d77de738
ML
29886Trap (do not trap) on integer division by zero.
29887
29888The default is @option{-mcheck-zero-division}.
29889
d77de738
ML
29890@opindex mdivide-traps
29891@opindex mdivide-breaks
ddf6fe37
AA
29892@item -mdivide-traps
29893@itemx -mdivide-breaks
d77de738
ML
29894MIPS systems check for division by zero by generating either a
29895conditional trap or a break instruction. Using traps results in
29896smaller code, but is only supported on MIPS II and later. Also, some
29897versions of the Linux kernel have a bug that prevents trap from
29898generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
29899allow conditional traps on architectures that support them and
29900@option{-mdivide-breaks} to force the use of breaks.
29901
29902The default is usually @option{-mdivide-traps}, but this can be
29903overridden at configure time using @option{--with-divide=breaks}.
29904Divide-by-zero checks can be completely disabled using
29905@option{-mno-check-zero-division}.
29906
d77de738
ML
29907@opindex mload-store-pairs
29908@opindex mno-load-store-pairs
ddf6fe37
AA
29909@item -mload-store-pairs
29910@itemx -mno-load-store-pairs
d77de738
ML
29911Enable (disable) an optimization that pairs consecutive load or store
29912instructions to enable load/store bonding. This option is enabled by
29913default but only takes effect when the selected architecture is known
29914to support bonding.
29915
acc38ff5
YS
29916@opindex mstrict-align
29917@opindex mno-strict-align
d77de738
ML
29918@opindex munaligned-access
29919@opindex mno-unaligned-access
acc38ff5
YS
29920@item -mstrict-align
29921@itemx -mno-strict-align
29922@itemx -munaligned-access
ddf6fe37 29923@itemx -mno-unaligned-access
acc38ff5
YS
29924Disable (enable) direct unaligned access for MIPS Release 6.
29925MIPSr6 requires load/store unaligned-access support, by hardware or
29926trap&emulate. So @option{-mstrict-align} may be needed by kernel. The
29927options @option{-munaligned-access} and @option{-mno-unaligned-access}
29928are obsoleted, and only for backward-compatible.
d77de738 29929
d77de738
ML
29930@opindex mmemcpy
29931@opindex mno-memcpy
ddf6fe37
AA
29932@item -mmemcpy
29933@itemx -mno-memcpy
d77de738
ML
29934Force (do not force) the use of @code{memcpy} for non-trivial block
29935moves. The default is @option{-mno-memcpy}, which allows GCC to inline
29936most constant-sized copies.
29937
d77de738
ML
29938@opindex mlong-calls
29939@opindex mno-long-calls
ddf6fe37
AA
29940@item -mlong-calls
29941@itemx -mno-long-calls
d77de738
ML
29942Disable (do not disable) use of the @code{jal} instruction. Calling
29943functions using @code{jal} is more efficient but requires the caller
29944and callee to be in the same 256 megabyte segment.
29945
29946This option has no effect on abicalls code. The default is
29947@option{-mno-long-calls}.
29948
d77de738
ML
29949@opindex mmad
29950@opindex mno-mad
ddf6fe37
AA
29951@item -mmad
29952@itemx -mno-mad
d77de738
ML
29953Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
29954instructions, as provided by the R4650 ISA@.
29955
d77de738
ML
29956@opindex mimadd
29957@opindex mno-imadd
ddf6fe37
AA
29958@item -mimadd
29959@itemx -mno-imadd
d77de738
ML
29960Enable (disable) use of the @code{madd} and @code{msub} integer
29961instructions. The default is @option{-mimadd} on architectures
a0e64a04 29962that support @code{madd} and @code{msub} except for the 74k
d77de738
ML
29963architecture where it was found to generate slower code.
29964
d77de738
ML
29965@opindex mfused-madd
29966@opindex mno-fused-madd
ddf6fe37
AA
29967@item -mfused-madd
29968@itemx -mno-fused-madd
d77de738
ML
29969Enable (disable) use of the floating-point multiply-accumulate
29970instructions, when they are available. The default is
29971@option{-mfused-madd}.
29972
29973On the R8000 CPU when multiply-accumulate instructions are used,
29974the intermediate product is calculated to infinite precision
29975and is not subject to the FCSR Flush to Zero bit. This may be
29976undesirable in some circumstances. On other processors the result
29977is numerically identical to the equivalent computation using
29978separate multiply, add, subtract and negate instructions.
29979
d77de738 29980@opindex nocpp
ddf6fe37 29981@item -nocpp
d77de738
ML
29982Tell the MIPS assembler to not run its preprocessor over user
29983assembler files (with a @samp{.s} suffix) when assembling them.
29984
d77de738
ML
29985@opindex mfix-24k
29986@opindex mno-fix-24k
ddf6fe37
AA
29987@item -mfix-24k
29988@itemx -mno-fix-24k
d77de738
ML
29989Work around the 24K E48 (lost data on stores during refill) errata.
29990The workarounds are implemented by the assembler rather than by GCC@.
29991
d77de738
ML
29992@opindex mfix-r4000
29993@opindex mno-fix-r4000
ddf6fe37
AA
29994@item -mfix-r4000
29995@itemx -mno-fix-r4000
d77de738
ML
29996Work around certain R4000 CPU errata:
29997@itemize @minus
29998@item
29999A double-word or a variable shift may give an incorrect result if executed
30000immediately after starting an integer division.
30001@item
30002A double-word or a variable shift may give an incorrect result if executed
30003while an integer multiplication is in progress.
30004@item
30005An integer division may give an incorrect result if started in a delay slot
30006of a taken branch or a jump.
30007@end itemize
30008
d77de738
ML
30009@opindex mfix-r4400
30010@opindex mno-fix-r4400
ddf6fe37
AA
30011@item -mfix-r4400
30012@itemx -mno-fix-r4400
d77de738
ML
30013Work around certain R4400 CPU errata:
30014@itemize @minus
30015@item
30016A double-word or a variable shift may give an incorrect result if executed
30017immediately after starting an integer division.
30018@end itemize
30019
d77de738
ML
30020@opindex mfix-r10000
30021@opindex mno-fix-r10000
ddf6fe37
AA
30022@item -mfix-r10000
30023@itemx -mno-fix-r10000
d77de738
ML
30024Work around certain R10000 errata:
30025@itemize @minus
30026@item
30027@code{ll}/@code{sc} sequences may not behave atomically on revisions
30028prior to 3.0. They may deadlock on revisions 2.6 and earlier.
30029@end itemize
30030
30031This option can only be used if the target architecture supports
30032branch-likely instructions. @option{-mfix-r10000} is the default when
30033@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
30034otherwise.
30035
ddf6fe37 30036@opindex mfix-r5900
d77de738
ML
30037@item -mfix-r5900
30038@itemx -mno-fix-r5900
d77de738
ML
30039Do not attempt to schedule the preceding instruction into the delay slot
30040of a branch instruction placed at the end of a short loop of six
30041instructions or fewer and always schedule a @code{nop} instruction there
30042instead. The short loop bug under certain conditions causes loops to
30043execute only once or twice, due to a hardware bug in the R5900 chip. The
30044workaround is implemented by the assembler rather than by GCC@.
30045
ddf6fe37 30046@opindex mfix-rm7000
d77de738
ML
30047@item -mfix-rm7000
30048@itemx -mno-fix-rm7000
d77de738
ML
30049Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
30050workarounds are implemented by the assembler rather than by GCC@.
30051
ddf6fe37 30052@opindex mfix-vr4120
d77de738
ML
30053@item -mfix-vr4120
30054@itemx -mno-fix-vr4120
d77de738
ML
30055Work around certain VR4120 errata:
30056@itemize @minus
30057@item
30058@code{dmultu} does not always produce the correct result.
30059@item
30060@code{div} and @code{ddiv} do not always produce the correct result if one
30061of the operands is negative.
30062@end itemize
30063The workarounds for the division errata rely on special functions in
30064@file{libgcc.a}. At present, these functions are only provided by
30065the @code{mips64vr*-elf} configurations.
30066
30067Other VR4120 errata require a NOP to be inserted between certain pairs of
30068instructions. These errata are handled by the assembler, not by GCC itself.
30069
d77de738 30070@opindex mfix-vr4130
ddf6fe37 30071@item -mfix-vr4130
d77de738
ML
30072Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
30073workarounds are implemented by the assembler rather than by GCC,
30074although GCC avoids using @code{mflo} and @code{mfhi} if the
30075VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
30076instructions are available instead.
30077
ddf6fe37 30078@opindex mfix-sb1
d77de738
ML
30079@item -mfix-sb1
30080@itemx -mno-fix-sb1
d77de738
ML
30081Work around certain SB-1 CPU core errata.
30082(This flag currently works around the SB-1 revision 2
30083``F1'' and ``F2'' floating-point errata.)
30084
d77de738 30085@opindex mr10k-cache-barrier
ddf6fe37 30086@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
30087Specify whether GCC should insert cache barriers to avoid the
30088side effects of speculation on R10K processors.
30089
30090In common with many processors, the R10K tries to predict the outcome
30091of a conditional branch and speculatively executes instructions from
30092the ``taken'' branch. It later aborts these instructions if the
30093predicted outcome is wrong. However, on the R10K, even aborted
30094instructions can have side effects.
30095
30096This problem only affects kernel stores and, depending on the system,
30097kernel loads. As an example, a speculatively-executed store may load
30098the target memory into cache and mark the cache line as dirty, even if
30099the store itself is later aborted. If a DMA operation writes to the
30100same area of memory before the ``dirty'' line is flushed, the cached
30101data overwrites the DMA-ed data. See the R10K processor manual
30102for a full description, including other potential problems.
30103
30104One workaround is to insert cache barrier instructions before every memory
30105access that might be speculatively executed and that might have side
30106effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
30107controls GCC's implementation of this workaround. It assumes that
30108aborted accesses to any byte in the following regions does not have
30109side effects:
30110
30111@enumerate
30112@item
30113the memory occupied by the current function's stack frame;
30114
30115@item
30116the memory occupied by an incoming stack argument;
30117
30118@item
30119the memory occupied by an object with a link-time-constant address.
30120@end enumerate
30121
30122It is the kernel's responsibility to ensure that speculative
30123accesses to these regions are indeed safe.
30124
30125If the input program contains a function declaration such as:
30126
30127@smallexample
30128void foo (void);
30129@end smallexample
30130
30131then the implementation of @code{foo} must allow @code{j foo} and
30132@code{jal foo} to be executed speculatively. GCC honors this
30133restriction for functions it compiles itself. It expects non-GCC
30134functions (such as hand-written assembly code) to do the same.
30135
30136The option has three forms:
30137
30138@table @gcctabopt
30139@item -mr10k-cache-barrier=load-store
30140Insert a cache barrier before a load or store that might be
30141speculatively executed and that might have side effects even
30142if aborted.
30143
30144@item -mr10k-cache-barrier=store
30145Insert a cache barrier before a store that might be speculatively
30146executed and that might have side effects even if aborted.
30147
30148@item -mr10k-cache-barrier=none
30149Disable the insertion of cache barriers. This is the default setting.
30150@end table
30151
ddf6fe37 30152@opindex mflush-func
00bc8c09 30153@opindex mno-flush-func
d77de738
ML
30154@item -mflush-func=@var{func}
30155@itemx -mno-flush-func
d77de738
ML
30156Specifies the function to call to flush the I and D caches, or to not
30157call any such function. If called, the function must take the same
30158arguments as the common @code{_flush_func}, that is, the address of the
30159memory range for which the cache is being flushed, the size of the
30160memory range, and the number 3 (to flush both caches). The default
30161depends on the target GCC was configured for, but commonly is either
30162@code{_flush_func} or @code{__cpu_flush}.
30163
d77de738 30164@opindex mbranch-cost
00bc8c09 30165@item -mbranch-cost=@var{num}
d77de738
ML
30166Set the cost of branches to roughly @var{num} ``simple'' instructions.
30167This cost is only a heuristic and is not guaranteed to produce
30168consistent results across releases. A zero cost redundantly selects
30169the default, which is based on the @option{-mtune} setting.
30170
d77de738
ML
30171@opindex mbranch-likely
30172@opindex mno-branch-likely
ddf6fe37
AA
30173@item -mbranch-likely
30174@itemx -mno-branch-likely
d77de738
ML
30175Enable or disable use of Branch Likely instructions, regardless of the
30176default for the selected architecture. By default, Branch Likely
30177instructions may be generated if they are supported by the selected
30178architecture. An exception is for the MIPS32 and MIPS64 architectures
30179and processors that implement those architectures; for those, Branch
30180Likely instructions are not be generated by default because the MIPS32
30181and MIPS64 architectures specifically deprecate their use.
30182
d77de738
ML
30183@opindex mcompact-branches=never
30184@opindex mcompact-branches=optimal
30185@opindex mcompact-branches=always
ddf6fe37
AA
30186@item -mcompact-branches=never
30187@itemx -mcompact-branches=optimal
30188@itemx -mcompact-branches=always
d77de738
ML
30189These options control which form of branches will be generated. The
30190default is @option{-mcompact-branches=optimal}.
30191
30192The @option{-mcompact-branches=never} option ensures that compact branch
30193instructions will never be generated.
30194
30195The @option{-mcompact-branches=always} option ensures that a compact
30196branch instruction will be generated if available for MIPS Release 6 onwards.
30197If a compact branch instruction is not available (or pre-R6),
30198a delay slot form of the branch will be used instead.
30199
30200If it is used for MIPS16/microMIPS targets, it will be just ignored now.
b9857b78 30201The behavior for MIPS16/microMIPS may change in future,
d77de738
ML
30202since they do have some compact branch instructions.
30203
30204The @option{-mcompact-branches=optimal} option will cause a delay slot
30205branch to be used if one is available in the current ISA and the delay
30206slot is successfully filled. If the delay slot is not filled, a compact
30207branch will be chosen if one is available.
30208
ddf6fe37 30209@opindex mfp-exceptions
d77de738
ML
30210@item -mfp-exceptions
30211@itemx -mno-fp-exceptions
d77de738
ML
30212Specifies whether FP exceptions are enabled. This affects how
30213FP instructions are scheduled for some processors.
30214The default is that FP exceptions are
30215enabled.
30216
30217For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
3021864-bit code, then we can use both FP pipes. Otherwise, we can only use one
30219FP pipe.
30220
ddf6fe37 30221@opindex mvr4130-align
d77de738
ML
30222@item -mvr4130-align
30223@itemx -mno-vr4130-align
d77de738
ML
30224The VR4130 pipeline is two-way superscalar, but can only issue two
30225instructions together if the first one is 8-byte aligned. When this
30226option is enabled, GCC aligns pairs of instructions that it
30227thinks should execute in parallel.
30228
30229This option only has an effect when optimizing for the VR4130.
30230It normally makes code faster, but at the expense of making it bigger.
30231It is enabled by default at optimization level @option{-O3}.
30232
ddf6fe37 30233@opindex msynci
d77de738
ML
30234@item -msynci
30235@itemx -mno-synci
d77de738
ML
30236Enable (disable) generation of @code{synci} instructions on
30237architectures that support it. The @code{synci} instructions (if
30238enabled) are generated when @code{__builtin___clear_cache} is
30239compiled.
30240
30241This option defaults to @option{-mno-synci}, but the default can be
30242overridden by configuring GCC with @option{--with-synci}.
30243
30244When compiling code for single processor systems, it is generally safe
30245to use @code{synci}. However, on many multi-core (SMP) systems, it
30246does not invalidate the instruction caches on all cores and may lead
30247to undefined behavior.
30248
ddf6fe37 30249@opindex mrelax-pic-calls
d77de738
ML
30250@item -mrelax-pic-calls
30251@itemx -mno-relax-pic-calls
d77de738
ML
30252Try to turn PIC calls that are normally dispatched via register
30253@code{$25} into direct calls. This is only possible if the linker can
30254resolve the destination at link time and if the destination is within
30255range for a direct call.
30256
30257@option{-mrelax-pic-calls} is the default if GCC was configured to use
30258an assembler and a linker that support the @code{.reloc} assembly
30259directive and @option{-mexplicit-relocs} is in effect. With
30260@option{-mno-explicit-relocs}, this optimization can be performed by the
30261assembler and the linker alone without help from the compiler.
30262
d77de738
ML
30263@opindex mmcount-ra-address
30264@opindex mno-mcount-ra-address
ddf6fe37
AA
30265@item -mmcount-ra-address
30266@itemx -mno-mcount-ra-address
d77de738
ML
30267Emit (do not emit) code that allows @code{_mcount} to modify the
30268calling function's return address. When enabled, this option extends
30269the usual @code{_mcount} interface with a new @var{ra-address}
30270parameter, which has type @code{intptr_t *} and is passed in register
30271@code{$12}. @code{_mcount} can then modify the return address by
30272doing both of the following:
30273@itemize
30274@item
30275Returning the new address in register @code{$31}.
30276@item
30277Storing the new address in @code{*@var{ra-address}},
30278if @var{ra-address} is nonnull.
30279@end itemize
30280
30281The default is @option{-mno-mcount-ra-address}.
30282
ddf6fe37 30283@opindex mframe-header-opt
d77de738
ML
30284@item -mframe-header-opt
30285@itemx -mno-frame-header-opt
d77de738
ML
30286Enable (disable) frame header optimization in the o32 ABI. When using the
30287o32 ABI, calling functions will allocate 16 bytes on the stack for the called
30288function to write out register arguments. When enabled, this optimization
30289will suppress the allocation of the frame header if it can be determined that
30290it is unused.
30291
30292This optimization is off by default at all optimization levels.
30293
ddf6fe37 30294@opindex mlxc1-sxc1
d77de738
ML
30295@item -mlxc1-sxc1
30296@itemx -mno-lxc1-sxc1
d77de738
ML
30297When applicable, enable (disable) the generation of @code{lwxc1},
30298@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
30299
ddf6fe37 30300@opindex mmadd4
d77de738
ML
30301@item -mmadd4
30302@itemx -mno-madd4
d77de738
ML
30303When applicable, enable (disable) the generation of 4-operand @code{madd.s},
30304@code{madd.d} and related instructions. Enabled by default.
30305
30306@end table
30307
30308@node MMIX Options
30309@subsection MMIX Options
30310@cindex MMIX Options
30311
30312These options are defined for the MMIX:
30313
30314@table @gcctabopt
d77de738
ML
30315@opindex mlibfuncs
30316@opindex mno-libfuncs
ddf6fe37
AA
30317@item -mlibfuncs
30318@itemx -mno-libfuncs
d77de738
ML
30319Specify that intrinsic library functions are being compiled, passing all
30320values in registers, no matter the size.
30321
d77de738
ML
30322@opindex mepsilon
30323@opindex mno-epsilon
ddf6fe37
AA
30324@item -mepsilon
30325@itemx -mno-epsilon
d77de738
ML
30326Generate floating-point comparison instructions that compare with respect
30327to the @code{rE} epsilon register.
30328
d77de738
ML
30329@opindex mabi=mmixware
30330@opindex mabi=gnu
ddf6fe37
AA
30331@item -mabi=mmixware
30332@itemx -mabi=gnu
d77de738
ML
30333Generate code that passes function parameters and return values that (in
30334the called function) are seen as registers @code{$0} and up, as opposed to
30335the GNU ABI which uses global registers @code{$231} and up.
30336
d77de738
ML
30337@opindex mzero-extend
30338@opindex mno-zero-extend
ddf6fe37
AA
30339@item -mzero-extend
30340@itemx -mno-zero-extend
d77de738
ML
30341When reading data from memory in sizes shorter than 64 bits, use (do not
30342use) zero-extending load instructions by default, rather than
30343sign-extending ones.
30344
d77de738
ML
30345@opindex mknuthdiv
30346@opindex mno-knuthdiv
ddf6fe37
AA
30347@item -mknuthdiv
30348@itemx -mno-knuthdiv
d77de738
ML
30349Make the result of a division yielding a remainder have the same sign as
30350the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
30351remainder follows the sign of the dividend. Both methods are
30352arithmetically valid, the latter being almost exclusively used.
30353
d77de738
ML
30354@opindex mtoplevel-symbols
30355@opindex mno-toplevel-symbols
ddf6fe37
AA
30356@item -mtoplevel-symbols
30357@itemx -mno-toplevel-symbols
d77de738
ML
30358Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
30359code can be used with the @code{PREFIX} assembly directive.
30360
d77de738 30361@opindex melf
ddf6fe37 30362@item -melf
d77de738
ML
30363Generate an executable in the ELF format, rather than the default
30364@samp{mmo} format used by the @command{mmix} simulator.
30365
d77de738
ML
30366@opindex mbranch-predict
30367@opindex mno-branch-predict
ddf6fe37
AA
30368@item -mbranch-predict
30369@itemx -mno-branch-predict
d77de738
ML
30370Use (do not use) the probable-branch instructions, when static branch
30371prediction indicates a probable branch.
30372
d77de738
ML
30373@opindex mbase-addresses
30374@opindex mno-base-addresses
ddf6fe37
AA
30375@item -mbase-addresses
30376@itemx -mno-base-addresses
d77de738
ML
30377Generate (do not generate) code that uses @emph{base addresses}. Using a
30378base address automatically generates a request (handled by the assembler
30379and the linker) for a constant to be set up in a global register. The
30380register is used for one or more base address requests within the range 0
30381to 255 from the value held in the register. The generally leads to short
30382and fast code, but the number of different data items that can be
30383addressed is limited. This means that a program that uses lots of static
30384data may require @option{-mno-base-addresses}.
30385
d77de738
ML
30386@opindex msingle-exit
30387@opindex mno-single-exit
ddf6fe37
AA
30388@item -msingle-exit
30389@itemx -mno-single-exit
d77de738
ML
30390Force (do not force) generated code to have a single exit point in each
30391function.
30392@end table
30393
30394@node MN10300 Options
30395@subsection MN10300 Options
30396@cindex MN10300 options
30397
30398These @option{-m} options are defined for Matsushita MN10300 architectures:
30399
30400@table @gcctabopt
d77de738 30401@opindex mmult-bug
ddf6fe37 30402@item -mmult-bug
d77de738
ML
30403Generate code to avoid bugs in the multiply instructions for the MN10300
30404processors. This is the default.
30405
d77de738 30406@opindex mno-mult-bug
ddf6fe37 30407@item -mno-mult-bug
d77de738
ML
30408Do not generate code to avoid bugs in the multiply instructions for the
30409MN10300 processors.
30410
d77de738 30411@opindex mam33
ddf6fe37 30412@item -mam33
d77de738
ML
30413Generate code using features specific to the AM33 processor.
30414
d77de738 30415@opindex mno-am33
ddf6fe37 30416@item -mno-am33
d77de738
ML
30417Do not generate code using features specific to the AM33 processor. This
30418is the default.
30419
d77de738 30420@opindex mam33-2
ddf6fe37 30421@item -mam33-2
d77de738
ML
30422Generate code using features specific to the AM33/2.0 processor.
30423
d77de738 30424@opindex mam34
ddf6fe37 30425@item -mam34
d77de738
ML
30426Generate code using features specific to the AM34 processor.
30427
d77de738 30428@opindex mtune
ddf6fe37 30429@item -mtune=@var{cpu-type}
d77de738
ML
30430Use the timing characteristics of the indicated CPU type when
30431scheduling instructions. This does not change the targeted processor
30432type. The CPU type must be one of @samp{mn10300}, @samp{am33},
30433@samp{am33-2} or @samp{am34}.
30434
d77de738 30435@opindex mreturn-pointer-on-d0
ddf6fe37 30436@item -mreturn-pointer-on-d0
d77de738
ML
30437When generating a function that returns a pointer, return the pointer
30438in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
30439only in @code{a0}, and attempts to call such functions without a prototype
30440result in errors. Note that this option is on by default; use
30441@option{-mno-return-pointer-on-d0} to disable it.
30442
d77de738 30443@opindex mno-crt0
ddf6fe37 30444@item -mno-crt0
d77de738
ML
30445Do not link in the C run-time initialization object file.
30446
d77de738 30447@opindex mrelax
ddf6fe37 30448@item -mrelax
d77de738
ML
30449Indicate to the linker that it should perform a relaxation optimization pass
30450to shorten branches, calls and absolute memory addresses. This option only
30451has an effect when used on the command line for the final link step.
30452
30453This option makes symbolic debugging impossible.
30454
d77de738 30455@opindex mliw
ddf6fe37 30456@item -mliw
d77de738
ML
30457Allow the compiler to generate @emph{Long Instruction Word}
30458instructions if the target is the @samp{AM33} or later. This is the
30459default. This option defines the preprocessor macro @code{__LIW__}.
30460
d77de738 30461@opindex mno-liw
ddf6fe37 30462@item -mno-liw
d77de738
ML
30463Do not allow the compiler to generate @emph{Long Instruction Word}
30464instructions. This option defines the preprocessor macro
30465@code{__NO_LIW__}.
30466
d77de738 30467@opindex msetlb
ddf6fe37 30468@item -msetlb
d77de738
ML
30469Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
30470instructions if the target is the @samp{AM33} or later. This is the
30471default. This option defines the preprocessor macro @code{__SETLB__}.
30472
d77de738 30473@opindex mno-setlb
ddf6fe37 30474@item -mno-setlb
d77de738
ML
30475Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
30476instructions. This option defines the preprocessor macro
30477@code{__NO_SETLB__}.
30478
30479@end table
30480
30481@node Moxie Options
30482@subsection Moxie Options
30483@cindex Moxie Options
30484
30485@table @gcctabopt
30486
d77de738 30487@opindex meb
ddf6fe37 30488@item -meb
d77de738
ML
30489Generate big-endian code. This is the default for @samp{moxie-*-*}
30490configurations.
30491
d77de738 30492@opindex mel
ddf6fe37 30493@item -mel
d77de738
ML
30494Generate little-endian code.
30495
d77de738 30496@opindex mmul.x
ddf6fe37 30497@item -mmul.x
d77de738
ML
30498Generate mul.x and umul.x instructions. This is the default for
30499@samp{moxiebox-*-*} configurations.
30500
d77de738 30501@opindex mno-crt0
ddf6fe37 30502@item -mno-crt0
d77de738
ML
30503Do not link in the C run-time initialization object file.
30504
30505@end table
30506
30507@node MSP430 Options
30508@subsection MSP430 Options
30509@cindex MSP430 Options
30510
30511These options are defined for the MSP430:
30512
30513@table @gcctabopt
30514
d77de738 30515@opindex masm-hex
ddf6fe37 30516@item -masm-hex
d77de738
ML
30517Force assembly output to always use hex constants. Normally such
30518constants are signed decimals, but this option is available for
30519testsuite and/or aesthetic purposes.
30520
d77de738 30521@opindex mmcu=
ddf6fe37 30522@item -mmcu=
d77de738
ML
30523Select the MCU to target. This is used to create a C preprocessor
30524symbol based upon the MCU name, converted to upper case and pre- and
30525post-fixed with @samp{__}. This in turn is used by the
30526@file{msp430.h} header file to select an MCU-specific supplementary
30527header file.
30528
30529The option also sets the ISA to use. If the MCU name is one that is
30530known to only support the 430 ISA then that is selected, otherwise the
30531430X ISA is selected. A generic MCU name of @samp{msp430} can also be
30532used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
30533name selects the 430X ISA.
30534
30535In addition an MCU-specific linker script is added to the linker
30536command line. The script's name is the name of the MCU with
30537@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
30538command line defines the C preprocessor symbol @code{__XXX__} and
30539cause the linker to search for a script called @file{xxx.ld}.
30540
30541The ISA and hardware multiply supported for the different MCUs is hard-coded
30542into GCC. However, an external @samp{devices.csv} file can be used to
30543extend device support beyond those that have been hard-coded.
30544
30545GCC searches for the @samp{devices.csv} file using the following methods in the
b9857b78 30546given precedence order, where the first method takes precedence over the
d77de738
ML
30547second which takes precedence over the third.
30548
30549@table @asis
30550@item Include path specified with @code{-I} and @code{-L}
b9857b78 30551@samp{devices.csv} is searched for in each of the directories specified by
d77de738
ML
30552include paths and linker library search paths.
30553@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
30554Define the value of the global environment variable
30555@samp{MSP430_GCC_INCLUDE_DIR}
30556to the full path to the directory containing devices.csv, and GCC will search
b9857b78
SL
30557this directory for devices.csv. If devices.csv is found, this directory is
30558also registered as an include path and linker library path. Header files
d77de738
ML
30559and linker scripts in this directory can therefore be used without manually
30560specifying @code{-I} and @code{-L} on the command line.
30561@item The @samp{msp430-elf@{,bare@}/include/devices} directory
b9857b78 30562Finally, GCC examines @samp{msp430-elf@{,bare@}/include/devices} from the
d77de738
ML
30563toolchain root directory. This directory does not exist in a default
30564installation, but if the user has created it and copied @samp{devices.csv}
b9857b78
SL
30565there, then the MCU data is read. As above, this directory is
30566also registered as an include path and linker library path.
d77de738
ML
30567
30568@end table
30569If none of the above search methods find @samp{devices.csv}, then the
30570hard-coded MCU data is used.
30571
30572
d77de738
ML
30573@opindex mwarn-mcu
30574@opindex mno-warn-mcu
ddf6fe37
AA
30575@item -mwarn-mcu
30576@itemx -mno-warn-mcu
d77de738
ML
30577This option enables or disables warnings about conflicts between the
30578MCU name specified by the @option{-mmcu} option and the ISA set by the
30579@option{-mcpu} option and/or the hardware multiply support set by the
30580@option{-mhwmult} option. It also toggles warnings about unrecognized
30581MCU names. This option is on by default.
30582
d77de738 30583@opindex mcpu=
ddf6fe37 30584@item -mcpu=
d77de738
ML
30585Specifies the ISA to use. Accepted values are @samp{msp430},
30586@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
30587@option{-mmcu=} option should be used to select the ISA.
30588
d77de738 30589@opindex msim
ddf6fe37 30590@item -msim
d77de738
ML
30591Link to the simulator runtime libraries and linker script. Overrides
30592any scripts that would be selected by the @option{-mmcu=} option.
30593
d77de738 30594@opindex mlarge
ddf6fe37 30595@item -mlarge
d77de738
ML
30596Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
30597
d77de738 30598@opindex msmall
ddf6fe37 30599@item -msmall
d77de738
ML
30600Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
30601
d77de738 30602@opindex mrelax
ddf6fe37 30603@item -mrelax
d77de738
ML
30604This option is passed to the assembler and linker, and allows the
30605linker to perform certain optimizations that cannot be done until
30606the final link.
30607
d77de738 30608@opindex mhwmult=
ddf6fe37 30609@item mhwmult=
d77de738
ML
30610Describes the type of hardware multiply supported by the target.
30611Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
30612for the original 16-bit-only multiply supported by early MCUs.
30613@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
30614@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
30615A value of @samp{auto} can also be given. This tells GCC to deduce
30616the hardware multiply support based upon the MCU name provided by the
30617@option{-mmcu} option. If no @option{-mmcu} option is specified or if
30618the MCU name is not recognized then no hardware multiply support is
30619assumed. @code{auto} is the default setting.
30620
30621Hardware multiplies are normally performed by calling a library
30622routine. This saves space in the generated code. When compiling at
30623@option{-O3} or higher however the hardware multiplier is invoked
30624inline. This makes for bigger, but faster code.
30625
30626The hardware multiply routines disable interrupts whilst running and
30627restore the previous interrupt state when they finish. This makes
30628them safe to use inside interrupt handlers as well as in normal code.
30629
d77de738 30630@opindex minrt
ddf6fe37 30631@item -minrt
d77de738
ML
30632Enable the use of a minimum runtime environment - no static
30633initializers or constructors. This is intended for memory-constrained
30634devices. The compiler includes special symbols in some objects
30635that tell the linker and runtime which code fragments are required.
30636
d77de738 30637@opindex mtiny-printf
ddf6fe37 30638@item -mtiny-printf
d77de738
ML
30639Enable reduced code size @code{printf} and @code{puts} library functions.
30640The @samp{tiny} implementations of these functions are not reentrant, so
30641must be used with caution in multi-threaded applications.
30642
30643Support for streams has been removed and the string to be printed will
30644always be sent to stdout via the @code{write} syscall. The string is not
30645buffered before it is sent to write.
30646
30647This option requires Newlib Nano IO, so GCC must be configured with
30648@samp{--enable-newlib-nano-formatted-io}.
30649
d77de738 30650@opindex mmax-inline-shift=
ddf6fe37 30651@item -mmax-inline-shift=
d77de738
ML
30652This option takes an integer between 0 and 64 inclusive, and sets
30653the maximum number of inline shift instructions which should be emitted to
30654perform a shift operation by a constant amount. When this value needs to be
30655exceeded, an mspabi helper function is used instead. The default value is 4.
30656
30657This only affects cases where a shift by multiple positions cannot be
30658completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
30659
30660Shifts of a 32-bit value are at least twice as costly, so the value passed for
30661this option is divided by 2 and the resulting value used instead.
30662
d77de738
ML
30663@opindex mcode-region
30664@opindex mdata-region
ddf6fe37
AA
30665@item -mcode-region=
30666@itemx -mdata-region=
d77de738
ML
30667These options tell the compiler where to place functions and data that
30668do not have one of the @code{lower}, @code{upper}, @code{either} or
30669@code{section} attributes. Possible values are @code{lower},
30670@code{upper}, @code{either} or @code{any}. The first three behave
30671like the corresponding attribute. The fourth possible value -
30672@code{any} - is the default. It leaves placement entirely up to the
30673linker script and how it assigns the standard sections
30674(@code{.text}, @code{.data}, etc) to the memory regions.
30675
d77de738 30676@opindex msilicon-errata
ddf6fe37 30677@item -msilicon-errata=
d77de738
ML
30678This option passes on a request to assembler to enable the fixes for
30679the named silicon errata.
30680
d77de738 30681@opindex msilicon-errata-warn
ddf6fe37 30682@item -msilicon-errata-warn=
d77de738
ML
30683This option passes on a request to the assembler to enable warning
30684messages when a silicon errata might need to be applied.
30685
d77de738
ML
30686@opindex mwarn-devices-csv
30687@opindex mno-warn-devices-csv
ddf6fe37
AA
30688@item -mwarn-devices-csv
30689@itemx -mno-warn-devices-csv
d77de738
ML
30690Warn if @samp{devices.csv} is not found or there are problem parsing it
30691(default: on).
30692
30693@end table
30694
30695@node NDS32 Options
30696@subsection NDS32 Options
30697@cindex NDS32 Options
30698
30699These options are defined for NDS32 implementations:
30700
30701@table @gcctabopt
30702
d77de738 30703@opindex mbig-endian
ddf6fe37 30704@item -mbig-endian
d77de738
ML
30705Generate code in big-endian mode.
30706
d77de738 30707@opindex mlittle-endian
ddf6fe37 30708@item -mlittle-endian
d77de738
ML
30709Generate code in little-endian mode.
30710
d77de738 30711@opindex mreduced-regs
ddf6fe37 30712@item -mreduced-regs
d77de738
ML
30713Use reduced-set registers for register allocation.
30714
d77de738 30715@opindex mfull-regs
ddf6fe37 30716@item -mfull-regs
d77de738
ML
30717Use full-set registers for register allocation.
30718
d77de738 30719@opindex mcmov
ddf6fe37 30720@item -mcmov
d77de738
ML
30721Generate conditional move instructions.
30722
d77de738 30723@opindex mno-cmov
ddf6fe37 30724@item -mno-cmov
d77de738
ML
30725Do not generate conditional move instructions.
30726
d77de738 30727@opindex mext-perf
ddf6fe37 30728@item -mext-perf
d77de738
ML
30729Generate performance extension instructions.
30730
d77de738 30731@opindex mno-ext-perf
ddf6fe37 30732@item -mno-ext-perf
d77de738
ML
30733Do not generate performance extension instructions.
30734
d77de738 30735@opindex mext-perf2
ddf6fe37 30736@item -mext-perf2
d77de738
ML
30737Generate performance extension 2 instructions.
30738
d77de738 30739@opindex mno-ext-perf2
ddf6fe37 30740@item -mno-ext-perf2
d77de738
ML
30741Do not generate performance extension 2 instructions.
30742
d77de738 30743@opindex mext-string
ddf6fe37 30744@item -mext-string
d77de738
ML
30745Generate string extension instructions.
30746
d77de738 30747@opindex mno-ext-string
ddf6fe37 30748@item -mno-ext-string
d77de738
ML
30749Do not generate string extension instructions.
30750
d77de738 30751@opindex mv3push
ddf6fe37 30752@item -mv3push
d77de738
ML
30753Generate v3 push25/pop25 instructions.
30754
d77de738 30755@opindex mno-v3push
ddf6fe37 30756@item -mno-v3push
d77de738
ML
30757Do not generate v3 push25/pop25 instructions.
30758
d77de738 30759@opindex m16-bit
ddf6fe37 30760@item -m16-bit
d77de738
ML
30761Generate 16-bit instructions.
30762
d77de738 30763@opindex mno-16-bit
ddf6fe37 30764@item -mno-16-bit
d77de738
ML
30765Do not generate 16-bit instructions.
30766
d77de738 30767@opindex misr-vector-size
ddf6fe37 30768@item -misr-vector-size=@var{num}
d77de738
ML
30769Specify the size of each interrupt vector, which must be 4 or 16.
30770
d77de738 30771@opindex mcache-block-size
ddf6fe37 30772@item -mcache-block-size=@var{num}
d77de738
ML
30773Specify the size of each cache block,
30774which must be a power of 2 between 4 and 512.
30775
d77de738 30776@opindex march
ddf6fe37 30777@item -march=@var{arch}
d77de738
ML
30778Specify the name of the target architecture.
30779
a0d60660 30780@opindex mcmodel=
ddf6fe37 30781@item -mcmodel=@var{code-model}
d77de738
ML
30782Set the code model to one of
30783@table @asis
30784@item @samp{small}
30785All the data and read-only data segments must be within 512KB addressing space.
30786The text segment must be within 16MB addressing space.
30787@item @samp{medium}
30788The data segment must be within 512KB while the read-only data segment can be
30789within 4GB addressing space. The text segment should be still within 16MB
30790addressing space.
30791@item @samp{large}
30792All the text and data segments can be within 4GB addressing space.
30793@end table
30794
d77de738 30795@opindex mctor-dtor
ddf6fe37 30796@item -mctor-dtor
d77de738
ML
30797Enable constructor/destructor feature.
30798
d77de738 30799@opindex mrelax
ddf6fe37 30800@item -mrelax
d77de738
ML
30801Guide linker to relax instructions.
30802
30803@end table
30804
d77de738
ML
30805@node Nvidia PTX Options
30806@subsection Nvidia PTX Options
30807@cindex Nvidia PTX options
30808@cindex nvptx options
30809
30810These options are defined for Nvidia PTX:
30811
30812@table @gcctabopt
30813
d77de738 30814@opindex m64
ddf6fe37 30815@item -m64
d77de738
ML
30816Ignored, but preserved for backward compatibility. Only 64-bit ABI is
30817supported.
30818
d77de738 30819@opindex march
ddf6fe37 30820@item -march=@var{architecture-string}
86b3a753
TS
30821Generate code for the specified PTX ISA target architecture.
30822Valid architecture strings are
7151d885 30823@samp{sm_30}, @samp{sm_35}, @samp{sm_37},
7cff338e 30824@samp{sm_52}, @samp{sm_53},
7b53b883 30825@samp{sm_61},
86b3a753 30826@samp{sm_70}, @samp{sm_75},
ed210c69 30827@samp{sm_80}, and @samp{sm_89}.
d77de738
ML
30828The default depends on how the compiler has been configured, see
30829@option{--with-arch}.
30830
30831This option sets the value of the preprocessor macro
30832@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
30833@samp{350}.
30834
d77de738 30835@opindex misa
ddf6fe37 30836@item -misa=@var{architecture-string}
d77de738
ML
30837Alias of @option{-march=}.
30838
d77de738 30839@opindex march
ddf6fe37 30840@item -march-map=@var{architecture-string}
d77de738
ML
30841Select the closest available @option{-march=} value that is not more
30842capable. For instance, for @option{-march-map=sm_50} select
59a4089c 30843@option{-march=sm_37}, and for @option{-march-map=sm_53} select
d77de738
ML
30844@option{-march=sm_53}.
30845
d77de738 30846@opindex mptx
ddf6fe37 30847@item -mptx=@var{version-string}
1af83aa0
TS
30848Generate code for the specified PTX ISA version.
30849Valid version strings are
30850@samp{3.1},
18d80e5e 30851@samp{4.1}, @samp{4.2},
97616687 30852@samp{5.0},
1af83aa0 30853@samp{6.0}, @samp{6.3},
ecb99f69 30854@samp{7.0}, @samp{7.3}, and @samp{7.8}.
b7f16864
TS
30855The default PTX ISA version is the one that added support for the
30856selected PTX ISA target architecture, see @option{-march=}, but at
5450afcf 30857least @samp{6.3}, or @samp{7.3} for @option{-march=sm_52} and higher.
d77de738
ML
30858
30859This option sets the values of the preprocessor macros
30860@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
30861for instance, for @samp{3.1} the macros have the values @samp{3} and
30862@samp{1}, respectively.
30863
d77de738 30864@opindex mmainkernel
ddf6fe37 30865@item -mmainkernel
d77de738
ML
30866Link in code for a __main kernel. This is for stand-alone instead of
30867offloading execution.
30868
d77de738 30869@opindex moptimize
ddf6fe37 30870@item -moptimize
d77de738
ML
30871Apply partitioned execution optimizations. This is the default when any
30872level of optimization is selected.
30873
d77de738 30874@opindex msoft-stack
3861d362 30875@opindex mno-soft-stack
ddf6fe37 30876@item -msoft-stack
3861d362
TS
30877@itemx -mno-soft-stack
30878For @option{-mno-soft-stack} (the default, unless @option{-mgomp} has
30879been specified), use PTX ``native'' stacks, that is,
30880generate code that uses @code{.local} memory or PTX @code{alloca}
30881directly for stack storage.
30882Unless @option{-mptx=7.3} or higher and @option{-march=sm_52} or
30883higher are active, variable-length arrays and dynamically allocating
30884memory on the stack with @code{alloca} are not supported.
30885
30886For @option{-msoft-stack} (implied by @option{-mgomp}),
30887generate code that does not use @code{.local} memory or PTX @code{alloca}
d77de738
ML
30888directly for stack storage. Instead, a per-warp stack pointer is
30889maintained explicitly. This enables variable-length stack allocation (with
30890variable-length arrays or @code{alloca}), and when global memory is used for
30891underlying storage, makes it possible to access automatic variables from other
30892threads, or with atomic instructions. This code generation variant is used
30893for OpenMP offloading, but the option is exposed on its own for the purpose
30894of testing the compiler; to generate code suitable for linking into programs
30895using OpenMP offloading, use option @option{-mgomp}.
30896
d77de738 30897@opindex muniform-simt
ddf6fe37 30898@item -muniform-simt
d77de738
ML
30899Switch to code generation variant that allows to execute all threads in each
30900warp, while maintaining memory state and side effects as if only one thread
30901in each warp was active outside of OpenMP SIMD regions. All atomic operations
30902and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
30903current lane index equals the master lane index), and the register being
30904assigned is copied via a shuffle instruction from the master lane. Outside of
30905SIMD regions lane 0 is the master; inside, each thread sees itself as the
30906master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
30907all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
30908regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
30909with current lane index to compute the master lane index.
30910
d77de738 30911@opindex mgomp
ddf6fe37 30912@item -mgomp
d77de738
ML
30913Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
30914@option{-muniform-simt} options, and selects corresponding multilib variant.
30915
30916@end table
30917
30918@node OpenRISC Options
30919@subsection OpenRISC Options
30920@cindex OpenRISC Options
30921
30922These options are defined for OpenRISC:
30923
30924@table @gcctabopt
30925
d77de738 30926@opindex mboard
ddf6fe37 30927@item -mboard=@var{name}
d77de738
ML
30928Configure a board specific runtime. This will be passed to the linker for
30929newlib board library linking. The default is @code{or1ksim}.
30930
d77de738 30931@opindex mnewlib
ddf6fe37 30932@item -mnewlib
d77de738
ML
30933This option is ignored; it is for compatibility purposes only. This used to
30934select linker and preprocessor options for use with newlib.
30935
d77de738
ML
30936@opindex msoft-div
30937@opindex mhard-div
ddf6fe37
AA
30938@item -msoft-div
30939@itemx -mhard-div
d77de738
ML
30940Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
30941This default is hardware divide.
30942
d77de738
ML
30943@opindex msoft-mul
30944@opindex mhard-mul
ddf6fe37
AA
30945@item -msoft-mul
30946@itemx -mhard-mul
d77de738
ML
30947Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
30948This default is hardware multiply.
30949
d77de738
ML
30950@opindex msoft-float
30951@opindex mhard-float
ddf6fe37
AA
30952@item -msoft-float
30953@itemx -mhard-float
d77de738
ML
30954Select software or hardware for floating point operations.
30955The default is software.
30956
d77de738 30957@opindex mdouble-float
ddf6fe37 30958@item -mdouble-float
d77de738
ML
30959When @option{-mhard-float} is selected, enables generation of double-precision
30960floating point instructions. By default functions from @file{libgcc} are used
30961to perform double-precision floating point operations.
30962
d77de738 30963@opindex munordered-float
ddf6fe37 30964@item -munordered-float
d77de738
ML
30965When @option{-mhard-float} is selected, enables generation of unordered
30966floating point compare and set flag (@code{lf.sfun*}) instructions. By default
30967functions from @file{libgcc} are used to perform unordered floating point
30968compare and set flag operations.
30969
d77de738 30970@opindex mcmov
ddf6fe37 30971@item -mcmov
d77de738
ML
30972Enable generation of conditional move (@code{l.cmov}) instructions. By
30973default the equivalent will be generated using set and branch.
30974
d77de738 30975@opindex mror
ddf6fe37 30976@item -mror
d77de738
ML
30977Enable generation of rotate right (@code{l.ror}) instructions. By default
30978functions from @file{libgcc} are used to perform rotate right operations.
30979
d77de738 30980@opindex mrori
ddf6fe37 30981@item -mrori
d77de738
ML
30982Enable generation of rotate right with immediate (@code{l.rori}) instructions.
30983By default functions from @file{libgcc} are used to perform rotate right with
30984immediate operations.
30985
d77de738 30986@opindex msext
ddf6fe37 30987@item -msext
d77de738
ML
30988Enable generation of sign extension (@code{l.ext*}) instructions. By default
30989memory loads are used to perform sign extension.
30990
d77de738 30991@opindex msfimm
ddf6fe37 30992@item -msfimm
d77de738
ML
30993Enable generation of compare and set flag with immediate (@code{l.sf*i})
30994instructions. By default extra instructions will be generated to store the
30995immediate to a register first.
30996
d77de738 30997@opindex mshftimm
ddf6fe37 30998@item -mshftimm
d77de738
ML
30999Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
31000@code{l.slli}) instructions. By default extra instructions will be generated
31001to store the immediate to a register first.
31002
a0d60660 31003@opindex mcmodel=
d77de738 31004@opindex mcmodel=small
ddf6fe37 31005@item -mcmodel=small
2588ef74
SH
31006Generate OpenRISC code for the small model: The GOT is limited to 64k and
31007function call jumps are limited to 64M offsets. This is the default model.
d77de738 31008
d77de738 31009@opindex mcmodel=large
ddf6fe37 31010@item -mcmodel=large
2588ef74
SH
31011Generate OpenRISC code for the large model: The GOT may grow up to 4G in size
31012and function call jumps can target the full 4G address space.
d77de738
ML
31013
31014
31015@end table
31016
31017@node PDP-11 Options
31018@subsection PDP-11 Options
31019@cindex PDP-11 Options
31020
31021These options are defined for the PDP-11:
31022
31023@table @gcctabopt
d77de738 31024@opindex mfpu
ddf6fe37 31025@item -mfpu
d77de738
ML
31026Use hardware FPP floating point. This is the default. (FIS floating
31027point on the PDP-11/40 is not supported.) Implies -m45.
31028
d77de738 31029@opindex msoft-float
ddf6fe37 31030@item -msoft-float
d77de738
ML
31031Do not use hardware floating point.
31032
d77de738 31033@opindex mac0
ddf6fe37 31034@item -mac0
d77de738
ML
31035Return floating-point results in ac0 (fr0 in Unix assembler syntax).
31036
d77de738 31037@opindex mno-ac0
ddf6fe37 31038@item -mno-ac0
d77de738
ML
31039Return floating-point results in memory. This is the default.
31040
d77de738 31041@opindex m40
ddf6fe37 31042@item -m40
d77de738
ML
31043Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
31044
d77de738 31045@opindex m45
ddf6fe37 31046@item -m45
d77de738
ML
31047Generate code for a PDP-11/45. This is the default.
31048
d77de738 31049@opindex m10
ddf6fe37 31050@item -m10
d77de738
ML
31051Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
31052
d77de738
ML
31053@opindex mint16
31054@opindex mno-int32
ddf6fe37
AA
31055@item -mint16
31056@itemx -mno-int32
d77de738
ML
31057Use 16-bit @code{int}. This is the default.
31058
d77de738
ML
31059@opindex mint32
31060@opindex mno-int16
ddf6fe37
AA
31061@item -mint32
31062@itemx -mno-int16
d77de738
ML
31063Use 32-bit @code{int}.
31064
d77de738 31065@opindex msplit
ddf6fe37 31066@item -msplit
d77de738
ML
31067Target has split instruction and data space. Implies -m45.
31068
d77de738 31069@opindex munix-asm
ddf6fe37 31070@item -munix-asm
d77de738
ML
31071Use Unix assembler syntax.
31072
d77de738 31073@opindex mdec-asm
ddf6fe37 31074@item -mdec-asm
d77de738
ML
31075Use DEC assembler syntax.
31076
d77de738 31077@opindex mgnu-asm
ddf6fe37 31078@item -mgnu-asm
d77de738
ML
31079Use GNU assembler syntax. This is the default.
31080
d77de738 31081@opindex mlra
ddf6fe37 31082@item -mlra
d77de738
ML
31083Use the new LRA register allocator. By default, the old ``reload''
31084allocator is used.
31085@end table
31086
d77de738
ML
31087@node PowerPC Options
31088@subsection PowerPC Options
31089@cindex PowerPC options
31090
31091These are listed under @xref{RS/6000 and PowerPC Options}.
31092
31093@node PRU Options
31094@subsection PRU Options
31095@cindex PRU Options
31096
31097These command-line options are defined for PRU target:
31098
31099@table @gcctabopt
d77de738 31100@opindex minrt
ddf6fe37 31101@item -minrt
e3dfc150
DD
31102Link with a minimum runtime environment. This can significantly reduce
31103the size of the final ELF binary, but some standard C runtime features
31104are removed.
31105
31106This option disables support for static initializers and constructors.
31107Beware that the compiler could still generate code with static initializers
31108and constructors. It is up to the programmer to ensure that the source
31109program will not use those features.
31110
31111The minimal startup code would not pass @code{argc} and @code{argv} arguments
31112to @code{main}, so the latter must be declared as @code{int main (void)}.
31113This is already the norm for most firmware projects.
d77de738 31114
d77de738 31115@opindex mmcu
ddf6fe37 31116@item -mmcu=@var{mcu}
608d40fd
DD
31117Specify the PRU hardware variant to use. A correspondingly named
31118spec file would be loaded, passing the memory region sizes to
31119the linker and defining hardware-specific C macros.
31120
31121Newlib provides only the @code{sim} spec, intended for running
31122regression tests using a simulator. Specs for real hardware can be
31123obtained by installing the
31124@w{@uref{https://github.com/dinuxbg/gnuprumcu/,GnuPruMcu}} package.
d77de738 31125
d77de738 31126@opindex mno-relax
ddf6fe37 31127@item -mno-relax
d77de738
ML
31128Make GCC pass the @option{--no-relax} command-line option to the linker
31129instead of the @option{--relax} option.
31130
d77de738 31131@opindex mloop
ddf6fe37 31132@item -mloop
d77de738
ML
31133Allow (or do not allow) GCC to use the LOOP instruction.
31134
d77de738 31135@opindex mabi
ddf6fe37 31136@item -mabi=@var{variant}
d77de738
ML
31137Specify the ABI variant to output code for. @option{-mabi=ti} selects the
31138unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
31139more naturally with certain GCC assumptions. These are the differences:
31140
31141@table @samp
31142@item Function Pointer Size
31143TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
31144supports only 32-bit data and code pointers.
31145
31146@item Optional Return Value Pointer
31147Function return values larger than 64 bits are passed by using a hidden
31148pointer as the first argument of the function. TI ABI, though, mandates that
31149the pointer can be NULL in case the caller is not using the returned value.
31150GNU always passes and expects a valid return value pointer.
31151
31152@end table
31153
31154The current @option{-mabi=ti} implementation simply raises a compile error
31155when any of the above code constructs is detected. As a consequence
31156the standard C library cannot be built and it is omitted when linking with
31157@option{-mabi=ti}.
31158
31159Relaxation is a GNU feature and for safety reasons is disabled when using
31160@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
31161instructions, so the GNU linker cannot adjust them when shortening adjacent
31162LDI32 pseudo instructions.
31163
31164@end table
31165
31166@node RISC-V Options
31167@subsection RISC-V Options
31168@cindex RISC-V Options
31169
31170These command-line options are defined for RISC-V targets:
31171
31172@table @gcctabopt
d77de738 31173@opindex mbranch-cost
ddf6fe37 31174@item -mbranch-cost=@var{n}
d77de738
ML
31175Set the cost of branches to roughly @var{n} instructions.
31176
ddf6fe37 31177@opindex plt
d77de738
ML
31178@item -mplt
31179@itemx -mno-plt
d77de738
ML
31180When generating PIC code, do or don't allow the use of PLTs. Ignored for
31181non-PIC. The default is @option{-mplt}.
31182
d77de738 31183@opindex mabi
ddf6fe37 31184@item -mabi=@var{ABI-string}
d77de738
ML
31185Specify integer and floating-point calling convention. @var{ABI-string}
31186contains two parts: the size of integer types and the registers used for
31187floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
31188@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
3118932-bit), and that floating-point values up to 64 bits wide are passed in F
31190registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
31191allows the compiler to generate code that uses the F and D extensions but only
31192allows floating-point values up to 32 bits long to be passed in registers; or
31193@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
31194passed in registers.
31195
31196The default for this argument is system dependent, users who want a specific
31197calling convention should specify one explicitly. The valid calling
31198conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
31199@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
31200implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
31201invalid because the ABI requires 64-bit values be passed in F registers, but F
006e90e1
TO
31202registers are only 32 bits wide. There are also the @samp{ilp32e} ABI that can
31203only be used with the @samp{rv32e} architecture and the @samp{lp64e} ABI that
31204can only be used with the @samp{rv64e}. Those ABIs are not well specified at
31205present, and are subject to change.
d77de738 31206
ddf6fe37 31207@opindex mfdiv
d77de738
ML
31208@item -mfdiv
31209@itemx -mno-fdiv
d77de738
ML
31210Do or don't use hardware floating-point divide and square root instructions.
31211This requires the F or D extensions for floating-point registers. The default
31212is to use them if the specified architecture has these instructions.
31213
a6114c2a
PD
31214@opindex mfence-tso
31215@item -mfence-tso
31216@itemx -mno-fence-tso
31217Do or don't use the @samp{fence.tso} instruction, which is unimplemented on
31218some processors (including those from T-Head). If the @samp{fence.tso}
b9857b78 31219instruction is not available then a stronger fence is used instead.
a6114c2a 31220
ddf6fe37 31221@opindex mdiv
d77de738
ML
31222@item -mdiv
31223@itemx -mno-div
d77de738
ML
31224Do or don't use hardware instructions for integer division. This requires the
31225M extension. The default is to use them if the specified architecture has
31226these instructions.
31227
d77de738 31228@opindex misa-spec
ddf6fe37 31229@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
31230Specify the version of the RISC-V Unprivileged (formerly User-Level)
31231ISA specification to produce code conforming to. The possibilities
31232for @var{ISA-spec-string} are:
31233@table @code
31234@item 2.2
31235Produce code conforming to version 2.2.
31236@item 20190608
31237Produce code conforming to version 20190608.
31238@item 20191213
31239Produce code conforming to version 20191213.
31240@end table
31241The default is @option{-misa-spec=20191213} unless GCC has been configured
31242with @option{--with-isa-spec=} specifying a different default version.
31243
d77de738 31244@opindex march
43b450e3
J
31245@item -march=@var{ISA-string|Profiles|Profile_ISA-string}
31246Generate code for given RISC-V ISA or Profiles or a combination of them
31247(e.g.@: @samp{rv64im} @samp{rvi20u64} @samp{rvi20u64_zbb}). ISA strings and
31248Profiles must be lower-case. Examples include @samp{rv64i}, @samp{rv32g},
31249@samp{rv32e}, @samp{rv32imaf}, @samp{rva22u64} and @samp{rva23u64}.
31250To combine Profiles and optional RISC-V ISA extention, the profile should start
31251at the beginning of the option, then use underline connect ISA-string (e.g.@:
31252@samp{rvi20u64_zca_zcb} @samp{rva23u64_zacas}). Additionally, a special value
31253@option{help} (@option{-march=help}) is accepted to list all supported
31254extensions.
d77de738 31255
5a22bb25
KC
31256The syntax of the ISA string is defined as follows:
31257
31258@table @code
31259@item The string must start with @samp{rv32} or @samp{rv64}, followed by
31260@samp{i}, @samp{e}, or @samp{g}, referred to as the base ISA.
31261@item The subsequent part of the string is a list of extension names. Extension
31262names can be categorized as multi-letter (e.g.@: @samp{zba}) and single-letter
31263(e.g.@: @samp{v}). Single-letter extensions can appear consecutively,
31264but multi-letter extensions must be separated by underscores.
31265@item An underscore can appear anywhere after the base ISA. It has no specific
31266effect but is used to improve readability and can act as a separator.
31267@item Extension names may include an optional version number, following the
31268syntax @samp{<major>p<minor>} or @samp{<major>}, (e.g.@: @samp{m2p1} or
31269@samp{m2}).
31270@end table
31271
19260a04 31272Supported extension are listed below:
19260a04 31273
124cbbbe 31274@include riscv-ext.texi
19260a04 31275
d77de738
ML
31276When @option{-march=} is not specified, use the setting from @option{-mcpu}.
31277
31278If both @option{-march} and @option{-mcpu=} are not specified, the default for
31279this argument is system dependent, users who want a specific architecture
31280extensions should specify one explicitly.
31281
70f6bc39
PD
31282When the RISC-V specifications define an extension as depending on other
31283extensions, GCC will implicitly add the dependent extensions to the enabled
31284extension set if they weren't added explicitly.
31285
d77de738 31286@opindex mcpu
ddf6fe37 31287@item -mcpu=@var{processor-string}
d77de738
ML
31288Use architecture of and optimize the output for the given processor, specified
31289by particular CPU name.
1186a2bd
UK
31290Permissible values for this option are: @samp{mips-p8700}, @samp{sifive-e20},
31291@samp{sifive-e21}, @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34},
31292@samp{sifive-e76}, @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54},
31293@samp{sifive-s76}, @samp{sifive-u54}, @samp{sifive-u74}, @samp{sifive-x280},
31294@samp{sifive-xp450}, @samp{sifive-x670}, @samp{thead-c906}, @samp{tt-ascalon-d8},
f0cd40f7
J
31295@samp{xiangshan-nanhu}, @samp{xiangshan-kunminghu}, @samp{xt-c908}, @samp{xt-c908v},
31296@samp{xt-c910}, @samp{xt-c910v2}, @samp{xt-c920}, @samp{xt-c920v2}.
d77de738 31297
1c5da882
PD
31298Note that @option{-mcpu} does not override @option{-march} or @option{-mtune}.
31299
d77de738 31300@opindex mtune
ddf6fe37 31301@item -mtune=@var{processor-string}
d77de738 31302Optimize the output for the given processor, specified by microarchitecture or
5601c411 31303particular CPU name. Permissible values for this option are:
1186a2bd 31304@samp{generic-ooo}, @samp{mips-p8700}, @samp{rocket}, @samp{sifive-3-series},
5601c411
AB
31305@samp{sifive-5-series}, @samp{sifive-7-series}, @samp{size},
31306@samp{sifive-p400-series}, @samp{sifive-p600-series}, and all valid options for
31307@option{-mcpu=}.
d77de738
ML
31308
31309When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
31310the default is @samp{rocket} if both are not specified.
31311
31312The @samp{size} choice is not intended for use by end-users. This is used
31313when @option{-Os} is specified. It overrides the instruction cost info
31314provided by @option{-mtune=}, but does not override the pipeline info. This
31315helps reduce code size while still giving good performance.
31316
d77de738 31317@opindex mpreferred-stack-boundary
ddf6fe37 31318@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
31319Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
31320byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
31321the default is 4 (16 bytes or 128-bits).
31322
31323@strong{Warning:} If you use this switch, then you must build all modules with
31324the same value, including any libraries. This includes the system libraries
31325and startup modules.
31326
d77de738 31327@opindex msmall-data-limit
ddf6fe37 31328@item -msmall-data-limit=@var{n}
d77de738
ML
31329Put global and static data smaller than @var{n} bytes into a special section
31330(on some targets).
31331
ddf6fe37 31332@opindex msave-restore
d77de738
ML
31333@item -msave-restore
31334@itemx -mno-save-restore
d77de738
ML
31335Do or don't use smaller but slower prologue and epilogue code that uses
31336library function calls. The default is to use fast inline prologues and
31337epilogues.
31338
dc95b338
MR
31339@opindex mmovcc
31340@item -mmovcc
31341@itemx -mno-movcc
31342Do or don't produce branchless conditional-move code sequences even with
31343targets that do not have specific instructions for conditional operations.
31344If enabled, sequences of ALU operations are produced using base integer
31345ISA instructions where profitable.
31346
f797260a
PN
31347@opindex minline-atomics
31348@item -minline-atomics
31349@itemx -mno-inline-atomics
31350Do or don't use smaller but slower subword atomic emulation code that uses
31351libatomic function calls. The default is to use fast inline subword atomics
31352that do not require libatomic.
31353
df48285b
CM
31354@opindex minline-strlen
31355@item -minline-strlen
31356@itemx -mno-inline-strlen
31357Do or do not attempt to inline strlen calls if possible.
31358Inlining will only be done if the string is properly aligned
31359and instructions for accelerated processing are available.
31360The default is to not inline strlen calls.
31361
949f1ccf
CM
31362@opindex minline-strcmp
31363@item -minline-strcmp
31364@itemx -mno-inline-strcmp
31365Do or do not attempt to inline strcmp calls if possible.
31366Inlining will only be done if the strings are properly aligned
31367and instructions for accelerated processing are available.
31368The default is to not inline strcmp calls.
31369
82576a6e
CM
31370The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
31371the maximum number of bytes compared by the inlined code.
31372The default value is 64.
31373
949f1ccf
CM
31374@opindex minline-strncmp
31375@item -minline-strncmp
31376@itemx -mno-inline-strncmp
31377Do or do not attempt to inline strncmp calls if possible.
31378Inlining will only be done if the strings are properly aligned
31379and instructions for accelerated processing are available.
31380The default is to not inline strncmp calls.
31381
82576a6e
CM
31382The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
31383the maximum number of bytes compared by the inlined code.
31384The default value is 64.
31385
ddf6fe37 31386@opindex mshorten-memrefs
d77de738
ML
31387@item -mshorten-memrefs
31388@itemx -mno-shorten-memrefs
d77de738
ML
31389Do or do not attempt to make more use of compressed load/store instructions by
31390replacing a load/store of 'base register + large offset' with a new load/store
31391of 'new base + small offset'. If the new base gets stored in a compressed
31392register, then the new load/store can be compressed. Currently targets 32-bit
31393integer load/stores only.
31394
ddf6fe37 31395@opindex mstrict-align
d77de738
ML
31396@item -mstrict-align
31397@itemx -mno-strict-align
d77de738
ML
31398Do not or do generate unaligned memory accesses. The default is set depending
31399on whether the processor we are optimizing for supports fast unaligned access
31400or not.
31401
68b0742a
RD
31402@opindex mscalar-strict-align
31403@opindex mno-scalar-strict-align
31404@item -mscalar-strict-align
31405@itemx -mno-scalar-strict-align
31406Do not or do generate unaligned memory accesses. The default is set depending
31407on whether the processor we are optimizing for supports fast unaligned access
31408or not. This is an alias for @option{-mstrict-align}.
31409
31410@opindex mvector-strict-align
31411@opindex mno-vector-strict-align
31412@item -mvector-strict-align
31413@itemx -mno-vector-strict-align
31414Do not or do generate unaligned vector memory accesses. The default is set
31415to off unless the processor we are optimizing for explicitly supports
31416element-misaligned vector memory access.
31417
31418
a0d60660 31419@opindex mcmodel=
d77de738 31420@opindex mcmodel=medlow
ddf6fe37 31421@item -mcmodel=medlow
d77de738
ML
31422Generate code for the medium-low code model. The program and its statically
31423defined symbols must lie within a single 2 GiB address range and must lie
feea589d
HH
31424between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be statically
31425or dynamically linked. This is the default code model unless GCC has been
31426configured with @option{--with-cmodel=} specifying a different default code
31427model.
d77de738 31428
d77de738 31429@opindex mcmodel=medany
ddf6fe37 31430@item -mcmodel=medany
d77de738
ML
31431Generate code for the medium-any code model. The program and its statically
31432defined symbols must be within any single 2 GiB address range. Programs can be
31433statically or dynamically linked.
31434
31435The code generated by the medium-any code model is position-independent, but is
31436not guaranteed to function correctly when linked into position-independent
31437executables or libraries.
31438
a0d60660 31439@opindex mcmodel=large
6ffea3e3
PD
31440@item -mcmodel=large
31441Generate code for a large code model, which has no restrictions on size or
31442placement of symbols.
31443
d77de738
ML
31444@item -mexplicit-relocs
31445@itemx -mno-exlicit-relocs
31446Use or do not use assembler relocation operators when dealing with symbolic
31447addresses. The alternative is to use assembler macros instead, which may
31448limit optimization.
31449
ddf6fe37 31450@opindex mrelax
d77de738
ML
31451@item -mrelax
31452@itemx -mno-relax
d77de738
ML
31453Take advantage of linker relaxations to reduce the number of instructions
31454required to materialize symbol addresses. The default is to take advantage of
31455linker relaxations.
31456
ddf6fe37 31457@opindex mriscv-attribute
d77de738
ML
31458@item -mriscv-attribute
31459@itemx -mno-riscv-attribute
d77de738
ML
31460Emit (do not emit) RISC-V attribute to record extra information into ELF
31461objects. This feature requires at least binutils 2.32.
31462
ddf6fe37 31463@opindex mcsr-check
d77de738
ML
31464@item -mcsr-check
31465@itemx -mno-csr-check
d77de738
ML
31466Enables or disables the CSR checking.
31467
d77de738 31468@opindex malign-data
ddf6fe37 31469@item -malign-data=@var{type}
d77de738
ML
31470Control how GCC aligns variables and constants of array, structure, or union
31471types. Supported values for @var{type} are @samp{xlen} which uses x register
31472width as the alignment value, and @samp{natural} which uses natural alignment.
31473@samp{xlen} is the default.
31474
d77de738 31475@opindex mbig-endian
ddf6fe37 31476@item -mbig-endian
d77de738
ML
31477Generate big-endian code. This is the default when GCC is configured for a
31478@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
31479
d77de738 31480@opindex mlittle-endian
ddf6fe37 31481@item -mlittle-endian
d77de738
ML
31482Generate little-endian code. This is the default when GCC is configured for a
31483@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
31484@samp{riscv32be-*-*} target.
31485
d77de738
ML
31486@opindex mstack-protector-guard
31487@opindex mstack-protector-guard-reg
31488@opindex mstack-protector-guard-offset
ddf6fe37
AA
31489@item -mstack-protector-guard=@var{guard}
31490@itemx -mstack-protector-guard-reg=@var{reg}
31491@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
31492Generate stack protection code using canary at @var{guard}. Supported
31493locations are @samp{global} for a global canary or @samp{tls} for per-thread
31494canary in the TLS block.
31495
31496With the latter choice the options
31497@option{-mstack-protector-guard-reg=@var{reg}} and
31498@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
31499which register to use as base register for reading the canary,
31500and from what offset from that base register. There is no default
31501register or offset as this is entirely for use within the Linux
31502kernel.
97069657
TI
31503
31504@opindex mtls-dialect=desc
31505@item -mtls-dialect=desc
31506Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
31507of TLS variables.
31508
31509@opindex mtls-dialect=trad
31510@item -mtls-dialect=trad
31511Use traditional TLS as the thread-local storage mechanism for dynamic accesses
31512of TLS variables. This is the default.
d77de738
ML
31513@end table
31514
31515@node RL78 Options
31516@subsection RL78 Options
31517@cindex RL78 Options
31518
31519@table @gcctabopt
31520
d77de738 31521@opindex msim
ddf6fe37 31522@item -msim
d77de738
ML
31523Links in additional target libraries to support operation within a
31524simulator.
31525
ddf6fe37 31526@opindex mmul
d77de738
ML
31527@item -mmul=none
31528@itemx -mmul=g10
31529@itemx -mmul=g13
31530@itemx -mmul=g14
31531@itemx -mmul=rl78
d77de738
ML
31532Specifies the type of hardware multiplication and division support to
31533be used. The simplest is @code{none}, which uses software for both
31534multiplication and division. This is the default. The @code{g13}
31535value is for the hardware multiply/divide peripheral found on the
31536RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
31537the multiplication and division instructions supported by the RL78/G14
31538(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
31539the value @code{mg10} is an alias for @code{none}.
31540
31541In addition a C preprocessor macro is defined, based upon the setting
31542of this option. Possible values are: @code{__RL78_MUL_NONE__},
31543@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
31544
ddf6fe37 31545@opindex mcpu
d77de738
ML
31546@item -mcpu=g10
31547@itemx -mcpu=g13
31548@itemx -mcpu=g14
31549@itemx -mcpu=rl78
d77de738
ML
31550Specifies the RL78 core to target. The default is the G14 core, also
31551known as an S3 core or just RL78. The G13 or S2 core does not have
31552multiply or divide instructions, instead it uses a hardware peripheral
31553for these operations. The G10 or S1 core does not have register
31554banks, so it uses a different calling convention.
31555
31556If this option is set it also selects the type of hardware multiply
31557support to use, unless this is overridden by an explicit
31558@option{-mmul=none} option on the command line. Thus specifying
31559@option{-mcpu=g13} enables the use of the G13 hardware multiply
31560peripheral and specifying @option{-mcpu=g10} disables the use of
31561hardware multiplications altogether.
31562
31563Note, although the RL78/G14 core is the default target, specifying
31564@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
31565change the behavior of the toolchain since it also enables G14
31566hardware multiply support. If these options are not specified on the
31567command line then software multiplication routines will be used even
31568though the code targets the RL78 core. This is for backwards
31569compatibility with older toolchains which did not have hardware
31570multiply and divide support.
31571
31572In addition a C preprocessor macro is defined, based upon the setting
31573of this option. Possible values are: @code{__RL78_G10__},
31574@code{__RL78_G13__} or @code{__RL78_G14__}.
31575
d77de738
ML
31576@opindex mg10
31577@opindex mg13
31578@opindex mg14
31579@opindex mrl78
ddf6fe37
AA
31580@item -mg10
31581@itemx -mg13
31582@itemx -mg14
31583@itemx -mrl78
d77de738
ML
31584These are aliases for the corresponding @option{-mcpu=} option. They
31585are provided for backwards compatibility.
31586
d77de738 31587@opindex mallregs
ddf6fe37 31588@item -mallregs
d77de738
ML
31589Allow the compiler to use all of the available registers. By default
31590registers @code{r24..r31} are reserved for use in interrupt handlers.
31591With this option enabled these registers can be used in ordinary
31592functions as well.
31593
d77de738
ML
31594@opindex m64bit-doubles
31595@opindex m32bit-doubles
ddf6fe37
AA
31596@item -m64bit-doubles
31597@itemx -m32bit-doubles
d77de738
ML
31598Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
31599or 32 bits (@option{-m32bit-doubles}) in size. The default is
31600@option{-m32bit-doubles}.
31601
d77de738
ML
31602@opindex msave-mduc-in-interrupts
31603@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
31604@item -msave-mduc-in-interrupts
31605@itemx -mno-save-mduc-in-interrupts
d77de738
ML
31606Specifies that interrupt handler functions should preserve the
31607MDUC registers. This is only necessary if normal code might use
31608the MDUC registers, for example because it performs multiplication
31609and division operations. The default is to ignore the MDUC registers
31610as this makes the interrupt handlers faster. The target option -mg13
31611needs to be passed for this to work as this feature is only available
31612on the G13 target (S2 core). The MDUC registers will only be saved
31613if the interrupt handler performs a multiplication or division
31614operation or it calls another function.
31615
31616@end table
31617
31618@node RS/6000 and PowerPC Options
31619@subsection IBM RS/6000 and PowerPC Options
31620@cindex RS/6000 and PowerPC Options
31621@cindex IBM RS/6000 and PowerPC Options
31622
31623These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
31624@table @gcctabopt
31625@item -mpowerpc-gpopt
31626@itemx -mno-powerpc-gpopt
31627@itemx -mpowerpc-gfxopt
31628@itemx -mno-powerpc-gfxopt
31629@need 800
31630@itemx -mpowerpc64
31631@itemx -mno-powerpc64
31632@itemx -mmfcrf
31633@itemx -mno-mfcrf
31634@itemx -mpopcntb
31635@itemx -mno-popcntb
31636@itemx -mpopcntd
31637@itemx -mno-popcntd
31638@itemx -mfprnd
31639@itemx -mno-fprnd
31640@need 800
d77de738
ML
31641@opindex mpowerpc-gpopt
31642@opindex mno-powerpc-gpopt
31643@opindex mpowerpc-gfxopt
31644@opindex mno-powerpc-gfxopt
31645@opindex mpowerpc64
31646@opindex mno-powerpc64
31647@opindex mmfcrf
31648@opindex mno-mfcrf
31649@opindex mpopcntb
31650@opindex mno-popcntb
31651@opindex mpopcntd
31652@opindex mno-popcntd
31653@opindex mfprnd
31654@opindex mno-fprnd
31655@opindex mcmpb
31656@opindex mno-cmpb
31657@opindex mhard-dfp
31658@opindex mno-hard-dfp
ddf6fe37
AA
31659@itemx -mcmpb
31660@itemx -mno-cmpb
31661@itemx -mhard-dfp
31662@itemx -mno-hard-dfp
d77de738
ML
31663You use these options to specify which instructions are available on the
31664processor you are using. The default value of these options is
31665determined when configuring GCC@. Specifying the
31666@option{-mcpu=@var{cpu_type}} overrides the specification of these
31667options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
31668rather than the options listed above.
31669
31670Specifying @option{-mpowerpc-gpopt} allows
31671GCC to use the optional PowerPC architecture instructions in the
31672General Purpose group, including floating-point square root. Specifying
31673@option{-mpowerpc-gfxopt} allows GCC to
31674use the optional PowerPC architecture instructions in the Graphics
31675group, including floating-point select.
31676
31677The @option{-mmfcrf} option allows GCC to generate the move from
31678condition register field instruction implemented on the POWER4
31679processor and other processors that support the PowerPC V2.01
31680architecture.
31681The @option{-mpopcntb} option allows GCC to generate the popcount and
31682double-precision FP reciprocal estimate instruction implemented on the
31683POWER5 processor and other processors that support the PowerPC V2.02
31684architecture.
31685The @option{-mpopcntd} option allows GCC to generate the popcount
31686instruction implemented on the POWER7 processor and other processors
31687that support the PowerPC V2.06 architecture.
31688The @option{-mfprnd} option allows GCC to generate the FP round to
31689integer instructions implemented on the POWER5+ processor and other
31690processors that support the PowerPC V2.03 architecture.
31691The @option{-mcmpb} option allows GCC to generate the compare bytes
31692instruction implemented on the POWER6 processor and other processors
31693that support the PowerPC V2.05 architecture.
31694The @option{-mhard-dfp} option allows GCC to generate the decimal
31695floating-point instructions implemented on some POWER processors.
31696
31697The @option{-mpowerpc64} option allows GCC to generate the additional
3169864-bit instructions that are found in the full PowerPC64 architecture
31699and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
31700@option{-mno-powerpc64}.
31701
d77de738 31702@opindex mcpu
ddf6fe37 31703@item -mcpu=@var{cpu_type}
d77de738
ML
31704Set architecture type, register usage, and
31705instruction scheduling parameters for machine type @var{cpu_type}.
31706Supported values for @var{cpu_type} are @samp{401}, @samp{403},
31707@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
31708@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
31709@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
31710@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
31711@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
31712@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
31713@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
31714@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
31715@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
05f0e9ee 31716@samp{power9}, @samp{power10}, @samp{power11}, @samp{powerpc}, @samp{powerpc64},
d77de738
ML
31717@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
31718
31719@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
31720@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
31721endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
31722architecture machine types, with an appropriate, generic processor
31723model assumed for scheduling purposes.
31724
31725Specifying @samp{native} as cpu type detects and selects the
31726architecture option that corresponds to the host processor of the
31727system performing the compilation.
31728@option{-mcpu=native} has no effect if GCC does not recognize the
31729processor.
31730
31731The other options specify a specific processor. Code generated under
31732those options runs best on that processor, and may not run at all on
31733others.
31734
31735The @option{-mcpu} options automatically enable or disable the
31736following options:
31737
43b72ede
AA
31738@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
31739-mpopcntb -mpopcntd -mpowerpc64
31740-mpowerpc-gpopt -mpowerpc-gfxopt
31741-mmulhw -mdlmzb -mmfpgpr -mvsx
438ef143 31742-mcrypto -mhtm -mpower8-fusion
43b72ede
AA
31743-mquad-memory -mquad-memory-atomic -mfloat128
31744-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
31745-mrop-protect}
31746
31747The particular options set for any particular CPU varies between
31748compiler versions, depending on what setting seems to produce optimal
31749code for that CPU; it doesn't necessarily reflect the actual hardware's
31750capabilities. If you wish to set an individual option to a particular
31751value, you may specify it after the @option{-mcpu} option, like
31752@option{-mcpu=970 -mno-altivec}.
31753
31754On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
31755not enabled or disabled by the @option{-mcpu} option at present because
31756AIX does not have full support for these options. You may still
31757enable or disable them individually if you're sure it'll work in your
31758environment.
31759
d77de738 31760@opindex mtune
ddf6fe37 31761@item -mtune=@var{cpu_type}
d77de738
ML
31762Set the instruction scheduling parameters for machine type
31763@var{cpu_type}, but do not set the architecture type or register usage,
31764as @option{-mcpu=@var{cpu_type}} does. The same
31765values for @var{cpu_type} are used for @option{-mtune} as for
31766@option{-mcpu}. If both are specified, the code generated uses the
31767architecture and registers set by @option{-mcpu}, but the
31768scheduling parameters set by @option{-mtune}.
31769
a0d60660 31770@opindex mcmodel=
d77de738 31771@opindex mcmodel=small
ddf6fe37 31772@item -mcmodel=small
d77de738
ML
31773Generate PowerPC64 code for the small model: The TOC is limited to
3177464k.
31775
d77de738 31776@opindex mcmodel=medium
ddf6fe37 31777@item -mcmodel=medium
d77de738
ML
31778Generate PowerPC64 code for the medium model: The TOC and other static
31779data may be up to a total of 4G in size. This is the default for 64-bit
31780Linux.
31781
d77de738 31782@opindex mcmodel=large
ddf6fe37 31783@item -mcmodel=large
d77de738
ML
31784Generate PowerPC64 code for the large model: The TOC may be up to 4G
31785in size. Other data and code is only limited by the 64-bit address
31786space.
31787
d77de738
ML
31788@opindex maltivec
31789@opindex mno-altivec
ddf6fe37
AA
31790@item -maltivec
31791@itemx -mno-altivec
d77de738
ML
31792Generate code that uses (does not use) AltiVec instructions, and also
31793enable the use of built-in functions that allow more direct access to
31794the AltiVec instruction set. You may also need to set
31795@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
31796enhancements.
31797
31798When @option{-maltivec} is used, the element order for AltiVec intrinsics
a0e64a04 31799such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
d77de738
ML
31800match array element order corresponding to the endianness of the
31801target. That is, element zero identifies the leftmost element in a
31802vector register when targeting a big-endian platform, and identifies
31803the rightmost element in a vector register when targeting a
31804little-endian platform.
31805
d77de738
ML
31806@opindex mvrsave
31807@opindex mno-vrsave
ddf6fe37
AA
31808@item -mvrsave
31809@itemx -mno-vrsave
d77de738
ML
31810Generate VRSAVE instructions when generating AltiVec code.
31811
d77de738 31812@opindex msecure-plt
ddf6fe37 31813@item -msecure-plt
d77de738
ML
31814Generate code that allows @command{ld} and @command{ld.so}
31815to build executables and shared
31816libraries with non-executable @code{.plt} and @code{.got} sections.
31817This is a PowerPC
3181832-bit SYSV ABI option.
31819
d77de738 31820@opindex mbss-plt
ddf6fe37 31821@item -mbss-plt
d77de738
ML
31822Generate code that uses a BSS @code{.plt} section that @command{ld.so}
31823fills in, and
31824requires @code{.plt} and @code{.got}
31825sections that are both writable and executable.
31826This is a PowerPC 32-bit SYSV ABI option.
31827
96698551
MM
31828@opindex msplit-patch-nops
31829@item -msplit-patch-nops
31830When adding NOPs for a patchable area via the
31831@option{-fpatchable-function-entry} option emit the ``before'' NOPs in front
31832of the global entry point and the ``after'' NOPs after the local entry point.
31833This makes the sequence of NOPs not consecutive when a global entry point
31834is generated. Without this option the NOPs are emitted directly before and
31835after the local entry point, making them consecutive but moving global and
31836local entry point further apart. If only a single entry point is generated
31837this option has no effect.
31838
d77de738
ML
31839@opindex misel
31840@opindex mno-isel
ddf6fe37
AA
31841@item -misel
31842@itemx -mno-isel
d77de738
ML
31843This switch enables or disables the generation of ISEL instructions.
31844
d77de738
ML
31845@opindex mvsx
31846@opindex mno-vsx
ddf6fe37
AA
31847@item -mvsx
31848@itemx -mno-vsx
d77de738
ML
31849Generate code that uses (does not use) vector/scalar (VSX)
31850instructions, and also enable the use of built-in functions that allow
31851more direct access to the VSX instruction set.
31852
d77de738
ML
31853@opindex mcrypto
31854@opindex mno-crypto
ddf6fe37
AA
31855@item -mcrypto
31856@itemx -mno-crypto
d77de738
ML
31857Enable the use (disable) of the built-in functions that allow direct
31858access to the cryptographic instructions that were added in version
318592.07 of the PowerPC ISA.
31860
d77de738
ML
31861@opindex mhtm
31862@opindex mno-htm
ddf6fe37
AA
31863@item -mhtm
31864@itemx -mno-htm
d77de738
ML
31865Enable (disable) the use of the built-in functions that allow direct
31866access to the Hardware Transactional Memory (HTM) instructions that
31867were added in version 2.07 of the PowerPC ISA.
31868
d77de738
ML
31869@opindex mpower8-fusion
31870@opindex mno-power8-fusion
ddf6fe37
AA
31871@item -mpower8-fusion
31872@itemx -mno-power8-fusion
d77de738
ML
31873Generate code that keeps (does not keeps) some integer operations
31874adjacent so that the instructions can be fused together on power8 and
31875later processors.
31876
d77de738
ML
31877@opindex mquad-memory
31878@opindex mno-quad-memory
ddf6fe37
AA
31879@item -mquad-memory
31880@itemx -mno-quad-memory
d77de738
ML
31881Generate code that uses (does not use) the non-atomic quad word memory
31882instructions. The @option{-mquad-memory} option requires use of
3188364-bit mode.
31884
d77de738
ML
31885@opindex mquad-memory-atomic
31886@opindex mno-quad-memory-atomic
ddf6fe37
AA
31887@item -mquad-memory-atomic
31888@itemx -mno-quad-memory-atomic
d77de738
ML
31889Generate code that uses (does not use) the atomic quad word memory
31890instructions. The @option{-mquad-memory-atomic} option requires use of
3189164-bit mode.
31892
d77de738
ML
31893@opindex mfloat128
31894@opindex mno-float128
ddf6fe37
AA
31895@item -mfloat128
31896@itemx -mno-float128
d77de738
ML
31897Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
31898and use either software emulation for IEEE 128-bit floating point or
31899hardware instructions.
31900
31901The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
31902128-bit floating point support. The IEEE 128-bit floating point is only
31903supported on Linux.
31904
31905The default for @option{-mfloat128} is enabled on PowerPC Linux
31906systems using the VSX instruction set, and disabled on other systems.
31907
438ef143
KL
31908If you use the ISA 3.0 instruction set (@option{-mcpu=power9}) on a
3190964-bit system, the IEEE 128-bit floating point support will also enable
31910the generation of ISA 3.0 IEEE 128-bit floating point instructions.
31911Otherwise, if you do not specify to generate ISA 3.0 instructions or you
31912are targeting a 32-bit big endian system, IEEE 128-bit floating point
31913will be done with software emulation.
d77de738 31914
d77de738
ML
31915@opindex mfloat128-hardware
31916@opindex mno-float128-hardware
ddf6fe37
AA
31917@item -mfloat128-hardware
31918@itemx -mno-float128-hardware
d77de738
ML
31919Enable/disable using ISA 3.0 hardware instructions to support the
31920@var{__float128} data type.
31921
31922The default for @option{-mfloat128-hardware} is enabled on PowerPC
31923Linux systems using the ISA 3.0 instruction set, and disabled on other
31924systems.
31925
d77de738
ML
31926@opindex m32
31927@opindex m64
ddf6fe37
AA
31928@item -m32
31929@itemx -m64
d77de738
ML
31930Generate code for 32-bit or 64-bit environments of Darwin and SVR4
31931targets (including GNU/Linux). The 32-bit environment sets int, long
31932and pointer to 32 bits and generates code that runs on any PowerPC
31933variant. The 64-bit environment sets int to 32 bits and long and
31934pointer to 64 bits, and generates code for PowerPC64, as for
31935@option{-mpowerpc64}.
31936
d77de738
ML
31937@opindex mfull-toc
31938@opindex mno-fp-in-toc
31939@opindex mno-sum-in-toc
31940@opindex mminimal-toc
ddf6fe37
AA
31941@item -mfull-toc
31942@itemx -mno-fp-in-toc
31943@itemx -mno-sum-in-toc
31944@itemx -mminimal-toc
d77de738
ML
31945Modify generation of the TOC (Table Of Contents), which is created for
31946every executable file. The @option{-mfull-toc} option is selected by
31947default. In that case, GCC allocates at least one TOC entry for
31948each unique non-automatic variable reference in your program. GCC
31949also places floating-point constants in the TOC@. However, only
3195016,384 entries are available in the TOC@.
31951
31952If you receive a linker error message that saying you have overflowed
31953the available TOC space, you can reduce the amount of TOC space used
31954with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
31955@option{-mno-fp-in-toc} prevents GCC from putting floating-point
31956constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
31957generate code to calculate the sum of an address and a constant at
31958run time instead of putting that sum into the TOC@. You may specify one
31959or both of these options. Each causes GCC to produce very slightly
31960slower and larger code at the expense of conserving TOC space.
31961
31962If you still run out of space in the TOC even when you specify both of
31963these options, specify @option{-mminimal-toc} instead. This option causes
31964GCC to make only one TOC entry for every file. When you specify this
31965option, GCC produces code that is slower and larger but which
31966uses extremely little TOC space. You may wish to use this option
31967only on files that contain less frequently-executed code.
31968
d77de738
ML
31969@opindex maix64
31970@opindex maix32
ddf6fe37
AA
31971@item -maix64
31972@itemx -maix32
d77de738
ML
31973Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
31974@code{long} type, and the infrastructure needed to support them.
31975Specifying @option{-maix64} implies @option{-mpowerpc64},
31976while @option{-maix32} disables the 64-bit ABI and
31977implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
31978
d77de738
ML
31979@opindex mxl-compat
31980@opindex mno-xl-compat
ddf6fe37
AA
31981@item -mxl-compat
31982@itemx -mno-xl-compat
d77de738
ML
31983Produce code that conforms more closely to IBM XL compiler semantics
31984when using AIX-compatible ABI@. Pass floating-point arguments to
31985prototyped functions beyond the register save area (RSA) on the stack
31986in addition to argument FPRs. Do not assume that most significant
31987double in 128-bit long double value is properly rounded when comparing
31988values and converting to double. Use XL symbol names for long double
31989support routines.
31990
31991The AIX calling convention was extended but not initially documented to
31992handle an obscure K&R C case of calling a function that takes the
31993address of its arguments with fewer arguments than declared. IBM XL
31994compilers access floating-point arguments that do not fit in the
31995RSA from the stack when a subroutine is compiled without
31996optimization. Because always storing floating-point arguments on the
31997stack is inefficient and rarely needed, this option is not enabled by
31998default and only is necessary when calling subroutines compiled by IBM
31999XL compilers without optimization.
32000
d77de738 32001@opindex mpe
ddf6fe37 32002@item -mpe
d77de738
ML
32003Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
32004application written to use message passing with special startup code to
32005enable the application to run. The system must have PE installed in the
32006standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
32007must be overridden with the @option{-specs=} option to specify the
32008appropriate directory location. The Parallel Environment does not
32009support threads, so the @option{-mpe} option and the @option{-pthread}
32010option are incompatible.
32011
d77de738
ML
32012@opindex malign-natural
32013@opindex malign-power
ddf6fe37
AA
32014@item -malign-natural
32015@itemx -malign-power
d77de738
ML
32016On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
32017@option{-malign-natural} overrides the ABI-defined alignment of larger
32018types, such as floating-point doubles, on their natural size-based boundary.
32019The option @option{-malign-power} instructs GCC to follow the ABI-specified
32020alignment rules. GCC defaults to the standard alignment defined in the ABI@.
32021
32022On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
32023is not supported.
32024
d77de738
ML
32025@opindex msoft-float
32026@opindex mhard-float
ddf6fe37
AA
32027@item -msoft-float
32028@itemx -mhard-float
d77de738
ML
32029Generate code that does not use (uses) the floating-point register set.
32030Software floating-point emulation is provided if you use the
32031@option{-msoft-float} option, and pass the option to GCC when linking.
32032
d77de738
ML
32033@opindex mmultiple
32034@opindex mno-multiple
ddf6fe37
AA
32035@item -mmultiple
32036@itemx -mno-multiple
d77de738
ML
32037Generate code that uses (does not use) the load multiple word
32038instructions and the store multiple word instructions. These
32039instructions are generated by default on POWER systems, and not
32040generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
32041PowerPC systems, since those instructions do not work when the
32042processor is in little-endian mode. The exceptions are PPC740 and
32043PPC750 which permit these instructions in little-endian mode.
32044
d77de738
ML
32045@opindex mupdate
32046@opindex mno-update
ddf6fe37
AA
32047@item -mupdate
32048@itemx -mno-update
d77de738
ML
32049Generate code that uses (does not use) the load or store instructions
32050that update the base register to the address of the calculated memory
32051location. These instructions are generated by default. If you use
32052@option{-mno-update}, there is a small window between the time that the
32053stack pointer is updated and the address of the previous frame is
32054stored, which means code that walks the stack frame across interrupts or
32055signals may get corrupted data.
32056
d77de738
ML
32057@opindex mavoid-indexed-addresses
32058@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
32059@item -mavoid-indexed-addresses
32060@itemx -mno-avoid-indexed-addresses
d77de738
ML
32061Generate code that tries to avoid (not avoid) the use of indexed load
32062or store instructions. These instructions can incur a performance
32063penalty on Power6 processors in certain situations, such as when
32064stepping through large arrays that cross a 16M boundary. This option
32065is enabled by default when targeting Power6 and disabled otherwise.
32066
d77de738
ML
32067@opindex mfused-madd
32068@opindex mno-fused-madd
ddf6fe37
AA
32069@item -mfused-madd
32070@itemx -mno-fused-madd
d77de738
ML
32071Generate code that uses (does not use) the floating-point multiply and
32072accumulate instructions. These instructions are generated by default
32073if hardware floating point is used. The machine-dependent
32074@option{-mfused-madd} option is now mapped to the machine-independent
32075@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
32076mapped to @option{-ffp-contract=off}.
32077
d77de738
ML
32078@opindex mmulhw
32079@opindex mno-mulhw
ddf6fe37
AA
32080@item -mmulhw
32081@itemx -mno-mulhw
d77de738
ML
32082Generate code that uses (does not use) the half-word multiply and
32083multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
32084These instructions are generated by default when targeting those
32085processors.
32086
d77de738
ML
32087@opindex mdlmzb
32088@opindex mno-dlmzb
ddf6fe37
AA
32089@item -mdlmzb
32090@itemx -mno-dlmzb
d77de738
ML
32091Generate code that uses (does not use) the string-search @samp{dlmzb}
32092instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
32093generated by default when targeting those processors.
32094
d77de738
ML
32095@opindex mno-bit-align
32096@opindex mbit-align
ddf6fe37
AA
32097@item -mno-bit-align
32098@itemx -mbit-align
d77de738
ML
32099On System V.4 and embedded PowerPC systems do not (do) force structures
32100and unions that contain bit-fields to be aligned to the base type of the
32101bit-field.
32102
32103For example, by default a structure containing nothing but 8
32104@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
32105boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
32106the structure is aligned to a 1-byte boundary and is 1 byte in
32107size.
32108
d77de738
ML
32109@opindex mno-strict-align
32110@opindex mstrict-align
ddf6fe37
AA
32111@item -mno-strict-align
32112@itemx -mstrict-align
d77de738
ML
32113On System V.4 and embedded PowerPC systems do not (do) assume that
32114unaligned memory references are handled by the system.
32115
d77de738
ML
32116@opindex mrelocatable
32117@opindex mno-relocatable
ddf6fe37
AA
32118@item -mrelocatable
32119@itemx -mno-relocatable
d77de738
ML
32120Generate code that allows (does not allow) a static executable to be
32121relocated to a different address at run time. A simple embedded
32122PowerPC system loader should relocate the entire contents of
32123@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
32124a table of 32-bit addresses generated by this option. For this to
32125work, all objects linked together must be compiled with
32126@option{-mrelocatable} or @option{-mrelocatable-lib}.
32127@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
32128
d77de738
ML
32129@opindex mrelocatable-lib
32130@opindex mno-relocatable-lib
ddf6fe37
AA
32131@item -mrelocatable-lib
32132@itemx -mno-relocatable-lib
d77de738
ML
32133Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
32134@code{.fixup} section to allow static executables to be relocated at
32135run time, but @option{-mrelocatable-lib} does not use the smaller stack
32136alignment of @option{-mrelocatable}. Objects compiled with
32137@option{-mrelocatable-lib} may be linked with objects compiled with
32138any combination of the @option{-mrelocatable} options.
32139
d77de738
ML
32140@opindex mno-toc
32141@opindex mtoc
ddf6fe37
AA
32142@item -mno-toc
32143@itemx -mtoc
d77de738
ML
32144On System V.4 and embedded PowerPC systems do not (do) assume that
32145register 2 contains a pointer to a global area pointing to the addresses
32146used in the program.
32147
d77de738
ML
32148@opindex mlittle
32149@opindex mlittle-endian
ddf6fe37
AA
32150@item -mlittle
32151@itemx -mlittle-endian
d77de738
ML
32152On System V.4 and embedded PowerPC systems compile code for the
32153processor in little-endian mode. The @option{-mlittle-endian} option is
32154the same as @option{-mlittle}.
32155
d77de738
ML
32156@opindex mbig
32157@opindex mbig-endian
ddf6fe37
AA
32158@item -mbig
32159@itemx -mbig-endian
d77de738
ML
32160On System V.4 and embedded PowerPC systems compile code for the
32161processor in big-endian mode. The @option{-mbig-endian} option is
32162the same as @option{-mbig}.
32163
d77de738 32164@opindex mdynamic-no-pic
ddf6fe37 32165@item -mdynamic-no-pic
a335cf24 32166On Darwin / macOS systems, compile code so that it is not
d77de738
ML
32167relocatable, but that its external references are relocatable. The
32168resulting code is suitable for applications, but not shared
32169libraries.
32170
d77de738 32171@opindex msingle-pic-base
ddf6fe37 32172@item -msingle-pic-base
d77de738
ML
32173Treat the register used for PIC addressing as read-only, rather than
32174loading it in the prologue for each function. The runtime system is
32175responsible for initializing this register with an appropriate value
32176before execution begins.
32177
d77de738 32178@opindex mprioritize-restricted-insns
ddf6fe37 32179@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
32180This option controls the priority that is assigned to
32181dispatch-slot restricted instructions during the second scheduling
32182pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
a0e64a04 32183or @samp{2} to assign no, highest, or second-highest (respectively)
d77de738
ML
32184priority to dispatch-slot restricted
32185instructions.
32186
d77de738 32187@opindex msched-costly-dep
ddf6fe37 32188@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
32189This option controls which dependences are considered costly
32190by the target during instruction scheduling. The argument
32191@var{dependence_type} takes one of the following values:
32192
32193@table @asis
32194@item @samp{no}
32195No dependence is costly.
32196
32197@item @samp{all}
32198All dependences are costly.
32199
32200@item @samp{true_store_to_load}
32201A true dependence from store to load is costly.
32202
32203@item @samp{store_to_load}
32204Any dependence from store to load is costly.
32205
32206@item @var{number}
a0e64a04 32207Any dependence for which the latency is greater than or equal to
d77de738
ML
32208@var{number} is costly.
32209@end table
32210
d77de738 32211@opindex minsert-sched-nops
ddf6fe37 32212@item -minsert-sched-nops=@var{scheme}
d77de738
ML
32213This option controls which NOP insertion scheme is used during
32214the second scheduling pass. The argument @var{scheme} takes one of the
32215following values:
32216
32217@table @asis
32218@item @samp{no}
32219Don't insert NOPs.
32220
32221@item @samp{pad}
32222Pad with NOPs any dispatch group that has vacant issue slots,
32223according to the scheduler's grouping.
32224
32225@item @samp{regroup_exact}
32226Insert NOPs to force costly dependent insns into
32227separate groups. Insert exactly as many NOPs as needed to force an insn
32228to a new group, according to the estimated processor grouping.
32229
32230@item @var{number}
32231Insert NOPs to force costly dependent insns into
32232separate groups. Insert @var{number} NOPs to force an insn to a new group.
32233@end table
32234
d77de738 32235@opindex mcall-sysv
ddf6fe37 32236@item -mcall-sysv
d77de738
ML
32237On System V.4 and embedded PowerPC systems compile code using calling
32238conventions that adhere to the March 1995 draft of the System V
32239Application Binary Interface, PowerPC processor supplement. This is the
32240default unless you configured GCC using @samp{powerpc-*-eabiaix}.
32241
d77de738
ML
32242@opindex mcall-sysv-eabi
32243@opindex mcall-eabi
ddf6fe37
AA
32244@item -mcall-sysv-eabi
32245@itemx -mcall-eabi
d77de738
ML
32246Specify both @option{-mcall-sysv} and @option{-meabi} options.
32247
d77de738 32248@opindex mcall-sysv-noeabi
ddf6fe37 32249@item -mcall-sysv-noeabi
d77de738
ML
32250Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
32251
d7971cf7 32252@opindex mcall-aixdesc
ddf6fe37 32253@item -mcall-aixdesc
d77de738
ML
32254On System V.4 and embedded PowerPC systems compile code for the AIX
32255operating system.
32256
d77de738 32257@opindex mcall-linux
ddf6fe37 32258@item -mcall-linux
d77de738
ML
32259On System V.4 and embedded PowerPC systems compile code for the
32260Linux-based GNU system.
32261
d77de738 32262@opindex mcall-freebsd
ddf6fe37 32263@item -mcall-freebsd
d77de738
ML
32264On System V.4 and embedded PowerPC systems compile code for the
32265FreeBSD operating system.
32266
d77de738 32267@opindex mcall-netbsd
ddf6fe37 32268@item -mcall-netbsd
d77de738
ML
32269On System V.4 and embedded PowerPC systems compile code for the
32270NetBSD operating system.
32271
d7971cf7 32272@opindex mcall-openbsd
ddf6fe37 32273@item -mcall-openbsd
d77de738
ML
32274On System V.4 and embedded PowerPC systems compile code for the
32275OpenBSD operating system.
32276
d77de738 32277@opindex mtraceback
ddf6fe37 32278@item -mtraceback=@var{traceback_type}
d77de738
ML
32279Select the type of traceback table. Valid values for @var{traceback_type}
32280are @samp{full}, @samp{part}, and @samp{no}.
32281
d77de738 32282@opindex maix-struct-return
ddf6fe37 32283@item -maix-struct-return
d77de738
ML
32284Return all structures in memory (as specified by the AIX ABI)@.
32285
d77de738 32286@opindex msvr4-struct-return
ddf6fe37 32287@item -msvr4-struct-return
d77de738
ML
32288Return structures smaller than 8 bytes in registers (as specified by the
32289SVR4 ABI)@.
32290
d77de738 32291@opindex mabi
ddf6fe37 32292@item -mabi=@var{abi-type}
d77de738
ML
32293Extend the current ABI with a particular extension, or remove such extension.
32294Valid values are: @samp{altivec}, @samp{no-altivec},
32295@samp{ibmlongdouble}, @samp{ieeelongdouble},
32296@samp{elfv1}, @samp{elfv2},
32297and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
32298
d77de738 32299@opindex mabi=ibmlongdouble
ddf6fe37 32300@item -mabi=ibmlongdouble
d77de738
ML
32301Change the current ABI to use IBM extended-precision long double.
32302This is not likely to work if your system defaults to using IEEE
32303extended-precision long double. If you change the long double type
027491d7
SL
32304from IEEE extended-precision, the compiler issues a warning unless
32305you use the @option{-Wno-psabi} option (@pxref{Warning Options}).
32306Requires @option{-mlong-double-128} to be enabled.
d77de738 32307
d77de738 32308@opindex mabi=ieeelongdouble
ddf6fe37 32309@item -mabi=ieeelongdouble
d77de738
ML
32310Change the current ABI to use IEEE extended-precision long double.
32311This is not likely to work if your system defaults to using IBM
32312extended-precision long double. If you change the long double type
027491d7
SL
32313from IBM extended-precision, the compiler issues a warning unless
32314you use the @option{-Wno-psabi} option (@pxref{Warning Options}).
32315Requires @option{-mlong-double-128} to be enabled.
d77de738 32316
d77de738 32317@opindex mabi=elfv1
ddf6fe37 32318@item -mabi=elfv1
d77de738
ML
32319Change the current ABI to use the ELFv1 ABI.
32320This is the default ABI for big-endian PowerPC 64-bit Linux.
32321Overriding the default ABI requires special system support and is
32322likely to fail in spectacular ways.
32323
d77de738 32324@opindex mabi=elfv2
ddf6fe37 32325@item -mabi=elfv2
d77de738
ML
32326Change the current ABI to use the ELFv2 ABI.
32327This is the default ABI for little-endian PowerPC 64-bit Linux.
32328Overriding the default ABI requires special system support and is
32329likely to fail in spectacular ways.
32330
d77de738
ML
32331@opindex mgnu-attribute
32332@opindex mno-gnu-attribute
ddf6fe37
AA
32333@item -mgnu-attribute
32334@itemx -mno-gnu-attribute
d77de738
ML
32335Emit .gnu_attribute assembly directives to set tag/value pairs in a
32336.gnu.attributes section that specify ABI variations in function
32337parameters or return values.
32338
d77de738
ML
32339@opindex mprototype
32340@opindex mno-prototype
ddf6fe37
AA
32341@item -mprototype
32342@itemx -mno-prototype
d77de738
ML
32343On System V.4 and embedded PowerPC systems assume that all calls to
32344variable argument functions are properly prototyped. Otherwise, the
32345compiler must insert an instruction before every non-prototyped call to
32346set or clear bit 6 of the condition code register (@code{CR}) to
32347indicate whether floating-point values are passed in the floating-point
32348registers in case the function takes variable arguments. With
32349@option{-mprototype}, only calls to prototyped variable argument functions
32350set or clear the bit.
32351
d77de738 32352@opindex msim
ddf6fe37 32353@item -msim
d77de738
ML
32354On embedded PowerPC systems, assume that the startup module is called
32355@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
32356@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
32357configurations.
32358
d77de738 32359@opindex mmvme
ddf6fe37 32360@item -mmvme
d77de738
ML
32361On embedded PowerPC systems, assume that the startup module is called
32362@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
32363@file{libc.a}.
32364
d77de738 32365@opindex mads
ddf6fe37 32366@item -mads
d77de738
ML
32367On embedded PowerPC systems, assume that the startup module is called
32368@file{crt0.o} and the standard C libraries are @file{libads.a} and
32369@file{libc.a}.
32370
d77de738 32371@opindex myellowknife
ddf6fe37 32372@item -myellowknife
d77de738
ML
32373On embedded PowerPC systems, assume that the startup module is called
32374@file{crt0.o} and the standard C libraries are @file{libyk.a} and
32375@file{libc.a}.
32376
d77de738 32377@opindex mvxworks
ddf6fe37 32378@item -mvxworks
d77de738
ML
32379On System V.4 and embedded PowerPC systems, specify that you are
32380compiling for a VxWorks system.
32381
d77de738 32382@opindex memb
ddf6fe37 32383@item -memb
d77de738
ML
32384On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
32385header to indicate that @samp{eabi} extended relocations are used.
32386
d77de738
ML
32387@opindex meabi
32388@opindex mno-eabi
ddf6fe37
AA
32389@item -meabi
32390@itemx -mno-eabi
d77de738
ML
32391On System V.4 and embedded PowerPC systems do (do not) adhere to the
32392Embedded Applications Binary Interface (EABI), which is a set of
32393modifications to the System V.4 specifications. Selecting @option{-meabi}
32394means that the stack is aligned to an 8-byte boundary, a function
32395@code{__eabi} is called from @code{main} to set up the EABI
32396environment, and the @option{-msdata} option can use both @code{r2} and
32397@code{r13} to point to two separate small data areas. Selecting
32398@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
32399no EABI initialization function is called from @code{main}, and the
32400@option{-msdata} option only uses @code{r13} to point to a single
32401small data area. The @option{-meabi} option is on by default if you
32402configured GCC using one of the @samp{powerpc*-*-eabi*} options.
32403
d77de738 32404@opindex msdata=eabi
ddf6fe37 32405@item -msdata=eabi
d77de738
ML
32406On System V.4 and embedded PowerPC systems, put small initialized
32407@code{const} global and static data in the @code{.sdata2} section, which
32408is pointed to by register @code{r2}. Put small initialized
32409non-@code{const} global and static data in the @code{.sdata} section,
32410which is pointed to by register @code{r13}. Put small uninitialized
32411global and static data in the @code{.sbss} section, which is adjacent to
32412the @code{.sdata} section. The @option{-msdata=eabi} option is
32413incompatible with the @option{-mrelocatable} option. The
32414@option{-msdata=eabi} option also sets the @option{-memb} option.
32415
d77de738 32416@opindex msdata=sysv
ddf6fe37 32417@item -msdata=sysv
d77de738
ML
32418On System V.4 and embedded PowerPC systems, put small global and static
32419data in the @code{.sdata} section, which is pointed to by register
32420@code{r13}. Put small uninitialized global and static data in the
32421@code{.sbss} section, which is adjacent to the @code{.sdata} section.
32422The @option{-msdata=sysv} option is incompatible with the
32423@option{-mrelocatable} option.
32424
d77de738
ML
32425@opindex msdata=default
32426@opindex msdata
ddf6fe37
AA
32427@item -msdata=default
32428@itemx -msdata
d77de738
ML
32429On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
32430compile code the same as @option{-msdata=eabi}, otherwise compile code the
32431same as @option{-msdata=sysv}.
32432
d77de738 32433@opindex msdata=data
ddf6fe37 32434@item -msdata=data
d77de738
ML
32435On System V.4 and embedded PowerPC systems, put small global
32436data in the @code{.sdata} section. Put small uninitialized global
32437data in the @code{.sbss} section. Do not use register @code{r13}
32438to address small data however. This is the default behavior unless
32439other @option{-msdata} options are used.
32440
d77de738
ML
32441@opindex msdata=none
32442@opindex mno-sdata
ddf6fe37
AA
32443@item -msdata=none
32444@itemx -mno-sdata
d77de738
ML
32445On embedded PowerPC systems, put all initialized global and static data
32446in the @code{.data} section, and all uninitialized data in the
32447@code{.bss} section.
32448
d77de738
ML
32449@opindex mreadonly-in-sdata
32450@opindex mno-readonly-in-sdata
ddf6fe37 32451@item -mreadonly-in-sdata
d77de738
ML
32452Put read-only objects in the @code{.sdata} section as well. This is the
32453default.
32454
d77de738 32455@opindex mblock-move-inline-limit
ddf6fe37 32456@item -mblock-move-inline-limit=@var{num}
d77de738
ML
32457Inline all block moves (such as calls to @code{memcpy} or structure
32458copies) less than or equal to @var{num} bytes. The minimum value for
32459@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
32460targets. The default value is target-specific.
32461
d77de738 32462@opindex mblock-compare-inline-limit
ddf6fe37 32463@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
32464Generate non-looping inline code for all block compares (such as calls
32465to @code{memcmp} or structure compares) less than or equal to @var{num}
32466bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
32467block compare is disabled. The default value is target-specific.
32468
d77de738 32469@opindex mblock-compare-inline-loop-limit
ddf6fe37 32470@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
32471Generate an inline expansion using loop code for all block compares that
32472are less than or equal to @var{num} bytes, but greater than the limit
32473for non-loop inline block compare expansion. If the block length is not
32474constant, at most @var{num} bytes will be compared before @code{memcmp}
32475is called to compare the remainder of the block. The default value is
32476target-specific.
32477
d77de738 32478@opindex mstring-compare-inline-limit
ddf6fe37 32479@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
32480Compare at most @var{num} string bytes with inline code.
32481If the difference or end of string is not found at the
32482end of the inline compare a call to @code{strcmp} or @code{strncmp} will
32483take care of the rest of the comparison. The default is 64 bytes.
32484
d77de738
ML
32485@opindex G
32486@cindex smaller data references (PowerPC)
32487@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 32488@item -G @var{num}
d77de738
ML
32489On embedded PowerPC systems, put global and static items less than or
32490equal to @var{num} bytes into the small data or BSS sections instead of
32491the normal data or BSS section. By default, @var{num} is 8. The
32492@option{-G @var{num}} switch is also passed to the linker.
32493All modules should be compiled with the same @option{-G @var{num}} value.
32494
d77de738
ML
32495@opindex mregnames
32496@opindex mno-regnames
ddf6fe37
AA
32497@item -mregnames
32498@itemx -mno-regnames
d77de738
ML
32499On System V.4 and embedded PowerPC systems do (do not) emit register
32500names in the assembly language output using symbolic forms.
32501
d77de738
ML
32502@opindex mlongcall
32503@opindex mno-longcall
ddf6fe37
AA
32504@item -mlongcall
32505@itemx -mno-longcall
d77de738
ML
32506By default assume that all calls are far away so that a longer and more
32507expensive calling sequence is required. This is required for calls
32508farther than 32 megabytes (33,554,432 bytes) from the current location.
32509A short call is generated if the compiler knows
32510the call cannot be that far away. This setting can be overridden by
32511the @code{shortcall} function attribute, or by @code{#pragma
32512longcall(0)}.
32513
32514Some linkers are capable of detecting out-of-range calls and generating
32515glue code on the fly. On these systems, long calls are unnecessary and
32516generate slower code. As of this writing, the AIX linker can do this,
32517as can the GNU linker for PowerPC/64. It is planned to add this feature
32518to the GNU linker for 32-bit PowerPC systems as well.
32519
32520On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
32521GCC can generate long calls using an inline PLT call sequence (see
32522@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
32523ELFv1 (big-endian) do not support inline PLT calls.
32524
32525On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
32526callee, L42}, plus a @dfn{branch island} (glue code). The two target
32527addresses represent the callee and the branch island. The
32528Darwin/PPC linker prefers the first address and generates a @code{bl
32529callee} if the PPC @code{bl} instruction reaches the callee directly;
32530otherwise, the linker generates @code{bl L42} to call the branch
32531island. The branch island is appended to the body of the
32532calling function; it computes the full 32-bit address of the callee
32533and jumps to it.
32534
32535On Mach-O (Darwin) systems, this option directs the compiler emit to
32536the glue for every direct call, and the Darwin linker decides whether
32537to use or discard it.
32538
32539In the future, GCC may ignore all longcall specifications
32540when the linker is known to generate glue.
32541
d77de738
ML
32542@opindex mpltseq
32543@opindex mno-pltseq
ddf6fe37
AA
32544@item -mpltseq
32545@itemx -mno-pltseq
d77de738
ML
32546Implement (do not implement) -fno-plt and long calls using an inline
32547PLT call sequence that supports lazy linking and long calls to
32548functions in dlopen'd shared libraries. Inline PLT calls are only
32549supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
32550linkers, and are enabled by default if the support is detected when
32551configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
32552configured with @option{--enable-secureplt}. @option{-mpltseq} code
32553and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
32554linked together.
32555
d77de738
ML
32556@opindex mtls-markers
32557@opindex mno-tls-markers
ddf6fe37
AA
32558@item -mtls-markers
32559@itemx -mno-tls-markers
d77de738
ML
32560Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
32561specifying the function argument. The relocation allows the linker to
32562reliably associate function call with argument setup instructions for
32563TLS optimization, which in turn allows GCC to better schedule the
32564sequence.
32565
ddf6fe37 32566@opindex mrecip
d77de738
ML
32567@item -mrecip
32568@itemx -mno-recip
d77de738
ML
32569This option enables use of the reciprocal estimate and
32570reciprocal square root estimate instructions with additional
32571Newton-Raphson steps to increase precision instead of doing a divide or
32572square root and divide for floating-point arguments. You should use
32573the @option{-ffast-math} option when using @option{-mrecip} (or at
32574least @option{-funsafe-math-optimizations},
32575@option{-ffinite-math-only}, @option{-freciprocal-math} and
32576@option{-fno-trapping-math}). Note that while the throughput of the
32577sequence is generally higher than the throughput of the non-reciprocal
32578instruction, the precision of the sequence can be decreased by up to 2
32579ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
32580roots.
32581
d77de738 32582@opindex mrecip=opt
ddf6fe37 32583@item -mrecip=@var{opt}
d77de738
ML
32584This option controls which reciprocal estimate instructions
32585may be used. @var{opt} is a comma-separated list of options, which may
32586be preceded by a @code{!} to invert the option:
32587
32588@table @samp
32589
32590@item all
32591Enable all estimate instructions.
32592
a0e64a04 32593@item default
d77de738
ML
32594Enable the default instructions, equivalent to @option{-mrecip}.
32595
a0e64a04 32596@item none
d77de738
ML
32597Disable all estimate instructions, equivalent to @option{-mno-recip}.
32598
a0e64a04
PN
32599@item div
32600Enable the reciprocal approximation instructions for both
d77de738
ML
32601single and double precision.
32602
a0e64a04 32603@item divf
d77de738
ML
32604Enable the single-precision reciprocal approximation instructions.
32605
a0e64a04 32606@item divd
d77de738
ML
32607Enable the double-precision reciprocal approximation instructions.
32608
a0e64a04 32609@item rsqrt
d77de738
ML
32610Enable the reciprocal square root approximation instructions for both
32611single and double precision.
32612
a0e64a04 32613@item rsqrtf
d77de738
ML
32614Enable the single-precision reciprocal square root approximation instructions.
32615
a0e64a04 32616@item rsqrtd
d77de738
ML
32617Enable the double-precision reciprocal square root approximation instructions.
32618
32619@end table
32620
32621So, for example, @option{-mrecip=all,!rsqrtd} enables
32622all of the reciprocal estimate instructions, except for the
32623@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
32624which handle the double-precision reciprocal square root calculations.
32625
ddf6fe37 32626@opindex mrecip-precision
d77de738
ML
32627@item -mrecip-precision
32628@itemx -mno-recip-precision
d77de738
ML
32629Assume (do not assume) that the reciprocal estimate instructions
32630provide higher-precision estimates than is mandated by the PowerPC
32631ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
32632@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
32633The double-precision square root estimate instructions are not generated by
32634default on low-precision machines, since they do not provide an
32635estimate that converges after three steps.
32636
d77de738 32637@opindex mveclibabi
ddf6fe37 32638@item -mveclibabi=@var{type}
d77de738
ML
32639Specifies the ABI type to use for vectorizing intrinsics using an
32640external library. The only type supported at present is @samp{mass},
32641which specifies to use IBM's Mathematical Acceleration Subsystem
32642(MASS) libraries for vectorizing intrinsics using external libraries.
32643GCC currently emits calls to @code{acosd2}, @code{acosf4},
32644@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
32645@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
32646@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
32647@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
32648@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
32649@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
32650@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
32651@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
32652@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
32653@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
32654@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
32655@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
32656@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
32657for power7. Both @option{-ftree-vectorize} and
32658@option{-funsafe-math-optimizations} must also be enabled. The MASS
32659libraries must be specified at link time.
32660
ddf6fe37 32661@opindex mfriz
d77de738
ML
32662@item -mfriz
32663@itemx -mno-friz
d77de738
ML
32664Generate (do not generate) the @code{friz} instruction when the
32665@option{-funsafe-math-optimizations} option is used to optimize
32666rounding of floating-point values to 64-bit integer and back to floating
32667point. The @code{friz} instruction does not return the same value if
32668the floating-point number is too large to fit in an integer.
32669
ddf6fe37 32670@opindex mpointers-to-nested-functions
d77de738
ML
32671@item -mpointers-to-nested-functions
32672@itemx -mno-pointers-to-nested-functions
d77de738
ML
32673Generate (do not generate) code to load up the static chain register
32674(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
32675systems where a function pointer points to a 3-word descriptor giving
32676the function address, TOC value to be loaded in register @code{r2}, and
32677static chain value to be loaded in register @code{r11}. The
32678@option{-mpointers-to-nested-functions} is on by default. You cannot
32679call through pointers to nested functions or pointers
32680to functions compiled in other languages that use the static chain if
32681you use @option{-mno-pointers-to-nested-functions}.
32682
ddf6fe37 32683@opindex msave-toc-indirect
d77de738
ML
32684@item -msave-toc-indirect
32685@itemx -mno-save-toc-indirect
d77de738
ML
32686Generate (do not generate) code to save the TOC value in the reserved
32687stack location in the function prologue if the function calls through
32688a pointer on AIX and 64-bit Linux systems. If the TOC value is not
32689saved in the prologue, it is saved just before the call through the
32690pointer. The @option{-mno-save-toc-indirect} option is the default.
32691
ddf6fe37 32692@opindex mcompat-align-parm
d77de738
ML
32693@item -mcompat-align-parm
32694@itemx -mno-compat-align-parm
d77de738
ML
32695Generate (do not generate) code to pass structure parameters with a
32696maximum alignment of 64 bits, for compatibility with older versions
32697of GCC.
32698
32699Older versions of GCC (prior to 4.9.0) incorrectly did not align a
32700structure parameter on a 128-bit boundary when that structure contained
32701a member requiring 128-bit alignment. This is corrected in more
32702recent versions of GCC. This option may be used to generate code
32703that is compatible with functions compiled with older versions of
32704GCC.
32705
32706The @option{-mno-compat-align-parm} option is the default.
32707
d77de738
ML
32708@opindex mstack-protector-guard
32709@opindex mstack-protector-guard-reg
32710@opindex mstack-protector-guard-offset
ddf6fe37
AA
32711@item -mstack-protector-guard=@var{guard}
32712@itemx -mstack-protector-guard-reg=@var{reg}
32713@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
32714Generate stack protection code using canary at @var{guard}. Supported
32715locations are @samp{global} for global canary or @samp{tls} for per-thread
32716canary in the TLS block (the default with GNU libc version 2.4 or later).
32717
32718With the latter choice the options
32719@option{-mstack-protector-guard-reg=@var{reg}} and
32720@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
32721which register to use as base register for reading the canary, and from what
32722offset from that base register. The default for those is as specified in the
fa878dc8 32723relevant ABI.
d77de738 32724
d77de738
ML
32725@opindex mpcrel
32726@opindex mno-pcrel
ddf6fe37
AA
32727@item -mpcrel
32728@itemx -mno-pcrel
d77de738
ML
32729Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
32730option requires that the medium code model (@option{-mcmodel=medium})
32731and prefixed addressing (@option{-mprefixed}) options are enabled.
32732
d77de738
ML
32733@opindex mprefixed
32734@opindex mno-prefixed
ddf6fe37
AA
32735@item -mprefixed
32736@itemx -mno-prefixed
d77de738
ML
32737Generate (do not generate) addressing modes using prefixed load and
32738store instructions. The @option{-mprefixed} option requires that
32739the option @option{-mcpu=power10} (or later) is enabled.
32740
d77de738
ML
32741@opindex mmma
32742@opindex mno-mma
ddf6fe37
AA
32743@item -mmma
32744@itemx -mno-mma
d77de738
ML
32745Generate (do not generate) the MMA instructions. The @option{-mma}
32746option requires that the option @option{-mcpu=power10} (or later)
32747is enabled.
32748
d77de738
ML
32749@opindex mrop-protect
32750@opindex mno-rop-protect
ddf6fe37
AA
32751@item -mrop-protect
32752@itemx -mno-rop-protect
d77de738
ML
32753Generate (do not generate) ROP protection instructions when the target
32754processor supports them. Currently this option disables the shrink-wrap
32755optimization (@option{-fshrink-wrap}).
32756
d77de738
ML
32757@opindex mprivileged
32758@opindex mno-privileged
ddf6fe37
AA
32759@item -mprivileged
32760@itemx -mno-privileged
d77de738
ML
32761Generate (do not generate) code that will run in privileged state.
32762
d77de738
ML
32763@opindex block-ops-unaligned-vsx
32764@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
32765@item -mblock-ops-unaligned-vsx
32766@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
32767Generate (do not generate) unaligned vsx loads and stores for
32768inline expansion of @code{memcpy} and @code{memmove}.
32769
32770@item --param rs6000-vect-unroll-limit=
32771The vectorizer will check with target information to determine whether it
32772would be beneficial to unroll the main vectorized loop and by how much. This
32773parameter sets the upper bound of how much the vectorizer will unroll the main
32774loop. The default value is four.
32775
32776@end table
32777
32778@node RX Options
32779@subsection RX Options
32780@cindex RX Options
32781
32782These command-line options are defined for RX targets:
32783
32784@table @gcctabopt
d77de738
ML
32785@opindex m64bit-doubles
32786@opindex m32bit-doubles
ddf6fe37
AA
32787@item -m64bit-doubles
32788@itemx -m32bit-doubles
d77de738
ML
32789Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
32790or 32 bits (@option{-m32bit-doubles}) in size. The default is
32791@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
32792works on 32-bit values, which is why the default is
32793@option{-m32bit-doubles}.
32794
d77de738
ML
32795@opindex fpu
32796@opindex nofpu
ddf6fe37
AA
32797@item -fpu
32798@itemx -nofpu
d77de738
ML
32799Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
32800floating-point hardware. The default is enabled for the RX600
32801series and disabled for the RX200 series.
32802
a0e64a04 32803Floating-point instructions are only generated for 32-bit floating-point
d77de738
ML
32804values, however, so the FPU hardware is not used for doubles if the
32805@option{-m64bit-doubles} option is used.
32806
32807@emph{Note} If the @option{-fpu} option is enabled then
32808@option{-funsafe-math-optimizations} is also enabled automatically.
32809This is because the RX FPU instructions are themselves unsafe.
32810
d77de738 32811@opindex mcpu
ddf6fe37 32812@item -mcpu=@var{name}
d77de738
ML
32813Selects the type of RX CPU to be targeted. Currently three types are
32814supported, the generic @samp{RX600} and @samp{RX200} series hardware and
32815the specific @samp{RX610} CPU. The default is @samp{RX600}.
32816
32817The only difference between @samp{RX600} and @samp{RX610} is that the
32818@samp{RX610} does not support the @code{MVTIPL} instruction.
32819
32820The @samp{RX200} series does not have a hardware floating-point unit
32821and so @option{-nofpu} is enabled by default when this type is
32822selected.
32823
d77de738
ML
32824@opindex mbig-endian-data
32825@opindex mlittle-endian-data
ddf6fe37
AA
32826@item -mbig-endian-data
32827@itemx -mlittle-endian-data
d77de738
ML
32828Store data (but not code) in the big-endian format. The default is
32829@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
32830format.
32831
d77de738 32832@opindex msmall-data-limit
ddf6fe37 32833@item -msmall-data-limit=@var{N}
d77de738
ML
32834Specifies the maximum size in bytes of global and static variables
32835which can be placed into the small data area. Using the small data
32836area can lead to smaller and faster code, but the size of area is
32837limited and it is up to the programmer to ensure that the area does
32838not overflow. Also when the small data area is used one of the RX's
32839registers (usually @code{r13}) is reserved for use pointing to this
32840area, so it is no longer available for use by the compiler. This
32841could result in slower and/or larger code if variables are pushed onto
32842the stack instead of being held in this register.
32843
32844Note, common variables (variables that have not been initialized) and
32845constants are not placed into the small data area as they are assigned
32846to other sections in the output executable.
32847
32848The default value is zero, which disables this feature. Note, this
32849feature is not enabled by default with higher optimization levels
32850(@option{-O2} etc) because of the potentially detrimental effects of
32851reserving a register. It is up to the programmer to experiment and
32852discover whether this feature is of benefit to their program. See the
32853description of the @option{-mpid} option for a description of how the
32854actual register to hold the small data area pointer is chosen.
32855
d77de738
ML
32856@opindex msim
32857@opindex mno-sim
ddf6fe37
AA
32858@item -msim
32859@itemx -mno-sim
d77de738
ML
32860Use the simulator runtime. The default is to use the libgloss
32861board-specific runtime.
32862
d77de738
ML
32863@opindex mas100-syntax
32864@opindex mno-as100-syntax
ddf6fe37
AA
32865@item -mas100-syntax
32866@itemx -mno-as100-syntax
d77de738
ML
32867When generating assembler output use a syntax that is compatible with
32868Renesas's AS100 assembler. This syntax can also be handled by the GAS
32869assembler, but it has some restrictions so it is not generated by default.
32870
d77de738 32871@opindex mmax-constant-size
ddf6fe37 32872@item -mmax-constant-size=@var{N}
d77de738
ML
32873Specifies the maximum size, in bytes, of a constant that can be used as
32874an operand in a RX instruction. Although the RX instruction set does
32875allow constants of up to 4 bytes in length to be used in instructions,
32876a longer value equates to a longer instruction. Thus in some
32877circumstances it can be beneficial to restrict the size of constants
32878that are used in instructions. Constants that are too big are instead
32879placed into a constant pool and referenced via register indirection.
32880
32881The value @var{N} can be between 0 and 4. A value of 0 (the default)
32882or 4 means that constants of any size are allowed.
32883
d77de738 32884@opindex mrelax
ddf6fe37 32885@item -mrelax
d77de738
ML
32886Enable linker relaxation. Linker relaxation is a process whereby the
32887linker attempts to reduce the size of a program by finding shorter
32888versions of various instructions. Disabled by default.
32889
d77de738 32890@opindex mint-register
ddf6fe37 32891@item -mint-register=@var{N}
d77de738
ML
32892Specify the number of registers to reserve for fast interrupt handler
32893functions. The value @var{N} can be between 0 and 4. A value of 1
32894means that register @code{r13} is reserved for the exclusive use
32895of fast interrupt handlers. A value of 2 reserves @code{r13} and
32896@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
32897@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
32898A value of 0, the default, does not reserve any registers.
32899
d77de738 32900@opindex msave-acc-in-interrupts
ddf6fe37 32901@item -msave-acc-in-interrupts
d77de738
ML
32902Specifies that interrupt handler functions should preserve the
32903accumulator register. This is only necessary if normal code might use
32904the accumulator register, for example because it performs 64-bit
32905multiplications. The default is to ignore the accumulator as this
32906makes the interrupt handlers faster.
32907
d77de738
ML
32908@opindex mpid
32909@opindex mno-pid
ddf6fe37
AA
32910@item -mpid
32911@itemx -mno-pid
d77de738
ML
32912Enables the generation of position independent data. When enabled any
32913access to constant data is done via an offset from a base address
32914held in a register. This allows the location of constant data to be
32915determined at run time without requiring the executable to be
32916relocated, which is a benefit to embedded applications with tight
32917memory constraints. Data that can be modified is not affected by this
32918option.
32919
32920Note, using this feature reserves a register, usually @code{r13}, for
32921the constant data base address. This can result in slower and/or
32922larger code, especially in complicated functions.
32923
32924The actual register chosen to hold the constant data base address
32925depends upon whether the @option{-msmall-data-limit} and/or the
32926@option{-mint-register} command-line options are enabled. Starting
32927with register @code{r13} and proceeding downwards, registers are
32928allocated first to satisfy the requirements of @option{-mint-register},
32929then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
32930is possible for the small data area register to be @code{r8} if both
32931@option{-mint-register=4} and @option{-mpid} are specified on the
32932command line.
32933
32934By default this feature is not enabled. The default can be restored
32935via the @option{-mno-pid} command-line option.
32936
d77de738
ML
32937@opindex mno-warn-multiple-fast-interrupts
32938@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
32939@item -mno-warn-multiple-fast-interrupts
32940@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
32941Prevents GCC from issuing a warning message if it finds more than one
32942fast interrupt handler when it is compiling a file. The default is to
32943issue a warning for each extra fast interrupt handler found, as the RX
32944only supports one such interrupt.
32945
d77de738
ML
32946@opindex mallow-string-insns
32947@opindex mno-allow-string-insns
ddf6fe37
AA
32948@item -mallow-string-insns
32949@itemx -mno-allow-string-insns
d77de738
ML
32950Enables or disables the use of the string manipulation instructions
32951@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
32952@code{SWHILE} and also the @code{RMPA} instruction. These
32953instructions may prefetch data, which is not safe to do if accessing
32954an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
32955for more information).
32956
32957The default is to allow these instructions, but it is not possible for
32958GCC to reliably detect all circumstances where a string instruction
32959might be used to access an I/O register, so their use cannot be
32960disabled automatically. Instead it is reliant upon the programmer to
32961use the @option{-mno-allow-string-insns} option if their program
32962accesses I/O space.
32963
32964When the instructions are enabled GCC defines the C preprocessor
32965symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
32966symbol @code{__RX_DISALLOW_STRING_INSNS__}.
32967
d77de738
ML
32968@opindex mjsr
32969@opindex mno-jsr
ddf6fe37
AA
32970@item -mjsr
32971@itemx -mno-jsr
d77de738
ML
32972Use only (or not only) @code{JSR} instructions to access functions.
32973This option can be used when code size exceeds the range of @code{BSR}
32974instructions. Note that @option{-mno-jsr} does not mean to not use
32975@code{JSR} but instead means that any type of branch may be used.
32976@end table
32977
32978@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
32979has special significance to the RX port when used with the
32980@code{interrupt} function attribute. This attribute indicates a
32981function intended to process fast interrupts. GCC ensures
32982that it only uses the registers @code{r10}, @code{r11}, @code{r12}
32983and/or @code{r13} and only provided that the normal use of the
32984corresponding registers have been restricted via the
32985@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
32986options.
32987
32988@node S/390 and zSeries Options
32989@subsection S/390 and zSeries Options
32990@cindex S/390 and zSeries Options
32991
32992These are the @samp{-m} options defined for the S/390 and zSeries architecture.
32993
32994@table @gcctabopt
d77de738
ML
32995@opindex mhard-float
32996@opindex msoft-float
ddf6fe37
AA
32997@item -mhard-float
32998@itemx -msoft-float
d77de738
ML
32999Use (do not use) the hardware floating-point instructions and registers
33000for floating-point operations. When @option{-msoft-float} is specified,
33001functions in @file{libgcc.a} are used to perform floating-point
33002operations. When @option{-mhard-float} is specified, the compiler
33003generates IEEE floating-point instructions. This is the default.
33004
d77de738
ML
33005@opindex mhard-dfp
33006@opindex mno-hard-dfp
ddf6fe37
AA
33007@item -mhard-dfp
33008@itemx -mno-hard-dfp
d77de738
ML
33009Use (do not use) the hardware decimal-floating-point instructions for
33010decimal-floating-point operations. When @option{-mno-hard-dfp} is
33011specified, functions in @file{libgcc.a} are used to perform
33012decimal-floating-point operations. When @option{-mhard-dfp} is
33013specified, the compiler generates decimal-floating-point hardware
33014instructions. This is the default for @option{-march=z9-ec} or higher.
33015
d77de738
ML
33016@opindex mlong-double-64
33017@opindex mlong-double-128
ddf6fe37
AA
33018@item -mlong-double-64
33019@itemx -mlong-double-128
d77de738
ML
33020These switches control the size of @code{long double} type. A size
33021of 64 bits makes the @code{long double} type equivalent to the @code{double}
33022type. This is the default.
33023
d77de738
ML
33024@opindex mbackchain
33025@opindex mno-backchain
ddf6fe37
AA
33026@item -mbackchain
33027@itemx -mno-backchain
d77de738
ML
33028Store (do not store) the address of the caller's frame as backchain pointer
33029into the callee's stack frame.
33030A backchain may be needed to allow debugging using tools that do not understand
33031DWARF call frame information.
33032When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
33033at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
33034the backchain is placed into the topmost word of the 96/160 byte register
33035save area.
33036
33037In general, code compiled with @option{-mbackchain} is call-compatible with
33038code compiled with @option{-mno-backchain}; however, use of the backchain
33039for debugging purposes usually requires that the whole binary is built with
33040@option{-mbackchain}. Note that the combination of @option{-mbackchain},
33041@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
33042to build a linux kernel use @option{-msoft-float}.
33043
33044The default is to not maintain the backchain.
33045
d77de738
ML
33046@opindex mpacked-stack
33047@opindex mno-packed-stack
ddf6fe37
AA
33048@item -mpacked-stack
33049@itemx -mno-packed-stack
d77de738
ML
33050Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
33051specified, the compiler uses the all fields of the 96/160 byte register save
33052area only for their default purpose; unused fields still take up stack space.
33053When @option{-mpacked-stack} is specified, register save slots are densely
33054packed at the top of the register save area; unused space is reused for other
33055purposes, allowing for more efficient use of the available stack space.
33056However, when @option{-mbackchain} is also in effect, the topmost word of
33057the save area is always used to store the backchain, and the return address
33058register is always saved two words below the backchain.
33059
33060As long as the stack frame backchain is not used, code generated with
33061@option{-mpacked-stack} is call-compatible with code generated with
33062@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
33063S/390 or zSeries generated code that uses the stack frame backchain at run
33064time, not just for debugging purposes. Such code is not call-compatible
33065with code compiled with @option{-mpacked-stack}. Also, note that the
33066combination of @option{-mbackchain},
33067@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
33068to build a linux kernel use @option{-msoft-float}.
33069
33070The default is to not use the packed stack layout.
33071
d77de738
ML
33072@opindex msmall-exec
33073@opindex mno-small-exec
ddf6fe37
AA
33074@item -msmall-exec
33075@itemx -mno-small-exec
d77de738
ML
33076Generate (or do not generate) code using the @code{bras} instruction
33077to do subroutine calls.
33078This only works reliably if the total executable size does not
33079exceed 64k. The default is to use the @code{basr} instruction instead,
33080which does not have this limitation.
33081
d77de738
ML
33082@opindex m64
33083@opindex m31
ddf6fe37
AA
33084@item -m64
33085@itemx -m31
d77de738
ML
33086When @option{-m31} is specified, generate code compliant to the
33087GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
33088code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
33089particular to generate 64-bit instructions. For the @samp{s390}
33090targets, the default is @option{-m31}, while the @samp{s390x}
81166d54 33091targets default to @option{-m64}.
d77de738 33092
d77de738
ML
33093@opindex mzarch
33094@opindex mesa
ddf6fe37
AA
33095@item -mzarch
33096@itemx -mesa
d77de738
ML
33097When @option{-mzarch} is specified, generate code using the
33098instructions available on z/Architecture.
33099When @option{-mesa} is specified, generate code using the
33100instructions available on ESA/390. Note that @option{-mesa} is
33101not possible with @option{-m64}.
33102When generating code compliant to the GNU/Linux for S/390 ABI,
33103the default is @option{-mesa}. When generating code compliant
33104to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
33105
d77de738
ML
33106@opindex mhtm
33107@opindex mno-htm
ddf6fe37
AA
33108@item -mhtm
33109@itemx -mno-htm
d77de738
ML
33110The @option{-mhtm} option enables a set of builtins making use of
33111instructions available with the transactional execution facility
33112introduced with the IBM zEnterprise EC12 machine generation
33113@ref{S/390 System z Built-in Functions}.
33114@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
33115
d77de738
ML
33116@opindex mvx
33117@opindex mno-vx
ddf6fe37
AA
33118@item -mvx
33119@itemx -mno-vx
d77de738
ML
33120When @option{-mvx} is specified, generate code using the instructions
33121available with the vector extension facility introduced with the IBM
33122z13 machine generation.
33123This option changes the ABI for some vector type values with regard to
33124alignment and calling conventions. In case vector type values are
33125being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
33126command will be added to mark the resulting binary with the ABI used.
33127@option{-mvx} is enabled by default when using @option{-march=z13}.
33128
d77de738
ML
33129@opindex mzvector
33130@opindex mno-zvector
ddf6fe37
AA
33131@item -mzvector
33132@itemx -mno-zvector
d77de738
ML
33133The @option{-mzvector} option enables vector language extensions and
33134builtins using instructions available with the vector extension
33135facility introduced with the IBM z13 machine generation.
33136This option adds support for @samp{vector} to be used as a keyword to
33137define vector type variables and arguments. @samp{vector} is only
33138available when GNU extensions are enabled. It will not be expanded
33139when requesting strict standard compliance e.g.@: with @option{-std=c99}.
33140In addition to the GCC low-level builtins @option{-mzvector} enables
33141a set of builtins added for compatibility with AltiVec-style
33142implementations like Power and Cell. In order to make use of these
33143builtins the header file @file{vecintrin.h} needs to be included.
33144@option{-mzvector} is disabled by default.
33145
d77de738
ML
33146@opindex mmvcle
33147@opindex mno-mvcle
ddf6fe37
AA
33148@item -mmvcle
33149@itemx -mno-mvcle
d77de738
ML
33150Generate (or do not generate) code using the @code{mvcle} instruction
33151to perform block moves. When @option{-mno-mvcle} is specified,
33152use a @code{mvc} loop instead. This is the default unless optimizing for
33153size.
33154
d77de738
ML
33155@opindex mdebug
33156@opindex mno-debug
ddf6fe37
AA
33157@item -mdebug
33158@itemx -mno-debug
d77de738
ML
33159Print (or do not print) additional debug information when compiling.
33160The default is to not print debug information.
33161
d77de738 33162@opindex march
ddf6fe37 33163@item -march=@var{cpu-type}
d77de738
ML
33164Generate code that runs on @var{cpu-type}, which is the name of a
33165system representing a certain processor type. Possible values for
33166@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
33167@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
33168@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
33169@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
1b290c16 33170@samp{z16}/@samp{arch14}, @samp{z17}/@samp{arch15}, and @samp{native}.
d77de738
ML
33171
33172The default is @option{-march=z900}.
33173
33174Specifying @samp{native} as cpu type can be used to select the best
33175architecture option for the host processor.
33176@option{-march=native} has no effect if GCC does not recognize the
33177processor.
33178
d77de738 33179@opindex mtune
ddf6fe37 33180@item -mtune=@var{cpu-type}
d77de738
ML
33181Tune to @var{cpu-type} everything applicable about the generated code,
33182except for the ABI and the set of available instructions.
33183The list of @var{cpu-type} values is the same as for @option{-march}.
33184The default is the value used for @option{-march}.
33185
d77de738
ML
33186@opindex mtpf-trace
33187@opindex mno-tpf-trace
ddf6fe37
AA
33188@item -mtpf-trace
33189@itemx -mno-tpf-trace
d77de738
ML
33190Generate code that adds (does not add) in TPF OS specific branches to trace
33191routines in the operating system. This option is off by default, even
33192when compiling for the TPF OS@.
33193
d77de738
ML
33194@opindex mtpf-trace-skip
33195@opindex mno-tpf-trace-skip
ddf6fe37
AA
33196@item -mtpf-trace-skip
33197@itemx -mno-tpf-trace-skip
d77de738
ML
33198Generate code that changes (does not change) the default branch
33199targets enabled by @option{-mtpf-trace} to point to specialized trace
33200routines providing the ability of selectively skipping function trace
33201entries for the TPF OS. This option is off by default, even when
33202compiling for the TPF OS and specifying @option{-mtpf-trace}.
33203
d77de738
ML
33204@opindex mfused-madd
33205@opindex mno-fused-madd
ddf6fe37
AA
33206@item -mfused-madd
33207@itemx -mno-fused-madd
d77de738
ML
33208Generate code that uses (does not use) the floating-point multiply and
33209accumulate instructions. These instructions are generated by default if
33210hardware floating point is used.
33211
d77de738 33212@opindex mwarn-framesize
ddf6fe37 33213@item -mwarn-framesize=@var{framesize}
d77de738
ML
33214Emit a warning if the current function exceeds the given frame size. Because
33215this is a compile-time check it doesn't need to be a real problem when the program
33216runs. It is intended to identify functions that most probably cause
33217a stack overflow. It is useful to be used in an environment with limited stack
33218size e.g.@: the linux kernel.
33219
d77de738 33220@opindex mwarn-dynamicstack
ddf6fe37 33221@item -mwarn-dynamicstack
d77de738
ML
33222Emit a warning if the function calls @code{alloca} or uses dynamically-sized
33223arrays. This is generally a bad idea with a limited stack size.
33224
d77de738
ML
33225@opindex mstack-guard
33226@opindex mstack-size
ddf6fe37
AA
33227@item -mstack-guard=@var{stack-guard}
33228@itemx -mstack-size=@var{stack-size}
d77de738
ML
33229If these options are provided the S/390 back end emits additional instructions in
33230the function prologue that trigger a trap if the stack size is @var{stack-guard}
33231bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
33232If the @var{stack-guard} option is omitted the smallest power of 2 larger than
33233the frame size of the compiled function is chosen.
33234These options are intended to be used to help debugging stack overflow problems.
33235The additionally emitted code causes only little overhead and hence can also be
33236used in production-like systems without greater performance degradation. The given
33237values have to be exact powers of 2 and @var{stack-size} has to be greater than
33238@var{stack-guard} without exceeding 64k.
33239In order to be efficient the extra code makes the assumption that the stack starts
33240at an address aligned to the value given by @var{stack-size}.
33241The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
33242
d77de738 33243@opindex mhotpatch
ddf6fe37 33244@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
33245If the hotpatch option is enabled, a ``hot-patching'' function
33246prologue is generated for all functions in the compilation unit.
33247The funtion label is prepended with the given number of two-byte
33248NOP instructions (@var{pre-halfwords}, maximum 1000000). After
33249the label, 2 * @var{post-halfwords} bytes are appended, using the
33250largest NOP like instructions the architecture allows (maximum
332511000000).
33252
33253If both arguments are zero, hotpatching is disabled.
33254
33255This option can be overridden for individual functions with the
33256@code{hotpatch} attribute.
33257@end table
33258
d77de738
ML
33259@node SH Options
33260@subsection SH Options
33261
33262These @samp{-m} options are defined for the SH implementations:
33263
33264@table @gcctabopt
d77de738 33265@opindex m1
ddf6fe37 33266@item -m1
d77de738
ML
33267Generate code for the SH1.
33268
d77de738 33269@opindex m2
ddf6fe37 33270@item -m2
d77de738
ML
33271Generate code for the SH2.
33272
33273@item -m2e
33274Generate code for the SH2e.
33275
d77de738 33276@opindex m2a-nofpu
ddf6fe37 33277@item -m2a-nofpu
d77de738
ML
33278Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
33279that the floating-point unit is not used.
33280
d77de738 33281@opindex m2a-single-only
ddf6fe37 33282@item -m2a-single-only
d77de738
ML
33283Generate code for the SH2a-FPU, in such a way that no double-precision
33284floating-point operations are used.
33285
d77de738 33286@opindex m2a-single
ddf6fe37 33287@item -m2a-single
d77de738
ML
33288Generate code for the SH2a-FPU assuming the floating-point unit is in
33289single-precision mode by default.
33290
d77de738 33291@opindex m2a
ddf6fe37 33292@item -m2a
d77de738
ML
33293Generate code for the SH2a-FPU assuming the floating-point unit is in
33294double-precision mode by default.
33295
d77de738 33296@opindex m3
ddf6fe37 33297@item -m3
d77de738
ML
33298Generate code for the SH3.
33299
d77de738 33300@opindex m3e
ddf6fe37 33301@item -m3e
d77de738
ML
33302Generate code for the SH3e.
33303
d77de738 33304@opindex m4-nofpu
ddf6fe37 33305@item -m4-nofpu
d77de738
ML
33306Generate code for the SH4 without a floating-point unit.
33307
d77de738 33308@opindex m4-single-only
ddf6fe37 33309@item -m4-single-only
d77de738
ML
33310Generate code for the SH4 with a floating-point unit that only
33311supports single-precision arithmetic.
33312
d77de738 33313@opindex m4-single
ddf6fe37 33314@item -m4-single
d77de738
ML
33315Generate code for the SH4 assuming the floating-point unit is in
33316single-precision mode by default.
33317
d77de738 33318@opindex m4
ddf6fe37 33319@item -m4
d77de738
ML
33320Generate code for the SH4.
33321
d77de738 33322@opindex m4-100
ddf6fe37 33323@item -m4-100
d77de738
ML
33324Generate code for SH4-100.
33325
d77de738 33326@opindex m4-100-nofpu
ddf6fe37 33327@item -m4-100-nofpu
d77de738
ML
33328Generate code for SH4-100 in such a way that the
33329floating-point unit is not used.
33330
d77de738 33331@opindex m4-100-single
ddf6fe37 33332@item -m4-100-single
d77de738
ML
33333Generate code for SH4-100 assuming the floating-point unit is in
33334single-precision mode by default.
33335
d77de738 33336@opindex m4-100-single-only
ddf6fe37 33337@item -m4-100-single-only
d77de738
ML
33338Generate code for SH4-100 in such a way that no double-precision
33339floating-point operations are used.
33340
d77de738 33341@opindex m4-200
ddf6fe37 33342@item -m4-200
d77de738
ML
33343Generate code for SH4-200.
33344
d77de738 33345@opindex m4-200-nofpu
ddf6fe37 33346@item -m4-200-nofpu
d77de738
ML
33347Generate code for SH4-200 without in such a way that the
33348floating-point unit is not used.
33349
d77de738 33350@opindex m4-200-single
ddf6fe37 33351@item -m4-200-single
d77de738
ML
33352Generate code for SH4-200 assuming the floating-point unit is in
33353single-precision mode by default.
33354
d77de738 33355@opindex m4-200-single-only
ddf6fe37 33356@item -m4-200-single-only
d77de738
ML
33357Generate code for SH4-200 in such a way that no double-precision
33358floating-point operations are used.
33359
d77de738 33360@opindex m4-300
ddf6fe37 33361@item -m4-300
d77de738
ML
33362Generate code for SH4-300.
33363
d77de738 33364@opindex m4-300-nofpu
ddf6fe37 33365@item -m4-300-nofpu
d77de738
ML
33366Generate code for SH4-300 without in such a way that the
33367floating-point unit is not used.
33368
d77de738 33369@opindex m4-300-single
ddf6fe37 33370@item -m4-300-single
d77de738
ML
33371Generate code for SH4-300 in such a way that no double-precision
33372floating-point operations are used.
33373
d77de738 33374@opindex m4-300-single-only
ddf6fe37 33375@item -m4-300-single-only
d77de738
ML
33376Generate code for SH4-300 in such a way that no double-precision
33377floating-point operations are used.
33378
d77de738 33379@opindex m4-340
ddf6fe37 33380@item -m4-340
d77de738
ML
33381Generate code for SH4-340 (no MMU, no FPU).
33382
d77de738 33383@opindex m4-500
ddf6fe37 33384@item -m4-500
d77de738
ML
33385Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
33386assembler.
33387
d77de738 33388@opindex m4a-nofpu
ddf6fe37 33389@item -m4a-nofpu
d77de738
ML
33390Generate code for the SH4al-dsp, or for a SH4a in such a way that the
33391floating-point unit is not used.
33392
d77de738 33393@opindex m4a-single-only
ddf6fe37 33394@item -m4a-single-only
d77de738
ML
33395Generate code for the SH4a, in such a way that no double-precision
33396floating-point operations are used.
33397
d77de738 33398@opindex m4a-single
ddf6fe37 33399@item -m4a-single
d77de738
ML
33400Generate code for the SH4a assuming the floating-point unit is in
33401single-precision mode by default.
33402
d77de738 33403@opindex m4a
ddf6fe37 33404@item -m4a
d77de738
ML
33405Generate code for the SH4a.
33406
d77de738 33407@opindex m4al
ddf6fe37 33408@item -m4al
d77de738
ML
33409Same as @option{-m4a-nofpu}, except that it implicitly passes
33410@option{-dsp} to the assembler. GCC doesn't generate any DSP
33411instructions at the moment.
33412
d77de738 33413@opindex mb
ddf6fe37 33414@item -mb
d77de738
ML
33415Compile code for the processor in big-endian mode.
33416
d77de738 33417@opindex ml
ddf6fe37 33418@item -ml
d77de738
ML
33419Compile code for the processor in little-endian mode.
33420
d77de738 33421@opindex mdalign
ddf6fe37 33422@item -mdalign
d77de738
ML
33423Align doubles at 64-bit boundaries. Note that this changes the calling
33424conventions, and thus some functions from the standard C library do
33425not work unless you recompile it first with @option{-mdalign}.
33426
d77de738 33427@opindex mrelax
ddf6fe37 33428@item -mrelax
d77de738
ML
33429Shorten some address references at link time, when possible; uses the
33430linker option @option{-relax}.
33431
d77de738 33432@opindex mbigtable
ddf6fe37 33433@item -mbigtable
d77de738
ML
33434Use 32-bit offsets in @code{switch} tables. The default is to use
3343516-bit offsets.
33436
d77de738 33437@opindex mbitops
ddf6fe37 33438@item -mbitops
d77de738
ML
33439Enable the use of bit manipulation instructions on SH2A.
33440
d77de738 33441@opindex mfmovd
ddf6fe37 33442@item -mfmovd
d77de738
ML
33443Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
33444alignment constraints.
33445
d77de738 33446@opindex mrenesas
ddf6fe37 33447@item -mrenesas
d77de738
ML
33448Comply with the calling conventions defined by Renesas.
33449
d77de738 33450@opindex mno-renesas
ddf6fe37 33451@item -mno-renesas
d77de738
ML
33452Comply with the calling conventions defined for GCC before the Renesas
33453conventions were available. This option is the default for all
33454targets of the SH toolchain.
33455
d77de738 33456@opindex mnomacsave
ddf6fe37 33457@item -mnomacsave
d77de738
ML
33458Mark the @code{MAC} register as call-clobbered, even if
33459@option{-mrenesas} is given.
33460
d77de738
ML
33461@opindex mieee
33462@opindex mno-ieee
ddf6fe37
AA
33463@item -mieee
33464@itemx -mno-ieee
d77de738
ML
33465Control the IEEE compliance of floating-point comparisons, which affects the
33466handling of cases where the result of a comparison is unordered. By default
33467@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
33468enabled @option{-mno-ieee} is implicitly set, which results in faster
33469floating-point greater-equal and less-equal comparisons. The implicit settings
33470can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
33471
d77de738 33472@opindex minline-ic_invalidate
ddf6fe37 33473@item -minline-ic_invalidate
d77de738
ML
33474Inline code to invalidate instruction cache entries after setting up
33475nested function trampolines.
33476This option has no effect if @option{-musermode} is in effect and the selected
33477code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
33478instruction.
33479If the selected code generation option does not allow the use of the @code{icbi}
33480instruction, and @option{-musermode} is not in effect, the inlined code
33481manipulates the instruction cache address array directly with an associative
33482write. This not only requires privileged mode at run time, but it also
33483fails if the cache line had been mapped via the TLB and has become unmapped.
33484
d77de738 33485@opindex misize
ddf6fe37 33486@item -misize
d77de738
ML
33487Dump instruction size and location in the assembly code.
33488
d77de738 33489@opindex mpadstruct
ddf6fe37 33490@item -mpadstruct
d77de738
ML
33491This option is deprecated. It pads structures to multiple of 4 bytes,
33492which is incompatible with the SH ABI@.
33493
d77de738 33494@opindex matomic-model=@var{model}
ddf6fe37 33495@item -matomic-model=@var{model}
d77de738
ML
33496Sets the model of atomic operations and additional parameters as a comma
33497separated list. For details on the atomic built-in functions see
33498@ref{__atomic Builtins}. The following models and parameters are supported:
33499
33500@table @samp
33501
33502@item none
33503Disable compiler generated atomic sequences and emit library calls for atomic
33504operations. This is the default if the target is not @code{sh*-*-linux*}.
33505
33506@item soft-gusa
33507Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
33508built-in functions. The generated atomic sequences require additional support
33509from the interrupt/exception handling code of the system and are only suitable
33510for SH3* and SH4* single-core systems. This option is enabled by default when
33511the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
33512this option also partially utilizes the hardware atomic instructions
33513@code{movli.l} and @code{movco.l} to create more efficient code, unless
a0e64a04 33514@samp{strict} is specified.
d77de738
ML
33515
33516@item soft-tcb
33517Generate software atomic sequences that use a variable in the thread control
33518block. This is a variation of the gUSA sequences which can also be used on
33519SH1* and SH2* targets. The generated atomic sequences require additional
33520support from the interrupt/exception handling code of the system and are only
33521suitable for single-core systems. When using this model, the @samp{gbr-offset=}
33522parameter has to be specified as well.
33523
33524@item soft-imask
33525Generate software atomic sequences that temporarily disable interrupts by
33526setting @code{SR.IMASK = 1111}. This model works only when the program runs
33527in privileged mode and is only suitable for single-core systems. Additional
33528support from the interrupt/exception handling code of the system is not
33529required. This model is enabled by default when the target is
33530@code{sh*-*-linux*} and SH1* or SH2*.
33531
33532@item hard-llcs
33533Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
33534instructions only. This is only available on SH4A and is suitable for
33535multi-core systems. Since the hardware instructions support only 32 bit atomic
33536variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
33537Code compiled with this option is also compatible with other software
33538atomic model interrupt/exception handling systems if executed on an SH4A
33539system. Additional support from the interrupt/exception handling code of the
33540system is not required for this model.
33541
33542@item gbr-offset=
33543This parameter specifies the offset in bytes of the variable in the thread
33544control block structure that should be used by the generated atomic sequences
33545when the @samp{soft-tcb} model has been selected. For other models this
33546parameter is ignored. The specified value must be an integer multiple of four
33547and in the range 0-1020.
33548
33549@item strict
33550This parameter prevents mixed usage of multiple atomic models, even if they
33551are compatible, and makes the compiler generate atomic sequences of the
33552specified model only.
33553
33554@end table
33555
d77de738 33556@opindex mtas
ddf6fe37 33557@item -mtas
d77de738
ML
33558Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
33559Notice that depending on the particular hardware and software configuration
33560this can degrade overall performance due to the operand cache line flushes
33561that are implied by the @code{tas.b} instruction. On multi-core SH4A
33562processors the @code{tas.b} instruction must be used with caution since it
33563can result in data corruption for certain cache configurations.
33564
d77de738 33565@opindex mprefergot
ddf6fe37 33566@item -mprefergot
d77de738
ML
33567When generating position-independent code, emit function calls using
33568the Global Offset Table instead of the Procedure Linkage Table.
33569
d77de738
ML
33570@opindex musermode
33571@opindex mno-usermode
ddf6fe37
AA
33572@item -musermode
33573@itemx -mno-usermode
d77de738
ML
33574Don't allow (allow) the compiler generating privileged mode code. Specifying
33575@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
33576inlined code would not work in user mode. @option{-musermode} is the default
33577when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
33578@option{-musermode} has no effect, since there is no user mode.
33579
d77de738 33580@opindex multcost=@var{number}
ddf6fe37 33581@item -multcost=@var{number}
d77de738
ML
33582Set the cost to assume for a multiply insn.
33583
d77de738 33584@opindex mdiv=@var{strategy}
ddf6fe37 33585@item -mdiv=@var{strategy}
d77de738 33586Set the division strategy to be used for integer division operations.
a0e64a04 33587@var{strategy} can be one of:
d77de738
ML
33588
33589@table @samp
33590
33591@item call-div1
33592Calls a library function that uses the single-step division instruction
33593@code{div1} to perform the operation. Division by zero calculates an
33594unspecified result and does not trap. This is the default except for SH4,
33595SH2A and SHcompact.
33596
33597@item call-fp
33598Calls a library function that performs the operation in double precision
33599floating point. Division by zero causes a floating-point exception. This is
33600the default for SHcompact with FPU. Specifying this for targets that do not
33601have a double precision FPU defaults to @code{call-div1}.
33602
33603@item call-table
33604Calls a library function that uses a lookup table for small divisors and
33605the @code{div1} instruction with case distinction for larger divisors. Division
33606by zero calculates an unspecified result and does not trap. This is the default
33607for SH4. Specifying this for targets that do not have dynamic shift
33608instructions defaults to @code{call-div1}.
33609
33610@end table
33611
33612When a division strategy has not been specified the default strategy is
33613selected based on the current target. For SH2A the default strategy is to
33614use the @code{divs} and @code{divu} instructions instead of library function
33615calls.
33616
d77de738 33617@opindex maccumulate-outgoing-args
ddf6fe37 33618@item -maccumulate-outgoing-args
d77de738
ML
33619Reserve space once for outgoing arguments in the function prologue rather
33620than around each call. Generally beneficial for performance and size. Also
33621needed for unwinding to avoid changing the stack frame around conditional code.
33622
d77de738 33623@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 33624@item -mdivsi3_libfunc=@var{name}
d77de738
ML
33625Set the name of the library function used for 32-bit signed division to
33626@var{name}.
33627This only affects the name used in the @samp{call} division strategies, and
33628the compiler still expects the same sets of input/output/clobbered registers as
33629if this option were not present.
33630
d77de738 33631@opindex mfixed-range
ddf6fe37 33632@item -mfixed-range=@var{register-range}
d77de738
ML
33633Generate code treating the given register range as fixed registers.
33634A fixed register is one that the register allocator cannot use. This is
33635useful when compiling kernel code. A register range is specified as
33636two registers separated by a dash. Multiple register ranges can be
33637specified separated by a comma.
33638
d77de738 33639@opindex mbranch-cost=@var{num}
ddf6fe37 33640@item -mbranch-cost=@var{num}
d77de738 33641Assume @var{num} to be the cost for a branch instruction. Higher numbers
a0e64a04 33642make the compiler try to generate more branch-free code if possible.
d77de738
ML
33643If not specified the value is selected depending on the processor type that
33644is being compiled for.
33645
d77de738
ML
33646@opindex mzdcbranch
33647@opindex mno-zdcbranch
ddf6fe37
AA
33648@item -mzdcbranch
33649@itemx -mno-zdcbranch
d77de738
ML
33650Assume (do not assume) that zero displacement conditional branch instructions
33651@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
33652compiler prefers zero displacement branch code sequences. This is
33653enabled by default when generating code for SH4 and SH4A. It can be explicitly
33654disabled by specifying @option{-mno-zdcbranch}.
33655
d77de738 33656@opindex mcbranch-force-delay-slot
ddf6fe37 33657@item -mcbranch-force-delay-slot
d77de738
ML
33658Force the usage of delay slots for conditional branches, which stuffs the delay
33659slot with a @code{nop} if a suitable instruction cannot be found. By default
33660this option is disabled. It can be enabled to work around hardware bugs as
33661found in the original SH7055.
33662
d77de738
ML
33663@opindex mfused-madd
33664@opindex mno-fused-madd
ddf6fe37
AA
33665@item -mfused-madd
33666@itemx -mno-fused-madd
d77de738
ML
33667Generate code that uses (does not use) the floating-point multiply and
33668accumulate instructions. These instructions are generated by default
33669if hardware floating point is used. The machine-dependent
33670@option{-mfused-madd} option is now mapped to the machine-independent
33671@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
33672mapped to @option{-ffp-contract=off}.
33673
d77de738
ML
33674@opindex mfsca
33675@opindex mno-fsca
ddf6fe37
AA
33676@item -mfsca
33677@itemx -mno-fsca
d77de738
ML
33678Allow or disallow the compiler to emit the @code{fsca} instruction for sine
33679and cosine approximations. The option @option{-mfsca} must be used in
33680combination with @option{-funsafe-math-optimizations}. It is enabled by default
33681when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
33682approximations even if @option{-funsafe-math-optimizations} is in effect.
33683
d77de738
ML
33684@opindex mfsrra
33685@opindex mno-fsrra
ddf6fe37
AA
33686@item -mfsrra
33687@itemx -mno-fsrra
d77de738
ML
33688Allow or disallow the compiler to emit the @code{fsrra} instruction for
33689reciprocal square root approximations. The option @option{-mfsrra} must be used
33690in combination with @option{-funsafe-math-optimizations} and
33691@option{-ffinite-math-only}. It is enabled by default when generating code for
33692SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
33693even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
33694in effect.
33695
d77de738 33696@opindex mpretend-cmove
ddf6fe37 33697@item -mpretend-cmove
d77de738
ML
33698Prefer zero-displacement conditional branches for conditional move instruction
33699patterns. This can result in faster code on the SH4 processor.
33700
d77de738 33701@opindex fdpic
ddf6fe37 33702@item -mfdpic
d77de738
ML
33703Generate code using the FDPIC ABI.
33704
33705@end table
33706
33707@node Solaris 2 Options
33708@subsection Solaris 2 Options
33709@cindex Solaris 2 options
33710
33711These @samp{-m} options are supported on Solaris 2:
33712
33713@table @gcctabopt
d77de738 33714@opindex mclear-hwcap
ddf6fe37 33715@item -mclear-hwcap
d77de738
ML
33716@option{-mclear-hwcap} tells the compiler to remove the hardware
33717capabilities generated by the Solaris assembler. This is only necessary
33718when object files use ISA extensions not supported by the current
33719machine, but check at runtime whether or not to use them.
33720
d77de738 33721@opindex mimpure-text
ddf6fe37 33722@item -mimpure-text
d77de738
ML
33723@option{-mimpure-text}, used in addition to @option{-shared}, tells
33724the compiler to not pass @option{-z text} to the linker when linking a
33725shared object. Using this option, you can link position-dependent
33726code into a shared object.
33727
33728@option{-mimpure-text} suppresses the ``relocations remain against
33729allocatable but non-writable sections'' linker error message.
33730However, the necessary relocations trigger copy-on-write, and the
33731shared object is not actually shared across processes. Instead of
33732using @option{-mimpure-text}, you should compile all source code with
33733@option{-fpic} or @option{-fPIC}.
33734
33735@end table
33736
33737These switches are supported in addition to the above on Solaris 2:
33738
33739@table @gcctabopt
d77de738 33740@opindex pthreads
ddf6fe37 33741@item -pthreads
d77de738
ML
33742This is a synonym for @option{-pthread}.
33743@end table
33744
33745@node SPARC Options
33746@subsection SPARC Options
33747@cindex SPARC options
33748
33749These @samp{-m} options are supported on the SPARC:
33750
33751@table @gcctabopt
d77de738
ML
33752@opindex mno-app-regs
33753@opindex mapp-regs
ddf6fe37
AA
33754@item -mno-app-regs
33755@itemx -mapp-regs
d77de738
ML
33756Specify @option{-mapp-regs} to generate output using the global registers
337572 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
33758global register 1, each global register 2 through 4 is then treated as an
33759allocable register that is clobbered by function calls. This is the default.
33760
33761To be fully SVR4 ABI-compliant at the cost of some performance loss,
33762specify @option{-mno-app-regs}. You should compile libraries and system
33763software with this option.
33764
d77de738
ML
33765@opindex mflat
33766@opindex mno-flat
ddf6fe37
AA
33767@item -mflat
33768@itemx -mno-flat
d77de738
ML
33769With @option{-mflat}, the compiler does not generate save/restore instructions
33770and uses a ``flat'' or single register window model. This model is compatible
33771with the regular register window model. The local registers and the input
33772registers (0--5) are still treated as ``call-saved'' registers and are
33773saved on the stack as needed.
33774
33775With @option{-mno-flat} (the default), the compiler generates save/restore
33776instructions (except for leaf functions). This is the normal operating mode.
33777
d77de738
ML
33778@opindex mfpu
33779@opindex mhard-float
ddf6fe37
AA
33780@item -mfpu
33781@itemx -mhard-float
d77de738
ML
33782Generate output containing floating-point instructions. This is the
33783default.
33784
d77de738
ML
33785@opindex mno-fpu
33786@opindex msoft-float
ddf6fe37
AA
33787@item -mno-fpu
33788@itemx -msoft-float
d77de738
ML
33789Generate output containing library calls for floating point.
33790@strong{Warning:} the requisite libraries are not available for all SPARC
33791targets. Normally the facilities of the machine's usual C compiler are
33792used, but this cannot be done directly in cross-compilation. You must make
33793your own arrangements to provide suitable library functions for
33794cross-compilation. The embedded targets @samp{sparc-*-aout} and
33795@samp{sparclite-*-*} do provide software floating-point support.
33796
33797@option{-msoft-float} changes the calling convention in the output file;
33798therefore, it is only useful if you compile @emph{all} of a program with
33799this option. In particular, you need to compile @file{libgcc.a}, the
33800library that comes with GCC, with @option{-msoft-float} in order for
33801this to work.
33802
d77de738 33803@opindex mhard-quad-float
ddf6fe37 33804@item -mhard-quad-float
d77de738
ML
33805Generate output containing quad-word (long double) floating-point
33806instructions.
33807
d77de738 33808@opindex msoft-quad-float
ddf6fe37 33809@item -msoft-quad-float
d77de738
ML
33810Generate output containing library calls for quad-word (long double)
33811floating-point instructions. The functions called are those specified
33812in the SPARC ABI@. This is the default.
33813
33814As of this writing, there are no SPARC implementations that have hardware
33815support for the quad-word floating-point instructions. They all invoke
33816a trap handler for one of these instructions, and then the trap handler
33817emulates the effect of the instruction. Because of the trap handler overhead,
33818this is much slower than calling the ABI library routines. Thus the
33819@option{-msoft-quad-float} option is the default.
33820
d77de738
ML
33821@opindex mno-unaligned-doubles
33822@opindex munaligned-doubles
ddf6fe37
AA
33823@item -mno-unaligned-doubles
33824@itemx -munaligned-doubles
d77de738
ML
33825Assume that doubles have 8-byte alignment. This is the default.
33826
33827With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
33828alignment only if they are contained in another type, or if they have an
33829absolute address. Otherwise, it assumes they have 4-byte alignment.
33830Specifying this option avoids some rare compatibility problems with code
33831generated by other compilers. It is not the default because it results
33832in a performance loss, especially for floating-point code.
33833
d77de738
ML
33834@opindex muser-mode
33835@opindex mno-user-mode
ddf6fe37
AA
33836@item -muser-mode
33837@itemx -mno-user-mode
d77de738
ML
33838Do not generate code that can only run in supervisor mode. This is relevant
33839only for the @code{casa} instruction emitted for the LEON3 processor. This
33840is the default.
33841
d77de738
ML
33842@opindex mfaster-structs
33843@opindex mno-faster-structs
ddf6fe37
AA
33844@item -mfaster-structs
33845@itemx -mno-faster-structs
d77de738
ML
33846With @option{-mfaster-structs}, the compiler assumes that structures
33847should have 8-byte alignment. This enables the use of pairs of
33848@code{ldd} and @code{std} instructions for copies in structure
33849assignment, in place of twice as many @code{ld} and @code{st} pairs.
33850However, the use of this changed alignment directly violates the SPARC
33851ABI@. Thus, it's intended only for use on targets where the developer
33852acknowledges that their resulting code is not directly in line with
33853the rules of the ABI@.
33854
d77de738
ML
33855@opindex mstd-struct-return
33856@opindex mno-std-struct-return
ddf6fe37
AA
33857@item -mstd-struct-return
33858@itemx -mno-std-struct-return
d77de738
ML
33859With @option{-mstd-struct-return}, the compiler generates checking code
33860in functions returning structures or unions to detect size mismatches
33861between the two sides of function calls, as per the 32-bit ABI@.
33862
33863The default is @option{-mno-std-struct-return}. This option has no effect
33864in 64-bit mode.
33865
d77de738 33866@opindex mcpu
ddf6fe37 33867@item -mcpu=@var{cpu_type}
d77de738
ML
33868Set the instruction set, register set, and instruction scheduling parameters
33869for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33870@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
33871@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
33872@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
33873@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
33874@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
33875@samp{m8}.
33876
33877Native Solaris and GNU/Linux toolchains also support the value @samp{native},
33878which selects the best architecture option for the host processor.
33879@option{-mcpu=native} has no effect if GCC does not recognize
33880the processor.
33881
33882Default instruction scheduling parameters are used for values that select
33883an architecture and not an implementation. These are @samp{v7}, @samp{v8},
33884@samp{sparclite}, @samp{sparclet}, @samp{v9}.
33885
33886Here is a list of each supported architecture and their supported
33887implementations.
33888
33889@table @asis
33890@item v7
33891cypress, leon3v7
33892
33893@item v8
33894supersparc, hypersparc, leon, leon3, leon5
33895
33896@item sparclite
33897f930, f934, sparclite86x
33898
33899@item sparclet
33900tsc701
33901
33902@item v9
33903ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
33904niagara7, m8
33905@end table
33906
33907By default (unless configured otherwise), GCC generates code for the V7
33908variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
33909additionally optimizes it for the Cypress CY7C602 chip, as used in the
33910SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
33911SPARCStation 1, 2, IPX etc.
33912
33913With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
33914architecture. The only difference from V7 code is that the compiler emits
33915the integer multiply and integer divide instructions which exist in SPARC-V8
33916but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
33917optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
339182000 series.
33919
33920With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
33921the SPARC architecture. This adds the integer multiply, integer divide step
33922and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
33923With @option{-mcpu=f930}, the compiler additionally optimizes it for the
33924Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
33925@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
33926MB86934 chip, which is the more recent SPARClite with FPU@.
33927
33928With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
33929the SPARC architecture. This adds the integer multiply, multiply/accumulate,
33930integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
33931but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
33932optimizes it for the TEMIC SPARClet chip.
33933
33934With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
33935architecture. This adds 64-bit integer and floating-point move instructions,
339363 additional floating-point condition code registers and conditional move
33937instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
33938optimizes it for the Sun UltraSPARC I/II/IIi chips. With
33939@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
33940Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
33941@option{-mcpu=niagara}, the compiler additionally optimizes it for
33942Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
33943additionally optimizes it for Sun UltraSPARC T2 chips. With
33944@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
33945UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
33946additionally optimizes it for Sun UltraSPARC T4 chips. With
33947@option{-mcpu=niagara7}, the compiler additionally optimizes it for
33948Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
33949additionally optimizes it for Oracle M8 chips.
33950
d77de738 33951@opindex mtune
ddf6fe37 33952@item -mtune=@var{cpu_type}
d77de738
ML
33953Set the instruction scheduling parameters for machine type
33954@var{cpu_type}, but do not set the instruction set or register set that the
33955option @option{-mcpu=@var{cpu_type}} does.
33956
33957The same values for @option{-mcpu=@var{cpu_type}} can be used for
33958@option{-mtune=@var{cpu_type}}, but the only useful values are those
33959that select a particular CPU implementation. Those are
33960@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
33961@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
33962@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
33963@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
33964@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
33965and GNU/Linux toolchains, @samp{native} can also be used.
33966
d77de738
ML
33967@opindex mv8plus
33968@opindex mno-v8plus
ddf6fe37
AA
33969@item -mv8plus
33970@itemx -mno-v8plus
d77de738
ML
33971With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
33972difference from the V8 ABI is that the global and out registers are
33973considered 64 bits wide. This is enabled by default on Solaris in 32-bit
33974mode for all SPARC-V9 processors.
33975
d77de738
ML
33976@opindex mvis
33977@opindex mno-vis
ddf6fe37
AA
33978@item -mvis
33979@itemx -mno-vis
d77de738
ML
33980With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
33981Visual Instruction Set extensions. The default is @option{-mno-vis}.
33982
d77de738
ML
33983@opindex mvis2
33984@opindex mno-vis2
ddf6fe37
AA
33985@item -mvis2
33986@itemx -mno-vis2
d77de738
ML
33987With @option{-mvis2}, GCC generates code that takes advantage of
33988version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
33989default is @option{-mvis2} when targeting a cpu that supports such
33990instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
33991also sets @option{-mvis}.
33992
d77de738
ML
33993@opindex mvis3
33994@opindex mno-vis3
ddf6fe37
AA
33995@item -mvis3
33996@itemx -mno-vis3
d77de738
ML
33997With @option{-mvis3}, GCC generates code that takes advantage of
33998version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
33999default is @option{-mvis3} when targeting a cpu that supports such
34000instructions, such as niagara-3 and later. Setting @option{-mvis3}
34001also sets @option{-mvis2} and @option{-mvis}.
34002
d309844d
EB
34003@opindex mvis3b
34004@opindex mno-vis3b
34005@item -mvis3b
34006@itemx -mno-vis3b
34007With @option{-mvis3b}, GCC generates code that takes advantage of
34008version 3.0 of the UltraSPARC Visual Instruction Set extensions, plus
34009the additional VIS instructions introduced in the Oracle SPARC
34010Architecture 2011. The default is @option{-mvis3b} when targeting
34011a cpu that supports such instructions, such as niagara-7 and later.
34012Setting @option{-mvis3b} also sets @option{-mvis3}, @option{-mvis2}
34013and @option{-mvis}.
34014
d77de738
ML
34015@opindex mvis4
34016@opindex mno-vis4
ddf6fe37
AA
34017@item -mvis4
34018@itemx -mno-vis4
d77de738
ML
34019With @option{-mvis4}, GCC generates code that takes advantage of
34020version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
34021default is @option{-mvis4} when targeting a cpu that supports such
34022instructions, such as niagara-7 and later. Setting @option{-mvis4}
d309844d
EB
34023also sets @option{-mvis3b}, @option{-mvis3}, @option{-mvis2} and
34024@option{-mvis}.
d77de738 34025
d77de738
ML
34026@opindex mvis4b
34027@opindex mno-vis4b
ddf6fe37
AA
34028@item -mvis4b
34029@itemx -mno-vis4b
d77de738
ML
34030With @option{-mvis4b}, GCC generates code that takes advantage of
34031version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
34032the additional VIS instructions introduced in the Oracle SPARC
34033Architecture 2017. The default is @option{-mvis4b} when targeting a
34034cpu that supports such instructions, such as m8 and later. Setting
d309844d
EB
34035@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3b},
34036@option{-mvis3}, @option{-mvis2} and @option{-mvis}.
d77de738 34037
d77de738
ML
34038@opindex mcbcond
34039@opindex mno-cbcond
ddf6fe37
AA
34040@item -mcbcond
34041@itemx -mno-cbcond
d77de738
ML
34042With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
34043Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
34044when targeting a CPU that supports such instructions, such as Niagara-4 and
34045later.
34046
d77de738
ML
34047@opindex mfmaf
34048@opindex mno-fmaf
ddf6fe37
AA
34049@item -mfmaf
34050@itemx -mno-fmaf
d77de738
ML
34051With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
34052Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
34053when targeting a CPU that supports such instructions, such as Niagara-3 and
34054later.
34055
d77de738
ML
34056@opindex mfsmuld
34057@opindex mno-fsmuld
ddf6fe37
AA
34058@item -mfsmuld
34059@itemx -mno-fsmuld
d77de738
ML
34060With @option{-mfsmuld}, GCC generates code that takes advantage of the
34061Floating-point Multiply Single to Double (FsMULd) instruction. The default is
34062@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
34063or V9 with FPU except @option{-mcpu=leon}.
34064
d77de738
ML
34065@opindex mpopc
34066@opindex mno-popc
ddf6fe37
AA
34067@item -mpopc
34068@itemx -mno-popc
d77de738
ML
34069With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
34070Population Count instruction. The default is @option{-mpopc}
34071when targeting a CPU that supports such an instruction, such as Niagara-2 and
34072later.
34073
d77de738
ML
34074@opindex msubxc
34075@opindex mno-subxc
ddf6fe37
AA
34076@item -msubxc
34077@itemx -mno-subxc
d77de738
ML
34078With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
34079Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
34080when targeting a CPU that supports such an instruction, such as Niagara-7 and
34081later.
34082
d77de738 34083@opindex mfix-at697f
ddf6fe37 34084@item -mfix-at697f
d77de738
ML
34085Enable the documented workaround for the single erratum of the Atmel AT697F
34086processor (which corresponds to erratum #13 of the AT697E processor).
34087
d77de738 34088@opindex mfix-ut699
ddf6fe37 34089@item -mfix-ut699
d77de738
ML
34090Enable the documented workarounds for the floating-point errata and the data
34091cache nullify errata of the UT699 processor.
34092
d77de738 34093@opindex mfix-ut700
ddf6fe37 34094@item -mfix-ut700
d77de738
ML
34095Enable the documented workaround for the back-to-back store errata of
34096the UT699E/UT700 processor.
34097
d77de738 34098@opindex mfix-gr712rc
ddf6fe37 34099@item -mfix-gr712rc
d77de738
ML
34100Enable the documented workaround for the back-to-back store errata of
34101the GR712RC processor.
34102@end table
34103
34104These @samp{-m} options are supported in addition to the above
34105on SPARC-V9 processors in 64-bit environments:
34106
34107@table @gcctabopt
d77de738
ML
34108@opindex m32
34109@opindex m64
ddf6fe37
AA
34110@item -m32
34111@itemx -m64
d77de738
ML
34112Generate code for a 32-bit or 64-bit environment.
34113The 32-bit environment sets int, long and pointer to 32 bits.
34114The 64-bit environment sets int to 32 bits and long and pointer
34115to 64 bits.
34116
a0d60660 34117@opindex mcmodel=
ddf6fe37 34118@item -mcmodel=@var{which}
d77de738
ML
34119Set the code model to one of
34120
34121@table @samp
34122@item medlow
34123The Medium/Low code model: 64-bit addresses, programs
34124must be linked in the low 32 bits of memory. Programs can be statically
34125or dynamically linked.
34126
34127@item medmid
34128The Medium/Middle code model: 64-bit addresses, programs
34129must be linked in the low 44 bits of memory, the text and data segments must
34130be less than 2GB in size and the data segment must be located within 2GB of
34131the text segment.
34132
34133@item medany
34134The Medium/Anywhere code model: 64-bit addresses, programs
34135may be linked anywhere in memory, the text and data segments must be less
34136than 2GB in size and the data segment must be located within 2GB of the
34137text segment.
34138
34139@item embmedany
34140The Medium/Anywhere code model for embedded systems:
3414164-bit addresses, the text and data segments must be less than 2GB in
34142size, both starting anywhere in memory (determined at link time). The
34143global register %g4 points to the base of the data segment. Programs
34144are statically linked and PIC is not supported.
34145@end table
34146
d77de738 34147@opindex mmemory-model
ddf6fe37 34148@item -mmemory-model=@var{mem-model}
d77de738
ML
34149Set the memory model in force on the processor to one of
34150
34151@table @samp
34152@item default
34153The default memory model for the processor and operating system.
34154
34155@item rmo
34156Relaxed Memory Order
34157
34158@item pso
34159Partial Store Order
34160
34161@item tso
34162Total Store Order
34163
34164@item sc
34165Sequential Consistency
34166@end table
34167
34168These memory models are formally defined in Appendix D of the SPARC-V9
34169architecture manual, as set in the processor's @code{PSTATE.MM} field.
34170
d77de738
ML
34171@opindex mstack-bias
34172@opindex mno-stack-bias
ddf6fe37
AA
34173@item -mstack-bias
34174@itemx -mno-stack-bias
d77de738
ML
34175With @option{-mstack-bias}, GCC assumes that the stack pointer, and
34176frame pointer if present, are offset by @minus{}2047 which must be added back
34177when making stack frame references. This is the default in 64-bit mode.
34178Otherwise, assume no such offset is present.
34179@end table
34180
34181@node System V Options
34182@subsection Options for System V
34183
34184These additional options are available on System V Release 4 for
34185compatibility with other compilers on those systems:
34186
34187@table @gcctabopt
d77de738 34188@opindex G
ddf6fe37 34189@item -G
d77de738
ML
34190Create a shared object.
34191It is recommended that @option{-symbolic} or @option{-shared} be used instead.
34192
d77de738 34193@opindex Qy
ddf6fe37 34194@item -Qy
d77de738
ML
34195Identify the versions of each tool used by the compiler, in a
34196@code{.ident} assembler directive in the output.
34197
d77de738 34198@opindex Qn
ddf6fe37 34199@item -Qn
d77de738
ML
34200Refrain from adding @code{.ident} directives to the output file (this is
34201the default).
34202
d77de738 34203@opindex YP
ddf6fe37 34204@item -YP,@var{dirs}
d77de738
ML
34205Search the directories @var{dirs}, and no others, for libraries
34206specified with @option{-l}.
34207
d77de738 34208@opindex Ym
ddf6fe37 34209@item -Ym,@var{dir}
d77de738
ML
34210Look in the directory @var{dir} to find the M4 preprocessor.
34211The assembler uses this option.
34212@c This is supposed to go with a -Yd for predefined M4 macro files, but
34213@c the generic assembler that comes with Solaris takes just -Ym.
34214@end table
34215
34216@node V850 Options
34217@subsection V850 Options
34218@cindex V850 Options
34219
34220These @samp{-m} options are defined for V850 implementations:
34221
34222@table @gcctabopt
d77de738
ML
34223@opindex mlong-calls
34224@opindex mno-long-calls
ddf6fe37
AA
34225@item -mlong-calls
34226@itemx -mno-long-calls
d77de738
ML
34227Treat all calls as being far away (near). If calls are assumed to be
34228far away, the compiler always loads the function's address into a
34229register, and calls indirect through the pointer.
34230
d77de738
ML
34231@opindex mno-ep
34232@opindex mep
ddf6fe37
AA
34233@item -mno-ep
34234@itemx -mep
d77de738
ML
34235Do not optimize (do optimize) basic blocks that use the same index
34236pointer 4 or more times to copy pointer into the @code{ep} register, and
34237use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
34238option is on by default if you optimize.
34239
d77de738
ML
34240@opindex mno-prolog-function
34241@opindex mprolog-function
ddf6fe37
AA
34242@item -mno-prolog-function
34243@itemx -mprolog-function
d77de738
ML
34244Do not use (do use) external functions to save and restore registers
34245at the prologue and epilogue of a function. The external functions
34246are slower, but use less code space if more than one function saves
34247the same number of registers. The @option{-mprolog-function} option
34248is on by default if you optimize.
34249
d77de738 34250@opindex mspace
ddf6fe37 34251@item -mspace
d77de738
ML
34252Try to make the code as small as possible. At present, this just turns
34253on the @option{-mep} and @option{-mprolog-function} options.
34254
d77de738 34255@opindex mtda
ddf6fe37 34256@item -mtda=@var{n}
d77de738
ML
34257Put static or global variables whose size is @var{n} bytes or less into
34258the tiny data area that register @code{ep} points to. The tiny data
34259area can hold up to 256 bytes in total (128 bytes for byte references).
34260
d77de738 34261@opindex msda
ddf6fe37 34262@item -msda=@var{n}
d77de738
ML
34263Put static or global variables whose size is @var{n} bytes or less into
34264the small data area that register @code{gp} points to. The small data
34265area can hold up to 64 kilobytes.
34266
d77de738 34267@opindex mzda
ddf6fe37 34268@item -mzda=@var{n}
d77de738
ML
34269Put static or global variables whose size is @var{n} bytes or less into
34270the first 32 kilobytes of memory.
34271
d77de738 34272@opindex mv850
ddf6fe37 34273@item -mv850
d77de738
ML
34274Specify that the target processor is the V850.
34275
d77de738 34276@opindex mv850e3v5
ddf6fe37 34277@item -mv850e3v5
d77de738
ML
34278Specify that the target processor is the V850E3V5. The preprocessor
34279constant @code{__v850e3v5__} is defined if this option is used.
34280
d77de738 34281@opindex mv850e2v4
ddf6fe37 34282@item -mv850e2v4
d77de738
ML
34283Specify that the target processor is the V850E3V5. This is an alias for
34284the @option{-mv850e3v5} option.
34285
d77de738 34286@opindex mv850e2v3
ddf6fe37 34287@item -mv850e2v3
d77de738
ML
34288Specify that the target processor is the V850E2V3. The preprocessor
34289constant @code{__v850e2v3__} is defined if this option is used.
34290
d77de738 34291@opindex mv850e2
ddf6fe37 34292@item -mv850e2
d77de738
ML
34293Specify that the target processor is the V850E2. The preprocessor
34294constant @code{__v850e2__} is defined if this option is used.
34295
d77de738 34296@opindex mv850e1
ddf6fe37 34297@item -mv850e1
d77de738
ML
34298Specify that the target processor is the V850E1. The preprocessor
34299constants @code{__v850e1__} and @code{__v850e__} are defined if
34300this option is used.
34301
d77de738 34302@opindex mv850es
ddf6fe37 34303@item -mv850es
d77de738
ML
34304Specify that the target processor is the V850ES. This is an alias for
34305the @option{-mv850e1} option.
34306
d77de738 34307@opindex mv850e
ddf6fe37 34308@item -mv850e
d77de738
ML
34309Specify that the target processor is the V850E@. The preprocessor
34310constant @code{__v850e__} is defined if this option is used.
34311
34312If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
34313nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
34314are defined then a default target processor is chosen and the
34315relevant @samp{__v850*__} preprocessor constant is defined.
34316
34317The preprocessor constants @code{__v850} and @code{__v851__} are always
34318defined, regardless of which processor variant is the target.
34319
d77de738
ML
34320@opindex mdisable-callt
34321@opindex mno-disable-callt
ddf6fe37
AA
34322@item -mdisable-callt
34323@itemx -mno-disable-callt
d77de738
ML
34324This option suppresses generation of the @code{CALLT} instruction for the
34325v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
34326architecture.
34327
34328This option is enabled by default when the RH850 ABI is
34329in use (see @option{-mrh850-abi}), and disabled by default when the
34330GCC ABI is in use. If @code{CALLT} instructions are being generated
34331then the C preprocessor symbol @code{__V850_CALLT__} is defined.
34332
d77de738
ML
34333@opindex mrelax
34334@opindex mno-relax
ddf6fe37
AA
34335@item -mrelax
34336@itemx -mno-relax
d77de738
ML
34337Pass on (or do not pass on) the @option{-mrelax} command-line option
34338to the assembler.
34339
d77de738
ML
34340@opindex mlong-jumps
34341@opindex mno-long-jumps
ddf6fe37
AA
34342@item -mlong-jumps
34343@itemx -mno-long-jumps
d77de738
ML
34344Disable (or re-enable) the generation of PC-relative jump instructions.
34345
d77de738
ML
34346@opindex msoft-float
34347@opindex mhard-float
ddf6fe37
AA
34348@item -msoft-float
34349@itemx -mhard-float
d77de738
ML
34350Disable (or re-enable) the generation of hardware floating point
34351instructions. This option is only significant when the target
34352architecture is @samp{V850E2V3} or higher. If hardware floating point
34353instructions are being generated then the C preprocessor symbol
34354@code{__FPU_OK__} is defined, otherwise the symbol
34355@code{__NO_FPU__} is defined.
34356
d77de738 34357@opindex mloop
ddf6fe37 34358@item -mloop
d77de738
ML
34359Enables the use of the e3v5 LOOP instruction. The use of this
34360instruction is not enabled by default when the e3v5 architecture is
34361selected because its use is still experimental.
34362
d77de738
ML
34363@opindex mrh850-abi
34364@opindex mghs
ddf6fe37
AA
34365@item -mrh850-abi
34366@itemx -mghs
d77de738
ML
34367Enables support for the RH850 version of the V850 ABI. This is the
34368default. With this version of the ABI the following rules apply:
34369
34370@itemize
34371@item
34372Integer sized structures and unions are returned via a memory pointer
34373rather than a register.
34374
34375@item
34376Large structures and unions (more than 8 bytes in size) are passed by
34377value.
34378
34379@item
34380Functions are aligned to 16-bit boundaries.
34381
34382@item
34383The @option{-m8byte-align} command-line option is supported.
34384
34385@item
34386The @option{-mdisable-callt} command-line option is enabled by
34387default. The @option{-mno-disable-callt} command-line option is not
34388supported.
34389@end itemize
34390
34391When this version of the ABI is enabled the C preprocessor symbol
34392@code{__V850_RH850_ABI__} is defined.
34393
d77de738 34394@opindex mgcc-abi
ddf6fe37 34395@item -mgcc-abi
d77de738
ML
34396Enables support for the old GCC version of the V850 ABI. With this
34397version of the ABI the following rules apply:
34398
34399@itemize
34400@item
34401Integer sized structures and unions are returned in register @code{r10}.
34402
34403@item
34404Large structures and unions (more than 8 bytes in size) are passed by
34405reference.
34406
34407@item
34408Functions are aligned to 32-bit boundaries, unless optimizing for
34409size.
34410
34411@item
34412The @option{-m8byte-align} command-line option is not supported.
34413
34414@item
34415The @option{-mdisable-callt} command-line option is supported but not
34416enabled by default.
34417@end itemize
34418
34419When this version of the ABI is enabled the C preprocessor symbol
34420@code{__V850_GCC_ABI__} is defined.
34421
d77de738
ML
34422@opindex m8byte-align
34423@opindex mno-8byte-align
ddf6fe37
AA
34424@item -m8byte-align
34425@itemx -mno-8byte-align
d77de738
ML
34426Enables support for @code{double} and @code{long long} types to be
34427aligned on 8-byte boundaries. The default is to restrict the
34428alignment of all objects to at most 4-bytes. When
34429@option{-m8byte-align} is in effect the C preprocessor symbol
34430@code{__V850_8BYTE_ALIGN__} is defined.
34431
d77de738 34432@opindex mbig-switch
ddf6fe37 34433@item -mbig-switch
d77de738
ML
34434Generate code suitable for big switch tables. Use this option only if
34435the assembler/linker complain about out of range branches within a switch
34436table.
34437
d77de738 34438@opindex mapp-regs
ddf6fe37 34439@item -mapp-regs
d77de738
ML
34440This option causes r2 and r5 to be used in the code generated by
34441the compiler. This setting is the default.
34442
d77de738 34443@opindex mno-app-regs
ddf6fe37 34444@item -mno-app-regs
d77de738
ML
34445This option causes r2 and r5 to be treated as fixed registers.
34446
34447@end table
34448
34449@node VAX Options
34450@subsection VAX Options
34451@cindex VAX options
34452
34453These @samp{-m} options are defined for the VAX:
34454
34455@table @gcctabopt
d77de738 34456@opindex munix
ddf6fe37 34457@item -munix
d77de738
ML
34458Do not output certain jump instructions (@code{aobleq} and so on)
34459that the Unix assembler for the VAX cannot handle across long
34460ranges.
34461
d77de738 34462@opindex mgnu
ddf6fe37 34463@item -mgnu
d77de738
ML
34464Do output those jump instructions, on the assumption that the
34465GNU assembler is being used.
34466
314448fc
MR
34467@opindex md
34468@opindex md-float
34469@item -md
34470@itemx -md-float
34471Use the D_floating data format for double-precision floating-point numbers
34472instead of G_floating.
34473
d77de738 34474@opindex mg
314448fc 34475@opindex mg-float
ddf6fe37 34476@item -mg
314448fc
MR
34477@itemx -mg-float
34478Use the G_floating data format for double-precision floating-point numbers
34479instead of D_floating.
d77de738 34480
d77de738
ML
34481@opindex mlra
34482@opindex mno-lra
ddf6fe37
AA
34483@item -mlra
34484@itemx -mno-lra
d77de738
ML
34485Enable Local Register Allocation. This is still experimental for the VAX,
34486so by default the compiler uses standard reload.
34487@end table
34488
34489@node Visium Options
34490@subsection Visium Options
34491@cindex Visium options
34492
34493@table @gcctabopt
34494
d77de738 34495@opindex mdebug
ddf6fe37 34496@item -mdebug
d77de738
ML
34497A program which performs file I/O and is destined to run on an MCM target
34498should be linked with this option. It causes the libraries libc.a and
34499libdebug.a to be linked. The program should be run on the target under
34500the control of the GDB remote debugging stub.
34501
d77de738 34502@opindex msim
ddf6fe37 34503@item -msim
d77de738
ML
34504A program which performs file I/O and is destined to run on the simulator
34505should be linked with option. This causes libraries libc.a and libsim.a to
34506be linked.
34507
d77de738
ML
34508@opindex mfpu
34509@opindex mhard-float
ddf6fe37
AA
34510@item -mfpu
34511@itemx -mhard-float
d77de738
ML
34512Generate code containing floating-point instructions. This is the
34513default.
34514
d77de738
ML
34515@opindex mno-fpu
34516@opindex msoft-float
ddf6fe37
AA
34517@item -mno-fpu
34518@itemx -msoft-float
d77de738
ML
34519Generate code containing library calls for floating-point.
34520
34521@option{-msoft-float} changes the calling convention in the output file;
34522therefore, it is only useful if you compile @emph{all} of a program with
34523this option. In particular, you need to compile @file{libgcc.a}, the
34524library that comes with GCC, with @option{-msoft-float} in order for
34525this to work.
34526
d77de738 34527@opindex mcpu
ddf6fe37 34528@item -mcpu=@var{cpu_type}
d77de738
ML
34529Set the instruction set, register set, and instruction scheduling parameters
34530for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
34531@samp{mcm}, @samp{gr5} and @samp{gr6}.
34532
34533@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
34534
34535By default (unless configured otherwise), GCC generates code for the GR5
a0e64a04 34536variant of the Visium architecture.
d77de738
ML
34537
34538With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
34539architecture. The only difference from GR5 code is that the compiler will
34540generate block move instructions.
34541
d77de738 34542@opindex mtune
ddf6fe37 34543@item -mtune=@var{cpu_type}
d77de738
ML
34544Set the instruction scheduling parameters for machine type @var{cpu_type},
34545but do not set the instruction set or register set that the option
34546@option{-mcpu=@var{cpu_type}} would.
34547
d77de738 34548@opindex msv-mode
ddf6fe37 34549@item -msv-mode
d77de738
ML
34550Generate code for the supervisor mode, where there are no restrictions on
34551the access to general registers. This is the default.
34552
d77de738 34553@opindex muser-mode
ddf6fe37 34554@item -muser-mode
d77de738
ML
34555Generate code for the user mode, where the access to some general registers
34556is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
34557mode; on the GR6, only registers r29 to r31 are affected.
34558@end table
34559
34560@node VMS Options
34561@subsection VMS Options
34562
34563These @samp{-m} options are defined for the VMS implementations:
34564
34565@table @gcctabopt
d77de738 34566@opindex mvms-return-codes
ddf6fe37 34567@item -mvms-return-codes
d77de738
ML
34568Return VMS condition codes from @code{main}. The default is to return POSIX-style
34569condition (e.g.@: error) codes.
34570
d77de738 34571@opindex mdebug-main=@var{prefix}
ddf6fe37 34572@item -mdebug-main=@var{prefix}
d77de738
ML
34573Flag the first routine whose name starts with @var{prefix} as the main
34574routine for the debugger.
34575
d77de738 34576@opindex mmalloc64
ddf6fe37 34577@item -mmalloc64
d77de738
ML
34578Default to 64-bit memory allocation routines.
34579
d77de738 34580@opindex mpointer-size=@var{size}
ddf6fe37 34581@item -mpointer-size=@var{size}
d77de738
ML
34582Set the default size of pointers. Possible options for @var{size} are
34583@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
34584for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
34585The later option disables @code{pragma pointer_size}.
34586@end table
34587
34588@node VxWorks Options
34589@subsection VxWorks Options
34590@cindex VxWorks Options
34591
34592The options in this section are defined for all VxWorks targets.
34593Options specific to the target hardware are listed with the other
34594options for that target.
34595
34596@table @gcctabopt
d77de738 34597@opindex mrtp
ddf6fe37 34598@item -mrtp
d77de738
ML
34599GCC can generate code for both VxWorks kernels and real time processes
34600(RTPs). This option switches from the former to the latter. It also
34601defines the preprocessor macro @code{__RTP__}.
34602
b6f4b000
AO
34603@opindex msmp
34604@item -msmp
34605Select SMP runtimes for linking. Not available on architectures other
34606than PowerPC, nor on VxWorks version 7 or later, in which the selection
34607is part of the VxWorks build configuration and the library paths are the
34608same for either choice.
34609
d77de738 34610@opindex non-static
ddf6fe37 34611@item -non-static
d77de738
ML
34612Link an RTP executable against shared libraries rather than static
34613libraries. The options @option{-static} and @option{-shared} can
34614also be used for RTPs (@pxref{Link Options}); @option{-static}
34615is the default.
34616
d77de738
ML
34617@opindex Bstatic
34618@opindex Bdynamic
ddf6fe37
AA
34619@item -Bstatic
34620@itemx -Bdynamic
d77de738
ML
34621These options are passed down to the linker. They are defined for
34622compatibility with Diab.
34623
d77de738 34624@opindex Xbind-lazy
ddf6fe37 34625@item -Xbind-lazy
d77de738
ML
34626Enable lazy binding of function calls. This option is equivalent to
34627@option{-Wl,-z,now} and is defined for compatibility with Diab.
34628
d77de738 34629@opindex Xbind-now
ddf6fe37 34630@item -Xbind-now
d77de738
ML
34631Disable lazy binding of function calls. This option is the default and
34632is defined for compatibility with Diab.
34633@end table
34634
34635@node x86 Options
34636@subsection x86 Options
34637@cindex x86 Options
34638
34639These @samp{-m} options are defined for the x86 family of computers.
34640
34641@table @gcctabopt
34642
d77de738 34643@opindex march
ddf6fe37 34644@item -march=@var{cpu-type}
d77de738 34645Generate instructions for the machine type @var{cpu-type}. In contrast to
a0e64a04 34646@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
d77de738
ML
34647for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
34648to generate code that may not run at all on processors other than the one
a0e64a04 34649indicated. Specifying @option{-march=@var{cpu-type}} implies
d77de738
ML
34650@option{-mtune=@var{cpu-type}}, except where noted otherwise.
34651
34652The choices for @var{cpu-type} are:
34653
34654@table @samp
34655@item native
34656This selects the CPU to generate code for at compilation time by determining
34657the processor type of the compiling machine. Using @option{-march=native}
34658enables all instruction subsets supported by the local machine (hence
34659the result might not run on different machines). Using @option{-mtune=native}
34660produces code optimized for the local machine under the constraints
a0e64a04 34661of the selected instruction set.
d77de738
ML
34662
34663@item x86-64
342f1663
SL
34664A generic CPU with 64-bit extensions, MMX, SSE, SSE2, and FXSR instruction set
34665support.
d77de738
ML
34666
34667@item x86-64-v2
34668@itemx x86-64-v3
34669@itemx x86-64-v4
34670These choices for @var{cpu-type} select the corresponding
34671micro-architecture level from the x86-64 psABI. On ABIs other than
34672the x86-64 psABI they select the same CPU features as the x86-64 psABI
34673documents for the particular micro-architecture level.
34674
34675Since these @var{cpu-type} values do not have a corresponding
34676@option{-mtune} setting, using @option{-march} with these values enables
34677generic tuning. Specific tuning can be enabled using the
34678@option{-mtune=@var{other-cpu-type}} option with an appropriate
34679@var{other-cpu-type} value.
34680
34681@item i386
34682Original Intel i386 CPU@.
34683
34684@item i486
34685Intel i486 CPU@. (No scheduling is implemented for this chip.)
34686
34687@item i586
34688@itemx pentium
34689Intel Pentium CPU with no MMX support.
34690
34691@item lakemont
34692Intel Lakemont MCU, based on Intel Pentium CPU.
34693
34694@item pentium-mmx
34695Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
34696
34697@item pentiumpro
f7a2f0aa 34698Intel Pentium Pro CPU with no MMX support.
d77de738
ML
34699
34700@item i686
34701When used with @option{-march}, the Pentium Pro
34702instruction set is used, so the code runs on all i686 family chips.
34703When used with @option{-mtune}, it has the same meaning as @samp{generic}.
34704
34705@item pentium2
34706Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
34707set support.
34708
34709@item pentium3
34710@itemx pentium3m
34711Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
34712instruction set support.
34713
34714@item pentium-m
34715Intel Pentium M; low-power version of Intel Pentium III CPU
34716with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
34717notebooks.
34718
34719@item pentium4
34720@itemx pentium4m
34721Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
34722
34723@item prescott
34724Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
34725instruction set support.
34726
34727@item nocona
34728Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
34729SSE2, SSE3 and FXSR instruction set support.
34730
34731@item core2
34732Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
34733SAHF and FXSR instruction set support.
34734
34735@item nehalem
877fb9bd 34736@itemx corei7
d77de738
ML
34737Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34738SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
34739
34740@item westmere
34741Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34742SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
34743
34744@item sandybridge
877fb9bd 34745@itemx corei7-avx
d77de738
ML
34746Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34747SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
34748support.
34749
34750@item ivybridge
877fb9bd 34751@itemx core-avx-i
d77de738
ML
34752Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34753SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
34754and F16C instruction set support.
34755
34756@item haswell
877fb9bd 34757@itemx core-avx2
aa85a5a6 34758Intel Haswell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
d77de738
ML
34759SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34760F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
34761
34762@item broadwell
aa85a5a6 34763Intel Broadwell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
d77de738
ML
34764SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34765F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
34766instruction set support.
34767
34768@item skylake
aa85a5a6 34769Intel Skylake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
d77de738
ML
34770SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34771F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34772CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
34773
d77de738 34774@item skylake-avx512
aa85a5a6 34775Intel Skylake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
d77de738
ML
34776SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34777RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34778AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
34779AVX512DQ and AVX512CD instruction set support.
34780
877fb9bd
HJ
34781@item cascadelake
34782Intel Cascade Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34783SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34784F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34785CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34786AVX512CD and AVX512VNNI instruction set support.
34787
d77de738 34788@item cannonlake
877fb9bd 34789Intel Cannon Lake Server CPU with 64-bit extensions, MMX, SSE, SSE2,
d77de738
ML
34790SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34791FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34792PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34793AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
34794support.
34795
877fb9bd
HJ
34796@item cooperlake
34797Intel Cooper Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34798SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34799F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34800CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34801AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
34802
d77de738 34803@item icelake-client
877fb9bd 34804Intel Ice Lake Client CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
d77de738
ML
34805SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34806RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34807AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34808AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34809, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34810
34811@item icelake-server
877fb9bd 34812Intel Ice Lake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
d77de738
ML
34813SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34814RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34815AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34816AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34817, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
34818instruction set support.
34819
d77de738 34820@item tigerlake
877fb9bd 34821Intel Tiger Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
d77de738
ML
34822SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34823F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34824CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34825PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34826VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
34827AVX512VP2INTERSECT and KEYLOCKER instruction set support.
34828
877fb9bd
HJ
34829@item rocketlake
34830Intel Rocket Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34831SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34832F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34833CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34834PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34835VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
d77de738
ML
34836
34837@item alderlake
91bc2ad2
HJ
34838@itemx raptorlake
34839@itemx meteorlake
877fb9bd
HJ
34840@itemx gracemont
34841Intel Alder Lake/Raptor Lake/Meteor Lake/Gracemont CPU with 64-bit extensions,
34842MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW,
34843PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX,
0c701c7d
HJ
34844GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C,
34845FMA, LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and
34846AVX-VNNI instruction set support.
877fb9bd
HJ
34847
34848@item arrowlake
34849Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34850SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34851XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
0c701c7d
HJ
34852MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34853VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
34854AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
877fb9bd
HJ
34855
34856@item arrowlake-s
34857@itemx lunarlake
34858Intel Arrow Lake S/Lunar Lake CPU with 64-bit extensions, MOVBE, MMX, SSE,
34859SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND,
91bc2ad2 34860XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
0c701c7d
HJ
34861MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34862PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR,
34863AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3 and
34864SM4 instruction set support.
d77de738 34865
877fb9bd
HJ
34866@item pantherlake
34867Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34868SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34869XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
0c701c7d
HJ
34870MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34871VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
34872AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 and
34873PREFETCHI instruction set support.
877fb9bd
HJ
34874
34875@item sapphirerapids
34876@itemx emeraldrapids
34877Intel Sapphire Rapids/Emerald Rapids CPU with 64-bit extensions, MMX, SSE,
34878SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34879FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34880PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34881AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES,
34882AVX512VBMI2, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG,
34883WBNOINVD, CLWB, MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
34884SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16
34885and AVX512BF16 instruction set support.
d77de738
ML
34886
34887@item graniterapids
877fb9bd 34888Intel Granite Rapids CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
d77de738
ML
34889SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34890RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34891AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34892AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34893VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
34894MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34895UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
34896and PREFETCHI instruction set support.
d77de738 34897
a0cb65d3 34898@item graniterapids-d
877fb9bd 34899Intel Granite Rapids D CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
a0cb65d3
MZ
34900SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34901RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34902AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34903AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34904VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
34905MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34906UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34907PREFETCHI and AMX-COMPLEX instruction set support.
a0cb65d3 34908
74ae651b
HJ
34909@item diamondrapids
34910Intel Diamond Rapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34911SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34912RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34913AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34914AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34915VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34916MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34917UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34918PREFETCHI, AMX-COMPLEX, AVX10.1-512, AVX-IFMA, AVX-NE-CONVERT, AVX-VNNI-INT16,
34919AVX-VNNI-INT8, CMPccXADD, SHA512, SM3, SM4, AVX10.2-512, APX_F, AMX-AVX512,
34920AMX-FP8, AMX-TF32, AMX-TRANSPOSE, MOVRS, AMX-MOVRS and USER_MSR instruction set
34921support.
34922
877fb9bd
HJ
34923@item bonnell
34924@itemx atom
34925Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
34926instruction set support.
34927
34928@item silvermont
34929@itemx slm
34930Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34931SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
34932instruction set support.
34933
34934@item goldmont
34935Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34936SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34937RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
34938set support.
34939
34940@item goldmont-plus
34941Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34942SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
34943SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
34944RDPID and SGX instruction set support.
34945
34946@item tremont
34947Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34948SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34949RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
34950SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
34951support.
34952
34953@item sierraforest
34954Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
faa0e82b
HJ
34955SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34956XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34957MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34958PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
877fb9bd 34959AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
faa0e82b
HJ
34960support.
34961
877fb9bd
HJ
34962@item grandridge
34963Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
faa0e82b
HJ
34964SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34965XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34966MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34967PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
877fb9bd
HJ
34968AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34969support.
34970
34971@item clearwaterforest
34972Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34973SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
34974XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
34975MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
34976LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34977ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
34978SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
faa0e82b 34979
d77de738
ML
34980@item k6
34981AMD K6 CPU with MMX instruction set support.
34982
34983@item k6-2
34984@itemx k6-3
34985Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
34986
34987@item athlon
34988@itemx athlon-tbird
34989AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
34990support.
34991
34992@item athlon-4
34993@itemx athlon-xp
34994@itemx athlon-mp
34995Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
34996instruction set support.
34997
34998@item k8
34999@itemx opteron
35000@itemx athlon64
35001@itemx athlon-fx
35002Processors based on the AMD K8 core with x86-64 instruction set support,
35003including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
35004(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
35005instruction set extensions.)
35006
35007@item k8-sse3
35008@itemx opteron-sse3
35009@itemx athlon64-sse3
35010Improved versions of AMD K8 cores with SSE3 instruction set support.
35011
35012@item amdfam10
35013@itemx barcelona
35014CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
35015supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
35016instruction set extensions.)
35017
35018@item bdver1
35019CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
35020supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
35021SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
35022
35023@item bdver2
35024AMD Family 15h core based CPUs with x86-64 instruction set support. (This
35025supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
a0e64a04 35026SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
d77de738
ML
35027extensions.)
35028
35029@item bdver3
35030AMD Family 15h core based CPUs with x86-64 instruction set support. (This
a0e64a04 35031supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
d77de738
ML
35032PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3503364-bit instruction set extensions.)
35034
35035@item bdver4
35036AMD Family 15h core based CPUs with x86-64 instruction set support. (This
a0e64a04 35037supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
d77de738
ML
35038AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
35039SSE4.2, ABM and 64-bit instruction set extensions.)
35040
35041@item znver1
35042AMD Family 17h core based CPUs with x86-64 instruction set support. (This
35043supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
35044SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
35045SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
35046instruction set extensions.)
35047
35048@item znver2
35049AMD Family 17h core based CPUs with x86-64 instruction set support. (This
35050supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35051MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35052SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35053WBNOINVD, and 64-bit instruction set extensions.)
35054
35055@item znver3
35056AMD Family 19h core based CPUs with x86-64 instruction set support. (This
35057supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35058MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35059SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35060WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
35061
35062@item znver4
35063AMD Family 19h core based CPUs with x86-64 instruction set support. (This
35064supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35065MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35066SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35067WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
35068AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
35069AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
35070
d0aa0af9
JH
35071@item znver5
35072AMD Family 1ah core based CPUs with x86-64 instruction set support. (This
35073supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35074MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35075SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35076WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
35077AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
35078AVX512BITALG, AVX512VPOPCNTDQ, GFNI, AVXVNNI, MOVDIRI, MOVDIR64B,
35079AVX512VP2INTERSECT, PREFETCHI and 64-bit instruction set extensions.)
35080
d77de738
ML
35081@item btver1
35082CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
35083supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
35084instruction set extensions.)
35085
35086@item btver2
35087CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
35088includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
35089SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
35090
35091@item winchip-c6
35092IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
35093set support.
35094
35095@item winchip2
35096IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
35097instruction set support.
35098
35099@item c3
35100VIA C3 CPU with MMX and 3DNow!@: instruction set support.
35101(No scheduling is implemented for this chip.)
35102
35103@item c3-2
35104VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
35105(No scheduling is implemented for this chip.)
35106
35107@item c7
35108VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
35109(No scheduling is implemented for this chip.)
35110
35111@item samuel-2
35112VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
35113(No scheduling is implemented for this chip.)
35114
35115@item nehemiah
35116VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
35117(No scheduling is implemented for this chip.)
35118
35119@item esther
35120VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
35121(No scheduling is implemented for this chip.)
35122
35123@item eden-x2
35124VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
35125(No scheduling is implemented for this chip.)
35126
35127@item eden-x4
35128VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
35129AVX and AVX2 instruction set support.
35130(No scheduling is implemented for this chip.)
35131
35132@item nano
35133Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35134instruction set support.
35135(No scheduling is implemented for this chip.)
35136
35137@item nano-1000
35138VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35139instruction set support.
35140(No scheduling is implemented for this chip.)
35141
35142@item nano-2000
35143VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35144instruction set support.
35145(No scheduling is implemented for this chip.)
35146
35147@item nano-3000
35148VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35149instruction set support.
35150(No scheduling is implemented for this chip.)
35151
35152@item nano-x2
35153VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35154instruction set support.
35155(No scheduling is implemented for this chip.)
35156
35157@item nano-x4
35158VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35159instruction set support.
35160(No scheduling is implemented for this chip.)
35161
35162@item lujiazui
35163ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
09b4ab53
JJ
35164SSE4.2, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35165ABM, BMI, BMI2, FXSR, RDSEED instruction set support. While the CPUs
35166do support AVX and F16C, these aren't enabled by @code{-march=lujiazui}
35167for performance reasons.
d77de738 35168
94c0b26f
M
35169@item yongfeng
35170ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
35171SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35172ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
35173instruction set support.
35174
6f6ea27d 35175@item shijidadao
35176ZHAOXIN shijidadao CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
35177SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35178ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
35179instruction set support.
35180
d77de738
ML
35181@item geode
35182AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
35183@end table
35184
d77de738 35185@opindex mtune
ddf6fe37 35186@item -mtune=@var{cpu-type}
d77de738 35187Tune to @var{cpu-type} everything applicable about the generated code, except
a0e64a04 35188for the ABI and the set of available instructions.
d77de738
ML
35189While picking a specific @var{cpu-type} schedules things appropriately
35190for that particular chip, the compiler does not generate any code that
35191cannot run on the default machine type unless you use a
35192@option{-march=@var{cpu-type}} option.
35193For example, if GCC is configured for i686-pc-linux-gnu
35194then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
35195but still runs on i686 machines.
35196
35197The choices for @var{cpu-type} are the same as for @option{-march}.
35198In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
35199
35200@table @samp
35201@item generic
35202Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
35203If you know the CPU on which your code will run, then you should use
35204the corresponding @option{-mtune} or @option{-march} option instead of
35205@option{-mtune=generic}. But, if you do not know exactly what CPU users
35206of your application will have, then you should use this option.
35207
35208As new processors are deployed in the marketplace, the behavior of this
35209option will change. Therefore, if you upgrade to a newer version of
35210GCC, code generation controlled by this option will change to reflect
35211the processors
35212that are most common at the time that version of GCC is released.
35213
35214There is no @option{-march=generic} option because @option{-march}
35215indicates the instruction set the compiler can use, and there is no
35216generic instruction set applicable to all processors. In contrast,
35217@option{-mtune} indicates the processor (or, in this case, collection of
35218processors) for which the code is optimized.
35219
35220@item intel
35221Produce code optimized for the most current Intel processors, which are
35222Haswell and Silvermont for this version of GCC. If you know the CPU
35223on which your code will run, then you should use the corresponding
35224@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
7fd6cb3c
L
35225But, if you want your application performs better on both Diamond Rapids
35226and Clearwater Forest, then you should use this option.
d77de738
ML
35227
35228As new Intel processors are deployed in the marketplace, the behavior of
35229this option will change. Therefore, if you upgrade to a newer version of
35230GCC, code generation controlled by this option will change to reflect
35231the most current Intel processors at the time that version of GCC is
35232released.
35233
35234There is no @option{-march=intel} option because @option{-march} indicates
35235the instruction set the compiler can use, and there is no common
35236instruction set applicable to all processors. In contrast,
35237@option{-mtune} indicates the processor (or, in this case, collection of
35238processors) for which the code is optimized.
35239@end table
35240
d77de738 35241@opindex mcpu
ddf6fe37 35242@item -mcpu=@var{cpu-type}
d77de738
ML
35243A deprecated synonym for @option{-mtune}.
35244
d77de738 35245@opindex mfpmath
ddf6fe37 35246@item -mfpmath=@var{unit}
d77de738
ML
35247Generate floating-point arithmetic for selected unit @var{unit}. The choices
35248for @var{unit} are:
35249
35250@table @samp
35251@item 387
35252Use the standard 387 floating-point coprocessor present on the majority of chips and
35253emulated otherwise. Code compiled with this option runs almost everywhere.
35254The temporary results are computed in 80-bit precision instead of the precision
35255specified by the type, resulting in slightly different results compared to most
35256of other chips. See @option{-ffloat-store} for more detailed description.
35257
35258This is the default choice for non-Darwin x86-32 targets.
35259
35260@item sse
35261Use scalar floating-point instructions present in the SSE instruction set.
35262This instruction set is supported by Pentium III and newer chips,
35263and in the AMD line
35264by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
35265instruction set supports only single-precision arithmetic, thus the double and
35266extended-precision arithmetic are still done using 387. A later version, present
35267only in Pentium 4 and AMD x86-64 chips, supports double-precision
35268arithmetic too.
35269
35270For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
35271or @option{-msse2} switches to enable SSE extensions and make this option
35272effective. For the x86-64 compiler, these extensions are enabled by default.
35273
35274The resulting code should be considerably faster in the majority of cases and avoid
35275the numerical instability problems of 387 code, but may break some existing
35276code that expects temporaries to be 80 bits.
35277
35278This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
35279and the default choice for x86-32 targets with the SSE2 instruction set
35280when @option{-ffast-math} is enabled.
35281
35282@item sse,387
35283@itemx sse+387
35284@itemx both
35285Attempt to utilize both instruction sets at once. This effectively doubles the
35286amount of available registers, and on chips with separate execution units for
35287387 and SSE the execution resources too. Use this option with care, as it is
35288still experimental, because the GCC register allocator does not model separate
35289functional units well, resulting in unstable performance.
35290@end table
35291
d77de738 35292@opindex masm=@var{dialect}
ddf6fe37 35293@item -masm=@var{dialect}
d77de738
ML
35294Output assembly instructions using selected @var{dialect}. Also affects
35295which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
35296extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
35297order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
35298not support @samp{intel}.
35299
d77de738
ML
35300@opindex mieee-fp
35301@opindex mno-ieee-fp
ddf6fe37
AA
35302@item -mieee-fp
35303@itemx -mno-ieee-fp
d77de738
ML
35304Control whether or not the compiler uses IEEE floating-point
35305comparisons. These correctly handle the case where the result of a
35306comparison is unordered.
35307
30348d30 35308@opindex m80387
d77de738 35309@opindex mhard-float
ddf6fe37
AA
35310@item -m80387
35311@itemx -mhard-float
d77de738
ML
35312Generate output containing 80387 instructions for floating point.
35313
d77de738
ML
35314@opindex no-80387
35315@opindex msoft-float
ddf6fe37
AA
35316@item -mno-80387
35317@itemx -msoft-float
d77de738
ML
35318Generate output containing library calls for floating point.
35319
35320@strong{Warning:} the requisite libraries are not part of GCC@.
35321Normally the facilities of the machine's usual C compiler are used, but
35322this cannot be done directly in cross-compilation. You must make your
35323own arrangements to provide suitable library functions for
35324cross-compilation.
35325
35326On machines where a function returns floating-point results in the 80387
35327register stack, some floating-point opcodes may be emitted even if
35328@option{-msoft-float} is used.
35329
d77de738
ML
35330@opindex mno-fp-ret-in-387
35331@opindex mfp-ret-in-387
ddf6fe37 35332@item -mno-fp-ret-in-387
d77de738
ML
35333Do not use the FPU registers for return values of functions.
35334
35335The usual calling convention has functions return values of types
35336@code{float} and @code{double} in an FPU register, even if there
35337is no FPU@. The idea is that the operating system should emulate
35338an FPU@.
35339
35340The option @option{-mno-fp-ret-in-387} causes such values to be returned
35341in ordinary CPU registers instead.
35342
d77de738
ML
35343@opindex mno-fancy-math-387
35344@opindex mfancy-math-387
ddf6fe37 35345@item -mno-fancy-math-387
d77de738
ML
35346Some 387 emulators do not support the @code{sin}, @code{cos} and
35347@code{sqrt} instructions for the 387. Specify this option to avoid
35348generating those instructions.
35349This option is overridden when @option{-march}
35350indicates that the target CPU always has an FPU and so the
35351instruction does not need emulation. These
35352instructions are not generated unless you also use the
35353@option{-funsafe-math-optimizations} switch.
35354
d77de738
ML
35355@opindex malign-double
35356@opindex mno-align-double
ddf6fe37
AA
35357@item -malign-double
35358@itemx -mno-align-double
d77de738
ML
35359Control whether GCC aligns @code{double}, @code{long double}, and
35360@code{long long} variables on a two-word boundary or a one-word
35361boundary. Aligning @code{double} variables on a two-word boundary
35362produces code that runs somewhat faster on a Pentium at the
35363expense of more memory.
35364
35365On x86-64, @option{-malign-double} is enabled by default.
35366
35367@strong{Warning:} if you use the @option{-malign-double} switch,
35368structures containing the above types are aligned differently than
35369the published application binary interface specifications for the x86-32
35370and are not binary compatible with structures in code compiled
35371without that switch.
35372
d77de738
ML
35373@opindex m96bit-long-double
35374@opindex m128bit-long-double
ddf6fe37
AA
35375@item -m96bit-long-double
35376@itemx -m128bit-long-double
d77de738
ML
35377These switches control the size of @code{long double} type. The x86-32
35378application binary interface specifies the size to be 96 bits,
35379so @option{-m96bit-long-double} is the default in 32-bit mode.
35380
35381Modern architectures (Pentium and newer) prefer @code{long double}
35382to be aligned to an 8- or 16-byte boundary. In arrays or structures
35383conforming to the ABI, this is not possible. So specifying
35384@option{-m128bit-long-double} aligns @code{long double}
35385to a 16-byte boundary by padding the @code{long double} with an additional
3538632-bit zero.
35387
35388In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
35389its ABI specifies that @code{long double} is aligned on 16-byte boundary.
35390
35391Notice that neither of these options enable any extra precision over the x87
35392standard of 80 bits for a @code{long double}.
35393
35394@strong{Warning:} if you override the default value for your target ABI, this
a0e64a04 35395changes the size of
d77de738
ML
35396structures and arrays containing @code{long double} variables,
35397as well as modifying the function calling convention for functions taking
35398@code{long double}. Hence they are not binary-compatible
35399with code compiled without that switch.
35400
d77de738
ML
35401@opindex mlong-double-64
35402@opindex mlong-double-80
35403@opindex mlong-double-128
ddf6fe37
AA
35404@item -mlong-double-64
35405@itemx -mlong-double-80
35406@itemx -mlong-double-128
d77de738
ML
35407These switches control the size of @code{long double} type. A size
35408of 64 bits makes the @code{long double} type equivalent to the @code{double}
35409type. This is the default for 32-bit Bionic C library. A size
35410of 128 bits makes the @code{long double} type equivalent to the
35411@code{__float128} type. This is the default for 64-bit Bionic C library.
35412
35413@strong{Warning:} if you override the default value for your target ABI, this
35414changes the size of
35415structures and arrays containing @code{long double} variables,
35416as well as modifying the function calling convention for functions taking
35417@code{long double}. Hence they are not binary-compatible
35418with code compiled without that switch.
35419
d77de738 35420@opindex malign-data
ddf6fe37 35421@item -malign-data=@var{type}
d77de738
ML
35422Control how GCC aligns variables. Supported values for @var{type} are
35423@samp{compat} uses increased alignment value compatible uses GCC 4.8
35424and earlier, @samp{abi} uses alignment value as specified by the
35425psABI, and @samp{cacheline} uses increased alignment value to match
35426the cache line size. @samp{compat} is the default.
35427
d77de738 35428@opindex mlarge-data-threshold
ddf6fe37 35429@item -mlarge-data-threshold=@var{threshold}
1a64156c
UB
35430When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
35431objects larger than @var{threshold} are placed in large data sections. The
35432default is 65535.
d77de738 35433
d77de738 35434@opindex mrtd
ddf6fe37 35435@item -mrtd
d77de738
ML
35436Use a different function-calling convention, in which functions that
35437take a fixed number of arguments return with the @code{ret @var{num}}
35438instruction, which pops their arguments while returning. This saves one
35439instruction in the caller since there is no need to pop the arguments
35440there.
35441
35442You can specify that an individual function is called with this calling
35443sequence with the function attribute @code{stdcall}. You can also
35444override the @option{-mrtd} option by using the function attribute
35445@code{cdecl}. @xref{Function Attributes}.
35446
35447@strong{Warning:} this calling convention is incompatible with the one
35448normally used on Unix, so you cannot use it if you need to call
35449libraries compiled with the Unix compiler.
35450
35451Also, you must provide function prototypes for all functions that
35452take variable numbers of arguments (including @code{printf});
35453otherwise incorrect code is generated for calls to those
35454functions.
35455
35456In addition, seriously incorrect code results if you call a
35457function with too many arguments. (Normally, extra arguments are
35458harmlessly ignored.)
35459
d77de738 35460@opindex mregparm
ddf6fe37 35461@item -mregparm=@var{num}
d77de738
ML
35462Control how many registers are used to pass integer arguments. By
35463default, no registers are used to pass arguments, and at most 3
35464registers can be used. You can control this behavior for a specific
35465function by using the function attribute @code{regparm}.
35466@xref{Function Attributes}.
35467
35468@strong{Warning:} if you use this switch, and
35469@var{num} is nonzero, then you must build all modules with the same
35470value, including any libraries. This includes the system libraries and
35471startup modules.
35472
d77de738 35473@opindex msseregparm
ddf6fe37 35474@item -msseregparm
d77de738
ML
35475Use SSE register passing conventions for float and double arguments
35476and return values. You can control this behavior for a specific
35477function by using the function attribute @code{sseregparm}.
35478@xref{Function Attributes}.
35479
35480@strong{Warning:} if you use this switch then you must build all
35481modules with the same value, including any libraries. This includes
35482the system libraries and startup modules.
35483
d77de738 35484@opindex mvect8-ret-in-mem
ddf6fe37 35485@item -mvect8-ret-in-mem
d77de738
ML
35486Return 8-byte vectors in memory instead of MMX registers. This is the
35487default on VxWorks to match the ABI of the Sun Studio compilers until
35488version 12. @emph{Only} use this option if you need to remain
35489compatible with existing code produced by those previous compiler
35490versions or older versions of GCC@.
35491
d77de738
ML
35492@opindex mpc32
35493@opindex mpc64
35494@opindex mpc80
ddf6fe37
AA
35495@item -mpc32
35496@itemx -mpc64
35497@itemx -mpc80
d77de738
ML
35498
35499Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
35500is specified, the significands of results of floating-point operations are
35501rounded to 24 bits (single precision); @option{-mpc64} rounds the
35502significands of results of floating-point operations to 53 bits (double
35503precision) and @option{-mpc80} rounds the significands of results of
35504floating-point operations to 64 bits (extended double precision), which is
35505the default. When this option is used, floating-point operations in higher
35506precisions are not available to the programmer without setting the FPU
35507control word explicitly.
35508
35509Setting the rounding of floating-point operations to less than the default
3551080 bits can speed some programs by 2% or more. Note that some mathematical
35511libraries assume that extended-precision (80-bit) floating-point operations
35512are enabled by default; routines in such libraries could suffer significant
35513loss of accuracy, typically through so-called ``catastrophic cancellation'',
35514when this option is used to set the precision to less than extended precision.
35515
e54375d8 35516@opindex mdaz-ftz
ddf6fe37 35517@item -mdaz-ftz
e54375d8 35518
35519The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
35520are used to control floating-point calculations.SSE and AVX instructions
35521including scalar and vector instructions could benefit from enabling the FTZ
35522and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
35523when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
35524will set FTZ/DAZ flags even with @option{-shared}.
35525
d77de738 35526@opindex mstackrealign
ddf6fe37 35527@item -mstackrealign
d77de738
ML
35528Realign the stack at entry. On the x86, the @option{-mstackrealign}
35529option generates an alternate prologue and epilogue that realigns the
35530run-time stack if necessary. This supports mixing legacy codes that keep
355314-byte stack alignment with modern codes that keep 16-byte stack alignment for
35532SSE compatibility. See also the attribute @code{force_align_arg_pointer},
35533applicable to individual functions.
35534
d77de738 35535@opindex mpreferred-stack-boundary
ddf6fe37 35536@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
35537Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
35538byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
35539the default is 4 (16 bytes or 128 bits).
35540
35541@strong{Warning:} When generating code for the x86-64 architecture with
35542SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
35543used to keep the stack boundary aligned to 8 byte boundary. Since
35544x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
35545intended to be used in controlled environment where stack space is
35546important limitation. This option leads to wrong code when functions
35547compiled with 16 byte stack alignment (such as functions from a standard
35548library) are called with misaligned stack. In this case, SSE
35549instructions may lead to misaligned memory access traps. In addition,
35550variable arguments are handled incorrectly for 16 byte aligned
35551objects (including x87 long double and __int128), leading to wrong
35552results. You must build all modules with
35553@option{-mpreferred-stack-boundary=3}, including any libraries. This
35554includes the system libraries and startup modules.
35555
d77de738 35556@opindex mincoming-stack-boundary
ddf6fe37 35557@item -mincoming-stack-boundary=@var{num}
d77de738
ML
35558Assume the incoming stack is aligned to a 2 raised to @var{num} byte
35559boundary. If @option{-mincoming-stack-boundary} is not specified,
35560the one specified by @option{-mpreferred-stack-boundary} is used.
35561
35562On Pentium and Pentium Pro, @code{double} and @code{long double} values
35563should be aligned to an 8-byte boundary (see @option{-malign-double}) or
35564suffer significant run time performance penalties. On Pentium III, the
35565Streaming SIMD Extension (SSE) data type @code{__m128} may not work
35566properly if it is not 16-byte aligned.
35567
35568To ensure proper alignment of this values on the stack, the stack boundary
35569must be as aligned as that required by any value stored on the stack.
35570Further, every function must be generated such that it keeps the stack
35571aligned. Thus calling a function compiled with a higher preferred
35572stack boundary from a function compiled with a lower preferred stack
35573boundary most likely misaligns the stack. It is recommended that
35574libraries that use callbacks always use the default setting.
35575
35576This extra alignment does consume extra stack space, and generally
35577increases code size. Code that is sensitive to stack space usage, such
35578as embedded systems and operating system kernels, may want to reduce the
35579preferred alignment to @option{-mpreferred-stack-boundary=2}.
35580
35581@need 200
d77de738 35582@opindex mmmx
ddf6fe37 35583@item -mmmx
d77de738 35584@need 200
d77de738 35585@opindex msse
ddf6fe37 35586@itemx -msse
d77de738 35587@need 200
d77de738 35588@opindex msse2
ddf6fe37 35589@itemx -msse2
d77de738 35590@need 200
d77de738 35591@opindex msse3
ddf6fe37 35592@itemx -msse3
d77de738 35593@need 200
d77de738 35594@opindex mssse3
ddf6fe37 35595@itemx -mssse3
d77de738 35596@need 200
d77de738 35597@opindex msse4
ddf6fe37 35598@itemx -msse4
d77de738 35599@need 200
d77de738 35600@opindex msse4a
ddf6fe37 35601@itemx -msse4a
d77de738 35602@need 200
d77de738 35603@opindex msse4.1
ddf6fe37 35604@itemx -msse4.1
d77de738 35605@need 200
d77de738 35606@opindex msse4.2
ddf6fe37 35607@itemx -msse4.2
d77de738 35608@need 200
d77de738 35609@opindex mavx
ddf6fe37 35610@itemx -mavx
d77de738 35611@need 200
d77de738 35612@opindex mavx2
ddf6fe37 35613@itemx -mavx2
d77de738 35614@need 200
d77de738 35615@opindex mavx512f
ddf6fe37 35616@itemx -mavx512f
d77de738 35617@need 200
d77de738 35618@opindex mavx512cd
ddf6fe37 35619@itemx -mavx512cd
d77de738 35620@need 200
d77de738 35621@opindex mavx512vl
ddf6fe37 35622@itemx -mavx512vl
d77de738 35623@need 200
d77de738 35624@opindex mavx512bw
ddf6fe37 35625@itemx -mavx512bw
d77de738 35626@need 200
d77de738 35627@opindex mavx512dq
ddf6fe37 35628@itemx -mavx512dq
d77de738 35629@need 200
d77de738 35630@opindex mavx512ifma
ddf6fe37 35631@itemx -mavx512ifma
d77de738 35632@need 200
d77de738 35633@opindex mavx512vbmi
ddf6fe37 35634@itemx -mavx512vbmi
d77de738 35635@need 200
d77de738 35636@opindex msha
ddf6fe37 35637@itemx -msha
d77de738 35638@need 200
d77de738 35639@opindex maes
ddf6fe37 35640@itemx -maes
d77de738 35641@need 200
d77de738 35642@opindex mpclmul
ddf6fe37 35643@itemx -mpclmul
d77de738 35644@need 200
d77de738 35645@opindex mclflushopt
ddf6fe37 35646@itemx -mclflushopt
d77de738 35647@need 200
d77de738 35648@opindex mclwb
ddf6fe37 35649@itemx -mclwb
d77de738 35650@need 200
d77de738 35651@opindex mfsgsbase
ddf6fe37 35652@itemx -mfsgsbase
d77de738 35653@need 200
d77de738 35654@opindex mptwrite
ddf6fe37 35655@itemx -mptwrite
d77de738 35656@need 200
d77de738 35657@opindex mrdrnd
ddf6fe37 35658@itemx -mrdrnd
d77de738 35659@need 200
d77de738 35660@opindex mf16c
ddf6fe37 35661@itemx -mf16c
d77de738 35662@need 200
d77de738 35663@opindex mfma
ddf6fe37 35664@itemx -mfma
d77de738 35665@need 200
d77de738 35666@opindex mpconfig
ddf6fe37 35667@itemx -mpconfig
d77de738 35668@need 200
d77de738 35669@opindex mwbnoinvd
ddf6fe37 35670@itemx -mwbnoinvd
d77de738 35671@need 200
d77de738 35672@opindex mfma4
ddf6fe37 35673@itemx -mfma4
d77de738 35674@need 200
d77de738 35675@opindex mprfchw
ddf6fe37 35676@itemx -mprfchw
d77de738 35677@need 200
d77de738 35678@opindex mrdpid
ddf6fe37 35679@itemx -mrdpid
d77de738 35680@need 200
d77de738 35681@opindex mrdseed
ddf6fe37 35682@itemx -mrdseed
d77de738 35683@need 200
d77de738 35684@opindex msgx
ddf6fe37 35685@itemx -msgx
d77de738 35686@need 200
d77de738 35687@opindex mxop
ddf6fe37 35688@itemx -mxop
d77de738 35689@need 200
d77de738 35690@opindex mlwp
ddf6fe37 35691@itemx -mlwp
d77de738 35692@need 200
d77de738 35693@opindex m3dnow
ddf6fe37 35694@itemx -m3dnow
d77de738 35695@need 200
d77de738 35696@opindex m3dnowa
ddf6fe37 35697@itemx -m3dnowa
d77de738 35698@need 200
d77de738 35699@opindex mpopcnt
ddf6fe37 35700@itemx -mpopcnt
d77de738 35701@need 200
d77de738 35702@opindex mabm
ddf6fe37 35703@itemx -mabm
d77de738 35704@need 200
d77de738 35705@opindex madx
ddf6fe37 35706@itemx -madx
d77de738 35707@need 200
d77de738 35708@opindex mbmi
ddf6fe37 35709@itemx -mbmi
d77de738 35710@need 200
d77de738 35711@opindex mbmi2
ddf6fe37 35712@itemx -mbmi2
d77de738 35713@need 200
d77de738 35714@opindex mlzcnt
ddf6fe37 35715@itemx -mlzcnt
d77de738 35716@need 200
d77de738 35717@opindex mfxsr
ddf6fe37 35718@itemx -mfxsr
d77de738 35719@need 200
d77de738 35720@opindex mxsave
ddf6fe37 35721@itemx -mxsave
d77de738 35722@need 200
d77de738 35723@opindex mxsaveopt
ddf6fe37 35724@itemx -mxsaveopt
d77de738 35725@need 200
d77de738 35726@opindex mxsavec
ddf6fe37 35727@itemx -mxsavec
d77de738 35728@need 200
d77de738 35729@opindex mxsaves
ddf6fe37 35730@itemx -mxsaves
d77de738 35731@need 200
d77de738 35732@opindex mrtm
ddf6fe37 35733@itemx -mrtm
d77de738 35734@need 200
d77de738 35735@opindex mhle
ddf6fe37 35736@itemx -mhle
d77de738 35737@need 200
d77de738 35738@opindex mtbm
ddf6fe37 35739@itemx -mtbm
d77de738 35740@need 200
d77de738 35741@opindex mmwaitx
ddf6fe37 35742@itemx -mmwaitx
d77de738 35743@need 200
d77de738 35744@opindex mclzero
ddf6fe37 35745@itemx -mclzero
d77de738 35746@need 200
d77de738 35747@opindex mpku
ddf6fe37 35748@itemx -mpku
d77de738 35749@need 200
d77de738 35750@opindex mavx512vbmi2
ddf6fe37 35751@itemx -mavx512vbmi2
d77de738 35752@need 200
d77de738 35753@opindex mavx512bf16
ddf6fe37 35754@itemx -mavx512bf16
d77de738 35755@need 200
d77de738 35756@opindex mavx512fp16
ddf6fe37 35757@itemx -mavx512fp16
d77de738 35758@need 200
d77de738 35759@opindex mgfni
ddf6fe37 35760@itemx -mgfni
d77de738 35761@need 200
d77de738 35762@opindex mvaes
ddf6fe37 35763@itemx -mvaes
d77de738 35764@need 200
d77de738 35765@opindex mwaitpkg
ddf6fe37 35766@itemx -mwaitpkg
d77de738 35767@need 200
d77de738 35768@opindex mvpclmulqdq
ddf6fe37 35769@itemx -mvpclmulqdq
d77de738 35770@need 200
d77de738 35771@opindex mavx512bitalg
ddf6fe37 35772@itemx -mavx512bitalg
d77de738 35773@need 200
d77de738 35774@opindex mmovdiri
ddf6fe37 35775@itemx -mmovdiri
d77de738 35776@need 200
d77de738 35777@opindex mmovdir64b
ddf6fe37 35778@itemx -mmovdir64b
d77de738 35779@need 200
d77de738 35780@opindex menqcmd
d77de738 35781@opindex muintr
ddf6fe37
AA
35782@itemx -menqcmd
35783@itemx -muintr
d77de738 35784@need 200
d77de738 35785@opindex mtsxldtrk
ddf6fe37 35786@itemx -mtsxldtrk
d77de738 35787@need 200
d77de738 35788@opindex mavx512vpopcntdq
ddf6fe37 35789@itemx -mavx512vpopcntdq
d77de738 35790@need 200
d77de738 35791@opindex mavx512vp2intersect
ddf6fe37 35792@itemx -mavx512vp2intersect
d77de738 35793@need 200
d77de738 35794@opindex mavx512vnni
ddf6fe37 35795@itemx -mavx512vnni
d77de738 35796@need 200
d77de738 35797@opindex mavxvnni
ddf6fe37 35798@itemx -mavxvnni
d77de738 35799@need 200
d77de738 35800@opindex mcldemote
ddf6fe37 35801@itemx -mcldemote
d77de738 35802@need 200
d77de738 35803@opindex mserialize
ddf6fe37 35804@itemx -mserialize
d77de738 35805@need 200
d77de738 35806@opindex mamx-tile
ddf6fe37 35807@itemx -mamx-tile
d77de738 35808@need 200
d77de738 35809@opindex mamx-int8
ddf6fe37 35810@itemx -mamx-int8
d77de738 35811@need 200
d77de738 35812@opindex mamx-bf16
ddf6fe37 35813@itemx -mamx-bf16
d77de738 35814@need 200
d77de738 35815@opindex mhreset
d77de738 35816@opindex mkl
ddf6fe37
AA
35817@itemx -mhreset
35818@itemx -mkl
d77de738 35819@need 200
d77de738 35820@opindex mwidekl
ddf6fe37 35821@itemx -mwidekl
d77de738 35822@need 200
d77de738 35823@opindex mavxifma
ddf6fe37 35824@itemx -mavxifma
d77de738 35825@need 200
d77de738 35826@opindex mavxvnniint8
ddf6fe37 35827@itemx -mavxvnniint8
d77de738 35828@need 200
d77de738 35829@opindex mavxneconvert
ddf6fe37 35830@itemx -mavxneconvert
d77de738 35831@need 200
d77de738 35832@opindex mcmpccxadd
ddf6fe37 35833@itemx -mcmpccxadd
d77de738 35834@need 200
d77de738 35835@opindex mamx-fp16
ddf6fe37 35836@itemx -mamx-fp16
d77de738 35837@need 200
d77de738 35838@opindex mprefetchi
ddf6fe37 35839@itemx -mprefetchi
d77de738 35840@need 200
d77de738 35841@opindex mraoint
ddf6fe37 35842@itemx -mraoint
efa6a82b
HJ
35843@need 200
35844@opindex mamx-complex
35845@itemx -mamx-complex
1dbc1081
KL
35846@need 200
35847@opindex mavxvnniint16
35848@itemx -mavxvnniint16
8643bcba
HJ
35849@need 200
35850@opindex msm3
35851@itemx -msm3
86446132
HJ
35852@need 200
35853@opindex msha512
35854@itemx -msha512
37bdeb8f
HJ
35855@need 200
35856@opindex msm4
35857@itemx -msm4
e686416b
KL
35858@need 200
35859@opindex mapxf
35860@itemx -mapxf
5fbd91b1
HL
35861@need 200
35862@opindex musermsr
35863@itemx -musermsr
2f8f7ee2
HJ
35864@need 200
35865@opindex mavx10.1
35866@itemx -mavx10.1
35867@need 200
4bcb480d
HJ
35868@opindex mavx10.2
35869@itemx -mavx10.2
35870@need 200
343f8113
HJ
35871@opindex mamx-avx512
35872@itemx -mamx-avx512
8cc38abf
HJ
35873@need 200
35874@opindex mamx-tf32
35875@itemx -mamx-tf32
9f2f36a7
HJ
35876@need 200
35877@opindex mamx-transpose
35878@itemx -mamx-transpose
dd859e93
LX
35879@need 200
35880@itemx -mamx-fp8
35881@opindex mamx-fp8
e9ab41b7
HL
35882@need 200
35883@opindex mmovrs
35884@itemx -mmovrs
f8ae2cce
HL
35885@need 200
35886@opindex mamx-movrs
35887@itemx -mamx-movrs
d77de738 35888These switches enable the use of instructions in the MMX, SSE,
e1a7e2c5
HJ
35889AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, AES,
35890PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
35891WBNOINVD, FMA4, PREFETCHW, RDPID, RDSEED, SGX, XOP, LWP, 3DNow!@:,
35892enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, XSAVEOPT,
35893XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, GFNI, VAES,
35894WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, ENQCMD,
35895AVX512VPOPCNTDQ, AVX512VNNI, SERIALIZE, UINTR, HRESET, AMXTILE, AMXINT8,
35896AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, AVXIFMA, AVXVNNIINT8, AVXNECONVERT,
35897CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512,
dd859e93 35898SM4, APX_F, USER_MSR, AVX10.1, AVX10.2, AMX-AVX512, AMX-TF32, AMX-TRANSPOSE,
f8ae2cce
HL
35899AMX-FP8, MOVRS, AMX-MOVRS or CLDEMOTE extended instruction sets. Each has a
35900corresponding @option{-mno-} option to disable use of these instructions.
d77de738
ML
35901
35902These extensions are also available as built-in functions: see
35903@ref{x86 Built-in Functions}, for details of the functions enabled and
35904disabled by these switches.
35905
c781da2c
SL
35906Note that @option{-msse4} enables both SSE4.1 and SSE4.2 support,
35907while @option{-mno-sse4} turns off those features; neither form of the
35908option affects SSE4A support, controlled separately by
35909@option{-msse4a}.
35910
d77de738
ML
35911To generate SSE/SSE2 instructions automatically from floating-point
35912code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
35913
35914GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
35915generates new AVX instructions or AVX equivalence for all SSEx instructions
35916when needed.
35917
35918These options enable GCC to use these extended instructions in
35919generated code, even without @option{-mfpmath=sse}. Applications that
35920perform run-time CPU detection must compile separate files for each
35921supported architecture, using the appropriate flags. In particular,
35922the file containing the CPU detection code should be compiled without
35923these options.
35924
d77de738 35925@opindex mdump-tune-features
ddf6fe37 35926@item -mdump-tune-features
a0e64a04
PN
35927This option instructs GCC to dump the names of the x86 performance
35928tuning features and default settings. The names can be used in
d77de738
ML
35929@option{-mtune-ctrl=@var{feature-list}}.
35930
d77de738 35931@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 35932@item -mtune-ctrl=@var{feature-list}
d77de738
ML
35933This option is used to do fine grain control of x86 code generation features.
35934@var{feature-list} is a comma separated list of @var{feature} names. See also
35935@option{-mdump-tune-features}. When specified, the @var{feature} is turned
a0e64a04 35936on if it is not preceded with @samp{^}, otherwise, it is turned off.
d77de738
ML
35937@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
35938developers. Using it may lead to code paths not covered by testing and can
35939potentially result in compiler ICEs or runtime errors.
35940
d77de738 35941@opindex mno-default
ddf6fe37 35942@item -mno-default
a0e64a04 35943This option instructs GCC to turn off all tunable features. See also
d77de738
ML
35944@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
35945
d77de738 35946@opindex mcld
ddf6fe37 35947@item -mcld
d77de738
ML
35948This option instructs GCC to emit a @code{cld} instruction in the prologue
35949of functions that use string instructions. String instructions depend on
35950the DF flag to select between autoincrement or autodecrement mode. While the
35951ABI specifies the DF flag to be cleared on function entry, some operating
35952systems violate this specification by not clearing the DF flag in their
35953exception dispatchers. The exception handler can be invoked with the DF flag
35954set, which leads to wrong direction mode when string instructions are used.
35955This option can be enabled by default on 32-bit x86 targets by configuring
35956GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
35957instructions can be suppressed with the @option{-mno-cld} compiler option
35958in this case.
35959
d77de738 35960@opindex mvzeroupper
ddf6fe37 35961@item -mvzeroupper
d77de738
ML
35962This option instructs GCC to emit a @code{vzeroupper} instruction
35963before a transfer of control flow out of the function to minimize
35964the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
35965intrinsics.
35966
d77de738 35967@opindex mprefer-avx128
ddf6fe37 35968@item -mprefer-avx128
d77de738
ML
35969This option instructs GCC to use 128-bit AVX instructions instead of
35970256-bit AVX instructions in the auto-vectorizer.
35971
d77de738 35972@opindex mprefer-vector-width
ddf6fe37 35973@item -mprefer-vector-width=@var{opt}
d77de738
ML
35974This option instructs GCC to use @var{opt}-bit vector width in instructions
35975instead of default on the selected platform.
35976
ad5b757d
UB
35977@opindex mpartial-vector-fp-math
35978@item -mpartial-vector-fp-math
35979This option enables GCC to generate floating-point operations that might
35980affect the set of floating-point status flags on partial vectors, where
35981vector elements reside in the low part of the 128-bit SSE register. Unless
35982@option{-fno-trapping-math} is specified, the compiler guarantees correct
35983behavior by sanitizing all input operands to have zeroes in the unused
35984upper part of the vector register. Note that by using built-in functions
35985or inline assembly with partial vector arguments, NaNs, denormal or invalid
35986values can leak into the upper part of the vector, causing possible
35987performance issues when @option{-fno-trapping-math} is in effect. These
35988issues can be mitigated by manually sanitizing the upper part of the partial
35989vector argument register or by using @option{-mdaz-ftz} to set
35990denormals-are-zero (DAZ) flag in the MXCSR register.
35991
35992This option is enabled by default.
35993
d77de738 35994@opindex mmove-max
ddf6fe37 35995@item -mmove-max=@var{bits}
d77de738
ML
35996This option instructs GCC to set the maximum number of bits can be
35997moved from memory to memory efficiently to @var{bits}. The valid
35998@var{bits} are 128, 256 and 512.
35999
d77de738 36000@opindex mstore-max
ddf6fe37 36001@item -mstore-max=@var{bits}
d77de738
ML
36002This option instructs GCC to set the maximum number of bits can be
36003stored to memory efficiently to @var{bits}. The valid @var{bits} are
36004128, 256 and 512.
36005
36006@table @samp
36007@item none
36008No extra limitations applied to GCC other than defined by the selected platform.
36009
36010@item 128
36011Prefer 128-bit vector width for instructions.
36012
36013@item 256
36014Prefer 256-bit vector width for instructions.
36015
36016@item 512
36017Prefer 512-bit vector width for instructions.
36018@end table
36019
a307a26e
JJ
36020@opindex mnoreturn-no-callee-saved-registers
36021@item -mnoreturn-no-callee-saved-registers
36022This option optimizes functions with @code{noreturn} attribute or
36023@code{_Noreturn} specifier by not saving in the function prologue callee-saved
36024registers which are used in the function (except for the @code{BP}
36025register). This option can interfere with debugging of the caller of the
36026@code{noreturn} function or any function further up in the call stack, so it
36027is not enabled by default.
36028
d77de738 36029@opindex mcx16
ddf6fe37 36030@item -mcx16
d77de738
ML
36031This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
36032code to implement compare-and-exchange operations on 16-byte aligned 128-bit
36033objects. This is useful for atomic updates of data structures exceeding one
36034machine word in size. The compiler uses this instruction to implement
36035@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
36036128-bit integers, a library call is always used.
36037
d77de738 36038@opindex msahf
ddf6fe37 36039@item -msahf
d77de738
ML
36040This option enables generation of @code{SAHF} instructions in 64-bit code.
36041Early Intel Pentium 4 CPUs with Intel 64 support,
36042prior to the introduction of Pentium 4 G1 step in December 2005,
36043lacked the @code{LAHF} and @code{SAHF} instructions
36044which are supported by AMD64.
36045These are load and store instructions, respectively, for certain status flags.
36046In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
36047@code{drem}, and @code{remainder} built-in functions;
36048see @ref{Other Builtins} for details.
36049
d77de738 36050@opindex mmovbe
ddf6fe37 36051@item -mmovbe
4b358f9b
RB
36052This option enables use of the @code{movbe} instruction to optimize
36053byte swapping of four and eight byte entities.
d77de738 36054
d77de738 36055@opindex mshstk
ddf6fe37 36056@item -mshstk
d77de738
ML
36057The @option{-mshstk} option enables shadow stack built-in functions
36058from x86 Control-flow Enforcement Technology (CET).
36059
d77de738 36060@opindex mcrc32
ddf6fe37 36061@item -mcrc32
d77de738
ML
36062This option enables built-in functions @code{__builtin_ia32_crc32qi},
36063@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
36064@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
36065
d77de738 36066@opindex mmwait
ddf6fe37 36067@item -mmwait
d77de738
ML
36068This option enables built-in functions @code{__builtin_ia32_monitor},
36069and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
36070@code{mwait} machine instructions.
36071
d77de738 36072@opindex mrecip
ddf6fe37 36073@item -mrecip
d77de738
ML
36074This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
36075(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
36076with an additional Newton-Raphson step
36077to increase precision instead of @code{DIVSS} and @code{SQRTSS}
36078(and their vectorized
36079variants) for single-precision floating-point arguments. These instructions
36080are generated only when @option{-funsafe-math-optimizations} is enabled
36081together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
36082Note that while the throughput of the sequence is higher than the throughput
36083of the non-reciprocal instruction, the precision of the sequence can be
36084decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
36085
36086Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
36087(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
36088combination), and doesn't need @option{-mrecip}.
36089
36090Also note that GCC emits the above sequence with additional Newton-Raphson step
36091for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
36092already with @option{-ffast-math} (or the above option combination), and
36093doesn't need @option{-mrecip}.
36094
d77de738 36095@opindex mrecip=opt
ddf6fe37 36096@item -mrecip=@var{opt}
d77de738
ML
36097This option controls which reciprocal estimate instructions
36098may be used. @var{opt} is a comma-separated list of options, which may
36099be preceded by a @samp{!} to invert the option:
36100
36101@table @samp
36102@item all
36103Enable all estimate instructions.
36104
36105@item default
36106Enable the default instructions, equivalent to @option{-mrecip}.
36107
36108@item none
36109Disable all estimate instructions, equivalent to @option{-mno-recip}.
36110
36111@item div
36112Enable the approximation for scalar division.
36113
36114@item vec-div
36115Enable the approximation for vectorized division.
36116
36117@item sqrt
36118Enable the approximation for scalar square root.
36119
36120@item vec-sqrt
36121Enable the approximation for vectorized square root.
36122@end table
36123
36124So, for example, @option{-mrecip=all,!sqrt} enables
36125all of the reciprocal approximations, except for square root.
36126
d77de738 36127@opindex mveclibabi
ddf6fe37 36128@item -mveclibabi=@var{type}
99ec0eb3
FK
36129Specifies the ABI type to use for vectorizing intrinsics using an external
36130library. Supported values for @var{type} are @samp{svml} for the Intel short
36131vector math library, @samp{aocl} for the math library (LibM) from AMD
36132Optimizing CPU Libraries (AOCL) and @samp{acml} for the end-of-life AMD core
36133math library (to which AOCL-LibM is the successor).
d77de738 36134To use this option, both @option{-ftree-vectorize} and
a0e64a04 36135@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
d77de738
ML
36136ABI-compatible library must be specified at link time.
36137
99ec0eb3
FK
36138GCC currently emits calls to @code{vmldExp2}, @code{vmldLn2},
36139@code{vmldLog102}, @code{vmldPow2}, @code{vmldTanh2}, @code{vmldTan2},
36140@code{vmldAtan2}, @code{vmldAtanh2}, @code{vmldCbrt2}, @code{vmldSinh2},
36141@code{vmldSin2}, @code{vmldAsinh2}, @code{vmldAsin2}, @code{vmldCosh2},
36142@code{vmldCos2}, @code{vmldAcosh2}, @code{vmldAcos2}, @code{vmlsExp4},
36143@code{vmlsLn4}, @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4},
36144@code{vmlsTan4}, @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4},
36145@code{vmlsSinh4}, @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4},
36146@code{vmlsCosh4}, @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for
36147corresponding function type when @option{-mveclibabi=svml} is used,
36148@code{amd_vrs4_acosf}, @code{amd_vrs16_acosf}, @code{amd_vrd8_asin},
36149@code{amd_vrs4_asinf}, @code{amd_vrs8_asinf}, @code{amd_vrs16_asinf},
36150@code{amd_vrd2_atan}, @code{amd_vrd8_atan}, @code{amd_vrs4_atanf},
36151@code{amd_vrs8_atanf}, @code{amd_vrs16_atanf}, @code{amd_vrd2_cos},
36152@code{amd_vrd4_cos}, @code{amd_vrd8_cos}, @code{amd_vrs4_cosf},
36153@code{amd_vrs8_cosf}, @code{amd_vrs16_cosf}, @code{amd_vrs4_coshf},
36154@code{amd_vrs8_coshf}, @code{amd_vrd2_erf}, @code{amd_vrd4_erf},
36155@code{amd_vrd8_erf}, @code{amd_vrs4_erff}, @code{amd_vrs8_erff},
36156@code{amd_vrs16_erff}, @code{amd_vrd2_exp}, @code{amd_vrd4_exp},
36157@code{amd_vrd8_exp}, @code{amd_vrs4_expf}, @code{amd_vrs8_expf},
36158@code{amd_vrs16_expf}, @code{amd_vrd2_exp10}, @code{amd_vrs4_exp10f},
36159@code{amd_vrd2_exp2}, @code{amd_vrd4_exp2}, @code{amd_vrd8_exp2},
36160@code{amd_vrs4_exp2f}, @code{amd_vrs8_exp2f}, @code{amd_vrs16_exp2f},
36161@code{amd_vrs4_expm1f}, @code{amd_vrd2_log}, @code{amd_vrd4_log},
36162@code{amd_vrd8_log}, @code{amd_vrs4_logf}, @code{amd_vrs8_logf},
36163@code{amd_vrs16_logf}, @code{amd_vrd2_log10}, @code{amd_vrs4_log10f},
36164@code{amd_vrs8_log10f}, @code{amd_vrs16_log10f}, @code{amd_vrd2_log1p},
36165@code{amd_vrs4_log1pf}, @code{amd_vrd2_log2}, @code{amd_vrd4_log2},
36166@code{amd_vrd8_log2}, @code{amd_vrs4_log2f}, @code{amd_vrs8_log2f},
36167@code{amd_vrs16_log2f}, @code{amd_vrd2_pow}, @code{amd_vrd4_pow},
36168@code{amd_vrd8_pow}, @code{amd_vrs4_powf}, @code{amd_vrs8_powf},
36169@code{amd_vrs16_powf}, @code{amd_vrd2_sin}, @code{amd_vrd4_sin},
36170@code{amd_vrd8_sin}, @code{amd_vrs4_sinf}, @code{amd_vrs8_sinf},
36171@code{amd_vrs16_sinf}, @code{amd_vrd2_tan}, @code{amd_vrd4_tan},
36172@code{amd_vrd8_tan}, @code{amd_vrs16_tanf}, @code{amd_vrs4_tanhf},
36173@code{amd_vrs8_tanhf}, @code{amd_vrs16_tanhf} for the corresponding function
36174type when @option{-mveclibabi=aocl} is used, and @code{__vrd2_sin},
d77de738
ML
36175@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
36176@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
36177@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
36178@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
a0e64a04 36179when @option{-mveclibabi=acml} is used.
d77de738 36180
d77de738 36181@opindex mabi
ddf6fe37 36182@item -mabi=@var{name}
d77de738
ML
36183Generate code for the specified calling convention. Permissible values
36184are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
36185@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
36186ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
36187You can control this behavior for specific functions by
36188using the function attributes @code{ms_abi} and @code{sysv_abi}.
36189@xref{Function Attributes}.
36190
d77de738 36191@opindex mforce-indirect-call
ddf6fe37 36192@item -mforce-indirect-call
d77de738
ML
36193Force all calls to functions to be indirect. This is useful
36194when using Intel Processor Trace where it generates more precise timing
36195information for function calls.
36196
d77de738 36197@opindex mmanual-endbr
ddf6fe37 36198@item -mmanual-endbr
d77de738
ML
36199Insert ENDBR instruction at function entry only via the @code{cf_check}
36200function attribute. This is useful when used with the option
36201@option{-fcf-protection=branch} to control ENDBR insertion at the
36202function entry.
36203
d77de738 36204@opindex mcet-switch
ddf6fe37 36205@item -mcet-switch
d77de738
ML
36206By default, CET instrumentation is turned off on switch statements that
36207use a jump table and indirect branch track is disabled. Since jump
36208tables are stored in read-only memory, this does not result in a direct
36209loss of hardening. But if the jump table index is attacker-controlled,
36210the indirect jump may not be constrained by CET. This option turns on
36211CET instrumentation to enable indirect branch track for switch statements
36212with jump tables which leads to the jump targets reachable via any indirect
36213jumps.
36214
d77de738
ML
36215@opindex mcall-ms2sysv-xlogues
36216@opindex mno-call-ms2sysv-xlogues
ddf6fe37 36217@item -mcall-ms2sysv-xlogues
d77de738
ML
36218Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
36219System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
36220default, the code for saving and restoring these registers is emitted inline,
36221resulting in fairly lengthy prologues and epilogues. Using
36222@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
36223use stubs in the static portion of libgcc to perform these saves and restores,
36224thus reducing function size at the cost of a few extra instructions.
36225
d77de738 36226@opindex mtls-dialect
ddf6fe37 36227@item -mtls-dialect=@var{type}
d77de738
ML
36228Generate code to access thread-local storage using the @samp{gnu} or
36229@samp{gnu2} conventions. @samp{gnu} is the conservative default;
36230@samp{gnu2} is more efficient, but it may add compile- and run-time
36231requirements that cannot be satisfied on all systems.
36232
d77de738
ML
36233@opindex mpush-args
36234@opindex mno-push-args
ddf6fe37
AA
36235@item -mpush-args
36236@itemx -mno-push-args
d77de738
ML
36237Use PUSH operations to store outgoing parameters. This method is shorter
36238and usually equally fast as method using SUB/MOV operations and is enabled
36239by default. In some cases disabling it may improve performance because of
36240improved scheduling and reduced dependencies.
36241
d77de738 36242@opindex maccumulate-outgoing-args
ddf6fe37 36243@item -maccumulate-outgoing-args
d77de738
ML
36244If enabled, the maximum amount of space required for outgoing arguments is
36245computed in the function prologue. This is faster on most modern CPUs
36246because of reduced dependencies, improved scheduling and reduced stack usage
36247when the preferred stack boundary is not equal to 2. The drawback is a notable
36248increase in code size. This switch implies @option{-mno-push-args}.
36249
d77de738 36250@opindex mthreads
ddf6fe37 36251@item -mthreads
d77de738
ML
36252Support thread-safe exception handling on MinGW. Programs that rely
36253on thread-safe exception handling must compile and link all code with the
36254@option{-mthreads} option. When compiling, @option{-mthreads} defines
36255@option{-D_MT}; when linking, it links in a special thread helper library
36256@option{-lmingwthrd} which cleans up per-thread exception-handling data.
36257
d77de738
ML
36258@opindex mms-bitfields
36259@opindex mno-ms-bitfields
ddf6fe37
AA
36260@item -mms-bitfields
36261@itemx -mno-ms-bitfields
d77de738
ML
36262
36263Enable/disable bit-field layout compatible with the native Microsoft
a0e64a04 36264Windows compiler.
d77de738
ML
36265
36266If @code{packed} is used on a structure, or if bit-fields are used,
36267it may be that the Microsoft ABI lays out the structure differently
36268than the way GCC normally does. Particularly when moving packed
36269data between functions compiled with GCC and the native Microsoft compiler
36270(either via function call or as data in a file), it may be necessary to access
36271either format.
36272
36273This option is enabled by default for Microsoft Windows
36274targets. This behavior can also be controlled locally by use of variable
36275or type attributes. For more information, see @ref{x86 Variable Attributes}
36276and @ref{x86 Type Attributes}.
36277
36278The Microsoft structure layout algorithm is fairly simple with the exception
a0e64a04
PN
36279of the bit-field packing.
36280The padding and alignment of members of structures and whether a bit-field
d77de738
ML
36281can straddle a storage-unit boundary are determine by these rules:
36282
36283@enumerate
36284@item Structure members are stored sequentially in the order in which they are
36285declared: the first member has the lowest memory address and the last member
36286the highest.
36287
36288@item Every data object has an alignment requirement. The alignment requirement
36289for all data except structures, unions, and arrays is either the size of the
36290object or the current packing size (specified with either the
36291@code{aligned} attribute or the @code{pack} pragma),
36292whichever is less. For structures, unions, and arrays,
36293the alignment requirement is the largest alignment requirement of its members.
36294Every object is allocated an offset so that:
36295
36296@smallexample
36297offset % alignment_requirement == 0
36298@end smallexample
36299
36300@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
36301unit if the integral types are the same size and if the next bit-field fits
36302into the current allocation unit without crossing the boundary imposed by the
36303common alignment requirements of the bit-fields.
36304@end enumerate
36305
36306MSVC interprets zero-length bit-fields in the following ways:
36307
36308@enumerate
36309@item If a zero-length bit-field is inserted between two bit-fields that
36310are normally coalesced, the bit-fields are not coalesced.
36311
36312For example:
36313
36314@smallexample
36315struct
36316 @{
36317 unsigned long bf_1 : 12;
36318 unsigned long : 0;
36319 unsigned long bf_2 : 12;
36320 @} t1;
36321@end smallexample
36322
36323@noindent
36324The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
36325zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
36326
36327@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
36328alignment of the zero-length bit-field is greater than the member that follows it,
36329@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
36330
36331For example:
36332
36333@smallexample
36334struct
36335 @{
36336 char foo : 4;
36337 short : 0;
36338 char bar;
36339 @} t2;
36340
36341struct
36342 @{
36343 char foo : 4;
36344 short : 0;
36345 double bar;
36346 @} t3;
36347@end smallexample
36348
36349@noindent
36350For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
36351Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
36352bit-field does not affect the alignment of @code{bar} or, as a result, the size
36353of the structure.
36354
36355Taking this into account, it is important to note the following:
36356
36357@enumerate
36358@item If a zero-length bit-field follows a normal bit-field, the type of the
36359zero-length bit-field may affect the alignment of the structure as whole. For
36360example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
36361normal bit-field, and is of type short.
36362
36363@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
36364still affect the alignment of the structure:
36365
36366@smallexample
36367struct
36368 @{
36369 char foo : 6;
36370 long : 0;
36371 @} t4;
36372@end smallexample
36373
36374@noindent
36375Here, @code{t4} takes up 4 bytes.
36376@end enumerate
36377
36378@item Zero-length bit-fields following non-bit-field members are ignored:
36379
36380@smallexample
36381struct
36382 @{
36383 char foo;
36384 long : 0;
36385 char bar;
36386 @} t5;
36387@end smallexample
36388
36389@noindent
36390Here, @code{t5} takes up 2 bytes.
36391@end enumerate
36392
36393
d77de738
ML
36394@opindex mno-align-stringops
36395@opindex malign-stringops
ddf6fe37 36396@item -mno-align-stringops
d77de738
ML
36397Do not align the destination of inlined string operations. This switch reduces
36398code size and improves performance in case the destination is already aligned,
36399but GCC doesn't know about it.
36400
d77de738 36401@opindex minline-all-stringops
ddf6fe37 36402@item -minline-all-stringops
a0e64a04
PN
36403By default GCC inlines string operations only when the destination is
36404known to be aligned to least a 4-byte boundary.
d77de738
ML
36405This enables more inlining and increases code
36406size, but may improve performance of code that depends on fast
36407@code{memcpy} and @code{memset} for short lengths.
36408The option enables inline expansion of @code{strlen} for all
36409pointer alignments.
36410
d77de738 36411@opindex minline-stringops-dynamically
ddf6fe37 36412@item -minline-stringops-dynamically
d77de738
ML
36413For string operations of unknown size, use run-time checks with
36414inline code for small blocks and a library call for large blocks.
36415
d77de738 36416@opindex mstringop-strategy=@var{alg}
ddf6fe37 36417@item -mstringop-strategy=@var{alg}
d77de738
ML
36418Override the internal decision heuristic for the particular algorithm to use
36419for inlining string operations. The allowed values for @var{alg} are:
36420
36421@table @samp
36422@item rep_byte
36423@itemx rep_4byte
36424@itemx rep_8byte
36425Expand using i386 @code{rep} prefix of the specified size.
36426
36427@item byte_loop
36428@itemx loop
36429@itemx unrolled_loop
36430Expand into an inline loop.
36431
36432@item libcall
36433Always use a library call.
36434@end table
36435
d77de738 36436@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 36437@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
36438Override the internal decision heuristic to decide if @code{__builtin_memcpy}
36439should be inlined and what inline algorithm to use when the expected size
a0e64a04
PN
36440of the copy operation is known. @var{strategy}
36441is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
d77de738
ML
36442@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
36443the max byte size with which inline algorithm @var{alg} is allowed. For the last
36444triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
a0e64a04
PN
36445in the list must be specified in increasing order. The minimal byte size for
36446@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
d77de738
ML
36447preceding range.
36448
d77de738 36449@opindex mmemset-strategy=@var{strategy}
ddf6fe37 36450@item -mmemset-strategy=@var{strategy}
d77de738
ML
36451The option is similar to @option{-mmemcpy-strategy=} except that it is to control
36452@code{__builtin_memset} expansion.
36453
d77de738 36454@opindex momit-leaf-frame-pointer
ddf6fe37 36455@item -momit-leaf-frame-pointer
d77de738
ML
36456Don't keep the frame pointer in a register for leaf functions. This
36457avoids the instructions to save, set up, and restore frame pointers and
36458makes an extra register available in leaf functions. The option
36459@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
36460which might make debugging harder.
36461
ddf6fe37 36462@opindex mtls-direct-seg-refs
d77de738
ML
36463@item -mtls-direct-seg-refs
36464@itemx -mno-tls-direct-seg-refs
d77de738
ML
36465Controls whether TLS variables may be accessed with offsets from the
36466TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
36467or whether the thread base pointer must be added. Whether or not this
36468is valid depends on the operating system, and whether it maps the
36469segment to cover the entire TLS area.
36470
36471For systems that use the GNU C Library, the default is on.
36472
ddf6fe37 36473@opindex msse2avx
d77de738
ML
36474@item -msse2avx
36475@itemx -mno-sse2avx
d77de738
ML
36476Specify that the assembler should encode SSE instructions with VEX
36477prefix. The option @option{-mavx} turns this on by default.
36478
ddf6fe37 36479@opindex mfentry
d77de738
ML
36480@item -mfentry
36481@itemx -mno-fentry
d77de738
ML
36482If profiling is active (@option{-pg}), put the profiling
36483counter call before the prologue.
36484Note: On x86 architectures the attribute @code{ms_hook_prologue}
36485isn't possible at the moment for @option{-mfentry} and @option{-pg}.
36486
ddf6fe37 36487@opindex mrecord-mcount
d77de738
ML
36488@item -mrecord-mcount
36489@itemx -mno-record-mcount
d77de738
ML
36490If profiling is active (@option{-pg}), generate a __mcount_loc section
36491that contains pointers to each profiling call. This is useful for
36492automatically patching and out calls.
36493
ddf6fe37 36494@opindex mnop-mcount
d77de738
ML
36495@item -mnop-mcount
36496@itemx -mno-nop-mcount
d77de738
ML
36497If profiling is active (@option{-pg}), generate the calls to
36498the profiling functions as NOPs. This is useful when they
36499should be patched in later dynamically. This is likely only
36500useful together with @option{-mrecord-mcount}.
36501
d77de738 36502@opindex minstrument-return
ddf6fe37 36503@item -minstrument-return=@var{type}
d77de738
ML
36504Instrument function exit in -pg -mfentry instrumented functions with
36505call to specified function. This only instruments true returns ending
36506with ret, but not sibling calls ending with jump. Valid types
36507are @var{none} to not instrument, @var{call} to generate a call to __return__,
36508or @var{nop5} to generate a 5 byte nop.
36509
ddf6fe37 36510@opindex mrecord-return
d77de738
ML
36511@item -mrecord-return
36512@itemx -mno-record-return
d77de738
ML
36513Generate a __return_loc section pointing to all return instrumentation code.
36514
d77de738 36515@opindex mfentry-name
ddf6fe37 36516@item -mfentry-name=@var{name}
d77de738
ML
36517Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
36518
d77de738 36519@opindex mfentry-section
ddf6fe37 36520@item -mfentry-section=@var{name}
d77de738
ML
36521Set name of section to record -mrecord-mcount calls (default __mcount_loc).
36522
ddf6fe37 36523@opindex mskip-rax-setup
d77de738
ML
36524@item -mskip-rax-setup
36525@itemx -mno-skip-rax-setup
d77de738
ML
36526When generating code for the x86-64 architecture with SSE extensions
36527disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
36528register when there are no variable arguments passed in vector registers.
36529
36530@strong{Warning:} Since RAX register is used to avoid unnecessarily
36531saving vector registers on stack when passing variable arguments, the
36532impacts of this option are callees may waste some stack space,
36533misbehave or jump to a random location. GCC 4.4 or newer don't have
36534those issues, regardless the RAX register value.
36535
ddf6fe37 36536@opindex m8bit-idiv
d77de738
ML
36537@item -m8bit-idiv
36538@itemx -mno-8bit-idiv
d77de738
ML
36539On some processors, like Intel Atom, 8-bit unsigned integer divide is
36540much faster than 32-bit/64-bit integer divide. This option generates a
36541run-time check. If both dividend and divisor are within range of 0
36542to 255, 8-bit unsigned integer divide is used instead of
3654332-bit/64-bit integer divide.
36544
d77de738
ML
36545@opindex mavx256-split-unaligned-load
36546@opindex mavx256-split-unaligned-store
ddf6fe37
AA
36547@item -mavx256-split-unaligned-load
36548@itemx -mavx256-split-unaligned-store
d77de738
ML
36549Split 32-byte AVX unaligned load and store.
36550
d77de738
ML
36551@opindex mstack-protector-guard
36552@opindex mstack-protector-guard-reg
36553@opindex mstack-protector-guard-offset
fa878dc8 36554@opindex mstack-protector-guard-symbol
ddf6fe37
AA
36555@item -mstack-protector-guard=@var{guard}
36556@itemx -mstack-protector-guard-reg=@var{reg}
36557@itemx -mstack-protector-guard-offset=@var{offset}
fa878dc8 36558@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
36559Generate stack protection code using canary at @var{guard}. Supported
36560locations are @samp{global} for global canary or @samp{tls} for per-thread
36561canary in the TLS block (the default). This option has effect only when
36562@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
36563
36564With the latter choice the options
36565@option{-mstack-protector-guard-reg=@var{reg}} and
36566@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
36567which segment register (@code{%fs} or @code{%gs}) to use as base register
36568for reading the canary, and from what offset from that base register.
36569The default for those is as specified in the relevant ABI.
36570
fa878dc8
SL
36571@option{-mstack-protector-guard-symbol=@var{symbol}} overrides
36572the offset with a symbol reference to a canary in the TLS block.
36573
d77de738 36574@opindex mgeneral-regs-only
ddf6fe37 36575@item -mgeneral-regs-only
d77de738
ML
36576Generate code that uses only the general-purpose registers. This
36577prevents the compiler from using floating-point, vector, mask and bound
36578registers.
36579
d77de738 36580@opindex mrelax-cmpxchg-loop
ddf6fe37 36581@item -mrelax-cmpxchg-loop
85966f0d
AM
36582When emitting a compare-and-swap loop for @ref{__sync Builtins}
36583and @ref{__atomic Builtins} lacking a native instruction, optimize
36584for the highly contended case by issuing an atomic load before the
36585@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
36586to save CPU power when restarting the loop.
d77de738 36587
d77de738 36588@opindex mindirect-branch
ddf6fe37 36589@item -mindirect-branch=@var{choice}
d77de738
ML
36590Convert indirect call and jump with @var{choice}. The default is
36591@samp{keep}, which keeps indirect call and jump unmodified.
36592@samp{thunk} converts indirect call and jump to call and return thunk.
36593@samp{thunk-inline} converts indirect call and jump to inlined call
36594and return thunk. @samp{thunk-extern} converts indirect call and jump
36595to external call and return thunk provided in a separate object file.
36596You can control this behavior for a specific function by using the
36597function attribute @code{indirect_branch}. @xref{Function Attributes}.
36598
36599Note that @option{-mcmodel=large} is incompatible with
36600@option{-mindirect-branch=thunk} and
36601@option{-mindirect-branch=thunk-extern} since the thunk function may
36602not be reachable in the large code model.
36603
36604Note that @option{-mindirect-branch=thunk-extern} is compatible with
36605@option{-fcf-protection=branch} since the external thunk can be made
36606to enable control-flow check.
36607
d77de738 36608@opindex mfunction-return
ddf6fe37 36609@item -mfunction-return=@var{choice}
d77de738
ML
36610Convert function return with @var{choice}. The default is @samp{keep},
36611which keeps function return unmodified. @samp{thunk} converts function
36612return to call and return thunk. @samp{thunk-inline} converts function
36613return to inlined call and return thunk. @samp{thunk-extern} converts
36614function return to external call and return thunk provided in a separate
36615object file. You can control this behavior for a specific function by
36616using the function attribute @code{function_return}.
36617@xref{Function Attributes}.
36618
36619Note that @option{-mindirect-return=thunk-extern} is compatible with
36620@option{-fcf-protection=branch} since the external thunk can be made
36621to enable control-flow check.
36622
36623Note that @option{-mcmodel=large} is incompatible with
36624@option{-mfunction-return=thunk} and
36625@option{-mfunction-return=thunk-extern} since the thunk function may
36626not be reachable in the large code model.
36627
36628
d77de738 36629@opindex mindirect-branch-register
ddf6fe37 36630@item -mindirect-branch-register
d77de738
ML
36631Force indirect call and jump via register.
36632
d77de738 36633@opindex mharden-sls
ddf6fe37 36634@item -mharden-sls=@var{choice}
d77de738
ML
36635Generate code to mitigate against straight line speculation (SLS) with
36636@var{choice}. The default is @samp{none} which disables all SLS
36637hardening. @samp{return} enables SLS hardening for function returns.
36638@samp{indirect-jmp} enables SLS hardening for indirect jumps.
36639@samp{all} enables all SLS hardening.
36640
d77de738 36641@opindex mindirect-branch-cs-prefix
ddf6fe37 36642@item -mindirect-branch-cs-prefix
d77de738
ML
36643Add CS prefix to call and jmp to indirect thunk with branch target in
36644r8-r15 registers so that the call and jmp instruction length is 6 bytes
36645to allow them to be replaced with @samp{lfence; call *%r8-r15} or
36646@samp{lfence; jmp *%r8-r15} at run-time.
36647
7de5bb64
HW
36648@opindex mapx-inline-asm-use-gpr32
36649@item -mapx-inline-asm-use-gpr32
36650For inline asm support with APX, by default the EGPR feature was
36651disabled to prevent potential illegal instruction with EGPR occurs.
36652To invoke egpr usage in inline asm, use new compiler option
36653-mapx-inline-asm-use-gpr32 and user should ensure the instruction
36654supports EGPR.
36655
d77de738
ML
36656@end table
36657
36658These @samp{-m} switches are supported in addition to the above
36659on x86-64 processors in 64-bit environments.
36660
36661@table @gcctabopt
d77de738
ML
36662@opindex m32
36663@opindex m64
36664@opindex mx32
36665@opindex m16
36666@opindex miamcu
ddf6fe37
AA
36667@item -m32
36668@itemx -m64
36669@itemx -mx32
36670@itemx -m16
36671@itemx -miamcu
d77de738
ML
36672Generate code for a 16-bit, 32-bit or 64-bit environment.
36673The @option{-m32} option sets @code{int}, @code{long}, and pointer types
36674to 32 bits, and
eeb92704 36675generates code that runs in 32-bit mode.
d77de738
ML
36676
36677The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
36678types to 64 bits, and generates code for the x86-64 architecture.
36679For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
36680and @option{-mdynamic-no-pic} options.
36681
36682The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
36683to 32 bits, and
36684generates code for the x86-64 architecture.
36685
36686The @option{-m16} option is the same as @option{-m32}, except for that
36687it outputs the @code{.code16gcc} assembly directive at the beginning of
36688the assembly output so that the binary can run in 16-bit mode.
36689
36690The @option{-miamcu} option generates code which conforms to Intel MCU
36691psABI. It requires the @option{-m32} option to be turned on.
36692
d77de738
ML
36693@opindex mno-red-zone
36694@opindex mred-zone
ddf6fe37 36695@item -mno-red-zone
d77de738
ML
36696Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
36697by the x86-64 ABI; it is a 128-byte area beyond the location of the
36698stack pointer that is not modified by signal or interrupt handlers
36699and therefore can be used for temporary data without adjusting the stack
36700pointer. The flag @option{-mno-red-zone} disables this red zone.
36701
a0d60660 36702@opindex mcmodel=
d77de738 36703@opindex mcmodel=small
ddf6fe37 36704@item -mcmodel=small
d77de738
ML
36705Generate code for the small code model: the program and its symbols must
36706be linked in the lower 2 GB of the address space. Pointers are 64 bits.
36707Programs can be statically or dynamically linked. This is the default
36708code model.
36709
d77de738 36710@opindex mcmodel=kernel
ddf6fe37 36711@item -mcmodel=kernel
d77de738
ML
36712Generate code for the kernel code model. The kernel runs in the
36713negative 2 GB of the address space.
36714This model has to be used for Linux kernel code.
36715
d77de738 36716@opindex mcmodel=medium
ddf6fe37 36717@item -mcmodel=medium
d77de738
ML
36718Generate code for the medium model: the program is linked in the lower 2
36719GB of the address space. Small symbols are also placed there. Symbols
36720with sizes larger than @option{-mlarge-data-threshold} are put into
36721large data or BSS sections and can be located above 2GB. Programs can
36722be statically or dynamically linked.
36723
d77de738 36724@opindex mcmodel=large
ddf6fe37 36725@item -mcmodel=large
d77de738
ML
36726Generate code for the large model. This model makes no assumptions
36727about addresses and sizes of sections.
36728
d77de738 36729@opindex maddress-mode=long
ddf6fe37 36730@item -maddress-mode=long
d77de738
ML
36731Generate code for long address mode. This is only supported for 64-bit
36732and x32 environments. It is the default address mode for 64-bit
36733environments.
36734
d77de738 36735@opindex maddress-mode=short
ddf6fe37 36736@item -maddress-mode=short
d77de738
ML
36737Generate code for short address mode. This is only supported for 32-bit
36738and x32 environments. It is the default address mode for 32-bit and
36739x32 environments.
36740
ddf6fe37 36741@opindex mneeded
d77de738
ML
36742@item -mneeded
36743@itemx -mno-needed
d77de738
ML
36744Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
36745indicate the micro-architecture ISA level required to execute the binary.
36746
d77de738
ML
36747@opindex mno-direct-extern-access
36748@opindex mdirect-extern-access
ddf6fe37 36749@item -mno-direct-extern-access
d77de738
ML
36750Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
36751to access external symbols. With @option{-fpic} or @option{-fPIC},
36752treat access to protected symbols as local symbols. The default is
36753@option{-mdirect-extern-access}.
36754
36755@strong{Warning:} shared libraries compiled with
36756@option{-mno-direct-extern-access} and executable compiled with
36757@option{-mdirect-extern-access} may not be binary compatible if
36758protected symbols are used in shared libraries and executable.
ce51e843 36759
ce51e843
ML
36760@opindex munroll-only-small-loops
36761@opindex mno-unroll-only-small-loops
ddf6fe37 36762@item -munroll-only-small-loops
ce51e843
ML
36763Controls conservative small loop unrolling. It is default enabled by
36764O2, and unrolls loop with less than 4 insns by 1 time. Explicit
36765-f[no-]unroll-[all-]loops would disable this flag to avoid any
36766unintended unrolling behavior that user does not want.
bb576017 36767
bb576017 36768@opindex mlam
ddf6fe37 36769@item -mlam=@var{choice}
bb576017 36770LAM(linear-address masking) allows special bits in the pointer to be used
36771for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
36772positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
36773positions 62:57 can be used for metadata.
d77de738
ML
36774@end table
36775
36776@node x86 Windows Options
36777@subsection x86 Windows Options
36778@cindex x86 Windows Options
36779@cindex Windows Options for x86
36780
e8d00373
ZW
36781@xref{Cygwin and MinGW Options}.
36782
d77de738
ML
36783@node Xstormy16 Options
36784@subsection Xstormy16 Options
36785@cindex Xstormy16 Options
36786
36787These options are defined for Xstormy16:
36788
36789@table @gcctabopt
d77de738 36790@opindex msim
ddf6fe37 36791@item -msim
d77de738
ML
36792Choose startup files and linker script suitable for the simulator.
36793@end table
36794
36795@node Xtensa Options
36796@subsection Xtensa Options
36797@cindex Xtensa Options
36798
36799These options are supported for Xtensa targets:
36800
36801@table @gcctabopt
d77de738
ML
36802@opindex mconst16
36803@opindex mno-const16
ddf6fe37
AA
36804@item -mconst16
36805@itemx -mno-const16
d77de738
ML
36806Enable or disable use of @code{CONST16} instructions for loading
36807constant values. The @code{CONST16} instruction is currently not a
36808standard option from Tensilica. When enabled, @code{CONST16}
36809instructions are always used in place of the standard @code{L32R}
36810instructions. The use of @code{CONST16} is enabled by default only if
36811the @code{L32R} instruction is not available.
36812
d77de738
ML
36813@opindex mfused-madd
36814@opindex mno-fused-madd
ddf6fe37
AA
36815@item -mfused-madd
36816@itemx -mno-fused-madd
d77de738
ML
36817Enable or disable use of fused multiply/add and multiply/subtract
36818instructions in the floating-point option. This has no effect if the
36819floating-point option is not also enabled. Disabling fused multiply/add
36820and multiply/subtract instructions forces the compiler to use separate
36821instructions for the multiply and add/subtract operations. This may be
36822desirable in some cases where strict IEEE 754-compliant results are
36823required: the fused multiply add/subtract instructions do not round the
36824intermediate result, thereby producing results with @emph{more} bits of
36825precision than specified by the IEEE standard. Disabling fused multiply
36826add/subtract instructions also ensures that the program output is not
36827sensitive to the compiler's ability to combine multiply and add/subtract
36828operations.
36829
d77de738
ML
36830@opindex mserialize-volatile
36831@opindex mno-serialize-volatile
ddf6fe37
AA
36832@item -mserialize-volatile
36833@itemx -mno-serialize-volatile
d77de738
ML
36834When this option is enabled, GCC inserts @code{MEMW} instructions before
36835@code{volatile} memory references to guarantee sequential consistency.
36836The default is @option{-mserialize-volatile}. Use
36837@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
36838
d77de738 36839@opindex mforce-no-pic
ddf6fe37 36840@item -mforce-no-pic
d77de738
ML
36841For targets, like GNU/Linux, where all user-mode Xtensa code must be
36842position-independent code (PIC), this option disables PIC for compiling
36843kernel code.
36844
d77de738
ML
36845@opindex mtext-section-literals
36846@opindex mno-text-section-literals
ddf6fe37
AA
36847@item -mtext-section-literals
36848@itemx -mno-text-section-literals
d77de738
ML
36849These options control the treatment of literal pools. The default is
36850@option{-mno-text-section-literals}, which places literals in a separate
36851section in the output file. This allows the literal pool to be placed
36852in a data RAM/ROM, and it also allows the linker to combine literal
36853pools from separate object files to remove redundant literals and
36854improve code size. With @option{-mtext-section-literals}, the literals
36855are interspersed in the text section in order to keep them as close as
36856possible to their references. This may be necessary for large assembly
36857files. Literals for each function are placed right before that function.
36858
d77de738
ML
36859@opindex mauto-litpools
36860@opindex mno-auto-litpools
ddf6fe37
AA
36861@item -mauto-litpools
36862@itemx -mno-auto-litpools
d77de738
ML
36863These options control the treatment of literal pools. The default is
36864@option{-mno-auto-litpools}, which places literals in a separate
36865section in the output file unless @option{-mtext-section-literals} is
36866used. With @option{-mauto-litpools} the literals are interspersed in
36867the text section by the assembler. Compiler does not produce explicit
36868@code{.literal} directives and loads literals into registers with
36869@code{MOVI} instructions instead of @code{L32R} to let the assembler
36870do relaxation and place literals as necessary. This option allows
36871assembler to create several literal pools per function and assemble
36872very big functions, which may not be possible with
36873@option{-mtext-section-literals}.
36874
d77de738
ML
36875@opindex mtarget-align
36876@opindex mno-target-align
ddf6fe37
AA
36877@item -mtarget-align
36878@itemx -mno-target-align
d77de738
ML
36879When this option is enabled, GCC instructs the assembler to
36880automatically align instructions to reduce branch penalties at the
36881expense of some code density. The assembler attempts to widen density
36882instructions to align branch targets and the instructions following call
36883instructions. If there are not enough preceding safe density
36884instructions to align a target, no widening is performed. The
36885default is @option{-mtarget-align}. These options do not affect the
36886treatment of auto-aligned instructions like @code{LOOP}, which the
36887assembler always aligns, either by widening density instructions or
36888by inserting NOP instructions.
36889
d77de738
ML
36890@opindex mlongcalls
36891@opindex mno-longcalls
ddf6fe37
AA
36892@item -mlongcalls
36893@itemx -mno-longcalls
d77de738
ML
36894When this option is enabled, GCC instructs the assembler to translate
36895direct calls to indirect calls unless it can determine that the target
36896of a direct call is in the range allowed by the call instruction. This
36897translation typically occurs for calls to functions in other source
36898files. Specifically, the assembler translates a direct @code{CALL}
36899instruction into an @code{L32R} followed by a @code{CALLX} instruction.
36900The default is @option{-mno-longcalls}. This option should be used in
36901programs where the call target can potentially be out of range. This
36902option is implemented in the assembler, not the compiler, so the
36903assembly code generated by GCC still shows direct call
36904instructions---look at the disassembled object code to see the actual
36905instructions. Note that the assembler uses an indirect call for
36906every cross-file call, not just those that really are out of range.
36907
d77de738 36908@opindex mabi
ddf6fe37 36909@item -mabi=@var{name}
d77de738
ML
36910Generate code for the specified ABI@. Permissible values are: @samp{call0},
36911@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
36912
d77de738 36913@opindex mabi=call0
ddf6fe37 36914@item -mabi=call0
d77de738
ML
36915When this option is enabled function parameters are passed in registers
36916@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
36917caller-saved, and register @code{a15} may be used as a frame pointer.
36918When this version of the ABI is enabled the C preprocessor symbol
36919@code{__XTENSA_CALL0_ABI__} is defined.
36920
d77de738 36921@opindex mabi=windowed
ddf6fe37 36922@item -mabi=windowed
d77de738
ML
36923When this option is enabled function parameters are passed in registers
36924@code{a10} through @code{a15}, and called function rotates register window
36925by 8 registers on entry so that its arguments are found in registers
36926@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
36927pointer. Register window is rotated 8 registers back upon return.
36928When this version of the ABI is enabled the C preprocessor symbol
36929@code{__XTENSA_WINDOWED_ABI__} is defined.
36930
d77de738 36931@opindex mextra-l32r-costs
ddf6fe37 36932@item -mextra-l32r-costs=@var{n}
d77de738
ML
36933Specify an extra cost of instruction RAM/ROM access for @code{L32R}
36934instructions, in clock cycles. This affects, when optimizing for speed,
36935whether loading a constant from literal pool using @code{L32R} or
36936synthesizing the constant from a small one with a couple of arithmetic
36937instructions. The default value is 0.
675b390e
MF
36938
36939@opindex mstrict-align
36940@opindex mno-strict-align
36941@item -mstrict-align
36942@itemx -mno-strict-align
36943Avoid or allow generating memory accesses that may not be aligned on a natural
36944object boundary as described in the architecture specification.
36945The default is @option{-mno-strict-align} for cores that support both
36946unaligned loads and stores in hardware and @option{-mstrict-align} for all
36947other cores.
36948
d77de738
ML
36949@end table
36950
36951@node zSeries Options
36952@subsection zSeries Options
36953@cindex zSeries options
36954
36955These are listed under @xref{S/390 and zSeries Options}.
36956
36957
36958@c man end
36959
36960@node Spec Files
36961@section Specifying Subprocesses and the Switches to Pass to Them
36962@cindex Spec Files
36963
36964@command{gcc} is a driver program. It performs its job by invoking a
36965sequence of other programs to do the work of compiling, assembling and
36966linking. GCC interprets its command-line parameters and uses these to
36967deduce which programs it should invoke, and which command-line options
36968it ought to place on their command lines. This behavior is controlled
36969by @dfn{spec strings}. In most cases there is one spec string for each
36970program that GCC can invoke, but a few programs have multiple spec
36971strings to control their behavior. The spec strings built into GCC can
36972be overridden by using the @option{-specs=} command-line switch to specify
36973a spec file.
36974
36975@dfn{Spec files} are plain-text files that are used to construct spec
36976strings. They consist of a sequence of directives separated by blank
36977lines. The type of directive is determined by the first non-whitespace
36978character on the line, which can be one of the following:
36979
36980@table @code
36981@item %@var{command}
36982Issues a @var{command} to the spec file processor. The commands that can
36983appear here are:
36984
36985@table @code
d77de738 36986@cindex @code{%include}
f33d7a88 36987@item %include <@var{file}>
d77de738
ML
36988Search for @var{file} and insert its text at the current point in the
36989specs file.
36990
d77de738 36991@cindex @code{%include_noerr}
f33d7a88 36992@item %include_noerr <@var{file}>
d77de738
ML
36993Just like @samp{%include}, but do not generate an error message if the include
36994file cannot be found.
36995
d77de738 36996@cindex @code{%rename}
f33d7a88 36997@item %rename @var{old_name} @var{new_name}
d77de738
ML
36998Rename the spec string @var{old_name} to @var{new_name}.
36999
37000@end table
37001
37002@item *[@var{spec_name}]:
37003This tells the compiler to create, override or delete the named spec
37004string. All lines after this directive up to the next directive or
37005blank line are considered to be the text for the spec string. If this
37006results in an empty string then the spec is deleted. (Or, if the
37007spec did not exist, then nothing happens.) Otherwise, if the spec
37008does not currently exist a new spec is created. If the spec does
37009exist then its contents are overridden by the text of this
37010directive, unless the first character of that text is the @samp{+}
37011character, in which case the text is appended to the spec.
37012
37013@item [@var{suffix}]:
37014Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
37015and up to the next directive or blank line are considered to make up the
37016spec string for the indicated suffix. When the compiler encounters an
37017input file with the named suffix, it processes the spec string in
37018order to work out how to compile that file. For example:
37019
37020@smallexample
37021.ZZ:
37022z-compile -input %i
37023@end smallexample
37024
37025This says that any input file whose name ends in @samp{.ZZ} should be
37026passed to the program @samp{z-compile}, which should be invoked with the
37027command-line switch @option{-input} and with the result of performing the
37028@samp{%i} substitution. (See below.)
37029
37030As an alternative to providing a spec string, the text following a
37031suffix directive can be one of the following:
37032
37033@table @code
37034@item @@@var{language}
37035This says that the suffix is an alias for a known @var{language}. This is
37036similar to using the @option{-x} command-line switch to GCC to specify a
37037language explicitly. For example:
37038
37039@smallexample
37040.ZZ:
37041@@c++
37042@end smallexample
37043
37044Says that .ZZ files are, in fact, C++ source files.
37045
37046@item #@var{name}
37047This causes an error messages saying:
37048
37049@smallexample
37050@var{name} compiler not installed on this system.
37051@end smallexample
37052@end table
37053
37054GCC already has an extensive list of suffixes built into it.
37055This directive adds an entry to the end of the list of suffixes, but
37056since the list is searched from the end backwards, it is effectively
37057possible to override earlier entries using this technique.
37058
37059@end table
37060
37061GCC has the following spec strings built into it. Spec files can
37062override these strings or create their own. Note that individual
37063targets can also add their own spec strings to this list.
37064
37065@smallexample
37066asm Options to pass to the assembler
37067asm_final Options to pass to the assembler post-processor
37068cpp Options to pass to the C preprocessor
37069cc1 Options to pass to the C compiler
37070cc1plus Options to pass to the C++ compiler
37071endfile Object files to include at the end of the link
37072link Options to pass to the linker
37073lib Libraries to include on the command line to the linker
37074libgcc Decides which GCC support library to pass to the linker
37075linker Sets the name of the linker
d77de738
ML
37076startfile Object files to include at the start of the link
37077@end smallexample
37078
37079Here is a small example of a spec file:
37080
37081@smallexample
37082%rename lib old_lib
37083
37084*lib:
37085--start-group -lgcc -lc -leval1 --end-group %(old_lib)
37086@end smallexample
37087
37088This example renames the spec called @samp{lib} to @samp{old_lib} and
37089then overrides the previous definition of @samp{lib} with a new one.
37090The new definition adds in some extra command-line options before
37091including the text of the old definition.
37092
37093@dfn{Spec strings} are a list of command-line options to be passed to their
37094corresponding program. In addition, the spec strings can contain
37095@samp{%}-prefixed sequences to substitute variable text or to
37096conditionally insert text into the command line. Using these constructs
37097it is possible to generate quite complex command lines.
37098
37099Here is a table of all defined @samp{%}-sequences for spec
37100strings. Note that spaces are not generated automatically around the
37101results of expanding these sequences. Therefore you can concatenate them
37102together or combine them with constant text in a single argument.
37103
37104@table @code
37105@item %%
37106Substitute one @samp{%} into the program name or argument.
37107
37108@item %"
37109Substitute an empty argument.
37110
37111@item %i
37112Substitute the name of the input file being processed.
37113
37114@item %b
37115Substitute the basename for outputs related with the input file being
37116processed. This is often the substring up to (and not including) the
37117last period and not including the directory but, unless %w is active, it
37118expands to the basename for auxiliary outputs, which may be influenced
37119by an explicit output name, and by various other options that control
37120how auxiliary outputs are named.
37121
37122@item %B
37123This is the same as @samp{%b}, but include the file suffix (text after
37124the last period). Without %w, it expands to the basename for dump
37125outputs.
37126
37127@item %d
37128Marks the argument containing or following the @samp{%d} as a
37129temporary file name, so that that file is deleted if GCC exits
37130successfully. Unlike @samp{%g}, this contributes no text to the
37131argument.
37132
37133@item %g@var{suffix}
37134Substitute a file name that has suffix @var{suffix} and is chosen
37135once per compilation, and mark the argument in the same way as
37136@samp{%d}. To reduce exposure to denial-of-service attacks, the file
37137name is now chosen in a way that is hard to predict even when previously
37138chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
37139might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
37140the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
37141treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
37142was simply substituted with a file name chosen once per compilation,
37143without regard to any appended suffix (which was therefore treated
37144just like ordinary text), making such attacks more likely to succeed.
37145
37146@item %u@var{suffix}
37147Like @samp{%g}, but generates a new temporary file name
37148each time it appears instead of once per compilation.
37149
37150@item %U@var{suffix}
37151Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
37152new one if there is no such last file name. In the absence of any
37153@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
37154the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
37155involves the generation of two distinct file names, one
37156for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
37157simply substituted with a file name chosen for the previous @samp{%u},
37158without regard to any appended suffix.
37159
37160@item %j@var{suffix}
37161Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
a0e64a04 37162writable, and if @option{-save-temps} is not used;
d77de738
ML
37163otherwise, substitute the name
37164of a temporary file, just like @samp{%u}. This temporary file is not
37165meant for communication between processes, but rather as a junk
37166disposal mechanism.
37167
37168@item %|@var{suffix}
37169@itemx %m@var{suffix}
37170Like @samp{%g}, except if @option{-pipe} is in effect. In that case
37171@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
37172all. These are the two most common ways to instruct a program that it
37173should read from standard input or write to standard output. If you
37174need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
37175construct: see for example @file{gcc/fortran/lang-specs.h}.
37176
37177@item %.@var{SUFFIX}
37178Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
37179when it is subsequently output with @samp{%*}. @var{SUFFIX} is
37180terminated by the next space or %.
37181
37182@item %w
37183Marks the argument containing or following the @samp{%w} as the
37184designated output file of this compilation. This puts the argument
37185into the sequence of arguments that @samp{%o} substitutes.
37186
37187@item %V
37188Indicates that this compilation produces no output file.
37189
37190@item %o
37191Substitutes the names of all the output files, with spaces
37192automatically placed around them. You should write spaces
37193around the @samp{%o} as well or the results are undefined.
37194@samp{%o} is for use in the specs for running the linker.
37195Input files whose names have no recognized suffix are not compiled
37196at all, but they are included among the output files, so they are
37197linked.
37198
37199@item %O
37200Substitutes the suffix for object files. Note that this is
37201handled specially when it immediately follows @samp{%g, %u, or %U},
37202because of the need for those to form complete file names. The
37203handling is such that @samp{%O} is treated exactly as if it had already
37204been substituted, except that @samp{%g, %u, and %U} do not currently
37205support additional @var{suffix} characters following @samp{%O} as they do
37206following, for example, @samp{.o}.
37207
37208@item %I
37209Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
37210@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
37211@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
37212and @option{-imultilib} as necessary.
37213
37214@item %s
37215Current argument is the name of a library or startup file of some sort.
37216Search for that file in a standard list of directories and substitute
37217the full name found. The current working directory is included in the
37218list of directories scanned.
37219
37220@item %T
37221Current argument is the name of a linker script. Search for that file
37222in the current list of directories to scan for libraries. If the file
37223is located insert a @option{--script} option into the command line
37224followed by the full path name found. If the file is not found then
37225generate an error message. Note: the current working directory is not
37226searched.
37227
37228@item %e@var{str}
37229Print @var{str} as an error message. @var{str} is terminated by a newline.
37230Use this when inconsistent options are detected.
37231
37232@item %n@var{str}
37233Print @var{str} as a notice. @var{str} is terminated by a newline.
37234
37235@item %(@var{name})
37236Substitute the contents of spec string @var{name} at this point.
37237
37238@item %x@{@var{option}@}
37239Accumulate an option for @samp{%X}.
37240
37241@item %X
37242Output the accumulated linker options specified by a @samp{%x} spec string.
37243
37244@item %Y
37245Output the accumulated assembler options specified by @option{-Wa}.
37246
37247@item %Z
37248Output the accumulated preprocessor options specified by @option{-Wp}.
37249
37250@item %M
37251Output @code{multilib_os_dir}.
37252
37253@item %R
37254Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
37255
37256@item %a
37257Process the @code{asm} spec. This is used to compute the
37258switches to be passed to the assembler.
37259
37260@item %A
37261Process the @code{asm_final} spec. This is a spec string for
37262passing switches to an assembler post-processor, if such a program is
37263needed.
37264
37265@item %l
37266Process the @code{link} spec. This is the spec for computing the
37267command line passed to the linker. Typically it makes use of the
37268@samp{%L %G %S %D and %E} sequences.
37269
37270@item %D
37271Dump out a @option{-L} option for each directory that GCC believes might
37272contain startup files. If the target supports multilibs then the
37273current multilib directory is prepended to each of these paths.
37274
37275@item %L
37276Process the @code{lib} spec. This is a spec string for deciding which
37277libraries are included on the command line to the linker.
37278
37279@item %G
37280Process the @code{libgcc} spec. This is a spec string for deciding
37281which GCC support library is included on the command line to the linker.
37282
37283@item %S
37284Process the @code{startfile} spec. This is a spec for deciding which
37285object files are the first ones passed to the linker. Typically
37286this might be a file named @file{crt0.o}.
37287
37288@item %E
37289Process the @code{endfile} spec. This is a spec string that specifies
37290the last object files that are passed to the linker.
37291
37292@item %C
37293Process the @code{cpp} spec. This is used to construct the arguments
37294to be passed to the C preprocessor.
37295
37296@item %1
37297Process the @code{cc1} spec. This is used to construct the options to be
37298passed to the actual C compiler (@command{cc1}).
37299
37300@item %2
37301Process the @code{cc1plus} spec. This is used to construct the options to be
37302passed to the actual C++ compiler (@command{cc1plus}).
37303
37304@item %*
37305Substitute the variable part of a matched option. See below.
37306Note that each comma in the substituted string is replaced by
37307a single space.
37308
db41057a
JJ
37309@item %<@var{S}
37310Remove all occurrences of @code{-@var{S}} from the command line. Note---this
d77de738 37311command is position dependent. @samp{%} commands in the spec string
db41057a 37312before this one see @code{-@var{S}}, @samp{%} commands in the spec string
d77de738
ML
37313after this one do not.
37314
db41057a
JJ
37315@item %<@var{S}*
37316Similar to @samp{%<@var{S}}, but match all switches beginning with @code{-@var{S}}.
d77de738 37317
db41057a
JJ
37318@item %>@var{S}
37319Similar to @samp{%<@var{S}}, but keep @code{-@var{S}} in the GCC command line.
d77de738
ML
37320
37321@item %:@var{function}(@var{args})
37322Call the named function @var{function}, passing it @var{args}.
37323@var{args} is first processed as a nested spec string, then split
37324into an argument vector in the usual fashion. The function returns
37325a string which is processed as if it had appeared literally as part
37326of the current spec.
37327
37328The following built-in spec functions are provided:
37329
37330@table @code
37331@item @code{getenv}
37332The @code{getenv} spec function takes two arguments: an environment
37333variable name and a string. If the environment variable is not
37334defined, a fatal error is issued. Otherwise, the return value is the
37335value of the environment variable concatenated with the string. For
37336example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
37337
37338@smallexample
37339%:getenv(TOPDIR /include)
37340@end smallexample
37341
37342expands to @file{/path/to/top/include}.
37343
37344@item @code{if-exists}
37345The @code{if-exists} spec function takes one argument, an absolute
37346pathname to a file. If the file exists, @code{if-exists} returns the
37347pathname. Here is a small example of its usage:
37348
37349@smallexample
37350*startfile:
37351crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
37352@end smallexample
37353
37354@item @code{if-exists-else}
37355The @code{if-exists-else} spec function is similar to the @code{if-exists}
37356spec function, except that it takes two arguments. The first argument is
37357an absolute pathname to a file. If the file exists, @code{if-exists-else}
37358returns the pathname. If it does not exist, it returns the second argument.
37359This way, @code{if-exists-else} can be used to select one file or another,
37360based on the existence of the first. Here is a small example of its usage:
37361
37362@smallexample
37363*startfile:
37364crt0%O%s %:if-exists(crti%O%s) \
37365%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
37366@end smallexample
37367
37368@item @code{if-exists-then-else}
37369The @code{if-exists-then-else} spec function takes at least two arguments
37370and an optional third one. The first argument is an absolute pathname to a
37371file. If the file exists, the function returns the second argument.
37372If the file does not exist, the function returns the third argument if there
37373is one, or NULL otherwise. This can be used to expand one text, or optionally
37374another, based on the existence of a file. Here is a small example of its
37375usage:
37376
37377@smallexample
37378-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
37379@end smallexample
37380
37381@item @code{sanitize}
37382The @code{sanitize} spec function takes no arguments. It returns non-NULL if
37383any address, thread or undefined behavior sanitizers are active.
37384
37385@smallexample
37386%@{%:sanitize(address):-funwind-tables@}
37387@end smallexample
37388
37389@item @code{replace-outfile}
37390The @code{replace-outfile} spec function takes two arguments. It looks for the
37391first argument in the outfiles array and replaces it with the second argument. Here
37392is a small example of its usage:
37393
37394@smallexample
37395%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
37396@end smallexample
37397
37398@item @code{remove-outfile}
37399The @code{remove-outfile} spec function takes one argument. It looks for the
37400first argument in the outfiles array and removes it. Here is a small example
37401its usage:
37402
37403@smallexample
37404%:remove-outfile(-lm)
37405@end smallexample
37406
37407@item @code{version-compare}
37408The @code{version-compare} spec function takes four or five arguments of the following
37409form:
37410
37411@smallexample
37412<comparison-op> <arg1> [<arg2>] <switch> <result>
37413@end smallexample
37414
37415It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
37416The supported @code{comparison-op} values are:
37417
37418@table @code
37419@item >=
37420True if @code{switch} is a later (or same) version than @code{arg1}
37421
37422@item !>
37423Opposite of @code{>=}
37424
37425@item <
37426True if @code{switch} is an earlier version than @code{arg1}
37427
37428@item !<
37429Opposite of @code{<}
37430
37431@item ><
37432True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
37433
37434@item <>
37435True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
37436@end table
37437
37438If the @code{switch} is not present at all, the condition is false unless the first character
37439of the @code{comparison-op} is @code{!}.
37440
37441@smallexample
37442%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
37443@end smallexample
37444
37445The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
37446passed.
37447
37448@item @code{include}
37449The @code{include} spec function behaves much like @code{%include}, with the advantage
37450that it can be nested inside a spec and thus be conditionalized. It takes one argument,
37451the filename, and looks for it in the startfile path. It always returns NULL.
37452
37453@smallexample
37454%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
37455@end smallexample
37456
37457@item @code{pass-through-libs}
37458The @code{pass-through-libs} spec function takes any number of arguments. It
37459finds any @option{-l} options and any non-options ending in @file{.a} (which it
37460assumes are the names of linker input library archive files) and returns a
37461result containing all the found arguments each prepended by
37462@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
37463intended to be passed to the LTO linker plugin.
37464
37465@smallexample
37466%:pass-through-libs(%G %L %G)
37467@end smallexample
37468
37469@item @code{print-asm-header}
37470The @code{print-asm-header} function takes no arguments and simply
37471prints a banner like:
37472
37473@smallexample
37474Assembler options
37475=================
37476
37477Use "-Wa,OPTION" to pass "OPTION" to the assembler.
37478@end smallexample
37479
37480It is used to separate compiler options from assembler options
37481in the @option{--target-help} output.
37482
37483@item @code{gt}
37484The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
37485empty string) if the second-to-last argument is greater than the last argument, and NULL
37486otherwise. The following example inserts the @code{link_gomp} spec if the last
37487@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
37488
37489@smallexample
37490%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
37491@end smallexample
37492
37493@item @code{debug-level-gt}
37494The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
37495empty string) if @code{debug_info_level} is greater than the specified number, and NULL
37496otherwise.
37497
37498@smallexample
37499%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
37500@end smallexample
37501@end table
37502
db41057a
JJ
37503@item %@{@var{S}@}
37504Substitutes the @code{-@var{S}} switch, if that switch is given to GCC@.
d77de738
ML
37505If that switch is not specified, this substitutes nothing. Note that
37506the leading dash is omitted when specifying this option, and it is
37507automatically inserted if the substitution is performed. Thus the spec
37508string @samp{%@{foo@}} matches the command-line option @option{-foo}
37509and outputs the command-line option @option{-foo}.
37510
db41057a
JJ
37511@item %W@{@var{S}@}
37512Like %@{@code{@var{S}}@} but mark last argument supplied within as a file to be
d77de738
ML
37513deleted on failure.
37514
db41057a
JJ
37515@item %@@@{@var{S}@}
37516Like %@{@code{@var{S}}@} but puts the result into a @code{FILE} and substitutes
d77de738
ML
37517@code{@@FILE} if an @code{@@file} argument has been supplied.
37518
db41057a 37519@item %@{@var{S}*@}
d77de738 37520Substitutes all the switches specified to GCC whose names start
db41057a 37521with @code{-@var{S}}, but which also take an argument. This is used for
d77de738
ML
37522switches like @option{-o}, @option{-D}, @option{-I}, etc.
37523GCC considers @option{-o foo} as being
37524one switch whose name starts with @samp{o}. %@{o*@} substitutes this
37525text, including the space. Thus two arguments are generated.
37526
db41057a
JJ
37527@item %@{@var{S}*&@var{T}*@}
37528Like %@{@code{@var{S}}*@}, but preserve order of @code{@var{S}} and @code{@var{T}} options
37529(the order of @code{@var{S}} and @code{@var{T}} in the spec is not significant).
d77de738
ML
37530There can be any number of ampersand-separated variables; for each the
37531wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
37532
db41057a
JJ
37533@item %@{@var{S}:@var{X}@}
37534Substitutes @code{@var{X}}, if the @option{-@var{S}} switch is given to GCC@.
d77de738 37535
db41057a
JJ
37536@item %@{!@var{S}:@var{X}@}
37537Substitutes @code{@var{X}}, if the @option{-@var{S}} switch is @emph{not} given to GCC@.
d77de738 37538
db41057a
JJ
37539@item %@{@var{S}*:@var{X}@}
37540Substitutes @code{@var{X}} if one or more switches whose names start with
37541@code{-@var{S}} are specified to GCC@. Normally @code{@var{X}} is substituted only
d77de738 37542once, no matter how many such switches appeared. However, if @code{%*}
db41057a 37543appears somewhere in @code{@var{X}}, then @code{@var{X}} is substituted once
d77de738
ML
37544for each matching switch, with the @code{%*} replaced by the part of
37545that switch matching the @code{*}.
37546
37547If @code{%*} appears as the last part of a spec sequence then a space
37548is added after the end of the last substitution. If there is more
37549text in the sequence, however, then a space is not generated. This
37550allows the @code{%*} substitution to be used as part of a larger
37551string. For example, a spec string like this:
37552
37553@smallexample
37554%@{mcu=*:--script=%*/memory.ld@}
37555@end smallexample
37556
37557@noindent
37558when matching an option like @option{-mcu=newchip} produces:
37559
37560@smallexample
37561--script=newchip/memory.ld
37562@end smallexample
37563
db41057a
JJ
37564@item %@{.@var{S}:@var{X}@}
37565Substitutes @code{@var{X}}, if processing a file with suffix @code{@var{S}}.
d77de738 37566
db41057a
JJ
37567@item %@{!.@var{S}:@var{X}@}
37568Substitutes @code{@var{X}}, if @emph{not} processing a file with suffix @code{@var{S}}.
d77de738 37569
db41057a
JJ
37570@item %@{,@var{S}:@var{X}@}
37571Substitutes @code{@var{X}}, if processing a file for language @code{@var{S}}.
d77de738 37572
db41057a
JJ
37573@item %@{!,@var{S}:@var{X}@}
37574Substitutes @code{@var{X}}, if not processing a file for language @code{@var{S}}.
d77de738 37575
db41057a
JJ
37576@item %@{@var{S}|@var{P}:@var{X}@}
37577Substitutes @code{@var{X}} if either @code{-@var{S}} or @code{-@var{P}} is given to
d77de738
ML
37578GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
37579@code{*} sequences as well, although they have a stronger binding than
db41057a 37580the @samp{|}. If @code{%*} appears in @code{@var{X}}, all of the
d77de738
ML
37581alternatives must be starred, and only the first matching alternative
37582is substituted.
37583
37584For example, a spec string like this:
37585
37586@smallexample
37587%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
37588@end smallexample
37589
37590@noindent
37591outputs the following command-line options from the following input
37592command-line options:
37593
37594@smallexample
37595fred.c -foo -baz
37596jim.d -bar -boggle
37597-d fred.c -foo -baz -boggle
37598-d jim.d -bar -baz -boggle
37599@end smallexample
37600
db41057a 37601@item %@{%:@var{function}(@var{args}):@var{X}@}
d77de738
ML
37602
37603Call function named @var{function} with args @var{args}. If the
db41057a 37604function returns non-NULL, then @code{@var{X}} is substituted, if it returns
d77de738
ML
37605NULL, it isn't substituted.
37606
db41057a 37607@item %@{@var{S}:@var{X}; @var{T}:@var{Y}; :@var{D}@}
d77de738 37608
db41057a
JJ
37609If @code{@var{S}} is given to GCC, substitutes @code{@var{X}}; else if @code{@var{T}} is
37610given to GCC, substitutes @code{@var{Y}}; else substitutes @code{@var{D}}. There can
d77de738
ML
37611be as many clauses as you need. This may be combined with @code{.},
37612@code{,}, @code{!}, @code{|}, and @code{*} as needed.
37613
37614
37615@end table
37616
db41057a 37617The switch matching text @code{@var{S}} in a @samp{%@{@var{S}@}}, @samp{%@{@var{S}:@var{X}@}}
d77de738
ML
37618or similar construct can use a backslash to ignore the special meaning
37619of the character following it, thus allowing literal matching of a
37620character that is otherwise specially treated. For example,
db41057a 37621@samp{%@{std=iso9899\:1999:@var{X}@}} substitutes @code{@var{X}} if the
d77de738
ML
37622@option{-std=iso9899:1999} option is given.
37623
db41057a 37624The conditional text @code{@var{X}} in a @samp{%@{@var{S}:@var{X}@}} or similar
d77de738
ML
37625construct may contain other nested @samp{%} constructs or spaces, or
37626even newlines. They are processed as usual, as described above.
db41057a 37627Trailing white space in @code{@var{X}} is ignored. White space may also
d77de738
ML
37628appear anywhere on the left side of the colon in these constructs,
37629except between @code{.} or @code{*} and the corresponding word.
37630
37631The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
37632handled specifically in these constructs. If another value of
37633@option{-O} or the negated form of a @option{-f}, @option{-m}, or
37634@option{-W} switch is found later in the command line, the earlier
db41057a 37635switch value is ignored, except with @{@code{@var{S}}*@} where @code{@var{S}} is
d77de738
ML
37636just one letter, which passes all matching options.
37637
37638The character @samp{|} at the beginning of the predicate text is used to
37639indicate that a command should be piped to the following command, but
37640only if @option{-pipe} is specified.
37641
37642It is built into GCC which switches take arguments and which do not.
37643(You might think it would be useful to generalize this to allow each
37644compiler's spec to say which switches take arguments. But this cannot
37645be done in a consistent fashion. GCC cannot even decide which input
37646files have been specified without knowing which switches take arguments,
37647and it must know which input files to compile in order to tell which
37648compilers to run).
37649
37650GCC also knows implicitly that arguments starting in @option{-l} are to be
37651treated as compiler output files, and passed to the linker in their
37652proper position among the other output files.
37653
37654@node Environment Variables
37655@section Environment Variables Affecting GCC
37656@cindex environment variables
37657
37658@c man begin ENVIRONMENT
37659This section describes several environment variables that affect how GCC
37660operates. Some of them work by specifying directories or prefixes to use
37661when searching for various kinds of files. Some are used to specify other
37662aspects of the compilation environment.
37663
37664Note that you can also specify places to search using options such as
37665@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
37666take precedence over places specified using environment variables, which
37667in turn take precedence over those specified by the configuration of GCC@.
37668@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
37669GNU Compiler Collection (GCC) Internals}.
37670
37671@table @env
f33d7a88
AA
37672@vindex LANG
37673@vindex LC_CTYPE
37674@c @vindex LC_COLLATE
37675@vindex LC_MESSAGES
37676@c @vindex LC_MONETARY
37677@c @vindex LC_NUMERIC
37678@c @vindex LC_TIME
37679@vindex LC_ALL
37680@cindex locale
d77de738
ML
37681@item LANG
37682@itemx LC_CTYPE
37683@c @itemx LC_COLLATE
37684@itemx LC_MESSAGES
37685@c @itemx LC_MONETARY
37686@c @itemx LC_NUMERIC
37687@c @itemx LC_TIME
37688@itemx LC_ALL
d77de738
ML
37689These environment variables control the way that GCC uses
37690localization information which allows GCC to work with different
37691national conventions. GCC inspects the locale categories
37692@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
37693so. These locale categories can be set to any value supported by your
37694installation. A typical value is @samp{en_GB.UTF-8} for English in the United
37695Kingdom encoded in UTF-8.
37696
37697The @env{LC_CTYPE} environment variable specifies character
37698classification. GCC uses it to determine the character boundaries in
37699a string; this is needed for some multibyte encodings that contain quote
37700and escape characters that are otherwise interpreted as a string
37701end or escape.
37702
37703The @env{LC_MESSAGES} environment variable specifies the language to
37704use in diagnostic messages.
37705
37706If the @env{LC_ALL} environment variable is set, it overrides the value
37707of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
37708and @env{LC_MESSAGES} default to the value of the @env{LANG}
37709environment variable. If none of these variables are set, GCC
37710defaults to traditional C English behavior.
37711
f33d7a88 37712@vindex TMPDIR
d77de738 37713@item TMPDIR
d77de738
ML
37714If @env{TMPDIR} is set, it specifies the directory to use for temporary
37715files. GCC uses temporary files to hold the output of one stage of
37716compilation which is to be used as input to the next stage: for example,
37717the output of the preprocessor, which is the input to the compiler
37718proper.
37719
f33d7a88 37720@vindex GCC_COMPARE_DEBUG
d77de738 37721@item GCC_COMPARE_DEBUG
d77de738
ML
37722Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
37723@option{-fcompare-debug} to the compiler driver. See the documentation
37724of this option for more details.
37725
f33d7a88 37726@vindex GCC_EXEC_PREFIX
d77de738 37727@item GCC_EXEC_PREFIX
d77de738
ML
37728If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
37729names of the subprograms executed by the compiler. No slash is added
37730when this prefix is combined with the name of a subprogram, but you can
37731specify a prefix that ends with a slash if you wish.
37732
37733If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
37734an appropriate prefix to use based on the pathname it is invoked with.
37735
37736If GCC cannot find the subprogram using the specified prefix, it
37737tries looking in the usual places for the subprogram.
37738
37739The default value of @env{GCC_EXEC_PREFIX} is
37740@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
37741the installed compiler. In many cases @var{prefix} is the value
37742of @code{prefix} when you ran the @file{configure} script.
37743
37744Other prefixes specified with @option{-B} take precedence over this prefix.
37745
37746This prefix is also used for finding files such as @file{crt0.o} that are
37747used for linking.
37748
37749In addition, the prefix is used in an unusual way in finding the
37750directories to search for header files. For each of the standard
37751directories whose name normally begins with @samp{/usr/local/lib/gcc}
37752(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
37753replacing that beginning with the specified prefix to produce an
37754alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
a0e64a04 37755@file{foo/bar} just before it searches the standard directory
d77de738
ML
37756@file{/usr/local/lib/bar}.
37757If a standard directory begins with the configured
37758@var{prefix} then the value of @var{prefix} is replaced by
37759@env{GCC_EXEC_PREFIX} when looking for header files.
37760
f33d7a88 37761@vindex COMPILER_PATH
d77de738 37762@item COMPILER_PATH
d77de738
ML
37763The value of @env{COMPILER_PATH} is a colon-separated list of
37764directories, much like @env{PATH}. GCC tries the directories thus
37765specified when searching for subprograms, if it cannot find the
37766subprograms using @env{GCC_EXEC_PREFIX}.
37767
f33d7a88 37768@vindex LIBRARY_PATH
d77de738 37769@item LIBRARY_PATH
d77de738
ML
37770The value of @env{LIBRARY_PATH} is a colon-separated list of
37771directories, much like @env{PATH}. When configured as a native compiler,
37772GCC tries the directories thus specified when searching for special
37773linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
37774using GCC also uses these directories when searching for ordinary
37775libraries for the @option{-l} option (but directories specified with
37776@option{-L} come first).
37777
f33d7a88 37778@vindex LANG
d77de738 37779@cindex locale definition
f33d7a88 37780@item LANG
d77de738
ML
37781This variable is used to pass locale information to the compiler. One way in
37782which this information is used is to determine the character set to be used
37783when character literals, string literals and comments are parsed in C and C++.
37784When the compiler is configured to allow multibyte characters,
37785the following values for @env{LANG} are recognized:
37786
37787@table @samp
37788@item C-JIS
37789Recognize JIS characters.
37790@item C-SJIS
37791Recognize SJIS characters.
37792@item C-EUCJP
37793Recognize EUCJP characters.
37794@end table
37795
37796If @env{LANG} is not defined, or if it has some other value, then the
37797compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
37798recognize and translate multibyte characters.
37799
f33d7a88 37800@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 37801@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
37802If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
37803then additional text will be emitted to stderr when fix-it hints are
37804emitted. @option{-fdiagnostics-parseable-fixits} and
37805@option{-fno-diagnostics-parseable-fixits} take precedence over this
37806environment variable.
37807
37808@table @samp
37809@item fixits-v1
37810Emit parseable fix-it hints, equivalent to
37811@option{-fdiagnostics-parseable-fixits}. In particular, columns are
37812expressed as a count of bytes, starting at byte 1 for the initial column.
37813
37814@item fixits-v2
37815As @code{fixits-v1}, but columns are expressed as display columns,
37816as per @option{-fdiagnostics-column-unit=display}.
37817@end table
37818
37819@end table
37820
37821@noindent
37822Some additional environment variables affect the behavior of the
37823preprocessor.
37824
37825@include cppenv.texi
37826
37827@c man end
37828
37829@node Precompiled Headers
37830@section Using Precompiled Headers
37831@cindex precompiled headers
37832@cindex speed of compilation
37833
37834Often large projects have many header files that are included in every
37835source file. The time the compiler takes to process these header files
37836over and over again can account for nearly all of the time required to
37837build the project. To make builds faster, GCC allows you to
37838@dfn{precompile} a header file.
37839
37840To create a precompiled header file, simply compile it as you would any
37841other file, if necessary using the @option{-x} option to make the driver
37842treat it as a C or C++ header file. You may want to use a
37843tool like @command{make} to keep the precompiled header up-to-date when
37844the headers it contains change.
37845
37846A precompiled header file is searched for when @code{#include} is
37847seen in the compilation. As it searches for the included file
37848(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
37849compiler looks for a precompiled header in each directory just before it
37850looks for the include file in that directory. The name searched for is
37851the name specified in the @code{#include} with @samp{.gch} appended. If
37852the precompiled header file cannot be used, it is ignored.
37853
37854For instance, if you have @code{#include "all.h"}, and you have
37855@file{all.h.gch} in the same directory as @file{all.h}, then the
37856precompiled header file is used if possible, and the original
37857header is used otherwise.
37858
37859Alternatively, you might decide to put the precompiled header file in a
37860directory and use @option{-I} to ensure that directory is searched
37861before (or instead of) the directory containing the original header.
37862Then, if you want to check that the precompiled header file is always
37863used, you can put a file of the same name as the original header in this
37864directory containing an @code{#error} command.
37865
37866This also works with @option{-include}. So yet another way to use
37867precompiled headers, good for projects not designed with precompiled
37868header files in mind, is to simply take most of the header files used by
37869a project, include them from another header file, precompile that header
37870file, and @option{-include} the precompiled header. If the header files
37871have guards against multiple inclusion, they are skipped because
37872they've already been included (in the precompiled header).
37873
37874If you need to precompile the same header file for different
37875languages, targets, or compiler options, you can instead make a
37876@emph{directory} named like @file{all.h.gch}, and put each precompiled
37877header in the directory, perhaps using @option{-o}. It doesn't matter
37878what you call the files in the directory; every precompiled header in
37879the directory is considered. The first precompiled header
37880encountered in the directory that is valid for this compilation is
37881used; they're searched in no particular order.
37882
37883There are many other possibilities, limited only by your imagination,
37884good sense, and the constraints of your build system.
37885
37886A precompiled header file can be used only when these conditions apply:
37887
37888@itemize
37889@item
37890Only one precompiled header can be used in a particular compilation.
37891
37892@item
37893A precompiled header cannot be used once the first C token is seen. You
37894can have preprocessor directives before a precompiled header; you cannot
37895include a precompiled header from inside another header.
37896
37897@item
37898The precompiled header file must be produced for the same language as
37899the current compilation. You cannot use a C precompiled header for a C++
37900compilation.
37901
37902@item
37903The precompiled header file must have been produced by the same compiler
37904binary as the current compilation is using.
37905
37906@item
37907Any macros defined before the precompiled header is included must
37908either be defined in the same way as when the precompiled header was
37909generated, or must not affect the precompiled header, which usually
37910means that they don't appear in the precompiled header at all.
37911
37912The @option{-D} option is one way to define a macro before a
37913precompiled header is included; using a @code{#define} can also do it.
37914There are also some options that define macros implicitly, like
37915@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
37916defined this way.
37917
37918@item If debugging information is output when using the precompiled
37919header, using @option{-g} or similar, the same kind of debugging information
37920must have been output when building the precompiled header. However,
37921a precompiled header built using @option{-g} can be used in a compilation
37922when no debugging information is being output.
37923
37924@item The same @option{-m} options must generally be used when building
37925and using the precompiled header. @xref{Submodel Options},
37926for any cases where this rule is relaxed.
37927
37928@item Each of the following options must be the same when building and using
37929the precompiled header:
37930
37931@gccoptlist{-fexceptions}
37932
37933@item
37934Some other command-line options starting with @option{-f},
37935@option{-p}, or @option{-O} must be defined in the same way as when
37936the precompiled header was generated. At present, it's not clear
37937which options are safe to change and which are not; the safest choice
37938is to use exactly the same options when generating and using the
37939precompiled header. The following are known to be safe:
37940
43b72ede
AA
37941@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
37942-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
37943-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
37944-pedantic-errors}
37945
37946@item Address space layout randomization (ASLR) can lead to not binary identical
37947PCH files. If you rely on stable PCH file contents disable ASLR when generating
37948PCH files.
37949
37950@end itemize
37951
37952For all of these except the last, the compiler automatically
37953ignores the precompiled header if the conditions aren't met. If you
37954find an option combination that doesn't work and doesn't cause the
37955precompiled header to be ignored, please consider filing a bug report,
37956see @ref{Bugs}.
37957
37958If you do use differing options when generating and using the
37959precompiled header, the actual behavior is a mixture of the
37960behavior for the options. For instance, if you use @option{-g} to
37961generate the precompiled header but not when using it, you may or may
37962not get debugging information for routines in the precompiled header.
37963
37964@node C++ Modules
37965@section C++ Modules
37966@cindex speed of compilation
37967
37968Modules are a C++20 language feature. As the name suggests, they
424f8a01 37969provide a modular compilation system, intending to provide both
d77de738
ML
37970faster builds and better library isolation. The ``Merging Modules''
37971paper @uref{https://wg21.link/p1103}, provides the easiest to read set
37972of changes to the standard, although it does not capture later
37973changes.
37974
37975@emph{G++'s modules support is not complete.} Other than bugs, the
37976known missing pieces are:
37977
37978@table @emph
37979
37980@item Private Module Fragment
37981The Private Module Fragment is recognized, but an error is emitted.
37982
37983@item Partition definition visibility rules
37984Entities may be defined in implementation partitions, and those
37985definitions are not available outside of the module. This is not
37986implemented, and the definitions are available to extra-module use.
37987
37988@item Textual merging of reachable GM entities
37989Entities may be multiply defined across different header-units.
37990These must be de-duplicated, and this is implemented across imports,
37991or when an import redefines a textually-defined entity. However the
37992reverse is not implemented---textually redefining an entity that has
37993been defined in an imported header-unit. A redefinition error is
37994emitted.
37995
37996@item Translation-Unit local referencing rules
37997Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
37998(@uref{https://wg21.link/p2003}) add limitations on which entities an
37999exported region may reference (for instance, the entities an exported
38000template definition may reference). These are not fully implemented.
38001
38002@item Standard Library Header Units
38003The Standard Library is not provided as importable header units. If
38004you want to import such units, you must explicitly build them first.
38005If you do not do this with care, you may have multiple declarations,
38006which the module machinery must merge---compiler resource usage can be
38007affected by how you partition header files into header units.
38008
38009@end table
38010
38011Modular compilation is @emph{not} enabled with just the
38012@option{-std=c++20} option. You must explicitly enable it with the
38013@option{-fmodules-ts} option. It is independent of the language
38014version selected, although in pre-C++20 versions, it is of course an
38015extension.
38016
ff41abdc
JM
38017No new source file suffixes are required. A few suffixes preferred
38018for module interface units by other compilers (e.g. @samp{.ixx},
38019@samp{.cppm}) are supported, but files with these suffixes are treated
38020the same as any other C++ source file.
d77de738
ML
38021
38022Compiling a module interface unit produces an additional output (to
38023the assembly or object file), called a Compiled Module Interface
38024(CMI). This encodes the exported declarations of the module.
38025Importing a module reads in the CMI. The import graph is a Directed
38026Acyclic Graph (DAG). You must build imports before the importer.
38027
38028Header files may themselves be compiled to header units, which are a
38029transitional ability aiming at faster compilation. The
38030@option{-fmodule-header} option is used to enable this, and implies
d9c3c3c8 38031the @option{-fmodules} option. These CMIs are named by the fully
d77de738
ML
38032resolved underlying header file, and thus may be a complete pathname
38033containing subdirectories. If the header file is found at an absolute
38034pathname, the CMI location is still relative to a CMI root directory.
38035
38036As header files often have no suffix, you commonly have to specify a
38037@option{-x} option to tell the compiler the source is a header file.
38038You may use @option{-x c++-header}, @option{-x c++-user-header} or
38039@option{-x c++-system-header}. When used in conjunction with
d9c3c3c8 38040@option{-fmodules}, these all imply an appropriate
d77de738
ML
38041@option{-fmodule-header} option. The latter two variants use the
38042user or system include path to search for the file specified. This
38043allows you to, for instance, compile standard library header files as
38044header units, without needing to know exactly where they are
38045installed. Specifying the language as one of these variants also
38046inhibits output of the object file, as header files have no associated
38047object file.
38048
dbfbd3aa
JM
38049Alternately, or for a module interface unit in an installed location,
38050you can use @option{-fsearch-include-path} to specify that the main
38051source file should be found on the include path rather than the
38052current directory.
38053
a29f481b
JM
38054Header units can be used in much the same way as precompiled headers
38055(@pxref{Precompiled Headers}), but with fewer restrictions: an
38056#include that is translated to a header unit import can appear at any
38057point in the source file, and multiple header units can be used
38058together. In particular, the @option{-include} strategy works: with
38059the bits/stdc++.h header used for libstdc++ precompiled headers you
38060can
38061
38062@smallexample
d9c3c3c8
JM
38063g++ -fmodules -x c++-system-header -c bits/stdc++.h
38064g++ -fmodules -include bits/stdc++.h mycode.C
a29f481b
JM
38065@end smallexample
38066
38067and any standard library #includes in mycode.C will be skipped,
38068because the import brought in the whole library. This can be a simple
38069way to use modules to speed up compilation without any code changes.
38070
d77de738
ML
38071The @option{-fmodule-only} option disables generation of the
38072associated object file for compiling a module interface. Only the CMI
38073is generated. This option is implied when using the
38074@option{-fmodule-header} option.
38075
38076The @option{-flang-info-include-translate} and
38077@option{-flang-info-include-translate-not} options notes whether
38078include translation occurs or not. With no argument, the first will
38079note all include translation. The second will note all
38080non-translations of include files not known to intentionally be
38081textual. With an argument, queries about include translation of a
38082header files with that particular trailing pathname are noted. You
38083may repeat this form to cover several different header files. This
38084option may be helpful in determining whether include translation is
38085happening---if it is working correctly, it behaves as if it isn't
38086there at all.
38087
38088The @option{-flang-info-module-cmi} option can be used to determine
38089where the compiler is reading a CMI from. Without the option, the
38090compiler is silent when such a read is successful. This option has an
38091optional argument, which will restrict the notification to just the
38092set of named modules or header units specified.
38093
38094The @option{-Winvalid-imported-macros} option causes all imported macros
38095to be resolved at the end of compilation. Without this, imported
38096macros are only resolved when expanded or (re)defined. This option
38097detects conflicting import definitions for all macros.
38098
38099For details of the @option{-fmodule-mapper} family of options,
38100@pxref{C++ Module Mapper}.
38101
38102@menu
38103* C++ Module Mapper:: Module Mapper
38104* C++ Module Preprocessing:: Module Preprocessing
38105* C++ Compiled Module Interface:: Compiled Module Interface
38106@end menu
38107
38108@node C++ Module Mapper
38109@subsection Module Mapper
38110@cindex C++ Module Mapper
38111
38112A module mapper provides a server or file that the compiler queries to
38113determine the mapping between module names and CMI files. It is also
38114used to build CMIs on demand. @emph{Mapper functionality is in its
38115infancy and is intended for experimentation with build system
38116interactions.}
38117
38118You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
38119option or @env{CXX_MODULE_MAPPER} environment variable. The value may
38120have one of the following forms:
38121
38122@table @gcctabopt
38123
38124@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
38125An optional hostname and a numeric port number to connect to. If the
38126hostname is omitted, the loopback address is used. If the hostname
38127corresponds to multiple IPV6 addresses, these are tried in turn, until
38128one is successful. If your host lacks IPv6, this form is
38129non-functional. If you must use IPv4 use
38130@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
38131
38132@item =@var{socket}@r{[}?@var{ident}@r{]}
38133A local domain socket. If your host lacks local domain sockets, this
38134form is non-functional.
38135
38136@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
38137A program to spawn, and communicate with on its stdin/stdout streams.
38138Your @var{PATH} environment variable is searched for the program.
38139Arguments are separated by space characters, (it is not possible for
38140one of the arguments delivered to the program to contain a space). An
38141exception is if @var{program} begins with @@. In that case
38142@var{program} (sans @@) is looked for in the compiler's internal
38143binary directory. Thus the sample mapper-server can be specified
38144with @code{@@g++-mapper-server}.
38145
38146@item <>@r{[}?@var{ident}@r{]}
38147@item <>@var{inout}@r{[}?@var{ident}@r{]}
38148@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
38149Named pipes or file descriptors to communicate over. The first form,
38150@option{<>}, communicates over stdin and stdout. The other forms
38151allow you to specify a file descriptor or name a pipe. A numeric value
38152is interpreted as a file descriptor, otherwise named pipe is opened.
38153The second form specifies a bidirectional pipe and the last form
38154allows specifying two independent pipes. Using file descriptors
38155directly in this manner is fragile in general, as it can require the
38156cooperation of intermediate processes. In particular using stdin &
38157stdout is fraught with danger as other compiler options might also
38158cause the compiler to read stdin or write stdout, and it can have
38159unfortunate interactions with signal delivery from the terminal.
38160
38161@item @var{file}@r{[}?@var{ident}@r{]}
38162A mapping file consisting of space-separated module-name, filename
38163pairs, one per line. Only the mappings for the direct imports and any
38164module export name need be provided. If other mappings are provided,
38165they override those stored in any imported CMI files. A repository
38166root may be specified in the mapping file by using @samp{$root} as the
38167module name in the first active line. Use of this option will disable
38168any default module->CMI name mapping.
38169
38170@end table
38171
38172As shown, an optional @var{ident} may suffix the first word of the
38173option, indicated by a @samp{?} prefix. The value is used in the
38174initial handshake with the module server, or to specify a prefix on
38175mapping file lines. In the server case, the main source file name is
38176used if no @var{ident} is specified. In the file case, all non-blank
38177lines are significant, unless a value is specified, in which case only
38178lines beginning with @var{ident} are significant. The @var{ident}
38179must be separated by whitespace from the module name. Be aware that
38180@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
38181significant to the shell, and therefore may need quoting.
38182
38183The mapper is connected to or loaded lazily, when the first module
38184mapping is required. The networking protocols are only supported on
38185hosts that provide networking. If no mapper is specified a default is
38186provided.
38187
38188A project-specific mapper is expected to be provided by the build
38189system that invokes the compiler. It is not expected that a
38190general-purpose server is provided for all compilations. As such, the
38191server will know the build configuration, the compiler it invoked, and
38192the environment (such as working directory) in which that is
38193operating. As it may parallelize builds, several compilations may
38194connect to the same socket.
38195
38196The default mapper generates CMI files in a @samp{gcm.cache}
38197directory. CMI files have a @samp{.gcm} suffix. The module unit name
38198is used directly to provide the basename. Header units construct a
38199relative path using the underlying header file name. If the path is
38200already relative, a @samp{,} directory is prepended. Internal
38201@samp{..} components are translated to @samp{,,}. No attempt is made
38202to canonicalize these filenames beyond that done by the preprocessor's
38203include search algorithm, as in general it is ambiguous when symbolic
38204links are present.
38205
38206The mapper protocol was published as ``A Module Mapper''
38207@uref{https://wg21.link/p1184}. The implementation is provided by
38208@command{libcody}, @uref{https://github.com/urnathan/libcody},
38209which specifies the canonical protocol definition. A proof of concept
38210server implementation embedded in @command{make} was described in
38211''Make Me A Module'', @uref{https://wg21.link/p1602}.
38212
38213@node C++ Module Preprocessing
38214@subsection Module Preprocessing
38215@cindex C++ Module Preprocessing
38216
38217Modules affect preprocessing because of header units and include
38218translation. Some uses of the preprocessor as a separate step either
38219do not produce a correct output, or require CMIs to be available.
38220
38221Header units import macros. These macros can affect later conditional
38222inclusion, which therefore can cascade to differing import sets. When
38223preprocessing, it is necessary to load the CMI. If a header unit is
38224unavailable, the preprocessor issues a warning and continue (when
38225not just preprocessing, an error is emitted). Detecting such imports
38226requires preprocessor tokenization of the input stream to phase 4
38227(macro expansion).
38228
38229Include translation converts @code{#include}, @code{#include_next} and
38230@code{#import} directives to internal @code{import} declarations.
38231Whether a particular directive is translated is controlled by the
38232module mapper. Header unit names are canonicalized during
38233preprocessing.
38234
c877a27f
JM
38235Dependency information can be emitted for module import, extending the
38236functionality of the various @option{-M} options. Detection of import
38237declarations requires phase 4 handling of preprocessor directives, but
38238does not require macro expansion, so it is not necessary to use
38239@option{-MD}. See also @option{-fdeps-*} for an alternate format for
38240module dependency information.
d77de738
ML
38241
38242The @option{-save-temps} option uses @option{-fdirectives-only} for
38243preprocessing, and preserve the macro definitions in the preprocessed
38244output. Usually you also want to use this option when explicitly
38245preprocessing a header-unit, or consuming such preprocessed output:
38246
38247@smallexample
d9c3c3c8
JM
38248g++ -fmodules -E -fdirectives-only my-header.hh -o my-header.ii
38249g++ -x c++-header -fmodules -fpreprocessed -fdirectives-only my-header.ii
d77de738
ML
38250@end smallexample
38251
38252@node C++ Compiled Module Interface
38253@subsection Compiled Module Interface
38254@cindex C++ Compiled Module Interface
38255
38256CMIs are an additional artifact when compiling named module
38257interfaces, partitions or header units. These are read when
38258importing. CMI contents are implementation-specific, and in GCC's
38259case tied to the compiler version. Consider them a rebuildable cache
38260artifact, not a distributable object.
38261
38262When creating an output CMI, any missing directory components are
38263created in a manner that is safe for concurrent builds creating
38264multiple, different, CMIs within a common subdirectory tree.
38265
38266CMI contents are written to a temporary file, which is then atomically
38267renamed. Observers either see old contents (if there is an
38268existing file), or complete new contents. They do not observe the
38269CMI during its creation. This is unlike object file writing, which
38270may be observed by an external process.
38271
38272CMIs are read in lazily, if the host OS provides @code{mmap}
38273functionality. Generally blocks are read when name lookup or template
38274instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
38275option may be used.
38276
38277The @option{--param lazy-modules=@var{n}} parameter controls the limit
38278on the number of concurrently open module files during lazy loading.
38279Should more modules be imported, an LRU algorithm is used to determine
38280which files to close---until that file is needed again. This limit
38281may be exceeded with deep module dependency hierarchies. With large
38282code bases there may be more imports than the process limit of file
38283descriptors. By default, the limit is a few less than the per-process
38284file descriptor hard limit, if that is determinable.@footnote{Where
38285applicable the soft limit is incremented as needed towards the hard limit.}
38286
38287GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
38288You may use @command{readelf} to inspect them, although section
38289contents are largely undecipherable. There is a section named
38290@code{.gnu.c++.README}, which contains human-readable text. Other
38291than the first line, each line consists of @code{@var{tag}: @code{value}}
38292tuples.
38293
38294@smallexample
38295> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
38296
38297String dump of section '.gnu.c++.README':
38298 [ 0] GNU C++ primary module interface
38299 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
38300 [ 6f] version: 2020/11/16-04:54
38301 [ 89] module: foo
38302 [ 95] source: c_b.ii
38303 [ a4] dialect: C++20/coroutines
38304 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
38305 [ ee] repository: gcm.cache
38306 [ 104] buildtime: 2020/11/16 15:03:21 UTC
38307 [ 127] localtime: 2020/11/16 07:03:21 PST
38308 [ 14a] export: foo:part1 foo-part1.gcm
38309@end smallexample
38310
38311Amongst other things, this lists the source that was built, C++
38312dialect used and imports of the module.@footnote{The precise contents
38313of this output may change.} The timestamp is the same value as that
38314provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
38315explicitly specified with the environment variable
38316@code{SOURCE_DATE_EPOCH}. For further details
38317@pxref{Environment Variables}.
38318
38319A set of related CMIs may be copied, provided the relative pathnames
38320are preserved.
38321
38322The @code{.gnu.c++.README} contents do not affect CMI integrity, and
38323it may be removed or altered. The section numbering of the sections
38324whose names do not begin with @code{.gnu.c++.}, or are not the string
38325section is significant and must not be altered.