]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
LoongArch:Implement vec_widen standard names.
[thirdparty/gcc.git] / gcc / doc / invoke.texi
CommitLineData
83ffe9cd 1@c Copyright (C) 1988-2023 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
74d5206f 11Copyright @copyright{} 1988-2023 Free Software Foundation, Inc.
d77de738
ML
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``GNU General Public License'' and ``Funding
17Free Software'', the Front-Cover texts being (a) (see below), and with
18the Back-Cover Texts being (b) (see below). A copy of the license is
19included in the gfdl(7) man page.
20
21(a) The FSF's Front-Cover Text is:
22
23 A GNU Manual
24
25(b) The FSF's Back-Cover Text is:
26
27 You have freedom to copy and modify this GNU Manual, like GNU
28 software. Copies published by the Free Software Foundation raise
29 funds for GNU development.
30@c man end
31@c Set file name and title for the man page.
32@setfilename gcc
33@settitle GNU project C and C++ compiler
34@c man begin SYNOPSIS
35gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
36 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
37 [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}]
38 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
39 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
40 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
41 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
42
43Only the most useful options are listed here; see below for the
44remainder. @command{g++} accepts mostly the same options as @command{gcc}.
45@c man end
46@c man begin SEEALSO
47gpl(7), gfdl(7), fsf-funding(7),
48cpp(1), gcov(1), as(1), ld(1), gdb(1)
49and the Info entries for @file{gcc}, @file{cpp}, @file{as},
50@file{ld}, @file{binutils} and @file{gdb}.
51@c man end
52@c man begin BUGS
53For instructions on reporting bugs, see
54@w{@value{BUGURL}}.
55@c man end
56@c man begin AUTHOR
57See the Info entry for @command{gcc}, or
58@w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59for contributors to GCC@.
60@c man end
61@end ignore
62
63@node Invoking GCC
64@chapter GCC Command Options
65@cindex GCC command options
66@cindex command options
67@cindex options, GCC command
68
69@c man begin DESCRIPTION
70When you invoke GCC, it normally does preprocessing, compilation,
71assembly and linking. The ``overall options'' allow you to stop this
72process at an intermediate stage. For example, the @option{-c} option
73says not to run the linker. Then the output consists of object files
74output by the assembler.
75@xref{Overall Options,,Options Controlling the Kind of Output}.
76
77Other options are passed on to one or more stages of processing. Some options
78control the preprocessor and others the compiler itself. Yet other
79options control the assembler and linker; most of these are not
80documented here, since you rarely need to use any of them.
81
82@cindex C compilation options
83Most of the command-line options that you can use with GCC are useful
84for C programs; when an option is only useful with another language
85(usually C++), the explanation says so explicitly. If the description
86for a particular option does not mention a source language, you can use
87that option with all supported languages.
88
89@cindex cross compiling
90@cindex specifying machine version
91@cindex specifying compiler version and target machine
92@cindex compiler version, specifying
93@cindex target machine, specifying
94The usual way to run GCC is to run the executable called @command{gcc}, or
95@command{@var{machine}-gcc} when cross-compiling, or
96@command{@var{machine}-gcc-@var{version}} to run a specific version of GCC.
97When you compile C++ programs, you should invoke GCC as @command{g++}
98instead. @xref{Invoking G++,,Compiling C++ Programs},
99for information about the differences in behavior between @command{gcc}
100and @command{g++} when compiling C++ programs.
101
102@cindex grouping options
103@cindex options, grouping
104The @command{gcc} program accepts options and file names as operands. Many
105options have multi-letter names; therefore multiple single-letter options
106may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d
107-v}}.
108
109@cindex order of options
110@cindex options, order
111You can mix options and other arguments. For the most part, the order
112you use doesn't matter. Order does matter when you use several
113options of the same kind; for example, if you specify @option{-L} more
114than once, the directories are searched in the order specified. Also,
115the placement of the @option{-l} option is significant.
116
117Many options have long names starting with @samp{-f} or with
118@samp{-W}---for example,
119@option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
120these have both positive and negative forms; the negative form of
121@option{-ffoo} is @option{-fno-foo}. This manual documents
122only one of these two forms, whichever one is not the default.
123
124Some options take one or more arguments typically separated either
125by a space or by the equals sign (@samp{=}) from the option name.
126Unless documented otherwise, an argument can be either numeric or
127a string. Numeric arguments must typically be small unsigned decimal
128or hexadecimal integers. Hexadecimal arguments must begin with
129the @samp{0x} prefix. Arguments to options that specify a size
130threshold of some sort may be arbitrarily large decimal or hexadecimal
131integers followed by a byte size suffix designating a multiple of bytes
132such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
133@code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and
134@code{GiB} for gigabyte and gigibyte, and so on. Such arguments are
135designated by @var{byte-size} in the following text. Refer to the NIST,
136IEC, and other relevant national and international standards for the full
137listing and explanation of the binary and decimal byte size prefixes.
138
139@c man end
140
141@xref{Option Index}, for an index to GCC's options.
142
143@menu
144* Option Summary:: Brief list of all options, without explanations.
145* Overall Options:: Controlling the kind of output:
146 an executable, object files, assembler files,
147 or preprocessed source.
148* Invoking G++:: Compiling C++ programs.
149* C Dialect Options:: Controlling the variant of C language compiled.
150* C++ Dialect Options:: Variations on C++.
151* Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C
152 and Objective-C++.
153* Diagnostic Message Formatting Options:: Controlling how diagnostics should
154 be formatted.
155* Warning Options:: How picky should the compiler be?
156* Static Analyzer Options:: More expensive warnings.
157* Debugging Options:: Producing debuggable code.
158* Optimize Options:: How much optimization?
159* Instrumentation Options:: Enabling profiling and extra run-time error checking.
160* Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162* Assembler Options:: Passing options to the assembler.
163* Link Options:: Specifying libraries and so on.
164* Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166* Code Gen Options:: Specifying conventions for function calls, data layout
167 and register usage.
168* Developer Options:: Printing GCC configuration info, statistics, and
169 debugging dumps.
170* Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172* Spec Files:: How to pass switches to sub-processes.
173* Environment Variables:: Env vars that affect GCC.
174* Precompiled Headers:: Compiling a header once, and using it many times.
175* C++ Modules:: Experimental C++20 module system.
176@end menu
177
178@c man begin OPTIONS
179
180@node Option Summary
181@section Option Summary
182
183Here is a summary of all the options, grouped by type. Explanations are
184in the following sections.
185
186@table @emph
187@item Overall Options
188@xref{Overall Options,,Options Controlling the Kind of Output}.
43b72ede
AA
189@gccoptlist{-c -S -E -o @var{file}
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf}
191-dumpdir @var{dumppfx} -x @var{language}
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version
193-pass-exit-codes -pipe -specs=@var{file} -wrapper
194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map
195-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}
d77de738
ML
196-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
197
198@item C Language Options
199@xref{C Dialect Options,,Options Controlling C Dialect}.
43b72ede
AA
200@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename}
201-fno-asm
202-fno-builtin -fno-builtin-@var{function} -fcond-mismatch
203-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted
204-flax-vector-conversions -fms-extensions
205-foffload=@var{arg} -foffload-options=@var{arg}
206-fopenacc -fopenacc-dim=@var{geom}
207-fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}
208-fpermitted-flt-eval-methods=@var{standard}
209-fplan9-extensions -fsigned-bitfields -funsigned-bitfields
210-fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}]
d77de738
ML
211-fsso-struct=@var{endianness}}
212
213@item C++ Language Options
214@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
43b72ede
AA
215@gccoptlist{-fabi-version=@var{n} -fno-access-control
216-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new
217-fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n}
218-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n}
219-fno-elide-constructors
220-fno-enforce-eh-specs
221-fno-gnu-keywords
222-fno-implicit-templates
223-fno-implicit-inline-templates
224-fno-implement-inlines
225-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts
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
43b72ede
AA
235-fno-pretty-templates
236-fno-rtti -fsized-deallocation
237-ftemplate-backtrace-limit=@var{n}
238-ftemplate-depth=@var{n}
239-fno-threadsafe-statics -fuse-cxa-atexit
240-fno-weak -nostdinc++
241-fvisibility-inlines-hidden
242-fvisibility-ms-compat
243-fext-numeric-literals
244-flang-info-include-translate@r{[}=@var{header}@r{]}
245-flang-info-include-translate-not
246-flang-info-module-cmi@r{[}=@var{module}@r{]}
247-stdlib=@var{libstdc++,libc++}
248-Wabi-tag -Wcatch-value -Wcatch-value=@var{n}
249-Wno-class-conversion -Wclass-memaccess
250-Wcomma-subscript -Wconditionally-supported
251-Wno-conversion-null -Wctad-maybe-unsupported
252-Wctor-dtor-privacy -Wdangling-reference
253-Wno-delete-incomplete
254-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare
255-Wdeprecated-copy -Wdeprecated-copy-dtor
256-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
b106f11d
AC
257-Weffc++ -Wno-elaborated-enum-base
258-Wno-exceptions -Wextra-semi -Wno-inaccessible-base
43b72ede
AA
259-Wno-inherited-variadic-ctor -Wno-init-list-lifetime
260-Winvalid-constexpr -Winvalid-imported-macros
261-Wno-invalid-offsetof -Wno-literal-suffix
262-Wmismatched-new-delete -Wmismatched-tags
263-Wmultiple-inheritance -Wnamespaces -Wnarrowing
264-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
265-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
266-Wrange-loop-construct -Wredundant-move -Wredundant-tags
267-Wreorder -Wregister
268-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
269-Wno-non-template-friend -Wold-style-cast
270-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
271-Wsized-deallocation -Wsuggest-final-methods
272-Wsuggest-final-types -Wsuggest-override
273-Wno-terminate -Wuseless-cast -Wno-vexing-parse
274-Wvirtual-inheritance
d77de738
ML
275-Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
276
277@item Objective-C and Objective-C++ Language Options
278@xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
279Objective-C and Objective-C++ Dialects}.
43b72ede
AA
280@gccoptlist{-fconstant-string-class=@var{class-name}
281-fgnu-runtime -fnext-runtime
282-fno-nil-receivers
283-fobjc-abi-version=@var{n}
284-fobjc-call-cxx-cdtors
285-fobjc-direct-dispatch
286-fobjc-exceptions
287-fobjc-gc
288-fobjc-nilcheck
289-fobjc-std=objc1
290-fno-local-ivars
291-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
292-freplace-objc-classes
293-fzero-link
294-gen-decls
295-Wassign-intercept -Wno-property-assign-default
296-Wno-protocol -Wobjc-root-class -Wselector
297-Wstrict-selector-match
d77de738
ML
298-Wundeclared-selector}
299
300@item Diagnostic Message Formatting Options
301@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
43b72ede
AA
302@gccoptlist{-fmessage-length=@var{n}
303-fdiagnostics-plain-output
304-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
305-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
306-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
307-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]}
308-fno-diagnostics-show-option -fno-diagnostics-show-caret
309-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
310-fno-diagnostics-show-cwe
311-fno-diagnostics-show-rule
312-fdiagnostics-minimum-margin-width=@var{width}
313-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
314-fdiagnostics-show-template-tree -fno-elide-type
315-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
316-fdiagnostics-show-path-depths
317-fno-show-column
318-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
319-fdiagnostics-column-origin=@var{origin}
4f01ae37
DM
320-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}
321-fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}}
d77de738
ML
322
323@item Warning Options
324@xref{Warning Options,,Options to Request or Suppress Warnings}.
43b72ede 325@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
ef10cb86 326-pedantic-errors -fpermissive
43b72ede
AA
327-w -Wextra -Wall -Wabi=@var{n}
328-Waddress -Wno-address-of-packed-member -Waggregate-return
329-Walloc-size-larger-than=@var{byte-size} -Walloc-zero
330-Walloca -Walloca-larger-than=@var{byte-size}
331-Wno-aggressive-loop-optimizations
332-Warith-conversion
333-Warray-bounds -Warray-bounds=@var{n} -Warray-compare
334-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
335-Wno-attribute-warning
336-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
337-Wbool-compare -Wbool-operation
338-Wno-builtin-declaration-mismatch
339-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
340-Wc11-c2x-compat
341-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
342-Wc++20-compat
343-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
344-Wno-c++20-extensions -Wno-c++23-extensions
345-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
346-Wchar-subscripts
347-Wclobbered -Wcomment
e1f45bea 348-Wcompare-distinct-pointer-types
43b72ede
AA
349-Wno-complain-wrong-lang
350-Wconversion -Wno-coverage-mismatch -Wno-cpp
351-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
352-Wdate-time
353-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
354-Wdisabled-optimization
355-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
356-Wno-div-by-zero -Wdouble-promotion
357-Wduplicated-branches -Wduplicated-cond
358-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
359-Wenum-int-mismatch
360-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
44e3f39a 361-Wflex-array-member-not-at-end
43b72ede
AA
362-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
363-Wno-format-contains-nul -Wno-format-extra-args
364-Wformat-nonliteral -Wformat-overflow=@var{n}
365-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
366-Wformat-y2k -Wframe-address
367-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
368-Wno-if-not-aligned -Wno-ignored-attributes
369-Wignored-qualifiers -Wno-incompatible-pointer-types
370-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
371-Wno-implicit-function-declaration -Wno-implicit-int
372-Winfinite-recursion
373-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
374-Wno-int-to-pointer-cast -Wno-invalid-memory-model
375-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
376-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op
377-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
378-Wmemset-elt-size -Wmemset-transposed-args
379-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
380-Wmissing-field-initializers -Wmissing-format-attribute
381-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile
382-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
383-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
384-Wnull-dereference -Wno-odr
385-Wopenacc-parallelism
386-Wopenmp-simd
387-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
388-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
389-Wparentheses -Wno-pedantic-ms-format
390-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
391-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
392-Wrestrict -Wno-return-local-addr -Wreturn-type
393-Wno-scalar-storage-order -Wsequence-point
394-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
395-Wno-shadow-ivar
396-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
397-Wno-shift-overflow -Wshift-overflow=@var{n}
398-Wsign-compare -Wsign-conversion
399-Wno-sizeof-array-argument
400-Wsizeof-array-div
401-Wsizeof-pointer-div -Wsizeof-pointer-memaccess
402-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
403-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
404-Wstring-compare
405-Wno-stringop-overflow -Wno-stringop-overread
406-Wno-stringop-truncation -Wstrict-flex-arrays
407-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]}
408-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
409-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
410-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
411-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef
412-Wuninitialized -Wunknown-pragmas
413-Wunsuffixed-float-constants -Wunused
414-Wunused-but-set-parameter -Wunused-but-set-variable
415-Wunused-const-variable -Wunused-const-variable=@var{n}
416-Wunused-function -Wunused-label -Wunused-local-typedefs
417-Wunused-macros
418-Wunused-parameter -Wno-unused-result
419-Wunused-value -Wunused-variable
420-Wno-varargs -Wvariadic-macros
421-Wvector-operation-performance
422-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
423-Wvolatile-register-var -Wwrite-strings
424-Wxor-used-as-pow
d77de738
ML
425-Wzero-length-bounds}
426
427@item Static Analyzer Options
428@gccoptlist{
43b72ede
AA
429-fanalyzer
430-fanalyzer-call-summaries
431-fanalyzer-checker=@var{name}
432-fno-analyzer-feasibility
433-fanalyzer-fine-grained
ce8cdf5b 434-fanalyzer-show-events-in-system-headers
43b72ede
AA
435-fno-analyzer-state-merge
436-fno-analyzer-state-purge
437-fno-analyzer-suppress-followups
438-fanalyzer-transitivity
439-fno-analyzer-undo-inlining
440-fanalyzer-verbose-edges
441-fanalyzer-verbose-state-changes
442-fanalyzer-verbosity=@var{level}
443-fdump-analyzer
444-fdump-analyzer-callgraph
445-fdump-analyzer-exploded-graph
446-fdump-analyzer-exploded-nodes
447-fdump-analyzer-exploded-nodes-2
448-fdump-analyzer-exploded-nodes-3
449-fdump-analyzer-exploded-paths
450-fdump-analyzer-feasibility
451-fdump-analyzer-json
452-fdump-analyzer-state-purge
453-fdump-analyzer-stderr
454-fdump-analyzer-supergraph
455-fdump-analyzer-untracked
456-Wno-analyzer-double-fclose
457-Wno-analyzer-double-free
458-Wno-analyzer-exposure-through-output-file
459-Wno-analyzer-exposure-through-uninit-copy
460-Wno-analyzer-fd-access-mode-mismatch
461-Wno-analyzer-fd-double-close
462-Wno-analyzer-fd-leak
463-Wno-analyzer-fd-phase-mismatch
464-Wno-analyzer-fd-type-mismatch
465-Wno-analyzer-fd-use-after-close
466-Wno-analyzer-fd-use-without-check
467-Wno-analyzer-file-leak
468-Wno-analyzer-free-of-non-heap
469-Wno-analyzer-imprecise-fp-arithmetic
470-Wno-analyzer-infinite-recursion
471-Wno-analyzer-jump-through-null
472-Wno-analyzer-malloc-leak
473-Wno-analyzer-mismatching-deallocation
474-Wno-analyzer-null-argument
475-Wno-analyzer-null-dereference
476-Wno-analyzer-out-of-bounds
034d99e8 477-Wno-analyzer-overlapping-buffers
43b72ede
AA
478-Wno-analyzer-possible-null-argument
479-Wno-analyzer-possible-null-dereference
480-Wno-analyzer-putenv-of-auto-var
481-Wno-analyzer-shift-count-negative
482-Wno-analyzer-shift-count-overflow
483-Wno-analyzer-stale-setjmp-buffer
484-Wno-analyzer-tainted-allocation-size
485-Wno-analyzer-tainted-assertion
486-Wno-analyzer-tainted-array-index
487-Wno-analyzer-tainted-divisor
488-Wno-analyzer-tainted-offset
489-Wno-analyzer-tainted-size
490-Wanalyzer-too-complex
491-Wno-analyzer-unsafe-call-within-signal-handler
492-Wno-analyzer-use-after-free
493-Wno-analyzer-use-of-pointer-in-stale-stack-frame
494-Wno-analyzer-use-of-uninitialized-value
495-Wno-analyzer-va-arg-type-mismatch
496-Wno-analyzer-va-list-exhausted
497-Wno-analyzer-va-list-leak
498-Wno-analyzer-va-list-use-after-va-end
499-Wno-analyzer-write-to-const
500-Wno-analyzer-write-to-string-literal
d77de738
ML
501}
502
503@item C and Objective-C-only Warning Options
43b72ede 504@gccoptlist{-Wbad-function-cast -Wmissing-declarations
ffc74822
HM
505-Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations
506-Wnested-externs -Wold-style-declaration -Wold-style-definition
43b72ede 507-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
d77de738
ML
508-Wdeclaration-after-statement -Wpointer-sign}
509
510@item Debugging Options
511@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
512@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
513-gbtf -gctf -gctf@var{level}
514-ggdb -grecord-gcc-switches -gno-record-gcc-switches
515-gstrict-dwarf -gno-strict-dwarf
516-gas-loc-support -gno-as-loc-support
517-gas-locview-support -gno-as-locview-support
3eeb4801 518-gcodeview
43b72ede
AA
519-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
520-gstatement-frontiers -gno-statement-frontiers
521-gvariable-location-views -gno-variable-location-views
522-ginternal-reset-location-views -gno-internal-reset-location-views
523-ginline-points -gno-inline-points
524-gvms -gz@r{[}=@var{type}@r{]}
525-gsplit-dwarf -gdescribe-dies -gno-describe-dies
526-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
527-fno-eliminate-unused-debug-types
528-femit-struct-debug-baseonly -femit-struct-debug-reduced
529-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
530-fno-eliminate-unused-debug-symbols -femit-class-debug-always
531-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
532-fvar-tracking -fvar-tracking-assignments}
533
534@item Optimization Options
535@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
536@gccoptlist{-faggressive-loop-optimizations
537-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
538-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
539-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
540-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
541-fno-allocation-dce -fallow-store-data-races
542-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
543-fauto-inc-dec -fbranch-probabilities
544-fcaller-saves
545-fcombine-stack-adjustments -fconserve-stack
04c9cf5c 546-ffold-mem-offsets
43b72ede
AA
547-fcompare-elim -fcprop-registers -fcrossjumping
548-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
549-fcx-limited-range
550-fdata-sections -fdce -fdelayed-branch
551-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
552-fdevirtualize-at-ltrans -fdse
553-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
554-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
555-ffinite-loops
556-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
557-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
558-fgcse-sm -fhoist-adjacent-loads -fif-conversion
559-fif-conversion2 -findirect-inlining
560-finline-functions -finline-functions-called-once -finline-limit=@var{n}
561-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
562-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
563-fipa-reference -fipa-reference-addressable
564-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
565-flive-patching=@var{level}
566-fira-region=@var{region} -fira-hoist-pressure
567-fira-loop-pressure -fno-ira-share-save-slots
568-fno-ira-share-spill-slots
569-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
570-fivopts -fkeep-inline-functions -fkeep-static-functions
571-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
572-floop-block -floop-interchange -floop-strip-mine
573-floop-unroll-and-jam -floop-nest-optimize
574-floop-parallelize-all -flra-remat -flto -flto-compression-level
575-flto-partition=@var{alg} -fmerge-all-constants
576-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
577-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
578-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
579-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
580-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
581-fno-sched-spec -fno-signed-zeros
582-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
583-fomit-frame-pointer -foptimize-sibling-calls
584-fpartial-inlining -fpeel-loops -fpredictive-commoning
585-fprefetch-loop-arrays
586-fprofile-correction
587-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
588-fprofile-values -fprofile-reorder-functions
589-freciprocal-math -free -frename-registers -freorder-blocks
590-freorder-blocks-algorithm=@var{algorithm}
591-freorder-blocks-and-partition -freorder-functions
592-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
593-frounding-math -fsave-optimization-record
594-fsched2-use-superblocks -fsched-pressure
595-fsched-spec-load -fsched-spec-load-dangerous
596-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
597-fsched-group-heuristic -fsched-critical-path-heuristic
598-fsched-spec-insn-heuristic -fsched-rank-heuristic
599-fsched-last-insn-heuristic -fsched-dep-count-heuristic
600-fschedule-fusion
601-fschedule-insns -fschedule-insns2 -fsection-anchors
602-fselective-scheduling -fselective-scheduling2
603-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
604-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
605-fsignaling-nans
606-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
607-fsplit-paths
608-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
609-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
610-fthread-jumps -ftracer -ftree-bit-ccp
611-ftree-builtin-call-dce -ftree-ccp -ftree-ch
612-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
613-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
614-ftree-loop-if-convert -ftree-loop-im
615-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
616-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
617-ftree-loop-vectorize
618-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
619-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
620-ftree-switch-conversion -ftree-tail-merge
621-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
622-funconstrained-commons -funit-at-a-time -funroll-all-loops
623-funroll-loops -funsafe-math-optimizations -funswitch-loops
624-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
625-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
626--param @var{name}=@var{value}
627-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
628
629@item Program Instrumentation Options
630@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede
AA
631@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
632-fprofile-abs-path
633-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
634-fprofile-info-section -fprofile-info-section=@var{name}
635-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
636-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
637-fprofile-exclude-files=@var{regex}
638-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
639-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
640-fsanitize-trap -fsanitize-trap=@var{style}
641-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
642-fsanitize-undefined-trap-on-error -fbounds-check
643-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
644-fharden-compares -fharden-conditional-branches
645-fstack-protector -fstack-protector-all -fstack-protector-strong
646-fstack-protector-explicit -fstack-check
647-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
648-fno-stack-limit -fsplit-stack
649-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
650-fvtv-counts -fvtv-debug
651-finstrument-functions -finstrument-functions-once
652-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
653-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
654-fprofile-prefix-map=@var{old}=@var{new}}
d77de738
ML
655
656@item Preprocessor Options
657@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
658@gccoptlist{-A@var{question}=@var{answer}
659-A-@var{question}@r{[}=@var{answer}@r{]}
660-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
661-dD -dI -dM -dN -dU
662-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
663-fexec-charset=@var{charset} -fextended-identifiers
664-finput-charset=@var{charset} -flarge-source-files
665-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
666-fno-canonical-system-headers -fpch-deps -fpch-preprocess
667-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
668-fwide-exec-charset=@var{charset} -fworking-directory
669-H -imacros @var{file} -include @var{file}
670-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
671-no-integrated-cpp -P -pthread -remap
672-traditional -traditional-cpp -trigraphs
673-U@var{macro} -undef
d77de738
ML
674-Wp,@var{option} -Xpreprocessor @var{option}}
675
676@item Assembler Options
677@xref{Assembler Options,,Passing Options to the Assembler}.
678@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
679
680@item Linker Options
681@xref{Link Options,,Options for Linking}.
43b72ede
AA
682@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
683-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
684-e @var{entry} --entry=@var{entry}
685-pie -pthread -r -rdynamic
686-s -static -static-pie -static-libgcc -static-libstdc++
687-static-libasan -static-libtsan -static-liblsan -static-libubsan
688-shared -shared-libgcc -symbolic
689-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
690-u @var{symbol} -z @var{keyword}}
691
692@item Directory Options
693@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
694@gccoptlist{-B@var{prefix} -I@var{dir} -I-
695-idirafter @var{dir}
696-imacros @var{file} -imultilib @var{dir}
697-iplugindir=@var{dir} -iprefix @var{file}
698-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
699-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
700-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
701-nostdinc -nostdinc++ --sysroot=@var{dir}}
702
703@item Code Generation Options
704@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
705@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
706-ffixed-@var{reg} -fexceptions
707-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
708-fasynchronous-unwind-tables
709-fno-gnu-unique
710-finhibit-size-directive -fcommon -fno-ident
711-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
712-fno-jump-tables -fno-bit-tests
713-frecord-gcc-switches
714-freg-struct-return -fshort-enums -fshort-wchar
715-fverbose-asm -fpack-struct[=@var{n}]
716-fleading-underscore -ftls-model=@var{model}
717-fstack-reuse=@var{reuse_level}
718-ftrampolines -ftrapv -fwrapv
719-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
720-fstrict-volatile-bitfields -fsync-libcalls}
721
722@item Developer Options
723@xref{Developer Options,,GCC Developer Options}.
43b72ede 724@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 725-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
726-fchecking -fchecking=@var{n}
727-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
728-fdisable-ipa-@var{pass_name}
729-fdisable-rtl-@var{pass_name}
730-fdisable-rtl-@var{pass-name}=@var{range-list}
731-fdisable-tree-@var{pass_name}
732-fdisable-tree-@var{pass-name}=@var{range-list}
733-fdump-debug -fdump-earlydebug
734-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
735-fdump-final-insns@r{[}=@var{file}@r{]}
736-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
737-fdump-lang-all
738-fdump-lang-@var{switch}
739-fdump-lang-@var{switch}-@var{options}
740-fdump-lang-@var{switch}-@var{options}=@var{filename}
741-fdump-passes
742-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
743-fdump-statistics
744-fdump-tree-all
745-fdump-tree-@var{switch}
746-fdump-tree-@var{switch}-@var{options}
747-fdump-tree-@var{switch}-@var{options}=@var{filename}
748-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
749-fenable-@var{kind}-@var{pass}
750-fenable-@var{kind}-@var{pass}=@var{range-list}
751-fira-verbose=@var{n}
752-flto-report -flto-report-wpa -fmem-report-wpa
753-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
754-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
755-fmultiflags -fprofile-report
756-frandom-seed=@var{string} -fsched-verbose=@var{n}
757-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
758-fstats -fstack-usage -ftime-report -ftime-report-details
759-fvar-tracking-assignments-toggle -gtoggle
760-print-file-name=@var{library} -print-libgcc-file-name
761-print-multi-directory -print-multi-lib -print-multi-os-directory
762-print-prog-name=@var{program} -print-search-dirs -Q
763-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
764-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
765
766@item Machine-Dependent Options
767@xref{Submodel Options,,Machine-Dependent Options}.
768@c This list is ordered alphanumerically by subsection name.
769@c Try and put the significant identifier (CPU or system) first,
770@c so users have a clue at guessing where the ones they want will be.
771
772@emph{AArch64 Options}
43b72ede
AA
773@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
774-mgeneral-regs-only
775-mcmodel=tiny -mcmodel=small -mcmodel=large
776-mstrict-align -mno-strict-align
777-momit-leaf-frame-pointer
778-mtls-dialect=desc -mtls-dialect=traditional
779-mtls-size=@var{size}
780-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
781-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
782-mpc-relative-literal-loads
783-msign-return-address=@var{scope}
d77de738 784-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
43b72ede
AA
785+@var{b-key}]|@var{bti}
786-mharden-sls=@var{opts}
787-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
788-moverride=@var{string} -mverbose-cost-dump
789-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
790-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
d77de738
ML
791-moutline-atomics }
792
793@emph{Adapteva Epiphany Options}
43b72ede
AA
794@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
795-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
796-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
797-mround-nearest -mlong-calls -mshort-calls -msmall16
798-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
799-msplit-vecmove-early -m1reg-@var{reg}}
800
801@emph{AMD GCN Options}
802@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
803
804@emph{ARC Options}
43b72ede
AA
805@gccoptlist{-mbarrel-shifter -mjli-always
806-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
807-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
808-mea -mno-mpy -mmul32x16 -mmul64 -matomic
809-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
810-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
811-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
812-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
813-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
814-mvolatile-cache -mtp-regno=@var{regno}
815-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
816-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
817-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
818-mlra-priority-compact -mlra-priority-noncompact -mmillicode
819-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
820-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
821-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
822-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
823
824@emph{ARM Options}
43b72ede
AA
825@gccoptlist{-mapcs-frame -mno-apcs-frame
826-mabi=@var{name}
827-mapcs-stack-check -mno-apcs-stack-check
828-mapcs-reentrant -mno-apcs-reentrant
829-mgeneral-regs-only
830-msched-prolog -mno-sched-prolog
831-mlittle-endian -mbig-endian
832-mbe8 -mbe32
833-mfloat-abi=@var{name}
d77de738 834-mfp16-format=@var{name}
43b72ede
AA
835-mthumb-interwork -mno-thumb-interwork
836-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
837-mtune=@var{name} -mprint-tune-info
838-mstructure-size-boundary=@var{n}
839-mabort-on-noreturn
840-mlong-calls -mno-long-calls
841-msingle-pic-base -mno-single-pic-base
842-mpic-register=@var{reg}
843-mnop-fun-dllimport
844-mpoke-function-name
845-mthumb -marm -mflip-thumb
846-mtpcs-frame -mtpcs-leaf-frame
847-mcaller-super-interworking -mcallee-super-interworking
848-mtp=@var{name} -mtls-dialect=@var{dialect}
849-mword-relocations
850-mfix-cortex-m3-ldrd
851-mfix-cortex-a57-aes-1742098
852-mfix-cortex-a72-aes-1655431
853-munaligned-access
854-mneon-for-64bits
855-mslow-flash-data
856-masm-syntax-unified
857-mrestrict-it
858-mverbose-cost-dump
859-mpure-code
860-mcmse
861-mfix-cmse-cve-2021-35465
862-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
863-mfdpic
14fab5fb
AC
864-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
865[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
866
867@emph{AVR Options}
43b72ede
AA
868@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
869-mbranch-cost=@var{cost}
870-mcall-prologues -mgas-isr-prologues -mint8
871-mdouble=@var{bits} -mlong-double=@var{bits}
872-mn_flash=@var{size} -mno-interrupts
873-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
874-mfract-convert-truncate
875-mshort-calls -nodevicelib -nodevicespecs
d77de738
ML
876-Waddr-space-convert -Wmisspelled-isr}
877
878@emph{Blackfin Options}
43b72ede
AA
879@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
880-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
881-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
882-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
883-mno-id-shared-library -mshared-library-id=@var{n}
884-mleaf-id-shared-library -mno-leaf-id-shared-library
885-msep-data -mno-sep-data -mlong-calls -mno-long-calls
886-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
887-micplb}
888
889@emph{C6X Options}
43b72ede 890@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
891-msim -msdata=@var{sdata-type}}
892
893@emph{CRIS Options}
894@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
895-mtune=@var{cpu} -mmax-stack-frame=@var{n}
896-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
897-mstack-align -mdata-align -mconst-align
898-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
899-melf -maout -sim -sim2
d77de738
ML
900-mmul-bug-workaround -mno-mul-bug-workaround}
901
902@emph{C-SKY Options}
43b72ede
AA
903@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
904-mbig-endian -EB -mlittle-endian -EL
905-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
906-mfloat-abi=@var{name}
907-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
908-mdsp -medsp -mvdsp
909-mdiv -msmart -mhigh-registers -manchor
910-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
911-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
912
913@emph{Darwin Options}
43b72ede
AA
914@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
915-arch_only -bind_at_load -bundle -bundle_loader
916-client_name -compatibility_version -current_version
917-dead_strip
918-dependency-file -dylib_file -dylinker_install_name
919-dynamic -dynamiclib -exported_symbols_list
920-filelist -flat_namespace -force_cpusubtype_ALL
921-force_flat_namespace -headerpad_max_install_names
922-iframework
923-image_base -init -install_name -keep_private_externs
924-multi_module -multiply_defined -multiply_defined_unused
925-noall_load -no_dead_strip_inits_and_terms
926-nofixprebinding -nomultidefs -noprebind -noseglinkedit
927-pagezero_size -prebind -prebind_all_twolevel_modules
928-private_bundle -read_only_relocs -sectalign
929-sectobjectsymbols -whyload -seg1addr
930-sectcreate -sectobjectsymbols -sectorder
931-segaddr -segs_read_only_addr -segs_read_write_addr
932-seg_addr_table -seg_addr_table_filename -seglinkedit
933-segprot -segs_read_only_addr -segs_read_write_addr
934-single_module -static -sub_library -sub_umbrella
935-twolevel_namespace -umbrella -undefined
936-unexported_symbols_list -weak_reference_mismatches
937-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
938-mkernel -mone-byte-bool}
939
940@emph{DEC Alpha Options}
43b72ede
AA
941@gccoptlist{-mno-fp-regs -msoft-float
942-mieee -mieee-with-inexact -mieee-conformant
943-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
944-mtrap-precision=@var{mode} -mbuild-constants
945-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
946-mbwx -mmax -mfix -mcix
947-mfloat-vax -mfloat-ieee
948-mexplicit-relocs -msmall-data -mlarge-data
949-msmall-text -mlarge-text
d77de738
ML
950-mmemory-latency=@var{time}}
951
952@emph{eBPF Options}
9cbf4286 953@gccoptlist{-mbig-endian -mlittle-endian
77d0f9ec 954-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
14dab1a1 955-mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
9cbf4286 956-masm=@var{dialect}}
d77de738
ML
957
958@emph{FR30 Options}
959@gccoptlist{-msmall-model -mno-lsim}
960
961@emph{FT32 Options}
962@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
963
964@emph{FRV Options}
43b72ede
AA
965@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
966-mhard-float -msoft-float
967-malloc-cc -mfixed-cc -mdword -mno-dword
968-mdouble -mno-double
969-mmedia -mno-media -mmuladd -mno-muladd
970-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
971-mlinked-fp -mlong-calls -malign-labels
972-mlibrary-pic -macc-4 -macc-8
973-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
974-moptimize-membar -mno-optimize-membar
975-mscc -mno-scc -mcond-exec -mno-cond-exec
976-mvliw-branch -mno-vliw-branch
977-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
978-mno-nested-cond-exec -mtomcat-stats
979-mTLS -mtls
d77de738
ML
980-mcpu=@var{cpu}}
981
982@emph{GNU/Linux Options}
43b72ede 983@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
984-tno-android-cc -tno-android-ld}
985
986@emph{H8/300 Options}
987@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
988
989@emph{HPPA Options}
43b72ede
AA
990@gccoptlist{-march=@var{architecture-type}
991-matomic-libcalls -mbig-switch
992-mcaller-copies -mdisable-fpregs -mdisable-indexing
993-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
994-mfixed-range=@var{register-range}
995-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
996-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
997-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
998-mno-jump-in-delay -mno-long-load-store
999-mno-portable-runtime -mno-soft-float
1000-mno-space-regs -msoft-float -mpa-risc-1-0
1001-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1002-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
1003-munix=@var{unix-std} -nolibdld -static -threads}
1004
1005@emph{IA-64 Options}
43b72ede
AA
1006@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1007-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1008-mconstant-gp -mauto-pic -mfused-madd
1009-minline-float-divide-min-latency
1010-minline-float-divide-max-throughput
1011-mno-inline-float-divide
1012-minline-int-divide-min-latency
1013-minline-int-divide-max-throughput
1014-mno-inline-int-divide
1015-minline-sqrt-min-latency -minline-sqrt-max-throughput
1016-mno-inline-sqrt
1017-mdwarf2-asm -mearly-stop-bits
1018-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1019-mtune=@var{cpu-type} -milp32 -mlp64
1020-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1021-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1022-msched-spec-ldc -msched-spec-control-ldc
1023-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1024-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1025-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1026-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1027
1028@emph{LM32 Options}
43b72ede 1029@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1030-msign-extend-enabled -muser-enabled}
1031
1032@emph{LoongArch Options}
43b72ede 1033@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
bb4a8198
YY
1034-mfpu=@var{fpu-type} -msimd=@var{simd-type}
1035-msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
43b72ede
AA
1036-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1037-mcond-move-int -mno-cond-move-int
1038-mcond-move-float -mno-cond-move-float
1039-memcpy -mno-memcpy -mstrict-align -mno-strict-align
1040-mmax-inline-memcpy-size=@var{n}
1041-mexplicit-relocs -mno-explicit-relocs
1042-mdirect-extern-access -mno-direct-extern-access
d77de738
ML
1043-mcmodel=@var{code-model}}
1044
1045@emph{M32R/D Options}
43b72ede
AA
1046@gccoptlist{-m32r2 -m32rx -m32r
1047-mdebug
1048-malign-loops -mno-align-loops
1049-missue-rate=@var{number}
1050-mbranch-cost=@var{number}
1051-mmodel=@var{code-size-model-type}
1052-msdata=@var{sdata-type}
1053-mno-flush-func -mflush-func=@var{name}
1054-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1055-G @var{num}}
1056
1057@emph{M32C Options}
1058@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1059
1060@emph{M680x0 Options}
43b72ede
AA
1061@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1062-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1063-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1064-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1065-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1066-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1067-malign-int -mstrict-align -msep-data -mno-sep-data
1068-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1069-mxgot -mno-xgot -mlong-jump-table-offsets}
1070
1071@emph{MCore Options}
43b72ede
AA
1072@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1073-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1074-m4byte-functions -mno-4byte-functions -mcallgraph-data
1075-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1076-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1077
d77de738 1078@emph{MicroBlaze Options}
43b72ede
AA
1079@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1080-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1081-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1082-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1083-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1084-mpic-data-is-text-relative}
1085
1086@emph{MIPS Options}
43b72ede
AA
1087@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1088-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1089-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1090-mips16 -mno-mips16 -mflip-mips16
1091-minterlink-compressed -mno-interlink-compressed
1092-minterlink-mips16 -mno-interlink-mips16
1093-mabi=@var{abi} -mabicalls -mno-abicalls
1094-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1095-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1096-mno-float -msingle-float -mdouble-float
1097-modd-spreg -mno-odd-spreg
1098-mabs=@var{mode} -mnan=@var{encoding}
1099-mdsp -mno-dsp -mdspr2 -mno-dspr2
1100-mmcu -mmno-mcu
1101-meva -mno-eva
1102-mvirt -mno-virt
1103-mxpa -mno-xpa
1104-mcrc -mno-crc
1105-mginv -mno-ginv
1106-mmicromips -mno-micromips
1107-mmsa -mno-msa
1108-mloongson-mmi -mno-loongson-mmi
1109-mloongson-ext -mno-loongson-ext
1110-mloongson-ext2 -mno-loongson-ext2
1111-mfpu=@var{fpu-type}
1112-msmartmips -mno-smartmips
1113-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1114-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1115-mlong64 -mlong32 -msym32 -mno-sym32
1116-G@var{num} -mlocal-sdata -mno-local-sdata
1117-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1118-membedded-data -mno-embedded-data
1119-muninit-const-in-rodata -mno-uninit-const-in-rodata
1120-mcode-readable=@var{setting}
1121-msplit-addresses -mno-split-addresses
1122-mexplicit-relocs -mno-explicit-relocs
1123-mcheck-zero-division -mno-check-zero-division
1124-mdivide-traps -mdivide-breaks
1125-mload-store-pairs -mno-load-store-pairs
1126-munaligned-access -mno-unaligned-access
1127-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1128-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1129-mfix-24k -mno-fix-24k
1130-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1131-mfix-r5900 -mno-fix-r5900
1132-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1133-mfix-vr4120 -mno-fix-vr4120
1134-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1135-mflush-func=@var{func} -mno-flush-func
1136-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1137-mcompact-branches=@var{policy}
1138-mfp-exceptions -mno-fp-exceptions
1139-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1140-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1141-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1142-mframe-header-opt -mno-frame-header-opt}
1143
1144@emph{MMIX Options}
43b72ede
AA
1145@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1146-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1147-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1148-mno-base-addresses -msingle-exit -mno-single-exit}
1149
1150@emph{MN10300 Options}
43b72ede
AA
1151@gccoptlist{-mmult-bug -mno-mult-bug
1152-mno-am33 -mam33 -mam33-2 -mam34
1153-mtune=@var{cpu-type}
1154-mreturn-pointer-on-d0
d77de738
ML
1155-mno-crt0 -mrelax -mliw -msetlb}
1156
1157@emph{Moxie Options}
1158@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1159
1160@emph{MSP430 Options}
43b72ede
AA
1161@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1162-mwarn-mcu
1163-mcode-region= -mdata-region=
1164-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1165-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1166
1167@emph{NDS32 Options}
43b72ede
AA
1168@gccoptlist{-mbig-endian -mlittle-endian
1169-mreduced-regs -mfull-regs
1170-mcmov -mno-cmov
1171-mext-perf -mno-ext-perf
1172-mext-perf2 -mno-ext-perf2
1173-mext-string -mno-ext-string
1174-mv3push -mno-v3push
1175-m16bit -mno-16bit
1176-misr-vector-size=@var{num}
1177-mcache-block-size=@var{num}
1178-march=@var{arch}
1179-mcmodel=@var{code-model}
d77de738
ML
1180-mctor-dtor -mrelax}
1181
1182@emph{Nios II Options}
43b72ede
AA
1183@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1184-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1185-mel -meb
1186-mno-bypass-cache -mbypass-cache
1187-mno-cache-volatile -mcache-volatile
1188-mno-fast-sw-div -mfast-sw-div
1189-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1190-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1191-mcustom-fpu-cfg=@var{name}
1192-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
d77de738
ML
1193-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1194
1195@emph{Nvidia PTX Options}
1196@gccoptlist{-m64 -mmainkernel -moptimize}
1197
1198@emph{OpenRISC Options}
43b72ede
AA
1199@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1200-msoft-mul -msoft-div
1201-msoft-float -mhard-float -mdouble-float -munordered-float
1202-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1203-mcmodel=@var{code-model}}
1204
1205@emph{PDP-11 Options}
43b72ede
AA
1206@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1207-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1208-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1209
d77de738
ML
1210@emph{PowerPC Options}
1211See RS/6000 and PowerPC Options.
1212
1213@emph{PRU Options}
43b72ede 1214@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1215-mabi=@var{variant}}
d77de738
ML
1216
1217@emph{RISC-V Options}
43b72ede
AA
1218@gccoptlist{-mbranch-cost=@var{N-instruction}
1219-mplt -mno-plt
1220-mabi=@var{ABI-string}
1221-mfdiv -mno-fdiv
1222-mdiv -mno-div
1223-misa-spec=@var{ISA-spec-string}
1224-march=@var{ISA-string}
1225-mtune=@var{processor-string}
1226-mpreferred-stack-boundary=@var{num}
1227-msmall-data-limit=@var{N-bytes}
1228-msave-restore -mno-save-restore
1229-mshorten-memrefs -mno-shorten-memrefs
1230-mstrict-align -mno-strict-align
1231-mcmodel=medlow -mcmodel=medany
1232-mexplicit-relocs -mno-explicit-relocs
1233-mrelax -mno-relax
1234-mriscv-attribute -mno-riscv-attribute
1235-malign-data=@var{type}
1236-mbig-endian -mlittle-endian
1237-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1238-mstack-protector-guard-offset=@var{offset}
f797260a 1239-mcsr-check -mno-csr-check
df48285b 1240-minline-atomics -mno-inline-atomics
949f1ccf
CM
1241-minline-strlen -mno-inline-strlen
1242-minline-strcmp -mno-inline-strcmp
1243-minline-strncmp -mno-inline-strncmp}
d77de738
ML
1244
1245@emph{RL78 Options}
43b72ede
AA
1246@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1247-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1248-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1249
1250@emph{RS/6000 and PowerPC Options}
43b72ede
AA
1251@gccoptlist{-mcpu=@var{cpu-type}
1252-mtune=@var{cpu-type}
1253-mcmodel=@var{code-model}
1254-mpowerpc64
1255-maltivec -mno-altivec
1256-mpowerpc-gpopt -mno-powerpc-gpopt
1257-mpowerpc-gfxopt -mno-powerpc-gfxopt
1258-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1259-mfprnd -mno-fprnd
1260-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1261-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1262-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1263-malign-power -malign-natural
1264-msoft-float -mhard-float -mmultiple -mno-multiple
1265-mupdate -mno-update
1266-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1267-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1268-mstrict-align -mno-strict-align -mrelocatable
1269-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1270-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1271-mdynamic-no-pic -mswdiv -msingle-pic-base
1272-mprioritize-restricted-insns=@var{priority}
1273-msched-costly-dep=@var{dependence_type}
1274-minsert-sched-nops=@var{scheme}
1275-mcall-aixdesc -mcall-eabi -mcall-freebsd
1276-mcall-linux -mcall-netbsd -mcall-openbsd
1277-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1278-mtraceback=@var{traceback_type}
1279-maix-struct-return -msvr4-struct-return
1280-mabi=@var{abi-type} -msecure-plt -mbss-plt
1281-mlongcall -mno-longcall -mpltseq -mno-pltseq
1282-mblock-move-inline-limit=@var{num}
1283-mblock-compare-inline-limit=@var{num}
1284-mblock-compare-inline-loop-limit=@var{num}
1285-mno-block-ops-unaligned-vsx
1286-mstring-compare-inline-limit=@var{num}
1287-misel -mno-isel
1288-mvrsave -mno-vrsave
1289-mmulhw -mno-mulhw
1290-mdlmzb -mno-dlmzb
1291-mprototype -mno-prototype
1292-msim -mmvme -mads -myellowknife -memb -msdata
1293-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1294-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1295-mno-recip-precision
1296-mveclibabi=@var{type} -mfriz -mno-friz
1297-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1298-msave-toc-indirect -mno-save-toc-indirect
1299-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector
1300-mcrypto -mno-crypto -mhtm -mno-htm
1301-mquad-memory -mno-quad-memory
1302-mquad-memory-atomic -mno-quad-memory-atomic
1303-mcompat-align-parm -mno-compat-align-parm
1304-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1305-mgnu-attribute -mno-gnu-attribute
1306-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1307-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1308-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1309-mprivileged -mno-privileged}
1310
1311@emph{RX Options}
43b72ede
AA
1312@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1313-mcpu=
1314-mbig-endian-data -mlittle-endian-data
1315-msmall-data
1316-msim -mno-sim
1317-mas100-syntax -mno-as100-syntax
1318-mrelax
1319-mmax-constant-size=
1320-mint-register=
1321-mpid
1322-mallow-string-insns -mno-allow-string-insns
1323-mjsr
1324-mno-warn-multiple-fast-interrupts
d77de738
ML
1325-msave-acc-in-interrupts}
1326
1327@emph{S/390 and zSeries Options}
43b72ede
AA
1328@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1329-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1330-mlong-double-64 -mlong-double-128
1331-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1332-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1333-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1334-mhtm -mvx -mzvector
1335-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1336-mfused-madd -mno-fused-madd
1337-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1338-mhotpatch=@var{halfwords},@var{halfwords}}
1339
d77de738 1340@emph{SH Options}
43b72ede
AA
1341@gccoptlist{-m1 -m2 -m2e
1342-m2a-nofpu -m2a-single-only -m2a-single -m2a
1343-m3 -m3e
1344-m4-nofpu -m4-single-only -m4-single -m4
1345-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1346-mb -ml -mdalign -mrelax
1347-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1348-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1349-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1350-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1351-maccumulate-outgoing-args
1352-matomic-model=@var{atomic-model}
1353-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1354-mcbranch-force-delay-slot
1355-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1356-mpretend-cmove -mtas}
1357
1358@emph{Solaris 2 Options}
43b72ede 1359@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1360-pthreads}
1361
1362@emph{SPARC Options}
43b72ede
AA
1363@gccoptlist{-mcpu=@var{cpu-type}
1364-mtune=@var{cpu-type}
1365-mcmodel=@var{code-model}
1366-mmemory-model=@var{mem-model}
1367-m32 -m64 -mapp-regs -mno-app-regs
1368-mfaster-structs -mno-faster-structs -mflat -mno-flat
1369-mfpu -mno-fpu -mhard-float -msoft-float
1370-mhard-quad-float -msoft-quad-float
1371-mstack-bias -mno-stack-bias
1372-mstd-struct-return -mno-std-struct-return
1373-munaligned-doubles -mno-unaligned-doubles
1374-muser-mode -mno-user-mode
1375-mv8plus -mno-v8plus -mvis -mno-vis
1376-mvis2 -mno-vis2 -mvis3 -mno-vis3
1377-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1378-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1379-mpopc -mno-popc -msubxc -mno-subxc
1380-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
d77de738
ML
1381-mlra -mno-lra}
1382
1383@emph{System V Options}
1384@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1385
1386@emph{V850 Options}
43b72ede
AA
1387@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1388-mprolog-function -mno-prolog-function -mspace
1389-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1390-mapp-regs -mno-app-regs
1391-mdisable-callt -mno-disable-callt
1392-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1393-mv850e -mv850 -mv850e3v5
1394-mloop
1395-mrelax
1396-mlong-jumps
1397-msoft-float
1398-mhard-float
1399-mgcc-abi
1400-mrh850-abi
d77de738
ML
1401-mbig-switch}
1402
1403@emph{VAX Options}
1404@gccoptlist{-mg -mgnu -munix -mlra}
1405
1406@emph{Visium Options}
43b72ede 1407@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1408-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1409
1410@emph{VMS Options}
43b72ede 1411@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1412-mpointer-size=@var{size}}
1413
1414@emph{VxWorks Options}
b6f4b000 1415@gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
d77de738
ML
1416-Xbind-lazy -Xbind-now}
1417
1418@emph{x86 Options}
43b72ede
AA
1419@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1420-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1421-mfpmath=@var{unit}
1422-masm=@var{dialect} -mno-fancy-math-387
1423-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1424-mno-wide-multiply -mrtd -malign-double
1425-mpreferred-stack-boundary=@var{num}
1426-mincoming-stack-boundary=@var{num}
1427-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1428-mrecip -mrecip=@var{opt}
1429-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
ad5b757d 1430-mpartial-vector-fp-math
43b72ede
AA
1431-mmove-max=@var{bits} -mstore-max=@var{bits}
1432-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1433-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1434-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1435-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1436-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1437-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1438-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1439-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1440-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1441-mavx512vbmi2 -mavx512bf16 -menqcmd
1442-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1443-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1444-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1445-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1446-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
e686416b 1447-mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
5fbd91b1 1448-musermsr
43b72ede
AA
1449-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1450-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1451-mkl -mwidekl
1452-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1453-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1454-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1455-mregparm=@var{num} -msseregparm
1456-mveclibabi=@var{type} -mvect8-ret-in-mem
1457-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1458-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1459-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1460-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1461-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1462-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1463-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1464-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1465-mstack-protector-guard-reg=@var{reg}
1466-mstack-protector-guard-offset=@var{offset}
1467-mstack-protector-guard-symbol=@var{symbol}
1468-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1469-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1470-mindirect-branch-register -mharden-sls=@var{choice}
1471-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1472-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1473
1474@emph{x86 Windows Options}
453cb585 1475@gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll
43b72ede 1476-mnop-fun-dllimport -mthread
d77de738
ML
1477-municode -mwin32 -mwindows -fno-set-stack-executable}
1478
1479@emph{Xstormy16 Options}
1480@gccoptlist{-msim}
1481
1482@emph{Xtensa Options}
43b72ede
AA
1483@gccoptlist{-mconst16 -mno-const16
1484-mfused-madd -mno-fused-madd
1485-mforce-no-pic
1486-mserialize-volatile -mno-serialize-volatile
1487-mtext-section-literals -mno-text-section-literals
1488-mauto-litpools -mno-auto-litpools
1489-mtarget-align -mno-target-align
1490-mlongcalls -mno-longcalls
1491-mabi=@var{abi-type}
675b390e
MF
1492-mextra-l32r-costs=@var{cycles}
1493-mstrict-align -mno-strict-align}
d77de738
ML
1494
1495@emph{zSeries Options}
1496See S/390 and zSeries Options.
1497@end table
1498
1499
1500@node Overall Options
1501@section Options Controlling the Kind of Output
1502
1503Compilation can involve up to four stages: preprocessing, compilation
1504proper, assembly and linking, always in that order. GCC is capable of
1505preprocessing and compiling several files either into several
1506assembler input files, or into one assembler input file; then each
1507assembler input file produces an object file, and linking combines all
1508the object files (those newly compiled, and those specified as input)
1509into an executable file.
1510
1511@cindex file name suffix
1512For any given input file, the file name suffix determines what kind of
1513compilation is done:
1514
1515@table @gcctabopt
1516@item @var{file}.c
1517C source code that must be preprocessed.
1518
1519@item @var{file}.i
1520C source code that should not be preprocessed.
1521
1522@item @var{file}.ii
1523C++ source code that should not be preprocessed.
1524
1525@item @var{file}.m
1526Objective-C source code. Note that you must link with the @file{libobjc}
1527library to make an Objective-C program work.
1528
1529@item @var{file}.mi
1530Objective-C source code that should not be preprocessed.
1531
1532@item @var{file}.mm
1533@itemx @var{file}.M
1534Objective-C++ source code. Note that you must link with the @file{libobjc}
1535library to make an Objective-C++ program work. Note that @samp{.M} refers
1536to a literal capital M@.
1537
1538@item @var{file}.mii
1539Objective-C++ source code that should not be preprocessed.
1540
1541@item @var{file}.h
1542C, C++, Objective-C or Objective-C++ header file to be turned into a
1543precompiled header (default), or C, C++ header file to be turned into an
1544Ada spec (via the @option{-fdump-ada-spec} switch).
1545
1546@item @var{file}.cc
1547@itemx @var{file}.cp
1548@itemx @var{file}.cxx
1549@itemx @var{file}.cpp
1550@itemx @var{file}.CPP
1551@itemx @var{file}.c++
1552@itemx @var{file}.C
1553C++ source code that must be preprocessed. Note that in @samp{.cxx},
1554the last two letters must both be literally @samp{x}. Likewise,
1555@samp{.C} refers to a literal capital C@.
1556
1557@item @var{file}.mm
1558@itemx @var{file}.M
1559Objective-C++ source code that must be preprocessed.
1560
1561@item @var{file}.mii
1562Objective-C++ source code that should not be preprocessed.
1563
1564@item @var{file}.hh
1565@itemx @var{file}.H
1566@itemx @var{file}.hp
1567@itemx @var{file}.hxx
1568@itemx @var{file}.hpp
1569@itemx @var{file}.HPP
1570@itemx @var{file}.h++
1571@itemx @var{file}.tcc
1572C++ header file to be turned into a precompiled header or Ada spec.
1573
1574@item @var{file}.f
1575@itemx @var{file}.for
1576@itemx @var{file}.ftn
1577Fixed form Fortran source code that should not be preprocessed.
1578
1579@item @var{file}.F
1580@itemx @var{file}.FOR
1581@itemx @var{file}.fpp
1582@itemx @var{file}.FPP
1583@itemx @var{file}.FTN
1584Fixed form Fortran source code that must be preprocessed (with the traditional
1585preprocessor).
1586
1587@item @var{file}.f90
1588@itemx @var{file}.f95
1589@itemx @var{file}.f03
1590@itemx @var{file}.f08
1591Free form Fortran source code that should not be preprocessed.
1592
1593@item @var{file}.F90
1594@itemx @var{file}.F95
1595@itemx @var{file}.F03
1596@itemx @var{file}.F08
1597Free form Fortran source code that must be preprocessed (with the
1598traditional preprocessor).
1599
1600@item @var{file}.go
1601Go source code.
1602
1603@item @var{file}.d
1604D source code.
1605
1606@item @var{file}.di
1607D interface file.
1608
1609@item @var{file}.dd
1610D documentation code (Ddoc).
1611
1612@item @var{file}.ads
1613Ada source code file that contains a library unit declaration (a
1614declaration of a package, subprogram, or generic, or a generic
1615instantiation), or a library unit renaming declaration (a package,
1616generic, or subprogram renaming declaration). Such files are also
1617called @dfn{specs}.
1618
1619@item @var{file}.adb
1620Ada source code file containing a library unit body (a subprogram or
1621package body). Such files are also called @dfn{bodies}.
1622
1623@c GCC also knows about some suffixes for languages not yet included:
1624@c Ratfor:
1625@c @var{file}.r
1626
1627@item @var{file}.s
1628Assembler code.
1629
1630@item @var{file}.S
1631@itemx @var{file}.sx
1632Assembler code that must be preprocessed.
1633
1634@item @var{other}
1635An object file to be fed straight into linking.
1636Any file name with no recognized suffix is treated this way.
1637@end table
1638
1639@opindex x
1640You can specify the input language explicitly with the @option{-x} option:
1641
1642@table @gcctabopt
1643@item -x @var{language}
1644Specify explicitly the @var{language} for the following input files
1645(rather than letting the compiler choose a default based on the file
1646name suffix). This option applies to all following input files until
1647the next @option{-x} option. Possible values for @var{language} are:
1648@smallexample
1649c c-header cpp-output
1650c++ c++-header c++-system-header c++-user-header c++-cpp-output
1651objective-c objective-c-header objective-c-cpp-output
1652objective-c++ objective-c++-header objective-c++-cpp-output
1653assembler assembler-with-cpp
1654ada
1655d
1656f77 f77-cpp-input f95 f95-cpp-input
1657go
1658@end smallexample
1659
1660@item -x none
1661Turn off any specification of a language, so that subsequent files are
1662handled according to their file name suffixes (as they are if @option{-x}
1663has not been used at all).
1664@end table
1665
1666If you only want some of the stages of compilation, you can use
1667@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1668one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1669@command{gcc} is to stop. Note that some combinations (for example,
1670@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1671
1672@table @gcctabopt
d77de738 1673@opindex c
ddf6fe37 1674@item -c
d77de738
ML
1675Compile or assemble the source files, but do not link. The linking
1676stage simply is not done. The ultimate output is in the form of an
1677object file for each source file.
1678
1679By default, the object file name for a source file is made by replacing
1680the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1681
1682Unrecognized input files, not requiring compilation or assembly, are
1683ignored.
1684
d77de738 1685@opindex S
ddf6fe37 1686@item -S
d77de738
ML
1687Stop after the stage of compilation proper; do not assemble. The output
1688is in the form of an assembler code file for each non-assembler input
1689file specified.
1690
1691By default, the assembler file name for a source file is made by
1692replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1693
1694Input files that don't require compilation are ignored.
1695
d77de738 1696@opindex E
ddf6fe37 1697@item -E
d77de738
ML
1698Stop after the preprocessing stage; do not run the compiler proper. The
1699output is in the form of preprocessed source code, which is sent to the
1700standard output.
1701
1702Input files that don't require preprocessing are ignored.
1703
1704@cindex output file option
d77de738 1705@opindex o
ddf6fe37 1706@item -o @var{file}
d77de738
ML
1707Place the primary output in file @var{file}. This applies to whatever
1708sort of output is being produced, whether it be an executable file, an
1709object file, an assembler file or preprocessed C code.
1710
1711If @option{-o} is not specified, the default is to put an executable
1712file in @file{a.out}, the object file for
1713@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1714assembler file in @file{@var{source}.s}, a precompiled header file in
1715@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1716standard output.
1717
1718Though @option{-o} names only the primary output, it also affects the
1719naming of auxiliary and dump outputs. See the examples below. Unless
1720overridden, both auxiliary outputs and dump outputs are placed in the
1721same directory as the primary output. In auxiliary outputs, the suffix
1722of the input file is replaced with that of the auxiliary output file
1723type; in dump outputs, the suffix of the dump file is appended to the
1724input file suffix. In compilation commands, the base name of both
1725auxiliary and dump outputs is that of the primary output; in compile and
1726link commands, the primary output name, minus the executable suffix, is
1727combined with the input file name. If both share the same base name,
1728disregarding the suffix, the result of the combination is that base
1729name, otherwise, they are concatenated, separated by a dash.
1730
1731@smallexample
1732gcc -c foo.c ...
1733@end smallexample
1734
1735will use @file{foo.o} as the primary output, and place aux outputs and
1736dumps next to it, e.g., aux file @file{foo.dwo} for
1737@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1738@option{-fdump-rtl-final}.
1739
1740If a non-linker output file is explicitly specified, aux and dump files
1741by default take the same base name:
1742
1743@smallexample
1744gcc -c foo.c -o dir/foobar.o ...
1745@end smallexample
1746
1747will name aux outputs @file{dir/foobar.*} and dump outputs
1748@file{dir/foobar.c.*}.
1749
1750A linker output will instead prefix aux and dump outputs:
1751
1752@smallexample
1753gcc foo.c bar.c -o dir/foobar ...
1754@end smallexample
1755
1756will generally name aux outputs @file{dir/foobar-foo.*} and
1757@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1758@file{dir/foobar-bar.c.*}.
1759
1760The one exception to the above is when the executable shares the base
1761name with the single input:
1762
1763@smallexample
1764gcc foo.c -o dir/foo ...
1765@end smallexample
1766
1767in which case aux outputs are named @file{dir/foo.*} and dump outputs
1768named @file{dir/foo.c.*}.
1769
1770The location and the names of auxiliary and dump outputs can be adjusted
1771by the options @option{-dumpbase}, @option{-dumpbase-ext},
1772@option{-dumpdir}, @option{-save-temps=cwd}, and
1773@option{-save-temps=obj}.
1774
1775
d77de738 1776@opindex dumpbase
ddf6fe37 1777@item -dumpbase @var{dumpbase}
d77de738
ML
1778This option sets the base name for auxiliary and dump output files. It
1779does not affect the name of the primary output file. Intermediate
1780outputs, when preserved, are not regarded as primary outputs, but as
1781auxiliary outputs:
1782
1783@smallexample
1784gcc -save-temps -S foo.c
1785@end smallexample
1786
1787saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1788then compiles to the (implied) output file @file{foo.s}, whereas:
1789
1790@smallexample
1791gcc -save-temps -dumpbase save-foo -c foo.c
1792@end smallexample
1793
1794preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1795an intermediate, thus auxiliary output), and then assembles to the
1796(implied) output file @file{foo.o}.
1797
1798Absent this option, dump and aux files take their names from the input
1799file, or from the (non-linker) output file, if one is explicitly
1800specified: dump output files (e.g. those requested by @option{-fdump-*}
1801options) with the input name suffix, and aux output files (those
1802requested by other non-dump options, e.g. @code{-save-temps},
1803@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1804
1805Similar suffix differentiation of dump and aux outputs can be attained
1806for explicitly-given @option{-dumpbase basename.suf} by also specifying
1807@option{-dumpbase-ext .suf}.
1808
1809If @var{dumpbase} is explicitly specified with any directory component,
1810any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1811@option{-save-temps=*}) is ignored, and instead of appending to it,
1812@var{dumpbase} fully overrides it:
1813
1814@smallexample
1815gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1816 -dumpdir pfx- -save-temps=cwd ...
1817@end smallexample
1818
1819creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1820@file{dir/} in @option{-o}, the @file{./} prefix implied by
1821@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1822
1823When @option{-dumpbase} is specified in a command that compiles multiple
1824inputs, or that compiles and then links, it may be combined with
1825@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1826file is compiled using the combined @var{dumppfx}, and default values
1827for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1828file:
1829
1830@smallexample
1831gcc foo.c bar.c -c -dumpbase main ...
1832@end smallexample
1833
1834creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1835overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1836as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1837and @file{main-bar.*}.
1838
1839An empty string specified as @var{dumpbase} avoids the influence of the
1840output basename in the naming of auxiliary and dump outputs during
1841compilation, computing default values :
1842
1843@smallexample
1844gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1845@end smallexample
1846
1847will name aux outputs @file{dir/foo.*} and dump outputs
1848@file{dir/foo.c.*}. Note how their basenames are taken from the input
1849name, but the directory still defaults to that of the output.
1850
1851The empty-string dumpbase does not prevent the use of the output
1852basename for outputs during linking:
1853
1854@smallexample
1855gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1856@end smallexample
1857
1858The compilation of the source files will name auxiliary outputs
1859@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1860@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1861linking will use @file{dir/foobar.} as the prefix for dumps and
1862auxiliary files.
1863
1864
d77de738 1865@opindex dumpbase-ext
ddf6fe37 1866@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1867When forming the name of an auxiliary (but not a dump) output file, drop
1868trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1869suffixes. If not specified, this option defaults to the suffix of a
1870default @var{dumpbase}, i.e., the suffix of the input file when
1871@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1872is combined with @var{dumppfx}.
1873
1874@smallexample
1875gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1876@end smallexample
1877
1878creates @file{dir/foo.o} as the main output, and generates auxiliary
1879outputs in @file{dir/x-foo.*}, taking the location of the primary
1880output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1881outputs retain the suffix: @file{dir/x-foo.c.*}.
1882
1883This option is disregarded if it does not match the suffix of a
1884specified @var{dumpbase}, except as an alternative to the executable
1885suffix when appending the linker output base name to @var{dumppfx}, as
1886specified below:
1887
1888@smallexample
1889gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1890@end smallexample
1891
1892creates @file{main.out} as the primary output, and avoids overwriting
1893the auxiliary and dump outputs by using the executable name minus
1894@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1895@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1896@file{main-foo.c.*} and @file{main-bar.c.*}.
1897
1898
d77de738 1899@opindex dumpdir
ddf6fe37 1900@item -dumpdir @var{dumppfx}
d77de738
ML
1901When forming the name of an auxiliary or dump output file, use
1902@var{dumppfx} as a prefix:
1903
1904@smallexample
1905gcc -dumpdir pfx- -c foo.c ...
1906@end smallexample
1907
1908creates @file{foo.o} as the primary output, and auxiliary outputs named
1909@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1910@var{dumpbase} derived from the default primary output, derived in turn
1911from the input name. Dump outputs also take the input name suffix:
1912@file{pfx-foo.c.*}.
1913
1914If @var{dumppfx} is to be used as a directory name, it must end with a
1915directory separator:
1916
1917@smallexample
1918gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1919@end smallexample
1920
1921creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1922named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1923default @var{dumpbase} derived from the primary output name. Dump
1924outputs also take the input name suffix: @file{dir/bar.c.*}.
1925
1926It defaults to the location of the output file, unless the output
1927file is a special file like @code{/dev/null}. Options
1928@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1929default, just like an explicit @option{-dumpdir} option. In case
1930multiple such options are given, the last one prevails:
1931
1932@smallexample
1933gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1934@end smallexample
1935
1936outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1937@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1938@option{-dumpdir} option. It does not matter that @option{=obj} is the
1939default for @option{-save-temps}, nor that the output directory is
1940implicitly the current directory. Dump outputs are named
1941@file{foo.c.*}.
1942
1943When compiling from multiple input files, if @option{-dumpbase} is
1944specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1945are appended to (or override, if containing any directory components) an
1946explicit or defaulted @var{dumppfx}, so that each of the multiple
1947compilations gets differently-named aux and dump outputs.
1948
1949@smallexample
1950gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1951@end smallexample
1952
1953outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1954@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1955Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1956and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1957single-input compilation:
1958
1959@smallexample
1960gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1961@end smallexample
1962
1963that, applying @option{-dumpbase} to a single source, does not compute
1964and append a separate @var{dumpbase} per input file. Its auxiliary and
1965dump outputs go in @file{dir/pfx-main.*}.
1966
1967When compiling and then linking from multiple input files, a defaulted
1968or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1969transformation above (e.g. the compilation of @file{foo.c} and
1970@file{bar.c} above, but without @option{-c}). If neither
1971@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1972base name, minus @var{auxdropsuf}, if specified, or the executable
1973suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1974instead. Note, however, that unlike earlier cases of linking:
1975
1976@smallexample
1977gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1978@end smallexample
1979
1980does not append the output name @file{main} to @var{dumppfx}, because
1981@option{-dumpdir} is explicitly specified. The goal is that the
1982explicitly-specified @var{dumppfx} may contain the specified output name
1983as part of the prefix, if desired; only an explicitly-specified
1984@option{-dumpbase} would be combined with it, in order to avoid simply
1985discarding a meaningful option.
1986
1987When compiling and then linking from a single input file, the linker
1988output base name will only be appended to the default @var{dumppfx} as
1989above if it does not share the base name with the single input file
1990name. This has been covered in single-input linking cases above, but
1991not with an explicit @option{-dumpdir} that inhibits the combination,
1992even if overridden by @option{-save-temps=*}:
1993
1994@smallexample
1995gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1996@end smallexample
1997
1998Auxiliary outputs are named @file{foo.*}, and dump outputs
1999@file{foo.c.*}, in the current working directory as ultimately requested
2000by @option{-save-temps=cwd}.
2001
2002Summing it all up for an intuitive though slightly imprecise data flow:
2003the primary output name is broken into a directory part and a basename
2004part; @var{dumppfx} is set to the former, unless overridden by
2005@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2006to the latter, unless overriden by @option{-dumpbase}. If there are
2007multiple inputs or linking, this @var{dumpbase} may be combined with
2008@var{dumppfx} and taken from each input file. Auxiliary output names
2009for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2010minus suffix, and the auxiliary output suffix; dump output names are
2011only different in that the suffix from @var{dumpbase} is retained.
2012
2013When it comes to auxiliary and dump outputs created during LTO
2014recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2015given or as derived from the linker output name but not from inputs,
2016even in cases in which this combination would not otherwise be used as
2017such, is passed down with a trailing period replacing the compiler-added
2018dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2019being involved in linking, this program does not normally get any
2020@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2021
2022When running sub-compilers, @command{lto-wrapper} appends LTO stage
2023names to the received @var{dumppfx}, ensures it contains a directory
2024component so that it overrides any @option{-dumpdir}, and passes that as
2025@option{-dumpbase} to sub-compilers.
2026
d77de738 2027@opindex v
ddf6fe37 2028@item -v
d77de738
ML
2029Print (on standard error output) the commands executed to run the stages
2030of compilation. Also print the version number of the compiler driver
2031program and of the preprocessor and the compiler proper.
2032
d77de738 2033@opindex ###
ddf6fe37 2034@item -###
d77de738
ML
2035Like @option{-v} except the commands are not executed and arguments
2036are quoted unless they contain only alphanumeric characters or @code{./-_}.
2037This is useful for shell scripts to capture the driver-generated command lines.
2038
d77de738 2039@opindex help
ddf6fe37 2040@item --help
d77de738
ML
2041Print (on the standard output) a description of the command-line options
2042understood by @command{gcc}. If the @option{-v} option is also specified
2043then @option{--help} is also passed on to the various processes
2044invoked by @command{gcc}, so that they can display the command-line options
2045they accept. If the @option{-Wextra} option has also been specified
2046(prior to the @option{--help} option), then command-line options that
2047have no documentation associated with them are also displayed.
2048
d77de738 2049@opindex target-help
ddf6fe37 2050@item --target-help
d77de738
ML
2051Print (on the standard output) a description of target-specific command-line
2052options for each tool. For some targets extra target-specific
2053information may also be printed.
2054
2055@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2056Print (on the standard output) a description of the command-line
2057options understood by the compiler that fit into all specified classes
2058and qualifiers. These are the supported classes:
2059
2060@table @asis
2061@item @samp{optimizers}
2062Display all of the optimization options supported by the
2063compiler.
2064
2065@item @samp{warnings}
2066Display all of the options controlling warning messages
2067produced by the compiler.
2068
2069@item @samp{target}
2070Display target-specific options. Unlike the
2071@option{--target-help} option however, target-specific options of the
2072linker and assembler are not displayed. This is because those
2073tools do not currently support the extended @option{--help=} syntax.
2074
2075@item @samp{params}
2076Display the values recognized by the @option{--param}
2077option.
2078
2079@item @var{language}
2080Display the options supported for @var{language}, where
2081@var{language} is the name of one of the languages supported in this
2082version of GCC@. If an option is supported by all languages, one needs
2083to select @samp{common} class.
2084
2085@item @samp{common}
2086Display the options that are common to all languages.
2087@end table
2088
2089These are the supported qualifiers:
2090
2091@table @asis
2092@item @samp{undocumented}
2093Display only those options that are undocumented.
2094
2095@item @samp{joined}
2096Display options taking an argument that appears after an equal
2097sign in the same continuous piece of text, such as:
2098@samp{--help=target}.
2099
2100@item @samp{separate}
2101Display options taking an argument that appears as a separate word
2102following the original option, such as: @samp{-o output-file}.
2103@end table
2104
2105Thus for example to display all the undocumented target-specific
2106switches supported by the compiler, use:
2107
2108@smallexample
2109--help=target,undocumented
2110@end smallexample
2111
2112The sense of a qualifier can be inverted by prefixing it with the
2113@samp{^} character, so for example to display all binary warning
2114options (i.e., ones that are either on or off and that do not take an
2115argument) that have a description, use:
2116
2117@smallexample
2118--help=warnings,^joined,^undocumented
2119@end smallexample
2120
2121The argument to @option{--help=} should not consist solely of inverted
2122qualifiers.
2123
2124Combining several classes is possible, although this usually
2125restricts the output so much that there is nothing to display. One
2126case where it does work, however, is when one of the classes is
2127@var{target}. For example, to display all the target-specific
2128optimization options, use:
2129
2130@smallexample
2131--help=target,optimizers
2132@end smallexample
2133
2134The @option{--help=} option can be repeated on the command line. Each
2135successive use displays its requested class of options, skipping
2136those that have already been displayed. If @option{--help} is also
2137specified anywhere on the command line then this takes precedence
2138over any @option{--help=} option.
2139
2140If the @option{-Q} option appears on the command line before the
2141@option{--help=} option, then the descriptive text displayed by
2142@option{--help=} is changed. Instead of describing the displayed
2143options, an indication is given as to whether the option is enabled,
2144disabled or set to a specific value (assuming that the compiler
2145knows this at the point where the @option{--help=} option is used).
2146
2147Here is a truncated example from the ARM port of @command{gcc}:
2148
2149@smallexample
2150 % gcc -Q -mabi=2 --help=target -c
2151 The following options are target specific:
2152 -mabi= 2
2153 -mabort-on-noreturn [disabled]
2154 -mapcs [disabled]
2155@end smallexample
2156
2157The output is sensitive to the effects of previous command-line
2158options, so for example it is possible to find out which optimizations
2159are enabled at @option{-O2} by using:
2160
2161@smallexample
2162-Q -O2 --help=optimizers
2163@end smallexample
2164
2165Alternatively you can discover which binary optimizations are enabled
2166by @option{-O3} by using:
2167
2168@smallexample
2169gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2170gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2171diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2172@end smallexample
2173
d77de738 2174@opindex version
ddf6fe37 2175@item --version
d77de738
ML
2176Display the version number and copyrights of the invoked GCC@.
2177
d77de738 2178@opindex pass-exit-codes
ddf6fe37 2179@item -pass-exit-codes
d77de738
ML
2180Normally the @command{gcc} program exits with the code of 1 if any
2181phase of the compiler returns a non-success return code. If you specify
2182@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2183the numerically highest error produced by any phase returning an error
2184indication. The C, C++, and Fortran front ends return 4 if an internal
2185compiler error is encountered.
2186
d77de738 2187@opindex pipe
ddf6fe37 2188@item -pipe
d77de738
ML
2189Use pipes rather than temporary files for communication between the
2190various stages of compilation. This fails to work on some systems where
2191the assembler is unable to read from a pipe; but the GNU assembler has
2192no trouble.
2193
d77de738 2194@opindex specs
ddf6fe37 2195@item -specs=@var{file}
d77de738
ML
2196Process @var{file} after the compiler reads in the standard @file{specs}
2197file, in order to override the defaults which the @command{gcc} driver
2198program uses when determining what switches to pass to @command{cc1},
2199@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2200@option{-specs=@var{file}} can be specified on the command line, and they
2201are processed in order, from left to right. @xref{Spec Files}, for
2202information about the format of the @var{file}.
2203
d77de738 2204@opindex wrapper
ddf6fe37 2205@item -wrapper
d77de738
ML
2206Invoke all subcommands under a wrapper program. The name of the
2207wrapper program and its parameters are passed as a comma separated
2208list.
2209
2210@smallexample
2211gcc -c t.c -wrapper gdb,--args
2212@end smallexample
2213
2214@noindent
2215This invokes all subprograms of @command{gcc} under
2216@samp{gdb --args}, thus the invocation of @command{cc1} is
2217@samp{gdb --args cc1 @dots{}}.
2218
d77de738 2219@opindex ffile-prefix-map
ddf6fe37 2220@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2221When compiling files residing in directory @file{@var{old}}, record
2222any references to them in the result of the compilation as if the
2223files resided in directory @file{@var{new}} instead. Specifying this
2224option is equivalent to specifying all the individual
2225@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2226builds that are location independent. Directories referenced by
2eb0191a
JJ
2227directives are not affected by these options. See also
2228@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2229@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2230
2eb0191a 2231@opindex fcanon-prefix-map
e54b01a1 2232@item -fcanon-prefix-map
2eb0191a
JJ
2233For the @option{-f*-prefix-map} options normally comparison
2234of @file{@var{old}} prefix against the filename that would be normally
2235referenced in the result of the compilation is done using textual
2236comparison of the prefixes, or ignoring character case for case insensitive
2237filesystems and considering slashes and backslashes as equal on DOS based
2238filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2239to be done on canonicalized paths of @file{@var{old}}
2240and the referenced filename.
d77de738 2241
d77de738 2242@opindex fplugin
ddf6fe37 2243@item -fplugin=@var{name}.so
d77de738
ML
2244Load the plugin code in file @var{name}.so, assumed to be a
2245shared object to be dlopen'd by the compiler. The base name of
2246the shared object file is used to identify the plugin for the
2247purposes of argument parsing (See
2248@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2249Each plugin should define the callback functions specified in the
2250Plugins API.
2251
d77de738 2252@opindex fplugin-arg
ddf6fe37 2253@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2254Define an argument called @var{key} with a value of @var{value}
2255for the plugin called @var{name}.
2256
d77de738 2257@opindex fdump-ada-spec
ddf6fe37 2258@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2259For C and C++ source and include files, generate corresponding Ada specs.
2260@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2261GNAT User's Guide}, which provides detailed documentation on this feature.
2262
d77de738 2263@opindex fada-spec-parent
ddf6fe37 2264@item -fada-spec-parent=@var{unit}
d77de738
ML
2265In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2266Ada specs as child units of parent @var{unit}.
2267
d77de738 2268@opindex fdump-go-spec
ddf6fe37 2269@item -fdump-go-spec=@var{file}
d77de738
ML
2270For input files in any language, generate corresponding Go
2271declarations in @var{file}. This generates Go @code{const},
2272@code{type}, @code{var}, and @code{func} declarations which may be a
2273useful way to start writing a Go interface to code written in some
2274other language.
2275
2276@include @value{srcdir}/../libiberty/at-file.texi
2277@end table
2278
2279@node Invoking G++
2280@section Compiling C++ Programs
2281
2282@cindex suffixes for C++ source
2283@cindex C++ source file suffixes
2284C++ source files conventionally use one of the suffixes @samp{.C},
2285@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2286@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2287@samp{.H}, or (for shared template code) @samp{.tcc}; and
2288preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2289files with these names and compiles them as C++ programs even if you
2290call the compiler the same way as for compiling C programs (usually
2291with the name @command{gcc}).
2292
2293@findex g++
2294@findex c++
2295However, the use of @command{gcc} does not add the C++ library.
2296@command{g++} is a program that calls GCC and automatically specifies linking
2297against the C++ library. It treats @samp{.c},
2298@samp{.h} and @samp{.i} files as C++ source files instead of C source
2299files unless @option{-x} is used. This program is also useful when
2300precompiling a C header file with a @samp{.h} extension for use in C++
2301compilations. On many systems, @command{g++} is also installed with
2302the name @command{c++}.
2303
2304@cindex invoking @command{g++}
2305When you compile C++ programs, you may specify many of the same
2306command-line options that you use for compiling programs in any
2307language; or command-line options meaningful for C and related
2308languages; or options that are meaningful only for C++ programs.
2309@xref{C Dialect Options,,Options Controlling C Dialect}, for
2310explanations of options for languages related to C@.
2311@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2312explanations of options that are meaningful only for C++ programs.
2313
2314@node C Dialect Options
2315@section Options Controlling C Dialect
2316@cindex dialect options
2317@cindex language dialect options
2318@cindex options, dialect
2319
2320The following options control the dialect of C (or languages derived
2321from C, such as C++, Objective-C and Objective-C++) that the compiler
2322accepts:
2323
2324@table @gcctabopt
2325@cindex ANSI support
2326@cindex ISO support
d77de738 2327@opindex ansi
ddf6fe37 2328@item -ansi
d77de738
ML
2329In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2330equivalent to @option{-std=c++98}.
2331
2332This turns off certain features of GCC that are incompatible with ISO
2333C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2334such as the @code{asm} and @code{typeof} keywords, and
2335predefined macros such as @code{unix} and @code{vax} that identify the
2336type of system you are using. It also enables the undesirable and
2337rarely used ISO trigraph feature. For the C compiler,
2338it disables recognition of C++ style @samp{//} comments as well as
2339the @code{inline} keyword.
2340
2341The alternate keywords @code{__asm__}, @code{__extension__},
2342@code{__inline__} and @code{__typeof__} continue to work despite
2343@option{-ansi}. You would not want to use them in an ISO C program, of
2344course, but it is useful to put them in header files that might be included
2345in compilations done with @option{-ansi}. Alternate predefined macros
2346such as @code{__unix__} and @code{__vax__} are also available, with or
2347without @option{-ansi}.
2348
2349The @option{-ansi} option does not cause non-ISO programs to be
2350rejected gratuitously. For that, @option{-Wpedantic} is required in
2351addition to @option{-ansi}. @xref{Warning Options}.
2352
2353The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2354option is used. Some header files may notice this macro and refrain
2355from declaring certain functions or defining certain macros that the
2356ISO standard doesn't call for; this is to avoid interfering with any
2357programs that might use these names for other things.
2358
2359Functions that are normally built in but do not have semantics
2360defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2361functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2362built-in functions provided by GCC}, for details of the functions
2363affected.
2364
d77de738 2365@opindex std
ddf6fe37 2366@item -std=
d77de738
ML
2367Determine the language standard. @xref{Standards,,Language Standards
2368Supported by GCC}, for details of these standard versions. This option
2369is currently only supported when compiling C or C++.
2370
2371The compiler can accept several base standards, such as @samp{c90} or
2372@samp{c++98}, and GNU dialects of those standards, such as
2373@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2374compiler accepts all programs following that standard plus those
2375using GNU extensions that do not contradict it. For example,
2376@option{-std=c90} turns off certain features of GCC that are
2377incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2378keywords, but not other GNU extensions that do not have a meaning in
2379ISO C90, such as omitting the middle term of a @code{?:}
2380expression. On the other hand, when a GNU dialect of a standard is
2381specified, all features supported by the compiler are enabled, even when
2382those features change the meaning of the base standard. As a result, some
2383strict-conforming programs may be rejected. The particular standard
2384is used by @option{-Wpedantic} to identify which features are GNU
2385extensions given that version of the standard. For example
2386@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2387comments, while @option{-std=gnu99 -Wpedantic} does not.
2388
2389A value for this option must be provided; possible values are
2390
2391@table @samp
2392@item c90
2393@itemx c89
2394@itemx iso9899:1990
2395Support all ISO C90 programs (certain GNU extensions that conflict
2396with ISO C90 are disabled). Same as @option{-ansi} for C code.
2397
2398@item iso9899:199409
2399ISO C90 as modified in amendment 1.
2400
2401@item c99
2402@itemx c9x
2403@itemx iso9899:1999
2404@itemx iso9899:199x
2405ISO C99. This standard is substantially completely supported, modulo
2406bugs and floating-point issues
2407(mainly but not entirely relating to optional C99 features from
2408Annexes F and G). See
2409@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2410names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2411
2412@item c11
2413@itemx c1x
2414@itemx iso9899:2011
2415ISO C11, the 2011 revision of the ISO C standard. This standard is
2416substantially completely supported, modulo bugs, floating-point issues
2417(mainly but not entirely relating to optional C11 features from
2418Annexes F and G) and the optional Annexes K (Bounds-checking
2419interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2420
2421@item c17
2422@itemx c18
2423@itemx iso9899:2017
2424@itemx iso9899:2018
2425ISO C17, the 2017 revision of the ISO C standard
2426(published in 2018). This standard is
2427same as C11 except for corrections of defects (all of which are also
2428applied with @option{-std=c11}) and a new value of
2429@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2430
2431@item c2x
2432The next version of the ISO C standard, still under development. The
2433support for this version is experimental and incomplete.
2434
2435@item gnu90
2436@itemx gnu89
2437GNU dialect of ISO C90 (including some C99 features).
2438
2439@item gnu99
2440@itemx gnu9x
2441GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2442
2443@item gnu11
2444@itemx gnu1x
2445GNU dialect of ISO C11.
2446The name @samp{gnu1x} is deprecated.
2447
2448@item gnu17
2449@itemx gnu18
2450GNU dialect of ISO C17. This is the default for C code.
2451
2452@item gnu2x
2453The next version of the ISO C standard, still under development, plus
2454GNU extensions. The support for this version is experimental and
2455incomplete.
2456
2457@item c++98
2458@itemx c++03
2459The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2460additional defect reports. Same as @option{-ansi} for C++ code.
2461
2462@item gnu++98
2463@itemx gnu++03
2464GNU dialect of @option{-std=c++98}.
2465
2466@item c++11
2467@itemx c++0x
2468The 2011 ISO C++ standard plus amendments.
2469The name @samp{c++0x} is deprecated.
2470
2471@item gnu++11
2472@itemx gnu++0x
2473GNU dialect of @option{-std=c++11}.
2474The name @samp{gnu++0x} is deprecated.
2475
2476@item c++14
2477@itemx c++1y
2478The 2014 ISO C++ standard plus amendments.
2479The name @samp{c++1y} is deprecated.
2480
2481@item gnu++14
2482@itemx gnu++1y
2483GNU dialect of @option{-std=c++14}.
2484The name @samp{gnu++1y} is deprecated.
2485
2486@item c++17
2487@itemx c++1z
2488The 2017 ISO C++ standard plus amendments.
2489The name @samp{c++1z} is deprecated.
2490
2491@item gnu++17
2492@itemx gnu++1z
2493GNU dialect of @option{-std=c++17}.
2494This is the default for C++ code.
2495The name @samp{gnu++1z} is deprecated.
2496
2497@item c++20
2498@itemx c++2a
2499The 2020 ISO C++ standard plus amendments.
2500Support is experimental, and could change in incompatible ways in
2501future releases.
2502The name @samp{c++2a} is deprecated.
2503
2504@item gnu++20
2505@itemx gnu++2a
2506GNU dialect of @option{-std=c++20}.
2507Support is experimental, and could change in incompatible ways in
2508future releases.
2509The name @samp{gnu++2a} is deprecated.
2510
2511@item c++2b
2512@itemx c++23
2513The next revision of the ISO C++ standard, planned for
25142023. Support is highly experimental, and will almost certainly
2515change in incompatible ways in future releases.
2516
2517@item gnu++2b
2518@itemx gnu++23
2519GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2520and will almost certainly change in incompatible ways in future
2521releases.
5388a43f
MP
2522
2523@item c++2c
2524@itemx c++26
2525The next revision of the ISO C++ standard, planned for
25262026. Support is highly experimental, and will almost certainly
2527change in incompatible ways in future releases.
2528
2529@item gnu++2c
2530@itemx gnu++26
2531GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2532and will almost certainly change in incompatible ways in future
2533releases.
d77de738
ML
2534@end table
2535
d77de738 2536@opindex aux-info
ddf6fe37 2537@item -aux-info @var{filename}
d77de738
ML
2538Output to the given filename prototyped declarations for all functions
2539declared and/or defined in a translation unit, including those in header
2540files. This option is silently ignored in any language other than C@.
2541
2542Besides declarations, the file indicates, in comments, the origin of
2543each declaration (source file and line), whether the declaration was
2544implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2545@samp{O} for old, respectively, in the first character after the line
2546number and the colon), and whether it came from a declaration or a
2547definition (@samp{C} or @samp{F}, respectively, in the following
2548character). In the case of function definitions, a K&R-style list of
2549arguments followed by their declarations is also provided, inside
2550comments, after the declaration.
2551
d77de738
ML
2552@opindex fno-asm
2553@opindex fasm
ddf6fe37 2554@item -fno-asm
d77de738
ML
2555Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2556keyword, so that code can use these words as identifiers. You can use
2557the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2558instead. In C, @option{-ansi} implies @option{-fno-asm}.
2559
2560In C++, @code{inline} is a standard keyword and is not affected by
2561this switch. You may want to use the @option{-fno-gnu-keywords} flag
2562instead, which disables @code{typeof} but not @code{asm} and
2563@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2564this switch only affects the @code{asm} and @code{typeof} keywords,
2565since @code{inline} is a standard keyword in ISO C99. In C2X mode
2566(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2567the @code{asm} keyword, since @code{typeof} is a standard keyword in
2568ISO C2X.
2569
d77de738
ML
2570@opindex fno-builtin
2571@opindex fbuiltin
f33d7a88 2572@cindex built-in functions
ddf6fe37
AA
2573@item -fno-builtin
2574@itemx -fno-builtin-@var{function}
d77de738
ML
2575Don't recognize built-in functions that do not begin with
2576@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2577functions provided by GCC}, for details of the functions affected,
2578including those which are not built-in functions when @option{-ansi} or
2579@option{-std} options for strict ISO C conformance are used because they
2580do not have an ISO standard meaning.
2581
2582GCC normally generates special code to handle certain built-in functions
2583more efficiently; for instance, calls to @code{alloca} may become single
2584instructions which adjust the stack directly, and calls to @code{memcpy}
2585may become inline copy loops. The resulting code is often both smaller
2586and faster, but since the function calls no longer appear as such, you
2587cannot set a breakpoint on those calls, nor can you change the behavior
2588of the functions by linking with a different library. In addition,
2589when a function is recognized as a built-in function, GCC may use
2590information about that function to warn about problems with calls to
2591that function, or to generate more efficient code, even if the
2592resulting code still contains calls to that function. For example,
2593warnings are given with @option{-Wformat} for bad calls to
2594@code{printf} when @code{printf} is built in and @code{strlen} is
2595known not to modify global memory.
2596
2597With the @option{-fno-builtin-@var{function}} option
2598only the built-in function @var{function} is
2599disabled. @var{function} must not begin with @samp{__builtin_}. If a
2600function is named that is not built-in in this version of GCC, this
2601option is ignored. There is no corresponding
2602@option{-fbuiltin-@var{function}} option; if you wish to enable
2603built-in functions selectively when using @option{-fno-builtin} or
2604@option{-ffreestanding}, you may define macros such as:
2605
2606@smallexample
2607#define abs(n) __builtin_abs ((n))
2608#define strcpy(d, s) __builtin_strcpy ((d), (s))
2609@end smallexample
2610
d77de738 2611@opindex fcond-mismatch
ddf6fe37 2612@item -fcond-mismatch
d77de738
ML
2613Allow conditional expressions with mismatched types in the second and
2614third arguments. The value of such an expression is void. This option
2615is not supported for C++.
2616
d77de738
ML
2617@opindex ffreestanding
2618@cindex hosted environment
f33d7a88 2619@item -ffreestanding
d77de738
ML
2620
2621Assert that compilation targets a freestanding environment. This
2622implies @option{-fno-builtin}. A freestanding environment
2623is one in which the standard library may not exist, and program startup may
2624not necessarily be at @code{main}. The most obvious example is an OS kernel.
2625This is equivalent to @option{-fno-hosted}.
2626
2627@xref{Standards,,Language Standards Supported by GCC}, for details of
2628freestanding and hosted environments.
2629
d77de738 2630@opindex fgimple
ddf6fe37 2631@item -fgimple
d77de738
ML
2632
2633Enable parsing of function definitions marked with @code{__GIMPLE}.
2634This is an experimental feature that allows unit testing of GIMPLE
2635passes.
2636
d77de738 2637@opindex fgnu-tm
ddf6fe37 2638@item -fgnu-tm
d77de738
ML
2639When the option @option{-fgnu-tm} is specified, the compiler
2640generates code for the Linux variant of Intel's current Transactional
2641Memory ABI specification document (Revision 1.1, May 6 2009). This is
2642an experimental feature whose interface may change in future versions
2643of GCC, as the official specification changes. Please note that not
2644all architectures are supported for this feature.
2645
2646For more information on GCC's support for transactional memory,
2647@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2648Transactional Memory Library}.
2649
2650Note that the transactional memory feature is not supported with
2651non-call exceptions (@option{-fnon-call-exceptions}).
2652
d77de738 2653@opindex fgnu89-inline
ddf6fe37 2654@item -fgnu89-inline
d77de738
ML
2655The option @option{-fgnu89-inline} tells GCC to use the traditional
2656GNU semantics for @code{inline} functions when in C99 mode.
2657@xref{Inline,,An Inline Function is As Fast As a Macro}.
2658Using this option is roughly equivalent to adding the
2659@code{gnu_inline} function attribute to all inline functions
2660(@pxref{Function Attributes}).
2661
2662The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2663C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2664specifies the default behavior).
2665This option is not supported in @option{-std=c90} or
2666@option{-std=gnu90} mode.
2667
2668The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2669@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2670in effect for @code{inline} functions. @xref{Common Predefined
2671Macros,,,cpp,The C Preprocessor}.
2672
d77de738
ML
2673@opindex fhosted
2674@cindex hosted environment
f33d7a88 2675@item -fhosted
d77de738
ML
2676
2677Assert that compilation targets a hosted environment. This implies
2678@option{-fbuiltin}. A hosted environment is one in which the
2679entire standard library is available, and in which @code{main} has a return
2680type of @code{int}. Examples are nearly everything except a kernel.
2681This is equivalent to @option{-fno-freestanding}.
2682
d77de738 2683@opindex flax-vector-conversions
ddf6fe37 2684@item -flax-vector-conversions
d77de738
ML
2685Allow implicit conversions between vectors with differing numbers of
2686elements and/or incompatible element types. This option should not be
2687used for new code.
2688
d77de738 2689@opindex fms-extensions
ddf6fe37 2690@item -fms-extensions
d77de738
ML
2691Accept some non-standard constructs used in Microsoft header files.
2692
2693In C++ code, this allows member names in structures to be similar
2694to previous types declarations.
2695
2696@smallexample
2697typedef int UOW;
2698struct ABC @{
2699 UOW UOW;
2700@};
2701@end smallexample
2702
2703Some cases of unnamed fields in structures and unions are only
2704accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2705fields within structs/unions}, for details.
2706
2707Note that this option is off for all targets except for x86
2708targets using ms-abi.
2709
ddf6fe37 2710@opindex foffload
d77de738
ML
2711@cindex Offloading targets
2712@cindex OpenACC offloading targets
2713@cindex OpenMP offloading targets
f33d7a88
AA
2714@item -foffload=disable
2715@itemx -foffload=default
2716@itemx -foffload=@var{target-list}
d77de738
ML
2717Specify for which OpenMP and OpenACC offload targets code should be generated.
2718The default behavior, equivalent to @option{-foffload=default}, is to generate
2719code for all supported offload targets. The @option{-foffload=disable} form
2720generates code only for the host fallback, while
2721@option{-foffload=@var{target-list}} generates code only for the specified
2722comma-separated list of offload targets.
2723
2724Offload targets are specified in GCC's internal target-triplet format. You can
2725run the compiler with @option{-v} to show the list of configured offload targets
2726under @code{OFFLOAD_TARGET_NAMES}.
2727
ddf6fe37 2728@opindex foffload-options
d77de738
ML
2729@cindex Offloading options
2730@cindex OpenACC offloading options
2731@cindex OpenMP offloading options
f33d7a88
AA
2732@item -foffload-options=@var{options}
2733@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2734
2735With @option{-foffload-options=@var{options}}, GCC passes the specified
2736@var{options} to the compilers for all enabled offloading targets. You can
2737specify options that apply only to a specific target or targets by using
2738the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2739@var{target-list} is a comma-separated list in the same format as for the
2740@option{-foffload=} option.
2741
2742Typical command lines are
2743
2744@smallexample
4bcb46b3 2745-foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic
e9c1679c 2746-foffload-options=amdgcn-amdhsa=-march=gfx906
d77de738
ML
2747@end smallexample
2748
d77de738
ML
2749@opindex fopenacc
2750@cindex OpenACC accelerator programming
f33d7a88 2751@item -fopenacc
643a5223
TB
2752Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
2753@samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
2754@samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified,
2755the compiler generates accelerated code according to the OpenACC Application
d77de738
ML
2756Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2757implies @option{-pthread}, and thus is only supported on targets that
2758have support for @option{-pthread}.
2759
d77de738
ML
2760@opindex fopenacc-dim
2761@cindex OpenACC accelerator programming
f33d7a88 2762@item -fopenacc-dim=@var{geom}
d77de738
ML
2763Specify default compute dimensions for parallel offload regions that do
2764not explicitly specify. The @var{geom} value is a triple of
2765':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2766can be omitted, to use a target-specific default value.
2767
d77de738
ML
2768@opindex fopenmp
2769@cindex OpenMP parallel
f33d7a88 2770@item -fopenmp
643a5223
TB
2771Enable handling of OpenMP directives @samp{#pragma omp} in C/C++,
2772@samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and
2773@samp{[[omp::decl(...)]]} in C++ and @samp{!$omp} in Fortran. It
2774additionally enables the conditional compilation sentinel @samp{!$} in
2775Fortran. In fixed source form Fortran, the sentinels can also start with
2776@samp{c} or @samp{*}. When @option{-fopenmp} is specified, the
d77de738
ML
2777compiler generates parallel code according to the OpenMP Application
2778Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2779implies @option{-pthread}, and thus is only supported on targets that
2780have support for @option{-pthread}. @option{-fopenmp} implies
2781@option{-fopenmp-simd}.
2782
d77de738
ML
2783@opindex fopenmp-simd
2784@cindex OpenMP SIMD
2785@cindex SIMD
f33d7a88 2786@item -fopenmp-simd
d77de738 2787Enable handling of OpenMP's @code{simd}, @code{declare simd},
1fab441d
TB
2788@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
2789and @code{loop} directive, and of combined or composite directives with
d77de738 2790@code{simd} as constituent with @code{#pragma omp} in C/C++,
1fab441d 2791@code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
643a5223
TB
2792@code{[[omp::decl(...)]]} in C++ and @code{!$omp} in Fortran. It
2793additionally enables the conditional compilation sentinel @samp{!$} in
2794Fortran. In fixed source form Fortran, the sentinels can also start with
2795@samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
2796@option{-fopenmp} is additionally specified, the @code{loop} region binds
2797to the current task region, independent of the specified @code{bind} clause.
d77de738 2798
ddf6fe37 2799@opindex fopenmp-target-simd-clone
f33d7a88 2800@cindex OpenMP target SIMD clone
309e2d95
SL
2801@item -fopenmp-target-simd-clone
2802@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2803In addition to generating SIMD clones for functions marked with the
2804@code{declare simd} directive, GCC also generates clones
2805for functions marked with the OpenMP @code{declare target} directive
2806that are suitable for vectorization when this option is in effect. The
2807@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2808and @code{any}, which correspond to keywords for the @code{device_type}
2809clause of the @code{declare target} directive; clones are generated for
2810the intersection of devices specified.
2811@option{-fopenmp-target-simd-clone} is equivalent to
2812@option{-fopenmp-target-simd-clone=any} and
2813@option{-fno-openmp-target-simd-clone} is equivalent to
2814@option{-fopenmp-target-simd-clone=none}.
2815
2816At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2817optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2818it is disabled by default.
2819
d77de738
ML
2820@opindex fpermitted-flt-eval-methods
2821@opindex fpermitted-flt-eval-methods=c11
2822@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2823@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2824ISO/IEC TS 18661-3 defines new permissible values for
2825@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2826a semantic type that is an interchange or extended format should be
2827evaluated to the precision and range of that type. These new values are
2828a superset of those permitted under C99/C11, which does not specify the
2829meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2830conforming to C11 may not have been written expecting the possibility of
2831the new values.
2832
2833@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2834should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2835or the extended set of values specified in ISO/IEC TS 18661-3.
2836
2837@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2838
2839The default when in a standards compliant mode (@option{-std=c11} or similar)
2840is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2841dialect (@option{-std=gnu11} or similar) is
2842@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2843
024f135a
BB
2844@opindex fdeps-
2845The @samp{-fdeps-*} options are used to extract structured dependency
2846information for a source. This involves determining what resources provided by
2847other source files will be required to compile the source as well as what
2848resources are provided by the source. This information can be used to add
2849required dependencies between compilation rules of dependent sources based on
2850their contents rather than requiring such information be reflected within the
2851build tools as well.
2852
2853@opindex fdeps-file
2854@item -fdeps-file=@var{file}
2855Where to write structured dependency information.
2856
2857@opindex fdeps-format
2858@item -fdeps-format=@var{format}
2859The format to use for structured dependency information. @samp{p1689r5} is the
2860only supported format right now. Note that when this argument is specified, the
2861output of @samp{-MF} is stripped of some information (namely C++ modules) so
2862that it does not use extended makefile syntax not understood by most tools.
2863
2864@opindex fdeps-target
2865@item -fdeps-target=@var{file}
2866Analogous to @option{-MT} but for structured dependency information. This
2867indicates the target which will ultimately need any required resources and
2868provide any resources extracted from the source that may be required by other
2869sources.
2870
d77de738 2871@opindex fplan9-extensions
ddf6fe37 2872@item -fplan9-extensions
d77de738
ML
2873Accept some non-standard constructs used in Plan 9 code.
2874
2875This enables @option{-fms-extensions}, permits passing pointers to
2876structures with anonymous fields to functions that expect pointers to
2877elements of the type of the field, and permits referring to anonymous
2878fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2879struct/union fields within structs/unions}, for details. This is only
2880supported for C, not C++.
2881
d77de738
ML
2882@opindex fsigned-bitfields
2883@opindex funsigned-bitfields
2884@opindex fno-signed-bitfields
2885@opindex fno-unsigned-bitfields
ddf6fe37
AA
2886@item -fsigned-bitfields
2887@itemx -funsigned-bitfields
2888@itemx -fno-signed-bitfields
2889@itemx -fno-unsigned-bitfields
d77de738
ML
2890These options control whether a bit-field is signed or unsigned, when the
2891declaration does not use either @code{signed} or @code{unsigned}. By
2892default, such a bit-field is signed, because this is consistent: the
2893basic integer types such as @code{int} are signed types.
2894
d77de738 2895@opindex fsigned-char
ddf6fe37 2896@item -fsigned-char
d77de738
ML
2897Let the type @code{char} be signed, like @code{signed char}.
2898
2899Note that this is equivalent to @option{-fno-unsigned-char}, which is
2900the negative form of @option{-funsigned-char}. Likewise, the option
2901@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2902
d77de738 2903@opindex funsigned-char
ddf6fe37 2904@item -funsigned-char
d77de738
ML
2905Let the type @code{char} be unsigned, like @code{unsigned char}.
2906
2907Each kind of machine has a default for what @code{char} should
2908be. It is either like @code{unsigned char} by default or like
2909@code{signed char} by default.
2910
2911Ideally, a portable program should always use @code{signed char} or
2912@code{unsigned char} when it depends on the signedness of an object.
2913But many programs have been written to use plain @code{char} and
2914expect it to be signed, or expect it to be unsigned, depending on the
2915machines they were written for. This option, and its inverse, let you
2916make such a program work with the opposite default.
2917
2918The type @code{char} is always a distinct type from each of
2919@code{signed char} or @code{unsigned char}, even though its behavior
2920is always just like one of those two.
2921
d77de738
ML
2922@opindex fstrict-flex-arrays
2923@opindex fno-strict-flex-arrays
ddf6fe37 2924@item -fstrict-flex-arrays
d77de738
ML
2925Control when to treat the trailing array of a structure as a flexible array
2926member for the purpose of accessing the elements of such an array.
2927The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2928strictest. A trailing array is treated as a flexible array member only when it
2929is declared as a flexible array member per C99 standard onwards.
2930The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2931least strict. All trailing arrays of structures are treated as flexible array
2932members.
2933
d77de738 2934@opindex fstrict-flex-arrays=@var{level}
ddf6fe37 2935@item -fstrict-flex-arrays=@var{level}
d77de738
ML
2936Control when to treat the trailing array of a structure as a flexible array
2937member for the purpose of accessing the elements of such an array. The value
2938of @var{level} controls the level of strictness.
2939
2940The possible values of @var{level} are the same as for the
2941@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2942
2943You can control this behavior for a specific trailing array field of a
2944structure by using the variable attribute @code{strict_flex_array} attribute
2945(@pxref{Variable Attributes}).
2946
d77de738 2947@opindex fsso-struct
ddf6fe37 2948@item -fsso-struct=@var{endianness}
d77de738
ML
2949Set the default scalar storage order of structures and unions to the
2950specified endianness. The accepted values are @samp{big-endian},
2951@samp{little-endian} and @samp{native} for the native endianness of
2952the target (the default). This option is not supported for C++.
2953
2954@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2955code that is not binary compatible with code generated without it if the
2956specified endianness is not the native endianness of the target.
2957@end table
2958
2959@node C++ Dialect Options
2960@section Options Controlling C++ Dialect
2961
2962@cindex compiler options, C++
2963@cindex C++ options, command-line
2964@cindex options, C++
2965This section describes the command-line options that are only meaningful
2966for C++ programs. You can also use most of the GNU compiler options
2967regardless of what language your program is in. For example, you
2968might compile a file @file{firstClass.C} like this:
2969
2970@smallexample
2971g++ -g -fstrict-enums -O -c firstClass.C
2972@end smallexample
2973
2974@noindent
2975In this example, only @option{-fstrict-enums} is an option meant
2976only for C++ programs; you can use the other options with any
2977language supported by GCC@.
2978
2979Some options for compiling C programs, such as @option{-std}, are also
2980relevant for C++ programs.
2981@xref{C Dialect Options,,Options Controlling C Dialect}.
2982
2983Here is a list of options that are @emph{only} for compiling C++ programs:
2984
2985@table @gcctabopt
2986
d77de738 2987@opindex fabi-version
ddf6fe37 2988@item -fabi-version=@var{n}
d77de738
ML
2989Use version @var{n} of the C++ ABI@. The default is version 0.
2990
2991Version 0 refers to the version conforming most closely to
2992the C++ ABI specification. Therefore, the ABI obtained using version 0
2993will change in different versions of G++ as ABI bugs are fixed.
2994
2995Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2996
2997Version 2 is the version of the C++ ABI that first appeared in G++
29983.4, and was the default through G++ 4.9.
2999
3000Version 3 corrects an error in mangling a constant address as a
3001template argument.
3002
3003Version 4, which first appeared in G++ 4.5, implements a standard
3004mangling for vector types.
3005
3006Version 5, which first appeared in G++ 4.6, corrects the mangling of
3007attribute const/volatile on function pointer types, decltype of a
3008plain decl, and use of a function parameter in the declaration of
3009another parameter.
3010
3011Version 6, which first appeared in G++ 4.7, corrects the promotion
3012behavior of C++11 scoped enums and the mangling of template argument
3013packs, const/static_cast, prefix ++ and --, and a class scope function
3014used as a template argument.
3015
3016Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
3017builtin type and corrects the mangling of lambdas in default argument
3018scope.
3019
3020Version 8, which first appeared in G++ 4.9, corrects the substitution
3021behavior of function types with function-cv-qualifiers.
3022
3023Version 9, which first appeared in G++ 5.2, corrects the alignment of
3024@code{nullptr_t}.
3025
3026Version 10, which first appeared in G++ 6.1, adds mangling of
3027attributes that affect type identity, such as ia32 calling convention
3028attributes (e.g.@: @samp{stdcall}).
3029
3030Version 11, which first appeared in G++ 7, corrects the mangling of
3031sizeof... expressions and operator names. For multiple entities with
3032the same name within a function, that are declared in different scopes,
3033the mangling now changes starting with the twelfth occurrence. It also
3034implies @option{-fnew-inheriting-ctors}.
3035
3036Version 12, which first appeared in G++ 8, corrects the calling
3037conventions for empty classes on the x86_64 target and for classes
3038with only deleted copy/move constructors. It accidentally changes the
3039calling convention for classes with a deleted copy constructor and a
3040trivial move constructor.
3041
3042Version 13, which first appeared in G++ 8.2, fixes the accidental
3043change in version 12.
3044
3045Version 14, which first appeared in G++ 10, corrects the mangling of
3046the nullptr expression.
3047
3048Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
3049tag regression.
3050
3051Version 16, which first appeared in G++ 11, changes the mangling of
3052@code{__alignof__} to be distinct from that of @code{alignof}, and
3053dependent operator names.
3054
3055Version 17, which first appeared in G++ 12, fixes layout of classes
3056that inherit from aggregate classes with default member initializers
3057in C++14 and up.
3058
3059Version 18, which first appeard in G++ 13, fixes manglings of lambdas
3060that have additional context.
3061
cd37325b
JJ
3062Version 19, which first appeard in G++ 14, fixes manglings of structured
3063bindings to include ABI tags.
3064
d77de738
ML
3065See also @option{-Wabi}.
3066
d77de738 3067@opindex fabi-compat-version
ddf6fe37 3068@item -fabi-compat-version=@var{n}
d77de738
ML
3069On targets that support strong aliases, G++
3070works around mangling changes by creating an alias with the correct
3071mangled name when defining a symbol with an incorrect mangled name.
3072This switch specifies which ABI version to use for the alias.
3073
3074With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3075compatibility). If another ABI version is explicitly selected, this
3076defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3077use @option{-fabi-compat-version=2}.
3078
3079If this option is not provided but @option{-Wabi=@var{n}} is, that
3080version is used for compatibility aliases. If this option is provided
3081along with @option{-Wabi} (without the version), the version from this
3082option is used for the warning.
3083
d77de738
ML
3084@opindex fno-access-control
3085@opindex faccess-control
ddf6fe37 3086@item -fno-access-control
d77de738
ML
3087Turn off all access checking. This switch is mainly useful for working
3088around bugs in the access control code.
3089
d77de738 3090@opindex faligned-new
ddf6fe37 3091@item -faligned-new
d77de738
ML
3092Enable support for C++17 @code{new} of types that require more
3093alignment than @code{void* ::operator new(std::size_t)} provides. A
3094numeric argument such as @code{-faligned-new=32} can be used to
3095specify how much alignment (in bytes) is provided by that function,
3096but few users will need to override the default of
3097@code{alignof(std::max_align_t)}.
3098
3099This flag is enabled by default for @option{-std=c++17}.
3100
d77de738
ML
3101@opindex fchar8_t
3102@opindex fno-char8_t
ddf6fe37
AA
3103@item -fchar8_t
3104@itemx -fno-char8_t
d77de738
ML
3105Enable support for @code{char8_t} as adopted for C++20. This includes
3106the addition of a new @code{char8_t} fundamental type, changes to the
3107types of UTF-8 string and character literals, new signatures for
3108user-defined literals, associated standard library updates, and new
3109@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3110
3111This option enables functions to be overloaded for ordinary and UTF-8
3112strings:
3113
3114@smallexample
3115int f(const char *); // #1
3116int f(const char8_t *); // #2
3117int v1 = f("text"); // Calls #1
3118int v2 = f(u8"text"); // Calls #2
3119@end smallexample
3120
3121@noindent
3122and introduces new signatures for user-defined literals:
3123
3124@smallexample
3125int operator""_udl1(char8_t);
3126int v3 = u8'x'_udl1;
3127int operator""_udl2(const char8_t*, std::size_t);
3128int v4 = u8"text"_udl2;
3129template<typename T, T...> int operator""_udl3();
3130int v5 = u8"text"_udl3;
3131@end smallexample
3132
3133@noindent
3134The change to the types of UTF-8 string and character literals introduces
3135incompatibilities with ISO C++11 and later standards. For example, the
3136following code is well-formed under ISO C++11, but is ill-formed when
3137@option{-fchar8_t} is specified.
3138
3139@smallexample
d77de738
ML
3140const char *cp = u8"xx";// error: invalid conversion from
3141 // `const char8_t*' to `const char*'
3142int f(const char*);
3143auto v = f(u8"xx"); // error: invalid conversion from
3144 // `const char8_t*' to `const char*'
3145std::string s@{u8"xx"@}; // error: no matching function for call to
3146 // `std::basic_string<char>::basic_string()'
3147using namespace std::literals;
3148s = u8"xx"s; // error: conversion from
3149 // `basic_string<char8_t>' to non-scalar
3150 // type `basic_string<char>' requested
3151@end smallexample
3152
d77de738 3153@opindex fcheck-new
ddf6fe37 3154@item -fcheck-new
d77de738
ML
3155Check that the pointer returned by @code{operator new} is non-null
3156before attempting to modify the storage allocated. This check is
3157normally unnecessary because the C++ standard specifies that
3158@code{operator new} only returns @code{0} if it is declared
3159@code{throw()}, in which case the compiler always checks the
3160return value even without this option. In all other cases, when
3161@code{operator new} has a non-empty exception specification, memory
3162exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3163@samp{new (nothrow)}.
3164
d77de738
ML
3165@opindex fconcepts
3166@opindex fconcepts-ts
ddf6fe37
AA
3167@item -fconcepts
3168@itemx -fconcepts-ts
d77de738
ML
3169Enable support for the C++ Concepts feature for constraining template
3170arguments. With @option{-std=c++20} and above, Concepts are part of
3171the language standard, so @option{-fconcepts} defaults to on.
3172
3173Some constructs that were allowed by the earlier C++ Extensions for
3174Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3175into the standard, can additionally be enabled by
3176@option{-fconcepts-ts}.
3177
d77de738 3178@opindex fconstexpr-depth
ddf6fe37 3179@item -fconstexpr-depth=@var{n}
d77de738
ML
3180Set the maximum nested evaluation depth for C++11 constexpr functions
3181to @var{n}. A limit is needed to detect endless recursion during
3182constant expression evaluation. The minimum specified by the standard
3183is 512.
3184
d77de738 3185@opindex fconstexpr-cache-depth
ddf6fe37 3186@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3187Set the maximum level of nested evaluation depth for C++11 constexpr
3188functions that will be cached to @var{n}. This is a heuristic that
3189trades off compilation speed (when the cache avoids repeated
3190calculations) against memory consumption (when the cache grows very
3191large from highly recursive evaluations). The default is 8. Very few
3192users are likely to want to adjust it, but if your code does heavy
3193constexpr calculations you might want to experiment to find which
3194value works best for you.
3195
d77de738 3196@opindex fconstexpr-fp-except
ddf6fe37 3197@item -fconstexpr-fp-except
d77de738
ML
3198Annex F of the C standard specifies that IEC559 floating point
3199exceptions encountered at compile time should not stop compilation.
3200C++ compilers have historically not followed this guidance, instead
3201treating floating point division by zero as non-constant even though
3202it has a well defined value. This flag tells the compiler to give
3203Annex F priority over other rules saying that a particular operation
3204is undefined.
3205
3206@smallexample
3207constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3208@end smallexample
3209
d77de738 3210@opindex fconstexpr-loop-limit
ddf6fe37 3211@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3212Set the maximum number of iterations for a loop in C++14 constexpr functions
3213to @var{n}. A limit is needed to detect infinite loops during
3214constant expression evaluation. The default is 262144 (1<<18).
3215
d77de738 3216@opindex fconstexpr-ops-limit
ddf6fe37 3217@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3218Set the maximum number of operations during a single constexpr evaluation.
3219Even when number of iterations of a single loop is limited with the above limit,
3220if there are several nested loops and each of them has many iterations but still
3221smaller than the above limit, or if in a body of some loop or even outside
3222of a loop too many expressions need to be evaluated, the resulting constexpr
3223evaluation might take too long.
3224The default is 33554432 (1<<25).
3225
2efb237f 3226@opindex fcontracts
ddf6fe37 3227@item -fcontracts
2efb237f
JCI
3228Enable experimental support for the C++ Contracts feature, as briefly
3229added to and then removed from the C++20 working paper (N4820). The
3230implementation also includes proposed enhancements from papers P1290,
3231P1332, and P1429. This functionality is intended mostly for those
3232interested in experimentation towards refining the feature to get it
3233into shape for a future C++ standard.
3234
3235On violation of a checked contract, the violation handler is called.
3236Users can replace the violation handler by defining
3237@smallexample
4ace81b6
SL
3238void
3239handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3240@end smallexample
3241
3242There are different sets of additional flags that can be used together
3243to specify which contracts will be checked and how, for N4820
3244contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3245used together.
3246
3247@table @gcctabopt
2efb237f 3248@opindex fcontract-mode
ddf6fe37 3249@item -fcontract-mode=[on|off]
2efb237f
JCI
3250Control whether any contracts have any semantics at all. Defaults to on.
3251
2efb237f 3252@opindex fcontract-assumption-mode
ddf6fe37 3253@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3254[N4820] Control whether contracts with level @samp{axiom}
3255should have the assume semantic. Defaults to on.
3256
2efb237f 3257@opindex fcontract-build-level
ddf6fe37 3258@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3259[N4820] Specify which level of contracts to generate checks
3260for. Defaults to @samp{default}.
3261
2efb237f 3262@opindex fcontract-continuation-mode
ddf6fe37 3263@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3264[N4820] Control whether to allow the program to continue executing
3265after a contract violation. That is, do checked contracts have the
3266@samp{maybe} semantic described below rather than the @samp{never}
3267semantic. Defaults to off.
3268
2efb237f 3269@opindex fcontract-role
ddf6fe37 3270@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3271[P1332] Specify the concrete semantics for each contract level
3272of a particular contract role.
3273
3274@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3275[P1429] Specify the concrete semantic for a particular
3276contract level.
3277
2efb237f 3278@opindex fcontract-strict-declarations
ddf6fe37 3279@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3280Control whether to reject adding contracts to a function after its
3281first declaration. Defaults to off.
3282@end table
3283
3284The possible concrete semantics for that can be specified with
3285@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3286
3287@table @code
3288@item ignore
3289This contract has no effect.
3290
3291@item assume
3292This contract is treated like C++23 @code{[[assume]]}.
3293
3294@item check_never_continue
3295@itemx never
3296@itemx abort
3297This contract is checked. If it fails, the violation handler is
3298called. If the handler returns, @code{std::terminate} is called.
3299
3300@item check_maybe_continue
3301@itemx maybe
3302This contract is checked. If it fails, the violation handler is
3303called. If the handler returns, execution continues normally.
3304@end table
3305
d77de738 3306@opindex fcoroutines
ddf6fe37 3307@item -fcoroutines
d77de738
ML
3308Enable support for the C++ coroutines extension (experimental).
3309
d77de738
ML
3310@opindex fno-elide-constructors
3311@opindex felide-constructors
ddf6fe37 3312@item -fno-elide-constructors
d77de738
ML
3313The C++ standard allows an implementation to omit creating a temporary
3314that is only used to initialize another object of the same type.
3315Specifying this option disables that optimization, and forces G++ to
3316call the copy constructor in all cases. This option also causes G++
3317to call trivial member functions which otherwise would be expanded inline.
3318
3319In C++17, the compiler is required to omit these temporaries, but this
3320option still affects trivial member functions.
3321
d77de738
ML
3322@opindex fno-enforce-eh-specs
3323@opindex fenforce-eh-specs
ddf6fe37 3324@item -fno-enforce-eh-specs
d77de738
ML
3325Don't generate code to check for violation of exception specifications
3326at run time. This option violates the C++ standard, but may be useful
3327for reducing code size in production builds, much like defining
3328@code{NDEBUG}. This does not give user code permission to throw
3329exceptions in violation of the exception specifications; the compiler
3330still optimizes based on the specifications, so throwing an
3331unexpected exception results in undefined behavior at run time.
3332
d77de738
ML
3333@opindex fextern-tls-init
3334@opindex fno-extern-tls-init
ddf6fe37
AA
3335@item -fextern-tls-init
3336@itemx -fno-extern-tls-init
d77de738
ML
3337The C++11 and OpenMP standards allow @code{thread_local} and
3338@code{threadprivate} variables to have dynamic (runtime)
3339initialization. To support this, any use of such a variable goes
3340through a wrapper function that performs any necessary initialization.
3341When the use and definition of the variable are in the same
3342translation unit, this overhead can be optimized away, but when the
3343use is in a different translation unit there is significant overhead
3344even if the variable doesn't actually need dynamic initialization. If
3345the programmer can be sure that no use of the variable in a
3346non-defining TU needs to trigger dynamic initialization (either
3347because the variable is statically initialized, or a use of the
3348variable in the defining TU will be executed before any uses in
3349another TU), they can avoid this overhead with the
3350@option{-fno-extern-tls-init} option.
3351
3352On targets that support symbol aliases, the default is
3353@option{-fextern-tls-init}. On targets that do not support symbol
3354aliases, the default is @option{-fno-extern-tls-init}.
3355
d77de738
ML
3356@opindex ffold-simple-inlines
3357@opindex fno-fold-simple-inlines
ddf6fe37
AA
3358@item -ffold-simple-inlines
3359@itemx -fno-fold-simple-inlines
d77de738
ML
3360Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3361@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3362means no debug information will be generated for such calls. Since these
3363functions are rarely interesting to debug, this flag is enabled by default
3364unless @option{-fno-inline} is active.
3365
d77de738
ML
3366@opindex fno-gnu-keywords
3367@opindex fgnu-keywords
ddf6fe37 3368@item -fno-gnu-keywords
d77de738
ML
3369Do not recognize @code{typeof} as a keyword, so that code can use this
3370word as an identifier. You can use the keyword @code{__typeof__} instead.
3371This option is implied by the strict ISO C++ dialects: @option{-ansi},
3372@option{-std=c++98}, @option{-std=c++11}, etc.
3373
d77de738 3374@opindex fimplicit-constexpr
ddf6fe37 3375@item -fimplicit-constexpr
d77de738
ML
3376Make inline functions implicitly constexpr, if they satisfy the
3377requirements for a constexpr function. This option can be used in
3378C++14 mode or later. This can result in initialization changing from
3379dynamic to static and other optimizations.
3380
d77de738
ML
3381@opindex fno-implicit-templates
3382@opindex fimplicit-templates
ddf6fe37 3383@item -fno-implicit-templates
d77de738
ML
3384Never emit code for non-inline templates that are instantiated
3385implicitly (i.e.@: by use); only emit code for explicit instantiations.
3386If you use this option, you must take care to structure your code to
3387include all the necessary explicit instantiations to avoid getting
3388undefined symbols at link time.
3389@xref{Template Instantiation}, for more information.
3390
d77de738
ML
3391@opindex fno-implicit-inline-templates
3392@opindex fimplicit-inline-templates
ddf6fe37 3393@item -fno-implicit-inline-templates
d77de738
ML
3394Don't emit code for implicit instantiations of inline templates, either.
3395The default is to handle inlines differently so that compiles with and
3396without optimization need the same set of explicit instantiations.
3397
d77de738
ML
3398@opindex fno-implement-inlines
3399@opindex fimplement-inlines
ddf6fe37 3400@item -fno-implement-inlines
d77de738
ML
3401To save space, do not emit out-of-line copies of inline functions
3402controlled by @code{#pragma implementation}. This causes linker
3403errors if these functions are not inlined everywhere they are called.
3404
d77de738
ML
3405@opindex fmodules-ts
3406@opindex fno-modules-ts
ddf6fe37
AA
3407@item -fmodules-ts
3408@itemx -fno-modules-ts
d77de738
ML
3409Enable support for C++20 modules (@pxref{C++ Modules}). The
3410@option{-fno-modules-ts} is usually not needed, as that is the
3411default. Even though this is a C++20 feature, it is not currently
3412implicitly enabled by selecting that standard version.
3413
ddf6fe37 3414@opindex fmodule-header
d77de738
ML
3415@item -fmodule-header
3416@itemx -fmodule-header=user
3417@itemx -fmodule-header=system
d77de738
ML
3418Compile a header file to create an importable header unit.
3419
d77de738 3420@opindex fmodule-implicit-inline
ddf6fe37 3421@item -fmodule-implicit-inline
d77de738
ML
3422Member functions defined in their class definitions are not implicitly
3423inline for modular code. This is different to traditional C++
3424behavior, for good reasons. However, it may result in a difficulty
3425during code porting. This option makes such function definitions
3426implicitly inline. It does however generate an ABI incompatibility,
3427so you must use it everywhere or nowhere. (Such definitions outside
3428of a named module remain implicitly inline, regardless.)
3429
d77de738
ML
3430@opindex fno-module-lazy
3431@opindex fmodule-lazy
ddf6fe37 3432@item -fno-module-lazy
d77de738
ML
3433Disable lazy module importing and module mapper creation.
3434
f33d7a88
AA
3435@vindex CXX_MODULE_MAPPER @r{environment variable}
3436@opindex fmodule-mapper
d77de738
ML
3437@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3438@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3439@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3440@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3441@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3442@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3443An oracle to query for module name to filename mappings. If
3444unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3445and if that is unset, an in-process default is provided.
3446
d77de738 3447@opindex fmodule-only
ddf6fe37 3448@item -fmodule-only
d77de738
ML
3449Only emit the Compiled Module Interface, inhibiting any object file.
3450
d77de738 3451@opindex fms-extensions
ddf6fe37 3452@item -fms-extensions
d77de738
ML
3453Disable Wpedantic warnings about constructs used in MFC, such as implicit
3454int and getting a pointer to member function via non-standard syntax.
3455
d77de738 3456@opindex fnew-inheriting-ctors
ddf6fe37 3457@item -fnew-inheriting-ctors
d77de738
ML
3458Enable the P0136 adjustment to the semantics of C++11 constructor
3459inheritance. This is part of C++17 but also considered to be a Defect
3460Report against C++11 and C++14. This flag is enabled by default
3461unless @option{-fabi-version=10} or lower is specified.
3462
d77de738 3463@opindex fnew-ttp-matching
ddf6fe37 3464@item -fnew-ttp-matching
d77de738
ML
3465Enable the P0522 resolution to Core issue 150, template template
3466parameters and default arguments: this allows a template with default
3467template arguments as an argument for a template template parameter
3468with fewer template parameters. This flag is enabled by default for
3469@option{-std=c++17}.
3470
d77de738
ML
3471@opindex fno-nonansi-builtins
3472@opindex fnonansi-builtins
ddf6fe37 3473@item -fno-nonansi-builtins
d77de738
ML
3474Disable built-in declarations of functions that are not mandated by
3475ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3476@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3477
d77de738 3478@opindex fnothrow-opt
ddf6fe37 3479@item -fnothrow-opt
d77de738
ML
3480Treat a @code{throw()} exception specification as if it were a
3481@code{noexcept} specification to reduce or eliminate the text size
3482overhead relative to a function with no exception specification. If
3483the function has local variables of types with non-trivial
3484destructors, the exception specification actually makes the
3485function smaller because the EH cleanups for those variables can be
3486optimized away. The semantic effect is that an exception thrown out of
3487a function with such an exception specification results in a call
3488to @code{terminate} rather than @code{unexpected}.
3489
d77de738
ML
3490@opindex fno-operator-names
3491@opindex foperator-names
ddf6fe37 3492@item -fno-operator-names
d77de738
ML
3493Do not treat the operator name keywords @code{and}, @code{bitand},
3494@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3495synonyms as keywords.
3496
d77de738
ML
3497@opindex fno-optional-diags
3498@opindex foptional-diags
ddf6fe37 3499@item -fno-optional-diags
d77de738
ML
3500Disable diagnostics that the standard says a compiler does not need to
3501issue. Currently, the only such diagnostic issued by G++ is the one for
3502a name having multiple meanings within a class.
3503
d77de738
ML
3504@opindex fno-pretty-templates
3505@opindex fpretty-templates
ddf6fe37 3506@item -fno-pretty-templates
d77de738
ML
3507When an error message refers to a specialization of a function
3508template, the compiler normally prints the signature of the
3509template followed by the template arguments and any typedefs or
3510typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3511rather than @code{void f(int)}) so that it's clear which template is
3512involved. When an error message refers to a specialization of a class
3513template, the compiler omits any template arguments that match
3514the default template arguments for that template. If either of these
3515behaviors make it harder to understand the error message rather than
3516easier, you can use @option{-fno-pretty-templates} to disable them.
3517
d77de738
ML
3518@opindex fno-rtti
3519@opindex frtti
ddf6fe37 3520@item -fno-rtti
d77de738
ML
3521Disable generation of information about every class with virtual
3522functions for use by the C++ run-time type identification features
3523(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3524of the language, you can save some space by using this flag. Note that
3525exception handling uses the same information, but G++ generates it as
3526needed. The @code{dynamic_cast} operator can still be used for casts that
3527do not require run-time type information, i.e.@: casts to @code{void *} or to
3528unambiguous base classes.
3529
3530Mixing code compiled with @option{-frtti} with that compiled with
3531@option{-fno-rtti} may not work. For example, programs may
3532fail to link if a class compiled with @option{-fno-rtti} is used as a base
3533for a class compiled with @option{-frtti}.
3534
d77de738 3535@opindex fsized-deallocation
ddf6fe37 3536@item -fsized-deallocation
d77de738
ML
3537Enable the built-in global declarations
3538@smallexample
3539void operator delete (void *, std::size_t) noexcept;
3540void operator delete[] (void *, std::size_t) noexcept;
3541@end smallexample
3542as introduced in C++14. This is useful for user-defined replacement
3543deallocation functions that, for example, use the size of the object
3544to make deallocation faster. Enabled by default under
3545@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3546warns about places that might want to add a definition.
3547
d77de738 3548@opindex fstrict-enums
ddf6fe37 3549@item -fstrict-enums
d77de738
ML
3550Allow the compiler to optimize using the assumption that a value of
3551enumerated type can only be one of the values of the enumeration (as
3552defined in the C++ standard; basically, a value that can be
3553represented in the minimum number of bits needed to represent all the
3554enumerators). This assumption may not be valid if the program uses a
3555cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3556This option has no effect for an enumeration type with a fixed underlying
3557type.
d77de738 3558
d77de738 3559@opindex fstrong-eval-order
ddf6fe37 3560@item -fstrong-eval-order
d77de738
ML
3561Evaluate member access, array subscripting, and shift expressions in
3562left-to-right order, and evaluate assignment in right-to-left order,
3563as adopted for C++17. Enabled by default with @option{-std=c++17}.
3564@option{-fstrong-eval-order=some} enables just the ordering of member
3565access and shift expressions, and is the default without
3566@option{-std=c++17}.
3567
d77de738 3568@opindex ftemplate-backtrace-limit
ddf6fe37 3569@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3570Set the maximum number of template instantiation notes for a single
3571warning or error to @var{n}. The default value is 10.
3572
d77de738 3573@opindex ftemplate-depth
ddf6fe37 3574@item -ftemplate-depth=@var{n}
d77de738
ML
3575Set the maximum instantiation depth for template classes to @var{n}.
3576A limit on the template instantiation depth is needed to detect
3577endless recursions during template class instantiation. ANSI/ISO C++
3578conforming programs must not rely on a maximum depth greater than 17
3579(changed to 1024 in C++11). The default value is 900, as the compiler
3580can run out of stack space before hitting 1024 in some situations.
3581
d77de738
ML
3582@opindex fno-threadsafe-statics
3583@opindex fthreadsafe-statics
ddf6fe37 3584@item -fno-threadsafe-statics
d77de738
ML
3585Do not emit the extra code to use the routines specified in the C++
3586ABI for thread-safe initialization of local statics. You can use this
3587option to reduce code size slightly in code that doesn't need to be
3588thread-safe.
3589
d77de738 3590@opindex fuse-cxa-atexit
ddf6fe37 3591@item -fuse-cxa-atexit
d77de738
ML
3592Register destructors for objects with static storage duration with the
3593@code{__cxa_atexit} function rather than the @code{atexit} function.
3594This option is required for fully standards-compliant handling of static
3595destructors, but only works if your C library supports
3596@code{__cxa_atexit}.
3597
d77de738
ML
3598@opindex fno-use-cxa-get-exception-ptr
3599@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3600@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3601Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3602causes @code{std::uncaught_exception} to be incorrect, but is necessary
3603if the runtime routine is not available.
3604
d77de738 3605@opindex fvisibility-inlines-hidden
ddf6fe37 3606@item -fvisibility-inlines-hidden
d77de738
ML
3607This switch declares that the user does not attempt to compare
3608pointers to inline functions or methods where the addresses of the two functions
3609are taken in different shared objects.
3610
3611The effect of this is that GCC may, effectively, mark inline methods with
3612@code{__attribute__ ((visibility ("hidden")))} so that they do not
3613appear in the export table of a DSO and do not require a PLT indirection
3614when used within the DSO@. Enabling this option can have a dramatic effect
3615on load and link times of a DSO as it massively reduces the size of the
3616dynamic export table when the library makes heavy use of templates.
3617
3618The behavior of this switch is not quite the same as marking the
3619methods as hidden directly, because it does not affect static variables
3620local to the function or cause the compiler to deduce that
3621the function is defined in only one shared object.
3622
3623You may mark a method as having a visibility explicitly to negate the
3624effect of the switch for that method. For example, if you do want to
3625compare pointers to a particular inline method, you might mark it as
3626having default visibility. Marking the enclosing class with explicit
3627visibility has no effect.
3628
3629Explicitly instantiated inline methods are unaffected by this option
3630as their linkage might otherwise cross a shared library boundary.
3631@xref{Template Instantiation}.
3632
d77de738 3633@opindex fvisibility-ms-compat
ddf6fe37 3634@item -fvisibility-ms-compat
d77de738
ML
3635This flag attempts to use visibility settings to make GCC's C++
3636linkage model compatible with that of Microsoft Visual Studio.
3637
3638The flag makes these changes to GCC's linkage model:
3639
3640@enumerate
3641@item
3642It sets the default visibility to @code{hidden}, like
3643@option{-fvisibility=hidden}.
3644
3645@item
3646Types, but not their members, are not hidden by default.
3647
3648@item
3649The One Definition Rule is relaxed for types without explicit
3650visibility specifications that are defined in more than one
3651shared object: those declarations are permitted if they are
3652permitted when this option is not used.
3653@end enumerate
3654
3655In new code it is better to use @option{-fvisibility=hidden} and
3656export those classes that are intended to be externally visible.
3657Unfortunately it is possible for code to rely, perhaps accidentally,
3658on the Visual Studio behavior.
3659
3660Among the consequences of these changes are that static data members
3661of the same type with the same name but defined in different shared
3662objects are different, so changing one does not change the other;
3663and that pointers to function members defined in different shared
3664objects may not compare equal. When this flag is given, it is a
3665violation of the ODR to define types with the same name differently.
3666
d77de738
ML
3667@opindex fno-weak
3668@opindex fweak
ddf6fe37 3669@item -fno-weak
d77de738
ML
3670Do not use weak symbol support, even if it is provided by the linker.
3671By default, G++ uses weak symbols if they are available. This
3672option exists only for testing, and should not be used by end-users;
3673it results in inferior code and has no benefits. This option may
3674be removed in a future release of G++.
3675
d77de738
ML
3676@opindex fext-numeric-literals
3677@opindex fno-ext-numeric-literals
ddf6fe37 3678@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3679Accept imaginary, fixed-point, or machine-defined
3680literal number suffixes as GNU extensions.
3681When this option is turned off these suffixes are treated
3682as C++11 user-defined literal numeric suffixes.
3683This is on by default for all pre-C++11 dialects and all GNU dialects:
3684@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3685@option{-std=gnu++14}.
3686This option is off by default
3687for ISO C++11 onwards (@option{-std=c++11}, ...).
3688
d77de738 3689@opindex nostdinc++
ddf6fe37 3690@item -nostdinc++
d77de738
ML
3691Do not search for header files in the standard directories specific to
3692C++, but do still search the other standard directories. (This option
3693is used when building the C++ library.)
3694
ddf6fe37
AA
3695@opindex flang-info-include-translate
3696@opindex flang-info-include-translate-not
d77de738
ML
3697@item -flang-info-include-translate
3698@itemx -flang-info-include-translate-not
3699@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3700Inform of include translation events. The first will note accepted
3701include translations, the second will note declined include
3702translations. The @var{header} form will inform of include
3703translations relating to that specific header. If @var{header} is of
3704the form @code{"user"} or @code{<system>} it will be resolved to a
3705specific user or system header using the include path.
3706
ddf6fe37 3707@opindex flang-info-module-cmi
d77de738
ML
3708@item -flang-info-module-cmi
3709@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3710Inform of Compiled Module Interface pathnames. The first will note
3711all read CMI pathnames. The @var{module} form will not reading a
3712specific module's CMI. @var{module} may be a named module or a
3713header-unit (the latter indicated by either being a pathname containing
3714directory separators or enclosed in @code{<>} or @code{""}).
3715
d77de738 3716@opindex stdlib
ddf6fe37 3717@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3718When G++ is configured to support this option, it allows specification of
3719alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3720(the default, native C++ runtime for G++) and @var{libc++} which is the
3721C++ runtime installed on some operating systems (e.g. Darwin versions from
3722Darwin11 onwards). The option switches G++ to use the headers from the
3723specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3724when a C++ runtime is required for linking.
3725@end table
3726
3727In addition, these warning options have meanings only for C++ programs:
3728
3729@table @gcctabopt
d77de738 3730@opindex Wabi-tag
ddf6fe37 3731@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3732Warn when a type with an ABI tag is used in a context that does not
3733have that ABI tag. See @ref{C++ Attributes} for more information
3734about ABI tags.
3735
d77de738
ML
3736@opindex Wcomma-subscript
3737@opindex Wno-comma-subscript
ddf6fe37 3738@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3739Warn about uses of a comma expression within a subscripting expression.
3740This usage was deprecated in C++20 and is going to be removed in C++23.
3741However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3742
3743@smallexample
3744@group
3745void f(int *a, int b, int c) @{
3746 a[b,c]; // deprecated in C++20, invalid in C++23
3747 a[(b,c)]; // OK
3748@}
3749@end group
3750@end smallexample
3751
3752In C++23 it is valid to have comma separated expressions in a subscript
3753when an overloaded subscript operator is found and supports the right
3754number and types of arguments. G++ will accept the formerly valid syntax
3755for code that is not valid in C++23 but used to be valid but deprecated
3756in C++20 with a pedantic warning that can be disabled with
3757@option{-Wno-comma-subscript}.
3758
3759Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3760and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3761
5fccebdb
JM
3762This warning is upgraded to an error by @option{-pedantic-errors} in
3763C++23 mode or later.
3764
d77de738
ML
3765@opindex Wctad-maybe-unsupported
3766@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3767@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3768Warn when performing class template argument deduction (CTAD) on a type with
3769no explicitly written deduction guides. This warning will point out cases
3770where CTAD succeeded only because the compiler synthesized the implicit
3771deduction guides, which might not be what the programmer intended. Certain
3772style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3773types that are designed to support CTAD. This warning can be suppressed with
3774the following pattern:
3775
3776@smallexample
3777struct allow_ctad_t; // any name works
3778template <typename T> struct S @{
3779 S(T) @{ @}
3780@};
4ace81b6
SL
3781// Guide with incomplete parameter type will never be considered.
3782S(allow_ctad_t) -> S<void>;
d77de738
ML
3783@end smallexample
3784
d77de738
ML
3785@opindex Wctor-dtor-privacy
3786@opindex Wno-ctor-dtor-privacy
ddf6fe37 3787@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3788Warn when a class seems unusable because all the constructors or
3789destructors in that class are private, and it has neither friends nor
3790public static member functions. Also warn if there are no non-private
3791methods, and there's at least one private member function that isn't
3792a constructor or destructor.
3793
d77de738
ML
3794@opindex Wdangling-reference
3795@opindex Wno-dangling-reference
ddf6fe37 3796@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3797Warn when a reference is bound to a temporary whose lifetime has ended.
3798For example:
3799
3800@smallexample
3801int n = 1;
3802const int& r = std::max(n - 1, n + 1); // r is dangling
3803@end smallexample
3804
3805In the example above, two temporaries are created, one for each
3806argument, and a reference to one of the temporaries is returned.
3807However, both temporaries are destroyed at the end of the full
3808expression, so the reference @code{r} is dangling. This warning
3809also detects dangling references in member initializer lists:
3810
3811@smallexample
3812const int& f(const int& i) @{ return i; @}
3813struct S @{
3814 const int &r; // r is dangling
3815 S() : r(f(10)) @{ @}
3816@};
3817@end smallexample
3818
3819Member functions are checked as well, but only their object argument:
3820
3821@smallexample
3822struct S @{
3823 const S& self () @{ return *this; @}
3824@};
3825const S& s = S().self(); // s is dangling
3826@end smallexample
3827
3828Certain functions are safe in this respect, for example @code{std::use_facet}:
3829they take and return a reference, but they don't return one of its arguments,
3830which can fool the warning. Such functions can be excluded from the warning
3831by wrapping them in a @code{#pragma}:
3832
3833@smallexample
3834#pragma GCC diagnostic push
3835#pragma GCC diagnostic ignored "-Wdangling-reference"
3836const T& foo (const T&) @{ @dots{} @}
3837#pragma GCC diagnostic pop
3838@end smallexample
3839
ce51e843
ML
3840@option{-Wdangling-reference} also warns about code like
3841
3842@smallexample
3843auto p = std::minmax(1, 2);
3844@end smallexample
3845
3846where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3847both references dangle after the end of the full expression that contains
3848the call to @code{std::minmax}.
3849
d77de738
ML
3850This warning is enabled by @option{-Wall}.
3851
d77de738
ML
3852@opindex Wdelete-non-virtual-dtor
3853@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3854@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3855Warn when @code{delete} is used to destroy an instance of a class that
3856has virtual functions and non-virtual destructor. It is unsafe to delete
3857an instance of a derived class through a pointer to a base class if the
3858base class does not have a virtual destructor. This warning is enabled
3859by @option{-Wall}.
3860
d77de738
ML
3861@opindex Wdeprecated-copy
3862@opindex Wno-deprecated-copy
ddf6fe37 3863@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3864Warn that the implicit declaration of a copy constructor or copy
3865assignment operator is deprecated if the class has a user-provided
3866copy constructor or copy assignment operator, in C++11 and up. This
3867warning is enabled by @option{-Wextra}. With
3868@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3869user-provided destructor.
3870
d77de738
ML
3871@opindex Wdeprecated-enum-enum-conversion
3872@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3873@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3874Disable the warning about the case when the usual arithmetic conversions
3875are applied on operands where one is of enumeration type and the other is
3876of a different enumeration type. This conversion was deprecated in C++20.
3877For example:
3878
3879@smallexample
3880enum E1 @{ e @};
3881enum E2 @{ f @};
3882int k = f - e;
3883@end smallexample
3884
3885@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3886@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3887by @option{-Wenum-conversion}.
3888
d77de738
ML
3889@opindex Wdeprecated-enum-float-conversion
3890@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3891@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3892Disable the warning about the case when the usual arithmetic conversions
3893are applied on operands where one is of enumeration type and the other is
3894of a floating-point type. This conversion was deprecated in C++20. For
3895example:
3896
3897@smallexample
3898enum E1 @{ e @};
3899enum E2 @{ f @};
3900bool b = e <= 3.7;
3901@end smallexample
3902
3903@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3904@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3905by @option{-Wenum-conversion}.
3906
b106f11d
AC
3907@opindex Welaborated-enum-base
3908@opindex Wno-elaborated-enum-base
3909@item -Wno-elaborated-enum-base
3910For C++11 and above, warn if an (invalid) additional enum-base is used
3911in an elaborated-type-specifier. That is, if an enum with given
3912underlying type and no enumerator list is used in a declaration other
3913than just a standalone declaration of the enum. Enabled by default. This
3914warning is upgraded to an error with -pedantic-errors.
3915
d77de738
ML
3916@opindex Winit-list-lifetime
3917@opindex Wno-init-list-lifetime
ddf6fe37 3918@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3919Do not warn about uses of @code{std::initializer_list} that are likely
3920to result in dangling pointers. Since the underlying array for an
3921@code{initializer_list} is handled like a normal C++ temporary object,
3922it is easy to inadvertently keep a pointer to the array past the end
3923of the array's lifetime. For example:
3924
3925@itemize @bullet
3926@item
3927If a function returns a temporary @code{initializer_list}, or a local
3928@code{initializer_list} variable, the array's lifetime ends at the end
3929of the return statement, so the value returned has a dangling pointer.
3930
3931@item
3932If a new-expression creates an @code{initializer_list}, the array only
3933lives until the end of the enclosing full-expression, so the
3934@code{initializer_list} in the heap has a dangling pointer.
3935
3936@item
3937When an @code{initializer_list} variable is assigned from a
3938brace-enclosed initializer list, the temporary array created for the
3939right side of the assignment only lives until the end of the
3940full-expression, so at the next statement the @code{initializer_list}
3941variable has a dangling pointer.
3942
3943@smallexample
3944// li's initial underlying array lives as long as li
3945std::initializer_list<int> li = @{ 1,2,3 @};
3946// assignment changes li to point to a temporary array
3947li = @{ 4, 5 @};
3948// now the temporary is gone and li has a dangling pointer
3949int i = li.begin()[0] // undefined behavior
3950@end smallexample
3951
3952@item
3953When a list constructor stores the @code{begin} pointer from the
3954@code{initializer_list} argument, this doesn't extend the lifetime of
3955the array, so if a class variable is constructed from a temporary
3956@code{initializer_list}, the pointer is left dangling by the end of
3957the variable declaration statement.
3958
3959@end itemize
3960
c85f8dbb
MP
3961@opindex Winvalid-constexpr
3962@opindex Wno-invalid-constexpr
ddf6fe37 3963@item -Winvalid-constexpr
c85f8dbb
MP
3964
3965Warn when a function never produces a constant expression. In C++20
3966and earlier, for every @code{constexpr} function and function template,
3967there must be at least one set of function arguments in at least one
3968instantiation such that an invocation of the function or constructor
3969could be an evaluated subexpression of a core constant expression.
3970C++23 removed this restriction, so it's possible to have a function
3971or a function template marked @code{constexpr} for which no invocation
3972satisfies the requirements of a core constant expression.
3973
3974This warning is enabled as a pedantic warning by default in C++20 and
3975earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3976which case it will be an ordinary warning. For example:
3977
3978@smallexample
3979void f (int& i);
3980constexpr void
3981g (int& i)
3982@{
4ace81b6
SL
3983 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3984 f(i);
c85f8dbb
MP
3985@}
3986@end smallexample
3987
d77de738
ML
3988@opindex Winvalid-imported-macros
3989@opindex Wno-invalid-imported-macros
ddf6fe37 3990@item -Winvalid-imported-macros
d77de738
ML
3991Verify all imported macro definitions are valid at the end of
3992compilation. This is not enabled by default, as it requires
3993additional processing to determine. It may be useful when preparing
3994sets of header-units to ensure consistent macros.
3995
d77de738
ML
3996@opindex Wliteral-suffix
3997@opindex Wno-literal-suffix
ddf6fe37 3998@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
3999Do not warn when a string or character literal is followed by a
4000ud-suffix which does not begin with an underscore. As a conforming
4001extension, GCC treats such suffixes as separate preprocessing tokens
4002in order to maintain backwards compatibility with code that uses
4003formatting macros from @code{<inttypes.h>}. For example:
4004
4005@smallexample
4006#define __STDC_FORMAT_MACROS
4007#include <inttypes.h>
4008#include <stdio.h>
4009
4010int main() @{
4011 int64_t i64 = 123;
4012 printf("My int64: %" PRId64"\n", i64);
4013@}
4014@end smallexample
4015
4016In this case, @code{PRId64} is treated as a separate preprocessing token.
4017
4018This option also controls warnings when a user-defined literal
4019operator is declared with a literal suffix identifier that doesn't
4020begin with an underscore. Literal suffix identifiers that don't begin
4021with an underscore are reserved for future standardization.
4022
4023These warnings are enabled by default.
4024
d77de738
ML
4025@opindex Wnarrowing
4026@opindex Wno-narrowing
ddf6fe37 4027@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
4028For C++11 and later standards, narrowing conversions are diagnosed by default,
4029as required by the standard. A narrowing conversion from a constant produces
4030an error, and a narrowing conversion from a non-constant produces a warning,
4031but @option{-Wno-narrowing} suppresses the diagnostic.
4032Note that this does not affect the meaning of well-formed code;
4033narrowing conversions are still considered ill-formed in SFINAE contexts.
4034
4035With @option{-Wnarrowing} in C++98, warn when a narrowing
4036conversion prohibited by C++11 occurs within
4037@samp{@{ @}}, e.g.
4038
4039@smallexample
4040int i = @{ 2.2 @}; // error: narrowing from double to int
4041@end smallexample
4042
4043This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4044
d77de738
ML
4045@opindex Wnoexcept
4046@opindex Wno-noexcept
ddf6fe37 4047@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
4048Warn when a noexcept-expression evaluates to false because of a call
4049to a function that does not have a non-throwing exception
4050specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4051the compiler to never throw an exception.
4052
d77de738
ML
4053@opindex Wnoexcept-type
4054@opindex Wno-noexcept-type
ddf6fe37 4055@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
4056Warn if the C++17 feature making @code{noexcept} part of a function
4057type changes the mangled name of a symbol relative to C++14. Enabled
4058by @option{-Wabi} and @option{-Wc++17-compat}.
4059
4060As an example:
4061
4062@smallexample
4063template <class T> void f(T t) @{ t(); @};
4064void g() noexcept;
4065void h() @{ f(g); @}
4066@end smallexample
4067
4068@noindent
4069In C++14, @code{f} calls @code{f<void(*)()>}, but in
4070C++17 it calls @code{f<void(*)()noexcept>}.
4071
d77de738
ML
4072@opindex Wclass-memaccess
4073@opindex Wno-class-memaccess
ddf6fe37 4074@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4075Warn when the destination of a call to a raw memory function such as
4076@code{memset} or @code{memcpy} is an object of class type, and when writing
4077into such an object might bypass the class non-trivial or deleted constructor
4078or copy assignment, violate const-correctness or encapsulation, or corrupt
4079virtual table pointers. Modifying the representation of such objects may
4080violate invariants maintained by member functions of the class. For example,
4081the call to @code{memset} below is undefined because it modifies a non-trivial
4082class object and is, therefore, diagnosed. The safe way to either initialize
4083or clear the storage of objects of such types is by using the appropriate
4084constructor or assignment operator, if one is available.
4085@smallexample
4086std::string str = "abc";
4087memset (&str, 0, sizeof str);
4088@end smallexample
4089The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4090Explicitly casting the pointer to the class object to @code{void *} or
4091to a type that can be safely accessed by the raw memory function suppresses
4092the warning.
4093
d77de738
ML
4094@opindex Wnon-virtual-dtor
4095@opindex Wno-non-virtual-dtor
ddf6fe37 4096@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4097Warn when a class has virtual functions and an accessible non-virtual
4098destructor itself or in an accessible polymorphic base class, in which
4099case it is possible but unsafe to delete an instance of a derived
4100class through a pointer to the class itself or base class. This
4101warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4102The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4103should be preferred because it warns about the unsafe cases without false
4104positives.
d77de738 4105
d77de738
ML
4106@opindex Wregister
4107@opindex Wno-register
ddf6fe37 4108@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4109Warn on uses of the @code{register} storage class specifier, except
4110when it is part of the GNU @ref{Explicit Register Variables} extension.
4111The use of the @code{register} keyword as storage class specifier has
4112been deprecated in C++11 and removed in C++17.
4113Enabled by default with @option{-std=c++17}.
4114
d77de738
ML
4115@opindex Wreorder
4116@opindex Wno-reorder
4117@cindex reordering, warning
4118@cindex warning for reordering of member initializers
f33d7a88 4119@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4120Warn when the order of member initializers given in the code does not
4121match the order in which they must be executed. For instance:
4122
4123@smallexample
4124struct A @{
4125 int i;
4126 int j;
4127 A(): j (0), i (1) @{ @}
4128@};
4129@end smallexample
4130
4131@noindent
4132The compiler rearranges the member initializers for @code{i}
4133and @code{j} to match the declaration order of the members, emitting
4134a warning to that effect. This warning is enabled by @option{-Wall}.
4135
d77de738
ML
4136@opindex Wpessimizing-move
4137@opindex Wno-pessimizing-move
ddf6fe37 4138@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4139This warning warns when a call to @code{std::move} prevents copy
4140elision. A typical scenario when copy elision can occur is when returning in
4141a function with a class return type, when the expression being returned is the
4142name of a non-volatile automatic object, and is not a function parameter, and
4143has the same type as the function return type.
4144
4145@smallexample
4146struct T @{
4147@dots{}
4148@};
4149T fn()
4150@{
4151 T t;
4152 @dots{}
4153 return std::move (t);
4154@}
4155@end smallexample
4156
4157But in this example, the @code{std::move} call prevents copy elision.
4158
4159This warning is enabled by @option{-Wall}.
4160
d77de738
ML
4161@opindex Wredundant-move
4162@opindex Wno-redundant-move
ddf6fe37 4163@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4164This warning warns about redundant calls to @code{std::move}; that is, when
4165a move operation would have been performed even without the @code{std::move}
4166call. This happens because the compiler is forced to treat the object as if
4167it were an rvalue in certain situations such as returning a local variable,
4168where copy elision isn't applicable. Consider:
4169
4170@smallexample
4171struct T @{
4172@dots{}
4173@};
4174T fn(T t)
4175@{
4176 @dots{}
4177 return std::move (t);
4178@}
4179@end smallexample
4180
4181Here, the @code{std::move} call is redundant. Because G++ implements Core
4182Issue 1579, another example is:
4183
4184@smallexample
4185struct T @{ // convertible to U
4186@dots{}
4187@};
4188struct U @{
4189@dots{}
4190@};
4191U fn()
4192@{
4193 T t;
4194 @dots{}
4195 return std::move (t);
4196@}
4197@end smallexample
4198In this example, copy elision isn't applicable because the type of the
4199expression being returned and the function return type differ, yet G++
4200treats the return value as if it were designated by an rvalue.
4201
4202This warning is enabled by @option{-Wextra}.
4203
d77de738
ML
4204@opindex Wrange-loop-construct
4205@opindex Wno-range-loop-construct
ddf6fe37 4206@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4207This warning warns when a C++ range-based for-loop is creating an unnecessary
4208copy. This can happen when the range declaration is not a reference, but
4209probably should be. For example:
4210
4211@smallexample
4212struct S @{ char arr[128]; @};
4213void fn () @{
4214 S arr[5];
4215 for (const auto x : arr) @{ @dots{} @}
4216@}
4217@end smallexample
4218
4219It does not warn when the type being copied is a trivially-copyable type whose
4220size is less than 64 bytes.
4221
4222This warning also warns when a loop variable in a range-based for-loop is
4223initialized with a value of a different type resulting in a copy. For example:
4224
4225@smallexample
4226void fn() @{
4227 int arr[10];
4228 for (const double &x : arr) @{ @dots{} @}
4229@}
4230@end smallexample
4231
4232In the example above, in every iteration of the loop a temporary value of
4233type @code{double} is created and destroyed, to which the reference
4234@code{const double &} is bound.
4235
4236This warning is enabled by @option{-Wall}.
4237
d77de738
ML
4238@opindex Wredundant-tags
4239@opindex Wno-redundant-tags
ddf6fe37 4240@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4241Warn about redundant class-key and enum-key in references to class types
4242and enumerated types in contexts where the key can be eliminated without
4243causing an ambiguity. For example:
4244
4245@smallexample
4246struct foo;
4247struct foo *p; // warn that keyword struct can be eliminated
4248@end smallexample
4249
4250@noindent
4251On the other hand, in this example there is no warning:
4252
4253@smallexample
4254struct foo;
4255void foo (); // "hides" struct foo
4256void bar (struct foo&); // no warning, keyword struct is necessary
4257@end smallexample
4258
d77de738
ML
4259@opindex Wsubobject-linkage
4260@opindex Wno-subobject-linkage
ddf6fe37 4261@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4262Do not warn
4263if a class type has a base or a field whose type uses the anonymous
4264namespace or depends on a type with no linkage. If a type A depends on
4265a type B with no or internal linkage, defining it in multiple
4266translation units would be an ODR violation because the meaning of B
4267is different in each translation unit. If A only appears in a single
4268translation unit, the best way to silence the warning is to give it
4269internal linkage by putting it in an anonymous namespace as well. The
4270compiler doesn't give this warning for types defined in the main .C
4271file, as those are unlikely to have multiple definitions.
4272@option{-Wsubobject-linkage} is enabled by default.
4273
d77de738
ML
4274@opindex Weffc++
4275@opindex Wno-effc++
ddf6fe37 4276@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4277Warn about violations of the following style guidelines from Scott Meyers'
4278@cite{Effective C++} series of books:
4279
4280@itemize @bullet
4281@item
4282Define a copy constructor and an assignment operator for classes
4283with dynamically-allocated memory.
4284
4285@item
4286Prefer initialization to assignment in constructors.
4287
4288@item
4289Have @code{operator=} return a reference to @code{*this}.
4290
4291@item
4292Don't try to return a reference when you must return an object.
4293
4294@item
4295Distinguish between prefix and postfix forms of increment and
4296decrement operators.
4297
4298@item
4299Never overload @code{&&}, @code{||}, or @code{,}.
4300
4301@end itemize
4302
4303This option also enables @option{-Wnon-virtual-dtor}, which is also
4304one of the effective C++ recommendations. However, the check is
4305extended to warn about the lack of virtual destructor in accessible
4306non-polymorphic bases classes too.
4307
4308When selecting this option, be aware that the standard library
4309headers do not obey all of these guidelines; use @samp{grep -v}
4310to filter out those warnings.
4311
d77de738
ML
4312@opindex Wexceptions
4313@opindex Wno-exceptions
ddf6fe37 4314@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4315Disable the warning about the case when an exception handler is shadowed by
4316another handler, which can point out a wrong ordering of exception handlers.
4317
d77de738
ML
4318@opindex Wstrict-null-sentinel
4319@opindex Wno-strict-null-sentinel
ddf6fe37 4320@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4321Warn about the use of an uncasted @code{NULL} as sentinel. When
4322compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4323to @code{__null}. Although it is a null pointer constant rather than a
4324null pointer, it is guaranteed to be of the same size as a pointer.
4325But this use is not portable across different compilers.
4326
d77de738
ML
4327@opindex Wno-non-template-friend
4328@opindex Wnon-template-friend
ddf6fe37 4329@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4330Disable warnings when non-template friend functions are declared
4331within a template. In very old versions of GCC that predate implementation
4332of the ISO standard, declarations such as
4333@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4334could be interpreted as a particular specialization of a template
4335function; the warning exists to diagnose compatibility problems,
4336and is enabled by default.
4337
d77de738
ML
4338@opindex Wold-style-cast
4339@opindex Wno-old-style-cast
ddf6fe37 4340@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4341Warn if an old-style (C-style) cast to a non-void type is used within
4342a C++ program. The new-style casts (@code{dynamic_cast},
4343@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4344less vulnerable to unintended effects and much easier to search for.
4345
d77de738
ML
4346@opindex Woverloaded-virtual
4347@opindex Wno-overloaded-virtual
4348@cindex overloaded virtual function, warning
4349@cindex warning for overloaded virtual function
f33d7a88
AA
4350@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4351@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4352Warn when a function declaration hides virtual functions from a
4353base class. For example, in:
4354
4355@smallexample
4356struct A @{
4357 virtual void f();
4358@};
4359
4360struct B: public A @{
4361 void f(int); // does not override
4362@};
4363@end smallexample
4364
4365the @code{A} class version of @code{f} is hidden in @code{B}, and code
4366like:
4367
4368@smallexample
4369B* b;
4370b->f();
4371@end smallexample
4372
4373@noindent
4374fails to compile.
4375
d82490d5
JW
4376In cases where the different signatures are not an accident, the
4377simplest solution is to add a using-declaration to the derived class
4378to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4379
d77de738
ML
4380The optional level suffix controls the behavior when all the
4381declarations in the derived class override virtual functions in the
4382base class, even if not all of the base functions are overridden:
4383
4384@smallexample
4385struct C @{
4386 virtual void f();
4387 virtual void f(int);
4388@};
4389
4390struct D: public C @{
4391 void f(int); // does override
4392@}
4393@end smallexample
4394
4395This pattern is less likely to be a mistake; if D is only used
4396virtually, the user might have decided that the base class semantics
4397for some of the overloads are fine.
4398
4399At level 1, this case does not warn; at level 2, it does.
4400@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4401included in @option{-Wall}.
4402
d77de738
ML
4403@opindex Wno-pmf-conversions
4404@opindex Wpmf-conversions
ddf6fe37 4405@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4406Disable the diagnostic for converting a bound pointer to member function
4407to a plain pointer.
4408
d77de738
ML
4409@opindex Wsign-promo
4410@opindex Wno-sign-promo
ddf6fe37 4411@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4412Warn when overload resolution chooses a promotion from unsigned or
4413enumerated type to a signed type, over a conversion to an unsigned type of
4414the same size. Previous versions of G++ tried to preserve
4415unsignedness, but the standard mandates the current behavior.
4416
d77de738
ML
4417@opindex Wtemplates
4418@opindex Wno-templates
ddf6fe37 4419@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4420Warn when a primary template declaration is encountered. Some coding
4421rules disallow templates, and this may be used to enforce that rule.
4422The warning is inactive inside a system header file, such as the STL, so
4423one can still use the STL. One may also instantiate or specialize
4424templates.
4425
d77de738
ML
4426@opindex Wmismatched-new-delete
4427@opindex Wno-mismatched-new-delete
ddf6fe37 4428@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4429Warn for mismatches between calls to @code{operator new} or @code{operator
4430delete} and the corresponding call to the allocation or deallocation function.
4431This includes invocations of C++ @code{operator delete} with pointers
4432returned from either mismatched forms of @code{operator new}, or from other
4433functions that allocate objects for which the @code{operator delete} isn't
4434a suitable deallocator, as well as calls to other deallocation functions
4435with pointers returned from @code{operator new} for which the deallocation
4436function isn't suitable.
4437
4438For example, the @code{delete} expression in the function below is diagnosed
4439because it doesn't match the array form of the @code{new} expression
4440the pointer argument was returned from. Similarly, the call to @code{free}
4441is also diagnosed.
4442
4443@smallexample
4444void f ()
4445@{
4446 int *a = new int[n];
4447 delete a; // warning: mismatch in array forms of expressions
4448
4449 char *p = new char[n];
4450 free (p); // warning: mismatch between new and free
4451@}
4452@end smallexample
4453
4454The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4455involving allocation and deallocation functions other than @code{operator
4456new} and @code{operator delete}.
4457
4458@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4459
d77de738
ML
4460@opindex Wmismatched-tags
4461@opindex Wno-mismatched-tags
ddf6fe37 4462@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4463Warn for declarations of structs, classes, and class templates and their
4464specializations with a class-key that does not match either the definition
4465or the first declaration if no definition is provided.
4466
4467For example, the declaration of @code{struct Object} in the argument list
4468of @code{draw} triggers the warning. To avoid it, either remove the redundant
4469class-key @code{struct} or replace it with @code{class} to match its definition.
4470@smallexample
4471class Object @{
4472public:
4473 virtual ~Object () = 0;
4474@};
4475void draw (struct Object*);
4476@end smallexample
4477
4478It is not wrong to declare a class with the class-key @code{struct} as
4479the example above shows. The @option{-Wmismatched-tags} option is intended
4480to help achieve a consistent style of class declarations. In code that is
4481intended to be portable to Windows-based compilers the warning helps prevent
4482unresolved references due to the difference in the mangling of symbols
4483declared with different class-keys. The option can be used either on its
4484own or in conjunction with @option{-Wredundant-tags}.
4485
d77de738
ML
4486@opindex Wmultiple-inheritance
4487@opindex Wno-multiple-inheritance
ddf6fe37 4488@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4489Warn when a class is defined with multiple direct base classes. Some
4490coding rules disallow multiple inheritance, and this may be used to
4491enforce that rule. The warning is inactive inside a system header file,
4492such as the STL, so one can still use the STL. One may also define
4493classes that indirectly use multiple inheritance.
4494
d77de738
ML
4495@opindex Wvirtual-inheritance
4496@opindex Wno-virtual-inheritance
ddf6fe37 4497@item -Wvirtual-inheritance
d77de738
ML
4498Warn when a class is defined with a virtual direct base class. Some
4499coding rules disallow multiple inheritance, and this may be used to
4500enforce that rule. The warning is inactive inside a system header file,
4501such as the STL, so one can still use the STL. One may also define
4502classes that indirectly use virtual inheritance.
4503
d77de738
ML
4504@opindex Wvirtual-move-assign
4505@opindex Wno-virtual-move-assign
ddf6fe37 4506@item -Wno-virtual-move-assign
d77de738
ML
4507Suppress warnings about inheriting from a virtual base with a
4508non-trivial C++11 move assignment operator. This is dangerous because
4509if the virtual base is reachable along more than one path, it is
4510moved multiple times, which can mean both objects end up in the
4511moved-from state. If the move assignment operator is written to avoid
4512moving from a moved-from object, this warning can be disabled.
4513
d77de738
ML
4514@opindex Wnamespaces
4515@opindex Wno-namespaces
ddf6fe37 4516@item -Wnamespaces
d77de738
ML
4517Warn when a namespace definition is opened. Some coding rules disallow
4518namespaces, and this may be used to enforce that rule. The warning is
4519inactive inside a system header file, such as the STL, so one can still
4520use the STL. One may also use using directives and qualified names.
4521
d77de738
ML
4522@opindex Wterminate
4523@opindex Wno-terminate
ddf6fe37 4524@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4525Disable the warning about a throw-expression that will immediately
4526result in a call to @code{terminate}.
4527
d77de738
ML
4528@opindex Wvexing-parse
4529@opindex Wno-vexing-parse
ddf6fe37 4530@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4531Warn about the most vexing parse syntactic ambiguity. This warns about
4532the cases when a declaration looks like a variable definition, but the
4533C++ language requires it to be interpreted as a function declaration.
4534For instance:
4535
4536@smallexample
4537void f(double a) @{
4538 int i(); // extern int i (void);
4539 int n(int(a)); // extern int n (int);
4540@}
4541@end smallexample
4542
4543Another example:
4544
4545@smallexample
4546struct S @{ S(int); @};
4547void f(double a) @{
4548 S x(int(a)); // extern struct S x (int);
4549 S y(int()); // extern struct S y (int (*) (void));
4550 S z(); // extern struct S z (void);
4551@}
4552@end smallexample
4553
4554The warning will suggest options how to deal with such an ambiguity; e.g.,
4555it can suggest removing the parentheses or using braces instead.
4556
4557This warning is enabled by default.
4558
d77de738
ML
4559@opindex Wno-class-conversion
4560@opindex Wclass-conversion
ddf6fe37 4561@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4562Do not warn when a conversion function converts an
4563object to the same type, to a base class of that type, or to void; such
4564a conversion function will never be called.
4565
d77de738
ML
4566@opindex Wvolatile
4567@opindex Wno-volatile
ddf6fe37 4568@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4569Warn about deprecated uses of the @code{volatile} qualifier. This includes
4570postfix and prefix @code{++} and @code{--} expressions of
4571@code{volatile}-qualified types, using simple assignments where the left
4572operand is a @code{volatile}-qualified non-class type for their value,
4573compound assignments where the left operand is a @code{volatile}-qualified
4574non-class type, @code{volatile}-qualified function return type,
4575@code{volatile}-qualified parameter type, and structured bindings of a
4576@code{volatile}-qualified type. This usage was deprecated in C++20.
4577
4578Enabled by default with @option{-std=c++20}.
4579
d77de738
ML
4580@opindex Wzero-as-null-pointer-constant
4581@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4582@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4583Warn when a literal @samp{0} is used as null pointer constant. This can
4584be useful to facilitate the conversion to @code{nullptr} in C++11.
4585
d77de738
ML
4586@opindex Waligned-new
4587@opindex Wno-aligned-new
ddf6fe37 4588@item -Waligned-new
d77de738
ML
4589Warn about a new-expression of a type that requires greater alignment
4590than the @code{alignof(std::max_align_t)} but uses an allocation
4591function without an explicit alignment parameter. This option is
4592enabled by @option{-Wall}.
4593
4594Normally this only warns about global allocation functions, but
4595@option{-Waligned-new=all} also warns about class member allocation
4596functions.
4597
d77de738
ML
4598@opindex Wplacement-new
4599@opindex Wno-placement-new
ddf6fe37
AA
4600@item -Wno-placement-new
4601@itemx -Wplacement-new=@var{n}
d77de738
ML
4602Warn about placement new expressions with undefined behavior, such as
4603constructing an object in a buffer that is smaller than the type of
4604the object. For example, the placement new expression below is diagnosed
4605because it attempts to construct an array of 64 integers in a buffer only
460664 bytes large.
4607@smallexample
4608char buf [64];
4609new (buf) int[64];
4610@end smallexample
4611This warning is enabled by default.
4612
4613@table @gcctabopt
4614@item -Wplacement-new=1
4615This is the default warning level of @option{-Wplacement-new}. At this
4616level the warning is not issued for some strictly undefined constructs that
4617GCC allows as extensions for compatibility with legacy code. For example,
4618the following @code{new} expression is not diagnosed at this level even
4619though it has undefined behavior according to the C++ standard because
4620it writes past the end of the one-element array.
4621@smallexample
4622struct S @{ int n, a[1]; @};
4623S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4624new (s->a)int [32]();
4625@end smallexample
4626
4627@item -Wplacement-new=2
4628At this level, in addition to diagnosing all the same constructs as at level
46291, a diagnostic is also issued for placement new expressions that construct
4630an object in the last member of structure whose type is an array of a single
4631element and whose size is less than the size of the object being constructed.
4632While the previous example would be diagnosed, the following construct makes
4633use of the flexible member array extension to avoid the warning at level 2.
4634@smallexample
4635struct S @{ int n, a[]; @};
4636S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4637new (s->a)int [32]();
4638@end smallexample
4639
4640@end table
4641
d77de738
ML
4642@opindex Wcatch-value
4643@opindex Wno-catch-value
ddf6fe37
AA
4644@item -Wcatch-value
4645@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4646Warn about catch handlers that do not catch via reference.
4647With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4648warn about polymorphic class types that are caught by value.
4649With @option{-Wcatch-value=2} warn about all class types that are caught
4650by value. With @option{-Wcatch-value=3} warn about all types that are
4651not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4652
d77de738
ML
4653@opindex Wconditionally-supported
4654@opindex Wno-conditionally-supported
ddf6fe37 4655@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4656Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4657
d77de738
ML
4658@opindex Wdelete-incomplete
4659@opindex Wno-delete-incomplete
ddf6fe37 4660@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4661Do not warn when deleting a pointer to incomplete type, which may cause
4662undefined behavior at runtime. This warning is enabled by default.
4663
d77de738
ML
4664@opindex Wextra-semi
4665@opindex Wno-extra-semi
ddf6fe37 4666@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4667Warn about redundant semicolons after in-class function definitions.
4668
d77de738
ML
4669@opindex Winaccessible-base
4670@opindex Wno-inaccessible-base
ddf6fe37 4671@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4672This option controls warnings
4673when a base class is inaccessible in a class derived from it due to
4674ambiguity. The warning is enabled by default.
4675Note that the warning for ambiguous virtual
4676bases is enabled by the @option{-Wextra} option.
4677@smallexample
4678@group
4679struct A @{ int a; @};
4680
4681struct B : A @{ @};
4682
4683struct C : B, A @{ @};
4684@end group
4685@end smallexample
4686
d77de738
ML
4687@opindex Winherited-variadic-ctor
4688@opindex Wno-inherited-variadic-ctor
ddf6fe37 4689@item -Wno-inherited-variadic-ctor
d77de738
ML
4690Suppress warnings about use of C++11 inheriting constructors when the
4691base class inherited from has a C variadic constructor; the warning is
4692on by default because the ellipsis is not inherited.
4693
d77de738
ML
4694@opindex Wno-invalid-offsetof
4695@opindex Winvalid-offsetof
ddf6fe37 4696@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4697Suppress warnings from applying the @code{offsetof} macro to a non-POD
4698type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4699to a non-standard-layout type is undefined. In existing C++ implementations,
4700however, @code{offsetof} typically gives meaningful results.
4701This flag is for users who are aware that they are
4702writing nonportable code and who have deliberately chosen to ignore the
4703warning about it.
4704
4705The restrictions on @code{offsetof} may be relaxed in a future version
4706of the C++ standard.
4707
d77de738
ML
4708@opindex Wsized-deallocation
4709@opindex Wno-sized-deallocation
ddf6fe37 4710@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4711Warn about a definition of an unsized deallocation function
4712@smallexample
4713void operator delete (void *) noexcept;
4714void operator delete[] (void *) noexcept;
4715@end smallexample
4716without a definition of the corresponding sized deallocation function
4717@smallexample
4718void operator delete (void *, std::size_t) noexcept;
4719void operator delete[] (void *, std::size_t) noexcept;
4720@end smallexample
4721or vice versa. Enabled by @option{-Wextra} along with
4722@option{-fsized-deallocation}.
4723
d77de738
ML
4724@opindex Wno-suggest-final-types
4725@opindex Wsuggest-final-types
ddf6fe37 4726@item -Wsuggest-final-types
d77de738
ML
4727Warn about types with virtual methods where code quality would be improved
4728if the type were declared with the C++11 @code{final} specifier,
4729or, if possible,
4730declared in an anonymous namespace. This allows GCC to more aggressively
4731devirtualize the polymorphic calls. This warning is more effective with
4732link-time optimization,
4733where the information about the class hierarchy graph is
4734more complete.
4735
d77de738
ML
4736@opindex Wno-suggest-final-methods
4737@opindex Wsuggest-final-methods
ddf6fe37 4738@item -Wsuggest-final-methods
d77de738
ML
4739Warn about virtual methods where code quality would be improved if the method
4740were declared with the C++11 @code{final} specifier,
4741or, if possible, its type were
4742declared in an anonymous namespace or with the @code{final} specifier.
4743This warning is
4744more effective with link-time optimization, where the information about the
4745class hierarchy graph is more complete. It is recommended to first consider
4746suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4747annotations.
4748
d77de738
ML
4749@opindex Wsuggest-override
4750@opindex Wno-suggest-override
ddf6fe37 4751@item -Wsuggest-override
d77de738
ML
4752Warn about overriding virtual functions that are not marked with the
4753@code{override} keyword.
4754
d77de738
ML
4755@opindex Wuse-after-free
4756@opindex Wno-use-after-free
ddf6fe37
AA
4757@item -Wuse-after-free
4758@itemx -Wuse-after-free=@var{n}
d77de738
ML
4759Warn about uses of pointers to dynamically allocated objects that have
4760been rendered indeterminate by a call to a deallocation function.
4761The warning is enabled at all optimization levels but may yield different
4762results with optimization than without.
4763
4764@table @gcctabopt
4765@item -Wuse-after-free=1
4766At level 1 the warning attempts to diagnose only unconditional uses
4767of pointers made indeterminate by a deallocation call or a successful
4768call to @code{realloc}, regardless of whether or not the call resulted
4769in an actual reallocatio of memory. This includes double-@code{free}
4770calls as well as uses in arithmetic and relational expressions. Although
4771undefined, uses of indeterminate pointers in equality (or inequality)
4772expressions are not diagnosed at this level.
4773@item -Wuse-after-free=2
4774At level 2, in addition to unconditional uses, the warning also diagnoses
4775conditional uses of pointers made indeterminate by a deallocation call.
4776As at level 2, uses in equality (or inequality) expressions are not
4777diagnosed. For example, the second call to @code{free} in the following
4778function is diagnosed at this level:
4779@smallexample
4780struct A @{ int refcount; void *data; @};
4781
4782void release (struct A *p)
4783@{
4784 int refcount = --p->refcount;
4785 free (p);
4786 if (refcount == 0)
4787 free (p->data); // warning: p may be used after free
4788@}
4789@end smallexample
4790@item -Wuse-after-free=3
4791At level 3, the warning also diagnoses uses of indeterminate pointers in
4792equality expressions. All uses of indeterminate pointers are undefined
4793but equality tests sometimes appear after calls to @code{realloc} as
4794an attempt to determine whether the call resulted in relocating the object
4795to a different address. They are diagnosed at a separate level to aid
4796legacy code gradually transition to safe alternatives. For example,
4797the equality test in the function below is diagnosed at this level:
4798@smallexample
4799void adjust_pointers (int**, int);
4800
4801void grow (int **p, int n)
4802@{
4803 int **q = (int**)realloc (p, n *= 2);
4804 if (q == p)
4805 return;
4806 adjust_pointers ((int**)q, n);
4807@}
4808@end smallexample
4809To avoid the warning at this level, store offsets into allocated memory
4810instead of pointers. This approach obviates needing to adjust the stored
4811pointers after reallocation.
4812@end table
4813
4814@option{-Wuse-after-free=2} is included in @option{-Wall}.
4815
d77de738
ML
4816@opindex Wuseless-cast
4817@opindex Wno-useless-cast
68783211 4818@item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
4819Warn when an expression is cast to its own type. This warning does not
4820occur when a class object is converted to a non-reference type as that
4821is a way to create a temporary:
4822
4823@smallexample
4824struct S @{ @};
4825void g (S&&);
4826void f (S&& arg)
4827@{
4828 g (S(arg)); // make arg prvalue so that it can bind to S&&
4829@}
4830@end smallexample
4831
d77de738
ML
4832@opindex Wconversion-null
4833@opindex Wno-conversion-null
ddf6fe37 4834@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4835Do not warn for conversions between @code{NULL} and non-pointer
4836types. @option{-Wconversion-null} is enabled by default.
4837
4838@end table
4839
4840@node Objective-C and Objective-C++ Dialect Options
4841@section Options Controlling Objective-C and Objective-C++ Dialects
4842
4843@cindex compiler options, Objective-C and Objective-C++
4844@cindex Objective-C and Objective-C++ options, command-line
4845@cindex options, Objective-C and Objective-C++
4846(NOTE: This manual does not describe the Objective-C and Objective-C++
4847languages themselves. @xref{Standards,,Language Standards
4848Supported by GCC}, for references.)
4849
4850This section describes the command-line options that are only meaningful
4851for Objective-C and Objective-C++ programs. You can also use most of
4852the language-independent GNU compiler options.
4853For example, you might compile a file @file{some_class.m} like this:
4854
4855@smallexample
4856gcc -g -fgnu-runtime -O -c some_class.m
4857@end smallexample
4858
4859@noindent
4860In this example, @option{-fgnu-runtime} is an option meant only for
4861Objective-C and Objective-C++ programs; you can use the other options with
4862any language supported by GCC@.
4863
4864Note that since Objective-C is an extension of the C language, Objective-C
4865compilations may also use options specific to the C front-end (e.g.,
4866@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4867C++-specific options (e.g., @option{-Wabi}).
4868
4869Here is a list of options that are @emph{only} for compiling Objective-C
4870and Objective-C++ programs:
4871
4872@table @gcctabopt
d77de738 4873@opindex fconstant-string-class
ddf6fe37 4874@item -fconstant-string-class=@var{class-name}
d77de738
ML
4875Use @var{class-name} as the name of the class to instantiate for each
4876literal string specified with the syntax @code{@@"@dots{}"}. The default
4877class name is @code{NXConstantString} if the GNU runtime is being used, and
cdd4b3c0 4878@code{NSConstantString} if the NeXT runtime is being used (see below). On
a335cf24 4879Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
cdd4b3c0
IS
4880also present, overrides the @option{-fconstant-string-class} setting and cause
4881@code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
4882Note that @option{-fconstant-cfstrings} is an alias for the target-specific
4883@option{-mconstant-cfstrings} equivalent.
d77de738 4884
d77de738 4885@opindex fgnu-runtime
ddf6fe37 4886@item -fgnu-runtime
d77de738
ML
4887Generate object code compatible with the standard GNU Objective-C
4888runtime. This is the default for most types of systems.
4889
d77de738 4890@opindex fnext-runtime
ddf6fe37 4891@item -fnext-runtime
d77de738 4892Generate output compatible with the NeXT runtime. This is the default
a335cf24 4893for NeXT-based systems, including Darwin / macOS. The macro
d77de738
ML
4894@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4895used.
4896
d77de738
ML
4897@opindex fno-nil-receivers
4898@opindex fnil-receivers
ddf6fe37 4899@item -fno-nil-receivers
d77de738
ML
4900Assume that all Objective-C message dispatches (@code{[receiver
4901message:arg]}) in this translation unit ensure that the receiver is
4902not @code{nil}. This allows for more efficient entry points in the
4903runtime to be used. This option is only available in conjunction with
4904the NeXT runtime and ABI version 0 or 1.
4905
d77de738 4906@opindex fobjc-abi-version
ddf6fe37 4907@item -fobjc-abi-version=@var{n}
d77de738
ML
4908Use version @var{n} of the Objective-C ABI for the selected runtime.
4909This option is currently supported only for the NeXT runtime. In that
4910case, Version 0 is the traditional (32-bit) ABI without support for
4911properties and other Objective-C 2.0 additions. Version 1 is the
4912traditional (32-bit) ABI with support for properties and other
4913Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4914nothing is specified, the default is Version 0 on 32-bit target
4915machines, and Version 2 on 64-bit target machines.
4916
d77de738 4917@opindex fobjc-call-cxx-cdtors
ddf6fe37 4918@item -fobjc-call-cxx-cdtors
d77de738
ML
4919For each Objective-C class, check if any of its instance variables is a
4920C++ object with a non-trivial default constructor. If so, synthesize a
4921special @code{- (id) .cxx_construct} instance method which runs
4922non-trivial default constructors on any such instance variables, in order,
4923and then return @code{self}. Similarly, check if any instance variable
4924is a C++ object with a non-trivial destructor, and if so, synthesize a
4925special @code{- (void) .cxx_destruct} method which runs
4926all such default destructors, in reverse order.
4927
4928The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4929methods thusly generated only operate on instance variables
4930declared in the current Objective-C class, and not those inherited
4931from superclasses. It is the responsibility of the Objective-C
4932runtime to invoke all such methods in an object's inheritance
4933hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4934by the runtime immediately after a new object instance is allocated;
4935the @code{- (void) .cxx_destruct} methods are invoked immediately
4936before the runtime deallocates an object instance.
4937
4938As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4939support for invoking the @code{- (id) .cxx_construct} and
4940@code{- (void) .cxx_destruct} methods.
4941
d77de738 4942@opindex fobjc-direct-dispatch
ddf6fe37 4943@item -fobjc-direct-dispatch
d77de738
ML
4944Allow fast jumps to the message dispatcher. On Darwin this is
4945accomplished via the comm page.
4946
d77de738 4947@opindex fobjc-exceptions
ddf6fe37 4948@item -fobjc-exceptions
d77de738
ML
4949Enable syntactic support for structured exception handling in
4950Objective-C, similar to what is offered by C++. This option
4951is required to use the Objective-C keywords @code{@@try},
4952@code{@@throw}, @code{@@catch}, @code{@@finally} and
4953@code{@@synchronized}. This option is available with both the GNU
4954runtime and the NeXT runtime (but not available in conjunction with
4955the NeXT runtime on Mac OS X 10.2 and earlier).
4956
d77de738 4957@opindex fobjc-gc
ddf6fe37 4958@item -fobjc-gc
d77de738
ML
4959Enable garbage collection (GC) in Objective-C and Objective-C++
4960programs. This option is only available with the NeXT runtime; the
4961GNU runtime has a different garbage collection implementation that
4962does not require special compiler flags.
4963
d77de738 4964@opindex fobjc-nilcheck
ddf6fe37 4965@item -fobjc-nilcheck
d77de738
ML
4966For the NeXT runtime with version 2 of the ABI, check for a nil
4967receiver in method invocations before doing the actual method call.
4968This is the default and can be disabled using
4969@option{-fno-objc-nilcheck}. Class methods and super calls are never
4970checked for nil in this way no matter what this flag is set to.
4971Currently this flag does nothing when the GNU runtime, or an older
4972version of the NeXT runtime ABI, is used.
4973
d77de738 4974@opindex fobjc-std
ddf6fe37 4975@item -fobjc-std=objc1
d77de738
ML
4976Conform to the language syntax of Objective-C 1.0, the language
4977recognized by GCC 4.0. This only affects the Objective-C additions to
4978the C/C++ language; it does not affect conformance to C/C++ standards,
4979which is controlled by the separate C/C++ dialect option flags. When
4980this option is used with the Objective-C or Objective-C++ compiler,
4981any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4982This is useful if you need to make sure that your Objective-C code can
4983be compiled with older versions of GCC@.
4984
d77de738 4985@opindex freplace-objc-classes
ddf6fe37 4986@item -freplace-objc-classes
d77de738
ML
4987Emit a special marker instructing @command{ld(1)} not to statically link in
4988the resulting object file, and allow @command{dyld(1)} to load it in at
4989run time instead. This is used in conjunction with the Fix-and-Continue
4990debugging mode, where the object file in question may be recompiled and
4991dynamically reloaded in the course of program execution, without the need
4992to restart the program itself. Currently, Fix-and-Continue functionality
4993is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4994and later.
4995
d77de738 4996@opindex fzero-link
ddf6fe37 4997@item -fzero-link
d77de738
ML
4998When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4999to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5000compile time) with static class references that get initialized at load time,
5001which improves run-time performance. Specifying the @option{-fzero-link} flag
5002suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5003to be retained. This is useful in Zero-Link debugging mode, since it allows
5004for individual class implementations to be modified during program execution.
5005The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5006regardless of command-line options.
5007
d77de738
ML
5008@opindex fno-local-ivars
5009@opindex flocal-ivars
ddf6fe37 5010@item -fno-local-ivars
d77de738
ML
5011By default instance variables in Objective-C can be accessed as if
5012they were local variables from within the methods of the class they're
5013declared in. This can lead to shadowing between instance variables
5014and other variables declared either locally inside a class method or
5015globally with the same name. Specifying the @option{-fno-local-ivars}
5016flag disables this behavior thus avoiding variable shadowing issues.
5017
d77de738 5018@opindex fivar-visibility
ddf6fe37 5019@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
5020Set the default instance variable visibility to the specified option
5021so that instance variables declared outside the scope of any access
5022modifier directives default to the specified visibility.
5023
d77de738 5024@opindex gen-decls
ddf6fe37 5025@item -gen-decls
d77de738
ML
5026Dump interface declarations for all classes seen in the source file to a
5027file named @file{@var{sourcename}.decl}.
5028
d77de738
ML
5029@opindex Wassign-intercept
5030@opindex Wno-assign-intercept
ddf6fe37 5031@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5032Warn whenever an Objective-C assignment is being intercepted by the
5033garbage collector.
5034
d77de738
ML
5035@opindex Wproperty-assign-default
5036@opindex Wno-property-assign-default
ddf6fe37 5037@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5038Do not warn if a property for an Objective-C object has no assign
5039semantics specified.
5040
d77de738
ML
5041@opindex Wno-protocol
5042@opindex Wprotocol
ddf6fe37 5043@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5044If a class is declared to implement a protocol, a warning is issued for
5045every method in the protocol that is not implemented by the class. The
5046default behavior is to issue a warning for every method not explicitly
5047implemented in the class, even if a method implementation is inherited
5048from the superclass. If you use the @option{-Wno-protocol} option, then
5049methods inherited from the superclass are considered to be implemented,
5050and no warning is issued for them.
5051
d77de738 5052@opindex Wobjc-root-class
ddf6fe37 5053@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5054Warn if a class interface lacks a superclass. Most classes will inherit
5055from @code{NSObject} (or @code{Object}) for example. When declaring
5056classes intended to be root classes, the warning can be suppressed by
5057marking their interfaces with @code{__attribute__((objc_root_class))}.
5058
d77de738
ML
5059@opindex Wselector
5060@opindex Wno-selector
ddf6fe37 5061@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5062Warn if multiple methods of different types for the same selector are
5063found during compilation. The check is performed on the list of methods
5064in the final stage of compilation. Additionally, a check is performed
5065for each selector appearing in a @code{@@selector(@dots{})}
5066expression, and a corresponding method for that selector has been found
5067during compilation. Because these checks scan the method table only at
5068the end of compilation, these warnings are not produced if the final
5069stage of compilation is not reached, for example because an error is
5070found during compilation, or because the @option{-fsyntax-only} option is
5071being used.
5072
d77de738
ML
5073@opindex Wstrict-selector-match
5074@opindex Wno-strict-selector-match
ddf6fe37 5075@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5076Warn if multiple methods with differing argument and/or return types are
5077found for a given selector when attempting to send a message using this
5078selector to a receiver of type @code{id} or @code{Class}. When this flag
5079is off (which is the default behavior), the compiler omits such warnings
5080if any differences found are confined to types that share the same size
5081and alignment.
5082
d77de738
ML
5083@opindex Wundeclared-selector
5084@opindex Wno-undeclared-selector
ddf6fe37 5085@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5086Warn if a @code{@@selector(@dots{})} expression referring to an
5087undeclared selector is found. A selector is considered undeclared if no
5088method with that name has been declared before the
5089@code{@@selector(@dots{})} expression, either explicitly in an
5090@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5091an @code{@@implementation} section. This option always performs its
5092checks as soon as a @code{@@selector(@dots{})} expression is found,
5093while @option{-Wselector} only performs its checks in the final stage of
5094compilation. This also enforces the coding style convention
5095that methods and selectors must be declared before being used.
5096
d77de738 5097@opindex print-objc-runtime-info
ddf6fe37 5098@item -print-objc-runtime-info
d77de738
ML
5099Generate C header describing the largest structure that is passed by
5100value, if any.
5101
5102@end table
5103
5104@node Diagnostic Message Formatting Options
5105@section Options to Control Diagnostic Messages Formatting
5106@cindex options to control diagnostics formatting
5107@cindex diagnostic messages
5108@cindex message formatting
5109
5110Traditionally, diagnostic messages have been formatted irrespective of
5111the output device's aspect (e.g.@: its width, @dots{}). You can use the
5112options described below
5113to control the formatting algorithm for diagnostic messages,
5114e.g.@: how many characters per line, how often source location
5115information should be reported. Note that some language front ends may not
5116honor these options.
5117
5118@table @gcctabopt
d77de738 5119@opindex fmessage-length
ddf6fe37 5120@item -fmessage-length=@var{n}
d77de738
ML
5121Try to format error messages so that they fit on lines of about
5122@var{n} characters. If @var{n} is zero, then no line-wrapping is
5123done; each error message appears on a single line. This is the
5124default for all front ends.
5125
5126Note - this option also affects the display of the @samp{#error} and
5127@samp{#warning} pre-processor directives, and the @samp{deprecated}
5128function/type/variable attribute. It does not however affect the
5129@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5130
5131@item -fdiagnostics-plain-output
5132This option requests that diagnostic output look as plain as possible, which
5133may be useful when running @command{dejagnu} or other utilities that need to
5134parse diagnostics output and prefer that it remain more stable over time.
5135@option{-fdiagnostics-plain-output} is currently equivalent to the following
5136options:
43b72ede
AA
5137@gccoptlist{-fno-diagnostics-show-caret
5138-fno-diagnostics-show-line-numbers
5139-fdiagnostics-color=never
5140-fdiagnostics-urls=never
4f01ae37
DM
5141-fdiagnostics-path-format=separate-events
5142-fdiagnostics-text-art-charset=none}
d77de738
ML
5143In the future, if GCC changes the default appearance of its diagnostics, the
5144corresponding option to disable the new behavior will be added to this list.
5145
d77de738 5146@opindex fdiagnostics-show-location
ddf6fe37 5147@item -fdiagnostics-show-location=once
d77de738
ML
5148Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5149reporter to emit source location information @emph{once}; that is, in
5150case the message is too long to fit on a single physical line and has to
5151be wrapped, the source location won't be emitted (as prefix) again,
5152over and over, in subsequent continuation lines. This is the default
5153behavior.
5154
5155@item -fdiagnostics-show-location=every-line
5156Only meaningful in line-wrapping mode. Instructs the diagnostic
5157messages reporter to emit the same source location information (as
5158prefix) for physical lines that result from the process of breaking
5159a message which is too long to fit on a single line.
5160
ddf6fe37 5161@opindex fdiagnostics-color
d77de738
ML
5162@cindex highlight, color
5163@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5164@item -fdiagnostics-color[=@var{WHEN}]
5165@itemx -fno-diagnostics-color
d77de738
ML
5166Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5167or @samp{auto}. The default depends on how the compiler has been configured,
5168it can be any of the above @var{WHEN} options or also @samp{never}
5169if @env{GCC_COLORS} environment variable isn't present in the environment,
5170and @samp{auto} otherwise.
5171@samp{auto} makes GCC use color only when the standard error is a terminal,
5172and when not executing in an emacs shell.
5173The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5174aliases for @option{-fdiagnostics-color=always} and
5175@option{-fdiagnostics-color=never}, respectively.
5176
5177The colors are defined by the environment variable @env{GCC_COLORS}.
5178Its value is a colon-separated list of capabilities and Select Graphic
5179Rendition (SGR) substrings. SGR commands are interpreted by the
5180terminal or terminal emulator. (See the section in the documentation
5181of your text terminal for permitted values and their meanings as
5182character attributes.) These substring values are integers in decimal
5183representation and can be concatenated with semicolons.
5184Common values to concatenate include
5185@samp{1} for bold,
5186@samp{4} for underline,
5187@samp{5} for blink,
5188@samp{7} for inverse,
5189@samp{39} for default foreground color,
5190@samp{30} to @samp{37} for foreground colors,
5191@samp{90} to @samp{97} for 16-color mode foreground colors,
5192@samp{38;5;0} to @samp{38;5;255}
5193for 88-color and 256-color modes foreground colors,
5194@samp{49} for default background color,
5195@samp{40} to @samp{47} for background colors,
5196@samp{100} to @samp{107} for 16-color mode background colors,
5197and @samp{48;5;0} to @samp{48;5;255}
5198for 88-color and 256-color modes background colors.
5199
5200The default @env{GCC_COLORS} is
5201@smallexample
5202error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5203quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5204diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5205type-diff=01;32:fnname=01;32:targs=35
5206@end smallexample
5207@noindent
5208where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5209@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5210@samp{01} is bold, and @samp{31} is red.
5211Setting @env{GCC_COLORS} to the empty string disables colors.
5212Supported capabilities are as follows.
5213
5214@table @code
d77de738 5215@vindex error GCC_COLORS @r{capability}
f33d7a88 5216@item error=
d77de738
ML
5217SGR substring for error: markers.
5218
d77de738 5219@vindex warning GCC_COLORS @r{capability}
f33d7a88 5220@item warning=
d77de738
ML
5221SGR substring for warning: markers.
5222
d77de738 5223@vindex note GCC_COLORS @r{capability}
f33d7a88 5224@item note=
d77de738
ML
5225SGR substring for note: markers.
5226
d77de738 5227@vindex path GCC_COLORS @r{capability}
f33d7a88 5228@item path=
d77de738
ML
5229SGR substring for colorizing paths of control-flow events as printed
5230via @option{-fdiagnostics-path-format=}, such as the identifiers of
5231individual events and lines indicating interprocedural calls and returns.
5232
d77de738 5233@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5234@item range1=
d77de738
ML
5235SGR substring for first additional range.
5236
d77de738 5237@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5238@item range2=
d77de738
ML
5239SGR substring for second additional range.
5240
d77de738 5241@vindex locus GCC_COLORS @r{capability}
f33d7a88 5242@item locus=
d77de738
ML
5243SGR substring for location information, @samp{file:line} or
5244@samp{file:line:column} etc.
5245
d77de738 5246@vindex quote GCC_COLORS @r{capability}
f33d7a88 5247@item quote=
d77de738
ML
5248SGR substring for information printed within quotes.
5249
d77de738 5250@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5251@item fnname=
d77de738
ML
5252SGR substring for names of C++ functions.
5253
d77de738 5254@vindex targs GCC_COLORS @r{capability}
f33d7a88 5255@item targs=
d77de738
ML
5256SGR substring for C++ function template parameter bindings.
5257
d77de738 5258@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5259@item fixit-insert=
d77de738
ML
5260SGR substring for fix-it hints suggesting text to
5261be inserted or replaced.
5262
d77de738 5263@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5264@item fixit-delete=
d77de738
ML
5265SGR substring for fix-it hints suggesting text to
5266be deleted.
5267
d77de738 5268@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5269@item diff-filename=
d77de738
ML
5270SGR substring for filename headers within generated patches.
5271
d77de738 5272@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5273@item diff-hunk=
d77de738
ML
5274SGR substring for the starts of hunks within generated patches.
5275
d77de738 5276@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5277@item diff-delete=
d77de738
ML
5278SGR substring for deleted lines within generated patches.
5279
d77de738 5280@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5281@item diff-insert=
d77de738
ML
5282SGR substring for inserted lines within generated patches.
5283
d77de738 5284@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5285@item type-diff=
d77de738
ML
5286SGR substring for highlighting mismatching types within template
5287arguments in the C++ frontend.
5288@end table
5289
d77de738
ML
5290@opindex fdiagnostics-urls
5291@cindex urls
5292@vindex GCC_URLS @r{environment variable}
5293@vindex TERM_URLS @r{environment variable}
f33d7a88 5294@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5295Use escape sequences to embed URLs in diagnostics. For example, when
5296@option{-fdiagnostics-show-option} emits text showing the command-line
5297option controlling a diagnostic, embed a URL for documentation of that
5298option.
5299
5300@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5301@samp{auto} makes GCC use URL escape sequences only when the standard error
5302is a terminal, and when not executing in an emacs shell or any graphical
5303terminal which is known to be incompatible with this feature, see below.
5304
5305The default depends on how the compiler has been configured.
5306It can be any of the above @var{WHEN} options.
5307
5308GCC can also be configured (via the
5309@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5310so that the default is affected by environment variables.
5311Under such a configuration, GCC defaults to using @samp{auto}
5312if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5313present and non-empty in the environment of the compiler, or @samp{never}
5314if neither are.
5315
5316However, even with @option{-fdiagnostics-urls=always} the behavior is
5317dependent on those environment variables:
5318If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5319diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5320If set to @samp{bel}, the default, URLs use BEL escape sequences.
5321Any other non-empty value enables the feature.
5322If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5323Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5324BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5325
5326At this time GCC tries to detect also a few terminals that are known to
5327not implement the URL feature, and have bugs or at least had bugs in
5328some versions that are still in use, where the URL escapes are likely
5329to misbehave, i.e. print garbage on the screen.
5330That list is currently xfce4-terminal, certain known to be buggy
5331gnome-terminal versions, the linux console, and mingw.
5332This check can be skipped with the @option{-fdiagnostics-urls=always}.
5333
d77de738
ML
5334@opindex fno-diagnostics-show-option
5335@opindex fdiagnostics-show-option
ddf6fe37 5336@item -fno-diagnostics-show-option
d77de738
ML
5337By default, each diagnostic emitted includes text indicating the
5338command-line option that directly controls the diagnostic (if such an
5339option is known to the diagnostic machinery). Specifying the
5340@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5341
d77de738
ML
5342@opindex fno-diagnostics-show-caret
5343@opindex fdiagnostics-show-caret
ddf6fe37 5344@item -fno-diagnostics-show-caret
d77de738
ML
5345By default, each diagnostic emitted includes the original source line
5346and a caret @samp{^} indicating the column. This option suppresses this
5347information. The source line is truncated to @var{n} characters, if
5348the @option{-fmessage-length=n} option is given. When the output is done
5349to the terminal, the width is limited to the width given by the
5350@env{COLUMNS} environment variable or, if not set, to the terminal width.
5351
d77de738
ML
5352@opindex fno-diagnostics-show-labels
5353@opindex fdiagnostics-show-labels
ddf6fe37 5354@item -fno-diagnostics-show-labels
d77de738
ML
5355By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5356diagnostics can label ranges of source code with pertinent information, such
5357as the types of expressions:
5358
5359@smallexample
5360 printf ("foo %s bar", long_i + long_j);
5361 ~^ ~~~~~~~~~~~~~~~
5362 | |
5363 char * long int
5364@end smallexample
5365
5366This option suppresses the printing of these labels (in the example above,
5367the vertical bars and the ``char *'' and ``long int'' text).
5368
d77de738
ML
5369@opindex fno-diagnostics-show-cwe
5370@opindex fdiagnostics-show-cwe
ddf6fe37 5371@item -fno-diagnostics-show-cwe
d77de738
ML
5372Diagnostic messages can optionally have an associated
5373@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5374GCC itself only provides such metadata for some of the @option{-fanalyzer}
5375diagnostics. GCC plugins may also provide diagnostics with such metadata.
5376By default, if this information is present, it will be printed with
5377the diagnostic. This option suppresses the printing of this metadata.
5378
d77de738
ML
5379@opindex fno-diagnostics-show-rules
5380@opindex fdiagnostics-show-rules
ddf6fe37 5381@item -fno-diagnostics-show-rules
d77de738
ML
5382Diagnostic messages can optionally have rules associated with them, such
5383as from a coding standard, or a specification.
5384GCC itself does not do this for any of its diagnostics, but plugins may do so.
5385By default, if this information is present, it will be printed with
5386the diagnostic. This option suppresses the printing of this metadata.
5387
d77de738
ML
5388@opindex fno-diagnostics-show-line-numbers
5389@opindex fdiagnostics-show-line-numbers
ddf6fe37 5390@item -fno-diagnostics-show-line-numbers
d77de738
ML
5391By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5392a left margin is printed, showing line numbers. This option suppresses this
5393left margin.
5394
d77de738 5395@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5396@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5397This option controls the minimum width of the left margin printed by
5398@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5399
d77de738 5400@opindex fdiagnostics-parseable-fixits
ddf6fe37 5401@item -fdiagnostics-parseable-fixits
d77de738
ML
5402Emit fix-it hints in a machine-parseable format, suitable for consumption
5403by IDEs. For each fix-it, a line will be printed after the relevant
5404diagnostic, starting with the string ``fix-it:''. For example:
5405
5406@smallexample
5407fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5408@end smallexample
5409
5410The location is expressed as a half-open range, expressed as a count of
5411bytes, starting at byte 1 for the initial column. In the above example,
5412bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5413given string:
5414
5415@smallexample
541600000000011111111112222222222
541712345678901234567890123456789
5418 gtk_widget_showall (dlg);
5419 ^^^^^^^^^^^^^^^^^^
5420 gtk_widget_show_all
5421@end smallexample
5422
5423The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5424newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5425(e.g. vertical tab as ``\013'').
5426
5427An empty replacement string indicates that the given range is to be removed.
5428An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5429be inserted at the given position.
5430
d77de738 5431@opindex fdiagnostics-generate-patch
ddf6fe37 5432@item -fdiagnostics-generate-patch
d77de738
ML
5433Print fix-it hints to stderr in unified diff format, after any diagnostics
5434are printed. For example:
5435
5436@smallexample
5437--- test.c
5438+++ test.c
5439@@ -42,5 +42,5 @@
5440
5441 void show_cb(GtkDialog *dlg)
5442 @{
5443- gtk_widget_showall(dlg);
5444+ gtk_widget_show_all(dlg);
5445 @}
5446
5447@end smallexample
5448
5449The diff may or may not be colorized, following the same rules
5450as for diagnostics (see @option{-fdiagnostics-color}).
5451
d77de738 5452@opindex fdiagnostics-show-template-tree
ddf6fe37 5453@item -fdiagnostics-show-template-tree
d77de738
ML
5454
5455In the C++ frontend, when printing diagnostics showing mismatching
5456template types, such as:
5457
5458@smallexample
5459 could not convert 'std::map<int, std::vector<double> >()'
5460 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5461@end smallexample
5462
5463the @option{-fdiagnostics-show-template-tree} flag enables printing a
5464tree-like structure showing the common and differing parts of the types,
5465such as:
5466
5467@smallexample
5468 map<
5469 [...],
5470 vector<
5471 [double != float]>>
5472@end smallexample
5473
5474The parts that differ are highlighted with color (``double'' and
5475``float'' in this case).
5476
d77de738
ML
5477@opindex fno-elide-type
5478@opindex felide-type
ddf6fe37 5479@item -fno-elide-type
d77de738
ML
5480By default when the C++ frontend prints diagnostics showing mismatching
5481template types, common parts of the types are printed as ``[...]'' to
5482simplify the error message. For example:
5483
5484@smallexample
5485 could not convert 'std::map<int, std::vector<double> >()'
5486 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5487@end smallexample
5488
5489Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5490This flag also affects the output of the
5491@option{-fdiagnostics-show-template-tree} flag.
5492
d77de738 5493@opindex fdiagnostics-path-format
ddf6fe37 5494@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5495Specify how to print paths of control-flow events for diagnostics that
5496have such a path associated with them.
5497
5498@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5499the default.
5500
5501@samp{none} means to not print diagnostic paths.
5502
5503@samp{separate-events} means to print a separate ``note'' diagnostic for
5504each event within the diagnostic. For example:
5505
5506@smallexample
5507test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5508test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5509test.c:27:3: note: (2) when 'i < count'
5510test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5511@end smallexample
5512
5513@samp{inline-events} means to print the events ``inline'' within the source
5514code. This view attempts to consolidate the events into runs of
5515sufficiently-close events, printing them as labelled ranges within the source.
5516
5517For example, the same events as above might be printed as:
5518
5519@smallexample
5520 'test': events 1-3
5521 |
5522 | 25 | list = PyList_New(0);
5523 | | ^~~~~~~~~~~~~
5524 | | |
5525 | | (1) when 'PyList_New' fails, returning NULL
5526 | 26 |
5527 | 27 | for (i = 0; i < count; i++) @{
5528 | | ~~~
5529 | | |
5530 | | (2) when 'i < count'
5531 | 28 | item = PyLong_FromLong(random());
5532 | 29 | PyList_Append(list, item);
5533 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5534 | | |
5535 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5536 |
5537@end smallexample
5538
5539Interprocedural control flow is shown by grouping the events by stack frame,
5540and using indentation to show how stack frames are nested, pushed, and popped.
5541
5542For example:
5543
5544@smallexample
5545 'test': events 1-2
5546 |
5547 | 133 | @{
5548 | | ^
5549 | | |
5550 | | (1) entering 'test'
5551 | 134 | boxed_int *obj = make_boxed_int (i);
5552 | | ~~~~~~~~~~~~~~~~~~
5553 | | |
5554 | | (2) calling 'make_boxed_int'
5555 |
5556 +--> 'make_boxed_int': events 3-4
5557 |
5558 | 120 | @{
5559 | | ^
5560 | | |
5561 | | (3) entering 'make_boxed_int'
5562 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5563 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5564 | | |
5565 | | (4) calling 'wrapped_malloc'
5566 |
5567 +--> 'wrapped_malloc': events 5-6
5568 |
5569 | 7 | @{
5570 | | ^
5571 | | |
5572 | | (5) entering 'wrapped_malloc'
5573 | 8 | return malloc (size);
5574 | | ~~~~~~~~~~~~~
5575 | | |
5576 | | (6) calling 'malloc'
5577 |
5578 <-------------+
5579 |
5580 'test': event 7
5581 |
5582 | 138 | free_boxed_int (obj);
5583 | | ^~~~~~~~~~~~~~~~~~~~
5584 | | |
5585 | | (7) calling 'free_boxed_int'
5586 |
5587(etc)
5588@end smallexample
5589
d77de738 5590@opindex fdiagnostics-show-path-depths
ddf6fe37 5591@item -fdiagnostics-show-path-depths
d77de738
ML
5592This option provides additional information when printing control-flow paths
5593associated with a diagnostic.
5594
5595If this is option is provided then the stack depth will be printed for
5596each run of events within @option{-fdiagnostics-path-format=inline-events}.
5597If provided with @option{-fdiagnostics-path-format=separate-events}, then
5598the stack depth and function declaration will be appended when printing
5599each event.
5600
5601This is intended for use by GCC developers and plugin developers when
5602debugging diagnostics that report interprocedural control flow.
5603
d77de738
ML
5604@opindex fno-show-column
5605@opindex fshow-column
ddf6fe37 5606@item -fno-show-column
d77de738
ML
5607Do not print column numbers in diagnostics. This may be necessary if
5608diagnostics are being scanned by a program that does not understand the
5609column numbers, such as @command{dejagnu}.
5610
d77de738 5611@opindex fdiagnostics-column-unit
ddf6fe37 5612@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5613Select the units for the column number. This affects traditional diagnostics
5614(in the absence of @option{-fno-show-column}), as well as JSON format
5615diagnostics if requested.
5616
5617The default @var{UNIT}, @samp{display}, considers the number of display
5618columns occupied by each character. This may be larger than the number
5619of bytes required to encode the character, in the case of tab
5620characters, or it may be smaller, in the case of multibyte characters.
5621For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5622display column, and its UTF-8 encoding requires two bytes; the character
5623``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5624its UTF-8 encoding requires four bytes.
5625
5626Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5627count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5628
d77de738 5629@opindex fdiagnostics-column-origin
ddf6fe37 5630@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5631Select the origin for column numbers, i.e. the column number assigned to the
5632first column. The default value of 1 corresponds to traditional GCC
5633behavior and to the GNU style guide. Some utilities may perform better with an
5634origin of 0; any non-negative value may be specified.
5635
d77de738 5636@opindex fdiagnostics-escape-format
ddf6fe37 5637@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5638When GCC prints pertinent source lines for a diagnostic it normally attempts
5639to print the source bytes directly. However, some diagnostics relate to encoding
5640issues in the source file, such as malformed UTF-8, or issues with Unicode
5641normalization. These diagnostics are flagged so that GCC will escape bytes
5642that are not printable ASCII when printing their pertinent source lines.
5643
5644This option controls how such bytes should be escaped.
5645
5646The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5647are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5648correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5649displayed as hexadecimal in the form @samp{<XX>}.
5650
5651For example, a source line containing the string @samp{before} followed by the
5652Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
56530xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5654the string @samp{after} will be printed for such a diagnostic as:
5655
5656@smallexample
5657 before<U+03C0><BF>after
5658@end smallexample
5659
5660Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5661in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5662Unicode characters. For the example above, the following will be printed:
5663
5664@smallexample
5665 before<CF><80><BF>after
5666@end smallexample
5667
4f01ae37
DM
5668@opindex fdiagnostics-text-art-charset
5669@item -fdiagnostics-text-art-charset=@var{CHARSET}
5670Some diagnostics can contain ``text art'' diagrams: visualizations created
5671from text, intended to be viewed in a monospaced font.
5672
5673This option selects which characters should be used for printing such
5674diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
5675or @samp{emoji}.
5676
5677The @samp{none} value suppresses the printing of such diagrams.
5678The @samp{ascii} value will ensure that such diagrams are pure ASCII
5679(``ASCII art''). The @samp{unicode} value will allow for conservative use of
5680unicode drawing characters (such as box-drawing characters). The @samp{emoji}
5681value further adds the possibility of emoji in the output (such as emitting
5682U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
5683emoji variant of the character).
5684
04013e44
DM
5685The default is @samp{emoji}, except when the environment variable @env{LANG}
5686is set to @samp{C}, in which case the default is @samp{ascii}.
4f01ae37 5687
d77de738 5688@opindex fdiagnostics-format
ddf6fe37 5689@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5690Select a different format for printing diagnostics.
5691@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5692@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5693
5694The default is @samp{text}.
5695
5696The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5697diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5698named @file{@var{source}.sarif}, respectively.
5699
5700The @samp{json} format is a synonym for @samp{json-stderr}.
5701The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5702where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5703whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5704
5705The emitted JSON consists of a top-level JSON array containing JSON objects
5706representing the diagnostics. The JSON is emitted as one line, without
5707formatting; the examples below have been formatted for clarity.
5708
5709Diagnostics can have child diagnostics. For example, this error and note:
5710
5711@smallexample
5712misleading-indentation.c:15:3: warning: this 'if' clause does not
5713 guard... [-Wmisleading-indentation]
5714 15 | if (flag)
5715 | ^~
5716misleading-indentation.c:17:5: note: ...this statement, but the latter
5717 is misleadingly indented as if it were guarded by the 'if'
5718 17 | y = 2;
5719 | ^
5720@end smallexample
5721
5722@noindent
5723might be printed in JSON form (after formatting) like this:
5724
5725@smallexample
5726[
5727 @{
5728 "kind": "warning",
5729 "locations": [
5730 @{
5731 "caret": @{
5732 "display-column": 3,
5733 "byte-column": 3,
5734 "column": 3,
5735 "file": "misleading-indentation.c",
5736 "line": 15
5737 @},
5738 "finish": @{
5739 "display-column": 4,
5740 "byte-column": 4,
5741 "column": 4,
5742 "file": "misleading-indentation.c",
5743 "line": 15
5744 @}
5745 @}
5746 ],
5747 "message": "this \u2018if\u2019 clause does not guard...",
5748 "option": "-Wmisleading-indentation",
5749 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5750 "children": [
5751 @{
5752 "kind": "note",
5753 "locations": [
5754 @{
5755 "caret": @{
5756 "display-column": 5,
5757 "byte-column": 5,
5758 "column": 5,
5759 "file": "misleading-indentation.c",
5760 "line": 17
5761 @}
5762 @}
5763 ],
5764 "escape-source": false,
5765 "message": "...this statement, but the latter is @dots{}"
5766 @}
5767 ]
5768 "escape-source": false,
5769 "column-origin": 1,
5770 @}
5771]
5772@end smallexample
5773
5774@noindent
5775where the @code{note} is a child of the @code{warning}.
5776
5777A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5778an @code{option} key describing the command-line option controlling the
5779warning.
5780
5781A diagnostic can contain zero or more locations. Each location has an
5782optional @code{label} string and up to three positions within it: a
5783@code{caret} position and optional @code{start} and @code{finish} positions.
5784A position is described by a @code{file} name, a @code{line} number, and
5785three numbers indicating a column position:
5786@itemize @bullet
5787
5788@item
5789@code{display-column} counts display columns, accounting for tabs and
5790multibyte characters.
5791
5792@item
5793@code{byte-column} counts raw bytes.
5794
5795@item
5796@code{column} is equal to one of
5797the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5798option.
5799
5800@end itemize
5801All three columns are relative to the origin specified by
5802@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5803be set, for instance, to 0 for compatibility with other utilities that
5804number columns from 0. The column origin is recorded in the JSON output in
5805the @code{column-origin} tag. In the remaining examples below, the extra
5806column number outputs have been omitted for brevity.
5807
5808For example, this error:
5809
5810@smallexample
5811bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5812 'struct s'@} and 'T' @{aka 'struct t'@})
5813 64 | return callee_4a () + callee_4b ();
5814 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5815 | | |
5816 | | T @{aka struct t@}
5817 | S @{aka struct s@}
5818@end smallexample
5819
5820@noindent
5821has three locations. Its primary location is at the ``+'' token at column
582223. It has two secondary locations, describing the left and right-hand sides
5823of the expression, which have labels. It might be printed in JSON form as:
5824
5825@smallexample
5826 @{
5827 "children": [],
5828 "kind": "error",
5829 "locations": [
5830 @{
5831 "caret": @{
5832 "column": 23, "file": "bad-binary-ops.c", "line": 64
5833 @}
5834 @},
5835 @{
5836 "caret": @{
5837 "column": 10, "file": "bad-binary-ops.c", "line": 64
5838 @},
5839 "finish": @{
5840 "column": 21, "file": "bad-binary-ops.c", "line": 64
5841 @},
5842 "label": "S @{aka struct s@}"
5843 @},
5844 @{
5845 "caret": @{
5846 "column": 25, "file": "bad-binary-ops.c", "line": 64
5847 @},
5848 "finish": @{
5849 "column": 36, "file": "bad-binary-ops.c", "line": 64
5850 @},
5851 "label": "T @{aka struct t@}"
5852 @}
5853 ],
5854 "escape-source": false,
5855 "message": "invalid operands to binary + @dots{}"
5856 @}
5857@end smallexample
5858
5859If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5860consisting of half-open intervals, similar to the output of
5861@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5862with a replacement fix-it hint:
5863
5864@smallexample
5865demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5866 mean 'color'?
5867 8 | return ptr->colour;
5868 | ^~~~~~
5869 | color
5870@end smallexample
5871
5872@noindent
5873might be printed in JSON form as:
5874
5875@smallexample
5876 @{
5877 "children": [],
5878 "fixits": [
5879 @{
5880 "next": @{
5881 "column": 21,
5882 "file": "demo.c",
5883 "line": 8
5884 @},
5885 "start": @{
5886 "column": 15,
5887 "file": "demo.c",
5888 "line": 8
5889 @},
5890 "string": "color"
5891 @}
5892 ],
5893 "kind": "error",
5894 "locations": [
5895 @{
5896 "caret": @{
5897 "column": 15,
5898 "file": "demo.c",
5899 "line": 8
5900 @},
5901 "finish": @{
5902 "column": 20,
5903 "file": "demo.c",
5904 "line": 8
5905 @}
5906 @}
5907 ],
5908 "escape-source": false,
5909 "message": "\u2018struct s\u2019 has no member named @dots{}"
5910 @}
5911@end smallexample
5912
5913@noindent
5914where the fix-it hint suggests replacing the text from @code{start} up
5915to but not including @code{next} with @code{string}'s value. Deletions
5916are expressed via an empty value for @code{string}, insertions by
5917having @code{start} equal @code{next}.
5918
5919If the diagnostic has a path of control-flow events associated with it,
5920it has a @code{path} array of objects representing the events. Each
5921event object has a @code{description} string, a @code{location} object,
5922along with a @code{function} string and a @code{depth} number for
5923representing interprocedural paths. The @code{function} represents the
5924current function at that event, and the @code{depth} represents the
5925stack depth relative to some baseline: the higher, the more frames are
5926within the stack.
5927
5928For example, the intraprocedural example shown for
5929@option{-fdiagnostics-path-format=} might have this JSON for its path:
5930
5931@smallexample
5932 "path": [
5933 @{
5934 "depth": 0,
5935 "description": "when 'PyList_New' fails, returning NULL",
5936 "function": "test",
5937 "location": @{
5938 "column": 10,
5939 "file": "test.c",
5940 "line": 25
5941 @}
5942 @},
5943 @{
5944 "depth": 0,
5945 "description": "when 'i < count'",
5946 "function": "test",
5947 "location": @{
5948 "column": 3,
5949 "file": "test.c",
5950 "line": 27
5951 @}
5952 @},
5953 @{
5954 "depth": 0,
5955 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5956 "function": "test",
5957 "location": @{
5958 "column": 5,
5959 "file": "test.c",
5960 "line": 29
5961 @}
5962 @}
5963 ]
5964@end smallexample
5965
5966Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5967non-ASCII bytes should be escaped when printing the pertinent lines of
5968source code (@code{true} for diagnostics involving source encoding issues).
5969
5970@end table
5971
5972@node Warning Options
5973@section Options to Request or Suppress Warnings
5974@cindex options to control warnings
5975@cindex warning messages
5976@cindex messages, warning
5977@cindex suppressing warnings
5978
5979Warnings are diagnostic messages that report constructions that
5980are not inherently erroneous but that are risky or suggest there
5981may have been an error.
5982
5983The following language-independent options do not enable specific
5984warnings but control the kinds of diagnostics produced by GCC@.
5985
5986@table @gcctabopt
5987@cindex syntax checking
d77de738 5988@opindex fsyntax-only
ddf6fe37 5989@item -fsyntax-only
d77de738
ML
5990Check the code for syntax errors, but don't do anything beyond that.
5991
d77de738 5992@opindex fmax-errors
ddf6fe37 5993@item -fmax-errors=@var{n}
d77de738
ML
5994Limits the maximum number of error messages to @var{n}, at which point
5995GCC bails out rather than attempting to continue processing the source
5996code. If @var{n} is 0 (the default), there is no limit on the number
5997of error messages produced. If @option{-Wfatal-errors} is also
5998specified, then @option{-Wfatal-errors} takes precedence over this
5999option.
6000
d77de738 6001@opindex w
ddf6fe37 6002@item -w
d77de738
ML
6003Inhibit all warning messages.
6004
d77de738
ML
6005@opindex Werror
6006@opindex Wno-error
ddf6fe37 6007@item -Werror
d77de738
ML
6008Make all warnings into errors.
6009
d77de738
ML
6010@opindex Werror=
6011@opindex Wno-error=
ddf6fe37 6012@item -Werror=
d77de738
ML
6013Make the specified warning into an error. The specifier for a warning
6014is appended; for example @option{-Werror=switch} turns the warnings
6015controlled by @option{-Wswitch} into errors. This switch takes a
6016negative form, to be used to negate @option{-Werror} for specific
6017warnings; for example @option{-Wno-error=switch} makes
6018@option{-Wswitch} warnings not be errors, even when @option{-Werror}
6019is in effect.
6020
6021The warning message for each controllable warning includes the
6022option that controls the warning. That option can then be used with
6023@option{-Werror=} and @option{-Wno-error=} as described above.
6024(Printing of the option in the warning message can be disabled using the
6025@option{-fno-diagnostics-show-option} flag.)
6026
6027Note that specifying @option{-Werror=}@var{foo} automatically implies
6028@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6029imply anything.
6030
d77de738
ML
6031@opindex Wfatal-errors
6032@opindex Wno-fatal-errors
ddf6fe37 6033@item -Wfatal-errors
d77de738
ML
6034This option causes the compiler to abort compilation on the first error
6035occurred rather than trying to keep going and printing further error
6036messages.
6037
6038@end table
6039
6040You can request many specific warnings with options beginning with
6041@samp{-W}, for example @option{-Wimplicit} to request warnings on
6042implicit declarations. Each of these specific warning options also
6043has a negative form beginning @samp{-Wno-} to turn off warnings; for
6044example, @option{-Wno-implicit}. This manual lists only one of the
6045two forms, whichever is not the default. For further
6046language-specific options also refer to @ref{C++ Dialect Options} and
6047@ref{Objective-C and Objective-C++ Dialect Options}.
6048Additional warnings can be produced by enabling the static analyzer;
6049@xref{Static Analyzer Options}.
6050
6051Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6052options, such as @option{-Wunused}, which may turn on further options,
6053such as @option{-Wunused-value}. The combined effect of positive and
6054negative forms is that more specific options have priority over less
6055specific ones, independently of their position in the command-line. For
6056options of the same specificity, the last one takes effect. Options
6057enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6058as if they appeared at the end of the command-line.
6059
6060When an unrecognized warning option is requested (e.g.,
6061@option{-Wunknown-warning}), GCC emits a diagnostic stating
6062that the option is not recognized. However, if the @option{-Wno-} form
6063is used, the behavior is slightly different: no diagnostic is
6064produced for @option{-Wno-unknown-warning} unless other diagnostics
6065are being produced. This allows the use of new @option{-Wno-} options
6066with old compilers, but if something goes wrong, the compiler
6067warns that an unrecognized option is present.
6068
6069The effectiveness of some warnings depends on optimizations also being
6070enabled. For example @option{-Wsuggest-final-types} is more effective
6071with link-time optimization and some instances of other warnings may
6072not be issued at all unless optimization is enabled. While optimization
6073in general improves the efficacy of control and data flow sensitive
6074warnings, in some cases it may also cause false positives.
6075
6076@table @gcctabopt
d77de738
ML
6077@opindex pedantic
6078@opindex Wpedantic
6079@opindex Wno-pedantic
ddf6fe37
AA
6080@item -Wpedantic
6081@itemx -pedantic
d77de738 6082Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
6083diagnose all programs that use forbidden extensions, and some other
6084programs that do not follow ISO C and ISO C++. This follows the version
6085of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
6086
6087Valid ISO C and ISO C++ programs should compile properly with or without
6088this option (though a rare few require @option{-ansi} or a
5fccebdb 6089@option{-std} option specifying the version of the standard)@. However,
d77de738 6090without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6091features are supported as well. With this option, they are diagnosed
6092(or rejected with @option{-pedantic-errors}).
d77de738
ML
6093
6094@option{-Wpedantic} does not cause warning messages for use of the
6095alternate keywords whose names begin and end with @samp{__}. This alternate
6096format can also be used to disable warnings for non-ISO @samp{__intN} types,
6097i.e. @samp{__intN__}.
6098Pedantic warnings are also disabled in the expression that follows
6099@code{__extension__}. However, only system header files should use
6100these escape routes; application programs should avoid them.
6101@xref{Alternate Keywords}.
6102
5fccebdb
JM
6103Some warnings about non-conforming programs are controlled by options
6104other than @option{-Wpedantic}; in many cases they are implied by
6105@option{-Wpedantic} but can be disabled separately by their specific
6106option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6107
6108Where the standard specified with @option{-std} represents a GNU
6109extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6110corresponding @dfn{base standard}, the version of ISO C on which the GNU
6111extended dialect is based. Warnings from @option{-Wpedantic} are given
6112where they are required by the base standard. (It does not make sense
6113for such warnings to be given only for features not in the specified GNU
6114C dialect, since by definition the GNU dialects of C include all
6115features the compiler supports with the given option, and there would be
6116nothing to warn about.)
6117
d77de738 6118@opindex pedantic-errors
ddf6fe37 6119@item -pedantic-errors
d77de738
ML
6120Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6121requires a diagnostic, in some cases where there is undefined behavior
6122at compile-time and in some other cases that do not prevent compilation
6123of programs that are valid according to the standard. This is not
5fccebdb
JM
6124equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6125useful, as it only makes errors of the diagnostics that are controlled by
6126@option{-Wpedantic}, whereas this option also affects required diagnostics that
6127are always enabled or controlled by options other than @option{-Wpedantic}.
6128
6129If you want the required diagnostics that are warnings by default to
6130be errors instead, but don't also want to enable the @option{-Wpedantic}
6131diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6132(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6133only as warnings).
6134
6135Some required diagnostics are errors by default, but can be reduced to
6136warnings using @option{-fpermissive} or their specific warning option,
6137e.g. @option{-Wno-error=narrowing}.
6138
6139Some diagnostics for non-ISO practices are controlled by specific
6140warning options other than @option{-Wpedantic}, but are also made
6141errors by @option{-pedantic-errors}. For instance:
6142
6143@gccoptlist{
6144-Wattributes @r{(for standard attributes)}
6145-Wchanges-meaning @r{(C++)}
6146-Wcomma-subscript @r{(C++23 or later)}
6147-Wdeclaration-after-statement @r{(C90 or earlier)}
b106f11d 6148-Welaborated-enum-base @r{(C++11 or later)}
5fccebdb
JM
6149-Wimplicit-int @r{(C99 or later)}
6150-Wimplicit-function-declaration @r{(C99 or later)}
6151-Wincompatible-pointer-types
6152-Wint-conversion
6153-Wlong-long @r{(C90 or earlier)}
6154-Wmain
6155-Wnarrowing @r{(C++11 or later)}
6156-Wpointer-arith
6157-Wpointer-sign
6158-Wincompatible-pointer-types
6159-Wregister @r{(C++17 or later)}
6160-Wvla @r{(C90 or earlier)}
6161-Wwrite-strings @r{(C++11 or later)}
6162}
d77de738 6163
ef10cb86
JM
6164@opindex fpermissive
6165@item -fpermissive
6166Downgrade some required diagnostics about nonconformant code from
6167errors to warnings. Thus, using @option{-fpermissive} allows some
6168nonconforming code to compile. Some C++ diagnostics are controlled
6169only by this flag, but it also downgrades some diagnostics that have
6170their own flag:
6171
6172@gccoptlist{
6173-Wnarrowing @r{(C++)}
6174}
6175
d77de738
ML
6176@opindex Wall
6177@opindex Wno-all
ddf6fe37 6178@item -Wall
d77de738
ML
6179This enables all the warnings about constructions that some users
6180consider questionable, and that are easy to avoid (or modify to
6181prevent the warning), even in conjunction with macros. This also
6182enables some language-specific warnings described in @ref{C++ Dialect
6183Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6184
6185@option{-Wall} turns on the following warning flags:
6186
43b72ede
AA
6187@gccoptlist{-Waddress
6188-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6189-Warray-compare
6190-Warray-parameter=2 @r{(C and Objective-C only)}
6191-Wbool-compare
6192-Wbool-operation
6193-Wc++11-compat -Wc++14-compat
6194-Wcatch-value @r{(C++ and Objective-C++ only)}
6195-Wchar-subscripts
6196-Wcomment
6197-Wdangling-pointer=2
6198-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6199-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6200-Wenum-int-mismatch @r{(C and Objective-C only)}
6201-Wformat
6202-Wformat-overflow
6203-Wformat-truncation
6204-Wint-in-bool-context
6205-Wimplicit @r{(C and Objective-C only)}
6206-Wimplicit-int @r{(C and Objective-C only)}
6207-Wimplicit-function-declaration @r{(C and Objective-C only)}
6208-Winit-self @r{(only for C++)}
6209-Wlogical-not-parentheses
6210-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6211-Wmaybe-uninitialized
6212-Wmemset-elt-size
6213-Wmemset-transposed-args
6214-Wmisleading-indentation @r{(only for C/C++)}
6215-Wmismatched-dealloc
6216-Wmismatched-new-delete @r{(only for C/C++)}
6217-Wmissing-attributes
6218-Wmissing-braces @r{(only for C/ObjC)}
6219-Wmultistatement-macros
6220-Wnarrowing @r{(only for C++)}
6221-Wnonnull
6222-Wnonnull-compare
6223-Wopenmp-simd
6224-Wparentheses
6225-Wpessimizing-move @r{(only for C++)}
6226-Wpointer-sign
6227-Wrange-loop-construct @r{(only for C++)}
6228-Wreorder
6229-Wrestrict
6230-Wreturn-type
6231-Wself-move @r{(only for C++)}
6232-Wsequence-point
6233-Wsign-compare @r{(only in C++)}
6234-Wsizeof-array-div
6235-Wsizeof-pointer-div
6236-Wsizeof-pointer-memaccess
6237-Wstrict-aliasing
6238-Wstrict-overflow=1
6239-Wswitch
6240-Wtautological-compare
6241-Wtrigraphs
6242-Wuninitialized
6243-Wunknown-pragmas
6244-Wunused-function
6245-Wunused-label
6246-Wunused-value
6247-Wunused-variable
6248-Wuse-after-free=2
6249-Wvla-parameter @r{(C and Objective-C only)}
6250-Wvolatile-register-var
d77de738
ML
6251-Wzero-length-bounds}
6252
6253Note that some warning flags are not implied by @option{-Wall}. Some of
6254them warn about constructions that users generally do not consider
6255questionable, but which occasionally you might wish to check for;
6256others warn about constructions that are necessary or hard to avoid in
6257some cases, and there is no simple way to modify the code to suppress
6258the warning. Some of them are enabled by @option{-Wextra} but many of
6259them must be enabled individually.
6260
d77de738
ML
6261@opindex W
6262@opindex Wextra
6263@opindex Wno-extra
ddf6fe37 6264@item -Wextra
d77de738
ML
6265This enables some extra warning flags that are not enabled by
6266@option{-Wall}. (This option used to be called @option{-W}. The older
6267name is still supported, but the newer name is more descriptive.)
6268
43b72ede
AA
6269@gccoptlist{-Wclobbered
6270-Wcast-function-type
6271-Wdeprecated-copy @r{(C++ only)}
6272-Wempty-body
6273-Wenum-conversion @r{(C only)}
6274-Wignored-qualifiers
6275-Wimplicit-fallthrough=3
6276-Wmissing-field-initializers
6277-Wmissing-parameter-type @r{(C only)}
6278-Wold-style-declaration @r{(C only)}
6279-Woverride-init
6280-Wsign-compare @r{(C only)}
6281-Wstring-compare
6282-Wredundant-move @r{(only for C++)}
6283-Wtype-limits
6284-Wuninitialized
6285-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6286-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6287-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6288
6289
6290The option @option{-Wextra} also prints warning messages for the
6291following cases:
6292
6293@itemize @bullet
6294
6295@item
6296A pointer is compared against integer zero with @code{<}, @code{<=},
6297@code{>}, or @code{>=}.
6298
6299@item
6300(C++ only) An enumerator and a non-enumerator both appear in a
6301conditional expression.
6302
6303@item
6304(C++ only) Ambiguous virtual bases.
6305
6306@item
6307(C++ only) Subscripting an array that has been declared @code{register}.
6308
6309@item
6310(C++ only) Taking the address of a variable that has been declared
6311@code{register}.
6312
6313@item
6314(C++ only) A base class is not initialized in the copy constructor
6315of a derived class.
6316
6317@end itemize
6318
d77de738
ML
6319@opindex Wabi
6320@opindex Wno-abi
ddf6fe37 6321@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6322
6323Warn about code affected by ABI changes. This includes code that may
6324not be compatible with the vendor-neutral C++ ABI as well as the psABI
6325for the particular target.
6326
6327Since G++ now defaults to updating the ABI with each major release,
6328normally @option{-Wabi} warns only about C++ ABI compatibility
6329problems if there is a check added later in a release series for an
6330ABI issue discovered since the initial release. @option{-Wabi} warns
6331about more things if an older ABI version is selected (with
6332@option{-fabi-version=@var{n}}).
6333
6334@option{-Wabi} can also be used with an explicit version number to
6335warn about C++ ABI compatibility with a particular @option{-fabi-version}
6336level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6337@option{-fabi-version=2}.
6338
6339If an explicit version number is provided and
6340@option{-fabi-compat-version} is not specified, the version number
6341from this option is used for compatibility aliases. If no explicit
6342version number is provided with this option, but
6343@option{-fabi-compat-version} is specified, that version number is
6344used for C++ ABI warnings.
6345
6346Although an effort has been made to warn about
6347all such cases, there are probably some cases that are not warned about,
6348even though G++ is generating incompatible code. There may also be
6349cases where warnings are emitted even though the code that is generated
6350is compatible.
6351
6352You should rewrite your code to avoid these warnings if you are
6353concerned about the fact that code generated by G++ may not be binary
6354compatible with code generated by other compilers.
6355
6356Known incompatibilities in @option{-fabi-version=2} (which was the
6357default from GCC 3.4 to 4.9) include:
6358
6359@itemize @bullet
6360
6361@item
6362A template with a non-type template parameter of reference type was
6363mangled incorrectly:
6364@smallexample
6365extern int N;
6366template <int &> struct S @{@};
6367void n (S<N>) @{2@}
6368@end smallexample
6369
6370This was fixed in @option{-fabi-version=3}.
6371
6372@item
6373SIMD vector types declared using @code{__attribute ((vector_size))} were
6374mangled in a non-standard way that does not allow for overloading of
6375functions taking vectors of different sizes.
6376
6377The mangling was changed in @option{-fabi-version=4}.
6378
6379@item
6380@code{__attribute ((const))} and @code{noreturn} were mangled as type
6381qualifiers, and @code{decltype} of a plain declaration was folded away.
6382
6383These mangling issues were fixed in @option{-fabi-version=5}.
6384
6385@item
6386Scoped enumerators passed as arguments to a variadic function are
6387promoted like unscoped enumerators, causing @code{va_arg} to complain.
6388On most targets this does not actually affect the parameter passing
6389ABI, as there is no way to pass an argument smaller than @code{int}.
6390
6391Also, the ABI changed the mangling of template argument packs,
6392@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6393a class scope function used as a template argument.
6394
6395These issues were corrected in @option{-fabi-version=6}.
6396
6397@item
6398Lambdas in default argument scope were mangled incorrectly, and the
6399ABI changed the mangling of @code{nullptr_t}.
6400
6401These issues were corrected in @option{-fabi-version=7}.
6402
6403@item
6404When mangling a function type with function-cv-qualifiers, the
6405un-qualified function type was incorrectly treated as a substitution
6406candidate.
6407
6408This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6409
6410@item
6411@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6412unaligned accesses. Note that this did not affect the ABI of a
6413function with a @code{nullptr_t} parameter, as parameters have a
6414minimum alignment.
6415
6416This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6417
6418@item
6419Target-specific attributes that affect the identity of a type, such as
6420ia32 calling conventions on a function type (stdcall, regparm, etc.),
6421did not affect the mangled name, leading to name collisions when
6422function pointers were used as template arguments.
6423
6424This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6425
6426@end itemize
6427
6428This option also enables warnings about psABI-related changes.
6429The known psABI changes at this point include:
6430
6431@itemize @bullet
6432
6433@item
6434For SysV/x86-64, unions with @code{long double} members are
6435passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6436the case. For example:
6437
6438@smallexample
6439union U @{
6440 long double ld;
6441 int i;
6442@};
6443@end smallexample
6444
6445@noindent
6446@code{union U} is now always passed in memory.
6447
6448@end itemize
6449
e2f939d3
JM
6450@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6451C++ requires that unqualified uses of a name within a class have the
6452same meaning in the complete scope of the class, so declaring the name
6453after using it is ill-formed:
6454@smallexample
6455struct A;
6456struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6457struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6458@end smallexample
6459By default, the B1 case is only a warning because the two declarations
6460have the same type, while the B2 case is an error. Both diagnostics
6461can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6462error case can be reduced to a warning with
6463@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6464
6465Both diagnostics are also suppressed by @option{-fms-extensions}.
6466
d77de738
ML
6467@opindex Wchar-subscripts
6468@opindex Wno-char-subscripts
ddf6fe37 6469@item -Wchar-subscripts
d77de738
ML
6470Warn if an array subscript has type @code{char}. This is a common cause
6471of error, as programmers often forget that this type is signed on some
6472machines.
6473This warning is enabled by @option{-Wall}.
6474
d77de738
ML
6475@opindex Wno-coverage-mismatch
6476@opindex Wcoverage-mismatch
ddf6fe37 6477@item -Wno-coverage-mismatch
d77de738
ML
6478Warn if feedback profiles do not match when using the
6479@option{-fprofile-use} option.
6480If a source file is changed between compiling with @option{-fprofile-generate}
6481and with @option{-fprofile-use}, the files with the profile feedback can fail
6482to match the source file and GCC cannot use the profile feedback
6483information. By default, this warning is enabled and is treated as an
6484error. @option{-Wno-coverage-mismatch} can be used to disable the
6485warning or @option{-Wno-error=coverage-mismatch} can be used to
6486disable the error. Disabling the error for this warning can result in
6487poorly optimized code and is useful only in the
6488case of very minor changes such as bug fixes to an existing code-base.
6489Completely disabling the warning is not recommended.
6490
d77de738
ML
6491@opindex Wno-coverage-invalid-line-number
6492@opindex Wcoverage-invalid-line-number
ddf6fe37 6493@item -Wno-coverage-invalid-line-number
d77de738
ML
6494Warn in case a function ends earlier than it begins due
6495to an invalid linenum macros. The warning is emitted only
6496with @option{--coverage} enabled.
6497
6498By default, this warning is enabled and is treated as an
6499error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6500warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6501disable the error.
6502
d77de738
ML
6503@opindex Wno-cpp
6504@opindex Wcpp
ddf6fe37 6505@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6506Suppress warning messages emitted by @code{#warning} directives.
6507
d77de738
ML
6508@opindex Wdouble-promotion
6509@opindex Wno-double-promotion
ddf6fe37 6510@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6511Give a warning when a value of type @code{float} is implicitly
6512promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6513floating-point unit implement @code{float} in hardware, but emulate
6514@code{double} in software. On such a machine, doing computations
6515using @code{double} values is much more expensive because of the
6516overhead required for software emulation.
6517
6518It is easy to accidentally do computations with @code{double} because
6519floating-point literals are implicitly of type @code{double}. For
6520example, in:
6521@smallexample
6522@group
6523float area(float radius)
6524@{
6525 return 3.14159 * radius * radius;
6526@}
6527@end group
6528@end smallexample
6529the compiler performs the entire computation with @code{double}
6530because the floating-point literal is a @code{double}.
6531
d77de738
ML
6532@opindex Wduplicate-decl-specifier
6533@opindex Wno-duplicate-decl-specifier
ddf6fe37 6534@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6535Warn if a declaration has duplicate @code{const}, @code{volatile},
6536@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6537@option{-Wall}.
6538
d77de738
ML
6539@opindex Wformat
6540@opindex Wno-format
6541@opindex ffreestanding
6542@opindex fno-builtin
6543@opindex Wformat=
ddf6fe37
AA
6544@item -Wformat
6545@itemx -Wformat=@var{n}
d77de738
ML
6546Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6547the arguments supplied have types appropriate to the format string
6548specified, and that the conversions specified in the format string make
6549sense. This includes standard functions, and others specified by format
6550attributes (@pxref{Function Attributes}), in the @code{printf},
6551@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6552not in the C standard) families (or other target-specific families).
6553Which functions are checked without format attributes having been
6554specified depends on the standard version selected, and such checks of
6555functions without the attribute specified are disabled by
6556@option{-ffreestanding} or @option{-fno-builtin}.
6557
6558The formats are checked against the format features supported by GNU
6559libc version 2.2. These include all ISO C90 and C99 features, as well
6560as features from the Single Unix Specification and some BSD and GNU
6561extensions. Other library implementations may not support all these
6562features; GCC does not support warning about features that go beyond a
6563particular library's limitations. However, if @option{-Wpedantic} is used
6564with @option{-Wformat}, warnings are given about format features not
6565in the selected standard version (but not for @code{strfmon} formats,
6566since those are not in any version of the C standard). @xref{C Dialect
6567Options,,Options Controlling C Dialect}.
6568
6569@table @gcctabopt
d77de738
ML
6570@opindex Wformat
6571@opindex Wformat=1
ddf6fe37
AA
6572@item -Wformat=1
6573@itemx -Wformat
d77de738
ML
6574Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6575@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6576@option{-Wformat} also checks for null format arguments for several
6577functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6578aspects of this level of format checking can be disabled by the
6579options: @option{-Wno-format-contains-nul},
6580@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6581@option{-Wformat} is enabled by @option{-Wall}.
6582
d77de738 6583@opindex Wformat=2
ddf6fe37 6584@item -Wformat=2
d77de738
ML
6585Enable @option{-Wformat} plus additional format checks. Currently
6586equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6587-Wformat-y2k}.
6588@end table
6589
d77de738
ML
6590@opindex Wno-format-contains-nul
6591@opindex Wformat-contains-nul
ddf6fe37 6592@item -Wno-format-contains-nul
d77de738
ML
6593If @option{-Wformat} is specified, do not warn about format strings that
6594contain NUL bytes.
6595
d77de738
ML
6596@opindex Wno-format-extra-args
6597@opindex Wformat-extra-args
ddf6fe37 6598@item -Wno-format-extra-args
d77de738
ML
6599If @option{-Wformat} is specified, do not warn about excess arguments to a
6600@code{printf} or @code{scanf} format function. The C standard specifies
6601that such arguments are ignored.
6602
6603Where the unused arguments lie between used arguments that are
6604specified with @samp{$} operand number specifications, normally
6605warnings are still given, since the implementation could not know what
6606type to pass to @code{va_arg} to skip the unused arguments. However,
6607in the case of @code{scanf} formats, this option suppresses the
6608warning if the unused arguments are all pointers, since the Single
6609Unix Specification says that such unused arguments are allowed.
6610
d77de738
ML
6611@opindex Wformat-overflow
6612@opindex Wno-format-overflow
ddf6fe37
AA
6613@item -Wformat-overflow
6614@itemx -Wformat-overflow=@var{level}
d77de738
ML
6615Warn about calls to formatted input/output functions such as @code{sprintf}
6616and @code{vsprintf} that might overflow the destination buffer. When the
6617exact number of bytes written by a format directive cannot be determined
6618at compile-time it is estimated based on heuristics that depend on the
6619@var{level} argument and on optimization. While enabling optimization
6620will in most cases improve the accuracy of the warning, it may also
6621result in false positives.
6622
6623@table @gcctabopt
d77de738
ML
6624@opindex Wformat-overflow
6625@opindex Wno-format-overflow
ddf6fe37
AA
6626@item -Wformat-overflow
6627@itemx -Wformat-overflow=1
d77de738
ML
6628Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6629employs a conservative approach that warns only about calls that most
6630likely overflow the buffer. At this level, numeric arguments to format
6631directives with unknown values are assumed to have the value of one, and
6632strings of unknown length to be empty. Numeric arguments that are known
6633to be bounded to a subrange of their type, or string arguments whose output
6634is bounded either by their directive's precision or by a finite set of
6635string literals, are assumed to take on the value within the range that
6636results in the most bytes on output. For example, the call to @code{sprintf}
6637below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6638the terminating NUL character (@code{'\0'}) appended by the function
6639to the destination buffer will be written past its end. Increasing
6640the size of the buffer by a single byte is sufficient to avoid the
6641warning, though it may not be sufficient to avoid the overflow.
6642
6643@smallexample
6644void f (int a, int b)
6645@{
6646 char buf [13];
6647 sprintf (buf, "a = %i, b = %i\n", a, b);
6648@}
6649@end smallexample
6650
6651@item -Wformat-overflow=2
6652Level @var{2} warns also about calls that might overflow the destination
6653buffer given an argument of sufficient length or magnitude. At level
6654@var{2}, unknown numeric arguments are assumed to have the minimum
6655representable value for signed types with a precision greater than 1, and
6656the maximum representable value otherwise. Unknown string arguments whose
6657length cannot be assumed to be bounded either by the directive's precision,
6658or by a finite set of string literals they may evaluate to, or the character
6659array they may point to, are assumed to be 1 character long.
6660
6661At level @var{2}, the call in the example above is again diagnosed, but
6662this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6663@code{%i} directive will write some of its digits beyond the end of
6664the destination buffer. To make the call safe regardless of the values
6665of the two variables, the size of the destination buffer must be increased
6666to at least 34 bytes. GCC includes the minimum size of the buffer in
6667an informational note following the warning.
6668
6669An alternative to increasing the size of the destination buffer is to
6670constrain the range of formatted values. The maximum length of string
6671arguments can be bounded by specifying the precision in the format
6672directive. When numeric arguments of format directives can be assumed
6673to be bounded by less than the precision of their type, choosing
6674an appropriate length modifier to the format specifier will reduce
6675the required buffer size. For example, if @var{a} and @var{b} in the
6676example above can be assumed to be within the precision of
6677the @code{short int} type then using either the @code{%hi} format
6678directive or casting the argument to @code{short} reduces the maximum
6679required size of the buffer to 24 bytes.
6680
6681@smallexample
6682void f (int a, int b)
6683@{
6684 char buf [23];
6685 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6686@}
6687@end smallexample
6688@end table
6689
d77de738
ML
6690@opindex Wno-format-zero-length
6691@opindex Wformat-zero-length
ddf6fe37 6692@item -Wno-format-zero-length
d77de738
ML
6693If @option{-Wformat} is specified, do not warn about zero-length formats.
6694The C standard specifies that zero-length formats are allowed.
6695
d77de738
ML
6696@opindex Wformat-nonliteral
6697@opindex Wno-format-nonliteral
ddf6fe37 6698@item -Wformat-nonliteral
d77de738
ML
6699If @option{-Wformat} is specified, also warn if the format string is not a
6700string literal and so cannot be checked, unless the format function
6701takes its format arguments as a @code{va_list}.
6702
d77de738
ML
6703@opindex Wformat-security
6704@opindex Wno-format-security
ddf6fe37 6705@item -Wformat-security
d77de738
ML
6706If @option{-Wformat} is specified, also warn about uses of format
6707functions that represent possible security problems. At present, this
6708warns about calls to @code{printf} and @code{scanf} functions where the
6709format string is not a string literal and there are no format arguments,
6710as in @code{printf (foo);}. This may be a security hole if the format
6711string came from untrusted input and contains @samp{%n}. (This is
6712currently a subset of what @option{-Wformat-nonliteral} warns about, but
6713in future warnings may be added to @option{-Wformat-security} that are not
6714included in @option{-Wformat-nonliteral}.)
6715
d77de738
ML
6716@opindex Wformat-signedness
6717@opindex Wno-format-signedness
ddf6fe37 6718@item -Wformat-signedness
d77de738
ML
6719If @option{-Wformat} is specified, also warn if the format string
6720requires an unsigned argument and the argument is signed and vice versa.
6721
d77de738
ML
6722@opindex Wformat-truncation
6723@opindex Wno-format-truncation
ddf6fe37
AA
6724@item -Wformat-truncation
6725@itemx -Wformat-truncation=@var{level}
d77de738
ML
6726Warn about calls to formatted input/output functions such as @code{snprintf}
6727and @code{vsnprintf} that might result in output truncation. When the exact
6728number of bytes written by a format directive cannot be determined at
6729compile-time it is estimated based on heuristics that depend on
6730the @var{level} argument and on optimization. While enabling optimization
6731will in most cases improve the accuracy of the warning, it may also result
6732in false positives. Except as noted otherwise, the option uses the same
6733logic @option{-Wformat-overflow}.
6734
6735@table @gcctabopt
d77de738
ML
6736@opindex Wformat-truncation
6737@opindex Wno-format-truncation
ddf6fe37
AA
6738@item -Wformat-truncation
6739@itemx -Wformat-truncation=1
d77de738
ML
6740Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6741employs a conservative approach that warns only about calls to bounded
6742functions whose return value is unused and that will most likely result
6743in output truncation.
6744
6745@item -Wformat-truncation=2
6746Level @var{2} warns also about calls to bounded functions whose return
6747value is used and that might result in truncation given an argument of
6748sufficient length or magnitude.
6749@end table
6750
d77de738
ML
6751@opindex Wformat-y2k
6752@opindex Wno-format-y2k
ddf6fe37 6753@item -Wformat-y2k
d77de738
ML
6754If @option{-Wformat} is specified, also warn about @code{strftime}
6755formats that may yield only a two-digit year.
6756
d77de738
ML
6757@opindex Wnonnull
6758@opindex Wno-nonnull
ddf6fe37 6759@item -Wnonnull
d77de738
ML
6760Warn about passing a null pointer for arguments marked as
6761requiring a non-null value by the @code{nonnull} function attribute.
6762
6763@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6764can be disabled with the @option{-Wno-nonnull} option.
6765
d77de738
ML
6766@opindex Wnonnull-compare
6767@opindex Wno-nonnull-compare
ddf6fe37 6768@item -Wnonnull-compare
d77de738
ML
6769Warn when comparing an argument marked with the @code{nonnull}
6770function attribute against null inside the function.
6771
6772@option{-Wnonnull-compare} is included in @option{-Wall}. It
6773can be disabled with the @option{-Wno-nonnull-compare} option.
6774
d77de738
ML
6775@opindex Wnull-dereference
6776@opindex Wno-null-dereference
ddf6fe37 6777@item -Wnull-dereference
d77de738
ML
6778Warn if the compiler detects paths that trigger erroneous or
6779undefined behavior due to dereferencing a null pointer. This option
6780is only active when @option{-fdelete-null-pointer-checks} is active,
6781which is enabled by optimizations in most targets. The precision of
6782the warnings depends on the optimization options used.
6783
2ae5384d
JM
6784@opindex Wnrvo
6785@opindex Wno-nrvo
6786@item -Wnrvo @r{(C++ and Objective-C++ only)}
6787Warn if the compiler does not elide the copy from a local variable to
6788the return value of a function in a context where it is allowed by
6789[class.copy.elision]. This elision is commonly known as the Named
6790Return Value Optimization. For instance, in the example below the
72cfa0f7 6791compiler cannot elide copies from both v1 and v2, so it elides neither.
2ae5384d
JM
6792
6793@smallexample
6794std::vector<int> f()
6795@{
6796 std::vector<int> v1, v2;
6797 // ...
6798 if (cond) return v1;
6799 else return v2; // warning: not eliding copy
6800@}
6801@end smallexample
6802
d77de738
ML
6803@opindex Winfinite-recursion
6804@opindex Wno-infinite-recursion
ddf6fe37 6805@item -Winfinite-recursion
d77de738
ML
6806Warn about infinitely recursive calls. The warning is effective at all
6807optimization levels but requires optimization in order to detect infinite
6808recursion in calls between two or more functions.
6809@option{-Winfinite-recursion} is included in @option{-Wall}.
6810
ce51e843
ML
6811Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6812similar diagnostic, but is implemented in a different way (as part of
6813@option{-fanalyzer}).
6814
d77de738
ML
6815@opindex Winit-self
6816@opindex Wno-init-self
ddf6fe37 6817@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6818Warn about uninitialized variables that are initialized with themselves.
6819Note this option can only be used with the @option{-Wuninitialized} option.
6820
6821For example, GCC warns about @code{i} being uninitialized in the
6822following snippet only when @option{-Winit-self} has been specified:
6823@smallexample
6824@group
6825int f()
6826@{
6827 int i = i;
6828 return i;
6829@}
6830@end group
6831@end smallexample
6832
6833This warning is enabled by @option{-Wall} in C++.
6834
d77de738
ML
6835@opindex Wimplicit-int
6836@opindex Wno-implicit-int
ddf6fe37 6837@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6838This option controls warnings when a declaration does not specify a type.
6839This warning is enabled by default in C99 and later dialects of C,
6840and also by @option{-Wall}.
6841
5fccebdb
JM
6842This warning is upgraded to an error by @option{-pedantic-errors}.
6843
d77de738
ML
6844@opindex Wimplicit-function-declaration
6845@opindex Wno-implicit-function-declaration
ddf6fe37 6846@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6847This option controls warnings when a function is used before being declared.
6848This warning is enabled by default in C99 and later dialects of C,
6849and also by @option{-Wall}.
5fccebdb
JM
6850
6851This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 6852
d77de738
ML
6853@opindex Wimplicit
6854@opindex Wno-implicit
ddf6fe37 6855@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6856Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6857This warning is enabled by @option{-Wall}.
6858
d77de738
ML
6859@opindex Wimplicit-fallthrough
6860@opindex Wno-implicit-fallthrough
ddf6fe37 6861@item -Wimplicit-fallthrough
d77de738
ML
6862@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6863and @option{-Wno-implicit-fallthrough} is the same as
6864@option{-Wimplicit-fallthrough=0}.
6865
d77de738 6866@opindex Wimplicit-fallthrough=
ddf6fe37 6867@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6868Warn when a switch case falls through. For example:
6869
6870@smallexample
6871@group
6872switch (cond)
6873 @{
6874 case 1:
6875 a = 1;
6876 break;
6877 case 2:
6878 a = 2;
6879 case 3:
6880 a = 3;
6881 break;
6882 @}
6883@end group
6884@end smallexample
6885
6886This warning does not warn when the last statement of a case cannot
6887fall through, e.g. when there is a return statement or a call to function
6888declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6889also takes into account control flow statements, such as ifs, and only
6890warns when appropriate. E.g.@:
6891
6892@smallexample
6893@group
6894switch (cond)
6895 @{
6896 case 1:
6897 if (i > 3) @{
6898 bar (5);
6899 break;
6900 @} else if (i < 1) @{
6901 bar (0);
6902 @} else
6903 return;
6904 default:
6905 @dots{}
6906 @}
6907@end group
6908@end smallexample
6909
6910Since there are occasions where a switch case fall through is desirable,
6911GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6912to be used along with a null statement to suppress this warning that
6913would normally occur:
6914
6915@smallexample
6916@group
6917switch (cond)
6918 @{
6919 case 1:
6920 bar (0);
6921 __attribute__ ((fallthrough));
6922 default:
6923 @dots{}
6924 @}
6925@end group
6926@end smallexample
6927
6928C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6929warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6930or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6931Instead of these attributes, it is also possible to add a fallthrough comment
6932to silence the warning. The whole body of the C or C++ style comment should
6933match the given regular expressions listed below. The option argument @var{n}
6934specifies what kind of comments are accepted:
6935
6936@itemize @bullet
6937
6938@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6939
6940@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6941expression, any comment is used as fallthrough comment.
6942
6943@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6944@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6945
6946@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6947following regular expressions:
6948
6949@itemize @bullet
6950
6951@item @code{-fallthrough}
6952
6953@item @code{@@fallthrough@@}
6954
6955@item @code{lint -fallthrough[ \t]*}
6956
6957@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6958
6959@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6960
6961@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6962
6963@end itemize
6964
6965@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6966following regular expressions:
6967
6968@itemize @bullet
6969
6970@item @code{-fallthrough}
6971
6972@item @code{@@fallthrough@@}
6973
6974@item @code{lint -fallthrough[ \t]*}
6975
6976@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6977
6978@end itemize
6979
6980@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6981fallthrough comments, only attributes disable the warning.
6982
6983@end itemize
6984
6985The comment needs to be followed after optional whitespace and other comments
6986by @code{case} or @code{default} keywords or by a user label that precedes some
6987@code{case} or @code{default} label.
6988
6989@smallexample
6990@group
6991switch (cond)
6992 @{
6993 case 1:
6994 bar (0);
6995 /* FALLTHRU */
6996 default:
6997 @dots{}
6998 @}
6999@end group
7000@end smallexample
7001
7002The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7003
d77de738
ML
7004@opindex Wif-not-aligned
7005@opindex Wno-if-not-aligned
ddf6fe37 7006@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7007Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7008should be issued. These warnings are enabled by default.
7009
d77de738
ML
7010@opindex Wignored-qualifiers
7011@opindex Wno-ignored-qualifiers
ddf6fe37 7012@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
7013Warn if the return type of a function has a type qualifier
7014such as @code{const}. For ISO C such a type qualifier has no effect,
7015since the value returned by a function is not an lvalue.
7016For C++, the warning is only emitted for scalar types or @code{void}.
7017ISO C prohibits qualified @code{void} return types on function
7018definitions, so such return types always receive a warning
7019even without this option.
7020
7021This warning is also enabled by @option{-Wextra}.
7022
d77de738
ML
7023@opindex Wignored-attributes
7024@opindex Wno-ignored-attributes
ddf6fe37 7025@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
7026This option controls warnings when an attribute is ignored.
7027This is different from the
7028@option{-Wattributes} option in that it warns whenever the compiler decides
7029to drop an attribute, not that the attribute is either unknown, used in a
7030wrong place, etc. This warning is enabled by default.
7031
d77de738
ML
7032@opindex Wmain
7033@opindex Wno-main
ddf6fe37 7034@item -Wmain
d77de738
ML
7035Warn if the type of @code{main} is suspicious. @code{main} should be
7036a function with external linkage, returning int, taking either zero
7037arguments, two, or three arguments of appropriate types. This warning
7038is enabled by default in C++ and is enabled by either @option{-Wall}
7039or @option{-Wpedantic}.
7040
5fccebdb
JM
7041This warning is upgraded to an error by @option{-pedantic-errors}.
7042
d77de738
ML
7043@opindex Wmisleading-indentation
7044@opindex Wno-misleading-indentation
ddf6fe37 7045@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
7046Warn when the indentation of the code does not reflect the block structure.
7047Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7048@code{for} clauses with a guarded statement that does not use braces,
7049followed by an unguarded statement with the same indentation.
7050
7051In the following example, the call to ``bar'' is misleadingly indented as
7052if it were guarded by the ``if'' conditional.
7053
7054@smallexample
7055 if (some_condition ())
7056 foo ();
7057 bar (); /* Gotcha: this is not guarded by the "if". */
7058@end smallexample
7059
7060In the case of mixed tabs and spaces, the warning uses the
7061@option{-ftabstop=} option to determine if the statements line up
7062(defaulting to 8).
7063
7064The warning is not issued for code involving multiline preprocessor logic
7065such as the following example.
7066
7067@smallexample
7068 if (flagA)
7069 foo (0);
7070#if SOME_CONDITION_THAT_DOES_NOT_HOLD
7071 if (flagB)
7072#endif
7073 foo (1);
7074@end smallexample
7075
7076The warning is not issued after a @code{#line} directive, since this
7077typically indicates autogenerated code, and no assumptions can be made
7078about the layout of the file that the directive references.
7079
7080This warning is enabled by @option{-Wall} in C and C++.
7081
d77de738
ML
7082@opindex Wmissing-attributes
7083@opindex Wno-missing-attributes
ddf6fe37 7084@item -Wmissing-attributes
d77de738
ML
7085Warn when a declaration of a function is missing one or more attributes
7086that a related function is declared with and whose absence may adversely
7087affect the correctness or efficiency of generated code. For example,
7088the warning is issued for declarations of aliases that use attributes
7089to specify less restrictive requirements than those of their targets.
7090This typically represents a potential optimization opportunity.
7091By contrast, the @option{-Wattribute-alias=2} option controls warnings
7092issued when the alias is more restrictive than the target, which could
7093lead to incorrect code generation.
7094Attributes considered include @code{alloc_align}, @code{alloc_size},
7095@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7096@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7097@code{returns_nonnull}, and @code{returns_twice}.
7098
7099In C++, the warning is issued when an explicit specialization of a primary
7100template declared with attribute @code{alloc_align}, @code{alloc_size},
7101@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7102or @code{nonnull} is declared without it. Attributes @code{deprecated},
7103@code{error}, and @code{warning} suppress the warning.
7104(@pxref{Function Attributes}).
7105
7106You can use the @code{copy} attribute to apply the same
7107set of attributes to a declaration as that on another declaration without
7108explicitly enumerating the attributes. This attribute can be applied
7109to declarations of functions (@pxref{Common Function Attributes}),
7110variables (@pxref{Common Variable Attributes}), or types
7111(@pxref{Common Type Attributes}).
7112
7113@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7114
7115For example, since the declaration of the primary function template
7116below makes use of both attribute @code{malloc} and @code{alloc_size}
7117the declaration of the explicit specialization of the template is
7118diagnosed because it is missing one of the attributes.
7119
7120@smallexample
7121template <class T>
7122T* __attribute__ ((malloc, alloc_size (1)))
7123allocate (size_t);
7124
7125template <>
7126void* __attribute__ ((malloc)) // missing alloc_size
7127allocate<void> (size_t);
7128@end smallexample
7129
d77de738
ML
7130@opindex Wmissing-braces
7131@opindex Wno-missing-braces
ddf6fe37 7132@item -Wmissing-braces
d77de738
ML
7133Warn if an aggregate or union initializer is not fully bracketed. In
7134the following example, the initializer for @code{a} is not fully
7135bracketed, but that for @code{b} is fully bracketed.
7136
7137@smallexample
7138int a[2][2] = @{ 0, 1, 2, 3 @};
7139int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7140@end smallexample
7141
7142This warning is enabled by @option{-Wall}.
7143
d77de738
ML
7144@opindex Wmissing-include-dirs
7145@opindex Wno-missing-include-dirs
ddf6fe37 7146@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
72cfa0f7 7147Warn if a user-supplied include directory does not exist. This option is disabled
d77de738
ML
7148by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7149enabled by default by warning for -I and -J, only.
7150
d77de738
ML
7151@opindex Wmissing-profile
7152@opindex Wno-missing-profile
ddf6fe37 7153@item -Wno-missing-profile
d77de738
ML
7154This option controls warnings if feedback profiles are missing when using the
7155@option{-fprofile-use} option.
7156This option diagnoses those cases where a new function or a new file is added
7157between compiling with @option{-fprofile-generate} and with
7158@option{-fprofile-use}, without regenerating the profiles.
7159In these cases, the profile feedback data files do not contain any
7160profile feedback information for
7161the newly added function or file respectively. Also, in the case when profile
7162count data (.gcda) files are removed, GCC cannot use any profile feedback
7163information. In all these cases, warnings are issued to inform you that a
7164profile generation step is due.
7165Ignoring the warning can result in poorly optimized code.
7166@option{-Wno-missing-profile} can be used to
7167disable the warning, but this is not recommended and should be done only
7168when non-existent profile data is justified.
7169
d77de738
ML
7170@opindex Wmismatched-dealloc
7171@opindex Wno-mismatched-dealloc
ddf6fe37 7172@item -Wmismatched-dealloc
d77de738
ML
7173
7174Warn for calls to deallocation functions with pointer arguments returned
7175from from allocations functions for which the former isn't a suitable
7176deallocator. A pair of functions can be associated as matching allocators
7177and deallocators by use of attribute @code{malloc}. Unless disabled by
7178the @option{-fno-builtin} option the standard functions @code{calloc},
7179@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7180forms of C++ @code{operator new} and @code{operator delete} are implicitly
7181associated as matching allocators and deallocators. In the following
7182example @code{mydealloc} is the deallocator for pointers returned from
7183@code{myalloc}.
7184
7185@smallexample
7186void mydealloc (void*);
7187
7188__attribute__ ((malloc (mydealloc, 1))) void*
7189myalloc (size_t);
7190
7191void f (void)
7192@{
7193 void *p = myalloc (32);
7194 // @dots{}use p@dots{}
7195 free (p); // warning: not a matching deallocator for myalloc
7196 mydealloc (p); // ok
7197@}
7198@end smallexample
7199
7200In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7201mismatches involving either @code{operator new} or @code{operator delete}.
7202
7203Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7204
d77de738
ML
7205@opindex Wmultistatement-macros
7206@opindex Wno-multistatement-macros
ddf6fe37 7207@item -Wmultistatement-macros
d77de738
ML
7208Warn about unsafe multiple statement macros that appear to be guarded
7209by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7210@code{while}, in which only the first statement is actually guarded after
7211the macro is expanded.
7212
7213For example:
7214
7215@smallexample
7216#define DOIT x++; y++
7217if (c)
7218 DOIT;
7219@end smallexample
7220
7221will increment @code{y} unconditionally, not just when @code{c} holds.
7222The can usually be fixed by wrapping the macro in a do-while loop:
7223@smallexample
7224#define DOIT do @{ x++; y++; @} while (0)
7225if (c)
7226 DOIT;
7227@end smallexample
7228
7229This warning is enabled by @option{-Wall} in C and C++.
7230
d77de738
ML
7231@opindex Wparentheses
7232@opindex Wno-parentheses
ddf6fe37 7233@item -Wparentheses
d77de738
ML
7234Warn if parentheses are omitted in certain contexts, such
7235as when there is an assignment in a context where a truth value
7236is expected, or when operators are nested whose precedence people
7237often get confused about.
7238
7239Also warn if a comparison like @code{x<=y<=z} appears; this is
7240equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7241interpretation from that of ordinary mathematical notation.
7242
7243Also warn for dangerous uses of the GNU extension to
7244@code{?:} with omitted middle operand. When the condition
7245in the @code{?}: operator is a boolean expression, the omitted value is
7246always 1. Often programmers expect it to be a value computed
7247inside the conditional expression instead.
7248
7249For C++ this also warns for some cases of unnecessary parentheses in
7250declarations, which can indicate an attempt at a function call instead
7251of a declaration:
7252@smallexample
7253@{
7254 // Declares a local variable called mymutex.
7255 std::unique_lock<std::mutex> (mymutex);
7256 // User meant std::unique_lock<std::mutex> lock (mymutex);
7257@}
7258@end smallexample
7259
7260This warning is enabled by @option{-Wall}.
7261
d77de738
ML
7262@opindex Wself-move
7263@opindex Wno-self-move
ddf6fe37 7264@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7265This warning warns when a value is moved to itself with @code{std::move}.
7266Such a @code{std::move} typically has no effect.
7267
7268@smallexample
7269struct T @{
7270@dots{}
7271@};
7272void fn()
7273@{
7274 T t;
7275 @dots{}
7276 t = std::move (t);
7277@}
7278@end smallexample
7279
7280This warning is enabled by @option{-Wall}.
7281
d77de738
ML
7282@opindex Wsequence-point
7283@opindex Wno-sequence-point
ddf6fe37 7284@item -Wsequence-point
d77de738
ML
7285Warn about code that may have undefined semantics because of violations
7286of sequence point rules in the C and C++ standards.
7287
7288The C and C++ standards define the order in which expressions in a C/C++
7289program are evaluated in terms of @dfn{sequence points}, which represent
7290a partial ordering between the execution of parts of the program: those
7291executed before the sequence point, and those executed after it. These
7292occur after the evaluation of a full expression (one which is not part
7293of a larger expression), after the evaluation of the first operand of a
7294@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7295function is called (but after the evaluation of its arguments and the
7296expression denoting the called function), and in certain other places.
7297Other than as expressed by the sequence point rules, the order of
7298evaluation of subexpressions of an expression is not specified. All
7299these rules describe only a partial order rather than a total order,
7300since, for example, if two functions are called within one expression
7301with no sequence point between them, the order in which the functions
7302are called is not specified. However, the standards committee have
7303ruled that function calls do not overlap.
7304
7305It is not specified when between sequence points modifications to the
7306values of objects take effect. Programs whose behavior depends on this
7307have undefined behavior; the C and C++ standards specify that ``Between
7308the previous and next sequence point an object shall have its stored
7309value modified at most once by the evaluation of an expression.
7310Furthermore, the prior value shall be read only to determine the value
7311to be stored.''. If a program breaks these rules, the results on any
7312particular implementation are entirely unpredictable.
7313
7314Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7315= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7316diagnosed by this option, and it may give an occasional false positive
7317result, but in general it has been found fairly effective at detecting
7318this sort of problem in programs.
7319
7320The C++17 standard will define the order of evaluation of operands in
7321more cases: in particular it requires that the right-hand side of an
7322assignment be evaluated before the left-hand side, so the above
7323examples are no longer undefined. But this option will still warn
7324about them, to help people avoid writing code that is undefined in C
7325and earlier revisions of C++.
7326
7327The standard is worded confusingly, therefore there is some debate
7328over the precise meaning of the sequence point rules in subtle cases.
7329Links to discussions of the problem, including proposed formal
7330definitions, may be found on the GCC readings page, at
7331@uref{https://gcc.gnu.org/@/readings.html}.
7332
7333This warning is enabled by @option{-Wall} for C and C++.
7334
d77de738
ML
7335@opindex Wno-return-local-addr
7336@opindex Wreturn-local-addr
ddf6fe37 7337@item -Wno-return-local-addr
d77de738
ML
7338Do not warn about returning a pointer (or in C++, a reference) to a
7339variable that goes out of scope after the function returns.
7340
d77de738
ML
7341@opindex Wreturn-type
7342@opindex Wno-return-type
ddf6fe37 7343@item -Wreturn-type
d77de738
ML
7344Warn whenever a function is defined with a return type that defaults
7345to @code{int}. Also warn about any @code{return} statement with no
7346return value in a function whose return type is not @code{void}
7347(falling off the end of the function body is considered returning
7348without a value).
7349
7350For C only, warn about a @code{return} statement with an expression in a
7351function whose return type is @code{void}, unless the expression type is
7352also @code{void}. As a GNU extension, the latter case is accepted
7353without a warning unless @option{-Wpedantic} is used. Attempting
7354to use the return value of a non-@code{void} function other than @code{main}
7355that flows off the end by reaching the closing curly brace that terminates
7356the function is undefined.
7357
7358Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7359than @code{main} results in undefined behavior even when the value of
7360the function is not used.
7361
7362This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7363
d77de738
ML
7364@opindex Wshift-count-negative
7365@opindex Wno-shift-count-negative
ddf6fe37 7366@item -Wno-shift-count-negative
d77de738
ML
7367Controls warnings if a shift count is negative.
7368This warning is enabled by default.
7369
d77de738
ML
7370@opindex Wshift-count-overflow
7371@opindex Wno-shift-count-overflow
ddf6fe37 7372@item -Wno-shift-count-overflow
d77de738
ML
7373Controls warnings if a shift count is greater than or equal to the bit width
7374of the type. This warning is enabled by default.
7375
d77de738
ML
7376@opindex Wshift-negative-value
7377@opindex Wno-shift-negative-value
ddf6fe37 7378@item -Wshift-negative-value
d77de738
ML
7379Warn if left shifting a negative value. This warning is enabled by
7380@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7381
d77de738
ML
7382@opindex Wshift-overflow
7383@opindex Wno-shift-overflow
ddf6fe37
AA
7384@item -Wno-shift-overflow
7385@itemx -Wshift-overflow=@var{n}
d77de738
ML
7386These options control warnings about left shift overflows.
7387
7388@table @gcctabopt
7389@item -Wshift-overflow=1
7390This is the warning level of @option{-Wshift-overflow} and is enabled
7391by default in C99 and C++11 modes (and newer). This warning level does
7392not warn about left-shifting 1 into the sign bit. (However, in C, such
7393an overflow is still rejected in contexts where an integer constant expression
7394is required.) No warning is emitted in C++20 mode (and newer), as signed left
7395shifts always wrap.
7396
7397@item -Wshift-overflow=2
7398This warning level also warns about left-shifting 1 into the sign bit,
7399unless C++14 mode (or newer) is active.
7400@end table
7401
d77de738
ML
7402@opindex Wswitch
7403@opindex Wno-switch
ddf6fe37 7404@item -Wswitch
d77de738
ML
7405Warn whenever a @code{switch} statement has an index of enumerated type
7406and lacks a @code{case} for one or more of the named codes of that
7407enumeration. (The presence of a @code{default} label prevents this
7408warning.) @code{case} labels outside the enumeration range also
7409provoke warnings when this option is used (even if there is a
7410@code{default} label).
7411This warning is enabled by @option{-Wall}.
7412
d77de738
ML
7413@opindex Wswitch-default
7414@opindex Wno-switch-default
ddf6fe37 7415@item -Wswitch-default
d77de738
ML
7416Warn whenever a @code{switch} statement does not have a @code{default}
7417case.
7418
d77de738
ML
7419@opindex Wswitch-enum
7420@opindex Wno-switch-enum
ddf6fe37 7421@item -Wswitch-enum
d77de738
ML
7422Warn whenever a @code{switch} statement has an index of enumerated type
7423and lacks a @code{case} for one or more of the named codes of that
7424enumeration. @code{case} labels outside the enumeration range also
7425provoke warnings when this option is used. The only difference
7426between @option{-Wswitch} and this option is that this option gives a
7427warning about an omitted enumeration code even if there is a
7428@code{default} label.
7429
d77de738
ML
7430@opindex Wswitch-bool
7431@opindex Wno-switch-bool
ddf6fe37 7432@item -Wno-switch-bool
d77de738
ML
7433Do not warn when a @code{switch} statement has an index of boolean type
7434and the case values are outside the range of a boolean type.
7435It is possible to suppress this warning by casting the controlling
7436expression to a type other than @code{bool}. For example:
7437@smallexample
7438@group
7439switch ((int) (a == 4))
7440 @{
7441 @dots{}
7442 @}
7443@end group
7444@end smallexample
7445This warning is enabled by default for C and C++ programs.
7446
d77de738
ML
7447@opindex Wswitch-outside-range
7448@opindex Wno-switch-outside-range
ddf6fe37 7449@item -Wno-switch-outside-range
d77de738
ML
7450This option controls warnings when a @code{switch} case has a value
7451that is outside of its
7452respective type range. This warning is enabled by default for
7453C and C++ programs.
7454
d77de738
ML
7455@opindex Wswitch-unreachable
7456@opindex Wno-switch-unreachable
ddf6fe37 7457@item -Wno-switch-unreachable
d77de738
ML
7458Do not warn when a @code{switch} statement contains statements between the
7459controlling expression and the first case label, which will never be
7460executed. For example:
7461@smallexample
7462@group
7463switch (cond)
7464 @{
7465 i = 15;
7466 @dots{}
7467 case 5:
7468 @dots{}
7469 @}
7470@end group
7471@end smallexample
7472@option{-Wswitch-unreachable} does not warn if the statement between the
7473controlling expression and the first case label is just a declaration:
7474@smallexample
7475@group
7476switch (cond)
7477 @{
7478 int i;
7479 @dots{}
7480 case 5:
7481 i = 5;
7482 @dots{}
7483 @}
7484@end group
7485@end smallexample
7486This warning is enabled by default for C and C++ programs.
7487
d77de738
ML
7488@opindex Wsync-nand
7489@opindex Wno-sync-nand
ddf6fe37 7490@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7491Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7492built-in functions are used. These functions changed semantics in GCC 4.4.
7493
d77de738
ML
7494@opindex Wtrivial-auto-var-init
7495@opindex Wno-trivial-auto-var-init
ddf6fe37 7496@item -Wtrivial-auto-var-init
d77de738
ML
7497Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7498variable. A common situation is an automatic variable that is declared
7499between the controlling expression and the first case label of a @code{switch}
7500statement.
7501
d77de738
ML
7502@opindex Wunused-but-set-parameter
7503@opindex Wno-unused-but-set-parameter
ddf6fe37 7504@item -Wunused-but-set-parameter
d77de738
ML
7505Warn whenever a function parameter is assigned to, but otherwise unused
7506(aside from its declaration).
7507
7508To suppress this warning use the @code{unused} attribute
7509(@pxref{Variable Attributes}).
7510
7511This warning is also enabled by @option{-Wunused} together with
7512@option{-Wextra}.
7513
d77de738
ML
7514@opindex Wunused-but-set-variable
7515@opindex Wno-unused-but-set-variable
ddf6fe37 7516@item -Wunused-but-set-variable
d77de738
ML
7517Warn whenever a local variable is assigned to, but otherwise unused
7518(aside from its declaration).
7519This warning is enabled by @option{-Wall}.
7520
7521To suppress this warning use the @code{unused} attribute
7522(@pxref{Variable Attributes}).
7523
7524This warning is also enabled by @option{-Wunused}, which is enabled
7525by @option{-Wall}.
7526
d77de738
ML
7527@opindex Wunused-function
7528@opindex Wno-unused-function
ddf6fe37 7529@item -Wunused-function
d77de738
ML
7530Warn whenever a static function is declared but not defined or a
7531non-inline static function is unused.
7532This warning is enabled by @option{-Wall}.
7533
d77de738
ML
7534@opindex Wunused-label
7535@opindex Wno-unused-label
ddf6fe37 7536@item -Wunused-label
d77de738
ML
7537Warn whenever a label is declared but not used.
7538This warning is enabled by @option{-Wall}.
7539
7540To suppress this warning use the @code{unused} attribute
7541(@pxref{Variable Attributes}).
7542
d77de738
ML
7543@opindex Wunused-local-typedefs
7544@opindex Wno-unused-local-typedefs
ddf6fe37 7545@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7546Warn when a typedef locally defined in a function is not used.
7547This warning is enabled by @option{-Wall}.
7548
d77de738
ML
7549@opindex Wunused-parameter
7550@opindex Wno-unused-parameter
ddf6fe37 7551@item -Wunused-parameter
d77de738
ML
7552Warn whenever a function parameter is unused aside from its declaration.
7553
7554To suppress this warning use the @code{unused} attribute
7555(@pxref{Variable Attributes}).
7556
d77de738
ML
7557@opindex Wunused-result
7558@opindex Wno-unused-result
ddf6fe37 7559@item -Wno-unused-result
d77de738
ML
7560Do not warn if a caller of a function marked with attribute
7561@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7562its return value. The default is @option{-Wunused-result}.
7563
d77de738
ML
7564@opindex Wunused-variable
7565@opindex Wno-unused-variable
ddf6fe37 7566@item -Wunused-variable
d77de738
ML
7567Warn whenever a local or static variable is unused aside from its
7568declaration. This option implies @option{-Wunused-const-variable=1} for C,
7569but not for C++. This warning is enabled by @option{-Wall}.
7570
7571To suppress this warning use the @code{unused} attribute
7572(@pxref{Variable Attributes}).
7573
d77de738
ML
7574@opindex Wunused-const-variable
7575@opindex Wno-unused-const-variable
ddf6fe37
AA
7576@item -Wunused-const-variable
7577@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7578Warn whenever a constant static variable is unused aside from its declaration.
7579@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7580for C, but not for C++. In C this declares variable storage, but in C++ this
7581is not an error since const variables take the place of @code{#define}s.
7582
7583To suppress this warning use the @code{unused} attribute
7584(@pxref{Variable Attributes}).
7585
7586@table @gcctabopt
7587@item -Wunused-const-variable=1
7588This is the warning level that is enabled by @option{-Wunused-variable} for
7589C. It warns only about unused static const variables defined in the main
7590compilation unit, but not about static const variables declared in any
7591header included.
7592
7593@item -Wunused-const-variable=2
7594This warning level also warns for unused constant static variables in
7595headers (excluding system headers). This is the warning level of
7596@option{-Wunused-const-variable} and must be explicitly requested since
7597in C++ this isn't an error and in C it might be harder to clean up all
7598headers included.
7599@end table
7600
d77de738
ML
7601@opindex Wunused-value
7602@opindex Wno-unused-value
ddf6fe37 7603@item -Wunused-value
d77de738
ML
7604Warn whenever a statement computes a result that is explicitly not
7605used. To suppress this warning cast the unused expression to
7606@code{void}. This includes an expression-statement or the left-hand
7607side of a comma expression that contains no side effects. For example,
7608an expression such as @code{x[i,j]} causes a warning, while
7609@code{x[(void)i,j]} does not.
7610
7611This warning is enabled by @option{-Wall}.
7612
d77de738
ML
7613@opindex Wunused
7614@opindex Wno-unused
ddf6fe37 7615@item -Wunused
d77de738
ML
7616All the above @option{-Wunused} options combined.
7617
7618In order to get a warning about an unused function parameter, you must
7619either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7620@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7621
d77de738
ML
7622@opindex Wuninitialized
7623@opindex Wno-uninitialized
ddf6fe37 7624@item -Wuninitialized
d77de738
ML
7625Warn if an object with automatic or allocated storage duration is used
7626without having been initialized. In C++, also warn if a non-static
7627reference or non-static @code{const} member appears in a class without
7628constructors.
7629
7630In addition, passing a pointer (or in C++, a reference) to an uninitialized
7631object to a @code{const}-qualified argument of a built-in function known to
7632read the object is also diagnosed by this warning.
7633(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7634
7635If you want to warn about code that uses the uninitialized value of the
7636variable in its own initializer, use the @option{-Winit-self} option.
7637
7638These warnings occur for individual uninitialized elements of
7639structure, union or array variables as well as for variables that are
7640uninitialized as a whole. They do not occur for variables or elements
7641declared @code{volatile}. Because these warnings depend on
7642optimization, the exact variables or elements for which there are
7643warnings depend on the precise optimization options and version of GCC
7644used.
7645
7646Note that there may be no warning about a variable that is used only
7647to compute a value that itself is never used, because such
7648computations may be deleted by data flow analysis before the warnings
7649are printed.
7650
7651In C++, this warning also warns about using uninitialized objects in
7652member-initializer-lists. For example, GCC warns about @code{b} being
7653uninitialized in the following snippet:
7654
7655@smallexample
7656struct A @{
7657 int a;
7658 int b;
7659 A() : a(b) @{ @}
7660@};
7661@end smallexample
7662
d77de738
ML
7663@opindex Winvalid-memory-model
7664@opindex Wno-invalid-memory-model
ddf6fe37 7665@item -Wno-invalid-memory-model
d77de738
ML
7666This option controls warnings
7667for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7668and the C11 atomic generic functions with a memory consistency argument
7669that is either invalid for the operation or outside the range of values
7670of the @code{memory_order} enumeration. For example, since the
7671@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7672defined for the relaxed, release, and sequentially consistent memory
7673orders the following code is diagnosed:
7674
7675@smallexample
7676void store (int *i)
7677@{
7678 __atomic_store_n (i, 0, memory_order_consume);
7679@}
7680@end smallexample
7681
7682@option{-Winvalid-memory-model} is enabled by default.
7683
d77de738
ML
7684@opindex Wmaybe-uninitialized
7685@opindex Wno-maybe-uninitialized
ddf6fe37 7686@item -Wmaybe-uninitialized
d77de738
ML
7687For an object with automatic or allocated storage duration, if there exists
7688a path from the function entry to a use of the object that is initialized,
7689but there exist some other paths for which the object is not initialized,
7690the compiler emits a warning if it cannot prove the uninitialized paths
7691are not executed at run time.
7692
7693In addition, passing a pointer (or in C++, a reference) to an uninitialized
7694object to a @code{const}-qualified function argument is also diagnosed by
7695this warning. (@option{-Wuninitialized} is issued for built-in functions
7696known to read the object.) Annotating the function with attribute
7697@code{access (none)} indicates that the argument isn't used to access
7698the object and avoids the warning (@pxref{Common Function Attributes}).
7699
7700These warnings are only possible in optimizing compilation, because otherwise
7701GCC does not keep track of the state of variables.
7702
7703These warnings are made optional because GCC may not be able to determine when
7704the code is correct in spite of appearing to have an error. Here is one
7705example of how this can happen:
7706
7707@smallexample
7708@group
7709@{
7710 int x;
7711 switch (y)
7712 @{
7713 case 1: x = 1;
7714 break;
7715 case 2: x = 4;
7716 break;
7717 case 3: x = 5;
7718 @}
7719 foo (x);
7720@}
7721@end group
7722@end smallexample
7723
7724@noindent
7725If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7726always initialized, but GCC doesn't know this. To suppress the
7727warning, you need to provide a default case with assert(0) or
7728similar code.
7729
7730@cindex @code{longjmp} warnings
7731This option also warns when a non-volatile automatic variable might be
7732changed by a call to @code{longjmp}.
7733The compiler sees only the calls to @code{setjmp}. It cannot know
7734where @code{longjmp} will be called; in fact, a signal handler could
7735call it at any point in the code. As a result, you may get a warning
7736even when there is in fact no problem because @code{longjmp} cannot
7737in fact be called at the place that would cause a problem.
7738
7739Some spurious warnings can be avoided if you declare all the functions
7740you use that never return as @code{noreturn}. @xref{Function
7741Attributes}.
7742
7743This warning is enabled by @option{-Wall} or @option{-Wextra}.
7744
d77de738
ML
7745@opindex Wunknown-pragmas
7746@opindex Wno-unknown-pragmas
7747@cindex warning for unknown pragmas
7748@cindex unknown pragmas, warning
7749@cindex pragmas, warning of unknown
f33d7a88 7750@item -Wunknown-pragmas
d77de738
ML
7751Warn when a @code{#pragma} directive is encountered that is not understood by
7752GCC@. If this command-line option is used, warnings are even issued
7753for unknown pragmas in system header files. This is not the case if
7754the warnings are only enabled by the @option{-Wall} command-line option.
7755
d77de738
ML
7756@opindex Wno-pragmas
7757@opindex Wpragmas
ddf6fe37 7758@item -Wno-pragmas
d77de738
ML
7759Do not warn about misuses of pragmas, such as incorrect parameters,
7760invalid syntax, or conflicts between pragmas. See also
7761@option{-Wunknown-pragmas}.
7762
d77de738
ML
7763@opindex Wno-prio-ctor-dtor
7764@opindex Wprio-ctor-dtor
ddf6fe37 7765@item -Wno-prio-ctor-dtor
d77de738
ML
7766Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7767The use of constructor and destructor attributes allow you to assign a
7768priority to the constructor/destructor to control its order of execution
7769before @code{main} is called or after it returns. The priority values must be
7770greater than 100 as the compiler reserves priority values between 0--100 for
7771the implementation.
7772
d77de738
ML
7773@opindex Wstrict-aliasing
7774@opindex Wno-strict-aliasing
ddf6fe37 7775@item -Wstrict-aliasing
d77de738
ML
7776This option is only active when @option{-fstrict-aliasing} is active.
7777It warns about code that might break the strict aliasing rules that the
7778compiler is using for optimization. The warning does not catch all
7779cases, but does attempt to catch the more common pitfalls. It is
7780included in @option{-Wall}.
7781It is equivalent to @option{-Wstrict-aliasing=3}
7782
d77de738 7783@opindex Wstrict-aliasing=n
ddf6fe37 7784@item -Wstrict-aliasing=n
d77de738
ML
7785This option is only active when @option{-fstrict-aliasing} is active.
7786It warns about code that might break the strict aliasing rules that the
7787compiler is using for optimization.
7788Higher levels correspond to higher accuracy (fewer false positives).
7789Higher levels also correspond to more effort, similar to the way @option{-O}
7790works.
7791@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7792
7793Level 1: Most aggressive, quick, least accurate.
7794Possibly useful when higher levels
7795do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7796false negatives. However, it has many false positives.
7797Warns for all pointer conversions between possibly incompatible types,
7798even if never dereferenced. Runs in the front end only.
7799
7800Level 2: Aggressive, quick, not too precise.
7801May still have many false positives (not as many as level 1 though),
7802and few false negatives (but possibly more than level 1).
7803Unlike level 1, it only warns when an address is taken. Warns about
7804incomplete types. Runs in the front end only.
7805
7806Level 3 (default for @option{-Wstrict-aliasing}):
7807Should have very few false positives and few false
7808negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7809Takes care of the common pun+dereference pattern in the front end:
7810@code{*(int*)&some_float}.
7811If optimization is enabled, it also runs in the back end, where it deals
7812with multiple statement cases using flow-sensitive points-to information.
7813Only warns when the converted pointer is dereferenced.
7814Does not warn about incomplete types.
7815
d77de738
ML
7816@opindex Wstrict-overflow
7817@opindex Wno-strict-overflow
ddf6fe37
AA
7818@item -Wstrict-overflow
7819@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7820This option is only active when signed overflow is undefined.
7821It warns about cases where the compiler optimizes based on the
7822assumption that signed overflow does not occur. Note that it does not
7823warn about all cases where the code might overflow: it only warns
7824about cases where the compiler implements some optimization. Thus
7825this warning depends on the optimization level.
7826
7827An optimization that assumes that signed overflow does not occur is
7828perfectly safe if the values of the variables involved are such that
7829overflow never does, in fact, occur. Therefore this warning can
7830easily give a false positive: a warning about code that is not
7831actually a problem. To help focus on important issues, several
7832warning levels are defined. No warnings are issued for the use of
7833undefined signed overflow when estimating how many iterations a loop
7834requires, in particular when determining whether a loop will be
7835executed at all.
7836
7837@table @gcctabopt
7838@item -Wstrict-overflow=1
7839Warn about cases that are both questionable and easy to avoid. For
7840example the compiler simplifies
7841@code{x + 1 > x} to @code{1}. This level of
7842@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7843are not, and must be explicitly requested.
7844
7845@item -Wstrict-overflow=2
7846Also warn about other cases where a comparison is simplified to a
7847constant. For example: @code{abs (x) >= 0}. This can only be
7848simplified when signed integer overflow is undefined, because
7849@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7850zero. @option{-Wstrict-overflow} (with no level) is the same as
7851@option{-Wstrict-overflow=2}.
7852
7853@item -Wstrict-overflow=3
7854Also warn about other cases where a comparison is simplified. For
7855example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7856
7857@item -Wstrict-overflow=4
7858Also warn about other simplifications not covered by the above cases.
7859For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7860
7861@item -Wstrict-overflow=5
7862Also warn about cases where the compiler reduces the magnitude of a
7863constant involved in a comparison. For example: @code{x + 2 > y} is
7864simplified to @code{x + 1 >= y}. This is reported only at the
7865highest warning level because this simplification applies to many
7866comparisons, so this warning level gives a very large number of
7867false positives.
7868@end table
7869
d77de738
ML
7870@opindex Wstring-compare
7871@opindex Wno-string-compare
ddf6fe37 7872@item -Wstring-compare
d77de738
ML
7873Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7874determined to be either zero or non-zero in tests for such equality
7875owing to the length of one argument being greater than the size of
7876the array the other argument is stored in (or the bound in the case
7877of @code{strncmp}). Such calls could be mistakes. For example,
7878the call to @code{strcmp} below is diagnosed because its result is
7879necessarily non-zero irrespective of the contents of the array @code{a}.
7880
7881@smallexample
7882extern char a[4];
7883void f (char *d)
7884@{
7885 strcpy (d, "string");
7886 @dots{}
7887 if (0 == strcmp (a, d)) // cannot be true
7888 puts ("a and d are the same");
7889@}
7890@end smallexample
7891
7892@option{-Wstring-compare} is enabled by @option{-Wextra}.
7893
ddf6fe37
AA
7894@opindex Wstringop-overflow
7895@opindex Wno-stringop-overflow
d77de738
ML
7896@item -Wno-stringop-overflow
7897@item -Wstringop-overflow
7898@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7899Warn for calls to string manipulation functions such as @code{memcpy} and
7900@code{strcpy} that are determined to overflow the destination buffer. The
7901optional argument is one greater than the type of Object Size Checking to
7902perform to determine the size of the destination. @xref{Object Size Checking}.
7903The argument is meaningful only for functions that operate on character arrays
7904but not for raw memory functions like @code{memcpy} which always make use
7905of Object Size type-0. The option also warns for calls that specify a size
7906in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7907The option produces the best results with optimization enabled but can detect
7908a small subset of simple buffer overflows even without optimization in
7909calls to the GCC built-in functions like @code{__builtin_memcpy} that
7910correspond to the standard functions. In any case, the option warns about
7911just a subset of buffer overflows detected by the corresponding overflow
7912checking built-ins. For example, the option issues a warning for
7913the @code{strcpy} call below because it copies at least 5 characters
7914(the string @code{"blue"} including the terminating NUL) into the buffer
7915of size 4.
7916
7917@smallexample
7918enum Color @{ blue, purple, yellow @};
7919const char* f (enum Color clr)
7920@{
7921 static char buf [4];
7922 const char *str;
7923 switch (clr)
7924 @{
7925 case blue: str = "blue"; break;
7926 case purple: str = "purple"; break;
7927 case yellow: str = "yellow"; break;
7928 @}
7929
7930 return strcpy (buf, str); // warning here
7931@}
7932@end smallexample
7933
7934Option @option{-Wstringop-overflow=2} is enabled by default.
7935
7936@table @gcctabopt
d77de738
ML
7937@opindex Wstringop-overflow
7938@opindex Wno-stringop-overflow
ddf6fe37
AA
7939@item -Wstringop-overflow
7940@itemx -Wstringop-overflow=1
d77de738
ML
7941The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7942to determine the sizes of destination objects. At this setting the option
7943does not warn for writes past the end of subobjects of larger objects accessed
7944by pointers unless the size of the largest surrounding object is known. When
7945the destination may be one of several objects it is assumed to be the largest
7946one of them. On Linux systems, when optimization is enabled at this setting
7947the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7948is defined to a non-zero value.
7949
7950@item -Wstringop-overflow=2
7951The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7952to determine the sizes of destination objects. At this setting the option
7953warns about overflows when writing to members of the largest complete
7954objects whose exact size is known. However, it does not warn for excessive
7955writes to the same members of unknown objects referenced by pointers since
7956they may point to arrays containing unknown numbers of elements. This is
7957the default setting of the option.
7958
7959@item -Wstringop-overflow=3
7960The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7961to determine the sizes of destination objects. At this setting the option
7962warns about overflowing the smallest object or data member. This is the
7963most restrictive setting of the option that may result in warnings for safe
7964code.
7965
7966@item -Wstringop-overflow=4
7967The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7968to determine the sizes of destination objects. At this setting the option
7969warns about overflowing any data members, and when the destination is
7970one of several objects it uses the size of the largest of them to decide
7971whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7972setting of the option may result in warnings for benign code.
7973@end table
7974
d77de738
ML
7975@opindex Wstringop-overread
7976@opindex Wno-stringop-overread
ddf6fe37 7977@item -Wno-stringop-overread
d77de738
ML
7978Warn for calls to string manipulation functions such as @code{memchr}, or
7979@code{strcpy} that are determined to read past the end of the source
7980sequence.
7981
7982Option @option{-Wstringop-overread} is enabled by default.
7983
d77de738
ML
7984@opindex Wstringop-truncation
7985@opindex Wno-stringop-truncation
ddf6fe37 7986@item -Wno-stringop-truncation
d77de738
ML
7987Do not warn for calls to bounded string manipulation functions
7988such as @code{strncat},
7989@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7990or leave the destination unchanged.
7991
7992In the following example, the call to @code{strncat} specifies a bound that
7993is less than the length of the source string. As a result, the copy of
7994the source will be truncated and so the call is diagnosed. To avoid the
7995warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7996
7997@smallexample
7998void append (char *buf, size_t bufsize)
7999@{
8000 strncat (buf, ".txt", 3);
8001@}
8002@end smallexample
8003
8004As another example, the following call to @code{strncpy} results in copying
8005to @code{d} just the characters preceding the terminating NUL, without
8006appending the NUL to the end. Assuming the result of @code{strncpy} is
8007necessarily a NUL-terminated string is a common mistake, and so the call
8008is diagnosed. To avoid the warning when the result is not expected to be
8009NUL-terminated, call @code{memcpy} instead.
8010
8011@smallexample
8012void copy (char *d, const char *s)
8013@{
8014 strncpy (d, s, strlen (s));
8015@}
8016@end smallexample
8017
8018In the following example, the call to @code{strncpy} specifies the size
8019of the destination buffer as the bound. If the length of the source
8020string is equal to or greater than this size the result of the copy will
8021not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8022the warning, specify @code{sizeof buf - 1} as the bound and set the last
8023element of the buffer to @code{NUL}.
8024
8025@smallexample
8026void copy (const char *s)
8027@{
8028 char buf[80];
8029 strncpy (buf, s, sizeof buf);
8030 @dots{}
8031@}
8032@end smallexample
8033
8034In situations where a character array is intended to store a sequence
8035of bytes with no terminating @code{NUL} such an array may be annotated
8036with attribute @code{nonstring} to avoid this warning. Such arrays,
8037however, are not suitable arguments to functions that expect
8038@code{NUL}-terminated strings. To help detect accidental misuses of
8039such arrays GCC issues warnings unless it can prove that the use is
8040safe. @xref{Common Variable Attributes}.
8041
2a27ae32
QZ
8042@opindex Wstrict-flex-arrays
8043@opindex Wno-strict-flex-arrays
ddf6fe37 8044@item -Wstrict-flex-arrays
2a27ae32
QZ
8045Warn about inproper usages of flexible array members
8046according to the @var{level} of the @code{strict_flex_array (@var{level})}
8047attribute attached to the trailing array field of a structure if it's
8048available, otherwise according to the @var{level} of the option
8049@option{-fstrict-flex-arrays=@var{level}}.
8050
8051This option is effective only when @var{level} is bigger than 0. Otherwise,
8052it will be ignored with a warning.
8053
8054when @var{level}=1, warnings will be issued for a trailing array reference
8055of a structure that have 2 or more elements if the trailing array is referenced
8056as a flexible array member.
8057
8058when @var{level}=2, in addition to @var{level}=1, additional warnings will be
8059issued for a trailing one-element array reference of a structure
8060if the array is referenced as a flexible array member.
8061
8062when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8063issued for a trailing zero-length array reference of a structure
8064if the array is referenced as a flexible array member.
8065
8066
d77de738
ML
8067@opindex Wsuggest-attribute=
8068@opindex Wno-suggest-attribute=
ddf6fe37 8069@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
d77de738
ML
8070Warn for cases where adding an attribute may be beneficial. The
8071attributes currently supported are listed below.
8072
8073@table @gcctabopt
d77de738
ML
8074@opindex Wsuggest-attribute=pure
8075@opindex Wno-suggest-attribute=pure
8076@opindex Wsuggest-attribute=const
8077@opindex Wno-suggest-attribute=const
8078@opindex Wsuggest-attribute=noreturn
8079@opindex Wno-suggest-attribute=noreturn
8080@opindex Wmissing-noreturn
8081@opindex Wno-missing-noreturn
8082@opindex Wsuggest-attribute=malloc
8083@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
8084@item -Wsuggest-attribute=pure
8085@itemx -Wsuggest-attribute=const
8086@itemx -Wsuggest-attribute=noreturn
8087@itemx -Wmissing-noreturn
8088@itemx -Wsuggest-attribute=malloc
d77de738
ML
8089
8090Warn about functions that might be candidates for attributes
8091@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
8092only warns for functions visible in other compilation units or (in the case of
8093@code{pure} and @code{const}) if it cannot prove that the function returns
8094normally. A function returns normally if it doesn't contain an infinite loop or
8095return abnormally by throwing, calling @code{abort} or trapping. This analysis
8096requires option @option{-fipa-pure-const}, which is enabled by default at
8097@option{-O} and higher. Higher optimization levels improve the accuracy
8098of the analysis.
8099
d77de738
ML
8100@opindex Wsuggest-attribute=format
8101@opindex Wmissing-format-attribute
8102@opindex Wno-suggest-attribute=format
8103@opindex Wno-missing-format-attribute
8104@opindex Wformat
8105@opindex Wno-format
ddf6fe37
AA
8106@item -Wsuggest-attribute=format
8107@itemx -Wmissing-format-attribute
d77de738
ML
8108
8109Warn about function pointers that might be candidates for @code{format}
8110attributes. Note these are only possible candidates, not absolute ones.
8111GCC guesses that function pointers with @code{format} attributes that
8112are used in assignment, initialization, parameter passing or return
8113statements should have a corresponding @code{format} attribute in the
8114resulting type. I.e.@: the left-hand side of the assignment or
8115initialization, the type of the parameter variable, or the return type
8116of the containing function respectively should also have a @code{format}
8117attribute to avoid the warning.
8118
8119GCC also warns about function definitions that might be
8120candidates for @code{format} attributes. Again, these are only
8121possible candidates. GCC guesses that @code{format} attributes
8122might be appropriate for any function that calls a function like
8123@code{vprintf} or @code{vscanf}, but this might not always be the
8124case, and some functions for which @code{format} attributes are
8125appropriate may not be detected.
8126
d77de738
ML
8127@opindex Wsuggest-attribute=cold
8128@opindex Wno-suggest-attribute=cold
ddf6fe37 8129@item -Wsuggest-attribute=cold
d77de738
ML
8130
8131Warn about functions that might be candidates for @code{cold} attribute. This
8132is based on static detection and generally only warns about functions which
8133always leads to a call to another @code{cold} function such as wrappers of
8134C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8135@end table
8136
d77de738
ML
8137@opindex Wno-alloc-zero
8138@opindex Walloc-zero
ddf6fe37 8139@item -Walloc-zero
d77de738
ML
8140Warn about calls to allocation functions decorated with attribute
8141@code{alloc_size} that specify zero bytes, including those to the built-in
8142forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8143@code{malloc}, and @code{realloc}. Because the behavior of these functions
8144when called with a zero size differs among implementations (and in the case
8145of @code{realloc} has been deprecated) relying on it may result in subtle
8146portability bugs and should be avoided.
8147
d77de738
ML
8148@opindex Walloc-size-larger-than=
8149@opindex Wno-alloc-size-larger-than
ddf6fe37 8150@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8151Warn about calls to functions decorated with attribute @code{alloc_size}
8152that attempt to allocate objects larger than the specified number of bytes,
8153or where the result of the size computation in an integer type with infinite
8154precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8155@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8156Warnings controlled by the option can be disabled either by specifying
8157@var{byte-size} of @samp{SIZE_MAX} or more or by
8158@option{-Wno-alloc-size-larger-than}.
8159@xref{Function Attributes}.
8160
d77de738 8161@opindex Wno-alloc-size-larger-than
ddf6fe37 8162@item -Wno-alloc-size-larger-than
d77de738
ML
8163Disable @option{-Walloc-size-larger-than=} warnings. The option is
8164equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8165larger.
8166
d77de738
ML
8167@opindex Wno-alloca
8168@opindex Walloca
ddf6fe37 8169@item -Walloca
d77de738
ML
8170This option warns on all uses of @code{alloca} in the source.
8171
d77de738
ML
8172@opindex Walloca-larger-than=
8173@opindex Wno-alloca-larger-than
ddf6fe37 8174@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8175This option warns on calls to @code{alloca} with an integer argument whose
8176value is either zero, or that is not bounded by a controlling predicate
8177that limits its value to at most @var{byte-size}. It also warns for calls
8178to @code{alloca} where the bound value is unknown. Arguments of non-integer
8179types are considered unbounded even if they appear to be constrained to
8180the expected range.
8181
8182For example, a bounded case of @code{alloca} could be:
8183
8184@smallexample
8185void func (size_t n)
8186@{
8187 void *p;
8188 if (n <= 1000)
8189 p = alloca (n);
8190 else
8191 p = malloc (n);
8192 f (p);
8193@}
8194@end smallexample
8195
8196In the above example, passing @code{-Walloca-larger-than=1000} would not
8197issue a warning because the call to @code{alloca} is known to be at most
81981000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8199the compiler would emit a warning.
8200
8201Unbounded uses, on the other hand, are uses of @code{alloca} with no
8202controlling predicate constraining its integer argument. For example:
8203
8204@smallexample
8205void func ()
8206@{
8207 void *p = alloca (n);
8208 f (p);
8209@}
8210@end smallexample
8211
8212If @code{-Walloca-larger-than=500} were passed, the above would trigger
8213a warning, but this time because of the lack of bounds checking.
8214
8215Note, that even seemingly correct code involving signed integers could
8216cause a warning:
8217
8218@smallexample
8219void func (signed int n)
8220@{
8221 if (n < 500)
8222 @{
8223 p = alloca (n);
8224 f (p);
8225 @}
8226@}
8227@end smallexample
8228
8229In the above example, @var{n} could be negative, causing a larger than
8230expected argument to be implicitly cast into the @code{alloca} call.
8231
8232This option also warns when @code{alloca} is used in a loop.
8233
8234@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8235but is usually only effective when @option{-ftree-vrp} is active (default
8236for @option{-O2} and above).
8237
8238See also @option{-Wvla-larger-than=}@samp{byte-size}.
8239
d77de738 8240@opindex Wno-alloca-larger-than
ddf6fe37 8241@item -Wno-alloca-larger-than
d77de738
ML
8242Disable @option{-Walloca-larger-than=} warnings. The option is
8243equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8244
d77de738
ML
8245@opindex Warith-conversion
8246@opindex Wno-arith-conversion
ddf6fe37 8247@item -Warith-conversion
d77de738
ML
8248Do warn about implicit conversions from arithmetic operations even
8249when conversion of the operands to the same type cannot change their
8250values. This affects warnings from @option{-Wconversion},
8251@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8252
8253@smallexample
8254@group
8255void f (char c, int i)
8256@{
8257 c = c + i; // warns with @option{-Wconversion}
8258 c = c + 1; // only warns with @option{-Warith-conversion}
8259@}
8260@end group
8261@end smallexample
8262
d77de738
ML
8263@opindex Wno-array-bounds
8264@opindex Warray-bounds
ddf6fe37
AA
8265@item -Warray-bounds
8266@itemx -Warray-bounds=@var{n}
d77de738
ML
8267Warn about out of bounds subscripts or offsets into arrays. This warning
8268is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8269is active (the default for @option{-O2} and above) but a subset of instances
8270are issued even without optimization.
8271
710c9676
QZ
8272By default, the trailing array of a structure will be treated as a flexible
8273array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8274if it is declared as either a flexible array member per C99 standard onwards
8275(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8276array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8277zero-length arrays or one-element arrays are not warned by default.
8278
8279You can add the option @option{-fstrict-flex-arrays} or
8280@option{-fstrict-flex-arrays=@var{level}} to control how this
8281option treat trailing array of a structure as a flexible array member:
8282
8283when @var{level}<=1, no change to the default behavior.
8284
8285when @var{level}=2, additional warnings will be issued for out of bounds
8286subscripts or offsets into one-element arrays;
8287
8288when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8289issued for out of bounds subscripts or offsets into zero-length arrays.
8290
d77de738
ML
8291@table @gcctabopt
8292@item -Warray-bounds=1
8293This is the default warning level of @option{-Warray-bounds} and is enabled
8294by @option{-Wall}; higher levels are not, and must be explicitly requested.
8295
8296@item -Warray-bounds=2
710c9676
QZ
8297This warning level also warns about the intermediate results of pointer
8298arithmetic that may yield out of bounds values. This warning level may
8299give a larger number of false positives and is deactivated by default.
d77de738
ML
8300@end table
8301
d77de738
ML
8302@opindex Warray-compare
8303@opindex Wno-array-compare
ddf6fe37 8304@item -Warray-compare
d77de738
ML
8305Warn about equality and relational comparisons between two operands of array
8306type. This comparison was deprecated in C++20. For example:
8307
8308@smallexample
8309int arr1[5];
8310int arr2[5];
8311bool same = arr1 == arr2;
8312@end smallexample
8313
8314@option{-Warray-compare} is enabled by @option{-Wall}.
8315
ddf6fe37 8316@opindex Wno-array-parameter
d77de738
ML
8317@item -Warray-parameter
8318@itemx -Warray-parameter=@var{n}
d77de738
ML
8319Warn about redeclarations of functions involving arguments of array or
8320pointer types of inconsistent kinds or forms, and enable the detection
8321of out-of-bounds accesses to such parameters by warnings such as
8322@option{-Warray-bounds}.
8323
8324If the first function declaration uses the array form the bound specified
8325in the array is assumed to be the minimum number of elements expected to
8326be provided in calls to the function and the maximum number of elements
8327accessed by it. Failing to provide arguments of sufficient size or accessing
8328more than the maximum number of elements may be diagnosed by warnings such
8329as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8330involving array parameters declared using the @code{T[static N]} form.
8331
8332For example, the warning triggers for the following redeclarations because
8333the first one allows an array of any size to be passed to @code{f} while
8334the second one with the keyword @code{static} specifies that the array
8335argument must have at least four elements.
8336
8337@smallexample
8338void f (int[static 4]);
8339void f (int[]); // warning (inconsistent array form)
8340
8341void g (void)
8342@{
8343 int *p = (int *)malloc (4);
8344 f (p); // warning (array too small)
8345 @dots{}
8346@}
8347@end smallexample
8348
8349At level 2 the warning also triggers for redeclarations involving any other
8350inconsistency in array or pointer argument forms denoting array sizes.
8351Pointers and arrays of unspecified bound are considered equivalent and do
8352not trigger a warning.
8353
8354@smallexample
8355void g (int*);
8356void g (int[]); // no warning
8357void g (int[8]); // warning (inconsistent array bound)
8358@end smallexample
8359
8360@option{-Warray-parameter=2} is included in @option{-Wall}. The
8361@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8362involving Variable Length Array arguments.
8363
d77de738
ML
8364@opindex Wattribute-alias
8365@opindex Wno-attribute-alias
ddf6fe37
AA
8366@item -Wattribute-alias=@var{n}
8367@itemx -Wno-attribute-alias
d77de738
ML
8368Warn about declarations using the @code{alias} and similar attributes whose
8369target is incompatible with the type of the alias.
8370@xref{Function Attributes,,Declaring Attributes of Functions}.
8371
8372@table @gcctabopt
8373@item -Wattribute-alias=1
8374The default warning level of the @option{-Wattribute-alias} option diagnoses
8375incompatibilities between the type of the alias declaration and that of its
8376target. Such incompatibilities are typically indicative of bugs.
8377
8378@item -Wattribute-alias=2
8379
8380At this level @option{-Wattribute-alias} also diagnoses cases where
8381the attributes of the alias declaration are more restrictive than the
8382attributes applied to its target. These mismatches can potentially
8383result in incorrect code generation. In other cases they may be
8384benign and could be resolved simply by adding the missing attribute to
8385the target. For comparison, see the @option{-Wmissing-attributes}
8386option, which controls diagnostics when the alias declaration is less
8387restrictive than the target, rather than more restrictive.
8388
8389Attributes considered include @code{alloc_align}, @code{alloc_size},
8390@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8391@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8392@code{returns_nonnull}, and @code{returns_twice}.
8393@end table
8394
8395@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8396This is the default. You can disable these warnings with either
8397@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8398
d77de738
ML
8399@opindex Wbidi-chars=
8400@opindex Wbidi-chars
8401@opindex Wno-bidi-chars
ddf6fe37 8402@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8403Warn about possibly misleading UTF-8 bidirectional control characters in
8404comments, string literals, character constants, and identifiers. Such
8405characters can change left-to-right writing direction into right-to-left
8406(and vice versa), which can cause confusion between the logical order and
8407visual order. This may be dangerous; for instance, it may seem that a piece
8408of code is not commented out, whereas it in fact is.
8409
8410There are three levels of warning supported by GCC@. The default is
8411@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8412bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8413@option{-Wbidi-chars=any} warns about any use of bidirectional control
8414characters.
8415
8416By default, this warning does not warn about UCNs. It is, however, possible
8417to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8418@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8419and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8420@option{-Wbidi-chars=any} was specified.
8421
d77de738
ML
8422@opindex Wno-bool-compare
8423@opindex Wbool-compare
ddf6fe37 8424@item -Wbool-compare
d77de738
ML
8425Warn about boolean expression compared with an integer value different from
8426@code{true}/@code{false}. For instance, the following comparison is
8427always false:
8428@smallexample
8429int n = 5;
8430@dots{}
8431if ((n > 1) == 2) @{ @dots{} @}
8432@end smallexample
8433This warning is enabled by @option{-Wall}.
8434
d77de738
ML
8435@opindex Wno-bool-operation
8436@opindex Wbool-operation
ddf6fe37 8437@item -Wbool-operation
d77de738
ML
8438Warn about suspicious operations on expressions of a boolean type. For
8439instance, bitwise negation of a boolean is very likely a bug in the program.
8440For C, this warning also warns about incrementing or decrementing a boolean,
8441which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8442Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8443
8444This warning is enabled by @option{-Wall}.
8445
d77de738
ML
8446@opindex Wno-duplicated-branches
8447@opindex Wduplicated-branches
ddf6fe37 8448@item -Wduplicated-branches
d77de738
ML
8449Warn when an if-else has identical branches. This warning detects cases like
8450@smallexample
8451if (p != NULL)
8452 return 0;
8453else
8454 return 0;
8455@end smallexample
8456It doesn't warn when both branches contain just a null statement. This warning
8457also warn for conditional operators:
8458@smallexample
8459 int i = x ? *p : *p;
8460@end smallexample
8461
d77de738
ML
8462@opindex Wno-duplicated-cond
8463@opindex Wduplicated-cond
ddf6fe37 8464@item -Wduplicated-cond
d77de738
ML
8465Warn about duplicated conditions in an if-else-if chain. For instance,
8466warn for the following code:
8467@smallexample
8468if (p->q != NULL) @{ @dots{} @}
8469else if (p->q != NULL) @{ @dots{} @}
8470@end smallexample
8471
d77de738
ML
8472@opindex Wno-frame-address
8473@opindex Wframe-address
ddf6fe37 8474@item -Wframe-address
d77de738
ML
8475Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8476is called with an argument greater than 0. Such calls may return indeterminate
8477values or crash the program. The warning is included in @option{-Wall}.
8478
d77de738
ML
8479@opindex Wno-discarded-qualifiers
8480@opindex Wdiscarded-qualifiers
ddf6fe37 8481@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8482Do not warn if type qualifiers on pointers are being discarded.
8483Typically, the compiler warns if a @code{const char *} variable is
8484passed to a function that takes a @code{char *} parameter. This option
8485can be used to suppress such a warning.
8486
d77de738
ML
8487@opindex Wno-discarded-array-qualifiers
8488@opindex Wdiscarded-array-qualifiers
ddf6fe37 8489@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8490Do not warn if type qualifiers on arrays which are pointer targets
8491are being discarded. Typically, the compiler warns if a
8492@code{const int (*)[]} variable is passed to a function that
8493takes a @code{int (*)[]} parameter. This option can be used to
8494suppress such a warning.
8495
d77de738
ML
8496@opindex Wno-incompatible-pointer-types
8497@opindex Wincompatible-pointer-types
ddf6fe37 8498@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8499Do not warn when there is a conversion between pointers that have incompatible
8500types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8501which warns for pointer argument passing or assignment with different
8502signedness.
8503
5fccebdb
JM
8504This warning is upgraded to an error by @option{-pedantic-errors}.
8505
d77de738
ML
8506@opindex Wno-int-conversion
8507@opindex Wint-conversion
ddf6fe37 8508@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8509Do not warn about incompatible integer to pointer and pointer to integer
8510conversions. This warning is about implicit conversions; for explicit
8511conversions the warnings @option{-Wno-int-to-pointer-cast} and
8512@option{-Wno-pointer-to-int-cast} may be used.
8513
5fccebdb
JM
8514This warning is upgraded to an error by @option{-pedantic-errors}.
8515
d77de738
ML
8516@opindex Wzero-length-bounds
8517@opindex Wzero-length-bounds
ddf6fe37 8518@item -Wzero-length-bounds
d77de738
ML
8519Warn about accesses to elements of zero-length array members that might
8520overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8521arrays is discouraged because accesses to them are undefined.
d77de738
ML
8522@xref{Zero Length}.
8523
8524For example, the first two stores in function @code{bad} are diagnosed
8525because the array elements overlap the subsequent members @code{b} and
8526@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8527because it is beyond the bounds of the enclosing object.
8528
8529@smallexample
8530struct X @{ int a[0]; int b, c; @};
8531struct X x;
8532
8533void bad (void)
8534@{
8535 x.a[0] = 0; // -Wzero-length-bounds
8536 x.a[1] = 1; // -Wzero-length-bounds
8537 x.a[2] = 2; // -Warray-bounds
8538@}
8539@end smallexample
8540
8541Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8542
d77de738
ML
8543@opindex Wno-div-by-zero
8544@opindex Wdiv-by-zero
ddf6fe37 8545@item -Wno-div-by-zero
d77de738
ML
8546Do not warn about compile-time integer division by zero. Floating-point
8547division by zero is not warned about, as it can be a legitimate way of
8548obtaining infinities and NaNs.
8549
d77de738
ML
8550@opindex Wsystem-headers
8551@opindex Wno-system-headers
8552@cindex warnings from system headers
8553@cindex system headers, warnings from
f33d7a88 8554@item -Wsystem-headers
d77de738
ML
8555Print warning messages for constructs found in system header files.
8556Warnings from system headers are normally suppressed, on the assumption
8557that they usually do not indicate real problems and would only make the
8558compiler output harder to read. Using this command-line option tells
8559GCC to emit warnings from system headers as if they occurred in user
8560code. However, note that using @option{-Wall} in conjunction with this
8561option does @emph{not} warn about unknown pragmas in system
8562headers---for that, @option{-Wunknown-pragmas} must also be used.
8563
d77de738
ML
8564@opindex Wtautological-compare
8565@opindex Wno-tautological-compare
ddf6fe37 8566@item -Wtautological-compare
d77de738
ML
8567Warn if a self-comparison always evaluates to true or false. This
8568warning detects various mistakes such as:
8569@smallexample
8570int i = 1;
8571@dots{}
8572if (i > i) @{ @dots{} @}
8573@end smallexample
8574
8575This warning also warns about bitwise comparisons that always evaluate
8576to true or false, for instance:
8577@smallexample
8578if ((a & 16) == 10) @{ @dots{} @}
8579@end smallexample
8580will always be false.
8581
8582This warning is enabled by @option{-Wall}.
8583
d77de738
ML
8584@opindex Wtrampolines
8585@opindex Wno-trampolines
ddf6fe37 8586@item -Wtrampolines
d77de738
ML
8587Warn about trampolines generated for pointers to nested functions.
8588A trampoline is a small piece of data or code that is created at run
8589time on the stack when the address of a nested function is taken, and is
8590used to call the nested function indirectly. For some targets, it is
8591made up of data only and thus requires no special treatment. But, for
8592most targets, it is made up of code and thus requires the stack to be
8593made executable in order for the program to work properly.
8594
d77de738
ML
8595@opindex Wfloat-equal
8596@opindex Wno-float-equal
ddf6fe37 8597@item -Wfloat-equal
d77de738
ML
8598Warn if floating-point values are used in equality comparisons.
8599
8600The idea behind this is that sometimes it is convenient (for the
8601programmer) to consider floating-point values as approximations to
8602infinitely precise real numbers. If you are doing this, then you need
8603to compute (by analyzing the code, or in some other way) the maximum or
8604likely maximum error that the computation introduces, and allow for it
8605when performing comparisons (and when producing output, but that's a
8606different problem). In particular, instead of testing for equality, you
8607should check to see whether the two values have ranges that overlap; and
8608this is done with the relational operators, so equality comparisons are
8609probably mistaken.
8610
d77de738
ML
8611@opindex Wtraditional
8612@opindex Wno-traditional
ddf6fe37 8613@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8614Warn about certain constructs that behave differently in traditional and
8615ISO C@. Also warn about ISO C constructs that have no traditional C
8616equivalent, and/or problematic constructs that should be avoided.
8617
8618@itemize @bullet
8619@item
8620Macro parameters that appear within string literals in the macro body.
8621In traditional C macro replacement takes place within string literals,
8622but in ISO C it does not.
8623
8624@item
8625In traditional C, some preprocessor directives did not exist.
8626Traditional preprocessors only considered a line to be a directive
8627if the @samp{#} appeared in column 1 on the line. Therefore
8628@option{-Wtraditional} warns about directives that traditional C
8629understands but ignores because the @samp{#} does not appear as the
8630first character on the line. It also suggests you hide directives like
8631@code{#pragma} not understood by traditional C by indenting them. Some
8632traditional implementations do not recognize @code{#elif}, so this option
8633suggests avoiding it altogether.
8634
8635@item
8636A function-like macro that appears without arguments.
8637
8638@item
8639The unary plus operator.
8640
8641@item
8642The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8643constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8644constants.) Note, these suffixes appear in macros defined in the system
8645headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8646Use of these macros in user code might normally lead to spurious
8647warnings, however GCC's integrated preprocessor has enough context to
8648avoid warning in these cases.
8649
8650@item
8651A function declared external in one block and then used after the end of
8652the block.
8653
8654@item
8655A @code{switch} statement has an operand of type @code{long}.
8656
8657@item
8658A non-@code{static} function declaration follows a @code{static} one.
8659This construct is not accepted by some traditional C compilers.
8660
8661@item
8662The ISO type of an integer constant has a different width or
8663signedness from its traditional type. This warning is only issued if
8664the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8665typically represent bit patterns, are not warned about.
8666
8667@item
8668Usage of ISO string concatenation is detected.
8669
8670@item
8671Initialization of automatic aggregates.
8672
8673@item
8674Identifier conflicts with labels. Traditional C lacks a separate
8675namespace for labels.
8676
8677@item
8678Initialization of unions. If the initializer is zero, the warning is
8679omitted. This is done under the assumption that the zero initializer in
8680user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8681initializer warnings and relies on default initialization to zero in the
8682traditional C case.
8683
8684@item
8685Conversions by prototypes between fixed/floating-point values and vice
8686versa. The absence of these prototypes when compiling with traditional
8687C causes serious problems. This is a subset of the possible
8688conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8689
8690@item
8691Use of ISO C style function definitions. This warning intentionally is
8692@emph{not} issued for prototype declarations or variadic functions
8693because these ISO C features appear in your code when using
8694libiberty's traditional C compatibility macros, @code{PARAMS} and
8695@code{VPARAMS}. This warning is also bypassed for nested functions
8696because that feature is already a GCC extension and thus not relevant to
8697traditional C compatibility.
8698@end itemize
8699
d77de738
ML
8700@opindex Wtraditional-conversion
8701@opindex Wno-traditional-conversion
ddf6fe37 8702@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8703Warn if a prototype causes a type conversion that is different from what
8704would happen to the same argument in the absence of a prototype. This
8705includes conversions of fixed point to floating and vice versa, and
8706conversions changing the width or signedness of a fixed-point argument
8707except when the same as the default promotion.
8708
d77de738
ML
8709@opindex Wdeclaration-after-statement
8710@opindex Wno-declaration-after-statement
ddf6fe37 8711@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8712Warn when a declaration is found after a statement in a block. This
8713construct, known from C++, was introduced with ISO C99 and is by default
8714allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8715
5fccebdb
JM
8716This warning is upgraded to an error by @option{-pedantic-errors}.
8717
d77de738
ML
8718@opindex Wshadow
8719@opindex Wno-shadow
ddf6fe37 8720@item -Wshadow
d77de738
ML
8721Warn whenever a local variable or type declaration shadows another
8722variable, parameter, type, class member (in C++), or instance variable
8723(in Objective-C) or whenever a built-in function is shadowed. Note
8724that in C++, the compiler warns if a local variable shadows an
8725explicit typedef, but not if it shadows a struct/class/enum.
8726If this warning is enabled, it includes also all instances of
8727local shadowing. This means that @option{-Wno-shadow=local}
8728and @option{-Wno-shadow=compatible-local} are ignored when
8729@option{-Wshadow} is used.
8730Same as @option{-Wshadow=global}.
8731
d77de738
ML
8732@opindex Wno-shadow-ivar
8733@opindex Wshadow-ivar
ddf6fe37 8734@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8735Do not warn whenever a local variable shadows an instance variable in an
8736Objective-C method.
8737
d77de738 8738@opindex Wshadow=global
ddf6fe37 8739@item -Wshadow=global
d77de738
ML
8740Warn for any shadowing.
8741Same as @option{-Wshadow}.
8742
d77de738 8743@opindex Wshadow=local
ddf6fe37 8744@item -Wshadow=local
d77de738
ML
8745Warn when a local variable shadows another local variable or parameter.
8746
d77de738 8747@opindex Wshadow=compatible-local
ddf6fe37 8748@item -Wshadow=compatible-local
d77de738
ML
8749Warn when a local variable shadows another local variable or parameter
8750whose type is compatible with that of the shadowing variable. In C++,
8751type compatibility here means the type of the shadowing variable can be
8752converted to that of the shadowed variable. The creation of this flag
8753(in addition to @option{-Wshadow=local}) is based on the idea that when
8754a local variable shadows another one of incompatible type, it is most
8755likely intentional, not a bug or typo, as shown in the following example:
8756
8757@smallexample
8758@group
8759for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8760@{
8761 for (int i = 0; i < N; ++i)
8762 @{
8763 ...
8764 @}
8765 ...
8766@}
8767@end group
8768@end smallexample
8769
8770Since the two variable @code{i} in the example above have incompatible types,
8771enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8772Because their types are incompatible, if a programmer accidentally uses one
8773in place of the other, type checking is expected to catch that and emit an
8774error or warning. Use of this flag instead of @option{-Wshadow=local} can
8775possibly reduce the number of warnings triggered by intentional shadowing.
8776Note that this also means that shadowing @code{const char *i} by
8777@code{char *i} does not emit a warning.
8778
8779This warning is also enabled by @option{-Wshadow=local}.
8780
d77de738
ML
8781@opindex Wlarger-than=
8782@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8783@item -Wlarger-than=@var{byte-size}
d77de738
ML
8784Warn whenever an object is defined whose size exceeds @var{byte-size}.
8785@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8786Warnings controlled by the option can be disabled either by specifying
8787@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8788
8789Also warn for calls to bounded functions such as @code{memchr} or
8790@code{strnlen} that specify a bound greater than the largest possible
8791object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8792can only be disabled by @option{-Wno-larger-than}.
8793
d77de738 8794@opindex Wno-larger-than
ddf6fe37 8795@item -Wno-larger-than
d77de738
ML
8796Disable @option{-Wlarger-than=} warnings. The option is equivalent
8797to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8798
d77de738
ML
8799@opindex Wframe-larger-than=
8800@opindex Wno-frame-larger-than
ddf6fe37 8801@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8802Warn if the size of a function frame exceeds @var{byte-size}.
8803The computation done to determine the stack frame size is approximate
8804and not conservative.
8805The actual requirements may be somewhat greater than @var{byte-size}
8806even if you do not get a warning. In addition, any space allocated
8807via @code{alloca}, variable-length arrays, or related constructs
8808is not included by the compiler when determining
8809whether or not to issue a warning.
8810@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8811Warnings controlled by the option can be disabled either by specifying
8812@var{byte-size} of @samp{SIZE_MAX} or more or by
8813@option{-Wno-frame-larger-than}.
8814
d77de738 8815@opindex Wno-frame-larger-than
ddf6fe37 8816@item -Wno-frame-larger-than
d77de738
ML
8817Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8818to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8819
d77de738
ML
8820@opindex Wfree-nonheap-object
8821@opindex Wno-free-nonheap-object
ddf6fe37 8822@item -Wfree-nonheap-object
d77de738
ML
8823Warn when attempting to deallocate an object that was either not allocated
8824on the heap, or by using a pointer that was not returned from a prior call
8825to the corresponding allocation function. For example, because the call
8826to @code{stpcpy} returns a pointer to the terminating nul character and
8827not to the beginning of the object, the call to @code{free} below is
8828diagnosed.
8829
8830@smallexample
8831void f (char *p)
8832@{
8833 p = stpcpy (p, "abc");
8834 // ...
8835 free (p); // warning
8836@}
8837@end smallexample
8838
8839@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8840
d77de738
ML
8841@opindex Wstack-usage
8842@opindex Wno-stack-usage
ddf6fe37 8843@item -Wstack-usage=@var{byte-size}
d77de738
ML
8844Warn if the stack usage of a function might exceed @var{byte-size}.
8845The computation done to determine the stack usage is conservative.
8846Any space allocated via @code{alloca}, variable-length arrays, or related
8847constructs is included by the compiler when determining whether or not to
8848issue a warning.
8849
8850The message is in keeping with the output of @option{-fstack-usage}.
8851
8852@itemize
8853@item
8854If the stack usage is fully static but exceeds the specified amount, it's:
8855
8856@smallexample
8857 warning: stack usage is 1120 bytes
8858@end smallexample
8859@item
8860If the stack usage is (partly) dynamic but bounded, it's:
8861
8862@smallexample
8863 warning: stack usage might be 1648 bytes
8864@end smallexample
8865@item
8866If the stack usage is (partly) dynamic and not bounded, it's:
8867
8868@smallexample
8869 warning: stack usage might be unbounded
8870@end smallexample
8871@end itemize
8872
8873@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8874Warnings controlled by the option can be disabled either by specifying
8875@var{byte-size} of @samp{SIZE_MAX} or more or by
8876@option{-Wno-stack-usage}.
8877
d77de738 8878@opindex Wno-stack-usage
ddf6fe37 8879@item -Wno-stack-usage
d77de738
ML
8880Disable @option{-Wstack-usage=} warnings. The option is equivalent
8881to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8882
d77de738
ML
8883@opindex Wunsafe-loop-optimizations
8884@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8885@item -Wunsafe-loop-optimizations
d77de738
ML
8886Warn if the loop cannot be optimized because the compiler cannot
8887assume anything on the bounds of the loop indices. With
8888@option{-funsafe-loop-optimizations} warn if the compiler makes
8889such assumptions.
8890
d77de738
ML
8891@opindex Wno-pedantic-ms-format
8892@opindex Wpedantic-ms-format
ddf6fe37 8893@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8894When used in combination with @option{-Wformat}
8895and @option{-pedantic} without GNU extensions, this option
8896disables the warnings about non-ISO @code{printf} / @code{scanf} format
8897width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8898which depend on the MS runtime.
8899
d77de738
ML
8900@opindex Wpointer-arith
8901@opindex Wno-pointer-arith
ddf6fe37 8902@item -Wpointer-arith
d77de738
ML
8903Warn about anything that depends on the ``size of'' a function type or
8904of @code{void}. GNU C assigns these types a size of 1, for
8905convenience in calculations with @code{void *} pointers and pointers
8906to functions. In C++, warn also when an arithmetic operation involves
8907@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8908
5fccebdb
JM
8909This warning is upgraded to an error by @option{-pedantic-errors}.
8910
d77de738
ML
8911@opindex Wpointer-compare
8912@opindex Wno-pointer-compare
ddf6fe37 8913@item -Wno-pointer-compare
d77de738
ML
8914Do not warn if a pointer is compared with a zero character constant.
8915This usually
8916means that the pointer was meant to be dereferenced. For example:
8917
8918@smallexample
8919const char *p = foo ();
8920if (p == '\0')
8921 return 42;
8922@end smallexample
8923
8924Note that the code above is invalid in C++11.
8925
8926This warning is enabled by default.
8927
d77de738
ML
8928@opindex Wtsan
8929@opindex Wno-tsan
ddf6fe37 8930@item -Wtsan
d77de738
ML
8931Warn about unsupported features in ThreadSanitizer.
8932
8933ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8934can report false positives.
8935
8936This warning is enabled by default.
8937
d77de738
ML
8938@opindex Wtype-limits
8939@opindex Wno-type-limits
ddf6fe37 8940@item -Wtype-limits
d77de738
ML
8941Warn if a comparison is always true or always false due to the limited
8942range of the data type, but do not warn for constant expressions. For
8943example, warn if an unsigned variable is compared against zero with
8944@code{<} or @code{>=}. This warning is also enabled by
8945@option{-Wextra}.
8946
d77de738
ML
8947@opindex Wabsolute-value
8948@opindex Wno-absolute-value
ddf6fe37 8949@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8950Warn for calls to standard functions that compute the absolute value
8951of an argument when a more appropriate standard function is available.
8952For example, calling @code{abs(3.14)} triggers the warning because the
8953appropriate function to call to compute the absolute value of a double
8954argument is @code{fabs}. The option also triggers warnings when the
8955argument in a call to such a function has an unsigned type. This
8956warning can be suppressed with an explicit type cast and it is also
8957enabled by @option{-Wextra}.
8958
8959@include cppwarnopts.texi
8960
d77de738
ML
8961@opindex Wbad-function-cast
8962@opindex Wno-bad-function-cast
ddf6fe37 8963@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
8964Warn when a function call is cast to a non-matching type.
8965For example, warn if a call to a function returning an integer type
8966is cast to a pointer type.
8967
d77de738
ML
8968@opindex Wc90-c99-compat
8969@opindex Wno-c90-c99-compat
ddf6fe37 8970@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
8971Warn about features not present in ISO C90, but present in ISO C99.
8972For instance, warn about use of variable length arrays, @code{long long}
8973type, @code{bool} type, compound literals, designated initializers, and so
8974on. This option is independent of the standards mode. Warnings are disabled
8975in the expression that follows @code{__extension__}.
8976
d77de738
ML
8977@opindex Wc99-c11-compat
8978@opindex Wno-c99-c11-compat
ddf6fe37 8979@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
8980Warn about features not present in ISO C99, but present in ISO C11.
8981For instance, warn about use of anonymous structures and unions,
8982@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8983@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8984and so on. This option is independent of the standards mode. Warnings are
8985disabled in the expression that follows @code{__extension__}.
8986
d77de738
ML
8987@opindex Wc11-c2x-compat
8988@opindex Wno-c11-c2x-compat
ddf6fe37 8989@item -Wc11-c2x-compat @r{(C and Objective-C only)}
d77de738
ML
8990Warn about features not present in ISO C11, but present in ISO C2X.
8991For instance, warn about omitting the string in @code{_Static_assert},
8992use of @samp{[[]]} syntax for attributes, use of decimal
8993floating-point types, and so on. This option is independent of the
8994standards mode. Warnings are disabled in the expression that follows
8995@code{__extension__}.
8996
5fccebdb
JM
8997When not compiling in C2X mode, these warnings are upgraded to errors
8998by @option{-pedantic-errors}.
8999
d77de738
ML
9000@opindex Wc++-compat
9001@opindex Wno-c++-compat
ddf6fe37 9002@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
9003Warn about ISO C constructs that are outside of the common subset of
9004ISO C and ISO C++, e.g.@: request for implicit conversion from
9005@code{void *} to a pointer to non-@code{void} type.
9006
d77de738
ML
9007@opindex Wc++11-compat
9008@opindex Wno-c++11-compat
ddf6fe37 9009@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9010Warn about C++ constructs whose meaning differs between ISO C++ 1998
9011and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9012in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9013enabled by @option{-Wall}.
9014
d77de738
ML
9015@opindex Wc++14-compat
9016@opindex Wno-c++14-compat
ddf6fe37 9017@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9018Warn about C++ constructs whose meaning differs between ISO C++ 2011
9019and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9020
d77de738
ML
9021@opindex Wc++17-compat
9022@opindex Wno-c++17-compat
ddf6fe37 9023@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9024Warn about C++ constructs whose meaning differs between ISO C++ 2014
9025and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9026
d77de738
ML
9027@opindex Wc++20-compat
9028@opindex Wno-c++20-compat
ddf6fe37 9029@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9030Warn about C++ constructs whose meaning differs between ISO C++ 2017
9031and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9032
d77de738
ML
9033@opindex Wc++11-extensions
9034@opindex Wno-c++11-extensions
ddf6fe37 9035@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9036Do not warn about C++11 constructs in code being compiled using
9037an older C++ standard. Even without this option, some C++11 constructs
9038will only be diagnosed if @option{-Wpedantic} is used.
9039
d77de738
ML
9040@opindex Wc++14-extensions
9041@opindex Wno-c++14-extensions
ddf6fe37 9042@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9043Do not warn about C++14 constructs in code being compiled using
9044an older C++ standard. Even without this option, some C++14 constructs
9045will only be diagnosed if @option{-Wpedantic} is used.
9046
d77de738
ML
9047@opindex Wc++17-extensions
9048@opindex Wno-c++17-extensions
ddf6fe37 9049@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9050Do not warn about C++17 constructs in code being compiled using
9051an older C++ standard. Even without this option, some C++17 constructs
9052will only be diagnosed if @option{-Wpedantic} is used.
9053
d77de738
ML
9054@opindex Wc++20-extensions
9055@opindex Wno-c++20-extensions
ddf6fe37 9056@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9057Do not warn about C++20 constructs in code being compiled using
9058an older C++ standard. Even without this option, some C++20 constructs
9059will only be diagnosed if @option{-Wpedantic} is used.
9060
d77de738
ML
9061@opindex Wc++23-extensions
9062@opindex Wno-c++23-extensions
ddf6fe37 9063@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9064Do not warn about C++23 constructs in code being compiled using
9065an older C++ standard. Even without this option, some C++23 constructs
9066will only be diagnosed if @option{-Wpedantic} is used.
9067
d77de738
ML
9068@opindex Wcast-qual
9069@opindex Wno-cast-qual
ddf6fe37 9070@item -Wcast-qual
d77de738
ML
9071Warn whenever a pointer is cast so as to remove a type qualifier from
9072the target type. For example, warn if a @code{const char *} is cast
9073to an ordinary @code{char *}.
9074
9075Also warn when making a cast that introduces a type qualifier in an
9076unsafe way. For example, casting @code{char **} to @code{const char **}
9077is unsafe, as in this example:
9078
9079@smallexample
9080 /* p is char ** value. */
9081 const char **q = (const char **) p;
9082 /* Assignment of readonly string to const char * is OK. */
9083 *q = "string";
9084 /* Now char** pointer points to read-only memory. */
9085 **p = 'b';
9086@end smallexample
9087
d77de738
ML
9088@opindex Wcast-align
9089@opindex Wno-cast-align
ddf6fe37 9090@item -Wcast-align
d77de738
ML
9091Warn whenever a pointer is cast such that the required alignment of the
9092target is increased. For example, warn if a @code{char *} is cast to
9093an @code{int *} on machines where integers can only be accessed at
9094two- or four-byte boundaries.
9095
d77de738 9096@opindex Wcast-align=strict
ddf6fe37 9097@item -Wcast-align=strict
d77de738
ML
9098Warn whenever a pointer is cast such that the required alignment of the
9099target is increased. For example, warn if a @code{char *} is cast to
9100an @code{int *} regardless of the target machine.
9101
d77de738
ML
9102@opindex Wcast-function-type
9103@opindex Wno-cast-function-type
ddf6fe37 9104@item -Wcast-function-type
d77de738
ML
9105Warn when a function pointer is cast to an incompatible function pointer.
9106In a cast involving function types with a variable argument list only
9107the types of initial arguments that are provided are considered.
9108Any parameter of pointer-type matches any other pointer-type. Any benign
9109differences in integral types are ignored, like @code{int} vs.@: @code{long}
9110on ILP32 targets. Likewise type qualifiers are ignored. The function
9111type @code{void (*) (void)} is special and matches everything, which can
9112be used to suppress this warning.
9113In a cast involving pointer to member types this warning warns whenever
9114the type cast is changing the pointer to member type.
9115This warning is enabled by @option{-Wextra}.
9116
d77de738
ML
9117@opindex Wwrite-strings
9118@opindex Wno-write-strings
ddf6fe37 9119@item -Wwrite-strings
d77de738
ML
9120When compiling C, give string constants the type @code{const
9121char[@var{length}]} so that copying the address of one into a
9122non-@code{const} @code{char *} pointer produces a warning. These
9123warnings help you find at compile time code that can try to write
9124into a string constant, but only if you have been very careful about
9125using @code{const} in declarations and prototypes. Otherwise, it is
9126just a nuisance. This is why we did not make @option{-Wall} request
9127these warnings.
9128
9129When compiling C++, warn about the deprecated conversion from string
9130literals to @code{char *}. This warning is enabled by default for C++
9131programs.
9132
5fccebdb
JM
9133This warning is upgraded to an error by @option{-pedantic-errors} in
9134C++11 mode or later.
9135
d77de738
ML
9136@opindex Wclobbered
9137@opindex Wno-clobbered
f33d7a88 9138@item -Wclobbered
d77de738
ML
9139Warn for variables that might be changed by @code{longjmp} or
9140@code{vfork}. This warning is also enabled by @option{-Wextra}.
9141
320dc51c
TS
9142@opindex Wcomplain-wrong-lang
9143@opindex Wno-complain-wrong-lang
f33d7a88 9144@item -Wno-complain-wrong-lang
320dc51c
TS
9145By default, language front ends complain when a command-line option is
9146valid, but not applicable to that front end.
9147This may be disabled with @option{-Wno-complain-wrong-lang},
9148which is mostly useful when invoking a single compiler driver for
9149multiple source files written in different languages, for example:
9150
9151@smallexample
9152$ g++ -fno-rtti a.cc b.f90
9153@end smallexample
9154
9155The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9156and the Fortran front end to compile @file{b.f90}.
9157The latter front end diagnoses
9158@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9159which may be disabled with @option{-Wno-complain-wrong-lang}.
9160
e1f45bea
JM
9161@opindex Wcompare-distinct-pointer-types
9162@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9163Warn if pointers of distinct types are compared without a cast. This
9164warning is enabled by default.
9165
d77de738
ML
9166@opindex Wconversion
9167@opindex Wno-conversion
f33d7a88 9168@item -Wconversion
d77de738
ML
9169Warn for implicit conversions that may alter a value. This includes
9170conversions between real and integer, like @code{abs (x)} when
9171@code{x} is @code{double}; conversions between signed and unsigned,
9172like @code{unsigned ui = -1}; and conversions to smaller types, like
9173@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9174((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9175changed by the conversion like in @code{abs (2.0)}. Warnings about
9176conversions between signed and unsigned integers can be disabled by
9177using @option{-Wno-sign-conversion}.
9178
9179For C++, also warn for confusing overload resolution for user-defined
9180conversions; and conversions that never use a type conversion
9181operator: conversions to @code{void}, the same type, a base class or a
9182reference to them. Warnings about conversions between signed and
9183unsigned integers are disabled by default in C++ unless
9184@option{-Wsign-conversion} is explicitly enabled.
9185
9186Warnings about conversion from arithmetic on a small type back to that
9187type are only given with @option{-Warith-conversion}.
9188
d77de738
ML
9189@opindex Wdangling-else
9190@opindex Wno-dangling-else
ddf6fe37 9191@item -Wdangling-else
d77de738
ML
9192Warn about constructions where there may be confusion to which
9193@code{if} statement an @code{else} branch belongs. Here is an example of
9194such a case:
9195
9196@smallexample
9197@group
9198@{
9199 if (a)
9200 if (b)
9201 foo ();
9202 else
9203 bar ();
9204@}
9205@end group
9206@end smallexample
9207
9208In C/C++, every @code{else} branch belongs to the innermost possible
9209@code{if} statement, which in this example is @code{if (b)}. This is
9210often not what the programmer expected, as illustrated in the above
9211example by indentation the programmer chose. When there is the
9212potential for this confusion, GCC issues a warning when this flag
9213is specified. To eliminate the warning, add explicit braces around
9214the innermost @code{if} statement so there is no way the @code{else}
9215can belong to the enclosing @code{if}. The resulting code
9216looks like this:
9217
9218@smallexample
9219@group
9220@{
9221 if (a)
9222 @{
9223 if (b)
9224 foo ();
9225 else
9226 bar ();
9227 @}
9228@}
9229@end group
9230@end smallexample
9231
9232This warning is enabled by @option{-Wparentheses}.
9233
d77de738
ML
9234@opindex Wdangling-pointer
9235@opindex Wno-dangling-pointer
ddf6fe37
AA
9236@item -Wdangling-pointer
9237@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9238Warn about uses of pointers (or C++ references) to objects with automatic
9239storage duration after their lifetime has ended. This includes local
9240variables declared in nested blocks, compound literals and other unnamed
9241temporary objects. In addition, warn about storing the address of such
9242objects in escaped pointers. The warning is enabled at all optimization
9243levels but may yield different results with optimization than without.
9244
9245@table @gcctabopt
9246@item -Wdangling-pointer=1
9247At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9248For example
9249@smallexample
9250int f (int c1, int c2, x)
9251@{
9252 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9253 // warning: dangling pointer to a compound literal
9254 return p ? *p : 'x';
d77de738
ML
9255@}
9256@end smallexample
9257In the following function the store of the address of the local variable
9258@code{x} in the escaped pointer @code{*p} also triggers the warning.
9259@smallexample
9260void g (int **p)
9261@{
9262 int x = 7;
4ace81b6
SL
9263 // warning: storing the address of a local variable in *p
9264 *p = &x;
d77de738
ML
9265@}
9266@end smallexample
9267
9268@item -Wdangling-pointer=2
9269At level 2, in addition to unconditional uses the warning also diagnoses
9270conditional uses of dangling pointers.
9271
9272For example, because the array @var{a} in the following function is out of
9273scope when the pointer @var{s} that was set to point is used, the warning
9274triggers at this level.
9275
9276@smallexample
9277void f (char *s)
9278@{
9279 if (!s)
9280 @{
9281 char a[12] = "tmpname";
9282 s = a;
9283 @}
4ace81b6
SL
9284 // warning: dangling pointer to a may be used
9285 strcat (s, ".tmp");
d77de738
ML
9286 ...
9287@}
9288@end smallexample
9289@end table
9290
9291@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9292
d77de738
ML
9293@opindex Wdate-time
9294@opindex Wno-date-time
ddf6fe37 9295@item -Wdate-time
d77de738
ML
9296Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9297are encountered as they might prevent bit-wise-identical reproducible
9298compilations.
9299
d77de738
ML
9300@opindex Wempty-body
9301@opindex Wno-empty-body
ddf6fe37 9302@item -Wempty-body
d77de738
ML
9303Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9304while} statement. This warning is also enabled by @option{-Wextra}.
9305
d77de738
ML
9306@opindex Wendif-labels
9307@opindex Wno-endif-labels
ddf6fe37 9308@item -Wno-endif-labels
d77de738
ML
9309Do not warn about stray tokens after @code{#else} and @code{#endif}.
9310
d77de738
ML
9311@opindex Wenum-compare
9312@opindex Wno-enum-compare
ddf6fe37 9313@item -Wenum-compare
d77de738
ML
9314Warn about a comparison between values of different enumerated types.
9315In C++ enumerated type mismatches in conditional expressions are also
9316diagnosed and the warning is enabled by default. In C this warning is
9317enabled by @option{-Wall}.
9318
d77de738
ML
9319@opindex Wenum-conversion
9320@opindex Wno-enum-conversion
ddf6fe37 9321@item -Wenum-conversion
d77de738
ML
9322Warn when a value of enumerated type is implicitly converted to a
9323different enumerated type. This warning is enabled by @option{-Wextra}
9324in C@.
9325
d77de738
ML
9326@opindex Wenum-int-mismatch
9327@opindex Wno-enum-int-mismatch
ddf6fe37 9328@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9329Warn about mismatches between an enumerated type and an integer type in
9330declarations. For example:
9331
9332@smallexample
9333enum E @{ l = -1, z = 0, g = 1 @};
9334int foo(void);
9335enum E foo(void);
9336@end smallexample
9337
9338In C, an enumerated type is compatible with @code{char}, a signed
9339integer type, or an unsigned integer type. However, since the choice
9340of the underlying type of an enumerated type is implementation-defined,
9341such mismatches may cause portability issues. In C++, such mismatches
9342are an error. In C, this warning is enabled by @option{-Wall} and
9343@option{-Wc++-compat}.
9344
d77de738
ML
9345@opindex Wjump-misses-init
9346@opindex Wno-jump-misses-init
ddf6fe37 9347@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9348Warn if a @code{goto} statement or a @code{switch} statement jumps
9349forward across the initialization of a variable, or jumps backward to a
9350label after the variable has been initialized. This only warns about
9351variables that are initialized when they are declared. This warning is
9352only supported for C and Objective-C; in C++ this sort of branch is an
9353error in any case.
9354
9355@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9356can be disabled with the @option{-Wno-jump-misses-init} option.
9357
d77de738
ML
9358@opindex Wsign-compare
9359@opindex Wno-sign-compare
9360@cindex warning for comparison of signed and unsigned values
9361@cindex comparison of signed and unsigned values, warning
9362@cindex signed and unsigned values, comparison warning
f33d7a88 9363@item -Wsign-compare
d77de738
ML
9364Warn when a comparison between signed and unsigned values could produce
9365an incorrect result when the signed value is converted to unsigned.
9366In C++, this warning is also enabled by @option{-Wall}. In C, it is
9367also enabled by @option{-Wextra}.
9368
d77de738
ML
9369@opindex Wsign-conversion
9370@opindex Wno-sign-conversion
ddf6fe37 9371@item -Wsign-conversion
d77de738
ML
9372Warn for implicit conversions that may change the sign of an integer
9373value, like assigning a signed integer expression to an unsigned
9374integer variable. An explicit cast silences the warning. In C, this
9375option is enabled also by @option{-Wconversion}.
9376
44e3f39a
QZ
9377@opindex Wflex-array-member-not-at-end
9378@opindex Wno-flex-array-member-not-at-end
9379@item -Wflex-array-member-not-at-end @r{(C and C++ only)}
9380Warn when a structure containing a C99 flexible array member as the last
9381field is not at the end of another structure.
9382This warning warns e.g. about
9383
9384@smallexample
9385struct flex @{ int length; char data[]; @};
9386struct mid_flex @{ int m; struct flex flex_data; int n; @};
9387@end smallexample
9388
d77de738
ML
9389@opindex Wfloat-conversion
9390@opindex Wno-float-conversion
ddf6fe37 9391@item -Wfloat-conversion
d77de738
ML
9392Warn for implicit conversions that reduce the precision of a real value.
9393This includes conversions from real to integer, and from higher precision
9394real to lower precision real values. This option is also enabled by
9395@option{-Wconversion}.
9396
d77de738
ML
9397@opindex Wno-scalar-storage-order
9398@opindex Wscalar-storage-order
ddf6fe37 9399@item -Wno-scalar-storage-order
d77de738
ML
9400Do not warn on suspicious constructs involving reverse scalar storage order.
9401
d77de738
ML
9402@opindex Wsizeof-array-div
9403@opindex Wno-sizeof-array-div
ddf6fe37 9404@item -Wsizeof-array-div
d77de738
ML
9405Warn about divisions of two sizeof operators when the first one is applied
9406to an array and the divisor does not equal the size of the array element.
9407In such a case, the computation will not yield the number of elements in the
9408array, which is likely what the user intended. This warning warns e.g. about
9409@smallexample
9410int fn ()
9411@{
9412 int arr[10];
9413 return sizeof (arr) / sizeof (short);
9414@}
9415@end smallexample
9416
9417This warning is enabled by @option{-Wall}.
9418
d77de738
ML
9419@opindex Wsizeof-pointer-div
9420@opindex Wno-sizeof-pointer-div
ddf6fe37 9421@item -Wsizeof-pointer-div
d77de738
ML
9422Warn for suspicious divisions of two sizeof expressions that divide
9423the pointer size by the element size, which is the usual way to compute
9424the array size but won't work out correctly with pointers. This warning
9425warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9426not an array, but a pointer. This warning is enabled by @option{-Wall}.
9427
d77de738
ML
9428@opindex Wsizeof-pointer-memaccess
9429@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9430@item -Wsizeof-pointer-memaccess
d77de738
ML
9431Warn for suspicious length parameters to certain string and memory built-in
9432functions if the argument uses @code{sizeof}. This warning triggers for
9433example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9434an array, but a pointer, and suggests a possible fix, or about
9435@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9436also warns about calls to bounded string copy functions like @code{strncat}
9437or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9438the source array. For example, in the following function the call to
9439@code{strncat} specifies the size of the source string as the bound. That
9440is almost certainly a mistake and so the call is diagnosed.
9441@smallexample
9442void make_file (const char *name)
9443@{
9444 char path[PATH_MAX];
9445 strncpy (path, name, sizeof path - 1);
9446 strncat (path, ".text", sizeof ".text");
9447 @dots{}
9448@}
9449@end smallexample
9450
9451The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9452
d77de738
ML
9453@opindex Wsizeof-array-argument
9454@opindex Wno-sizeof-array-argument
ddf6fe37 9455@item -Wno-sizeof-array-argument
d77de738
ML
9456Do not warn when the @code{sizeof} operator is applied to a parameter that is
9457declared as an array in a function definition. This warning is enabled by
9458default for C and C++ programs.
9459
d77de738
ML
9460@opindex Wmemset-elt-size
9461@opindex Wno-memset-elt-size
ddf6fe37 9462@item -Wmemset-elt-size
d77de738
ML
9463Warn for suspicious calls to the @code{memset} built-in function, if the
9464first argument references an array, and the third argument is a number
9465equal to the number of elements, but not equal to the size of the array
9466in memory. This indicates that the user has omitted a multiplication by
9467the element size. This warning is enabled by @option{-Wall}.
9468
d77de738
ML
9469@opindex Wmemset-transposed-args
9470@opindex Wno-memset-transposed-args
ddf6fe37 9471@item -Wmemset-transposed-args
d77de738
ML
9472Warn for suspicious calls to the @code{memset} built-in function where
9473the second argument is not zero and the third argument is zero. For
9474example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9475@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9476is only emitted if the third argument is a literal zero. Otherwise, if
9477it is an expression that is folded to zero, or a cast of zero to some
9478type, it is far less likely that the arguments have been mistakenly
9479transposed and no warning is emitted. This warning is enabled
9480by @option{-Wall}.
9481
d77de738
ML
9482@opindex Waddress
9483@opindex Wno-address
ddf6fe37 9484@item -Waddress
d77de738
ML
9485Warn about suspicious uses of address expressions. These include comparing
9486the address of a function or a declared object to the null pointer constant
9487such as in
9488@smallexample
9489void f (void);
9490void g (void)
9491@{
9492 if (!f) // warning: expression evaluates to false
9493 abort ();
9494@}
9495@end smallexample
9496comparisons of a pointer to a string literal, such as in
9497@smallexample
9498void f (const char *x)
9499@{
9500 if (x == "abc") // warning: expression evaluates to false
9501 puts ("equal");
9502@}
9503@end smallexample
9504and tests of the results of pointer addition or subtraction for equality
9505to null, such as in
9506@smallexample
9507void f (const int *p, int i)
9508@{
9509 return p + i == NULL;
9510@}
9511@end smallexample
9512Such uses typically indicate a programmer error: the address of most
9513functions and objects necessarily evaluates to true (the exception are
9514weak symbols), so their use in a conditional might indicate missing
9515parentheses in a function call or a missing dereference in an array
9516expression. The subset of the warning for object pointers can be
9517suppressed by casting the pointer operand to an integer type such
9518as @code{intptr_t} or @code{uintptr_t}.
9519Comparisons against string literals result in unspecified behavior
9520and are not portable, and suggest the intent was to call @code{strcmp}.
9521The warning is suppressed if the suspicious expression is the result
9522of macro expansion.
9523@option{-Waddress} warning is enabled by @option{-Wall}.
9524
d77de738
ML
9525@opindex Waddress-of-packed-member
9526@opindex Wno-address-of-packed-member
ddf6fe37 9527@item -Wno-address-of-packed-member
d77de738
ML
9528Do not warn when the address of packed member of struct or union is taken,
9529which usually results in an unaligned pointer value. This is
9530enabled by default.
9531
d77de738
ML
9532@opindex Wlogical-op
9533@opindex Wno-logical-op
ddf6fe37 9534@item -Wlogical-op
d77de738
ML
9535Warn about suspicious uses of logical operators in expressions.
9536This includes using logical operators in contexts where a
9537bit-wise operator is likely to be expected. Also warns when
9538the operands of a logical operator are the same:
9539@smallexample
9540extern int a;
9541if (a < 0 && a < 0) @{ @dots{} @}
9542@end smallexample
9543
d77de738
ML
9544@opindex Wlogical-not-parentheses
9545@opindex Wno-logical-not-parentheses
ddf6fe37 9546@item -Wlogical-not-parentheses
d77de738
ML
9547Warn about logical not used on the left hand side operand of a comparison.
9548This option does not warn if the right operand is considered to be a boolean
9549expression. Its purpose is to detect suspicious code like the following:
9550@smallexample
9551int a;
9552@dots{}
9553if (!a > 1) @{ @dots{} @}
9554@end smallexample
9555
9556It is possible to suppress the warning by wrapping the LHS into
9557parentheses:
9558@smallexample
9559if ((!a) > 1) @{ @dots{} @}
9560@end smallexample
9561
9562This warning is enabled by @option{-Wall}.
9563
d77de738
ML
9564@opindex Waggregate-return
9565@opindex Wno-aggregate-return
ddf6fe37 9566@item -Waggregate-return
d77de738
ML
9567Warn if any functions that return structures or unions are defined or
9568called. (In languages where you can return an array, this also elicits
9569a warning.)
9570
d77de738
ML
9571@opindex Wno-aggressive-loop-optimizations
9572@opindex Waggressive-loop-optimizations
ddf6fe37 9573@item -Wno-aggressive-loop-optimizations
d77de738
ML
9574Warn if in a loop with constant number of iterations the compiler detects
9575undefined behavior in some statement during one or more of the iterations.
9576
d77de738
ML
9577@opindex Wno-attributes
9578@opindex Wattributes
ddf6fe37 9579@item -Wno-attributes
d77de738
ML
9580Do not warn if an unexpected @code{__attribute__} is used, such as
9581unrecognized attributes, function attributes applied to variables,
9582etc. This does not stop errors for incorrect use of supported
9583attributes.
9584
5fccebdb
JM
9585Warnings about ill-formed uses of standard attributes are upgraded to
9586errors by @option{-pedantic-errors}.
9587
d77de738
ML
9588Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9589warnings about unknown scoped attributes (in C++11 and C2X). For example,
9590@option{-Wno-attributes=vendor::attr} disables warning about the following
9591declaration:
9592
9593@smallexample
9594[[vendor::attr]] void f();
9595@end smallexample
9596
9597It is also possible to disable warning about all attributes in a namespace
9598using @option{-Wno-attributes=vendor::} which prevents warning about both
9599of these declarations:
9600
9601@smallexample
9602[[vendor::safe]] void f();
9603[[vendor::unsafe]] void f2();
9604@end smallexample
9605
9606Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9607
d77de738
ML
9608@opindex Wno-builtin-declaration-mismatch
9609@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9610@item -Wno-builtin-declaration-mismatch
d77de738
ML
9611Warn if a built-in function is declared with an incompatible signature
9612or as a non-function, or when a built-in function declared with a type
9613that does not include a prototype is called with arguments whose promoted
9614types do not match those expected by the function. When @option{-Wextra}
9615is specified, also warn when a built-in function that takes arguments is
9616declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9617warning is enabled by default. To avoid the warning include the appropriate
9618header to bring the prototypes of built-in functions into scope.
9619
9620For example, the call to @code{memset} below is diagnosed by the warning
9621because the function expects a value of type @code{size_t} as its argument
9622but the type of @code{32} is @code{int}. With @option{-Wextra},
9623the declaration of the function is diagnosed as well.
9624@smallexample
9625extern void* memset ();
9626void f (void *d)
9627@{
9628 memset (d, '\0', 32);
9629@}
9630@end smallexample
9631
d77de738
ML
9632@opindex Wno-builtin-macro-redefined
9633@opindex Wbuiltin-macro-redefined
ddf6fe37 9634@item -Wno-builtin-macro-redefined
d77de738
ML
9635Do not warn if certain built-in macros are redefined. This suppresses
9636warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9637@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9638
d77de738
ML
9639@opindex Wstrict-prototypes
9640@opindex Wno-strict-prototypes
ddf6fe37 9641@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9642Warn if a function is declared or defined without specifying the
9643argument types. (An old-style function definition is permitted without
9644a warning if preceded by a declaration that specifies the argument
9645types.)
9646
d77de738
ML
9647@opindex Wold-style-declaration
9648@opindex Wno-old-style-declaration
ddf6fe37 9649@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9650Warn for obsolescent usages, according to the C Standard, in a
9651declaration. For example, warn if storage-class specifiers like
9652@code{static} are not the first things in a declaration. This warning
9653is also enabled by @option{-Wextra}.
9654
d77de738
ML
9655@opindex Wold-style-definition
9656@opindex Wno-old-style-definition
ddf6fe37 9657@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9658Warn if an old-style function definition is used. A warning is given
9659even if there is a previous prototype. A definition using @samp{()}
9660is not considered an old-style definition in C2X mode, because it is
9661equivalent to @samp{(void)} in that case, but is considered an
9662old-style definition for older standards.
9663
d77de738
ML
9664@opindex Wmissing-parameter-type
9665@opindex Wno-missing-parameter-type
ddf6fe37 9666@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9667A function parameter is declared without a type specifier in K&R-style
9668functions:
9669
9670@smallexample
9671void foo(bar) @{ @}
9672@end smallexample
9673
9674This warning is also enabled by @option{-Wextra}.
9675
d77de738
ML
9676@opindex Wmissing-prototypes
9677@opindex Wno-missing-prototypes
ddf6fe37 9678@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9679Warn if a global function is defined without a previous prototype
9680declaration. This warning is issued even if the definition itself
9681provides a prototype. Use this option to detect global functions
9682that do not have a matching prototype declaration in a header file.
9683This option is not valid for C++ because all function declarations
9684provide prototypes and a non-matching declaration declares an
9685overload rather than conflict with an earlier declaration.
9686Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9687
ffc74822
HM
9688@opindex Wmissing-variable-declarations
9689@opindex Wno-missing-variable-declarations
9690@item -Wmissing-variable-declarations @r{(C and Objective-C only)}
9691Warn if a global variable is defined without a previous declaration.
9692Use this option to detect global variables that do not have a matching
9693extern declaration in a header file.
9694
d77de738
ML
9695@opindex Wmissing-declarations
9696@opindex Wno-missing-declarations
ddf6fe37 9697@item -Wmissing-declarations
d77de738
ML
9698Warn if a global function is defined without a previous declaration.
9699Do so even if the definition itself provides a prototype.
9700Use this option to detect global functions that are not declared in
9701header files. In C, no warnings are issued for functions with previous
9702non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9703missing prototypes. In C++, no warnings are issued for function templates,
9704or for inline functions, or for functions in anonymous namespaces.
9705
d77de738
ML
9706@opindex Wmissing-field-initializers
9707@opindex Wno-missing-field-initializers
9708@opindex W
9709@opindex Wextra
9710@opindex Wno-extra
ddf6fe37 9711@item -Wmissing-field-initializers
d77de738
ML
9712Warn if a structure's initializer has some fields missing. For
9713example, the following code causes such a warning, because
9714@code{x.h} is implicitly zero:
9715
9716@smallexample
9717struct s @{ int f, g, h; @};
9718struct s x = @{ 3, 4 @};
9719@end smallexample
9720
0f8f1dee
MP
9721@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
9722In C this option does not warn about designated initializers, so the
9723following modification does not trigger a warning:
d77de738
ML
9724
9725@smallexample
9726struct s @{ int f, g, h; @};
9727struct s x = @{ .f = 3, .g = 4 @};
9728@end smallexample
9729
9730In C this option does not warn about the universal zero initializer
9731@samp{@{ 0 @}}:
9732
9733@smallexample
9734struct s @{ int f, g, h; @};
9735struct s x = @{ 0 @};
9736@end smallexample
9737
9738Likewise, in C++ this option does not warn about the empty @{ @}
9739initializer, for example:
9740
9741@smallexample
9742struct s @{ int f, g, h; @};
9743s x = @{ @};
9744@end smallexample
9745
9746This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9747warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9748
d77de738
ML
9749@opindex Wmissing-requires
9750@opindex Wno-missing-requires
ddf6fe37 9751@item -Wno-missing-requires
d77de738
ML
9752
9753By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9754
9755@smallexample
9756bool satisfied = requires @{ C<T> @};
9757@end smallexample
9758
9759Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9760expression, which it is for all T. Presumably the user meant to write
9761
9762@smallexample
9763bool satisfied = requires @{ requires C<T> @};
9764@end smallexample
9765
9766so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9767type @samp{T}.
9768
9769This warning can be disabled with @option{-Wno-missing-requires}.
9770
d77de738
ML
9771@opindex Wmissing-template-keyword
9772@opindex Wno-missing-template-keyword
ddf6fe37 9773@item -Wno-missing-template-keyword
d77de738
ML
9774
9775The member access tokens ., -> and :: must be followed by the @code{template}
9776keyword if the parent object is dependent and the member being named is a
9777template.
9778
9779@smallexample
9780template <class X>
9781void DoStuff (X x)
9782@{
9783 x.template DoSomeOtherStuff<X>(); // Good.
9784 x.DoMoreStuff<X>(); // Warning, x is dependent.
9785@}
9786@end smallexample
9787
9788In rare cases it is possible to get false positives. To silence this, wrap
9789the expression in parentheses. For example, the following is treated as a
9790template, even where m and N are integers:
9791
9792@smallexample
9793void NotATemplate (my_class t)
9794@{
9795 int N = 5;
9796
9797 bool test = t.m < N > (0); // Treated as a template.
9798 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9799@}
9800@end smallexample
9801
9802This warning can be disabled with @option{-Wno-missing-template-keyword}.
9803
d77de738
ML
9804@opindex Wno-multichar
9805@opindex Wmultichar
ddf6fe37 9806@item -Wno-multichar
d77de738
ML
9807Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9808Usually they indicate a typo in the user's code, as they have
9809implementation-defined values, and should not be used in portable code.
9810
d77de738
ML
9811@opindex Wnormalized=
9812@opindex Wnormalized
9813@opindex Wno-normalized
9814@cindex NFC
9815@cindex NFKC
9816@cindex character set, input normalization
f33d7a88 9817@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9818In ISO C and ISO C++, two identifiers are different if they are
9819different sequences of characters. However, sometimes when characters
9820outside the basic ASCII character set are used, you can have two
9821different character sequences that look the same. To avoid confusion,
9822the ISO 10646 standard sets out some @dfn{normalization rules} which
9823when applied ensure that two sequences that look the same are turned into
9824the same sequence. GCC can warn you if you are using identifiers that
9825have not been normalized; this option controls that warning.
9826
9827There are four levels of warning supported by GCC@. The default is
9828@option{-Wnormalized=nfc}, which warns about any identifier that is
9829not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9830recommended form for most uses. It is equivalent to
9831@option{-Wnormalized}.
9832
9833Unfortunately, there are some characters allowed in identifiers by
9834ISO C and ISO C++ that, when turned into NFC, are not allowed in
9835identifiers. That is, there's no way to use these symbols in portable
9836ISO C or C++ and have all your identifiers in NFC@.
9837@option{-Wnormalized=id} suppresses the warning for these characters.
9838It is hoped that future versions of the standards involved will correct
9839this, which is why this option is not the default.
9840
9841You can switch the warning off for all characters by writing
9842@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9843only do this if you are using some other normalization scheme (like
9844``D''), because otherwise you can easily create bugs that are
9845literally impossible to see.
9846
9847Some characters in ISO 10646 have distinct meanings but look identical
9848in some fonts or display methodologies, especially once formatting has
9849been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9850LETTER N'', displays just like a regular @code{n} that has been
9851placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9852normalization scheme to convert all these into a standard form as
9853well, and GCC warns if your code is not in NFKC if you use
9854@option{-Wnormalized=nfkc}. This warning is comparable to warning
9855about every identifier that contains the letter O because it might be
9856confused with the digit 0, and so is not the default, but may be
9857useful as a local coding convention if the programming environment
9858cannot be fixed to display these characters distinctly.
9859
d77de738
ML
9860@opindex Wno-attribute-warning
9861@opindex Wattribute-warning
ddf6fe37 9862@item -Wno-attribute-warning
d77de738
ML
9863Do not warn about usage of functions (@pxref{Function Attributes})
9864declared with @code{warning} attribute. By default, this warning is
9865enabled. @option{-Wno-attribute-warning} can be used to disable the
9866warning or @option{-Wno-error=attribute-warning} can be used to
9867disable the error when compiled with @option{-Werror} flag.
9868
d77de738
ML
9869@opindex Wno-deprecated
9870@opindex Wdeprecated
ddf6fe37 9871@item -Wno-deprecated
d77de738
ML
9872Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9873
d77de738
ML
9874@opindex Wno-deprecated-declarations
9875@opindex Wdeprecated-declarations
ddf6fe37 9876@item -Wno-deprecated-declarations
d77de738
ML
9877Do not warn about uses of functions (@pxref{Function Attributes}),
9878variables (@pxref{Variable Attributes}), and types (@pxref{Type
9879Attributes}) marked as deprecated by using the @code{deprecated}
9880attribute.
9881
d77de738
ML
9882@opindex Wno-overflow
9883@opindex Woverflow
ddf6fe37 9884@item -Wno-overflow
d77de738
ML
9885Do not warn about compile-time overflow in constant expressions.
9886
d77de738
ML
9887@opindex Wno-odr
9888@opindex Wodr
ddf6fe37 9889@item -Wno-odr
d77de738
ML
9890Warn about One Definition Rule violations during link-time optimization.
9891Enabled by default.
9892
d77de738
ML
9893@opindex Wopenacc-parallelism
9894@opindex Wno-openacc-parallelism
9895@cindex OpenACC accelerator programming
f33d7a88 9896@item -Wopenacc-parallelism
d77de738
ML
9897Warn about potentially suboptimal choices related to OpenACC parallelism.
9898
d77de738
ML
9899@opindex Wopenmp-simd
9900@opindex Wno-openmp-simd
ddf6fe37 9901@item -Wopenmp-simd
d77de738
ML
9902Warn if the vectorizer cost model overrides the OpenMP
9903simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9904option can be used to relax the cost model.
9905
d77de738
ML
9906@opindex Woverride-init
9907@opindex Wno-override-init
9908@opindex W
9909@opindex Wextra
9910@opindex Wno-extra
ddf6fe37 9911@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9912Warn if an initialized field without side effects is overridden when
9913using designated initializers (@pxref{Designated Inits, , Designated
9914Initializers}).
9915
9916This warning is included in @option{-Wextra}. To get other
9917@option{-Wextra} warnings without this one, use @option{-Wextra
9918-Wno-override-init}.
9919
d77de738
ML
9920@opindex Woverride-init-side-effects
9921@opindex Wno-override-init-side-effects
ddf6fe37 9922@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9923Do not warn if an initialized field with side effects is overridden when
9924using designated initializers (@pxref{Designated Inits, , Designated
9925Initializers}). This warning is enabled by default.
9926
d77de738
ML
9927@opindex Wpacked
9928@opindex Wno-packed
ddf6fe37 9929@item -Wpacked
d77de738
ML
9930Warn if a structure is given the packed attribute, but the packed
9931attribute has no effect on the layout or size of the structure.
9932Such structures may be mis-aligned for little benefit. For
9933instance, in this code, the variable @code{f.x} in @code{struct bar}
9934is misaligned even though @code{struct bar} does not itself
9935have the packed attribute:
9936
9937@smallexample
9938@group
9939struct foo @{
9940 int x;
9941 char a, b, c, d;
9942@} __attribute__((packed));
9943struct bar @{
9944 char z;
9945 struct foo f;
9946@};
9947@end group
9948@end smallexample
9949
d77de738
ML
9950@opindex Wpacked-bitfield-compat
9951@opindex Wno-packed-bitfield-compat
ddf6fe37 9952@item -Wnopacked-bitfield-compat
d77de738
ML
9953The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9954on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9955the change can lead to differences in the structure layout. GCC
9956informs you when the offset of such a field has changed in GCC 4.4.
9957For example there is no longer a 4-bit padding between field @code{a}
9958and @code{b} in this structure:
9959
9960@smallexample
9961struct foo
9962@{
9963 char a:4;
9964 char b:8;
9965@} __attribute__ ((packed));
9966@end smallexample
9967
9968This warning is enabled by default. Use
9969@option{-Wno-packed-bitfield-compat} to disable this warning.
9970
d77de738
ML
9971@opindex Wpacked-not-aligned
9972@opindex Wno-packed-not-aligned
ddf6fe37 9973@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
9974Warn if a structure field with explicitly specified alignment in a
9975packed struct or union is misaligned. For example, a warning will
9976be issued on @code{struct S}, like, @code{warning: alignment 1 of
9977'struct S' is less than 8}, in this code:
9978
9979@smallexample
9980@group
9981struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9982struct __attribute__ ((packed)) S @{
9983 struct S8 s8;
9984@};
9985@end group
9986@end smallexample
9987
9988This warning is enabled by @option{-Wall}.
9989
d77de738
ML
9990@opindex Wpadded
9991@opindex Wno-padded
ddf6fe37 9992@item -Wpadded
d77de738
ML
9993Warn if padding is included in a structure, either to align an element
9994of the structure or to align the whole structure. Sometimes when this
9995happens it is possible to rearrange the fields of the structure to
9996reduce the padding and so make the structure smaller.
9997
d77de738
ML
9998@opindex Wredundant-decls
9999@opindex Wno-redundant-decls
ddf6fe37 10000@item -Wredundant-decls
d77de738
ML
10001Warn if anything is declared more than once in the same scope, even in
10002cases where multiple declaration is valid and changes nothing.
10003
d77de738
ML
10004@opindex Wrestrict
10005@opindex Wno-restrict
ddf6fe37 10006@item -Wrestrict
d77de738
ML
10007Warn when an object referenced by a @code{restrict}-qualified parameter
10008(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10009argument, or when copies between such objects overlap. For example,
10010the call to the @code{strcpy} function below attempts to truncate the string
10011by replacing its initial characters with the last four. However, because
10012the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10013the call is diagnosed.
10014
10015@smallexample
10016void foo (void)
10017@{
10018 char a[] = "abcd1234";
10019 strcpy (a, a + 4);
10020 @dots{}
10021@}
10022@end smallexample
10023The @option{-Wrestrict} option detects some instances of simple overlap
10024even without optimization but works best at @option{-O2} and above. It
10025is included in @option{-Wall}.
10026
d77de738
ML
10027@opindex Wnested-externs
10028@opindex Wno-nested-externs
ddf6fe37 10029@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
10030Warn if an @code{extern} declaration is encountered within a function.
10031
d77de738
ML
10032@opindex Winline
10033@opindex Wno-inline
ddf6fe37 10034@item -Winline
d77de738
ML
10035Warn if a function that is declared as inline cannot be inlined.
10036Even with this option, the compiler does not warn about failures to
10037inline functions declared in system headers.
10038
10039The compiler uses a variety of heuristics to determine whether or not
10040to inline a function. For example, the compiler takes into account
10041the size of the function being inlined and the amount of inlining
10042that has already been done in the current function. Therefore,
10043seemingly insignificant changes in the source program can cause the
10044warnings produced by @option{-Winline} to appear or disappear.
10045
d77de738 10046@opindex Winterference-size
ddf6fe37 10047@item -Winterference-size
d77de738
ML
10048Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10049without specifying its value with @option{--param destructive-interference-size}.
10050Also warn about questionable values for that option.
10051
10052This variable is intended to be used for controlling class layout, to
10053avoid false sharing in concurrent code:
10054
10055@smallexample
10056struct independent_fields @{
4ace81b6
SL
10057 alignas(std::hardware_destructive_interference_size)
10058 std::atomic<int> one;
10059 alignas(std::hardware_destructive_interference_size)
10060 std::atomic<int> two;
d77de738
ML
10061@};
10062@end smallexample
10063
10064Here @samp{one} and @samp{two} are intended to be far enough apart
10065that stores to one won't require accesses to the other to reload the
10066cache line.
10067
10068By default, @option{--param destructive-interference-size} and
10069@option{--param constructive-interference-size} are set based on the
10070current @option{-mtune} option, typically to the L1 cache line size
10071for the particular target CPU, sometimes to a range if tuning for a
10072generic target. So all translation units that depend on ABI
10073compatibility for the use of these variables must be compiled with
10074the same @option{-mtune} (or @option{-mcpu}).
10075
10076If ABI stability is important, such as if the use is in a header for a
10077library, you should probably not use the hardware interference size
10078variables at all. Alternatively, you can force a particular value
10079with @option{--param}.
10080
10081If you are confident that your use of the variable does not affect ABI
10082outside a single build of your project, you can turn off the warning
10083with @option{-Wno-interference-size}.
10084
d77de738
ML
10085@opindex Wint-in-bool-context
10086@opindex Wno-int-in-bool-context
ddf6fe37 10087@item -Wint-in-bool-context
d77de738
ML
10088Warn for suspicious use of integer values where boolean values are expected,
10089such as conditional expressions (?:) using non-boolean integer constants in
10090boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10091integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10092for all kinds of multiplications regardless of the data type.
10093This warning is enabled by @option{-Wall}.
10094
d77de738
ML
10095@opindex Wno-int-to-pointer-cast
10096@opindex Wint-to-pointer-cast
ddf6fe37 10097@item -Wno-int-to-pointer-cast
d77de738
ML
10098Suppress warnings from casts to pointer type of an integer of a
10099different size. In C++, casting to a pointer type of smaller size is
10100an error. @option{Wint-to-pointer-cast} is enabled by default.
10101
10102
d77de738
ML
10103@opindex Wno-pointer-to-int-cast
10104@opindex Wpointer-to-int-cast
ddf6fe37 10105@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
10106Suppress warnings from casts from a pointer to an integer type of a
10107different size.
10108
d77de738
ML
10109@opindex Winvalid-pch
10110@opindex Wno-invalid-pch
ddf6fe37 10111@item -Winvalid-pch
d77de738
ML
10112Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10113the search path but cannot be used.
10114
d77de738
ML
10115@opindex Winvalid-utf8
10116@opindex Wno-invalid-utf8
ddf6fe37 10117@item -Winvalid-utf8
d77de738
ML
10118Warn if an invalid UTF-8 character is found.
10119This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10120is used and turned into error with @option{-pedantic-errors}.
10121
d77de738
ML
10122@opindex Wunicode
10123@opindex Wno-unicode
ddf6fe37 10124@item -Wno-unicode
d77de738
ML
10125Don't diagnose invalid forms of delimited or named escape sequences which are
10126treated as separate tokens. @option{Wunicode} is enabled by default.
10127
d77de738
ML
10128@opindex Wlong-long
10129@opindex Wno-long-long
ddf6fe37 10130@item -Wlong-long
d77de738
ML
10131Warn if @code{long long} type is used. This is enabled by either
10132@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10133modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10134
5fccebdb
JM
10135This warning is upgraded to an error by @option{-pedantic-errors}.
10136
d77de738
ML
10137@opindex Wvariadic-macros
10138@opindex Wno-variadic-macros
ddf6fe37 10139@item -Wvariadic-macros
d77de738
ML
10140Warn if variadic macros are used in ISO C90 mode, or if the GNU
10141alternate syntax is used in ISO C99 mode. This is enabled by either
10142@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10143messages, use @option{-Wno-variadic-macros}.
10144
d77de738
ML
10145@opindex Wvarargs
10146@opindex Wno-varargs
ddf6fe37 10147@item -Wno-varargs
d77de738
ML
10148Do not warn upon questionable usage of the macros used to handle variable
10149arguments like @code{va_start}. These warnings are enabled by default.
10150
d77de738
ML
10151@opindex Wvector-operation-performance
10152@opindex Wno-vector-operation-performance
ddf6fe37 10153@item -Wvector-operation-performance
d77de738
ML
10154Warn if vector operation is not implemented via SIMD capabilities of the
10155architecture. Mainly useful for the performance tuning.
10156Vector operation can be implemented @code{piecewise}, which means that the
10157scalar operation is performed on every vector element;
10158@code{in parallel}, which means that the vector operation is implemented
10159using scalars of wider type, which normally is more performance efficient;
10160and @code{as a single scalar}, which means that vector fits into a
10161scalar type.
10162
d77de738
ML
10163@opindex Wvla
10164@opindex Wno-vla
ddf6fe37 10165@item -Wvla
d77de738
ML
10166Warn if a variable-length array is used in the code.
10167@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10168the variable-length array.
10169
5fccebdb
JM
10170This warning is upgraded to an error by @option{-pedantic-errors}.
10171
d77de738
ML
10172@opindex Wvla-larger-than=
10173@opindex Wno-vla-larger-than
ddf6fe37 10174@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10175If this option is used, the compiler warns for declarations of
10176variable-length arrays whose size is either unbounded, or bounded
10177by an argument that allows the array size to exceed @var{byte-size}
10178bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10179works, but with variable-length arrays.
10180
10181Note that GCC may optimize small variable-length arrays of a known
10182value into plain arrays, so this warning may not get triggered for
10183such arrays.
10184
10185@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10186is typically only effective when @option{-ftree-vrp} is active (default
10187for @option{-O2} and above).
10188
10189See also @option{-Walloca-larger-than=@var{byte-size}}.
10190
d77de738 10191@opindex Wno-vla-larger-than
ddf6fe37 10192@item -Wno-vla-larger-than
d77de738
ML
10193Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10194to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10195
d77de738 10196@opindex Wno-vla-parameter
ddf6fe37 10197@item -Wvla-parameter
d77de738
ML
10198Warn about redeclarations of functions involving arguments of Variable
10199Length Array types of inconsistent kinds or forms, and enable the detection
10200of out-of-bounds accesses to such parameters by warnings such as
10201@option{-Warray-bounds}.
10202
10203If the first function declaration uses the VLA form the bound specified
10204in the array is assumed to be the minimum number of elements expected to
10205be provided in calls to the function and the maximum number of elements
10206accessed by it. Failing to provide arguments of sufficient size or
10207accessing more than the maximum number of elements may be diagnosed.
10208
10209For example, the warning triggers for the following redeclarations because
10210the first one allows an array of any size to be passed to @code{f} while
10211the second one specifies that the array argument must have at least @code{n}
10212elements. In addition, calling @code{f} with the associated VLA bound
10213parameter in excess of the actual VLA bound triggers a warning as well.
10214
10215@smallexample
10216void f (int n, int[n]);
4ace81b6
SL
10217// warning: argument 2 previously declared as a VLA
10218void f (int, int[]);
d77de738
ML
10219
10220void g (int n)
10221@{
10222 if (n > 4)
10223 return;
10224 int a[n];
4ace81b6
SL
10225 // warning: access to a by f may be out of bounds
10226 f (sizeof a, a);
d77de738
ML
10227 @dots{}
10228@}
10229
10230@end smallexample
10231
10232@option{-Wvla-parameter} is included in @option{-Wall}. The
10233@option{-Warray-parameter} option triggers warnings for similar problems
10234involving ordinary array arguments.
10235
d77de738
ML
10236@opindex Wvolatile-register-var
10237@opindex Wno-volatile-register-var
ddf6fe37 10238@item -Wvolatile-register-var
d77de738
ML
10239Warn if a register variable is declared volatile. The volatile
10240modifier does not inhibit all optimizations that may eliminate reads
10241and/or writes to register variables. This warning is enabled by
10242@option{-Wall}.
10243
d77de738
ML
10244@opindex Wxor-used-as-pow
10245@opindex Wno-xor-used-as-pow
ddf6fe37 10246@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10247Warn about uses of @code{^}, the exclusive or operator, where it appears
10248the user meant exponentiation. Specifically, the warning occurs when the
10249left-hand side is the decimal constant 2 or 10 and the right-hand side
10250is also a decimal constant.
10251
10252In C and C++, @code{^} means exclusive or, whereas in some other languages
10253(e.g. TeX and some versions of BASIC) it means exponentiation.
10254
10255This warning is enabled by default. It can be silenced by converting one
10256of the operands to hexadecimal.
10257
d77de738
ML
10258@opindex Wdisabled-optimization
10259@opindex Wno-disabled-optimization
ddf6fe37 10260@item -Wdisabled-optimization
d77de738
ML
10261Warn if a requested optimization pass is disabled. This warning does
10262not generally indicate that there is anything wrong with your code; it
10263merely indicates that GCC's optimizers are unable to handle the code
10264effectively. Often, the problem is that your code is too big or too
10265complex; GCC refuses to optimize programs when the optimization
10266itself is likely to take inordinate amounts of time.
10267
d77de738
ML
10268@opindex Wpointer-sign
10269@opindex Wno-pointer-sign
ddf6fe37 10270@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10271Warn for pointer argument passing or assignment with different signedness.
10272This option is only supported for C and Objective-C@. It is implied by
10273@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10274@option{-Wno-pointer-sign}.
10275
5fccebdb
JM
10276This warning is upgraded to an error by @option{-pedantic-errors}.
10277
d77de738
ML
10278@opindex Wstack-protector
10279@opindex Wno-stack-protector
ddf6fe37 10280@item -Wstack-protector
d77de738
ML
10281This option is only active when @option{-fstack-protector} is active. It
10282warns about functions that are not protected against stack smashing.
10283
d77de738
ML
10284@opindex Woverlength-strings
10285@opindex Wno-overlength-strings
ddf6fe37 10286@item -Woverlength-strings
d77de738
ML
10287Warn about string constants that are longer than the ``minimum
10288maximum'' length specified in the C standard. Modern compilers
10289generally allow string constants that are much longer than the
10290standard's minimum limit, but very portable programs should avoid
10291using longer strings.
10292
10293The limit applies @emph{after} string constant concatenation, and does
10294not count the trailing NUL@. In C90, the limit was 509 characters; in
10295C99, it was raised to 4095. C++98 does not specify a normative
10296minimum maximum, so we do not diagnose overlength strings in C++@.
10297
10298This option is implied by @option{-Wpedantic}, and can be disabled with
10299@option{-Wno-overlength-strings}.
10300
d77de738
ML
10301@opindex Wunsuffixed-float-constants
10302@opindex Wno-unsuffixed-float-constants
ddf6fe37 10303@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10304
10305Issue a warning for any floating constant that does not have
10306a suffix. When used together with @option{-Wsystem-headers} it
10307warns about such constants in system header files. This can be useful
10308when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10309from the decimal floating-point extension to C99.
10310
d77de738
ML
10311@opindex Wlto-type-mismatch
10312@opindex Wno-lto-type-mismatch
ddf6fe37 10313@item -Wno-lto-type-mismatch
d77de738
ML
10314
10315During the link-time optimization, do not warn about type mismatches in
10316global declarations from different compilation units.
10317Requires @option{-flto} to be enabled. Enabled by default.
10318
d77de738
ML
10319@opindex Wdesignated-init
10320@opindex Wno-designated-init
ddf6fe37 10321@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10322Suppress warnings when a positional initializer is used to initialize
10323a structure that has been marked with the @code{designated_init}
10324attribute.
10325
10326@end table
10327
10328@node Static Analyzer Options
10329@section Options That Control Static Analysis
10330
10331@table @gcctabopt
d77de738
ML
10332@opindex analyzer
10333@opindex fanalyzer
10334@opindex fno-analyzer
ddf6fe37 10335@item -fanalyzer
d77de738
ML
10336This option enables an static analysis of program flow which looks
10337for ``interesting'' interprocedural paths through the
10338code, and issues warnings for problems found on them.
10339
10340This analysis is much more expensive than other GCC warnings.
10341
a90316c6
DM
10342In technical terms, it performs coverage-guided symbolic execution of
10343the code being compiled. It is neither sound nor complete: it can
10344have false positives and false negatives. It is a bug-finding tool,
10345rather than a tool for proving program correctness.
10346
10347The analyzer is only suitable for use on C code in this release.
10348
d77de738
ML
10349Enabling this option effectively enables the following warnings:
10350
43b72ede
AA
10351@gccoptlist{
10352-Wanalyzer-allocation-size
10353-Wanalyzer-deref-before-check
10354-Wanalyzer-double-fclose
10355-Wanalyzer-double-free
10356-Wanalyzer-exposure-through-output-file
10357-Wanalyzer-exposure-through-uninit-copy
10358-Wanalyzer-fd-access-mode-mismatch
10359-Wanalyzer-fd-double-close
10360-Wanalyzer-fd-leak
10361-Wanalyzer-fd-phase-mismatch
10362-Wanalyzer-fd-type-mismatch
10363-Wanalyzer-fd-use-after-close
10364-Wanalyzer-fd-use-without-check
10365-Wanalyzer-file-leak
10366-Wanalyzer-free-of-non-heap
10367-Wanalyzer-imprecise-fp-arithmetic
10368-Wanalyzer-infinite-recursion
10369-Wanalyzer-jump-through-null
10370-Wanalyzer-malloc-leak
10371-Wanalyzer-mismatching-deallocation
10372-Wanalyzer-null-argument
10373-Wanalyzer-null-dereference
10374-Wanalyzer-out-of-bounds
034d99e8 10375-Wanalyzer-overlapping-buffers
43b72ede
AA
10376-Wanalyzer-possible-null-argument
10377-Wanalyzer-possible-null-dereference
10378-Wanalyzer-putenv-of-auto-var
10379-Wanalyzer-shift-count-negative
10380-Wanalyzer-shift-count-overflow
10381-Wanalyzer-stale-setjmp-buffer
10382-Wanalyzer-unsafe-call-within-signal-handler
10383-Wanalyzer-use-after-free
10384-Wanalyzer-use-of-pointer-in-stale-stack-frame
10385-Wanalyzer-use-of-uninitialized-value
10386-Wanalyzer-va-arg-type-mismatch
10387-Wanalyzer-va-list-exhausted
10388-Wanalyzer-va-list-leak
10389-Wanalyzer-va-list-use-after-va-end
10390-Wanalyzer-write-to-const
10391-Wanalyzer-write-to-string-literal
d77de738
ML
10392}
10393@ignore
43b72ede
AA
10394-Wanalyzer-tainted-allocation-size
10395-Wanalyzer-tainted-array-index
10396-Wanalyzer-tainted-divisor
10397-Wanalyzer-tainted-offset
10398-Wanalyzer-tainted-size
d77de738
ML
10399@end ignore
10400
10401This option is only available if GCC was configured with analyzer
10402support enabled.
10403
d77de738
ML
10404@opindex Wanalyzer-too-complex
10405@opindex Wno-analyzer-too-complex
ddf6fe37 10406@item -Wanalyzer-too-complex
d77de738
ML
10407If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10408to attempt to explore the control flow and data flow in the program,
10409but these can be defeated by sufficiently complicated code.
10410
10411By default, the analysis silently stops if the code is too
10412complicated for the analyzer to fully explore and it reaches an internal
10413limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10414
d77de738
ML
10415@opindex Wanalyzer-allocation-size
10416@opindex Wno-analyzer-allocation-size
ddf6fe37 10417@item -Wno-analyzer-allocation-size
4ace81b6
SL
10418This warning requires @option{-fanalyzer}, which enables it;
10419to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10420
10421This diagnostic warns for paths through the code in which a pointer to
10422a buffer is assigned to point at a buffer with a size that is not a
10423multiple of @code{sizeof (*pointer)}.
10424
10425See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10426
ce51e843
ML
10427@opindex Wanalyzer-deref-before-check
10428@opindex Wno-analyzer-deref-before-check
ddf6fe37 10429@item -Wno-analyzer-deref-before-check
ce51e843
ML
10430This warning requires @option{-fanalyzer}, which enables it; use
10431@option{-Wno-analyzer-deref-before-check}
10432to disable it.
10433
10434This diagnostic warns for paths through the code in which a pointer
10435is checked for @code{NULL} *after* it has already been
10436dereferenced, suggesting that the pointer could have been NULL.
10437Such cases suggest that the check for NULL is either redundant,
10438or that it needs to be moved to before the pointer is dereferenced.
10439
10440This diagnostic also considers values passed to a function argument
10441marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10442value, and thus will complain if such values are checked for @code{NULL}
10443after returning from such a function call.
10444
10445This diagnostic is unlikely to be reported when any level of optimization
10446is enabled, as GCC's optimization logic will typically consider such
10447checks for NULL as being redundant, and optimize them away before the
10448analyzer "sees" them. Hence optimization should be disabled when
10449attempting to trigger this diagnostic.
10450
d77de738
ML
10451@opindex Wanalyzer-double-fclose
10452@opindex Wno-analyzer-double-fclose
ddf6fe37 10453@item -Wno-analyzer-double-fclose
d77de738
ML
10454This warning requires @option{-fanalyzer}, which enables it; use
10455@option{-Wno-analyzer-double-fclose} to disable it.
10456
10457This diagnostic warns for paths through the code in which a @code{FILE *}
10458can have @code{fclose} called on it more than once.
10459
10460See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10461
d77de738
ML
10462@opindex Wanalyzer-double-free
10463@opindex Wno-analyzer-double-free
ddf6fe37 10464@item -Wno-analyzer-double-free
d77de738
ML
10465This warning requires @option{-fanalyzer}, which enables it; use
10466@option{-Wno-analyzer-double-free} to disable it.
10467
10468This diagnostic warns for paths through the code in which a pointer
10469can have a deallocator called on it more than once, either @code{free},
10470or a deallocator referenced by attribute @code{malloc}.
10471
10472See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10473
d77de738
ML
10474@opindex Wanalyzer-exposure-through-output-file
10475@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10476@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10477This warning requires @option{-fanalyzer}, which enables it; use
10478@option{-Wno-analyzer-exposure-through-output-file}
10479to disable it.
10480
10481This diagnostic warns for paths through the code in which a
10482security-sensitive value is written to an output file
10483(such as writing a password to a log file).
10484
10485See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10486
d77de738
ML
10487@opindex Wanalyzer-exposure-through-uninit-copy
10488@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10489@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10490This warning requires both @option{-fanalyzer} and the use of a plugin
10491to specify a function that copies across a ``trust boundary''. Use
10492@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10493
10494This diagnostic warns for ``infoleaks'' - paths through the code in which
10495uninitialized values are copied across a security boundary
10496(such as code within an OS kernel that copies a partially-initialized
10497struct on the stack to user space).
10498
10499See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10500
d77de738
ML
10501@opindex Wanalyzer-fd-access-mode-mismatch
10502@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10503@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10504This warning requires @option{-fanalyzer}, which enables it; use
10505@option{-Wno-analyzer-fd-access-mode-mismatch}
10506to disable it.
10507
10508This diagnostic warns for paths through code in which a
10509@code{read} on a write-only file descriptor is attempted, or vice versa.
10510
10511This diagnostic also warns for code paths in a which a function with attribute
10512@code{fd_arg_read (N)} is called with a file descriptor opened with
10513@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10514@code{fd_arg_write (N)} is called with a file descriptor opened with
10515@code{O_RDONLY} at referenced argument @var{N}.
10516
d77de738
ML
10517@opindex Wanalyzer-fd-double-close
10518@opindex Wno-analyzer-fd-double-close
ddf6fe37 10519@item -Wno-analyzer-fd-double-close
d77de738
ML
10520This warning requires @option{-fanalyzer}, which enables it; use
10521@option{-Wno-analyzer-fd-double-close}
10522to disable it.
10523
10524This diagnostic warns for paths through code in which a
10525file descriptor can be closed more than once.
10526
10527See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10528
d77de738
ML
10529@opindex Wanalyzer-fd-leak
10530@opindex Wno-analyzer-fd-leak
ddf6fe37 10531@item -Wno-analyzer-fd-leak
d77de738
ML
10532This warning requires @option{-fanalyzer}, which enables it; use
10533@option{-Wno-analyzer-fd-leak}
10534to disable it.
10535
10536This diagnostic warns for paths through code in which an
10537open file descriptor is leaked.
10538
10539See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10540
86a90006
DM
10541@opindex Wanalyzer-fd-phase-mismatch
10542@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10543@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10544This warning requires @option{-fanalyzer}, which enables it; use
10545@option{-Wno-analyzer-fd-phase-mismatch}
10546to disable it.
10547
10548This diagnostic warns for paths through code in which an operation is
10549attempted in the wrong phase of a file descriptor's lifetime.
10550For example, it will warn on attempts to call @code{accept} on a stream
10551socket that has not yet had @code{listen} successfully called on it.
10552
10553See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10554
86a90006
DM
10555@opindex Wanalyzer-fd-type-mismatch
10556@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10557@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10558This warning requires @option{-fanalyzer}, which enables it; use
10559@option{-Wno-analyzer-fd-type-mismatch}
10560to disable it.
10561
10562This diagnostic warns for paths through code in which an
10563operation is attempted on the wrong type of file descriptor.
10564For example, it will warn on attempts to use socket operations
10565on a file descriptor obtained via @code{open}, or when attempting
10566to use a stream socket operation on a datagram socket.
10567
d77de738
ML
10568@opindex Wanalyzer-fd-use-after-close
10569@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10570@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10571This warning requires @option{-fanalyzer}, which enables it; use
10572@option{-Wno-analyzer-fd-use-after-close}
10573to disable it.
10574
10575This diagnostic warns for paths through code in which a
10576read or write is called on a closed file descriptor.
10577
10578This diagnostic also warns for paths through code in which
10579a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10580or @code{fd_arg_write (N)} is called with a closed file descriptor at
10581referenced argument @code{N}.
10582
d77de738
ML
10583@opindex Wanalyzer-fd-use-without-check
10584@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10585@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10586This warning requires @option{-fanalyzer}, which enables it; use
10587@option{-Wno-analyzer-fd-use-without-check}
10588to disable it.
10589
10590This diagnostic warns for paths through code in which a
10591file descriptor is used without being checked for validity.
10592
10593This diagnostic also warns for paths through code in which
10594a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10595or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10596argument @code{N}, without being checked for validity.
10597
d77de738
ML
10598@opindex Wanalyzer-file-leak
10599@opindex Wno-analyzer-file-leak
ddf6fe37 10600@item -Wno-analyzer-file-leak
d77de738
ML
10601This warning requires @option{-fanalyzer}, which enables it; use
10602@option{-Wno-analyzer-file-leak}
10603to disable it.
10604
10605This diagnostic warns for paths through the code in which a
10606@code{<stdio.h>} @code{FILE *} stream object is leaked.
10607
10608See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10609
d77de738
ML
10610@opindex Wanalyzer-free-of-non-heap
10611@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10612@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10613This warning requires @option{-fanalyzer}, which enables it; use
10614@option{-Wno-analyzer-free-of-non-heap}
10615to disable it.
10616
10617This diagnostic warns for paths through the code in which @code{free}
10618is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10619
10620See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10621
d77de738
ML
10622@opindex Wanalyzer-imprecise-fp-arithmetic
10623@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10624@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10625This warning requires @option{-fanalyzer}, which enables it; use
10626@option{-Wno-analyzer-imprecise-fp-arithmetic}
10627to disable it.
10628
10629This diagnostic warns for paths through the code in which floating-point
10630arithmetic is used in locations where precise computation is needed. This
10631diagnostic only warns on use of floating-point operands inside the
10632calculation of an allocation size at the moment.
10633
ce51e843
ML
10634@opindex Wanalyzer-infinite-recursion
10635@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10636@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10637This warning requires @option{-fanalyzer}, which enables it; use
10638@option{-Wno-analyzer-infinite-recursion} to disable it.
10639
10640This diagnostics warns for paths through the code which appear to
10641lead to infinite recursion.
10642
10643Specifically, when the analyzer "sees" a recursive call, it will compare
10644the state of memory at the entry to the new frame with that at the entry
10645to the previous frame of that function on the stack. The warning is
10646issued if nothing in memory appears to be changing; any changes observed
10647to parameters or globals are assumed to lead to termination of the
10648recursion and thus suppress the warning.
10649
10650This diagnostic is likely to miss cases of infinite recursion that
10651are convered to iteration by the optimizer before the analyzer "sees"
10652them. Hence optimization should be disabled when attempting to trigger
10653this diagnostic.
10654
10655Compare with @option{-Winfinite-recursion}, which provides a similar
10656diagnostic, but is implemented in a different way.
10657
d77de738
ML
10658@opindex Wanalyzer-jump-through-null
10659@opindex Wno-analyzer-jump-through-null
ddf6fe37 10660@item -Wno-analyzer-jump-through-null
d77de738
ML
10661This warning requires @option{-fanalyzer}, which enables it; use
10662@option{-Wno-analyzer-jump-through-null}
10663to disable it.
10664
10665This diagnostic warns for paths through the code in which a @code{NULL}
10666function pointer is called.
10667
d77de738
ML
10668@opindex Wanalyzer-malloc-leak
10669@opindex Wno-analyzer-malloc-leak
ddf6fe37 10670@item -Wno-analyzer-malloc-leak
d77de738
ML
10671This warning requires @option{-fanalyzer}, which enables it; use
10672@option{-Wno-analyzer-malloc-leak}
10673to disable it.
10674
10675This diagnostic warns for paths through the code in which a
10676pointer allocated via an allocator is leaked: either @code{malloc},
10677or a function marked with attribute @code{malloc}.
10678
10679See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10680
d77de738
ML
10681@opindex Wanalyzer-mismatching-deallocation
10682@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10683@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10684This warning requires @option{-fanalyzer}, which enables it; use
10685@option{-Wno-analyzer-mismatching-deallocation}
10686to disable it.
10687
10688This diagnostic warns for paths through the code in which the
10689wrong deallocation function is called on a pointer value, based on
10690which function was used to allocate the pointer value. The diagnostic
10691will warn about mismatches between @code{free}, scalar @code{delete}
10692and vector @code{delete[]}, and those marked as allocator/deallocator
10693pairs using attribute @code{malloc}.
10694
10695See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10696
d77de738
ML
10697@opindex Wanalyzer-out-of-bounds
10698@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10699@item -Wno-analyzer-out-of-bounds
4ace81b6 10700This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10701@option{-Wno-analyzer-out-of-bounds} to disable it.
10702
4ace81b6 10703This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10704definitely read or written out-of-bounds. The diagnostic applies for
10705cases where the analyzer is able to determine a constant offset and for
10706accesses past the end of a buffer, also a constant capacity. Further,
10707the diagnostic does limited checking for accesses past the end when the
10708offset as well as the capacity is symbolic.
10709
10710See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10711
0e466e97
DM
10712For cases where the analyzer is able, it will emit a text art diagram
10713visualizing the spatial relationship between the memory region that the
10714analyzer predicts would be accessed, versus the range of memory that is
10715valid to access: whether they overlap, are touching, are close or far
10716apart; which one is before or after in memory, the relative sizes
10717involved, the direction of the access (read vs write), and, in some
10718cases, the values of data involved. This diagram can be suppressed
10719using @option{-fdiagnostics-text-art-charset=none}.
10720
034d99e8
DM
10721@opindex Wanalyzer-overlapping-buffers
10722@opindex Wno-analyzer-overlapping-buffers
10723@item -Wno-analyzer-overlapping-buffers
10724This warning requires @option{-fanalyzer}, which enables it; use
10725@option{-Wno-analyzer-overlapping-buffers} to disable it.
10726
10727This diagnostic warns for paths through the code in which overlapping
10728buffers are passed to an API for which the behavior on such buffers
10729is undefined.
10730
10731Specifically, the diagnostic occurs on calls to the following functions
10732@itemize @bullet
10733@item @code{memcpy}
10734@item @code{strcat}
10735@item @code{strcpy}
10736@end itemize
10737for cases where the buffers are known to overlap.
10738
d77de738
ML
10739@opindex Wanalyzer-possible-null-argument
10740@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10741@item -Wno-analyzer-possible-null-argument
d77de738
ML
10742This warning requires @option{-fanalyzer}, which enables it; use
10743@option{-Wno-analyzer-possible-null-argument} to disable it.
10744
10745This diagnostic warns for paths through the code in which a
10746possibly-NULL value is passed to a function argument marked
10747with @code{__attribute__((nonnull))} as requiring a non-NULL
10748value.
10749
10750See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10751
d77de738
ML
10752@opindex Wanalyzer-possible-null-dereference
10753@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10754@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10755This warning requires @option{-fanalyzer}, which enables it; use
10756@option{-Wno-analyzer-possible-null-dereference} to disable it.
10757
10758This diagnostic warns for paths through the code in which a
10759possibly-NULL value is dereferenced.
10760
10761See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10762
d77de738
ML
10763@opindex Wanalyzer-null-argument
10764@opindex Wno-analyzer-null-argument
ddf6fe37 10765@item -Wno-analyzer-null-argument
d77de738
ML
10766This warning requires @option{-fanalyzer}, which enables it; use
10767@option{-Wno-analyzer-null-argument} to disable it.
10768
10769This diagnostic warns for paths through the code in which a
10770value known to be NULL is passed to a function argument marked
10771with @code{__attribute__((nonnull))} as requiring a non-NULL
10772value.
10773
10774See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10775
d77de738
ML
10776@opindex Wanalyzer-null-dereference
10777@opindex Wno-analyzer-null-dereference
ddf6fe37 10778@item -Wno-analyzer-null-dereference
d77de738
ML
10779This warning requires @option{-fanalyzer}, which enables it; use
10780@option{-Wno-analyzer-null-dereference} to disable it.
10781
10782This diagnostic warns for paths through the code in which a
10783value known to be NULL is dereferenced.
10784
10785See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10786
d77de738
ML
10787@opindex Wanalyzer-putenv-of-auto-var
10788@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10789@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10790This warning requires @option{-fanalyzer}, which enables it; use
10791@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10792
10793This diagnostic warns for paths through the code in which a
10794call to @code{putenv} is passed a pointer to an automatic variable
10795or an on-stack buffer.
10796
10797See @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}.
10798
d77de738
ML
10799@opindex Wanalyzer-shift-count-negative
10800@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10801@item -Wno-analyzer-shift-count-negative
d77de738
ML
10802This warning requires @option{-fanalyzer}, which enables it; use
10803@option{-Wno-analyzer-shift-count-negative} to disable it.
10804
10805This diagnostic warns for paths through the code in which a
10806shift is attempted with a negative count. It is analogous to
10807the @option{-Wshift-count-negative} diagnostic implemented in
10808the C/C++ front ends, but is implemented based on analyzing
10809interprocedural paths, rather than merely parsing the syntax tree.
10810However, the analyzer does not prioritize detection of such paths, so
10811false negatives are more likely relative to other warnings.
10812
d77de738
ML
10813@opindex Wanalyzer-shift-count-overflow
10814@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10815@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10816This warning requires @option{-fanalyzer}, which enables it; use
10817@option{-Wno-analyzer-shift-count-overflow} to disable it.
10818
10819This diagnostic warns for paths through the code in which a
10820shift is attempted with a count greater than or equal to the
10821precision of the operand's type. It is analogous to
10822the @option{-Wshift-count-overflow} diagnostic implemented in
10823the C/C++ front ends, but is implemented based on analyzing
10824interprocedural paths, rather than merely parsing the syntax tree.
10825However, the analyzer does not prioritize detection of such paths, so
10826false negatives are more likely relative to other warnings.
10827
d77de738
ML
10828@opindex Wanalyzer-stale-setjmp-buffer
10829@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10830@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10831This warning requires @option{-fanalyzer}, which enables it; use
10832@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10833
10834This diagnostic warns for paths through the code in which
10835@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10836to a @code{setjmp} call in a function that has returned.
10837
10838When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10839location, it records the stack frame. The stack frame becomes invalid
10840when the function containing the @code{setjmp} call returns. Attempting
10841to rewind to it via @code{longjmp} would reference a stack frame that
10842no longer exists, and likely lead to a crash (or worse).
10843
d77de738
ML
10844@opindex Wanalyzer-tainted-allocation-size
10845@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10846@item -Wno-analyzer-tainted-allocation-size
d77de738
ML
10847This warning requires both @option{-fanalyzer} and
10848@option{-fanalyzer-checker=taint} to enable it;
10849use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10850
10851This diagnostic warns for paths through the code in which a value
10852that could be under an attacker's control is used as the size
10853of an allocation without being sanitized, so that an attacker could
10854inject an excessively large allocation and potentially cause a denial
10855of service attack.
10856
10857See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10858
ce51e843
ML
10859@opindex Wanalyzer-tainted-assertion
10860@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10861@item -Wno-analyzer-tainted-assertion
ce51e843
ML
10862
10863This warning requires both @option{-fanalyzer} and
10864@option{-fanalyzer-checker=taint} to enable it;
10865use @option{-Wno-analyzer-tainted-assertion} to disable it.
10866
10867This diagnostic warns for paths through the code in which a value
10868that could be under an attacker's control is used as part of a
10869condition without being first sanitized, and that condition guards a
10870call to a function marked with attribute @code{noreturn}
10871(such as the function @code{__builtin_unreachable}). Such functions
10872typically indicate abnormal termination of the program, such as for
10873assertion failure handlers. For example:
10874
10875@smallexample
10876assert (some_tainted_value < SOME_LIMIT);
10877@end smallexample
10878
10879In such cases:
10880
10881@itemize
10882@item
10883when assertion-checking is enabled: an attacker could trigger
10884a denial of service by injecting an assertion failure
10885
10886@item
10887when assertion-checking is disabled, such as by defining @code{NDEBUG},
10888an attacker could inject data that subverts the process, since it
10889presumably violates a precondition that is being assumed by the code.
10890
10891@end itemize
10892
10893Note that when assertion-checking is disabled, the assertions are
10894typically removed by the preprocessor before the analyzer has a chance
10895to "see" them, so this diagnostic can only generate warnings on builds
10896in which assertion-checking is enabled.
10897
10898For the purpose of this warning, any function marked with attribute
10899@code{noreturn} is considered as a possible assertion failure
10900handler, including @code{__builtin_unreachable}. Note that these functions
10901are sometimes removed by the optimizer before the analyzer "sees" them.
10902Hence optimization should be disabled when attempting to trigger this
10903diagnostic.
10904
10905See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10906
10907The warning can also report problematic constructions such as
10908
10909@smallexample
10910switch (some_tainted_value) @{
10911case 0:
10912 /* [...etc; various valid cases omitted...] */
10913 break;
10914
10915default:
10916 __builtin_unreachable (); /* BUG: attacker can trigger this */
10917@}
10918@end smallexample
10919
10920despite the above not being an assertion failure, strictly speaking.
10921
d77de738
ML
10922@opindex Wanalyzer-tainted-array-index
10923@opindex Wno-analyzer-tainted-array-index
ddf6fe37 10924@item -Wno-analyzer-tainted-array-index
d77de738
ML
10925This warning requires both @option{-fanalyzer} and
10926@option{-fanalyzer-checker=taint} to enable it;
10927use @option{-Wno-analyzer-tainted-array-index} to disable it.
10928
10929This diagnostic warns for paths through the code in which a value
10930that could be under an attacker's control is used as the index
10931of an array access without being sanitized, so that an attacker
10932could inject an out-of-bounds access.
10933
10934See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10935
d77de738
ML
10936@opindex Wanalyzer-tainted-divisor
10937@opindex Wno-analyzer-tainted-divisor
ddf6fe37 10938@item -Wno-analyzer-tainted-divisor
d77de738
ML
10939This warning requires both @option{-fanalyzer} and
10940@option{-fanalyzer-checker=taint} to enable it;
10941use @option{-Wno-analyzer-tainted-divisor} to disable it.
10942
10943This diagnostic warns for paths through the code in which a value
10944that could be under an attacker's control is used as the divisor
10945in a division or modulus operation without being sanitized, so that
10946an attacker could inject a division-by-zero.
10947
10948See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10949
d77de738
ML
10950@opindex Wanalyzer-tainted-offset
10951@opindex Wno-analyzer-tainted-offset
ddf6fe37 10952@item -Wno-analyzer-tainted-offset
d77de738
ML
10953This warning requires both @option{-fanalyzer} and
10954@option{-fanalyzer-checker=taint} to enable it;
10955use @option{-Wno-analyzer-tainted-offset} to disable it.
10956
10957This diagnostic warns for paths through the code in which a value
10958that could be under an attacker's control is used as a pointer offset
10959without being sanitized, so that an attacker could inject an out-of-bounds
10960access.
10961
10962See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10963
d77de738
ML
10964@opindex Wanalyzer-tainted-size
10965@opindex Wno-analyzer-tainted-size
ddf6fe37 10966@item -Wno-analyzer-tainted-size
d77de738
ML
10967This warning requires both @option{-fanalyzer} and
10968@option{-fanalyzer-checker=taint} to enable it;
10969use @option{-Wno-analyzer-tainted-size} to disable it.
10970
10971This diagnostic warns for paths through the code in which a value
10972that could be under an attacker's control is used as the size of
10973an operation such as @code{memset} without being sanitized, so that an
10974attacker could inject an out-of-bounds access.
10975
10976See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10977
d77de738
ML
10978@opindex Wanalyzer-unsafe-call-within-signal-handler
10979@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 10980@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
10981This warning requires @option{-fanalyzer}, which enables it; use
10982@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10983
10984This diagnostic warns for paths through the code in which a
10985function known to be async-signal-unsafe (such as @code{fprintf}) is
10986called from a signal handler.
10987
10988See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10989
d77de738
ML
10990@opindex Wanalyzer-use-after-free
10991@opindex Wno-analyzer-use-after-free
ddf6fe37 10992@item -Wno-analyzer-use-after-free
d77de738
ML
10993This warning requires @option{-fanalyzer}, which enables it; use
10994@option{-Wno-analyzer-use-after-free} to disable it.
10995
10996This diagnostic warns for paths through the code in which a
10997pointer is used after a deallocator is called on it: either @code{free},
10998or a deallocator referenced by attribute @code{malloc}.
10999
11000See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11001
d77de738
ML
11002@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11003@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 11004@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
11005This warning requires @option{-fanalyzer}, which enables it; use
11006@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11007to disable it.
11008
11009This diagnostic warns for paths through the code in which a pointer
11010is dereferenced that points to a variable in a stale stack frame.
11011
d77de738
ML
11012@opindex Wanalyzer-va-arg-type-mismatch
11013@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 11014@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
11015This warning requires @option{-fanalyzer}, which enables it; use
11016@option{-Wno-analyzer-va-arg-type-mismatch}
11017to disable it.
11018
11019This diagnostic warns for interprocedural paths through the code for which
11020the analyzer detects an attempt to use @code{va_arg} to extract a value
11021passed to a variadic call, but uses a type that does not match that of
11022the expression passed to the call.
11023
11024See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11025
d77de738
ML
11026@opindex Wanalyzer-va-list-exhausted
11027@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 11028@item -Wno-analyzer-va-list-exhausted
d77de738
ML
11029This warning requires @option{-fanalyzer}, which enables it; use
11030@option{-Wno-analyzer-va-list-exhausted}
11031to disable it.
11032
11033This diagnostic warns for interprocedural paths through the code for which
11034the analyzer detects an attempt to use @code{va_arg} to access the next
11035value passed to a variadic call, but all of the values in the
11036@code{va_list} have already been consumed.
11037
11038See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11039
d77de738
ML
11040@opindex Wanalyzer-va-list-leak
11041@opindex Wno-analyzer-va-list-leak
ddf6fe37 11042@item -Wno-analyzer-va-list-leak
d77de738
ML
11043This warning requires @option{-fanalyzer}, which enables it; use
11044@option{-Wno-analyzer-va-list-leak}
11045to disable it.
11046
11047This diagnostic warns for interprocedural paths through the code for which
11048the analyzer detects that @code{va_start} or @code{va_copy} has been called
11049on a @code{va_list} without a corresponding call to @code{va_end}.
11050
d77de738
ML
11051@opindex Wanalyzer-va-list-use-after-va-end
11052@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 11053@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
11054This warning requires @option{-fanalyzer}, which enables it; use
11055@option{-Wno-analyzer-va-list-use-after-va-end}
11056to disable it.
11057
11058This diagnostic warns for interprocedural paths through the code for which
11059the analyzer detects an attempt to use a @code{va_list} after
11060@code{va_end} has been called on it.
11061@code{va_list}.
11062
d77de738
ML
11063@opindex Wanalyzer-write-to-const
11064@opindex Wno-analyzer-write-to-const
ddf6fe37 11065@item -Wno-analyzer-write-to-const
d77de738
ML
11066This warning requires @option{-fanalyzer}, which enables it; use
11067@option{-Wno-analyzer-write-to-const}
11068to disable it.
11069
11070This diagnostic warns for paths through the code in which the analyzer
11071detects an attempt to write through a pointer to a @code{const} object.
11072However, the analyzer does not prioritize detection of such paths, so
11073false negatives are more likely relative to other warnings.
11074
d77de738
ML
11075@opindex Wanalyzer-write-to-string-literal
11076@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 11077@item -Wno-analyzer-write-to-string-literal
d77de738
ML
11078This warning requires @option{-fanalyzer}, which enables it; use
11079@option{-Wno-analyzer-write-to-string-literal}
11080to disable it.
11081
11082This diagnostic warns for paths through the code in which the analyzer
11083detects an attempt to write through a pointer to a string literal.
11084However, the analyzer does not prioritize detection of such paths, so
11085false negatives are more likely relative to other warnings.
11086
d77de738
ML
11087@opindex Wanalyzer-use-of-uninitialized-value
11088@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 11089@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
11090This warning requires @option{-fanalyzer}, which enables it; use
11091@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11092
11093This diagnostic warns for paths through the code in which an uninitialized
11094value is used.
11095
11096See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11097
11098@end table
11099
11100The analyzer has hardcoded knowledge about the behavior of the following
11101memory-management functions:
11102
11103@itemize @bullet
11104@item @code{alloca}
11105@item The built-in functions @code{__builtin_alloc},
11106@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11107@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11108@code{__builtin_memcpy_chk}, @code{__builtin_memset},
11109@code{__builtin_memset_chk}, @code{__builtin_realloc},
11110@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11111@item @code{calloc}
11112@item @code{free}
11113@item @code{malloc}
11114@item @code{memset}
11115@item @code{operator delete}
11116@item @code{operator delete []}
11117@item @code{operator new}
11118@item @code{operator new []}
11119@item @code{realloc}
11120@item @code{strdup}
11121@item @code{strndup}
11122@end itemize
11123
4ace81b6 11124@noindent
d77de738
ML
11125of the following functions for working with file descriptors:
11126
11127@itemize @bullet
11128@item @code{open}
11129@item @code{close}
11130@item @code{creat}
11131@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 11132@item @code{isatty}
d77de738
ML
11133@item @code{pipe}, and @code{pipe2}
11134@item @code{read}
11135@item @code{write}
86a90006 11136@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
11137@end itemize
11138
4ace81b6 11139@noindent
d77de738
ML
11140of the following functions for working with @code{<stdio.h>} streams:
11141@itemize @bullet
11142@item The built-in functions @code{__builtin_fprintf},
11143@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11144@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11145@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11146@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11147@code{__builtin_printf_unlocked}, @code{__builtin_putc},
11148@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11149@code{__builtin_putc_unlocked}, @code{__builtin_puts},
11150@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
11151@code{__builtin_vprintf}
11152@item @code{fopen}
11153@item @code{fclose}
78a17f44 11154@item @code{ferror}
d77de738
ML
11155@item @code{fgets}
11156@item @code{fgets_unlocked}
78a17f44 11157@item @code{fileno}
d77de738 11158@item @code{fread}
78a17f44 11159@item @code{getc}
d77de738
ML
11160@item @code{getchar}
11161@item @code{fprintf}
11162@item @code{printf}
11163@item @code{fwrite}
11164@end itemize
11165
4ace81b6 11166@noindent
d77de738
ML
11167and of the following functions:
11168
11169@itemize @bullet
11170@item The built-in functions @code{__builtin_expect},
11171@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11172@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11173@code{__builtin_strlen}, @code{__builtin_va_copy}, and
11174@code{__builtin_va_start}
11175@item The GNU extensions @code{error} and @code{error_at_line}
11176@item @code{getpass}
11177@item @code{longjmp}
11178@item @code{putenv}
11179@item @code{setjmp}
11180@item @code{siglongjmp}
11181@item @code{signal}
11182@item @code{sigsetjmp}
bbdc0e0d 11183@item @code{strcat}
d77de738
ML
11184@item @code{strchr}
11185@item @code{strlen}
11186@end itemize
11187
11188In addition, various functions with an @code{__analyzer_} prefix have
11189special meaning to the analyzer, described in the GCC Internals manual.
11190
11191Pertinent parameters for controlling the exploration are:
4ace81b6
SL
11192@itemize @bullet
11193@item @option{--param analyzer-bb-explosion-factor=@var{value}}
11194@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11195@item @option{--param analyzer-max-recursion-depth=@var{value}}
11196@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11197@end itemize
d77de738
ML
11198
11199The following options control the analyzer.
11200
11201@table @gcctabopt
11202
d77de738
ML
11203@opindex fanalyzer-call-summaries
11204@opindex fno-analyzer-call-summaries
ddf6fe37 11205@item -fanalyzer-call-summaries
d77de738
ML
11206Simplify interprocedural analysis by computing the effect of certain calls,
11207rather than exploring all paths through the function from callsite to each
11208possible return.
11209
11210If enabled, call summaries are only used for functions with more than one
11211call site, and that are sufficiently complicated (as per
11212@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11213
d77de738 11214@opindex fanalyzer-checker
ddf6fe37 11215@item -fanalyzer-checker=@var{name}
d77de738
ML
11216Restrict the analyzer to run just the named checker, and enable it.
11217
11218Some checkers are disabled by default (even with @option{-fanalyzer}),
11219such as the @code{taint} checker that implements
11220@option{-Wanalyzer-tainted-array-index}, and this option is required
11221to enable them.
11222
11223@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
11224following warnings from @option{-fanalyzer}:
11225
43b72ede
AA
11226@gccoptlist{
11227-Wanalyzer-deref-before-check
11228-Wanalyzer-double-fclose
11229-Wanalyzer-double-free
11230-Wanalyzer-exposure-through-output-file
11231-Wanalyzer-fd-access-mode-mismatch
11232-Wanalyzer-fd-double-close
11233-Wanalyzer-fd-leak
11234-Wanalyzer-fd-use-after-close
11235-Wanalyzer-fd-use-without-check
11236-Wanalyzer-file-leak
11237-Wanalyzer-free-of-non-heap
11238-Wanalyzer-malloc-leak
11239-Wanalyzer-mismatching-deallocation
11240-Wanalyzer-null-argument
11241-Wanalyzer-null-dereference
11242-Wanalyzer-possible-null-argument
11243-Wanalyzer-possible-null-dereference
11244-Wanalyzer-unsafe-call-within-signal-handler
11245-Wanalyzer-use-after-free
11246-Wanalyzer-va-list-leak
11247-Wanalyzer-va-list-use-after-va-end
d77de738
ML
11248}
11249
0e466e97
DM
11250@opindex fanalyzer-debug-text-art
11251@opindex fno-analyzer-debug-text-art
11252@item -fanalyzer-debug-text-art-headings
11253This option is intended for analyzer developers. If enabled,
11254the analyzer will add extra annotations to any diagrams it generates.
11255
d77de738
ML
11256@opindex fanalyzer-feasibility
11257@opindex fno-analyzer-feasibility
ddf6fe37 11258@item -fno-analyzer-feasibility
d77de738
ML
11259This option is intended for analyzer developers.
11260
11261By default the analyzer verifies that there is a feasible control flow path
11262for each diagnostic it emits: that the conditions that hold are not mutually
11263exclusive. Diagnostics for which no feasible path can be found are rejected.
11264This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11265debugging issues in this code.
11266
d77de738
ML
11267@opindex fanalyzer-fine-grained
11268@opindex fno-analyzer-fine-grained
ddf6fe37 11269@item -fanalyzer-fine-grained
d77de738
ML
11270This option is intended for analyzer developers.
11271
11272Internally the analyzer builds an ``exploded graph'' that combines
11273control flow graphs with data flow information.
11274
11275By default, an edge in this graph can contain the effects of a run
11276of multiple statements within a basic block. With
11277@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11278
d77de738
ML
11279@opindex fanalyzer-show-duplicate-count
11280@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11281@item -fanalyzer-show-duplicate-count
d77de738
ML
11282This option is intended for analyzer developers: if multiple diagnostics
11283have been detected as being duplicates of each other, it emits a note when
11284reporting the best diagnostic, giving the number of additional diagnostics
11285that were suppressed by the deduplication logic.
11286
ce8cdf5b 11287@opindex fanalyzer-show-events-in-system-headers
11288@opindex fno-analyzer-show-events-in-system-headers
11289@item -fanalyzer-show-events-in-system-headers
11290By default the analyzer emits simplified diagnostics paths by hiding
11291events fully located within a system header.
11292With @option{-fanalyzer-show-events-in-system-headers} such
11293events are no longer suppressed.
11294
d77de738
ML
11295@opindex fanalyzer-state-merge
11296@opindex fno-analyzer-state-merge
ddf6fe37 11297@item -fno-analyzer-state-merge
d77de738
ML
11298This option is intended for analyzer developers.
11299
11300By default the analyzer attempts to simplify analysis by merging
11301sufficiently similar states at each program point as it builds its
11302``exploded graph''. With @option{-fno-analyzer-state-merge} this
11303merging can be suppressed, for debugging state-handling issues.
11304
d77de738
ML
11305@opindex fanalyzer-state-purge
11306@opindex fno-analyzer-state-purge
ddf6fe37 11307@item -fno-analyzer-state-purge
d77de738
ML
11308This option is intended for analyzer developers.
11309
11310By default the analyzer attempts to simplify analysis by purging
11311aspects of state at a program point that appear to no longer be relevant
11312e.g. the values of locals that aren't accessed later in the function
11313and which aren't relevant to leak analysis.
11314
11315With @option{-fno-analyzer-state-purge} this purging of state can
11316be suppressed, for debugging state-handling issues.
11317
8f636915
DM
11318@opindex fanalyzer-suppress-followups
11319@opindex fno-analyzer-suppress-followups
f33d7a88 11320@item -fno-analyzer-suppress-followups
8f636915
DM
11321This option is intended for analyzer developers.
11322
11323By default the analyzer will stop exploring an execution path after
11324encountering certain diagnostics, in order to avoid potentially issuing a
11325cascade of follow-up diagnostics.
11326
11327The diagnostics that terminate analysis along a path are:
11328
11329@itemize
11330@item @option{-Wanalyzer-null-argument}
11331@item @option{-Wanalyzer-null-dereference}
11332@item @option{-Wanalyzer-use-after-free}
11333@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11334@item @option{-Wanalyzer-use-of-uninitialized-value}
11335@end itemize
11336
11337With @option{-fno-analyzer-suppress-followups} the analyzer will
11338continue to explore such paths even after such diagnostics, which may
11339be helpful for debugging issues in the analyzer, or for microbenchmarks
11340for detecting undefined behavior.
11341
d77de738
ML
11342@opindex fanalyzer-transitivity
11343@opindex fno-analyzer-transitivity
ddf6fe37 11344@item -fanalyzer-transitivity
d77de738
ML
11345This option enables transitivity of constraints within the analyzer.
11346
d77de738
ML
11347@opindex fanalyzer-undo-inlining
11348@opindex fno-analyzer-undo-inlining
ddf6fe37 11349@item -fno-analyzer-undo-inlining
d77de738
ML
11350This option is intended for analyzer developers.
11351
11352@option{-fanalyzer} runs relatively late compared to other code analysis
11353tools, and some optimizations have already been applied to the code. In
11354particular function inlining may have occurred, leading to the
11355interprocedural execution paths emitted by the analyzer containing
11356function frames that don't correspond to those in the original source
11357code.
11358
11359By default the analyzer attempts to reconstruct the original function
11360frames, and to emit events showing the inlined calls.
11361
11362With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11363the original frame information can be be disabled, which may be of help
11364when debugging issues in the analyzer.
11365
11366@item -fanalyzer-verbose-edges
11367This option is intended for analyzer developers. It enables more
11368verbose, lower-level detail in the descriptions of control flow
11369within diagnostic paths.
11370
11371@item -fanalyzer-verbose-state-changes
11372This option is intended for analyzer developers. It enables more
11373verbose, lower-level detail in the descriptions of events relating
11374to state machines within diagnostic paths.
11375
11376@item -fanalyzer-verbosity=@var{level}
11377This option controls the complexity of the control flow paths that are
11378emitted for analyzer diagnostics.
11379
11380The @var{level} can be one of:
11381
11382@table @samp
11383@item 0
11384At this level, interprocedural call and return events are displayed,
11385along with the most pertinent state-change events relating to
11386a diagnostic. For example, for a double-@code{free} diagnostic,
11387both calls to @code{free} will be shown.
11388
11389@item 1
11390As per the previous level, but also show events for the entry
11391to each function.
11392
11393@item 2
11394As per the previous level, but also show events relating to
11395control flow that are significant to triggering the issue
11396(e.g. ``true path taken'' at a conditional).
11397
11398This level is the default.
11399
11400@item 3
11401As per the previous level, but show all control flow events, not
11402just significant ones.
11403
11404@item 4
11405This level is intended for analyzer developers; it adds various
11406other events intended for debugging the analyzer.
11407
11408@end table
11409
d77de738 11410@opindex fdump-analyzer
ddf6fe37 11411@item -fdump-analyzer
d77de738
ML
11412Dump internal details about what the analyzer is doing to
11413@file{@var{file}.analyzer.txt}.
4ace81b6 11414@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11415
d77de738 11416@opindex fdump-analyzer-stderr
ddf6fe37 11417@item -fdump-analyzer-stderr
d77de738
ML
11418Dump internal details about what the analyzer is doing to stderr.
11419This option overrides @option{-fdump-analyzer}.
11420
d77de738 11421@opindex fdump-analyzer-callgraph
ddf6fe37 11422@item -fdump-analyzer-callgraph
d77de738
ML
11423Dump a representation of the call graph suitable for viewing with
11424GraphViz to @file{@var{file}.callgraph.dot}.
11425
d77de738 11426@opindex fdump-analyzer-exploded-graph
ddf6fe37 11427@item -fdump-analyzer-exploded-graph
d77de738
ML
11428Dump a representation of the ``exploded graph'' suitable for viewing with
11429GraphViz to @file{@var{file}.eg.dot}.
11430Nodes are color-coded based on state-machine states to emphasize
11431state changes.
11432
d77de738 11433@opindex dump-analyzer-exploded-nodes
ddf6fe37 11434@item -fdump-analyzer-exploded-nodes
d77de738
ML
11435Emit diagnostics showing where nodes in the ``exploded graph'' are
11436in relation to the program source.
11437
d77de738 11438@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11439@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11440Dump a textual representation of the ``exploded graph'' to
11441@file{@var{file}.eg.txt}.
11442
d77de738 11443@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11444@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11445Dump a textual representation of the ``exploded graph'' to
11446one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11447This is typically a large number of dump files.
11448
d77de738 11449@opindex fdump-analyzer-exploded-paths
ddf6fe37 11450@item -fdump-analyzer-exploded-paths
d77de738
ML
11451Dump a textual representation of the ``exploded path'' for each
11452diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11453
d77de738 11454@opindex dump-analyzer-feasibility
ddf6fe37 11455@item -fdump-analyzer-feasibility
d77de738
ML
11456Dump internal details about the analyzer's search for feasible paths.
11457The details are written in a form suitable for viewing with GraphViz
11458to filenames of the form @file{@var{file}.*.fg.dot},
11459@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11460
d77de738 11461@opindex fdump-analyzer-json
ddf6fe37 11462@item -fdump-analyzer-json
d77de738
ML
11463Dump a compressed JSON representation of analyzer internals to
11464@file{@var{file}.analyzer.json.gz}. The precise format is subject
11465to change.
11466
d77de738 11467@opindex fdump-analyzer-state-purge
ddf6fe37 11468@item -fdump-analyzer-state-purge
d77de738
ML
11469As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11470``supergraph'' suitable for viewing with GraphViz, but annotate the
11471graph with information on what state will be purged at each node.
11472The graph is written to @file{@var{file}.state-purge.dot}.
11473
d77de738 11474@opindex fdump-analyzer-supergraph
ddf6fe37 11475@item -fdump-analyzer-supergraph
d77de738
ML
11476Dump representations of the ``supergraph'' suitable for viewing with
11477GraphViz to @file{@var{file}.supergraph.dot} and to
11478@file{@var{file}.supergraph-eg.dot}. These show all of the
11479control flow graphs in the program, with interprocedural edges for
11480calls and returns. The second dump contains annotations showing nodes
11481in the ``exploded graph'' and diagnostics associated with them.
11482
d77de738 11483@opindex fdump-analyzer-untracked
ddf6fe37 11484@item -fdump-analyzer-untracked
d77de738
ML
11485Emit custom warnings with internal details intended for analyzer developers.
11486
11487@end table
11488
11489@node Debugging Options
11490@section Options for Debugging Your Program
11491@cindex options, debugging
11492@cindex debugging information options
11493
11494To tell GCC to emit extra information for use by a debugger, in almost
11495all cases you need only to add @option{-g} to your other options. Some debug
11496formats can co-exist (like DWARF with CTF) when each of them is enabled
11497explicitly by adding the respective command line option to your other options.
11498
11499GCC allows you to use @option{-g} with
11500@option{-O}. The shortcuts taken by optimized code may occasionally
11501be surprising: some variables you declared may not exist
11502at all; flow of control may briefly move where you did not expect it;
11503some statements may not be executed because they compute constant
11504results or their values are already at hand; some statements may
11505execute in different places because they have been moved out of loops.
11506Nevertheless it is possible to debug optimized output. This makes
11507it reasonable to use the optimizer for programs that might have bugs.
11508
11509If you are not using some other optimization option, consider
11510using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11511With no @option{-O} option at all, some compiler passes that collect
11512information useful for debugging do not run at all, so that
11513@option{-Og} may result in a better debugging experience.
11514
11515@table @gcctabopt
d77de738 11516@opindex g
ddf6fe37 11517@item -g
d77de738
ML
11518Produce debugging information in the operating system's native format
11519(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11520information.
11521
11522On most systems that use stabs format, @option{-g} enables use of extra
11523debugging information that only GDB can use; this extra information
11524makes debugging work better in GDB but probably makes other debuggers
11525crash or refuse to read the program. If you want to control for certain whether
11526to generate the extra information, use @option{-gvms} (see below).
11527
d77de738 11528@opindex ggdb
ddf6fe37 11529@item -ggdb
d77de738
ML
11530Produce debugging information for use by GDB@. This means to use the
11531most expressive format available (DWARF, stabs, or the native format
11532if neither of those are supported), including GDB extensions if at all
11533possible.
11534
ddf6fe37 11535@opindex gdwarf
d77de738
ML
11536@item -gdwarf
11537@itemx -gdwarf-@var{version}
d77de738
ML
11538Produce debugging information in DWARF format (if that is supported).
11539The value of @var{version} may be either 2, 3, 4 or 5; the default
11540version for most targets is 5 (with the exception of VxWorks, TPF and
a335cf24 11541Darwin / macOS, which default to version 2, and AIX, which defaults
d77de738
ML
11542to version 4).
11543
11544Note that with DWARF Version 2, some ports require and always
11545use some non-conflicting DWARF 3 extensions in the unwind tables.
11546
11547Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11548for maximum benefit. Version 5 requires GDB 8.0 or higher.
11549
11550GCC no longer supports DWARF Version 1, which is substantially
11551different than Version 2 and later. For historical reasons, some
11552other DWARF-related options such as
11553@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11554in their names, but apply to all currently-supported versions of DWARF.
11555
d77de738 11556@opindex gbtf
ddf6fe37 11557@item -gbtf
d77de738
ML
11558Request BTF debug information. BTF is the default debugging format for the
11559eBPF target. On other targets, like x86, BTF debug information can be
11560generated along with DWARF debug information when both of the debug formats are
11561enabled explicitly via their respective command line options.
11562
ddf6fe37 11563@opindex gctf
d77de738
ML
11564@item -gctf
11565@itemx -gctf@var{level}
d77de738
ML
11566Request CTF debug information and use level to specify how much CTF debug
11567information should be produced. If @option{-gctf} is specified
11568without a value for level, the default level of CTF debug information is 2.
11569
11570CTF debug information can be generated along with DWARF debug information when
11571both of the debug formats are enabled explicitly via their respective command
11572line options.
11573
11574Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11575negates @option{-gctf}.
11576
11577Level 1 produces CTF information for tracebacks only. This includes callsite
11578information, but does not include type information.
11579
11580Level 2 produces type information for entities (functions, data objects etc.)
11581at file-scope or global-scope only.
11582
d77de738 11583@opindex gvms
ddf6fe37 11584@item -gvms
d77de738
ML
11585Produce debugging information in Alpha/VMS debug format (if that is
11586supported). This is the format used by DEBUG on Alpha/VMS systems.
11587
2f7e7bfa
MH
11588@item -gcodeview
11589@opindex gcodeview
11590Produce debugging information in CodeView debug format (if that is
11591supported). This is the format used by Microsoft Visual C++ on
11592Windows.
11593
d77de738
ML
11594@item -g@var{level}
11595@itemx -ggdb@var{level}
11596@itemx -gvms@var{level}
11597Request debugging information and also use @var{level} to specify how
11598much information. The default level is 2.
11599
11600Level 0 produces no debug information at all. Thus, @option{-g0} negates
11601@option{-g}.
11602
11603Level 1 produces minimal information, enough for making backtraces in
11604parts of the program that you don't plan to debug. This includes
11605descriptions of functions and external variables, and line number
11606tables, but no information about local variables.
11607
11608Level 3 includes extra information, such as all the macro definitions
11609present in the program. Some debuggers support macro expansion when
11610you use @option{-g3}.
11611
11612If you use multiple @option{-g} options, with or without level numbers,
11613the last such option is the one that is effective.
11614
11615@option{-gdwarf} does not accept a concatenated debug level, to avoid
11616confusion with @option{-gdwarf-@var{level}}.
11617Instead use an additional @option{-g@var{level}} option to change the
11618debug level for DWARF.
11619
d77de738
ML
11620@opindex feliminate-unused-debug-symbols
11621@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11622@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11623By default, no debug information is produced for symbols that are not actually
11624used. Use this option if you want debug information for all symbols.
11625
d77de738 11626@opindex femit-class-debug-always
ddf6fe37 11627@item -femit-class-debug-always
d77de738
ML
11628Instead of emitting debugging information for a C++ class in only one
11629object file, emit it in all object files using the class. This option
11630should be used only with debuggers that are unable to handle the way GCC
11631normally emits debugging information for classes because using this
11632option increases the size of debugging information by as much as a
11633factor of two.
11634
d77de738
ML
11635@opindex fmerge-debug-strings
11636@opindex fno-merge-debug-strings
ddf6fe37 11637@item -fno-merge-debug-strings
d77de738
ML
11638Direct the linker to not merge together strings in the debugging
11639information that are identical in different object files. Merging is
11640not supported by all assemblers or linkers. Merging decreases the size
11641of the debug information in the output file at the cost of increasing
11642link processing time. Merging is enabled by default.
11643
d77de738 11644@opindex fdebug-prefix-map
ddf6fe37 11645@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11646When compiling files residing in directory @file{@var{old}}, record
11647debugging information describing them as if the files resided in
11648directory @file{@var{new}} instead. This can be used to replace a
11649build-time path with an install-time path in the debug info. It can
11650also be used to change an absolute path to a relative path by using
11651@file{.} for @var{new}. This can give more reproducible builds, which
11652are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11653where to find the source files. See also @option{-ffile-prefix-map}
11654and @option{-fcanon-prefix-map}.
d77de738 11655
d77de738 11656@opindex fvar-tracking
ddf6fe37 11657@item -fvar-tracking
d77de738
ML
11658Run variable tracking pass. It computes where variables are stored at each
11659position in code. Better debugging information is then generated
11660(if the debugging information format supports this information).
11661
11662It is enabled by default when compiling with optimization (@option{-Os},
11663@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11664the debug info format supports it.
11665
d77de738
ML
11666@opindex fvar-tracking-assignments
11667@opindex fno-var-tracking-assignments
ddf6fe37 11668@item -fvar-tracking-assignments
d77de738
ML
11669Annotate assignments to user variables early in the compilation and
11670attempt to carry the annotations over throughout the compilation all the
11671way to the end, in an attempt to improve debug information while
11672optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11673
11674It can be enabled even if var-tracking is disabled, in which case
11675annotations are created and maintained, but discarded at the end.
11676By default, this flag is enabled together with @option{-fvar-tracking},
11677except when selective scheduling is enabled.
11678
d77de738 11679@opindex gsplit-dwarf
ddf6fe37 11680@item -gsplit-dwarf
d77de738
ML
11681If DWARF debugging information is enabled, separate as much debugging
11682information as possible into a separate output file with the extension
11683@file{.dwo}. This option allows the build system to avoid linking files with
11684debug information. To be useful, this option requires a debugger capable of
11685reading @file{.dwo} files.
11686
d77de738
ML
11687@opindex gdwarf32
11688@opindex gdwarf64
ddf6fe37
AA
11689@item -gdwarf32
11690@itemx -gdwarf64
d77de738
ML
11691If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11692the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11693DWARF format. The default is target specific, on most targets it is
11694@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11695can't support more than 2GiB of debug information in any of the DWARF
11696debug information sections. The 64-bit DWARF format allows larger debug
11697information and might not be well supported by all consumers yet.
11698
d77de738 11699@opindex gdescribe-dies
ddf6fe37 11700@item -gdescribe-dies
d77de738
ML
11701Add description attributes to some DWARF DIEs that have no name attribute,
11702such as artificial variables, external references and call site
11703parameter DIEs.
11704
d77de738 11705@opindex gpubnames
ddf6fe37 11706@item -gpubnames
d77de738
ML
11707Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11708
d77de738 11709@opindex ggnu-pubnames
ddf6fe37 11710@item -ggnu-pubnames
d77de738
ML
11711Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11712suitable for conversion into a GDB@ index. This option is only useful
11713with a linker that can produce GDB@ index version 7.
11714
d77de738
ML
11715@opindex fdebug-types-section
11716@opindex fno-debug-types-section
ddf6fe37 11717@item -fdebug-types-section
d77de738
ML
11718When using DWARF Version 4 or higher, type DIEs can be put into
11719their own @code{.debug_types} section instead of making them part of the
11720@code{.debug_info} section. It is more efficient to put them in a separate
11721comdat section since the linker can then remove duplicates.
11722But not all DWARF consumers support @code{.debug_types} sections yet
11723and on some objects @code{.debug_types} produces larger instead of smaller
11724debugging information.
11725
d77de738
ML
11726@opindex grecord-gcc-switches
11727@opindex gno-record-gcc-switches
ddf6fe37
AA
11728@item -grecord-gcc-switches
11729@itemx -gno-record-gcc-switches
d77de738
ML
11730This switch causes the command-line options used to invoke the
11731compiler that may affect code generation to be appended to the
11732DW_AT_producer attribute in DWARF debugging information. The options
11733are concatenated with spaces separating them from each other and from
11734the compiler version.
11735It is enabled by default.
11736See also @option{-frecord-gcc-switches} for another
11737way of storing compiler options into the object file.
11738
d77de738 11739@opindex gstrict-dwarf
ddf6fe37 11740@item -gstrict-dwarf
d77de738
ML
11741Disallow using extensions of later DWARF standard version than selected
11742with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11743DWARF extensions from later standard versions is allowed.
11744
d77de738 11745@opindex gno-strict-dwarf
ddf6fe37 11746@item -gno-strict-dwarf
d77de738
ML
11747Allow using extensions of later DWARF standard version than selected with
11748@option{-gdwarf-@var{version}}.
11749
d77de738 11750@opindex gas-loc-support
ddf6fe37 11751@item -gas-loc-support
d77de738
ML
11752Inform the compiler that the assembler supports @code{.loc} directives.
11753It may then use them for the assembler to generate DWARF2+ line number
11754tables.
11755
11756This is generally desirable, because assembler-generated line-number
11757tables are a lot more compact than those the compiler can generate
11758itself.
11759
11760This option will be enabled by default if, at GCC configure time, the
11761assembler was found to support such directives.
11762
d77de738 11763@opindex gno-as-loc-support
ddf6fe37 11764@item -gno-as-loc-support
d77de738
ML
11765Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11766line number tables are to be generated.
11767
d77de738 11768@opindex gas-locview-support
ddf6fe37 11769@item -gas-locview-support
d77de738
ML
11770Inform the compiler that the assembler supports @code{view} assignment
11771and reset assertion checking in @code{.loc} directives.
11772
11773This option will be enabled by default if, at GCC configure time, the
11774assembler was found to support them.
11775
11776@item -gno-as-locview-support
11777Force GCC to assign view numbers internally, if
11778@option{-gvariable-location-views} are explicitly requested.
11779
d77de738
ML
11780@opindex gcolumn-info
11781@opindex gno-column-info
ddf6fe37
AA
11782@item -gcolumn-info
11783@itemx -gno-column-info
d77de738
ML
11784Emit location column information into DWARF debugging information, rather
11785than just file and line.
11786This option is enabled by default.
11787
d77de738
ML
11788@opindex gstatement-frontiers
11789@opindex gno-statement-frontiers
ddf6fe37
AA
11790@item -gstatement-frontiers
11791@itemx -gno-statement-frontiers
d77de738
ML
11792This option causes GCC to create markers in the internal representation
11793at the beginning of statements, and to keep them roughly in place
11794throughout compilation, using them to guide the output of @code{is_stmt}
11795markers in the line number table. This is enabled by default when
11796compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11797@dots{}), and outputting DWARF 2 debug information at the normal level.
11798
d77de738
ML
11799@opindex gvariable-location-views
11800@opindex gvariable-location-views=incompat5
11801@opindex gno-variable-location-views
ddf6fe37
AA
11802@item -gvariable-location-views
11803@itemx -gvariable-location-views=incompat5
11804@itemx -gno-variable-location-views
d77de738
ML
11805Augment variable location lists with progressive view numbers implied
11806from the line number table. This enables debug information consumers to
11807inspect state at certain points of the program, even if no instructions
11808associated with the corresponding source locations are present at that
11809point. If the assembler lacks support for view numbers in line number
11810tables, this will cause the compiler to emit the line number table,
11811which generally makes them somewhat less compact. The augmented line
11812number tables and location lists are fully backward-compatible, so they
11813can be consumed by debug information consumers that are not aware of
11814these augmentations, but they won't derive any benefit from them either.
11815
11816This is enabled by default when outputting DWARF 2 debug information at
11817the normal level, as long as there is assembler support,
11818@option{-fvar-tracking-assignments} is enabled and
11819@option{-gstrict-dwarf} is not. When assembler support is not
11820available, this may still be enabled, but it will force GCC to output
11821internal line number tables, and if
11822@option{-ginternal-reset-location-views} is not enabled, that will most
11823certainly lead to silently mismatching location views.
11824
11825There is a proposed representation for view numbers that is not backward
11826compatible with the location list format introduced in DWARF 5, that can
11827be enabled with @option{-gvariable-location-views=incompat5}. This
11828option may be removed in the future, is only provided as a reference
11829implementation of the proposed representation. Debug information
11830consumers are not expected to support this extended format, and they
11831would be rendered unable to decode location lists using it.
11832
d77de738
ML
11833@opindex ginternal-reset-location-views
11834@opindex gno-internal-reset-location-views
ddf6fe37
AA
11835@item -ginternal-reset-location-views
11836@itemx -gno-internal-reset-location-views
d77de738
ML
11837Attempt to determine location views that can be omitted from location
11838view lists. This requires the compiler to have very accurate insn
11839length estimates, which isn't always the case, and it may cause
11840incorrect view lists to be generated silently when using an assembler
11841that does not support location view lists. The GNU assembler will flag
11842any such error as a @code{view number mismatch}. This is only enabled
11843on ports that define a reliable estimation function.
11844
d77de738
ML
11845@opindex ginline-points
11846@opindex gno-inline-points
ddf6fe37
AA
11847@item -ginline-points
11848@itemx -gno-inline-points
d77de738
ML
11849Generate extended debug information for inlined functions. Location
11850view tracking markers are inserted at inlined entry points, so that
11851address and view numbers can be computed and output in debug
11852information. This can be enabled independently of location views, in
11853which case the view numbers won't be output, but it can only be enabled
11854along with statement frontiers, and it is only enabled by default if
11855location views are enabled.
11856
d77de738 11857@opindex gz
ddf6fe37 11858@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11859Produce compressed debug sections in DWARF format, if that is supported.
11860If @var{type} is not given, the default type depends on the capabilities
11861of the assembler and linker used. @var{type} may be one of
11862@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11863compression in ELF gABI format). If the linker doesn't support writing
11864compressed debug sections, the option is rejected. Otherwise, if the
11865assembler does not support them, @option{-gz} is silently ignored when
11866producing object files.
11867
d77de738 11868@opindex femit-struct-debug-baseonly
ddf6fe37 11869@item -femit-struct-debug-baseonly
d77de738
ML
11870Emit debug information for struct-like types
11871only when the base name of the compilation source file
11872matches the base name of file in which the struct is defined.
11873
11874This option substantially reduces the size of debugging information,
11875but at significant potential loss in type information to the debugger.
11876See @option{-femit-struct-debug-reduced} for a less aggressive option.
11877See @option{-femit-struct-debug-detailed} for more detailed control.
11878
11879This option works only with DWARF debug output.
11880
d77de738 11881@opindex femit-struct-debug-reduced
ddf6fe37 11882@item -femit-struct-debug-reduced
d77de738
ML
11883Emit debug information for struct-like types
11884only when the base name of the compilation source file
11885matches the base name of file in which the type is defined,
11886unless the struct is a template or defined in a system header.
11887
11888This option significantly reduces the size of debugging information,
11889with some potential loss in type information to the debugger.
11890See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11891See @option{-femit-struct-debug-detailed} for more detailed control.
11892
11893This option works only with DWARF debug output.
11894
d77de738 11895@opindex femit-struct-debug-detailed
ddf6fe37 11896@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11897Specify the struct-like types
11898for which the compiler generates debug information.
11899The intent is to reduce duplicate struct debug information
11900between different object files within the same program.
11901
11902This option is a detailed version of
11903@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11904which serves for most needs.
11905
11906A specification has the syntax@*
11907[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11908
11909The optional first word limits the specification to
11910structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11911A struct type is used directly when it is the type of a variable, member.
11912Indirect uses arise through pointers to structs.
11913That is, when use of an incomplete struct is valid, the use is indirect.
11914An example is
11915@samp{struct one direct; struct two * indirect;}.
11916
11917The optional second word limits the specification to
11918ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11919Generic structs are a bit complicated to explain.
11920For C++, these are non-explicit specializations of template classes,
11921or non-template classes within the above.
11922Other programming languages have generics,
11923but @option{-femit-struct-debug-detailed} does not yet implement them.
11924
11925The third word specifies the source files for those
11926structs for which the compiler should emit debug information.
11927The values @samp{none} and @samp{any} have the normal meaning.
11928The value @samp{base} means that
11929the base of name of the file in which the type declaration appears
11930must match the base of the name of the main compilation file.
11931In practice, this means that when compiling @file{foo.c}, debug information
11932is generated for types declared in that file and @file{foo.h},
11933but not other header files.
11934The value @samp{sys} means those types satisfying @samp{base}
11935or declared in system or compiler headers.
11936
11937You may need to experiment to determine the best settings for your application.
11938
11939The default is @option{-femit-struct-debug-detailed=all}.
11940
11941This option works only with DWARF debug output.
11942
d77de738
ML
11943@opindex fdwarf2-cfi-asm
11944@opindex fno-dwarf2-cfi-asm
ddf6fe37 11945@item -fno-dwarf2-cfi-asm
d77de738
ML
11946Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11947instead of using GAS @code{.cfi_*} directives.
11948
d77de738
ML
11949@opindex feliminate-unused-debug-types
11950@opindex fno-eliminate-unused-debug-types
ddf6fe37 11951@item -fno-eliminate-unused-debug-types
d77de738
ML
11952Normally, when producing DWARF output, GCC avoids producing debug symbol
11953output for types that are nowhere used in the source file being compiled.
11954Sometimes it is useful to have GCC emit debugging
11955information for all types declared in a compilation
11956unit, regardless of whether or not they are actually used
11957in that compilation unit, for example
11958if, in the debugger, you want to cast a value to a type that is
11959not actually used in your program (but is declared). More often,
11960however, this results in a significant amount of wasted space.
11961@end table
11962
11963@node Optimize Options
11964@section Options That Control Optimization
11965@cindex optimize options
11966@cindex options, optimization
11967
11968These options control various sorts of optimizations.
11969
11970Without any optimization option, the compiler's goal is to reduce the
11971cost of compilation and to make debugging produce the expected
11972results. Statements are independent: if you stop the program with a
11973breakpoint between statements, you can then assign a new value to any
11974variable or change the program counter to any other statement in the
11975function and get exactly the results you expect from the source
11976code.
11977
11978Turning on optimization flags makes the compiler attempt to improve
11979the performance and/or code size at the expense of compilation time
11980and possibly the ability to debug the program.
11981
11982The compiler performs optimization based on the knowledge it has of the
11983program. Compiling multiple files at once to a single output file mode allows
11984the compiler to use information gained from all of the files when compiling
11985each of them.
11986
11987Not all optimizations are controlled directly by a flag. Only
11988optimizations that have a flag are listed in this section.
11989
11990Most optimizations are completely disabled at @option{-O0} or if an
11991@option{-O} level is not set on the command line, even if individual
11992optimization flags are specified. Similarly, @option{-Og} suppresses
11993many optimization passes.
11994
11995Depending on the target and how GCC was configured, a slightly different
11996set of optimizations may be enabled at each @option{-O} level than
11997those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11998to find out the exact set of optimizations that are enabled at each level.
11999@xref{Overall Options}, for examples.
12000
12001@table @gcctabopt
d77de738
ML
12002@opindex O
12003@opindex O1
ddf6fe37
AA
12004@item -O
12005@itemx -O1
d77de738
ML
12006Optimize. Optimizing compilation takes somewhat more time, and a lot
12007more memory for a large function.
12008
12009With @option{-O}, the compiler tries to reduce code size and execution
12010time, without performing any optimizations that take a great deal of
12011compilation time.
12012
12013@c Note that in addition to the default_options_table list in opts.cc,
12014@c several optimization flags default to true but control optimization
12015@c passes that are explicitly disabled at -O0.
12016
12017@option{-O} turns on the following optimization flags:
12018
12019@c Please keep the following list alphabetized.
43b72ede
AA
12020@gccoptlist{-fauto-inc-dec
12021-fbranch-count-reg
12022-fcombine-stack-adjustments
12023-fcompare-elim
12024-fcprop-registers
12025-fdce
12026-fdefer-pop
12027-fdelayed-branch
12028-fdse
12029-fforward-propagate
12030-fguess-branch-probability
12031-fif-conversion
12032-fif-conversion2
12033-finline-functions-called-once
12034-fipa-modref
12035-fipa-profile
12036-fipa-pure-const
12037-fipa-reference
12038-fipa-reference-addressable
12039-fmerge-constants
12040-fmove-loop-invariants
12041-fmove-loop-stores
12042-fomit-frame-pointer
12043-freorder-blocks
12044-fshrink-wrap
12045-fshrink-wrap-separate
12046-fsplit-wide-types
12047-fssa-backprop
12048-fssa-phiopt
12049-ftree-bit-ccp
12050-ftree-ccp
12051-ftree-ch
12052-ftree-coalesce-vars
12053-ftree-copy-prop
12054-ftree-dce
12055-ftree-dominator-opts
12056-ftree-dse
12057-ftree-forwprop
12058-ftree-fre
12059-ftree-phiprop
12060-ftree-pta
12061-ftree-scev-cprop
12062-ftree-sink
12063-ftree-slsr
12064-ftree-sra
12065-ftree-ter
d77de738
ML
12066-funit-at-a-time}
12067
d77de738 12068@opindex O2
ddf6fe37 12069@item -O2
d77de738
ML
12070Optimize even more. GCC performs nearly all supported optimizations
12071that do not involve a space-speed tradeoff.
12072As compared to @option{-O}, this option increases both compilation time
12073and the performance of the generated code.
12074
12075@option{-O2} turns on all optimization flags specified by @option{-O1}. It
12076also turns on the following optimization flags:
12077
12078@c Please keep the following list alphabetized!
43b72ede
AA
12079@gccoptlist{-falign-functions -falign-jumps
12080-falign-labels -falign-loops
12081-fcaller-saves
12082-fcode-hoisting
12083-fcrossjumping
12084-fcse-follow-jumps -fcse-skip-blocks
12085-fdelete-null-pointer-checks
12086-fdevirtualize -fdevirtualize-speculatively
12087-fexpensive-optimizations
12088-ffinite-loops
12089-fgcse -fgcse-lm
12090-fhoist-adjacent-loads
12091-finline-functions
12092-finline-small-functions
12093-findirect-inlining
12094-fipa-bit-cp -fipa-cp -fipa-icf
12095-fipa-ra -fipa-sra -fipa-vrp
12096-fisolate-erroneous-paths-dereference
12097-flra-remat
12098-foptimize-sibling-calls
12099-foptimize-strlen
12100-fpartial-inlining
12101-fpeephole2
12102-freorder-blocks-algorithm=stc
12103-freorder-blocks-and-partition -freorder-functions
12104-frerun-cse-after-loop
12105-fschedule-insns -fschedule-insns2
12106-fsched-interblock -fsched-spec
12107-fstore-merging
12108-fstrict-aliasing
12109-fthread-jumps
12110-ftree-builtin-call-dce
12111-ftree-loop-vectorize
12112-ftree-pre
12113-ftree-slp-vectorize
12114-ftree-switch-conversion -ftree-tail-merge
12115-ftree-vrp
d77de738
ML
12116-fvect-cost-model=very-cheap}
12117
12118Please note the warning under @option{-fgcse} about
12119invoking @option{-O2} on programs that use computed gotos.
12120
d77de738 12121@opindex O3
ddf6fe37 12122@item -O3
d77de738
ML
12123Optimize yet more. @option{-O3} turns on all optimizations specified
12124by @option{-O2} and also turns on the following optimization flags:
12125
12126@c Please keep the following list alphabetized!
43b72ede 12127@gccoptlist{-fgcse-after-reload
d77de738 12128-fipa-cp-clone
43b72ede
AA
12129-floop-interchange
12130-floop-unroll-and-jam
12131-fpeel-loops
12132-fpredictive-commoning
12133-fsplit-loops
12134-fsplit-paths
12135-ftree-loop-distribution
12136-ftree-partial-pre
12137-funswitch-loops
12138-fvect-cost-model=dynamic
d77de738
ML
12139-fversion-loops-for-strides}
12140
d77de738 12141@opindex O0
ddf6fe37 12142@item -O0
d77de738
ML
12143Reduce compilation time and make debugging produce the expected
12144results. This is the default.
12145
d77de738 12146@opindex Os
ddf6fe37 12147@item -Os
d77de738
ML
12148Optimize for size. @option{-Os} enables all @option{-O2} optimizations
12149except those that often increase code size:
12150
43b72ede
AA
12151@gccoptlist{-falign-functions -falign-jumps
12152-falign-labels -falign-loops
d77de738
ML
12153-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
12154
12155It also enables @option{-finline-functions}, causes the compiler to tune for
12156code size rather than execution speed, and performs further optimizations
12157designed to reduce code size.
12158
d77de738 12159@opindex Ofast
ddf6fe37 12160@item -Ofast
d77de738
ML
12161Disregard strict standards compliance. @option{-Ofast} enables all
12162@option{-O3} optimizations. It also enables optimizations that are not
12163valid for all standard-compliant programs.
12164It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
12165and the Fortran-specific @option{-fstack-arrays}, unless
12166@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
12167It turns off @option{-fsemantic-interposition}.
12168
d77de738 12169@opindex Og
ddf6fe37 12170@item -Og
d77de738
ML
12171Optimize debugging experience. @option{-Og} should be the optimization
12172level of choice for the standard edit-compile-debug cycle, offering
12173a reasonable level of optimization while maintaining fast compilation
12174and a good debugging experience. It is a better choice than @option{-O0}
12175for producing debuggable code because some compiler passes
12176that collect debug information are disabled at @option{-O0}.
12177
12178Like @option{-O0}, @option{-Og} completely disables a number of
12179optimization passes so that individual options controlling them have
12180no effect. Otherwise @option{-Og} enables all @option{-O1}
12181optimization flags except for those that may interfere with debugging:
12182
43b72ede
AA
12183@gccoptlist{-fbranch-count-reg -fdelayed-branch
12184-fdse -fif-conversion -fif-conversion2
12185-finline-functions-called-once
12186-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
12187-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12188
d77de738 12189@opindex Oz
ddf6fe37 12190@item -Oz
d77de738
ML
12191Optimize aggressively for size rather than speed. This may increase
12192the number of instructions executed if those instructions require
12193fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12194including enabling most @option{-O2} optimizations.
12195
12196@end table
12197
12198If you use multiple @option{-O} options, with or without level numbers,
12199the last such option is the one that is effective.
12200
12201Options of the form @option{-f@var{flag}} specify machine-independent
12202flags. Most flags have both positive and negative forms; the negative
12203form of @option{-ffoo} is @option{-fno-foo}. In the table
12204below, only one of the forms is listed---the one you typically
12205use. You can figure out the other form by either removing @samp{no-}
12206or adding it.
12207
12208The following options control specific optimizations. They are either
12209activated by @option{-O} options or are related to ones that are. You
12210can use the following flags in the rare cases when ``fine-tuning'' of
12211optimizations to be performed is desired.
12212
12213@table @gcctabopt
d77de738
ML
12214@opindex fno-defer-pop
12215@opindex fdefer-pop
ddf6fe37 12216@item -fno-defer-pop
d77de738
ML
12217For machines that must pop arguments after a function call, always pop
12218the arguments as soon as each function returns.
12219At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12220this allows the compiler to let arguments accumulate on the stack for several
12221function calls and pop them all at once.
12222
d77de738 12223@opindex fforward-propagate
ddf6fe37 12224@item -fforward-propagate
d77de738
ML
12225Perform a forward propagation pass on RTL@. The pass tries to combine two
12226instructions and checks if the result can be simplified. If loop unrolling
12227is active, two passes are performed and the second is scheduled after
12228loop unrolling.
12229
12230This option is enabled by default at optimization levels @option{-O1},
12231@option{-O2}, @option{-O3}, @option{-Os}.
12232
d77de738 12233@opindex ffp-contract
ddf6fe37 12234@item -ffp-contract=@var{style}
d77de738
ML
12235@option{-ffp-contract=off} disables floating-point expression contraction.
12236@option{-ffp-contract=fast} enables floating-point expression contraction
12237such as forming of fused multiply-add operations if the target has
12238native support for them.
12239@option{-ffp-contract=on} enables floating-point expression contraction
1c1dd396
AM
12240if allowed by the language standard. This is implemented for C and C++,
12241where it enables contraction within one expression, but not across
12242different statements.
d77de738 12243
1c1dd396
AM
12244The default is @option{-ffp-contract=off} for C in a standards compliant mode
12245(@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
d77de738 12246
d77de738 12247@opindex fomit-frame-pointer
ddf6fe37 12248@item -fomit-frame-pointer
d77de738
ML
12249Omit the frame pointer in functions that don't need one. This avoids the
12250instructions to save, set up and restore the frame pointer; on many targets
12251it also makes an extra register available.
12252
12253On some targets this flag has no effect because the standard calling sequence
12254always uses a frame pointer, so it cannot be omitted.
12255
12256Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12257is used in all functions. Several targets always omit the frame pointer in
12258leaf functions.
12259
12260Enabled by default at @option{-O1} and higher.
12261
d77de738 12262@opindex foptimize-sibling-calls
ddf6fe37 12263@item -foptimize-sibling-calls
d77de738
ML
12264Optimize sibling and tail recursive calls.
12265
12266Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12267
d77de738 12268@opindex foptimize-strlen
ddf6fe37 12269@item -foptimize-strlen
d77de738
ML
12270Optimize various standard C string functions (e.g.@: @code{strlen},
12271@code{strchr} or @code{strcpy}) and
12272their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12273
12274Enabled at levels @option{-O2}, @option{-O3}.
12275
d77de738
ML
12276@opindex fno-inline
12277@opindex finline
ddf6fe37 12278@item -fno-inline
d77de738
ML
12279Do not expand any functions inline apart from those marked with
12280the @code{always_inline} attribute. This is the default when not
12281optimizing.
12282
12283Single functions can be exempted from inlining by marking them
12284with the @code{noinline} attribute.
12285
d77de738 12286@opindex finline-small-functions
ddf6fe37 12287@item -finline-small-functions
d77de738
ML
12288Integrate functions into their callers when their body is smaller than expected
12289function call code (so overall size of program gets smaller). The compiler
12290heuristically decides which functions are simple enough to be worth integrating
12291in this way. This inlining applies to all functions, even those not declared
12292inline.
12293
12294Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12295
d77de738 12296@opindex findirect-inlining
ddf6fe37 12297@item -findirect-inlining
d77de738
ML
12298Inline also indirect calls that are discovered to be known at compile
12299time thanks to previous inlining. This option has any effect only
12300when inlining itself is turned on by the @option{-finline-functions}
12301or @option{-finline-small-functions} options.
12302
12303Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12304
d77de738 12305@opindex finline-functions
ddf6fe37 12306@item -finline-functions
d77de738
ML
12307Consider all functions for inlining, even if they are not declared inline.
12308The compiler heuristically decides which functions are worth integrating
12309in this way.
12310
12311If all calls to a given function are integrated, and the function is
12312declared @code{static}, then the function is normally not output as
12313assembler code in its own right.
12314
12315Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12316by @option{-fprofile-use} and @option{-fauto-profile}.
12317
d77de738 12318@opindex finline-functions-called-once
ddf6fe37 12319@item -finline-functions-called-once
d77de738
ML
12320Consider all @code{static} functions called once for inlining into their
12321caller even if they are not marked @code{inline}. If a call to a given
12322function is integrated, then the function is not output as assembler code
12323in its own right.
12324
12325Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12326but not @option{-Og}.
12327
d77de738 12328@opindex fearly-inlining
ddf6fe37 12329@item -fearly-inlining
d77de738
ML
12330Inline functions marked by @code{always_inline} and functions whose body seems
12331smaller than the function call overhead early before doing
12332@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12333makes profiling significantly cheaper and usually inlining faster on programs
12334having large chains of nested wrapper functions.
12335
12336Enabled by default.
12337
d77de738 12338@opindex fipa-sra
ddf6fe37 12339@item -fipa-sra
d77de738
ML
12340Perform interprocedural scalar replacement of aggregates, removal of
12341unused parameters and replacement of parameters passed by reference
12342by parameters passed by value.
12343
12344Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12345
d77de738 12346@opindex finline-limit
ddf6fe37 12347@item -finline-limit=@var{n}
d77de738
ML
12348By default, GCC limits the size of functions that can be inlined. This flag
12349allows coarse control of this limit. @var{n} is the size of functions that
12350can be inlined in number of pseudo instructions.
12351
12352Inlining is actually controlled by a number of parameters, which may be
12353specified individually by using @option{--param @var{name}=@var{value}}.
12354The @option{-finline-limit=@var{n}} option sets some of these parameters
12355as follows:
12356
12357@table @gcctabopt
12358@item max-inline-insns-single
12359is set to @var{n}/2.
12360@item max-inline-insns-auto
12361is set to @var{n}/2.
12362@end table
12363
12364See below for a documentation of the individual
12365parameters controlling inlining and for the defaults of these parameters.
12366
12367@emph{Note:} there may be no value to @option{-finline-limit} that results
12368in default behavior.
12369
12370@emph{Note:} pseudo instruction represents, in this particular context, an
12371abstract measurement of function's size. In no way does it represent a count
12372of assembly instructions and as such its exact meaning might change from one
12373release to an another.
12374
d77de738
ML
12375@opindex fno-keep-inline-dllexport
12376@opindex fkeep-inline-dllexport
ddf6fe37 12377@item -fno-keep-inline-dllexport
d77de738
ML
12378This is a more fine-grained version of @option{-fkeep-inline-functions},
12379which applies only to functions that are declared using the @code{dllexport}
12380attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12381Functions}.
12382
d77de738 12383@opindex fkeep-inline-functions
ddf6fe37 12384@item -fkeep-inline-functions
d77de738
ML
12385In C, emit @code{static} functions that are declared @code{inline}
12386into the object file, even if the function has been inlined into all
12387of its callers. This switch does not affect functions using the
12388@code{extern inline} extension in GNU C90@. In C++, emit any and all
12389inline functions into the object file.
12390
d77de738 12391@opindex fkeep-static-functions
ddf6fe37 12392@item -fkeep-static-functions
d77de738
ML
12393Emit @code{static} functions into the object file, even if the function
12394is never used.
12395
d77de738 12396@opindex fkeep-static-consts
ddf6fe37 12397@item -fkeep-static-consts
d77de738
ML
12398Emit variables declared @code{static const} when optimization isn't turned
12399on, even if the variables aren't referenced.
12400
12401GCC enables this option by default. If you want to force the compiler to
12402check if a variable is referenced, regardless of whether or not
12403optimization is turned on, use the @option{-fno-keep-static-consts} option.
12404
d77de738 12405@opindex fmerge-constants
ddf6fe37 12406@item -fmerge-constants
d77de738
ML
12407Attempt to merge identical constants (string constants and floating-point
12408constants) across compilation units.
12409
12410This option is the default for optimized compilation if the assembler and
12411linker support it. Use @option{-fno-merge-constants} to inhibit this
12412behavior.
12413
12414Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12415
d77de738 12416@opindex fmerge-all-constants
ddf6fe37 12417@item -fmerge-all-constants
d77de738
ML
12418Attempt to merge identical constants and identical variables.
12419
12420This option implies @option{-fmerge-constants}. In addition to
12421@option{-fmerge-constants} this considers e.g.@: even constant initialized
12422arrays or initialized constant variables with integral or floating-point
12423types. Languages like C or C++ require each variable, including multiple
12424instances of the same variable in recursive calls, to have distinct locations,
12425so using this option results in non-conforming
12426behavior.
12427
d77de738 12428@opindex fmodulo-sched
ddf6fe37 12429@item -fmodulo-sched
d77de738
ML
12430Perform swing modulo scheduling immediately before the first scheduling
12431pass. This pass looks at innermost loops and reorders their
12432instructions by overlapping different iterations.
12433
d77de738 12434@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12435@item -fmodulo-sched-allow-regmoves
d77de738
ML
12436Perform more aggressive SMS-based modulo scheduling with register moves
12437allowed. By setting this flag certain anti-dependences edges are
12438deleted, which triggers the generation of reg-moves based on the
12439life-range analysis. This option is effective only with
12440@option{-fmodulo-sched} enabled.
12441
d77de738
ML
12442@opindex fno-branch-count-reg
12443@opindex fbranch-count-reg
ddf6fe37 12444@item -fno-branch-count-reg
d77de738
ML
12445Disable the optimization pass that scans for opportunities to use
12446``decrement and branch'' instructions on a count register instead of
12447instruction sequences that decrement a register, compare it against zero, and
12448then branch based upon the result. This option is only meaningful on
12449architectures that support such instructions, which include x86, PowerPC,
12450IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12451doesn't remove the decrement and branch instructions from the generated
12452instruction stream introduced by other optimization passes.
12453
12454The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12455except for @option{-Og}.
12456
d77de738
ML
12457@opindex fno-function-cse
12458@opindex ffunction-cse
ddf6fe37 12459@item -fno-function-cse
d77de738
ML
12460Do not put function addresses in registers; make each instruction that
12461calls a constant function contain the function's address explicitly.
12462
12463This option results in less efficient code, but some strange hacks
12464that alter the assembler output may be confused by the optimizations
12465performed when this option is not used.
12466
12467The default is @option{-ffunction-cse}
12468
d77de738
ML
12469@opindex fno-zero-initialized-in-bss
12470@opindex fzero-initialized-in-bss
ddf6fe37 12471@item -fno-zero-initialized-in-bss
d77de738
ML
12472If the target supports a BSS section, GCC by default puts variables that
12473are initialized to zero into BSS@. This can save space in the resulting
12474code.
12475
12476This option turns off this behavior because some programs explicitly
12477rely on variables going to the data section---e.g., so that the
12478resulting executable can find the beginning of that section and/or make
12479assumptions based on that.
12480
12481The default is @option{-fzero-initialized-in-bss}.
12482
d77de738 12483@opindex fthread-jumps
ddf6fe37 12484@item -fthread-jumps
d77de738
ML
12485Perform optimizations that check to see if a jump branches to a
12486location where another comparison subsumed by the first is found. If
12487so, the first branch is redirected to either the destination of the
12488second branch or a point immediately following it, depending on whether
12489the condition is known to be true or false.
12490
12491Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12492
d77de738 12493@opindex fsplit-wide-types
ddf6fe37 12494@item -fsplit-wide-types
d77de738
ML
12495When using a type that occupies multiple registers, such as @code{long
12496long} on a 32-bit system, split the registers apart and allocate them
12497independently. This normally generates better code for those types,
12498but may make debugging more difficult.
12499
12500Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12501@option{-Os}.
12502
d77de738 12503@opindex fsplit-wide-types-early
ddf6fe37 12504@item -fsplit-wide-types-early
d77de738
ML
12505Fully split wide types early, instead of very late.
12506This option has no effect unless @option{-fsplit-wide-types} is turned on.
12507
12508This is the default on some targets.
12509
d77de738 12510@opindex fcse-follow-jumps
ddf6fe37 12511@item -fcse-follow-jumps
d77de738
ML
12512In common subexpression elimination (CSE), scan through jump instructions
12513when the target of the jump is not reached by any other path. For
12514example, when CSE encounters an @code{if} statement with an
12515@code{else} clause, CSE follows the jump when the condition
12516tested is false.
12517
12518Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12519
d77de738 12520@opindex fcse-skip-blocks
ddf6fe37 12521@item -fcse-skip-blocks
d77de738
ML
12522This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12523follow jumps that conditionally skip over blocks. When CSE
12524encounters a simple @code{if} statement with no else clause,
12525@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12526body of the @code{if}.
12527
12528Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12529
d77de738 12530@opindex frerun-cse-after-loop
ddf6fe37 12531@item -frerun-cse-after-loop
d77de738
ML
12532Re-run common subexpression elimination after loop optimizations are
12533performed.
12534
12535Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12536
d77de738 12537@opindex fgcse
ddf6fe37 12538@item -fgcse
d77de738
ML
12539Perform a global common subexpression elimination pass.
12540This pass also performs global constant and copy propagation.
12541
12542@emph{Note:} When compiling a program using computed gotos, a GCC
12543extension, you may get better run-time performance if you disable
12544the global common subexpression elimination pass by adding
12545@option{-fno-gcse} to the command line.
12546
12547Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12548
d77de738 12549@opindex fgcse-lm
ddf6fe37 12550@item -fgcse-lm
d77de738
ML
12551When @option{-fgcse-lm} is enabled, global common subexpression elimination
12552attempts to move loads that are only killed by stores into themselves. This
12553allows a loop containing a load/store sequence to be changed to a load outside
12554the loop, and a copy/store within the loop.
12555
12556Enabled by default when @option{-fgcse} is enabled.
12557
d77de738 12558@opindex fgcse-sm
ddf6fe37 12559@item -fgcse-sm
d77de738
ML
12560When @option{-fgcse-sm} is enabled, a store motion pass is run after
12561global common subexpression elimination. This pass attempts to move
12562stores out of loops. When used in conjunction with @option{-fgcse-lm},
12563loops containing a load/store sequence can be changed to a load before
12564the loop and a store after the loop.
12565
12566Not enabled at any optimization level.
12567
d77de738 12568@opindex fgcse-las
ddf6fe37 12569@item -fgcse-las
d77de738
ML
12570When @option{-fgcse-las} is enabled, the global common subexpression
12571elimination pass eliminates redundant loads that come after stores to the
12572same memory location (both partial and full redundancies).
12573
12574Not enabled at any optimization level.
12575
d77de738 12576@opindex fgcse-after-reload
ddf6fe37 12577@item -fgcse-after-reload
d77de738
ML
12578When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12579pass is performed after reload. The purpose of this pass is to clean up
12580redundant spilling.
12581
12582Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12583
d77de738 12584@opindex faggressive-loop-optimizations
ddf6fe37 12585@item -faggressive-loop-optimizations
d77de738
ML
12586This option tells the loop optimizer to use language constraints to
12587derive bounds for the number of iterations of a loop. This assumes that
12588loop code does not invoke undefined behavior by for example causing signed
12589integer overflows or out-of-bound array accesses. The bounds for the
12590number of iterations of a loop are used to guide loop unrolling and peeling
12591and loop exit test optimizations.
12592This option is enabled by default.
12593
d77de738 12594@opindex funconstrained-commons
ddf6fe37 12595@item -funconstrained-commons
d77de738
ML
12596This option tells the compiler that variables declared in common blocks
12597(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12598prevents certain optimizations that depend on knowing the array bounds.
12599
d77de738 12600@opindex fcrossjumping
ddf6fe37 12601@item -fcrossjumping
d77de738
ML
12602Perform cross-jumping transformation.
12603This transformation unifies equivalent code and saves code size. The
12604resulting code may or may not perform better than without cross-jumping.
12605
12606Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12607
d77de738 12608@opindex fauto-inc-dec
ddf6fe37 12609@item -fauto-inc-dec
d77de738
ML
12610Combine increments or decrements of addresses with memory accesses.
12611This pass is always skipped on architectures that do not have
12612instructions to support this. Enabled by default at @option{-O1} and
12613higher on architectures that support this.
12614
d77de738 12615@opindex fdce
ddf6fe37 12616@item -fdce
d77de738
ML
12617Perform dead code elimination (DCE) on RTL@.
12618Enabled by default at @option{-O1} and higher.
12619
d77de738 12620@opindex fdse
ddf6fe37 12621@item -fdse
d77de738
ML
12622Perform dead store elimination (DSE) on RTL@.
12623Enabled by default at @option{-O1} and higher.
12624
d77de738 12625@opindex fif-conversion
ddf6fe37 12626@item -fif-conversion
d77de738
ML
12627Attempt to transform conditional jumps into branch-less equivalents. This
12628includes use of conditional moves, min, max, set flags and abs instructions, and
12629some tricks doable by standard arithmetics. The use of conditional execution
12630on chips where it is available is controlled by @option{-fif-conversion2}.
12631
12632Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12633not with @option{-Og}.
12634
d77de738 12635@opindex fif-conversion2
ddf6fe37 12636@item -fif-conversion2
d77de738
ML
12637Use conditional execution (where available) to transform conditional jumps into
12638branch-less equivalents.
12639
12640Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12641not with @option{-Og}.
12642
d77de738 12643@opindex fdeclone-ctor-dtor
ddf6fe37 12644@item -fdeclone-ctor-dtor
d77de738
ML
12645The C++ ABI requires multiple entry points for constructors and
12646destructors: one for a base subobject, one for a complete object, and
12647one for a virtual destructor that calls operator delete afterwards.
12648For a hierarchy with virtual bases, the base and complete variants are
12649clones, which means two copies of the function. With this option, the
12650base and complete variants are changed to be thunks that call a common
12651implementation.
12652
12653Enabled by @option{-Os}.
12654
d77de738 12655@opindex fdelete-null-pointer-checks
ddf6fe37 12656@item -fdelete-null-pointer-checks
d77de738
ML
12657Assume that programs cannot safely dereference null pointers, and that
12658no code or data element resides at address zero.
12659This option enables simple constant
12660folding optimizations at all optimization levels. In addition, other
12661optimization passes in GCC use this flag to control global dataflow
12662analyses that eliminate useless checks for null pointers; these assume
12663that a memory access to address zero always results in a trap, so
12664that if a pointer is checked after it has already been dereferenced,
12665it cannot be null.
12666
12667Note however that in some environments this assumption is not true.
12668Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12669for programs that depend on that behavior.
12670
12671This option is enabled by default on most targets. On Nios II ELF, it
12672defaults to off. On AVR and MSP430, this option is completely disabled.
12673
12674Passes that use the dataflow information
12675are enabled independently at different optimization levels.
12676
d77de738 12677@opindex fdevirtualize
ddf6fe37 12678@item -fdevirtualize
d77de738
ML
12679Attempt to convert calls to virtual functions to direct calls. This
12680is done both within a procedure and interprocedurally as part of
12681indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12682propagation (@option{-fipa-cp}).
12683Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12684
d77de738 12685@opindex fdevirtualize-speculatively
ddf6fe37 12686@item -fdevirtualize-speculatively
d77de738
ML
12687Attempt to convert calls to virtual functions to speculative direct calls.
12688Based on the analysis of the type inheritance graph, determine for a given call
12689the set of likely targets. If the set is small, preferably of size 1, change
12690the call into a conditional deciding between direct and indirect calls. The
12691speculative calls enable more optimizations, such as inlining. When they seem
12692useless after further optimization, they are converted back into original form.
12693
d77de738 12694@opindex fdevirtualize-at-ltrans
ddf6fe37 12695@item -fdevirtualize-at-ltrans
d77de738
ML
12696Stream extra information needed for aggressive devirtualization when running
12697the link-time optimizer in local transformation mode.
12698This option enables more devirtualization but
12699significantly increases the size of streamed data. For this reason it is
12700disabled by default.
12701
d77de738 12702@opindex fexpensive-optimizations
ddf6fe37 12703@item -fexpensive-optimizations
d77de738
ML
12704Perform a number of minor optimizations that are relatively expensive.
12705
12706Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12707
d77de738 12708@opindex free
ddf6fe37 12709@item -free
d77de738
ML
12710Attempt to remove redundant extension instructions. This is especially
12711helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12712registers after writing to their lower 32-bit half.
12713
88ae53a3
LC
12714Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
12715levels @option{-O2}, @option{-O3}, @option{-Os}.
d77de738 12716
d77de738
ML
12717@opindex fno-lifetime-dse
12718@opindex flifetime-dse
ddf6fe37 12719@item -fno-lifetime-dse
d77de738
ML
12720In C++ the value of an object is only affected by changes within its
12721lifetime: when the constructor begins, the object has an indeterminate
12722value, and any changes during the lifetime of the object are dead when
12723the object is destroyed. Normally dead store elimination will take
12724advantage of this; if your code relies on the value of the object
12725storage persisting beyond the lifetime of the object, you can use this
12726flag to disable this optimization. To preserve stores before the
12727constructor starts (e.g.@: because your operator new clears the object
12728storage) but still treat the object as dead after the destructor, you
12729can use @option{-flifetime-dse=1}. The default behavior can be
12730explicitly selected with @option{-flifetime-dse=2}.
12731@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12732
d77de738 12733@opindex flive-range-shrinkage
ddf6fe37 12734@item -flive-range-shrinkage
d77de738
ML
12735Attempt to decrease register pressure through register live range
12736shrinkage. This is helpful for fast processors with small or moderate
12737size register sets.
12738
d77de738 12739@opindex fira-algorithm
ddf6fe37 12740@item -fira-algorithm=@var{algorithm}
d77de738
ML
12741Use the specified coloring algorithm for the integrated register
12742allocator. The @var{algorithm} argument can be @samp{priority}, which
12743specifies Chow's priority coloring, or @samp{CB}, which specifies
12744Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12745for all architectures, but for those targets that do support it, it is
12746the default because it generates better code.
12747
d77de738 12748@opindex fira-region
ddf6fe37 12749@item -fira-region=@var{region}
d77de738
ML
12750Use specified regions for the integrated register allocator. The
12751@var{region} argument should be one of the following:
12752
12753@table @samp
12754
12755@item all
12756Use all loops as register allocation regions.
12757This can give the best results for machines with a small and/or
12758irregular register set.
12759
12760@item mixed
12761Use all loops except for loops with small register pressure
12762as the regions. This value usually gives
12763the best results in most cases and for most architectures,
12764and is enabled by default when compiling with optimization for speed
12765(@option{-O}, @option{-O2}, @dots{}).
12766
12767@item one
12768Use all functions as a single region.
12769This typically results in the smallest code size, and is enabled by default for
12770@option{-Os} or @option{-O0}.
12771
12772@end table
12773
d77de738 12774@opindex fira-hoist-pressure
ddf6fe37 12775@item -fira-hoist-pressure
d77de738
ML
12776Use IRA to evaluate register pressure in the code hoisting pass for
12777decisions to hoist expressions. This option usually results in smaller
12778code, but it can slow the compiler down.
12779
12780This option is enabled at level @option{-Os} for all targets.
12781
d77de738 12782@opindex fira-loop-pressure
ddf6fe37 12783@item -fira-loop-pressure
d77de738
ML
12784Use IRA to evaluate register pressure in loops for decisions to move
12785loop invariants. This option usually results in generation
12786of faster and smaller code on machines with large register files (>= 32
12787registers), but it can slow the compiler down.
12788
12789This option is enabled at level @option{-O3} for some targets.
12790
d77de738
ML
12791@opindex fno-ira-share-save-slots
12792@opindex fira-share-save-slots
ddf6fe37 12793@item -fno-ira-share-save-slots
d77de738
ML
12794Disable sharing of stack slots used for saving call-used hard
12795registers living through a call. Each hard register gets a
12796separate stack slot, and as a result function stack frames are
12797larger.
12798
d77de738
ML
12799@opindex fno-ira-share-spill-slots
12800@opindex fira-share-spill-slots
ddf6fe37 12801@item -fno-ira-share-spill-slots
d77de738
ML
12802Disable sharing of stack slots allocated for pseudo-registers. Each
12803pseudo-register that does not get a hard register gets a separate
12804stack slot, and as a result function stack frames are larger.
12805
d77de738 12806@opindex flra-remat
ddf6fe37 12807@item -flra-remat
d77de738
ML
12808Enable CFG-sensitive rematerialization in LRA. Instead of loading
12809values of spilled pseudos, LRA tries to rematerialize (recalculate)
12810values if it is profitable.
12811
12812Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12813
d77de738 12814@opindex fdelayed-branch
ddf6fe37 12815@item -fdelayed-branch
d77de738
ML
12816If supported for the target machine, attempt to reorder instructions
12817to exploit instruction slots available after delayed branch
12818instructions.
12819
12820Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12821but not at @option{-Og}.
12822
d77de738 12823@opindex fschedule-insns
ddf6fe37 12824@item -fschedule-insns
d77de738
ML
12825If supported for the target machine, attempt to reorder instructions to
12826eliminate execution stalls due to required data being unavailable. This
12827helps machines that have slow floating point or memory load instructions
12828by allowing other instructions to be issued until the result of the load
12829or floating-point instruction is required.
12830
12831Enabled at levels @option{-O2}, @option{-O3}.
12832
d77de738 12833@opindex fschedule-insns2
ddf6fe37 12834@item -fschedule-insns2
d77de738
ML
12835Similar to @option{-fschedule-insns}, but requests an additional pass of
12836instruction scheduling after register allocation has been done. This is
12837especially useful on machines with a relatively small number of
12838registers and where memory load instructions take more than one cycle.
12839
12840Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12841
d77de738
ML
12842@opindex fno-sched-interblock
12843@opindex fsched-interblock
ddf6fe37 12844@item -fno-sched-interblock
d77de738
ML
12845Disable instruction scheduling across basic blocks, which
12846is normally enabled when scheduling before register allocation, i.e.@:
12847with @option{-fschedule-insns} or at @option{-O2} or higher.
12848
d77de738
ML
12849@opindex fno-sched-spec
12850@opindex fsched-spec
ddf6fe37 12851@item -fno-sched-spec
d77de738
ML
12852Disable speculative motion of non-load instructions, which
12853is normally enabled when scheduling before register allocation, i.e.@:
12854with @option{-fschedule-insns} or at @option{-O2} or higher.
12855
d77de738 12856@opindex fsched-pressure
ddf6fe37 12857@item -fsched-pressure
d77de738
ML
12858Enable register pressure sensitive insn scheduling before register
12859allocation. This only makes sense when scheduling before register
12860allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12861@option{-O2} or higher. Usage of this option can improve the
12862generated code and decrease its size by preventing register pressure
12863increase above the number of available hard registers and subsequent
12864spills in register allocation.
12865
d77de738 12866@opindex fsched-spec-load
ddf6fe37 12867@item -fsched-spec-load
d77de738
ML
12868Allow speculative motion of some load instructions. This only makes
12869sense when scheduling before register allocation, i.e.@: with
12870@option{-fschedule-insns} or at @option{-O2} or higher.
12871
d77de738 12872@opindex fsched-spec-load-dangerous
ddf6fe37 12873@item -fsched-spec-load-dangerous
d77de738
ML
12874Allow speculative motion of more load instructions. This only makes
12875sense when scheduling before register allocation, i.e.@: with
12876@option{-fschedule-insns} or at @option{-O2} or higher.
12877
ddf6fe37 12878@opindex fsched-stalled-insns
d77de738
ML
12879@item -fsched-stalled-insns
12880@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12881Define how many insns (if any) can be moved prematurely from the queue
12882of stalled insns into the ready list during the second scheduling pass.
12883@option{-fno-sched-stalled-insns} means that no insns are moved
12884prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12885on how many queued insns can be moved prematurely.
12886@option{-fsched-stalled-insns} without a value is equivalent to
12887@option{-fsched-stalled-insns=1}.
12888
ddf6fe37 12889@opindex fsched-stalled-insns-dep
d77de738
ML
12890@item -fsched-stalled-insns-dep
12891@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12892Define how many insn groups (cycles) are examined for a dependency
12893on a stalled insn that is a candidate for premature removal from the queue
12894of stalled insns. This has an effect only during the second scheduling pass,
12895and only if @option{-fsched-stalled-insns} is used.
12896@option{-fno-sched-stalled-insns-dep} is equivalent to
12897@option{-fsched-stalled-insns-dep=0}.
12898@option{-fsched-stalled-insns-dep} without a value is equivalent to
12899@option{-fsched-stalled-insns-dep=1}.
12900
d77de738 12901@opindex fsched2-use-superblocks
ddf6fe37 12902@item -fsched2-use-superblocks
d77de738
ML
12903When scheduling after register allocation, use superblock scheduling.
12904This allows motion across basic block boundaries,
12905resulting in faster schedules. This option is experimental, as not all machine
12906descriptions used by GCC model the CPU closely enough to avoid unreliable
12907results from the algorithm.
12908
12909This only makes sense when scheduling after register allocation, i.e.@: with
12910@option{-fschedule-insns2} or at @option{-O2} or higher.
12911
d77de738 12912@opindex fsched-group-heuristic
ddf6fe37 12913@item -fsched-group-heuristic
d77de738
ML
12914Enable the group heuristic in the scheduler. This heuristic favors
12915the instruction that belongs to a schedule group. This is enabled
12916by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12917or @option{-fschedule-insns2} or at @option{-O2} or higher.
12918
d77de738 12919@opindex fsched-critical-path-heuristic
ddf6fe37 12920@item -fsched-critical-path-heuristic
d77de738
ML
12921Enable the critical-path heuristic in the scheduler. This heuristic favors
12922instructions on the critical path. This is enabled by default when
12923scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12924or @option{-fschedule-insns2} or at @option{-O2} or higher.
12925
d77de738 12926@opindex fsched-spec-insn-heuristic
ddf6fe37 12927@item -fsched-spec-insn-heuristic
d77de738
ML
12928Enable the speculative instruction heuristic in the scheduler. This
12929heuristic favors speculative instructions with greater dependency weakness.
12930This is enabled by default when scheduling is enabled, i.e.@:
12931with @option{-fschedule-insns} or @option{-fschedule-insns2}
12932or at @option{-O2} or higher.
12933
d77de738 12934@opindex fsched-rank-heuristic
ddf6fe37 12935@item -fsched-rank-heuristic
d77de738
ML
12936Enable the rank heuristic in the scheduler. This heuristic favors
12937the instruction belonging to a basic block with greater size or frequency.
12938This is enabled by default when scheduling is enabled, i.e.@:
12939with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12940at @option{-O2} or higher.
12941
d77de738 12942@opindex fsched-last-insn-heuristic
ddf6fe37 12943@item -fsched-last-insn-heuristic
d77de738
ML
12944Enable the last-instruction heuristic in the scheduler. This heuristic
12945favors the instruction that is less dependent on the last instruction
12946scheduled. This is enabled by default when scheduling is enabled,
12947i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12948at @option{-O2} or higher.
12949
d77de738 12950@opindex fsched-dep-count-heuristic
ddf6fe37 12951@item -fsched-dep-count-heuristic
d77de738
ML
12952Enable the dependent-count heuristic in the scheduler. This heuristic
12953favors the instruction that has more instructions depending on it.
12954This is enabled by default when scheduling is enabled, i.e.@:
12955with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12956at @option{-O2} or higher.
12957
d77de738 12958@opindex freschedule-modulo-scheduled-loops
ddf6fe37 12959@item -freschedule-modulo-scheduled-loops
d77de738
ML
12960Modulo scheduling is performed before traditional scheduling. If a loop
12961is modulo scheduled, later scheduling passes may change its schedule.
12962Use this option to control that behavior.
12963
d77de738 12964@opindex fselective-scheduling
ddf6fe37 12965@item -fselective-scheduling
d77de738
ML
12966Schedule instructions using selective scheduling algorithm. Selective
12967scheduling runs instead of the first scheduler pass.
12968
d77de738 12969@opindex fselective-scheduling2
ddf6fe37 12970@item -fselective-scheduling2
d77de738
ML
12971Schedule instructions using selective scheduling algorithm. Selective
12972scheduling runs instead of the second scheduler pass.
12973
d77de738 12974@opindex fsel-sched-pipelining
ddf6fe37 12975@item -fsel-sched-pipelining
d77de738
ML
12976Enable software pipelining of innermost loops during selective scheduling.
12977This option has no effect unless one of @option{-fselective-scheduling} or
12978@option{-fselective-scheduling2} is turned on.
12979
d77de738 12980@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 12981@item -fsel-sched-pipelining-outer-loops
d77de738
ML
12982When pipelining loops during selective scheduling, also pipeline outer loops.
12983This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12984
d77de738 12985@opindex fsemantic-interposition
ddf6fe37 12986@item -fsemantic-interposition
d77de738
ML
12987Some object formats, like ELF, allow interposing of symbols by the
12988dynamic linker.
12989This means that for symbols exported from the DSO, the compiler cannot perform
12990interprocedural propagation, inlining and other optimizations in anticipation
12991that the function or variable in question may change. While this feature is
12992useful, for example, to rewrite memory allocation functions by a debugging
12993implementation, it is expensive in the terms of code quality.
12994With @option{-fno-semantic-interposition} the compiler assumes that
12995if interposition happens for functions the overwriting function will have
12996precisely the same semantics (and side effects).
12997Similarly if interposition happens
12998for variables, the constructor of the variable will be the same. The flag
12999has no effect for functions explicitly declared inline
13000(where it is never allowed for interposition to change semantics)
13001and for symbols explicitly declared weak.
13002
d77de738 13003@opindex fshrink-wrap
ddf6fe37 13004@item -fshrink-wrap
d77de738
ML
13005Emit function prologues only before parts of the function that need it,
13006rather than at the top of the function. This flag is enabled by default at
13007@option{-O} and higher.
13008
d77de738 13009@opindex fshrink-wrap-separate
ddf6fe37 13010@item -fshrink-wrap-separate
d77de738
ML
13011Shrink-wrap separate parts of the prologue and epilogue separately, so that
13012those parts are only executed when needed.
13013This option is on by default, but has no effect unless @option{-fshrink-wrap}
13014is also turned on and the target supports this.
13015
d77de738 13016@opindex fcaller-saves
ddf6fe37 13017@item -fcaller-saves
d77de738
ML
13018Enable allocation of values to registers that are clobbered by
13019function calls, by emitting extra instructions to save and restore the
13020registers around such calls. Such allocation is done only when it
13021seems to result in better code.
13022
13023This option is always enabled by default on certain machines, usually
13024those which have no call-preserved registers to use instead.
13025
13026Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13027
d77de738 13028@opindex fcombine-stack-adjustments
ddf6fe37 13029@item -fcombine-stack-adjustments
d77de738
ML
13030Tracks stack adjustments (pushes and pops) and stack memory references
13031and then tries to find ways to combine them.
13032
13033Enabled by default at @option{-O1} and higher.
13034
d77de738 13035@opindex fipa-ra
ddf6fe37 13036@item -fipa-ra
d77de738
ML
13037Use caller save registers for allocation if those registers are not used by
13038any called function. In that case it is not necessary to save and restore
13039them around calls. This is only possible if called functions are part of
13040same compilation unit as current function and they are compiled before it.
13041
13042Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13043is disabled if generated code will be instrumented for profiling
13044(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13045exactly (this happens on targets that do not expose prologues
13046and epilogues in RTL).
13047
d77de738 13048@opindex fconserve-stack
ddf6fe37 13049@item -fconserve-stack
d77de738
ML
13050Attempt to minimize stack usage. The compiler attempts to use less
13051stack space, even if that makes the program slower. This option
13052implies setting the @option{large-stack-frame} parameter to 100
13053and the @option{large-stack-frame-growth} parameter to 400.
13054
d77de738 13055@opindex ftree-reassoc
ddf6fe37 13056@item -ftree-reassoc
d77de738
ML
13057Perform reassociation on trees. This flag is enabled by default
13058at @option{-O1} and higher.
13059
d77de738 13060@opindex fcode-hoisting
ddf6fe37 13061@item -fcode-hoisting
d77de738
ML
13062Perform code hoisting. Code hoisting tries to move the
13063evaluation of expressions executed on all paths to the function exit
13064as early as possible. This is especially useful as a code size
13065optimization, but it often helps for code speed as well.
13066This flag is enabled by default at @option{-O2} and higher.
13067
d77de738 13068@opindex ftree-pre
ddf6fe37 13069@item -ftree-pre
d77de738
ML
13070Perform partial redundancy elimination (PRE) on trees. This flag is
13071enabled by default at @option{-O2} and @option{-O3}.
13072
d77de738 13073@opindex ftree-partial-pre
ddf6fe37 13074@item -ftree-partial-pre
d77de738
ML
13075Make partial redundancy elimination (PRE) more aggressive. This flag is
13076enabled by default at @option{-O3}.
13077
d77de738 13078@opindex ftree-forwprop
ddf6fe37 13079@item -ftree-forwprop
d77de738
ML
13080Perform forward propagation on trees. This flag is enabled by default
13081at @option{-O1} and higher.
13082
d77de738 13083@opindex ftree-fre
ddf6fe37 13084@item -ftree-fre
d77de738
ML
13085Perform full redundancy elimination (FRE) on trees. The difference
13086between FRE and PRE is that FRE only considers expressions
13087that are computed on all paths leading to the redundant computation.
13088This analysis is faster than PRE, though it exposes fewer redundancies.
13089This flag is enabled by default at @option{-O1} and higher.
13090
d77de738 13091@opindex ftree-phiprop
ddf6fe37 13092@item -ftree-phiprop
d77de738
ML
13093Perform hoisting of loads from conditional pointers on trees. This
13094pass is enabled by default at @option{-O1} and higher.
13095
d77de738 13096@opindex fhoist-adjacent-loads
ddf6fe37 13097@item -fhoist-adjacent-loads
d77de738
ML
13098Speculatively hoist loads from both branches of an if-then-else if the
13099loads are from adjacent locations in the same structure and the target
13100architecture has a conditional move instruction. This flag is enabled
13101by default at @option{-O2} and higher.
13102
d77de738 13103@opindex ftree-copy-prop
ddf6fe37 13104@item -ftree-copy-prop
d77de738
ML
13105Perform copy propagation on trees. This pass eliminates unnecessary
13106copy operations. This flag is enabled by default at @option{-O1} and
13107higher.
13108
d77de738 13109@opindex fipa-pure-const
ddf6fe37 13110@item -fipa-pure-const
d77de738
ML
13111Discover which functions are pure or constant.
13112Enabled by default at @option{-O1} and higher.
13113
d77de738 13114@opindex fipa-reference
ddf6fe37 13115@item -fipa-reference
d77de738
ML
13116Discover which static variables do not escape the
13117compilation unit.
13118Enabled by default at @option{-O1} and higher.
13119
d77de738 13120@opindex fipa-reference-addressable
ddf6fe37 13121@item -fipa-reference-addressable
d77de738
ML
13122Discover read-only, write-only and non-addressable static variables.
13123Enabled by default at @option{-O1} and higher.
13124
d77de738 13125@opindex fipa-stack-alignment
ddf6fe37 13126@item -fipa-stack-alignment
d77de738
ML
13127Reduce stack alignment on call sites if possible.
13128Enabled by default.
13129
d77de738 13130@opindex fipa-pta
ddf6fe37 13131@item -fipa-pta
d77de738
ML
13132Perform interprocedural pointer analysis and interprocedural modification
13133and reference analysis. This option can cause excessive memory and
13134compile-time usage on large compilation units. It is not enabled by
13135default at any optimization level.
13136
d77de738 13137@opindex fipa-profile
ddf6fe37 13138@item -fipa-profile
d77de738
ML
13139Perform interprocedural profile propagation. The functions called only from
13140cold functions are marked as cold. Also functions executed once (such as
13141@code{cold}, @code{noreturn}, static constructors or destructors) are
13142identified. Cold functions and loop less parts of functions executed once are
13143then optimized for size.
13144Enabled by default at @option{-O1} and higher.
13145
d77de738 13146@opindex fipa-modref
ddf6fe37 13147@item -fipa-modref
d77de738
ML
13148Perform interprocedural mod/ref analysis. This optimization analyzes the side
13149effects of functions (memory locations that are modified or referenced) and
13150enables better optimization across the function call boundary. This flag is
13151enabled by default at @option{-O1} and higher.
13152
d77de738 13153@opindex fipa-cp
ddf6fe37 13154@item -fipa-cp
d77de738
ML
13155Perform interprocedural constant propagation.
13156This optimization analyzes the program to determine when values passed
13157to functions are constants and then optimizes accordingly.
13158This optimization can substantially increase performance
13159if the application has constants passed to functions.
13160This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
13161It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13162
d77de738 13163@opindex fipa-cp-clone
ddf6fe37 13164@item -fipa-cp-clone
d77de738
ML
13165Perform function cloning to make interprocedural constant propagation stronger.
13166When enabled, interprocedural constant propagation performs function cloning
13167when externally visible function can be called with constant arguments.
13168Because this optimization can create multiple copies of functions,
13169it may significantly increase code size
13170(see @option{--param ipa-cp-unit-growth=@var{value}}).
13171This flag is enabled by default at @option{-O3}.
13172It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13173
d77de738 13174@opindex fipa-bit-cp
ddf6fe37 13175@item -fipa-bit-cp
d77de738
ML
13176When enabled, perform interprocedural bitwise constant
13177propagation. This flag is enabled by default at @option{-O2} and
13178by @option{-fprofile-use} and @option{-fauto-profile}.
13179It requires that @option{-fipa-cp} is enabled.
13180
d77de738 13181@opindex fipa-vrp
ddf6fe37 13182@item -fipa-vrp
d77de738
ML
13183When enabled, perform interprocedural propagation of value
13184ranges. This flag is enabled by default at @option{-O2}. It requires
13185that @option{-fipa-cp} is enabled.
13186
d77de738 13187@opindex fipa-icf
ddf6fe37 13188@item -fipa-icf
d77de738
ML
13189Perform Identical Code Folding for functions and read-only variables.
13190The optimization reduces code size and may disturb unwind stacks by replacing
13191a function by equivalent one with a different name. The optimization works
13192more effectively with link-time optimization enabled.
13193
13194Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13195works on different levels and thus the optimizations are not same - there are
13196equivalences that are found only by GCC and equivalences found only by Gold.
13197
13198This flag is enabled by default at @option{-O2} and @option{-Os}.
13199
d77de738 13200@opindex flive-patching
ddf6fe37 13201@item -flive-patching=@var{level}
d77de738
ML
13202Control GCC's optimizations to produce output suitable for live-patching.
13203
13204If the compiler's optimization uses a function's body or information extracted
13205from its body to optimize/change another function, the latter is called an
13206impacted function of the former. If a function is patched, its impacted
13207functions should be patched too.
13208
13209The impacted functions are determined by the compiler's interprocedural
13210optimizations. For example, a caller is impacted when inlining a function
13211into its caller,
13212cloning a function and changing its caller to call this new clone,
13213or extracting a function's pureness/constness information to optimize
13214its direct or indirect callers, etc.
13215
13216Usually, the more IPA optimizations enabled, the larger the number of
13217impacted functions for each function. In order to control the number of
13218impacted functions and more easily compute the list of impacted function,
13219IPA optimizations can be partially enabled at two different levels.
13220
13221The @var{level} argument should be one of the following:
13222
13223@table @samp
13224
13225@item inline-clone
13226
13227Only enable inlining and cloning optimizations, which includes inlining,
13228cloning, interprocedural scalar replacement of aggregates and partial inlining.
13229As a result, when patching a function, all its callers and its clones'
13230callers are impacted, therefore need to be patched as well.
13231
13232@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
13233@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13234-fipa-icf -fipa-icf-functions -fipa-icf-variables
13235-fipa-bit-cp -fipa-vrp -fipa-pure-const
13236-fipa-reference-addressable
d77de738
ML
13237-fipa-stack-alignment -fipa-modref}
13238
13239@item inline-only-static
13240
13241Only enable inlining of static functions.
13242As a result, when patching a static function, all its callers are impacted
13243and so need to be patched as well.
13244
13245In addition to all the flags that @option{-flive-patching=inline-clone}
13246disables,
13247@option{-flive-patching=inline-only-static} disables the following additional
13248optimization flags:
13249@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13250
13251@end table
13252
13253When @option{-flive-patching} is specified without any value, the default value
13254is @var{inline-clone}.
13255
13256This flag is disabled by default.
13257
13258Note that @option{-flive-patching} is not supported with link-time optimization
13259(@option{-flto}).
13260
d77de738 13261@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13262@item -fisolate-erroneous-paths-dereference
d77de738
ML
13263Detect paths that trigger erroneous or undefined behavior due to
13264dereferencing a null pointer. Isolate those paths from the main control
13265flow and turn the statement with erroneous or undefined behavior into a trap.
13266This flag is enabled by default at @option{-O2} and higher and depends on
13267@option{-fdelete-null-pointer-checks} also being enabled.
13268
d77de738 13269@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13270@item -fisolate-erroneous-paths-attribute
d77de738
ML
13271Detect paths that trigger erroneous or undefined behavior due to a null value
13272being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13273attribute. Isolate those paths from the main control flow and turn the
13274statement with erroneous or undefined behavior into a trap. This is not
13275currently enabled, but may be enabled by @option{-O2} in the future.
13276
d77de738 13277@opindex ftree-sink
ddf6fe37 13278@item -ftree-sink
d77de738
ML
13279Perform forward store motion on trees. This flag is
13280enabled by default at @option{-O1} and higher.
13281
d77de738 13282@opindex ftree-bit-ccp
ddf6fe37 13283@item -ftree-bit-ccp
d77de738
ML
13284Perform sparse conditional bit constant propagation on trees and propagate
13285pointer alignment information.
13286This pass only operates on local scalar variables and is enabled by default
13287at @option{-O1} and higher, except for @option{-Og}.
13288It requires that @option{-ftree-ccp} is enabled.
13289
d77de738 13290@opindex ftree-ccp
ddf6fe37 13291@item -ftree-ccp
d77de738
ML
13292Perform sparse conditional constant propagation (CCP) on trees. This
13293pass only operates on local scalar variables and is enabled by default
13294at @option{-O1} and higher.
13295
d77de738 13296@opindex fssa-backprop
ddf6fe37 13297@item -fssa-backprop
d77de738
ML
13298Propagate information about uses of a value up the definition chain
13299in order to simplify the definitions. For example, this pass strips
13300sign operations if the sign of a value never matters. The flag is
13301enabled by default at @option{-O1} and higher.
13302
d77de738 13303@opindex fssa-phiopt
ddf6fe37 13304@item -fssa-phiopt
d77de738
ML
13305Perform pattern matching on SSA PHI nodes to optimize conditional
13306code. This pass is enabled by default at @option{-O1} and higher,
13307except for @option{-Og}.
13308
d77de738 13309@opindex ftree-switch-conversion
ddf6fe37 13310@item -ftree-switch-conversion
d77de738
ML
13311Perform conversion of simple initializations in a switch to
13312initializations from a scalar array. This flag is enabled by default
13313at @option{-O2} and higher.
13314
d77de738 13315@opindex ftree-tail-merge
ddf6fe37 13316@item -ftree-tail-merge
d77de738
ML
13317Look for identical code sequences. When found, replace one with a jump to the
13318other. This optimization is known as tail merging or cross jumping. This flag
13319is enabled by default at @option{-O2} and higher. The compilation time
13320in this pass can
13321be limited using @option{max-tail-merge-comparisons} parameter and
13322@option{max-tail-merge-iterations} parameter.
13323
d77de738 13324@opindex ftree-dce
ddf6fe37 13325@item -ftree-dce
d77de738
ML
13326Perform dead code elimination (DCE) on trees. This flag is enabled by
13327default at @option{-O1} and higher.
13328
d77de738 13329@opindex ftree-builtin-call-dce
ddf6fe37 13330@item -ftree-builtin-call-dce
d77de738
ML
13331Perform conditional dead code elimination (DCE) for calls to built-in functions
13332that may set @code{errno} but are otherwise free of side effects. This flag is
13333enabled by default at @option{-O2} and higher if @option{-Os} is not also
13334specified.
13335
d77de738
ML
13336@opindex ffinite-loops
13337@opindex fno-finite-loops
ddf6fe37 13338@item -ffinite-loops
d77de738
ML
13339Assume that a loop with an exit will eventually take the exit and not loop
13340indefinitely. This allows the compiler to remove loops that otherwise have
13341no side-effects, not considering eventual endless looping as such.
13342
13343This option is enabled by default at @option{-O2} for C++ with -std=c++11
13344or higher.
13345
d77de738 13346@opindex ftree-dominator-opts
ddf6fe37 13347@item -ftree-dominator-opts
d77de738
ML
13348Perform a variety of simple scalar cleanups (constant/copy
13349propagation, redundancy elimination, range propagation and expression
13350simplification) based on a dominator tree traversal. This also
13351performs jump threading (to reduce jumps to jumps). This flag is
13352enabled by default at @option{-O1} and higher.
13353
d77de738 13354@opindex ftree-dse
ddf6fe37 13355@item -ftree-dse
d77de738
ML
13356Perform dead store elimination (DSE) on trees. A dead store is a store into
13357a memory location that is later overwritten by another store without
13358any intervening loads. In this case the earlier store can be deleted. This
13359flag is enabled by default at @option{-O1} and higher.
13360
d77de738 13361@opindex ftree-ch
ddf6fe37 13362@item -ftree-ch
d77de738
ML
13363Perform loop header copying on trees. This is beneficial since it increases
13364effectiveness of code motion optimizations. It also saves one jump. This flag
13365is enabled by default at @option{-O1} and higher. It is not enabled
13366for @option{-Os}, since it usually increases code size.
13367
d77de738 13368@opindex ftree-loop-optimize
ddf6fe37 13369@item -ftree-loop-optimize
d77de738
ML
13370Perform loop optimizations on trees. This flag is enabled by default
13371at @option{-O1} and higher.
13372
d77de738
ML
13373@opindex ftree-loop-linear
13374@opindex floop-strip-mine
13375@opindex floop-block
ddf6fe37
AA
13376@item -ftree-loop-linear
13377@itemx -floop-strip-mine
13378@itemx -floop-block
d77de738
ML
13379Perform loop nest optimizations. Same as
13380@option{-floop-nest-optimize}. To use this code transformation, GCC has
13381to be configured with @option{--with-isl} to enable the Graphite loop
13382transformation infrastructure.
13383
d77de738 13384@opindex fgraphite-identity
ddf6fe37 13385@item -fgraphite-identity
d77de738
ML
13386Enable the identity transformation for graphite. For every SCoP we generate
13387the polyhedral representation and transform it back to gimple. Using
13388@option{-fgraphite-identity} we can check the costs or benefits of the
13389GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13390are also performed by the code generator isl, like index splitting and
13391dead code elimination in loops.
13392
d77de738 13393@opindex floop-nest-optimize
ddf6fe37 13394@item -floop-nest-optimize
d77de738
ML
13395Enable the isl based loop nest optimizer. This is a generic loop nest
13396optimizer based on the Pluto optimization algorithms. It calculates a loop
13397structure optimized for data-locality and parallelism. This option
13398is experimental.
13399
d77de738 13400@opindex floop-parallelize-all
ddf6fe37 13401@item -floop-parallelize-all
d77de738
ML
13402Use the Graphite data dependence analysis to identify loops that can
13403be parallelized. Parallelize all the loops that can be analyzed to
13404not contain loop carried dependences without checking that it is
13405profitable to parallelize the loops.
13406
d77de738 13407@opindex ftree-coalesce-vars
ddf6fe37 13408@item -ftree-coalesce-vars
d77de738
ML
13409While transforming the program out of the SSA representation, attempt to
13410reduce copying by coalescing versions of different user-defined
13411variables, instead of just compiler temporaries. This may severely
13412limit the ability to debug an optimized program compiled with
13413@option{-fno-var-tracking-assignments}. In the negated form, this flag
13414prevents SSA coalescing of user variables. This option is enabled by
13415default if optimization is enabled, and it does very little otherwise.
13416
d77de738 13417@opindex ftree-loop-if-convert
ddf6fe37 13418@item -ftree-loop-if-convert
d77de738
ML
13419Attempt to transform conditional jumps in the innermost loops to
13420branch-less equivalents. The intent is to remove control-flow from
13421the innermost loops in order to improve the ability of the
13422vectorization pass to handle these loops. This is enabled by default
13423if vectorization is enabled.
13424
d77de738 13425@opindex ftree-loop-distribution
ddf6fe37 13426@item -ftree-loop-distribution
d77de738
ML
13427Perform loop distribution. This flag can improve cache performance on
13428big loop bodies and allow further loop optimizations, like
13429parallelization or vectorization, to take place. For example, the loop
13430@smallexample
13431DO I = 1, N
13432 A(I) = B(I) + C
13433 D(I) = E(I) * F
13434ENDDO
13435@end smallexample
13436is transformed to
13437@smallexample
13438DO I = 1, N
13439 A(I) = B(I) + C
13440ENDDO
13441DO I = 1, N
13442 D(I) = E(I) * F
13443ENDDO
13444@end smallexample
13445This flag is enabled by default at @option{-O3}.
13446It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13447
d77de738 13448@opindex ftree-loop-distribute-patterns
ddf6fe37 13449@item -ftree-loop-distribute-patterns
d77de738
ML
13450Perform loop distribution of patterns that can be code generated with
13451calls to a library. This flag is enabled by default at @option{-O2} and
13452higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13453
13454This pass distributes the initialization loops and generates a call to
13455memset zero. For example, the loop
13456@smallexample
13457DO I = 1, N
13458 A(I) = 0
13459 B(I) = A(I) + I
13460ENDDO
13461@end smallexample
13462is transformed to
13463@smallexample
13464DO I = 1, N
13465 A(I) = 0
13466ENDDO
13467DO I = 1, N
13468 B(I) = A(I) + I
13469ENDDO
13470@end smallexample
13471and the initialization loop is transformed into a call to memset zero.
13472This flag is enabled by default at @option{-O3}.
13473It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13474
d77de738 13475@opindex floop-interchange
ddf6fe37 13476@item -floop-interchange
d77de738
ML
13477Perform loop interchange outside of graphite. This flag can improve cache
13478performance on loop nest and allow further loop optimizations, like
13479vectorization, to take place. For example, the loop
13480@smallexample
13481for (int i = 0; i < N; i++)
13482 for (int j = 0; j < N; j++)
13483 for (int k = 0; k < N; k++)
13484 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13485@end smallexample
13486is transformed to
13487@smallexample
13488for (int i = 0; i < N; i++)
13489 for (int k = 0; k < N; k++)
13490 for (int j = 0; j < N; j++)
13491 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13492@end smallexample
13493This flag is enabled by default at @option{-O3}.
13494It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13495
d77de738 13496@opindex floop-unroll-and-jam
ddf6fe37 13497@item -floop-unroll-and-jam
d77de738
ML
13498Apply unroll and jam transformations on feasible loops. In a loop
13499nest this unrolls the outer loop by some factor and fuses the resulting
13500multiple inner loops. This flag is enabled by default at @option{-O3}.
13501It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13502
d77de738 13503@opindex ftree-loop-im
ddf6fe37 13504@item -ftree-loop-im
d77de738
ML
13505Perform loop invariant motion on trees. This pass moves only invariants that
13506are hard to handle at RTL level (function calls, operations that expand to
13507nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13508operands of conditions that are invariant out of the loop, so that we can use
13509just trivial invariantness analysis in loop unswitching. The pass also includes
13510store motion.
13511
d77de738 13512@opindex ftree-loop-ivcanon
ddf6fe37 13513@item -ftree-loop-ivcanon
d77de738
ML
13514Create a canonical counter for number of iterations in loops for which
13515determining number of iterations requires complicated analysis. Later
13516optimizations then may determine the number easily. Useful especially
13517in connection with unrolling.
13518
d77de738 13519@opindex ftree-scev-cprop
ddf6fe37 13520@item -ftree-scev-cprop
d77de738
ML
13521Perform final value replacement. If a variable is modified in a loop
13522in such a way that its value when exiting the loop can be determined using
13523only its initial value and the number of loop iterations, replace uses of
13524the final value by such a computation, provided it is sufficiently cheap.
13525This reduces data dependencies and may allow further simplifications.
13526Enabled by default at @option{-O1} and higher.
13527
d77de738 13528@opindex fivopts
ddf6fe37 13529@item -fivopts
d77de738
ML
13530Perform induction variable optimizations (strength reduction, induction
13531variable merging and induction variable elimination) on trees.
13532
d77de738 13533@opindex ftree-parallelize-loops
ddf6fe37 13534@item -ftree-parallelize-loops=n
d77de738
ML
13535Parallelize loops, i.e., split their iteration space to run in n threads.
13536This is only possible for loops whose iterations are independent
13537and can be arbitrarily reordered. The optimization is only
13538profitable on multiprocessor machines, for loops that are CPU-intensive,
13539rather than constrained e.g.@: by memory bandwidth. This option
13540implies @option{-pthread}, and thus is only supported on targets
13541that have support for @option{-pthread}.
13542
d77de738 13543@opindex ftree-pta
ddf6fe37 13544@item -ftree-pta
d77de738
ML
13545Perform function-local points-to analysis on trees. This flag is
13546enabled by default at @option{-O1} and higher, except for @option{-Og}.
13547
d77de738 13548@opindex ftree-sra
ddf6fe37 13549@item -ftree-sra
d77de738
ML
13550Perform scalar replacement of aggregates. This pass replaces structure
13551references with scalars to prevent committing structures to memory too
13552early. This flag is enabled by default at @option{-O1} and higher,
13553except for @option{-Og}.
13554
d77de738 13555@opindex fstore-merging
ddf6fe37 13556@item -fstore-merging
d77de738
ML
13557Perform merging of narrow stores to consecutive memory addresses. This pass
13558merges contiguous stores of immediate values narrower than a word into fewer
13559wider stores to reduce the number of instructions. This is enabled by default
13560at @option{-O2} and higher as well as @option{-Os}.
13561
d77de738 13562@opindex ftree-ter
ddf6fe37 13563@item -ftree-ter
d77de738
ML
13564Perform temporary expression replacement during the SSA->normal phase. Single
13565use/single def temporaries are replaced at their use location with their
13566defining expression. This results in non-GIMPLE code, but gives the expanders
13567much more complex trees to work on resulting in better RTL generation. This is
13568enabled by default at @option{-O1} and higher.
13569
d77de738 13570@opindex ftree-slsr
ddf6fe37 13571@item -ftree-slsr
d77de738
ML
13572Perform straight-line strength reduction on trees. This recognizes related
13573expressions involving multiplications and replaces them by less expensive
13574calculations when possible. This is enabled by default at @option{-O1} and
13575higher.
13576
d77de738 13577@opindex ftree-vectorize
ddf6fe37 13578@item -ftree-vectorize
d77de738
ML
13579Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13580and @option{-ftree-slp-vectorize} if not explicitly specified.
13581
d77de738 13582@opindex ftree-loop-vectorize
ddf6fe37 13583@item -ftree-loop-vectorize
d77de738
ML
13584Perform loop vectorization on trees. This flag is enabled by default at
13585@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13586and @option{-fauto-profile}.
13587
d77de738 13588@opindex ftree-slp-vectorize
ddf6fe37 13589@item -ftree-slp-vectorize
d77de738
ML
13590Perform basic block vectorization on trees. This flag is enabled by default at
13591@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13592and @option{-fauto-profile}.
13593
d77de738 13594@opindex ftrivial-auto-var-init
ddf6fe37 13595@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13596Initialize automatic variables with either a pattern or with zeroes to increase
13597the security and predictability of a program by preventing uninitialized memory
13598disclosure and use.
13599GCC still considers an automatic variable that doesn't have an explicit
13600initializer as uninitialized, @option{-Wuninitialized} and
13601@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13602warning messages on such automatic variables and the compiler will
13603perform optimization as if the variable were uninitialized.
d77de738
ML
13604With this option, GCC will also initialize any padding of automatic variables
13605that have structure or union types to zeroes.
13606However, the current implementation cannot initialize automatic variables that
13607are declared between the controlling expression and the first case of a
13608@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13609such cases.
13610
13611The three values of @var{choice} are:
13612
13613@itemize @bullet
13614@item
13615@samp{uninitialized} doesn't initialize any automatic variables.
13616This is C and C++'s default.
13617
13618@item
13619@samp{pattern} Initialize automatic variables with values which will likely
13620transform logic bugs into crashes down the line, are easily recognized in a
13621crash dump and without being values that programmers can rely on for useful
13622program semantics.
13623The current value is byte-repeatable pattern with byte "0xFE".
13624The values used for pattern initialization might be changed in the future.
13625
13626@item
13627@samp{zero} Initialize automatic variables with zeroes.
13628@end itemize
13629
13630The default is @samp{uninitialized}.
13631
13632You can control this behavior for a specific variable by using the variable
13633attribute @code{uninitialized} (@pxref{Variable Attributes}).
13634
d77de738 13635@opindex fvect-cost-model
ddf6fe37 13636@item -fvect-cost-model=@var{model}
d77de738
ML
13637Alter the cost model used for vectorization. The @var{model} argument
13638should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13639@samp{very-cheap}.
13640With the @samp{unlimited} model the vectorized code-path is assumed
13641to be profitable while with the @samp{dynamic} model a runtime check
13642guards the vectorized code-path to enable it only for iteration
13643counts that will likely execute faster than when executing the original
13644scalar loop. The @samp{cheap} model disables vectorization of
13645loops where doing so would be cost prohibitive for example due to
13646required runtime checks for data dependence or alignment but otherwise
13647is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13648allows vectorization if the vector code would entirely replace the
13649scalar code that is being vectorized. For example, if each iteration
13650of a vectorized loop would only be able to handle exactly four iterations
13651of the scalar loop, the @samp{very-cheap} model would only allow
13652vectorization if the scalar iteration count is known to be a multiple
13653of four.
13654
13655The default cost model depends on other optimization flags and is
13656either @samp{dynamic} or @samp{cheap}.
13657
d77de738 13658@opindex fsimd-cost-model
ddf6fe37 13659@item -fsimd-cost-model=@var{model}
d77de738
ML
13660Alter the cost model used for vectorization of loops marked with the OpenMP
13661simd directive. The @var{model} argument should be one of
13662@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13663have the same meaning as described in @option{-fvect-cost-model} and by
13664default a cost model defined with @option{-fvect-cost-model} is used.
13665
d77de738 13666@opindex ftree-vrp
ddf6fe37 13667@item -ftree-vrp
d77de738
ML
13668Perform Value Range Propagation on trees. This is similar to the
13669constant propagation pass, but instead of values, ranges of values are
13670propagated. This allows the optimizers to remove unnecessary range
13671checks like array bound checks and null pointer checks. This is
13672enabled by default at @option{-O2} and higher. Null pointer check
13673elimination is only done if @option{-fdelete-null-pointer-checks} is
13674enabled.
13675
d77de738 13676@opindex fsplit-paths
ddf6fe37 13677@item -fsplit-paths
d77de738
ML
13678Split paths leading to loop backedges. This can improve dead code
13679elimination and common subexpression elimination. This is enabled by
13680default at @option{-O3} and above.
13681
d77de738 13682@opindex fsplit-ivs-in-unroller
ddf6fe37 13683@item -fsplit-ivs-in-unroller
d77de738
ML
13684Enables expression of values of induction variables in later iterations
13685of the unrolled loop using the value in the first iteration. This breaks
13686long dependency chains, thus improving efficiency of the scheduling passes.
13687
13688A combination of @option{-fweb} and CSE is often sufficient to obtain the
13689same effect. However, that is not reliable in cases where the loop body
13690is more complicated than a single basic block. It also does not work at all
13691on some architectures due to restrictions in the CSE pass.
13692
13693This optimization is enabled by default.
13694
d77de738 13695@opindex fvariable-expansion-in-unroller
ddf6fe37 13696@item -fvariable-expansion-in-unroller
d77de738
ML
13697With this option, the compiler creates multiple copies of some
13698local variables when unrolling a loop, which can result in superior code.
13699
13700This optimization is enabled by default for PowerPC targets, but disabled
13701by default otherwise.
13702
d77de738 13703@opindex fpartial-inlining
ddf6fe37 13704@item -fpartial-inlining
d77de738
ML
13705Inline parts of functions. This option has any effect only
13706when inlining itself is turned on by the @option{-finline-functions}
13707or @option{-finline-small-functions} options.
13708
13709Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13710
d77de738 13711@opindex fpredictive-commoning
ddf6fe37 13712@item -fpredictive-commoning
d77de738
ML
13713Perform predictive commoning optimization, i.e., reusing computations
13714(especially memory loads and stores) performed in previous
13715iterations of loops.
13716
13717This option is enabled at level @option{-O3}.
13718It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13719
d77de738 13720@opindex fprefetch-loop-arrays
ddf6fe37 13721@item -fprefetch-loop-arrays
d77de738
ML
13722If supported by the target machine, generate instructions to prefetch
13723memory to improve the performance of loops that access large arrays.
13724
13725This option may generate better or worse code; results are highly
13726dependent on the structure of loops within the source code.
13727
13728Disabled at level @option{-Os}.
13729
d77de738
ML
13730@opindex fno-printf-return-value
13731@opindex fprintf-return-value
ddf6fe37 13732@item -fno-printf-return-value
d77de738
ML
13733Do not substitute constants for known return value of formatted output
13734functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13735@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13736transformation allows GCC to optimize or even eliminate branches based
13737on the known return value of these functions called with arguments that
13738are either constant, or whose values are known to be in a range that
13739makes determining the exact return value possible. For example, when
13740@option{-fprintf-return-value} is in effect, both the branch and the
13741body of the @code{if} statement (but not the call to @code{snprint})
13742can be optimized away when @code{i} is a 32-bit or smaller integer
13743because the return value is guaranteed to be at most 8.
13744
13745@smallexample
13746char buf[9];
13747if (snprintf (buf, "%08x", i) >= sizeof buf)
13748 @dots{}
13749@end smallexample
13750
13751The @option{-fprintf-return-value} option relies on other optimizations
13752and yields best results with @option{-O2} and above. It works in tandem
13753with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13754options. The @option{-fprintf-return-value} option is enabled by default.
13755
d77de738
ML
13756@opindex fno-peephole
13757@opindex fpeephole
13758@opindex fno-peephole2
13759@opindex fpeephole2
ddf6fe37
AA
13760@item -fno-peephole
13761@itemx -fno-peephole2
d77de738
ML
13762Disable any machine-specific peephole optimizations. The difference
13763between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13764are implemented in the compiler; some targets use one, some use the
13765other, a few use both.
13766
13767@option{-fpeephole} is enabled by default.
13768@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13769
d77de738
ML
13770@opindex fno-guess-branch-probability
13771@opindex fguess-branch-probability
ddf6fe37 13772@item -fno-guess-branch-probability
d77de738
ML
13773Do not guess branch probabilities using heuristics.
13774
13775GCC uses heuristics to guess branch probabilities if they are
13776not provided by profiling feedback (@option{-fprofile-arcs}). These
13777heuristics are based on the control flow graph. If some branch probabilities
13778are specified by @code{__builtin_expect}, then the heuristics are
13779used to guess branch probabilities for the rest of the control flow graph,
13780taking the @code{__builtin_expect} info into account. The interactions
13781between the heuristics and @code{__builtin_expect} can be complex, and in
13782some cases, it may be useful to disable the heuristics so that the effects
13783of @code{__builtin_expect} are easier to understand.
13784
13785It is also possible to specify expected probability of the expression
13786with @code{__builtin_expect_with_probability} built-in function.
13787
13788The default is @option{-fguess-branch-probability} at levels
13789@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13790
d77de738 13791@opindex freorder-blocks
ddf6fe37 13792@item -freorder-blocks
d77de738
ML
13793Reorder basic blocks in the compiled function in order to reduce number of
13794taken branches and improve code locality.
13795
13796Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13797
d77de738 13798@opindex freorder-blocks-algorithm
ddf6fe37 13799@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13800Use the specified algorithm for basic block reordering. The
13801@var{algorithm} argument can be @samp{simple}, which does not increase
13802code size (except sometimes due to secondary effects like alignment),
13803or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13804put all often executed code together, minimizing the number of branches
13805executed by making extra copies of code.
13806
13807The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13808@samp{stc} at levels @option{-O2}, @option{-O3}.
13809
d77de738 13810@opindex freorder-blocks-and-partition
ddf6fe37 13811@item -freorder-blocks-and-partition
d77de738
ML
13812In addition to reordering basic blocks in the compiled function, in order
13813to reduce number of taken branches, partitions hot and cold basic blocks
13814into separate sections of the assembly and @file{.o} files, to improve
13815paging and cache locality performance.
13816
13817This optimization is automatically turned off in the presence of
13818exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13819section attribute and on any architecture that does not support named
13820sections. When @option{-fsplit-stack} is used this option is not
13821enabled by default (to avoid linker errors), but may be enabled
13822explicitly (if using a working linker).
13823
13824Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13825
d77de738 13826@opindex freorder-functions
ddf6fe37 13827@item -freorder-functions
d77de738
ML
13828Reorder functions in the object file in order to
13829improve code locality. This is implemented by using special
13830subsections @code{.text.hot} for most frequently executed functions and
13831@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13832the linker so object file format must support named sections and linker must
13833place them in a reasonable way.
13834
13835This option isn't effective unless you either provide profile feedback
13836(see @option{-fprofile-arcs} for details) or manually annotate functions with
13837@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13838
13839Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13840
d77de738 13841@opindex fstrict-aliasing
ddf6fe37 13842@item -fstrict-aliasing
d77de738
ML
13843Allow the compiler to assume the strictest aliasing rules applicable to
13844the language being compiled. For C (and C++), this activates
13845optimizations based on the type of expressions. In particular, an
13846object of one type is assumed never to reside at the same address as an
13847object of a different type, unless the types are almost the same. For
13848example, an @code{unsigned int} can alias an @code{int}, but not a
13849@code{void*} or a @code{double}. A character type may alias any other
13850type.
13851
13852@anchor{Type-punning}Pay special attention to code like this:
13853@smallexample
13854union a_union @{
13855 int i;
13856 double d;
13857@};
13858
13859int f() @{
13860 union a_union t;
13861 t.d = 3.0;
13862 return t.i;
13863@}
13864@end smallexample
13865The practice of reading from a different union member than the one most
13866recently written to (called ``type-punning'') is common. Even with
13867@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13868is accessed through the union type. So, the code above works as
13869expected. @xref{Structures unions enumerations and bit-fields
13870implementation}. However, this code might not:
13871@smallexample
13872int f() @{
13873 union a_union t;
13874 int* ip;
13875 t.d = 3.0;
13876 ip = &t.i;
13877 return *ip;
13878@}
13879@end smallexample
13880
13881Similarly, access by taking the address, casting the resulting pointer
13882and dereferencing the result has undefined behavior, even if the cast
13883uses a union type, e.g.:
13884@smallexample
13885int f() @{
13886 double d = 3.0;
13887 return ((union a_union *) &d)->i;
13888@}
13889@end smallexample
13890
13891The @option{-fstrict-aliasing} option is enabled at levels
13892@option{-O2}, @option{-O3}, @option{-Os}.
13893
d77de738 13894@opindex fipa-strict-aliasing
ddf6fe37 13895@item -fipa-strict-aliasing
d77de738
ML
13896Controls whether rules of @option{-fstrict-aliasing} are applied across
13897function boundaries. Note that if multiple functions gets inlined into a
13898single function the memory accesses are no longer considered to be crossing a
13899function boundary.
13900
13901The @option{-fipa-strict-aliasing} option is enabled by default and is
13902effective only in combination with @option{-fstrict-aliasing}.
13903
ddf6fe37 13904@opindex falign-functions
d77de738
ML
13905@item -falign-functions
13906@itemx -falign-functions=@var{n}
13907@itemx -falign-functions=@var{n}:@var{m}
13908@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13909@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13910Align the start of functions to the next power-of-two greater than or
13911equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13912least the first @var{m} bytes of the function can be fetched by the CPU
13913without crossing an @var{n}-byte alignment boundary.
13914
13915If @var{m} is not specified, it defaults to @var{n}.
13916
13917Examples: @option{-falign-functions=32} aligns functions to the next
1391832-byte boundary, @option{-falign-functions=24} aligns to the next
1391932-byte boundary only if this can be done by skipping 23 bytes or less,
13920@option{-falign-functions=32:7} aligns to the next
1392132-byte boundary only if this can be done by skipping 6 bytes or less.
13922
13923The second pair of @var{n2}:@var{m2} values allows you to specify
13924a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13925the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13926otherwise aligns to the next 32-byte boundary if this can be done
13927by skipping 2 bytes or less.
13928If @var{m2} is not specified, it defaults to @var{n2}.
13929
13930Some assemblers only support this flag when @var{n} is a power of two;
13931in that case, it is rounded up.
13932
13933@option{-fno-align-functions} and @option{-falign-functions=1} are
13934equivalent and mean that functions are not aligned.
13935
13936If @var{n} is not specified or is zero, use a machine-dependent default.
13937The maximum allowed @var{n} option value is 65536.
13938
13939Enabled at levels @option{-O2}, @option{-O3}.
13940
13941@item -flimit-function-alignment
13942If this option is enabled, the compiler tries to avoid unnecessarily
13943overaligning functions. It attempts to instruct the assembler to align
13944by the amount specified by @option{-falign-functions}, but not to
13945skip more bytes than the size of the function.
13946
ddf6fe37 13947@opindex falign-labels
d77de738
ML
13948@item -falign-labels
13949@itemx -falign-labels=@var{n}
13950@itemx -falign-labels=@var{n}:@var{m}
13951@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13952@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13953Align all branch targets to a power-of-two boundary.
13954
13955Parameters of this option are analogous to the @option{-falign-functions} option.
13956@option{-fno-align-labels} and @option{-falign-labels=1} are
13957equivalent and mean that labels are not aligned.
13958
13959If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13960are greater than this value, then their values are used instead.
13961
13962If @var{n} is not specified or is zero, use a machine-dependent default
13963which is very likely to be @samp{1}, meaning no alignment.
13964The maximum allowed @var{n} option value is 65536.
13965
13966Enabled at levels @option{-O2}, @option{-O3}.
13967
ddf6fe37 13968@opindex falign-loops
d77de738
ML
13969@item -falign-loops
13970@itemx -falign-loops=@var{n}
13971@itemx -falign-loops=@var{n}:@var{m}
13972@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13973@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13974Align loops to a power-of-two boundary. If the loops are executed
13975many times, this makes up for any execution of the dummy padding
13976instructions.
13977
13978If @option{-falign-labels} is greater than this value, then its value
13979is used instead.
13980
13981Parameters of this option are analogous to the @option{-falign-functions} option.
13982@option{-fno-align-loops} and @option{-falign-loops=1} are
13983equivalent and mean that loops are not aligned.
13984The maximum allowed @var{n} option value is 65536.
13985
13986If @var{n} is not specified or is zero, use a machine-dependent default.
13987
13988Enabled at levels @option{-O2}, @option{-O3}.
13989
ddf6fe37 13990@opindex falign-jumps
d77de738
ML
13991@item -falign-jumps
13992@itemx -falign-jumps=@var{n}
13993@itemx -falign-jumps=@var{n}:@var{m}
13994@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13995@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13996Align branch targets to a power-of-two boundary, for branch targets
13997where the targets can only be reached by jumping. In this case,
13998no dummy operations need be executed.
13999
14000If @option{-falign-labels} is greater than this value, then its value
14001is used instead.
14002
14003Parameters of this option are analogous to the @option{-falign-functions} option.
14004@option{-fno-align-jumps} and @option{-falign-jumps=1} are
14005equivalent and mean that loops are not aligned.
14006
14007If @var{n} is not specified or is zero, use a machine-dependent default.
14008The maximum allowed @var{n} option value is 65536.
14009
14010Enabled at levels @option{-O2}, @option{-O3}.
14011
d77de738 14012@opindex fno-allocation-dce
ddf6fe37 14013@item -fno-allocation-dce
d77de738
ML
14014Do not remove unused C++ allocations in dead code elimination.
14015
d77de738 14016@opindex fallow-store-data-races
ddf6fe37 14017@item -fallow-store-data-races
d77de738
ML
14018Allow the compiler to perform optimizations that may introduce new data races
14019on stores, without proving that the variable cannot be concurrently accessed
14020by other threads. Does not affect optimization of local data. It is safe to
14021use this option if it is known that global data will not be accessed by
14022multiple threads.
14023
14024Examples of optimizations enabled by @option{-fallow-store-data-races} include
14025hoisting or if-conversions that may cause a value that was already in memory
14026to be re-written with that same value. Such re-writing is safe in a single
14027threaded context but may be unsafe in a multi-threaded context. Note that on
14028some processors, if-conversions may be required in order to enable
14029vectorization.
14030
14031Enabled at level @option{-Ofast}.
14032
d77de738 14033@opindex funit-at-a-time
ddf6fe37 14034@item -funit-at-a-time
d77de738
ML
14035This option is left for compatibility reasons. @option{-funit-at-a-time}
14036has no effect, while @option{-fno-unit-at-a-time} implies
14037@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
14038
14039Enabled by default.
14040
d77de738
ML
14041@opindex fno-toplevel-reorder
14042@opindex ftoplevel-reorder
ddf6fe37 14043@item -fno-toplevel-reorder
d77de738
ML
14044Do not reorder top-level functions, variables, and @code{asm}
14045statements. Output them in the same order that they appear in the
14046input file. When this option is used, unreferenced static variables
14047are not removed. This option is intended to support existing code
14048that relies on a particular ordering. For new code, it is better to
14049use attributes when possible.
14050
14051@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
14052also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
14053Additionally @option{-fno-toplevel-reorder} implies
14054@option{-fno-section-anchors}.
14055
d77de738 14056@opindex funreachable-traps
ddf6fe37 14057@item -funreachable-traps
d77de738
ML
14058With this option, the compiler turns calls to
14059@code{__builtin_unreachable} into traps, instead of using them for
14060optimization. This also affects any such calls implicitly generated
14061by the compiler.
14062
14063This option has the same effect as @option{-fsanitize=unreachable
14064-fsanitize-trap=unreachable}, but does not affect the values of those
14065options. If @option{-fsanitize=unreachable} is enabled, that option
14066takes priority over this one.
14067
14068This option is enabled by default at @option{-O0} and @option{-Og}.
14069
d77de738 14070@opindex fweb
ddf6fe37 14071@item -fweb
d77de738
ML
14072Constructs webs as commonly used for register allocation purposes and assign
14073each web individual pseudo register. This allows the register allocation pass
14074to operate on pseudos directly, but also strengthens several other optimization
14075passes, such as CSE, loop optimizer and trivial dead code remover. It can,
14076however, make debugging impossible, since variables no longer stay in a
14077``home register''.
14078
14079Enabled by default with @option{-funroll-loops}.
14080
d77de738 14081@opindex fwhole-program
ddf6fe37 14082@item -fwhole-program
d77de738
ML
14083Assume that the current compilation unit represents the whole program being
14084compiled. All public functions and variables with the exception of @code{main}
14085and those merged by attribute @code{externally_visible} become static functions
14086and in effect are optimized more aggressively by interprocedural optimizers.
14087
39ebd3a9
JH
14088With @option{-flto} this option has a limited use. In most cases the
14089precise list of symbols used or exported from the binary is known the
14090resolution info passed to the link-time optimizer by the linker plugin. It is
14091still useful if no linker plugin is used or during incremental link step when
14092final code is produced (with @option{-flto}
14093@option{-flinker-output=nolto-rel}).
d77de738 14094
d77de738 14095@opindex flto
ddf6fe37 14096@item -flto[=@var{n}]
d77de738
ML
14097This option runs the standard link-time optimizer. When invoked
14098with source code, it generates GIMPLE (one of GCC's internal
14099representations) and writes it to special ELF sections in the object
14100file. When the object files are linked together, all the function
14101bodies are read from these ELF sections and instantiated as if they
14102had been part of the same translation unit.
14103
14104To use the link-time optimizer, @option{-flto} and optimization
14105options should be specified at compile time and during the final link.
14106It is recommended that you compile all the files participating in the
14107same link with the same options and also specify those options at
14108link time.
14109For example:
14110
14111@smallexample
14112gcc -c -O2 -flto foo.c
14113gcc -c -O2 -flto bar.c
14114gcc -o myprog -flto -O2 foo.o bar.o
14115@end smallexample
14116
14117The first two invocations to GCC save a bytecode representation
14118of GIMPLE into special ELF sections inside @file{foo.o} and
14119@file{bar.o}. The final invocation reads the GIMPLE bytecode from
14120@file{foo.o} and @file{bar.o}, merges the two files into a single
14121internal image, and compiles the result as usual. Since both
14122@file{foo.o} and @file{bar.o} are merged into a single image, this
14123causes all the interprocedural analyses and optimizations in GCC to
14124work across the two files as if they were a single one. This means,
14125for example, that the inliner is able to inline functions in
14126@file{bar.o} into functions in @file{foo.o} and vice-versa.
14127
14128Another (simpler) way to enable link-time optimization is:
14129
14130@smallexample
14131gcc -o myprog -flto -O2 foo.c bar.c
14132@end smallexample
14133
14134The above generates bytecode for @file{foo.c} and @file{bar.c},
14135merges them together into a single GIMPLE representation and optimizes
14136them as usual to produce @file{myprog}.
14137
14138The important thing to keep in mind is that to enable link-time
14139optimizations you need to use the GCC driver to perform the link step.
14140GCC automatically performs link-time optimization if any of the
14141objects involved were compiled with the @option{-flto} command-line option.
14142You can always override
14143the automatic decision to do link-time optimization
14144by passing @option{-fno-lto} to the link command.
14145
14146To make whole program optimization effective, it is necessary to make
14147certain whole program assumptions. The compiler needs to know
14148what functions and variables can be accessed by libraries and runtime
14149outside of the link-time optimized unit. When supported by the linker,
14150the linker plugin (see @option{-fuse-linker-plugin}) passes information
14151to the compiler about used and externally visible symbols. When
14152the linker plugin is not available, @option{-fwhole-program} should be
14153used to allow the compiler to make these assumptions, which leads
14154to more aggressive optimization decisions.
14155
14156When a file is compiled with @option{-flto} without
14157@option{-fuse-linker-plugin}, the generated object file is larger than
14158a regular object file because it contains GIMPLE bytecodes and the usual
14159final code (see @option{-ffat-lto-objects}). This means that
14160object files with LTO information can be linked as normal object
14161files; if @option{-fno-lto} is passed to the linker, no
14162interprocedural optimizations are applied. Note that when
14163@option{-fno-fat-lto-objects} is enabled the compile stage is faster
14164but you cannot perform a regular, non-LTO link on them.
14165
14166When producing the final binary, GCC only
14167applies link-time optimizations to those files that contain bytecode.
14168Therefore, you can mix and match object files and libraries with
14169GIMPLE bytecodes and final object code. GCC automatically selects
14170which files to optimize in LTO mode and which files to link without
14171further processing.
14172
14173Generally, options specified at link time override those
14174specified at compile time, although in some cases GCC attempts to infer
14175link-time options from the settings used to compile the input files.
14176
14177If you do not specify an optimization level option @option{-O} at
14178link time, then GCC uses the highest optimization level
14179used when compiling the object files. Note that it is generally
14180ineffective to specify an optimization level option only at link time and
14181not at compile time, for two reasons. First, compiling without
14182optimization suppresses compiler passes that gather information
14183needed for effective optimization at link time. Second, some early
14184optimization passes can be performed only at compile time and
14185not at link time.
14186
14187There are some code generation flags preserved by GCC when
14188generating bytecodes, as they need to be used during the final link.
14189Currently, the following options and their settings are taken from
14190the first object file that explicitly specifies them:
14191@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14192@option{-fgnu-tm} and all the @option{-m} target flags.
14193
14194The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14195@option{-fPIE} are combined based on the following scheme:
14196
14197@smallexample
14198@option{-fPIC} + @option{-fpic} = @option{-fpic}
14199@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14200@option{-fpic/-fPIC} + (no option) = (no option)
14201@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14202@option{-fpic} + @option{-fPIE} = @option{-fpie}
14203@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14204@end smallexample
14205
14206Certain ABI-changing flags are required to match in all compilation units,
14207and trying to override this at link time with a conflicting value
14208is ignored. This includes options such as @option{-freg-struct-return}
14209and @option{-fpcc-struct-return}.
14210
14211Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14212@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14213are passed through to the link stage and merged conservatively for
14214conflicting translation units. Specifically
14215@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14216precedence; and for example @option{-ffp-contract=off} takes precedence
14217over @option{-ffp-contract=fast}. You can override them at link time.
14218
14219Diagnostic options such as @option{-Wstringop-overflow} are passed
14220through to the link stage and their setting matches that of the
14221compile-step at function granularity. Note that this matters only
14222for diagnostics emitted during optimization. Note that code
14223transforms such as inlining can lead to warnings being enabled
14224or disabled for regions if code not consistent with the setting
14225at compile time.
14226
14227When you need to pass options to the assembler via @option{-Wa} or
14228@option{-Xassembler} make sure to either compile such translation
14229units with @option{-fno-lto} or consistently use the same assembler
14230options on all translation units. You can alternatively also
14231specify assembler options at LTO link time.
14232
14233To enable debug info generation you need to supply @option{-g} at
14234compile time. If any of the input files at link time were built
14235with debug info generation enabled the link will enable debug info
14236generation as well. Any elaborate debug info settings
14237like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14238at the linker command line and mixing different settings in different
14239translation units is discouraged.
14240
14241If LTO encounters objects with C linkage declared with incompatible
14242types in separate translation units to be linked together (undefined
14243behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14244issued. The behavior is still undefined at run time. Similar
14245diagnostics may be raised for other languages.
14246
14247Another feature of LTO is that it is possible to apply interprocedural
14248optimizations on files written in different languages:
14249
14250@smallexample
14251gcc -c -flto foo.c
14252g++ -c -flto bar.cc
14253gfortran -c -flto baz.f90
14254g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14255@end smallexample
14256
14257Notice that the final link is done with @command{g++} to get the C++
14258runtime libraries and @option{-lgfortran} is added to get the Fortran
14259runtime libraries. In general, when mixing languages in LTO mode, you
14260should use the same link command options as when mixing languages in a
14261regular (non-LTO) compilation.
14262
14263If object files containing GIMPLE bytecode are stored in a library archive, say
14264@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14265are using a linker with plugin support. To create static libraries suitable
14266for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14267and @command{ranlib};
14268to show the symbols of object files with GIMPLE bytecode, use
14269@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14270and @command{nm} have been compiled with plugin support. At link time, use the
14271flag @option{-fuse-linker-plugin} to ensure that the library participates in
14272the LTO optimization process:
14273
14274@smallexample
14275gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14276@end smallexample
14277
14278With the linker plugin enabled, the linker extracts the needed
14279GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14280to make them part of the aggregated GIMPLE image to be optimized.
14281
14282If you are not using a linker with plugin support and/or do not
14283enable the linker plugin, then the objects inside @file{libfoo.a}
14284are extracted and linked as usual, but they do not participate
14285in the LTO optimization process. In order to make a static library suitable
14286for both LTO optimization and usual linkage, compile its object files with
14287@option{-flto} @option{-ffat-lto-objects}.
14288
14289Link-time optimizations do not require the presence of the whole program to
14290operate. If the program does not require any symbols to be exported, it is
14291possible to combine @option{-flto} and @option{-fwhole-program} to allow
14292the interprocedural optimizers to use more aggressive assumptions which may
14293lead to improved optimization opportunities.
14294Use of @option{-fwhole-program} is not needed when linker plugin is
14295active (see @option{-fuse-linker-plugin}).
14296
14297The current implementation of LTO makes no
14298attempt to generate bytecode that is portable between different
14299types of hosts. The bytecode files are versioned and there is a
14300strict version check, so bytecode files generated in one version of
14301GCC do not work with an older or newer version of GCC.
14302
14303Link-time optimization does not work well with generation of debugging
14304information on systems other than those using a combination of ELF and
14305DWARF.
14306
14307If you specify the optional @var{n}, the optimization and code
14308generation done at link time is executed in parallel using @var{n}
14309parallel jobs by utilizing an installed @command{make} program. The
14310environment variable @env{MAKE} may be used to override the program
14311used.
14312
14313You can also specify @option{-flto=jobserver} to use GNU make's
14314job server mode to determine the number of parallel jobs. This
14315is useful when the Makefile calling GCC is already executing in parallel.
14316You must prepend a @samp{+} to the command recipe in the parent Makefile
14317for this to work. This option likely only works if @env{MAKE} is
14318GNU make. Even without the option value, GCC tries to automatically
14319detect a running GNU make's job server.
14320
14321Use @option{-flto=auto} to use GNU make's job server, if available,
14322or otherwise fall back to autodetection of the number of CPU threads
14323present in your system.
14324
d77de738 14325@opindex flto-partition
ddf6fe37 14326@item -flto-partition=@var{alg}
d77de738
ML
14327Specify the partitioning algorithm used by the link-time optimizer.
14328The value is either @samp{1to1} to specify a partitioning mirroring
14329the original source files or @samp{balanced} to specify partitioning
14330into equally sized chunks (whenever possible) or @samp{max} to create
14331new partition for every symbol where possible. Specifying @samp{none}
14332as an algorithm disables partitioning and streaming completely.
14333The default value is @samp{balanced}. While @samp{1to1} can be used
14334as an workaround for various code ordering issues, the @samp{max}
14335partitioning is intended for internal testing only.
14336The value @samp{one} specifies that exactly one partition should be
14337used while the value @samp{none} bypasses partitioning and executes
14338the link-time optimization step directly from the WPA phase.
14339
d77de738 14340@opindex flto-compression-level
ddf6fe37 14341@item -flto-compression-level=@var{n}
d77de738
ML
14342This option specifies the level of compression used for intermediate
14343language written to LTO object files, and is only meaningful in
14344conjunction with LTO mode (@option{-flto}). GCC currently supports two
14345LTO compression algorithms. For zstd, valid values are 0 (no compression)
14346to 19 (maximum compression), while zlib supports values from 0 to 9.
14347Values outside this range are clamped to either minimum or maximum
14348of the supported values. If the option is not given,
14349a default balanced compression setting is used.
14350
d77de738 14351@opindex fuse-linker-plugin
ddf6fe37 14352@item -fuse-linker-plugin
d77de738
ML
14353Enables the use of a linker plugin during link-time optimization. This
14354option relies on plugin support in the linker, which is available in gold
14355or in GNU ld 2.21 or newer.
14356
14357This option enables the extraction of object files with GIMPLE bytecode out
14358of library archives. This improves the quality of optimization by exposing
14359more code to the link-time optimizer. This information specifies what
14360symbols can be accessed externally (by non-LTO object or during dynamic
14361linking). Resulting code quality improvements on binaries (and shared
14362libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14363See @option{-flto} for a description of the effect of this flag and how to
14364use it.
14365
14366This option is enabled by default when LTO support in GCC is enabled
14367and GCC was configured for use with
14368a linker supporting plugins (GNU ld 2.21 or newer or gold).
14369
d77de738 14370@opindex ffat-lto-objects
ddf6fe37 14371@item -ffat-lto-objects
d77de738
ML
14372Fat LTO objects are object files that contain both the intermediate language
14373and the object code. This makes them usable for both LTO linking and normal
14374linking. This option is effective only when compiling with @option{-flto}
14375and is ignored at link time.
14376
14377@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14378requires the complete toolchain to be aware of LTO. It requires a linker with
14379linker plugin support for basic functionality. Additionally,
14380@command{nm}, @command{ar} and @command{ranlib}
14381need to support linker plugins to allow a full-featured build environment
14382(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14383@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14384to these tools. With non fat LTO makefiles need to be modified to use them.
14385
14386Note that modern binutils provide plugin auto-load mechanism.
14387Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14388effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14389@command{gcc-ranlib}).
14390
14391The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14392support.
14393
d77de738 14394@opindex fcompare-elim
ddf6fe37 14395@item -fcompare-elim
d77de738
ML
14396After register allocation and post-register allocation instruction splitting,
14397identify arithmetic instructions that compute processor flags similar to a
14398comparison operation based on that arithmetic. If possible, eliminate the
14399explicit comparison operation.
14400
14401This pass only applies to certain targets that cannot explicitly represent
14402the comparison operation before register allocation is complete.
14403
14404Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14405
04c9cf5c
MT
14406@opindex ffold-mem-offsets
14407@item -ffold-mem-offsets
14408@itemx -fno-fold-mem-offsets
14409Try to eliminate add instructions by folding them in memory loads/stores.
14410
14411Enabled at levels @option{-O2}, @option{-O3}.
14412
d77de738 14413@opindex fcprop-registers
ddf6fe37 14414@item -fcprop-registers
d77de738
ML
14415After register allocation and post-register allocation instruction splitting,
14416perform a copy-propagation pass to try to reduce scheduling dependencies
14417and occasionally eliminate the copy.
14418
14419Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14420
d77de738 14421@opindex fprofile-correction
ddf6fe37 14422@item -fprofile-correction
d77de738
ML
14423Profiles collected using an instrumented binary for multi-threaded programs may
14424be inconsistent due to missed counter updates. When this option is specified,
14425GCC uses heuristics to correct or smooth out such inconsistencies. By
14426default, GCC emits an error message when an inconsistent profile is detected.
14427
14428This option is enabled by @option{-fauto-profile}.
14429
d77de738 14430@opindex fprofile-partial-training
ddf6fe37 14431@item -fprofile-partial-training
d77de738
ML
14432With @code{-fprofile-use} all portions of programs not executed during train
14433run are optimized agressively for size rather than speed. In some cases it is
14434not practical to train all possible hot paths in the program. (For
14435example, program may contain functions specific for a given hardware and
14436trianing may not cover all hardware configurations program is run on.) With
14437@code{-fprofile-partial-training} profile feedback will be ignored for all
14438functions not executed during the train run leading them to be optimized as if
14439they were compiled without profile feedback. This leads to better performance
14440when train run is not representative but also leads to significantly bigger
14441code.
14442
ddf6fe37 14443@opindex fprofile-use
d77de738
ML
14444@item -fprofile-use
14445@itemx -fprofile-use=@var{path}
d77de738
ML
14446Enable profile feedback-directed optimizations,
14447and the following optimizations, many of which
14448are generally profitable only with profile feedback available:
14449
43b72ede
AA
14450@gccoptlist{-fbranch-probabilities -fprofile-values
14451-funroll-loops -fpeel-loops -ftracer -fvpt
14452-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14453-fpredictive-commoning -fsplit-loops -funswitch-loops
14454-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14455-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14456-fprofile-reorder-functions}
14457
14458Before you can use this option, you must first generate profiling information.
14459@xref{Instrumentation Options}, for information about the
14460@option{-fprofile-generate} option.
14461
14462By default, GCC emits an error message if the feedback profiles do not
14463match the source code. This error can be turned into a warning by using
14464@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14465optimized code. Additionally, by default, GCC also emits a warning message if
14466the feedback profiles do not exist (see @option{-Wmissing-profile}).
14467
14468If @var{path} is specified, GCC looks at the @var{path} to find
14469the profile feedback data files. See @option{-fprofile-dir}.
14470
ddf6fe37 14471@opindex fauto-profile
d77de738
ML
14472@item -fauto-profile
14473@itemx -fauto-profile=@var{path}
d77de738
ML
14474Enable sampling-based feedback-directed optimizations,
14475and the following optimizations,
14476many of which are generally profitable only with profile feedback available:
14477
43b72ede
AA
14478@gccoptlist{-fbranch-probabilities -fprofile-values
14479-funroll-loops -fpeel-loops -ftracer -fvpt
14480-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14481-fpredictive-commoning -fsplit-loops -funswitch-loops
14482-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14483-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14484-fprofile-correction}
14485
14486@var{path} is the name of a file containing AutoFDO profile information.
14487If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14488
14489Producing an AutoFDO profile data file requires running your program
14490with the @command{perf} utility on a supported GNU/Linux target system.
14491For more information, see @uref{https://perf.wiki.kernel.org/}.
14492
14493E.g.
14494@smallexample
14495perf record -e br_inst_retired:near_taken -b -o perf.data \
14496 -- your_program
14497@end smallexample
14498
14499Then use the @command{create_gcov} tool to convert the raw profile data
14500to a format that can be used by GCC.@ You must also supply the
14501unstripped binary for your program to this tool.
14502See @uref{https://github.com/google/autofdo}.
14503
14504E.g.
14505@smallexample
14506create_gcov --binary=your_program.unstripped --profile=perf.data \
14507 --gcov=profile.afdo
14508@end smallexample
14509@end table
14510
14511The following options control compiler behavior regarding floating-point
14512arithmetic. These options trade off between speed and
14513correctness. All must be specifically enabled.
14514
14515@table @gcctabopt
d77de738 14516@opindex ffloat-store
ddf6fe37 14517@item -ffloat-store
d77de738
ML
14518Do not store floating-point variables in registers, and inhibit other
14519options that might change whether a floating-point value is taken from a
14520register or memory.
14521
14522@cindex floating-point precision
14523This option prevents undesirable excess precision on machines such as
14524the 68000 where the floating registers (of the 68881) keep more
14525precision than a @code{double} is supposed to have. Similarly for the
14526x86 architecture. For most programs, the excess precision does only
14527good, but a few programs rely on the precise definition of IEEE floating
14528point. Use @option{-ffloat-store} for such programs, after modifying
14529them to store all pertinent intermediate computations into variables.
14530
d77de738 14531@opindex fexcess-precision
ddf6fe37 14532@item -fexcess-precision=@var{style}
d77de738
ML
14533This option allows further control over excess precision on machines
14534where floating-point operations occur in a format with more precision or
14535range than the IEEE standard and interchange floating-point types. By
14536default, @option{-fexcess-precision=fast} is in effect; this means that
14537operations may be carried out in a wider precision than the types specified
14538in the source if that would result in faster code, and it is unpredictable
14539when rounding to the types specified in the source code takes place.
14540When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14541then excess precision follows the rules specified in ISO C99 or C++; in particular,
14542both casts and assignments cause values to be rounded to their
14543semantic types (whereas @option{-ffloat-store} only affects
14544assignments). This option is enabled by default for C or C++ if a strict
14545conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14546@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14547regardless of whether a strict conformance option is used.
14548
14549@opindex mfpmath
14550@option{-fexcess-precision=standard} is not implemented for languages
14551other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14552or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14553semantics apply without excess precision, and in the latter, rounding
14554is unpredictable.
14555
d77de738 14556@opindex ffast-math
ddf6fe37 14557@item -ffast-math
d77de738
ML
14558Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14559@option{-ffinite-math-only}, @option{-fno-rounding-math},
14560@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14561@option{-fexcess-precision=fast}.
14562
14563This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14564
14565This option is not turned on by any @option{-O} option besides
14566@option{-Ofast} since it can result in incorrect output for programs
14567that depend on an exact implementation of IEEE or ISO rules/specifications
14568for math functions. It may, however, yield faster code for programs
14569that do not require the guarantees of these specifications.
14570
d77de738
ML
14571@opindex fno-math-errno
14572@opindex fmath-errno
ddf6fe37 14573@item -fno-math-errno
d77de738
ML
14574Do not set @code{errno} after calling math functions that are executed
14575with a single instruction, e.g., @code{sqrt}. A program that relies on
14576IEEE exceptions for math error handling may want to use this flag
14577for speed while maintaining IEEE arithmetic compatibility.
14578
14579This option is not turned on by any @option{-O} option since
14580it can result in incorrect output for programs that depend on
14581an exact implementation of IEEE or ISO rules/specifications for
14582math functions. It may, however, yield faster code for programs
14583that do not require the guarantees of these specifications.
14584
14585The default is @option{-fmath-errno}.
14586
14587On Darwin systems, the math library never sets @code{errno}. There is
14588therefore no reason for the compiler to consider the possibility that
14589it might, and @option{-fno-math-errno} is the default.
14590
d77de738 14591@opindex funsafe-math-optimizations
ddf6fe37 14592@item -funsafe-math-optimizations
d77de738
ML
14593
14594Allow optimizations for floating-point arithmetic that (a) assume
14595that arguments and results are valid and (b) may violate IEEE or
14596ANSI standards. When used at link time, it may include libraries
14597or startup files that change the default FPU control word or other
14598similar optimizations.
14599
14600This option is not turned on by any @option{-O} option since
14601it can result in incorrect output for programs that depend on
14602an exact implementation of IEEE or ISO rules/specifications for
14603math functions. It may, however, yield faster code for programs
14604that do not require the guarantees of these specifications.
14605Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14606@option{-fassociative-math} and @option{-freciprocal-math}.
14607
14608The default is @option{-fno-unsafe-math-optimizations}.
14609
d77de738 14610@opindex fassociative-math
ddf6fe37 14611@item -fassociative-math
d77de738
ML
14612
14613Allow re-association of operands in series of floating-point operations.
14614This violates the ISO C and C++ language standard by possibly changing
14615computation result. NOTE: re-ordering may change the sign of zero as
14616well as ignore NaNs and inhibit or create underflow or overflow (and
14617thus cannot be used on code that relies on rounding behavior like
14618@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14619and thus may not be used when ordered comparisons are required.
14620This option requires that both @option{-fno-signed-zeros} and
14621@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14622much sense with @option{-frounding-math}. For Fortran the option
14623is automatically enabled when both @option{-fno-signed-zeros} and
14624@option{-fno-trapping-math} are in effect.
14625
14626The default is @option{-fno-associative-math}.
14627
d77de738 14628@opindex freciprocal-math
ddf6fe37 14629@item -freciprocal-math
d77de738
ML
14630
14631Allow the reciprocal of a value to be used instead of dividing by
14632the value if this enables optimizations. For example @code{x / y}
14633can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14634is subject to common subexpression elimination. Note that this loses
14635precision and increases the number of flops operating on the value.
14636
14637The default is @option{-fno-reciprocal-math}.
14638
d77de738 14639@opindex ffinite-math-only
ddf6fe37 14640@item -ffinite-math-only
d77de738
ML
14641Allow optimizations for floating-point arithmetic that assume
14642that arguments and results are not NaNs or +-Infs.
14643
14644This option is not turned on by any @option{-O} option since
14645it can result in incorrect output for programs that depend on
14646an exact implementation of IEEE or ISO rules/specifications for
14647math functions. It may, however, yield faster code for programs
14648that do not require the guarantees of these specifications.
14649
14650The default is @option{-fno-finite-math-only}.
14651
d77de738
ML
14652@opindex fno-signed-zeros
14653@opindex fsigned-zeros
ddf6fe37 14654@item -fno-signed-zeros
d77de738
ML
14655Allow optimizations for floating-point arithmetic that ignore the
14656signedness of zero. IEEE arithmetic specifies the behavior of
14657distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14658of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14659This option implies that the sign of a zero result isn't significant.
14660
14661The default is @option{-fsigned-zeros}.
14662
d77de738
ML
14663@opindex fno-trapping-math
14664@opindex ftrapping-math
ddf6fe37 14665@item -fno-trapping-math
d77de738
ML
14666Compile code assuming that floating-point operations cannot generate
14667user-visible traps. These traps include division by zero, overflow,
14668underflow, inexact result and invalid operation. This option requires
14669that @option{-fno-signaling-nans} be in effect. Setting this option may
14670allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14671
14672This option should never be turned on by any @option{-O} option since
14673it can result in incorrect output for programs that depend on
14674an exact implementation of IEEE or ISO rules/specifications for
14675math functions.
14676
14677The default is @option{-ftrapping-math}.
14678
14679Future versions of GCC may provide finer control of this setting
14680using C99's @code{FENV_ACCESS} pragma. This command-line option
14681will be used along with @option{-frounding-math} to specify the
14682default state for @code{FENV_ACCESS}.
14683
d77de738 14684@opindex frounding-math
ddf6fe37 14685@item -frounding-math
d77de738
ML
14686Disable transformations and optimizations that assume default floating-point
14687rounding behavior. This is round-to-zero for all floating point
14688to integer conversions, and round-to-nearest for all other arithmetic
14689truncations. This option should be specified for programs that change
14690the FP rounding mode dynamically, or that may be executed with a
14691non-default rounding mode. This option disables constant folding of
14692floating-point expressions at compile time (which may be affected by
14693rounding mode) and arithmetic transformations that are unsafe in the
14694presence of sign-dependent rounding modes.
14695
14696The default is @option{-fno-rounding-math}.
14697
14698This option is experimental and does not currently guarantee to
14699disable all GCC optimizations that are affected by rounding mode.
14700Future versions of GCC may provide finer control of this setting
14701using C99's @code{FENV_ACCESS} pragma. This command-line option
14702will be used along with @option{-ftrapping-math} to specify the
14703default state for @code{FENV_ACCESS}.
14704
d77de738 14705@opindex fsignaling-nans
ddf6fe37 14706@item -fsignaling-nans
d77de738
ML
14707Compile code assuming that IEEE signaling NaNs may generate user-visible
14708traps during floating-point operations. Setting this option disables
14709optimizations that may change the number of exceptions visible with
14710signaling NaNs. This option implies @option{-ftrapping-math}.
14711
14712This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14713be defined.
14714
14715The default is @option{-fno-signaling-nans}.
14716
14717This option is experimental and does not currently guarantee to
14718disable all GCC optimizations that affect signaling NaN behavior.
14719
d77de738
ML
14720@opindex fno-fp-int-builtin-inexact
14721@opindex ffp-int-builtin-inexact
ddf6fe37 14722@item -fno-fp-int-builtin-inexact
d77de738
ML
14723Do not allow the built-in functions @code{ceil}, @code{floor},
14724@code{round} and @code{trunc}, and their @code{float} and @code{long
14725double} variants, to generate code that raises the ``inexact''
14726floating-point exception for noninteger arguments. ISO C99 and C11
14727allow these functions to raise the ``inexact'' exception, but ISO/IEC
14728TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14729ISO C2X, does not allow these functions to do so.
14730
14731The default is @option{-ffp-int-builtin-inexact}, allowing the
14732exception to be raised, unless C2X or a later C standard is selected.
14733This option does nothing unless @option{-ftrapping-math} is in effect.
14734
14735Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14736generate a call to a library function then the ``inexact'' exception
14737may be raised if the library implementation does not follow TS 18661.
14738
d77de738 14739@opindex fsingle-precision-constant
ddf6fe37 14740@item -fsingle-precision-constant
d77de738
ML
14741Treat floating-point constants as single precision instead of
14742implicitly converting them to double-precision constants.
14743
d77de738 14744@opindex fcx-limited-range
ddf6fe37 14745@item -fcx-limited-range
d77de738
ML
14746When enabled, this option states that a range reduction step is not
14747needed when performing complex division. Also, there is no checking
14748whether the result of a complex multiplication or division is @code{NaN
14749+ I*NaN}, with an attempt to rescue the situation in that case. The
14750default is @option{-fno-cx-limited-range}, but is enabled by
14751@option{-ffast-math}.
14752
14753This option controls the default setting of the ISO C99
14754@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14755all languages.
14756
d77de738 14757@opindex fcx-fortran-rules
ddf6fe37 14758@item -fcx-fortran-rules
d77de738
ML
14759Complex multiplication and division follow Fortran rules. Range
14760reduction is done as part of complex division, but there is no checking
14761whether the result of a complex multiplication or division is @code{NaN
14762+ I*NaN}, with an attempt to rescue the situation in that case.
14763
14764The default is @option{-fno-cx-fortran-rules}.
14765
14766@end table
14767
14768The following options control optimizations that may improve
14769performance, but are not enabled by any @option{-O} options. This
14770section includes experimental options that may produce broken code.
14771
14772@table @gcctabopt
d77de738 14773@opindex fbranch-probabilities
ddf6fe37 14774@item -fbranch-probabilities
d77de738
ML
14775After running a program compiled with @option{-fprofile-arcs}
14776(@pxref{Instrumentation Options}),
14777you can compile it a second time using
14778@option{-fbranch-probabilities}, to improve optimizations based on
14779the number of times each branch was taken. When a program
14780compiled with @option{-fprofile-arcs} exits, it saves arc execution
14781counts to a file called @file{@var{sourcename}.gcda} for each source
14782file. The information in this data file is very dependent on the
14783structure of the generated code, so you must use the same source code
14784and the same optimization options for both compilations.
14785See details about the file naming in @option{-fprofile-arcs}.
14786
14787With @option{-fbranch-probabilities}, GCC puts a
14788@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14789These can be used to improve optimization. Currently, they are only
14790used in one place: in @file{reorg.cc}, instead of guessing which path a
14791branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14792exactly determine which path is taken more often.
14793
14794Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14795
d77de738 14796@opindex fprofile-values
ddf6fe37 14797@item -fprofile-values
d77de738
ML
14798If combined with @option{-fprofile-arcs}, it adds code so that some
14799data about values of expressions in the program is gathered.
14800
14801With @option{-fbranch-probabilities}, it reads back the data gathered
14802from profiling values of expressions for usage in optimizations.
14803
14804Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14805@option{-fauto-profile}.
14806
d77de738 14807@opindex fprofile-reorder-functions
ddf6fe37 14808@item -fprofile-reorder-functions
d77de738
ML
14809Function reordering based on profile instrumentation collects
14810first time of execution of a function and orders these functions
14811in ascending order.
14812
14813Enabled with @option{-fprofile-use}.
14814
d77de738 14815@opindex fvpt
ddf6fe37 14816@item -fvpt
d77de738
ML
14817If combined with @option{-fprofile-arcs}, this option instructs the compiler
14818to add code to gather information about values of expressions.
14819
14820With @option{-fbranch-probabilities}, it reads back the data gathered
14821and actually performs the optimizations based on them.
14822Currently the optimizations include specialization of division operations
14823using the knowledge about the value of the denominator.
14824
14825Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14826
d77de738 14827@opindex frename-registers
ddf6fe37 14828@item -frename-registers
d77de738
ML
14829Attempt to avoid false dependencies in scheduled code by making use
14830of registers left over after register allocation. This optimization
14831most benefits processors with lots of registers. Depending on the
14832debug information format adopted by the target, however, it can
14833make debugging impossible, since variables no longer stay in
14834a ``home register''.
14835
14836Enabled by default with @option{-funroll-loops}.
14837
d77de738 14838@opindex fschedule-fusion
ddf6fe37 14839@item -fschedule-fusion
d77de738
ML
14840Performs a target dependent pass over the instruction stream to schedule
14841instructions of same type together because target machine can execute them
14842more efficiently if they are adjacent to each other in the instruction flow.
14843
14844Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14845
d77de738 14846@opindex ftracer
ddf6fe37 14847@item -ftracer
d77de738
ML
14848Perform tail duplication to enlarge superblock size. This transformation
14849simplifies the control flow of the function allowing other optimizations to do
14850a better job.
14851
14852Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14853
d77de738 14854@opindex funroll-loops
ddf6fe37 14855@item -funroll-loops
d77de738
ML
14856Unroll loops whose number of iterations can be determined at compile time or
14857upon entry to the loop. @option{-funroll-loops} implies
14858@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14859It also turns on complete loop peeling (i.e.@: complete removal of loops with
14860a small constant number of iterations). This option makes code larger, and may
14861or may not make it run faster.
14862
14863Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14864
d77de738 14865@opindex funroll-all-loops
ddf6fe37 14866@item -funroll-all-loops
d77de738
ML
14867Unroll all loops, even if their number of iterations is uncertain when
14868the loop is entered. This usually makes programs run more slowly.
14869@option{-funroll-all-loops} implies the same options as
14870@option{-funroll-loops}.
14871
d77de738 14872@opindex fpeel-loops
ddf6fe37 14873@item -fpeel-loops
d77de738
ML
14874Peels loops for which there is enough information that they do not
14875roll much (from profile feedback or static analysis). It also turns on
14876complete loop peeling (i.e.@: complete removal of loops with small constant
14877number of iterations).
14878
14879Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14880
d77de738 14881@opindex fmove-loop-invariants
ddf6fe37 14882@item -fmove-loop-invariants
d77de738
ML
14883Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14884at level @option{-O1} and higher, except for @option{-Og}.
14885
d77de738 14886@opindex fmove-loop-stores
ddf6fe37 14887@item -fmove-loop-stores
d77de738
ML
14888Enables the loop store motion pass in the GIMPLE loop optimizer. This
14889moves invariant stores to after the end of the loop in exchange for
14890carrying the stored value in a register across the iteration.
14891Note for this option to have an effect @option{-ftree-loop-im} has to
14892be enabled as well. Enabled at level @option{-O1} and higher, except
14893for @option{-Og}.
14894
d77de738 14895@opindex fsplit-loops
ddf6fe37 14896@item -fsplit-loops
d77de738
ML
14897Split a loop into two if it contains a condition that's always true
14898for one side of the iteration space and false for the other.
14899
14900Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14901
d77de738 14902@opindex funswitch-loops
ddf6fe37 14903@item -funswitch-loops
d77de738
ML
14904Move branches with loop invariant conditions out of the loop, with duplicates
14905of the loop on both branches (modified according to result of the condition).
14906
14907Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14908
d77de738 14909@opindex fversion-loops-for-strides
ddf6fe37 14910@item -fversion-loops-for-strides
d77de738
ML
14911If a loop iterates over an array with a variable stride, create another
14912version of the loop that assumes the stride is always one. For example:
14913
14914@smallexample
14915for (int i = 0; i < n; ++i)
14916 x[i * stride] = @dots{};
14917@end smallexample
14918
14919becomes:
14920
14921@smallexample
14922if (stride == 1)
14923 for (int i = 0; i < n; ++i)
14924 x[i] = @dots{};
14925else
14926 for (int i = 0; i < n; ++i)
14927 x[i * stride] = @dots{};
14928@end smallexample
14929
14930This is particularly useful for assumed-shape arrays in Fortran where
14931(for example) it allows better vectorization assuming contiguous accesses.
14932This flag is enabled by default at @option{-O3}.
14933It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14934
d77de738
ML
14935@opindex ffunction-sections
14936@opindex fdata-sections
ddf6fe37
AA
14937@item -ffunction-sections
14938@itemx -fdata-sections
d77de738
ML
14939Place each function or data item into its own section in the output
14940file if the target supports arbitrary sections. The name of the
14941function or the name of the data item determines the section's name
14942in the output file.
14943
14944Use these options on systems where the linker can perform optimizations to
14945improve locality of reference in the instruction space. Most systems using the
14946ELF object format have linkers with such optimizations. On AIX, the linker
14947rearranges sections (CSECTs) based on the call graph. The performance impact
14948varies.
14949
14950Together with a linker garbage collection (linker @option{--gc-sections}
14951option) these options may lead to smaller statically-linked executables (after
14952stripping).
14953
14954On ELF/DWARF systems these options do not degenerate the quality of the debug
14955information. There could be issues with other object files/debug info formats.
14956
14957Only use these options when there are significant benefits from doing so. When
14958you specify these options, the assembler and linker create larger object and
14959executable files and are also slower. These options affect code generation.
14960They prevent optimizations by the compiler and assembler using relative
14961locations inside a translation unit since the locations are unknown until
14962link time. An example of such an optimization is relaxing calls to short call
14963instructions.
14964
d77de738 14965@opindex fstdarg-opt
ddf6fe37 14966@item -fstdarg-opt
d77de738
ML
14967Optimize the prologue of variadic argument functions with respect to usage of
14968those arguments.
14969
d77de738 14970@opindex fsection-anchors
ddf6fe37 14971@item -fsection-anchors
d77de738
ML
14972Try to reduce the number of symbolic address calculations by using
14973shared ``anchor'' symbols to address nearby objects. This transformation
14974can help to reduce the number of GOT entries and GOT accesses on some
14975targets.
14976
14977For example, the implementation of the following function @code{foo}:
14978
14979@smallexample
14980static int a, b, c;
14981int foo (void) @{ return a + b + c; @}
14982@end smallexample
14983
14984@noindent
14985usually calculates the addresses of all three variables, but if you
14986compile it with @option{-fsection-anchors}, it accesses the variables
14987from a common anchor point instead. The effect is similar to the
14988following pseudocode (which isn't valid C):
14989
14990@smallexample
14991int foo (void)
14992@{
14993 register int *xr = &x;
14994 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14995@}
14996@end smallexample
14997
14998Not all targets support this option.
14999
d77de738 15000@opindex fzero-call-used-regs
ddf6fe37 15001@item -fzero-call-used-regs=@var{choice}
d77de738
ML
15002Zero call-used registers at function return to increase program
15003security by either mitigating Return-Oriented Programming (ROP)
15004attacks or preventing information leakage through registers.
15005
15006The possible values of @var{choice} are the same as for the
15007@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
15008The default is @samp{skip}.
15009
15010You can control this behavior for a specific function by using the function
15011attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
15012
d77de738 15013@opindex param
ddf6fe37 15014@item --param @var{name}=@var{value}
d77de738
ML
15015In some places, GCC uses various constants to control the amount of
15016optimization that is done. For example, GCC does not inline functions
15017that contain more than a certain number of instructions. You can
15018control some of these constants on the command line using the
15019@option{--param} option.
15020
15021The names of specific parameters, and the meaning of the values, are
15022tied to the internals of the compiler, and are subject to change
15023without notice in future releases.
15024
c381327d
GP
15025In order to get the minimal, maximal and default values of a parameter,
15026use the @option{--help=param -Q} options.
d77de738
ML
15027
15028In each case, the @var{value} is an integer. The following choices
15029of @var{name} are recognized for all targets:
15030
15031@table @gcctabopt
15032@item predictable-branch-outcome
15033When branch is predicted to be taken with probability lower than this threshold
15034(in percent), then it is considered well predictable.
15035
15036@item max-rtl-if-conversion-insns
15037RTL if-conversion tries to remove conditional branches around a block and
15038replace them with conditionally executed instructions. This parameter
15039gives the maximum number of instructions in a block which should be
15040considered for if-conversion. The compiler will
15041also use other heuristics to decide whether if-conversion is likely to be
15042profitable.
15043
15044@item max-rtl-if-conversion-predictable-cost
15045RTL if-conversion will try to remove conditional branches around a block
15046and replace them with conditionally executed instructions. These parameters
15047give the maximum permissible cost for the sequence that would be generated
15048by if-conversion depending on whether the branch is statically determined
15049to be predictable or not. The units for this parameter are the same as
15050those for the GCC internal seq_cost metric. The compiler will try to
15051provide a reasonable default for this parameter using the BRANCH_COST
15052target macro.
15053
15054@item max-crossjump-edges
15055The maximum number of incoming edges to consider for cross-jumping.
15056The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
15057the number of edges incoming to each block. Increasing values mean
15058more aggressive optimization, making the compilation time increase with
15059probably small improvement in executable size.
15060
15061@item min-crossjump-insns
15062The minimum number of instructions that must be matched at the end
15063of two blocks before cross-jumping is performed on them. This
15064value is ignored in the case where all instructions in the block being
15065cross-jumped from are matched.
15066
15067@item max-grow-copy-bb-insns
15068The maximum code size expansion factor when copying basic blocks
15069instead of jumping. The expansion is relative to a jump instruction.
15070
15071@item max-goto-duplication-insns
15072The maximum number of instructions to duplicate to a block that jumps
15073to a computed goto. To avoid @math{O(N^2)} behavior in a number of
15074passes, GCC factors computed gotos early in the compilation process,
15075and unfactors them as late as possible. Only computed jumps at the
15076end of a basic blocks with no more than max-goto-duplication-insns are
15077unfactored.
15078
15079@item max-delay-slot-insn-search
15080The maximum number of instructions to consider when looking for an
15081instruction to fill a delay slot. If more than this arbitrary number of
15082instructions are searched, the time savings from filling the delay slot
15083are minimal, so stop searching. Increasing values mean more
15084aggressive optimization, making the compilation time increase with probably
15085small improvement in execution time.
15086
15087@item max-delay-slot-live-search
15088When trying to fill delay slots, the maximum number of instructions to
15089consider when searching for a block with valid live register
15090information. Increasing this arbitrarily chosen value means more
15091aggressive optimization, increasing the compilation time. This parameter
15092should be removed when the delay slot code is rewritten to maintain the
15093control-flow graph.
15094
15095@item max-gcse-memory
15096The approximate maximum amount of memory in @code{kB} that can be allocated in
15097order to perform the global common subexpression elimination
15098optimization. If more memory than specified is required, the
15099optimization is not done.
15100
15101@item max-gcse-insertion-ratio
15102If the ratio of expression insertions to deletions is larger than this value
15103for any expression, then RTL PRE inserts or removes the expression and thus
15104leaves partially redundant computations in the instruction stream.
15105
15106@item max-pending-list-length
15107The maximum number of pending dependencies scheduling allows
15108before flushing the current state and starting over. Large functions
15109with few branches or calls can create excessively large lists which
15110needlessly consume memory and resources.
15111
15112@item max-modulo-backtrack-attempts
15113The maximum number of backtrack attempts the scheduler should make
15114when modulo scheduling a loop. Larger values can exponentially increase
15115compilation time.
15116
15117@item max-inline-functions-called-once-loop-depth
15118Maximal loop depth of a call considered by inline heuristics that tries to
15119inline all functions called once.
15120
15121@item max-inline-functions-called-once-insns
15122Maximal estimated size of functions produced while inlining functions called
15123once.
15124
15125@item max-inline-insns-single
15126Several parameters control the tree inliner used in GCC@. This number sets the
15127maximum number of instructions (counted in GCC's internal representation) in a
15128single function that the tree inliner considers for inlining. This only
15129affects functions declared inline and methods implemented in a class
15130declaration (C++).
15131
15132
15133@item max-inline-insns-auto
15134When you use @option{-finline-functions} (included in @option{-O3}),
15135a lot of functions that would otherwise not be considered for inlining
15136by the compiler are investigated. To those functions, a different
15137(more restrictive) limit compared to functions declared inline can
15138be applied (@option{--param max-inline-insns-auto}).
15139
15140@item max-inline-insns-small
15141This is bound applied to calls which are considered relevant with
15142@option{-finline-small-functions}.
15143
15144@item max-inline-insns-size
15145This is bound applied to calls which are optimized for size. Small growth
15146may be desirable to anticipate optimization oppurtunities exposed by inlining.
15147
15148@item uninlined-function-insns
15149Number of instructions accounted by inliner for function overhead such as
15150function prologue and epilogue.
15151
15152@item uninlined-function-time
15153Extra time accounted by inliner for function overhead such as time needed to
15154execute function prologue and epilogue.
15155
15156@item inline-heuristics-hint-percent
15157The scale (in percents) applied to @option{inline-insns-single},
15158@option{inline-insns-single-O2}, @option{inline-insns-auto}
15159when inline heuristics hints that inlining is
15160very profitable (will enable later optimizations).
15161
15162@item uninlined-thunk-insns
15163@item uninlined-thunk-time
15164Same as @option{--param uninlined-function-insns} and
15165@option{--param uninlined-function-time} but applied to function thunks.
15166
15167@item inline-min-speedup
15168When estimated performance improvement of caller + callee runtime exceeds this
15169threshold (in percent), the function can be inlined regardless of the limit on
15170@option{--param max-inline-insns-single} and @option{--param
15171max-inline-insns-auto}.
15172
15173@item large-function-insns
15174The limit specifying really large functions. For functions larger than this
15175limit after inlining, inlining is constrained by
15176@option{--param large-function-growth}. This parameter is useful primarily
15177to avoid extreme compilation time caused by non-linear algorithms used by the
15178back end.
15179
15180@item large-function-growth
15181Specifies maximal growth of large function caused by inlining in percents.
15182For example, parameter value 100 limits large function growth to 2.0 times
15183the original size.
15184
15185@item large-unit-insns
15186The limit specifying large translation unit. Growth caused by inlining of
15187units larger than this limit is limited by @option{--param inline-unit-growth}.
15188For small units this might be too tight.
15189For example, consider a unit consisting of function A
15190that is inline and B that just calls A three times. If B is small relative to
15191A, the growth of unit is 300\% and yet such inlining is very sane. For very
15192large units consisting of small inlineable functions, however, the overall unit
15193growth limit is needed to avoid exponential explosion of code size. Thus for
15194smaller units, the size is increased to @option{--param large-unit-insns}
15195before applying @option{--param inline-unit-growth}.
15196
15197@item lazy-modules
15198Maximum number of concurrently open C++ module files when lazy loading.
15199
15200@item inline-unit-growth
15201Specifies maximal overall growth of the compilation unit caused by inlining.
15202For example, parameter value 20 limits unit growth to 1.2 times the original
15203size. Cold functions (either marked cold via an attribute or by profile
15204feedback) are not accounted into the unit size.
15205
15206@item ipa-cp-unit-growth
15207Specifies maximal overall growth of the compilation unit caused by
15208interprocedural constant propagation. For example, parameter value 10 limits
15209unit growth to 1.1 times the original size.
15210
15211@item ipa-cp-large-unit-insns
15212The size of translation unit that IPA-CP pass considers large.
15213
15214@item large-stack-frame
15215The limit specifying large stack frames. While inlining the algorithm is trying
15216to not grow past this limit too much.
15217
15218@item large-stack-frame-growth
15219Specifies maximal growth of large stack frames caused by inlining in percents.
15220For example, parameter value 1000 limits large stack frame growth to 11 times
15221the original size.
15222
15223@item max-inline-insns-recursive
15224@itemx max-inline-insns-recursive-auto
15225Specifies the maximum number of instructions an out-of-line copy of a
15226self-recursive inline
15227function can grow into by performing recursive inlining.
15228
15229@option{--param max-inline-insns-recursive} applies to functions
15230declared inline.
15231For functions not declared inline, recursive inlining
15232happens only when @option{-finline-functions} (included in @option{-O3}) is
15233enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15234
15235@item max-inline-recursive-depth
15236@itemx max-inline-recursive-depth-auto
15237Specifies the maximum recursion depth used for recursive inlining.
15238
15239@option{--param max-inline-recursive-depth} applies to functions
15240declared inline. For functions not declared inline, recursive inlining
15241happens only when @option{-finline-functions} (included in @option{-O3}) is
15242enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15243
15244@item min-inline-recursive-probability
15245Recursive inlining is profitable only for function having deep recursion
15246in average and can hurt for function having little recursion depth by
15247increasing the prologue size or complexity of function body to other
15248optimizers.
15249
15250When profile feedback is available (see @option{-fprofile-generate}) the actual
15251recursion depth can be guessed from the probability that function recurses
15252via a given call expression. This parameter limits inlining only to call
15253expressions whose probability exceeds the given threshold (in percents).
15254
15255@item early-inlining-insns
15256Specify growth that the early inliner can make. In effect it increases
15257the amount of inlining for code having a large abstraction penalty.
15258
15259@item max-early-inliner-iterations
15260Limit of iterations of the early inliner. This basically bounds
15261the number of nested indirect calls the early inliner can resolve.
15262Deeper chains are still handled by late inlining.
15263
15264@item comdat-sharing-probability
15265Probability (in percent) that C++ inline function with comdat visibility
15266are shared across multiple compilation units.
15267
15268@item modref-max-bases
15269@item modref-max-refs
15270@item modref-max-accesses
15271Specifies the maximal number of base pointers, references and accesses stored
15272for a single function by mod/ref analysis.
15273
15274@item modref-max-tests
15275Specifies the maxmal number of tests alias oracle can perform to disambiguate
15276memory locations using the mod/ref information. This parameter ought to be
15277bigger than @option{--param modref-max-bases} and @option{--param
15278modref-max-refs}.
15279
15280@item modref-max-depth
15281Specifies the maximum depth of DFS walk used by modref escape analysis.
15282Setting to 0 disables the analysis completely.
15283
15284@item modref-max-escape-points
15285Specifies the maximum number of escape points tracked by modref per SSA-name.
15286
15287@item modref-max-adjustments
15288Specifies the maximum number the access range is enlarged during modref dataflow
15289analysis.
15290
15291@item profile-func-internal-id
15292A parameter to control whether to use function internal id in profile
15293database lookup. If the value is 0, the compiler uses an id that
15294is based on function assembler name and filename, which makes old profile
15295data more tolerant to source changes such as function reordering etc.
15296
15297@item min-vect-loop-bound
15298The minimum number of iterations under which loops are not vectorized
15299when @option{-ftree-vectorize} is used. The number of iterations after
15300vectorization needs to be greater than the value specified by this option
15301to allow vectorization.
15302
15303@item gcse-cost-distance-ratio
15304Scaling factor in calculation of maximum distance an expression
15305can be moved by GCSE optimizations. This is currently supported only in the
15306code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15307is with simple expressions, i.e., the expressions that have cost
15308less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15309hoisting of simple expressions.
15310
15311@item gcse-unrestricted-cost
15312Cost, roughly measured as the cost of a single typical machine
15313instruction, at which GCSE optimizations do not constrain
15314the distance an expression can travel. This is currently
15315supported only in the code hoisting pass. The lesser the cost,
15316the more aggressive code hoisting is. Specifying 0
15317allows all expressions to travel unrestricted distances.
15318
15319@item max-hoist-depth
15320The depth of search in the dominator tree for expressions to hoist.
15321This is used to avoid quadratic behavior in hoisting algorithm.
15322The value of 0 does not limit on the search, but may slow down compilation
15323of huge functions.
15324
15325@item max-tail-merge-comparisons
15326The maximum amount of similar bbs to compare a bb with. This is used to
15327avoid quadratic behavior in tree tail merging.
15328
15329@item max-tail-merge-iterations
15330The maximum amount of iterations of the pass over the function. This is used to
15331limit compilation time in tree tail merging.
15332
15333@item store-merging-allow-unaligned
15334Allow the store merging pass to introduce unaligned stores if it is legal to
15335do so.
15336
15337@item max-stores-to-merge
15338The maximum number of stores to attempt to merge into wider stores in the store
15339merging pass.
15340
15341@item max-store-chains-to-track
15342The maximum number of store chains to track at the same time in the attempt
15343to merge them into wider stores in the store merging pass.
15344
15345@item max-stores-to-track
15346The maximum number of stores to track at the same time in the attemt to
15347to merge them into wider stores in the store merging pass.
15348
15349@item max-unrolled-insns
15350The maximum number of instructions that a loop may have to be unrolled.
15351If a loop is unrolled, this parameter also determines how many times
15352the loop code is unrolled.
15353
15354@item max-average-unrolled-insns
15355The maximum number of instructions biased by probabilities of their execution
15356that a loop may have to be unrolled. If a loop is unrolled,
15357this parameter also determines how many times the loop code is unrolled.
15358
15359@item max-unroll-times
15360The maximum number of unrollings of a single loop.
15361
15362@item max-peeled-insns
15363The maximum number of instructions that a loop may have to be peeled.
15364If a loop is peeled, this parameter also determines how many times
15365the loop code is peeled.
15366
15367@item max-peel-times
15368The maximum number of peelings of a single loop.
15369
15370@item max-peel-branches
15371The maximum number of branches on the hot path through the peeled sequence.
15372
15373@item max-completely-peeled-insns
15374The maximum number of insns of a completely peeled loop.
15375
15376@item max-completely-peel-times
15377The maximum number of iterations of a loop to be suitable for complete peeling.
15378
15379@item max-completely-peel-loop-nest-depth
15380The maximum depth of a loop nest suitable for complete peeling.
15381
15382@item max-unswitch-insns
15383The maximum number of insns of an unswitched loop.
15384
5b50850c
RB
15385@item max-unswitch-depth
15386The maximum depth of a loop nest to be unswitched.
15387
d77de738
ML
15388@item lim-expensive
15389The minimum cost of an expensive expression in the loop invariant motion.
15390
15391@item min-loop-cond-split-prob
15392When FDO profile information is available, @option{min-loop-cond-split-prob}
15393specifies minimum threshold for probability of semi-invariant condition
15394statement to trigger loop split.
15395
15396@item iv-consider-all-candidates-bound
15397Bound on number of candidates for induction variables, below which
15398all candidates are considered for each use in induction variable
15399optimizations. If there are more candidates than this,
15400only the most relevant ones are considered to avoid quadratic time complexity.
15401
15402@item iv-max-considered-uses
15403The induction variable optimizations give up on loops that contain more
15404induction variable uses.
15405
15406@item iv-always-prune-cand-set-bound
15407If the number of candidates in the set is smaller than this value,
15408always try to remove unnecessary ivs from the set
15409when adding a new one.
15410
15411@item avg-loop-niter
15412Average number of iterations of a loop.
15413
15414@item dse-max-object-size
15415Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15416Larger values may result in larger compilation times.
15417
15418@item dse-max-alias-queries-per-store
15419Maximum number of queries into the alias oracle per store.
15420Larger values result in larger compilation times and may result in more
15421removed dead stores.
15422
15423@item scev-max-expr-size
15424Bound on size of expressions used in the scalar evolutions analyzer.
15425Large expressions slow the analyzer.
15426
15427@item scev-max-expr-complexity
15428Bound on the complexity of the expressions in the scalar evolutions analyzer.
15429Complex expressions slow the analyzer.
15430
15431@item max-tree-if-conversion-phi-args
15432Maximum number of arguments in a PHI supported by TREE if conversion
15433unless the loop is marked with simd pragma.
15434
15435@item vect-max-layout-candidates
15436The maximum number of possible vector layouts (such as permutations)
15437to consider when optimizing to-be-vectorized code.
15438
15439@item vect-max-version-for-alignment-checks
15440The maximum number of run-time checks that can be performed when
15441doing loop versioning for alignment in the vectorizer.
15442
15443@item vect-max-version-for-alias-checks
15444The maximum number of run-time checks that can be performed when
15445doing loop versioning for alias in the vectorizer.
15446
15447@item vect-max-peeling-for-alignment
15448The maximum number of loop peels to enhance access alignment
15449for vectorizer. Value -1 means no limit.
15450
15451@item max-iterations-to-track
15452The maximum number of iterations of a loop the brute-force algorithm
15453for analysis of the number of iterations of the loop tries to evaluate.
15454
15455@item hot-bb-count-fraction
15456The denominator n of fraction 1/n of the maximal execution count of a
15457basic block in the entire program that a basic block needs to at least
15458have in order to be considered hot. The default is 10000, which means
15459that a basic block is considered hot if its execution count is greater
15460than 1/10000 of the maximal execution count. 0 means that it is never
15461considered hot. Used in non-LTO mode.
15462
15463@item hot-bb-count-ws-permille
15464The number of most executed permilles, ranging from 0 to 1000, of the
15465profiled execution of the entire program to which the execution count
15466of a basic block must be part of in order to be considered hot. The
15467default is 990, which means that a basic block is considered hot if
15468its execution count contributes to the upper 990 permilles, or 99.0%,
15469of the profiled execution of the entire program. 0 means that it is
15470never considered hot. Used in LTO mode.
15471
15472@item hot-bb-frequency-fraction
15473The denominator n of fraction 1/n of the execution frequency of the
15474entry block of a function that a basic block of this function needs
15475to at least have in order to be considered hot. The default is 1000,
15476which means that a basic block is considered hot in a function if it
15477is executed more frequently than 1/1000 of the frequency of the entry
15478block of the function. 0 means that it is never considered hot.
15479
15480@item unlikely-bb-count-fraction
15481The denominator n of fraction 1/n of the number of profiled runs of
15482the entire program below which the execution count of a basic block
15483must be in order for the basic block to be considered unlikely executed.
15484The default is 20, which means that a basic block is considered unlikely
15485executed if it is executed in fewer than 1/20, or 5%, of the runs of
15486the program. 0 means that it is always considered unlikely executed.
15487
15488@item max-predicted-iterations
15489The maximum number of loop iterations we predict statically. This is useful
15490in cases where a function contains a single loop with known bound and
15491another loop with unknown bound.
15492The known number of iterations is predicted correctly, while
15493the unknown number of iterations average to roughly 10. This means that the
15494loop without bounds appears artificially cold relative to the other one.
15495
15496@item builtin-expect-probability
15497Control the probability of the expression having the specified value. This
15498parameter takes a percentage (i.e.@: 0 ... 100) as input.
15499
15500@item builtin-string-cmp-inline-length
15501The maximum length of a constant string for a builtin string cmp call
15502eligible for inlining.
15503
15504@item align-threshold
15505
15506Select fraction of the maximal frequency of executions of a basic block in
15507a function to align the basic block.
15508
15509@item align-loop-iterations
15510
15511A loop expected to iterate at least the selected number of iterations is
15512aligned.
15513
15514@item tracer-dynamic-coverage
15515@itemx tracer-dynamic-coverage-feedback
15516
15517This value is used to limit superblock formation once the given percentage of
15518executed instructions is covered. This limits unnecessary code size
15519expansion.
15520
15521The @option{tracer-dynamic-coverage-feedback} parameter
15522is used only when profile
15523feedback is available. The real profiles (as opposed to statically estimated
15524ones) are much less balanced allowing the threshold to be larger value.
15525
15526@item tracer-max-code-growth
15527Stop tail duplication once code growth has reached given percentage. This is
15528a rather artificial limit, as most of the duplicates are eliminated later in
15529cross jumping, so it may be set to much higher values than is the desired code
15530growth.
15531
15532@item tracer-min-branch-ratio
15533
15534Stop reverse growth when the reverse probability of best edge is less than this
15535threshold (in percent).
15536
15537@item tracer-min-branch-probability
15538@itemx tracer-min-branch-probability-feedback
15539
15540Stop forward growth if the best edge has probability lower than this
15541threshold.
15542
15543Similarly to @option{tracer-dynamic-coverage} two parameters are
15544provided. @option{tracer-min-branch-probability-feedback} is used for
15545compilation with profile feedback and @option{tracer-min-branch-probability}
15546compilation without. The value for compilation with profile feedback
15547needs to be more conservative (higher) in order to make tracer
15548effective.
15549
15550@item stack-clash-protection-guard-size
15551Specify the size of the operating system provided stack guard as
155522 raised to @var{num} bytes. Higher values may reduce the
15553number of explicit probes, but a value larger than the operating system
15554provided guard will leave code vulnerable to stack clash style attacks.
15555
15556@item stack-clash-protection-probe-interval
15557Stack clash protection involves probing stack space as it is allocated. This
15558param controls the maximum distance between probes into the stack as 2 raised
15559to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15560larger than the operating system provided guard will leave code vulnerable to
15561stack clash style attacks.
15562
15563@item max-cse-path-length
15564
15565The maximum number of basic blocks on path that CSE considers.
15566
15567@item max-cse-insns
15568The maximum number of instructions CSE processes before flushing.
15569
15570@item ggc-min-expand
15571
15572GCC uses a garbage collector to manage its own memory allocation. This
15573parameter specifies the minimum percentage by which the garbage
15574collector's heap should be allowed to expand between collections.
15575Tuning this may improve compilation speed; it has no effect on code
15576generation.
15577
15578The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15579RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15580the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15581GCC is not able to calculate RAM on a particular platform, the lower
15582bound of 30% is used. Setting this parameter and
15583@option{ggc-min-heapsize} to zero causes a full collection to occur at
15584every opportunity. This is extremely slow, but can be useful for
15585debugging.
15586
15587@item ggc-min-heapsize
15588
15589Minimum size of the garbage collector's heap before it begins bothering
15590to collect garbage. The first collection occurs after the heap expands
15591by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15592tuning this may improve compilation speed, and has no effect on code
15593generation.
15594
15595The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15596tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15597with a lower bound of 4096 (four megabytes) and an upper bound of
15598131072 (128 megabytes). If GCC is not able to calculate RAM on a
15599particular platform, the lower bound is used. Setting this parameter
15600very large effectively disables garbage collection. Setting this
15601parameter and @option{ggc-min-expand} to zero causes a full collection
15602to occur at every opportunity.
15603
15604@item max-reload-search-insns
15605The maximum number of instruction reload should look backward for equivalent
15606register. Increasing values mean more aggressive optimization, making the
15607compilation time increase with probably slightly better performance.
15608
15609@item max-cselib-memory-locations
15610The maximum number of memory locations cselib should take into account.
15611Increasing values mean more aggressive optimization, making the compilation time
15612increase with probably slightly better performance.
15613
15614@item max-sched-ready-insns
15615The maximum number of instructions ready to be issued the scheduler should
15616consider at any given time during the first scheduling pass. Increasing
15617values mean more thorough searches, making the compilation time increase
15618with probably little benefit.
15619
15620@item max-sched-region-blocks
15621The maximum number of blocks in a region to be considered for
15622interblock scheduling.
15623
15624@item max-pipeline-region-blocks
15625The maximum number of blocks in a region to be considered for
15626pipelining in the selective scheduler.
15627
15628@item max-sched-region-insns
15629The maximum number of insns in a region to be considered for
15630interblock scheduling.
15631
15632@item max-pipeline-region-insns
15633The maximum number of insns in a region to be considered for
15634pipelining in the selective scheduler.
15635
15636@item min-spec-prob
15637The minimum probability (in percents) of reaching a source block
15638for interblock speculative scheduling.
15639
15640@item max-sched-extend-regions-iters
15641The maximum number of iterations through CFG to extend regions.
15642A value of 0 disables region extensions.
15643
15644@item max-sched-insn-conflict-delay
15645The maximum conflict delay for an insn to be considered for speculative motion.
15646
15647@item sched-spec-prob-cutoff
15648The minimal probability of speculation success (in percents), so that
15649speculative insns are scheduled.
15650
15651@item sched-state-edge-prob-cutoff
15652The minimum probability an edge must have for the scheduler to save its
15653state across it.
15654
15655@item sched-mem-true-dep-cost
15656Minimal distance (in CPU cycles) between store and load targeting same
15657memory locations.
15658
15659@item selsched-max-lookahead
15660The maximum size of the lookahead window of selective scheduling. It is a
15661depth of search for available instructions.
15662
15663@item selsched-max-sched-times
15664The maximum number of times that an instruction is scheduled during
15665selective scheduling. This is the limit on the number of iterations
15666through which the instruction may be pipelined.
15667
15668@item selsched-insns-to-rename
15669The maximum number of best instructions in the ready list that are considered
15670for renaming in the selective scheduler.
15671
15672@item sms-min-sc
15673The minimum value of stage count that swing modulo scheduler
15674generates.
15675
15676@item max-last-value-rtl
15677The maximum size measured as number of RTLs that can be recorded in an expression
15678in combiner for a pseudo register as last known value of that register.
15679
15680@item max-combine-insns
15681The maximum number of instructions the RTL combiner tries to combine.
15682
15683@item integer-share-limit
15684Small integer constants can use a shared data structure, reducing the
15685compiler's memory usage and increasing its speed. This sets the maximum
15686value of a shared integer constant.
15687
15688@item ssp-buffer-size
15689The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15690protection when @option{-fstack-protector} is used.
15691
15692@item min-size-for-stack-sharing
15693The minimum size of variables taking part in stack slot sharing when not
15694optimizing.
15695
15696@item max-jump-thread-duplication-stmts
15697Maximum number of statements allowed in a block that needs to be
15698duplicated when threading jumps.
15699
15700@item max-jump-thread-paths
15701The maximum number of paths to consider when searching for jump threading
15702opportunities. When arriving at a block, incoming edges are only considered
15703if the number of paths to be searched so far multiplied by the number of
15704incoming edges does not exhaust the specified maximum number of paths to
15705consider.
15706
15707@item max-fields-for-field-sensitive
15708Maximum number of fields in a structure treated in
15709a field sensitive manner during pointer analysis.
15710
15711@item prefetch-latency
15712Estimate on average number of instructions that are executed before
15713prefetch finishes. The distance prefetched ahead is proportional
15714to this constant. Increasing this number may also lead to less
15715streams being prefetched (see @option{simultaneous-prefetches}).
15716
15717@item simultaneous-prefetches
15718Maximum number of prefetches that can run at the same time.
15719
15720@item l1-cache-line-size
15721The size of cache line in L1 data cache, in bytes.
15722
15723@item l1-cache-size
15724The size of L1 data cache, in kilobytes.
15725
15726@item l2-cache-size
15727The size of L2 data cache, in kilobytes.
15728
15729@item prefetch-dynamic-strides
15730Whether the loop array prefetch pass should issue software prefetch hints
15731for strides that are non-constant. In some cases this may be
15732beneficial, though the fact the stride is non-constant may make it
15733hard to predict when there is clear benefit to issuing these hints.
15734
15735Set to 1 if the prefetch hints should be issued for non-constant
15736strides. Set to 0 if prefetch hints should be issued only for strides that
15737are known to be constant and below @option{prefetch-minimum-stride}.
15738
15739@item prefetch-minimum-stride
15740Minimum constant stride, in bytes, to start using prefetch hints for. If
15741the stride is less than this threshold, prefetch hints will not be issued.
15742
15743This setting is useful for processors that have hardware prefetchers, in
15744which case there may be conflicts between the hardware prefetchers and
15745the software prefetchers. If the hardware prefetchers have a maximum
15746stride they can handle, it should be used here to improve the use of
15747software prefetchers.
15748
15749A value of -1 means we don't have a threshold and therefore
15750prefetch hints can be issued for any constant stride.
15751
15752This setting is only useful for strides that are known and constant.
15753
15754@item destructive-interference-size
15755@item constructive-interference-size
15756The values for the C++17 variables
15757@code{std::hardware_destructive_interference_size} and
15758@code{std::hardware_constructive_interference_size}. The destructive
15759interference size is the minimum recommended offset between two
15760independent concurrently-accessed objects; the constructive
15761interference size is the maximum recommended size of contiguous memory
15762accessed together. Typically both will be the size of an L1 cache
15763line for the target, in bytes. For a generic target covering a range of L1
15764cache line sizes, typically the constructive interference size will be
15765the small end of the range and the destructive size will be the large
15766end.
15767
15768The destructive interference size is intended to be used for layout,
15769and thus has ABI impact. The default value is not expected to be
15770stable, and on some targets varies with @option{-mtune}, so use of
15771this variable in a context where ABI stability is important, such as
15772the public interface of a library, is strongly discouraged; if it is
15773used in that context, users can stabilize the value using this
15774option.
15775
15776The constructive interference size is less sensitive, as it is
15777typically only used in a @samp{static_assert} to make sure that a type
15778fits within a cache line.
15779
15780See also @option{-Winterference-size}.
15781
15782@item loop-interchange-max-num-stmts
15783The maximum number of stmts in a loop to be interchanged.
15784
15785@item loop-interchange-stride-ratio
15786The minimum ratio between stride of two loops for interchange to be profitable.
15787
15788@item min-insn-to-prefetch-ratio
15789The minimum ratio between the number of instructions and the
15790number of prefetches to enable prefetching in a loop.
15791
15792@item prefetch-min-insn-to-mem-ratio
15793The minimum ratio between the number of instructions and the
15794number of memory references to enable prefetching in a loop.
15795
15796@item use-canonical-types
15797Whether the compiler should use the ``canonical'' type system.
15798Should always be 1, which uses a more efficient internal
15799mechanism for comparing types in C++ and Objective-C++. However, if
15800bugs in the canonical type system are causing compilation failures,
15801set this value to 0 to disable canonical types.
15802
15803@item switch-conversion-max-branch-ratio
15804Switch initialization conversion refuses to create arrays that are
15805bigger than @option{switch-conversion-max-branch-ratio} times the number of
15806branches in the switch.
15807
15808@item max-partial-antic-length
15809Maximum length of the partial antic set computed during the tree
15810partial redundancy elimination optimization (@option{-ftree-pre}) when
15811optimizing at @option{-O3} and above. For some sorts of source code
15812the enhanced partial redundancy elimination optimization can run away,
15813consuming all of the memory available on the host machine. This
15814parameter sets a limit on the length of the sets that are computed,
15815which prevents the runaway behavior. Setting a value of 0 for
15816this parameter allows an unlimited set length.
15817
15818@item rpo-vn-max-loop-depth
15819Maximum loop depth that is value-numbered optimistically.
15820When the limit hits the innermost
15821@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15822loop nest are value-numbered optimistically and the remaining ones not.
15823
15824@item sccvn-max-alias-queries-per-access
15825Maximum number of alias-oracle queries we perform when looking for
15826redundancies for loads and stores. If this limit is hit the search
15827is aborted and the load or store is not considered redundant. The
15828number of queries is algorithmically limited to the number of
15829stores on all paths from the load to the function entry.
15830
15831@item ira-max-loops-num
15832IRA uses regional register allocation by default. If a function
15833contains more loops than the number given by this parameter, only at most
15834the given number of the most frequently-executed loops form regions
15835for regional register allocation.
15836
15837@item ira-max-conflict-table-size
15838Although IRA uses a sophisticated algorithm to compress the conflict
15839table, the table can still require excessive amounts of memory for
15840huge functions. If the conflict table for a function could be more
15841than the size in MB given by this parameter, the register allocator
15842instead uses a faster, simpler, and lower-quality
15843algorithm that does not require building a pseudo-register conflict table.
15844
15845@item ira-loop-reserved-regs
15846IRA can be used to evaluate more accurate register pressure in loops
15847for decisions to move loop invariants (see @option{-O3}). The number
15848of available registers reserved for some other purposes is given
15849by this parameter. Default of the parameter
15850is the best found from numerous experiments.
15851
15852@item ira-consider-dup-in-all-alts
15853Make IRA to consider matching constraint (duplicated operand number)
15854heavily in all available alternatives for preferred register class.
15855If it is set as zero, it means IRA only respects the matching
15856constraint when it's in the only available alternative with an
15857appropriate register class. Otherwise, it means IRA will check all
15858available alternatives for preferred register class even if it has
15859found some choice with an appropriate register class and respect the
15860found qualified matching constraint.
15861
9847c753
ML
15862@item ira-simple-lra-insn-threshold
15863Approximate function insn number in 1K units triggering simple local RA.
15864
d77de738
ML
15865@item lra-inheritance-ebb-probability-cutoff
15866LRA tries to reuse values reloaded in registers in subsequent insns.
15867This optimization is called inheritance. EBB is used as a region to
15868do this optimization. The parameter defines a minimal fall-through
15869edge probability in percentage used to add BB to inheritance EBB in
15870LRA. The default value was chosen
15871from numerous runs of SPEC2000 on x86-64.
15872
15873@item loop-invariant-max-bbs-in-loop
15874Loop invariant motion can be very expensive, both in compilation time and
15875in amount of needed compile-time memory, with very large loops. Loops
15876with more basic blocks than this parameter won't have loop invariant
15877motion optimization performed on them.
15878
15879@item loop-max-datarefs-for-datadeps
15880Building data dependencies is expensive for very large loops. This
15881parameter limits the number of data references in loops that are
15882considered for data dependence analysis. These large loops are no
15883handled by the optimizations using loop data dependencies.
15884
15885@item max-vartrack-size
15886Sets a maximum number of hash table slots to use during variable
15887tracking dataflow analysis of any function. If this limit is exceeded
15888with variable tracking at assignments enabled, analysis for that
15889function is retried without it, after removing all debug insns from
15890the function. If the limit is exceeded even without debug insns, var
15891tracking analysis is completely disabled for the function. Setting
15892the parameter to zero makes it unlimited.
15893
15894@item max-vartrack-expr-depth
15895Sets a maximum number of recursion levels when attempting to map
15896variable names or debug temporaries to value expressions. This trades
15897compilation time for more complete debug information. If this is set too
15898low, value expressions that are available and could be represented in
15899debug information may end up not being used; setting this higher may
15900enable the compiler to find more complex debug expressions, but compile
15901time and memory use may grow.
15902
15903@item max-debug-marker-count
15904Sets a threshold on the number of debug markers (e.g.@: begin stmt
15905markers) to avoid complexity explosion at inlining or expanding to RTL.
15906If a function has more such gimple stmts than the set limit, such stmts
15907will be dropped from the inlined copy of a function, and from its RTL
15908expansion.
15909
15910@item min-nondebug-insn-uid
15911Use uids starting at this parameter for nondebug insns. The range below
15912the parameter is reserved exclusively for debug insns created by
15913@option{-fvar-tracking-assignments}, but debug insns may get
15914(non-overlapping) uids above it if the reserved range is exhausted.
15915
10478270
MJ
15916@item ipa-sra-deref-prob-threshold
15917IPA-SRA replaces a pointer which is known not be NULL with one or more
15918new parameters only when the probability (in percent, relative to
15919function entry) of it being dereferenced is higher than this parameter.
15920
d77de738
ML
15921@item ipa-sra-ptr-growth-factor
15922IPA-SRA replaces a pointer to an aggregate with one or more new
15923parameters only when their cumulative size is less or equal to
15924@option{ipa-sra-ptr-growth-factor} times the size of the original
15925pointer parameter.
15926
69363825
ML
15927@item ipa-sra-ptrwrap-growth-factor
15928Additional maximum allowed growth of total size of new parameters
15929that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15930if it points to a local variable that the caller only writes to and
15931passes it as an argument to other functions.
69363825 15932
d77de738
ML
15933@item ipa-sra-max-replacements
15934Maximum pieces of an aggregate that IPA-SRA tracks. As a
15935consequence, it is also the maximum number of replacements of a formal
15936parameter.
15937
15938@item sra-max-scalarization-size-Ospeed
15939@itemx sra-max-scalarization-size-Osize
15940The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15941replace scalar parts of aggregates with uses of independent scalar
15942variables. These parameters control the maximum size, in storage units,
15943of aggregate which is considered for replacement when compiling for
15944speed
15945(@option{sra-max-scalarization-size-Ospeed}) or size
15946(@option{sra-max-scalarization-size-Osize}) respectively.
15947
15948@item sra-max-propagations
15949The maximum number of artificial accesses that Scalar Replacement of
15950Aggregates (SRA) will track, per one local variable, in order to
15951facilitate copy propagation.
15952
15953@item tm-max-aggregate-size
15954When making copies of thread-local variables in a transaction, this
15955parameter specifies the size in bytes after which variables are
15956saved with the logging functions as opposed to save/restore code
15957sequence pairs. This option only applies when using
15958@option{-fgnu-tm}.
15959
15960@item graphite-max-nb-scop-params
15961To avoid exponential effects in the Graphite loop transforms, the
15962number of parameters in a Static Control Part (SCoP) is bounded.
15963A value of zero can be used to lift
15964the bound. A variable whose value is unknown at compilation time and
15965defined outside a SCoP is a parameter of the SCoP.
15966
15967@item loop-block-tile-size
15968Loop blocking or strip mining transforms, enabled with
15969@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15970loop in the loop nest by a given number of iterations. The strip
15971length can be changed using the @option{loop-block-tile-size}
15972parameter.
15973
15974@item ipa-jump-function-lookups
15975Specifies number of statements visited during jump function offset discovery.
15976
15977@item ipa-cp-value-list-size
15978IPA-CP attempts to track all possible values and types passed to a function's
15979parameter in order to propagate them and perform devirtualization.
15980@option{ipa-cp-value-list-size} is the maximum number of values and types it
15981stores per one formal parameter of a function.
15982
15983@item ipa-cp-eval-threshold
15984IPA-CP calculates its own score of cloning profitability heuristics
15985and performs those cloning opportunities with scores that exceed
15986@option{ipa-cp-eval-threshold}.
15987
15988@item ipa-cp-max-recursive-depth
15989Maximum depth of recursive cloning for self-recursive function.
15990
15991@item ipa-cp-min-recursive-probability
15992Recursive cloning only when the probability of call being executed exceeds
15993the parameter.
15994
15995@item ipa-cp-profile-count-base
15996When using @option{-fprofile-use} option, IPA-CP will consider the measured
15997execution count of a call graph edge at this percentage position in their
15998histogram as the basis for its heuristics calculation.
15999
16000@item ipa-cp-recursive-freq-factor
16001The number of times interprocedural copy propagation expects recursive
16002functions to call themselves.
16003
16004@item ipa-cp-recursion-penalty
16005Percentage penalty the recursive functions will receive when they
16006are evaluated for cloning.
16007
16008@item ipa-cp-single-call-penalty
16009Percentage penalty functions containing a single call to another
16010function will receive when they are evaluated for cloning.
16011
16012@item ipa-max-agg-items
16013IPA-CP is also capable to propagate a number of scalar values passed
16014in an aggregate. @option{ipa-max-agg-items} controls the maximum
16015number of such values per one parameter.
16016
16017@item ipa-cp-loop-hint-bonus
16018When IPA-CP determines that a cloning candidate would make the number
16019of iterations of a loop known, it adds a bonus of
16020@option{ipa-cp-loop-hint-bonus} to the profitability score of
16021the candidate.
16022
16023@item ipa-max-loop-predicates
16024The maximum number of different predicates IPA will use to describe when
16025loops in a function have known properties.
16026
16027@item ipa-max-aa-steps
16028During its analysis of function bodies, IPA-CP employs alias analysis
16029in order to track values pointed to by function parameters. In order
16030not spend too much time analyzing huge functions, it gives up and
16031consider all memory clobbered after examining
16032@option{ipa-max-aa-steps} statements modifying memory.
16033
16034@item ipa-max-switch-predicate-bounds
16035Maximal number of boundary endpoints of case ranges of switch statement.
16036For switch exceeding this limit, IPA-CP will not construct cloning cost
16037predicate, which is used to estimate cloning benefit, for default case
16038of the switch statement.
16039
16040@item ipa-max-param-expr-ops
16041IPA-CP will analyze conditional statement that references some function
16042parameter to estimate benefit for cloning upon certain constant value.
16043But if number of operations in a parameter expression exceeds
16044@option{ipa-max-param-expr-ops}, the expression is treated as complicated
16045one, and is not handled by IPA analysis.
16046
16047@item lto-partitions
16048Specify desired number of partitions produced during WHOPR compilation.
16049The number of partitions should exceed the number of CPUs used for compilation.
16050
16051@item lto-min-partition
16052Size of minimal partition for WHOPR (in estimated instructions).
16053This prevents expenses of splitting very small programs into too many
16054partitions.
16055
16056@item lto-max-partition
16057Size of max partition for WHOPR (in estimated instructions).
16058to provide an upper bound for individual size of partition.
16059Meant to be used only with balanced partitioning.
16060
16061@item lto-max-streaming-parallelism
16062Maximal number of parallel processes used for LTO streaming.
16063
16064@item cxx-max-namespaces-for-diagnostic-help
16065The maximum number of namespaces to consult for suggestions when C++
16066name lookup fails for an identifier.
16067
16068@item sink-frequency-threshold
16069The maximum relative execution frequency (in percents) of the target block
16070relative to a statement's original block to allow statement sinking of a
16071statement. Larger numbers result in more aggressive statement sinking.
16072A small positive adjustment is applied for
16073statements with memory operands as those are even more profitable so sink.
16074
16075@item max-stores-to-sink
16076The maximum number of conditional store pairs that can be sunk. Set to 0
16077if either vectorization (@option{-ftree-vectorize}) or if-conversion
16078(@option{-ftree-loop-if-convert}) is disabled.
16079
16080@item case-values-threshold
16081The smallest number of different values for which it is best to use a
16082jump-table instead of a tree of conditional branches. If the value is
160830, use the default for the machine.
16084
16085@item jump-table-max-growth-ratio-for-size
16086The maximum code size growth ratio when expanding
16087into a jump table (in percent). The parameter is used when
16088optimizing for size.
16089
16090@item jump-table-max-growth-ratio-for-speed
16091The maximum code size growth ratio when expanding
16092into a jump table (in percent). The parameter is used when
16093optimizing for speed.
16094
16095@item tree-reassoc-width
16096Set the maximum number of instructions executed in parallel in
16097reassociated tree. This parameter overrides target dependent
16098heuristics used by default if has non zero value.
16099
16100@item sched-pressure-algorithm
16101Choose between the two available implementations of
16102@option{-fsched-pressure}. Algorithm 1 is the original implementation
16103and is the more likely to prevent instructions from being reordered.
16104Algorithm 2 was designed to be a compromise between the relatively
16105conservative approach taken by algorithm 1 and the rather aggressive
16106approach taken by the default scheduler. It relies more heavily on
16107having a regular register file and accurate register pressure classes.
16108See @file{haifa-sched.cc} in the GCC sources for more details.
16109
16110The default choice depends on the target.
16111
16112@item max-slsr-cand-scan
16113Set the maximum number of existing candidates that are considered when
16114seeking a basis for a new straight-line strength reduction candidate.
16115
16116@item asan-globals
16117Enable buffer overflow detection for global objects. This kind
16118of protection is enabled by default if you are using
16119@option{-fsanitize=address} option.
16120To disable global objects protection use @option{--param asan-globals=0}.
16121
16122@item asan-stack
16123Enable buffer overflow detection for stack objects. This kind of
16124protection is enabled by default when using @option{-fsanitize=address}.
16125To disable stack protection use @option{--param asan-stack=0} option.
16126
16127@item asan-instrument-reads
16128Enable buffer overflow detection for memory reads. This kind of
16129protection is enabled by default when using @option{-fsanitize=address}.
16130To disable memory reads protection use
16131@option{--param asan-instrument-reads=0}.
16132
16133@item asan-instrument-writes
16134Enable buffer overflow detection for memory writes. This kind of
16135protection is enabled by default when using @option{-fsanitize=address}.
16136To disable memory writes protection use
16137@option{--param asan-instrument-writes=0} option.
16138
16139@item asan-memintrin
16140Enable detection for built-in functions. This kind of protection
16141is enabled by default when using @option{-fsanitize=address}.
16142To disable built-in functions protection use
16143@option{--param asan-memintrin=0}.
16144
16145@item asan-use-after-return
16146Enable detection of use-after-return. This kind of protection
16147is enabled by default when using the @option{-fsanitize=address} option.
16148To disable it use @option{--param asan-use-after-return=0}.
16149
16150Note: By default the check is disabled at run time. To enable it,
16151add @code{detect_stack_use_after_return=1} to the environment variable
16152@env{ASAN_OPTIONS}.
16153
16154@item asan-instrumentation-with-call-threshold
16155If number of memory accesses in function being instrumented
16156is greater or equal to this number, use callbacks instead of inline checks.
16157E.g. to disable inline code use
16158@option{--param asan-instrumentation-with-call-threshold=0}.
16159
545c9f8b 16160@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
16161If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
16162with @samp{__asan_} or @samp{__hwasan_}
16163for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
16164respectively.
545c9f8b 16165
d77de738
ML
16166@item hwasan-instrument-stack
16167Enable hwasan instrumentation of statically sized stack-allocated variables.
16168This kind of instrumentation is enabled by default when using
16169@option{-fsanitize=hwaddress} and disabled by default when using
16170@option{-fsanitize=kernel-hwaddress}.
16171To disable stack instrumentation use
16172@option{--param hwasan-instrument-stack=0}, and to enable it use
16173@option{--param hwasan-instrument-stack=1}.
16174
16175@item hwasan-random-frame-tag
16176When using stack instrumentation, decide tags for stack variables using a
16177deterministic sequence beginning at a random tag for each frame. With this
16178parameter unset tags are chosen using the same sequence but beginning from 1.
16179This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16180for @option{-fsanitize=kernel-hwaddress}.
16181To disable it use @option{--param hwasan-random-frame-tag=0}.
16182
16183@item hwasan-instrument-allocas
16184Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16185This kind of instrumentation is enabled by default when using
16186@option{-fsanitize=hwaddress} and disabled by default when using
16187@option{-fsanitize=kernel-hwaddress}.
16188To disable instrumentation of such variables use
16189@option{--param hwasan-instrument-allocas=0}, and to enable it use
16190@option{--param hwasan-instrument-allocas=1}.
16191
16192@item hwasan-instrument-reads
16193Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16194default for both @option{-fsanitize=hwaddress} and
16195@option{-fsanitize=kernel-hwaddress}.
16196To disable checking memory reads use
16197@option{--param hwasan-instrument-reads=0}.
16198
16199@item hwasan-instrument-writes
16200Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16201default for both @option{-fsanitize=hwaddress} and
16202@option{-fsanitize=kernel-hwaddress}.
16203To disable checking memory writes use
16204@option{--param hwasan-instrument-writes=0}.
16205
16206@item hwasan-instrument-mem-intrinsics
16207Enable hwasan instrumentation of builtin functions. Instrumentation of these
16208builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16209and @option{-fsanitize=kernel-hwaddress}.
16210To disable instrumentation of builtin functions use
16211@option{--param hwasan-instrument-mem-intrinsics=0}.
16212
16213@item use-after-scope-direct-emission-threshold
16214If the size of a local variable in bytes is smaller or equal to this
16215number, directly poison (or unpoison) shadow memory instead of using
16216run-time callbacks.
16217
16218@item tsan-distinguish-volatile
16219Emit special instrumentation for accesses to volatiles.
16220
16221@item tsan-instrument-func-entry-exit
16222Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16223
16224@item max-fsm-thread-path-insns
16225Maximum number of instructions to copy when duplicating blocks on a
16226finite state automaton jump thread path.
16227
16228@item threader-debug
16229threader-debug=[none|all] Enables verbose dumping of the threader solver.
16230
16231@item parloops-chunk-size
16232Chunk size of omp schedule for loops parallelized by parloops.
16233
16234@item parloops-schedule
16235Schedule type of omp schedule for loops parallelized by parloops (static,
16236dynamic, guided, auto, runtime).
16237
16238@item parloops-min-per-thread
16239The minimum number of iterations per thread of an innermost parallelized
16240loop for which the parallelized variant is preferred over the single threaded
16241one. Note that for a parallelized loop nest the
16242minimum number of iterations of the outermost loop per thread is two.
16243
16244@item max-ssa-name-query-depth
16245Maximum depth of recursion when querying properties of SSA names in things
16246like fold routines. One level of recursion corresponds to following a
16247use-def chain.
16248
16249@item max-speculative-devirt-maydefs
16250The maximum number of may-defs we analyze when looking for a must-def
16251specifying the dynamic type of an object that invokes a virtual call
16252we may be able to devirtualize speculatively.
16253
d77de738
ML
16254@item ranger-debug
16255Specifies the type of debug output to be issued for ranges.
16256
d77de738
ML
16257@item unroll-jam-min-percent
16258The minimum percentage of memory references that must be optimized
16259away for the unroll-and-jam transformation to be considered profitable.
16260
16261@item unroll-jam-max-unroll
16262The maximum number of times the outer loop should be unrolled by
16263the unroll-and-jam transformation.
16264
16265@item max-rtl-if-conversion-unpredictable-cost
16266Maximum permissible cost for the sequence that would be generated
16267by the RTL if-conversion pass for a branch that is considered unpredictable.
16268
16269@item max-variable-expansions-in-unroller
16270If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16271of times that an individual variable will be expanded during loop unrolling.
16272
16273@item partial-inlining-entry-probability
16274Maximum probability of the entry BB of split region
16275(in percent relative to entry BB of the function)
16276to make partial inlining happen.
16277
16278@item max-tracked-strlens
16279Maximum number of strings for which strlen optimization pass will
16280track string lengths.
16281
16282@item gcse-after-reload-partial-fraction
16283The threshold ratio for performing partial redundancy
16284elimination after reload.
16285
16286@item gcse-after-reload-critical-fraction
16287The threshold ratio of critical edges execution count that
16288permit performing redundancy elimination after reload.
16289
16290@item max-loop-header-insns
16291The maximum number of insns in loop header duplicated
16292by the copy loop headers pass.
16293
16294@item vect-epilogues-nomask
16295Enable loop epilogue vectorization using smaller vector size.
16296
16297@item vect-partial-vector-usage
16298Controls when the loop vectorizer considers using partial vector loads
16299and stores as an alternative to falling back to scalar code. 0 stops
16300the vectorizer from ever using partial vector loads and stores. 1 allows
16301partial vector loads and stores if vectorization removes the need for the
16302code to iterate. 2 allows partial vector loads and stores in all loops.
16303The parameter only has an effect on targets that support partial
16304vector loads and stores.
16305
16306@item vect-inner-loop-cost-factor
16307The maximum factor which the loop vectorizer applies to the cost of statements
16308in an inner loop relative to the loop being vectorized. The factor applied
16309is the maximum of the estimated number of iterations of the inner loop and
16310this parameter. The default value of this parameter is 50.
16311
16312@item vect-induction-float
16313Enable loop vectorization of floating point inductions.
16314
cbe32d38
ML
16315@item vrp-sparse-threshold
16316Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16317
16318@item vrp-switch-limit
16319Maximum number of outgoing edges in a switch before VRP will not process it.
16320
16321@item vrp-vector-threshold
16322Maximum number of basic blocks for VRP to use a basic cache vector.
16323
d77de738
ML
16324@item avoid-fma-max-bits
16325Maximum number of bits for which we avoid creating FMAs.
16326
16327@item sms-loop-average-count-threshold
16328A threshold on the average loop count considered by the swing modulo scheduler.
16329
16330@item sms-dfa-history
16331The number of cycles the swing modulo scheduler considers when checking
16332conflicts using DFA.
16333
16334@item graphite-allow-codegen-errors
16335Whether codegen errors should be ICEs when @option{-fchecking}.
16336
16337@item sms-max-ii-factor
16338A factor for tuning the upper bound that swing modulo scheduler
16339uses for scheduling a loop.
16340
16341@item lra-max-considered-reload-pseudos
16342The max number of reload pseudos which are considered during
16343spilling a non-reload pseudo.
16344
16345@item max-pow-sqrt-depth
16346Maximum depth of sqrt chains to use when synthesizing exponentiation
16347by a real constant.
16348
16349@item max-dse-active-local-stores
16350Maximum number of active local stores in RTL dead store elimination.
16351
16352@item asan-instrument-allocas
16353Enable asan allocas/VLAs protection.
16354
16355@item max-iterations-computation-cost
16356Bound on the cost of an expression to compute the number of iterations.
16357
16358@item max-isl-operations
16359Maximum number of isl operations, 0 means unlimited.
16360
16361@item graphite-max-arrays-per-scop
16362Maximum number of arrays per scop.
16363
16364@item max-vartrack-reverse-op-size
16365Max. size of loc list for which reverse ops should be added.
16366
16367@item fsm-scale-path-stmts
16368Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16369crossing a loop backedge when comparing to
16370@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16371
16372@item uninit-control-dep-attempts
16373Maximum number of nested calls to search for control dependencies
16374during uninitialized variable analysis.
16375
b8a2a124
RB
16376@item uninit-max-chain-len
16377Maximum number of predicates anded for each predicate ored in the normalized
16378predicate chain.
16379
16380@item uninit-max-num-chains
16381Maximum number of predicates ored in the normalized predicate chain.
16382
d77de738
ML
16383@item sched-autopref-queue-depth
16384Hardware autoprefetcher scheduler model control flag.
16385Number of lookahead cycles the model looks into; at '
16386' only enable instruction sorting heuristic.
16387
16388@item loop-versioning-max-inner-insns
16389The maximum number of instructions that an inner loop can have
16390before the loop versioning pass considers it too big to copy.
16391
16392@item loop-versioning-max-outer-insns
16393The maximum number of instructions that an outer loop can have
16394before the loop versioning pass considers it too big to copy,
16395discounting any instructions in inner loops that directly benefit
16396from versioning.
16397
16398@item ssa-name-def-chain-limit
16399The maximum number of SSA_NAME assignments to follow in determining
16400a property of a variable such as its value. This limits the number
16401of iterations or recursive calls GCC performs when optimizing certain
16402statements or when determining their validity prior to issuing
16403diagnostics.
16404
16405@item store-merging-max-size
16406Maximum size of a single store merging region in bytes.
16407
16408@item hash-table-verification-limit
16409The number of elements for which hash table verification is done
16410for each searched element.
16411
16412@item max-find-base-term-values
16413Maximum number of VALUEs handled during a single find_base_term call.
16414
16415@item analyzer-max-enodes-per-program-point
16416The maximum number of exploded nodes per program point within
16417the analyzer, before terminating analysis of that point.
16418
16419@item analyzer-max-constraints
16420The maximum number of constraints per state.
16421
16422@item analyzer-min-snodes-for-call-summary
16423The minimum number of supernodes within a function for the
16424analyzer to consider summarizing its effects at call sites.
16425
16426@item analyzer-max-enodes-for-full-dump
16427The maximum depth of exploded nodes that should appear in a dot dump
16428before switching to a less verbose format.
16429
16430@item analyzer-max-recursion-depth
16431The maximum number of times a callsite can appear in a call stack
16432within the analyzer, before terminating analysis of a call that would
16433recurse deeper.
16434
16435@item analyzer-max-svalue-depth
16436The maximum depth of a symbolic value, before approximating
16437the value as unknown.
16438
16439@item analyzer-max-infeasible-edges
16440The maximum number of infeasible edges to reject before declaring
16441a diagnostic as infeasible.
16442
16443@item gimple-fe-computed-hot-bb-threshold
16444The number of executions of a basic block which is considered hot.
16445The parameter is used only in GIMPLE FE.
16446
16447@item analyzer-bb-explosion-factor
16448The maximum number of 'after supernode' exploded nodes within the analyzer
16449per supernode, before terminating analysis.
16450
c0c5a57b
MJ
16451@item analyzer-text-art-string-ellipsis-threshold
16452The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
16453
16454@item analyzer-text-art-ideal-canvas-width
16455The ideal width in characters of text art diagrams generated by the analyzer.
16456
16457@item analyzer-text-art-string-ellipsis-head-len
16458The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
16459
16460@item analyzer-text-art-string-ellipsis-tail-len
16461The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
16462
d77de738
ML
16463@item ranger-logical-depth
16464Maximum depth of logical expression evaluation ranger will look through
16465when evaluating outgoing edge ranges.
16466
9fd6d83a
ML
16467@item ranger-recompute-depth
16468Maximum depth of instruction chains to consider for recomputation
16469in the outgoing range calculator.
16470
d77de738
ML
16471@item relation-block-limit
16472Maximum number of relations the oracle will register in a basic block.
16473
16474@item min-pagesize
16475Minimum page size for warning purposes.
16476
16477@item openacc-kernels
16478Specify mode of OpenACC `kernels' constructs handling.
16479With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16480constructs are decomposed into parts, a sequence of compute
16481constructs, each then handled individually.
16482This is work in progress.
16483With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16484constructs are handled by the @samp{parloops} pass, en bloc.
16485This is the current default.
16486
16487@item openacc-privatization
4ace81b6
SL
16488Control whether the @option{-fopt-info-omp-note} and applicable
16489@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16490With @option{--param=openacc-privatization=quiet}, don't diagnose.
16491This is the current default.
16492With @option{--param=openacc-privatization=noisy}, do diagnose.
16493
16494@end table
16495
16496The following choices of @var{name} are available on AArch64 targets:
16497
16498@table @gcctabopt
16499@item aarch64-sve-compare-costs
16500When vectorizing for SVE, consider using ``unpacked'' vectors for
16501smaller elements and use the cost model to pick the cheapest approach.
16502Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16503
16504Using unpacked vectors includes storing smaller elements in larger
16505containers and accessing elements with extending loads and truncating
16506stores.
16507
16508@item aarch64-float-recp-precision
16509The number of Newton iterations for calculating the reciprocal for float type.
16510The precision of division is proportional to this param when division
16511approximation is enabled. The default value is 1.
16512
16513@item aarch64-double-recp-precision
16514The number of Newton iterations for calculating the reciprocal for double type.
16515The precision of division is propotional to this param when division
16516approximation is enabled. The default value is 2.
16517
16518@item aarch64-autovec-preference
16519Force an ISA selection strategy for auto-vectorization. Accepts values from
165200 to 4, inclusive.
16521@table @samp
16522@item 0
16523Use the default heuristics.
16524@item 1
16525Use only Advanced SIMD for auto-vectorization.
16526@item 2
16527Use only SVE for auto-vectorization.
16528@item 3
16529Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16530deemed equal.
16531@item 4
16532Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16533@end table
16534The default value is 0.
16535
834fc2bf
MA
16536@item aarch64-ldp-policy
16537Fine-grained policy for load pairs.
16538With @option{--param=aarch64-ldp-policy=default}, use the policy of the
16539tuning structure. This is the current default.
16540With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
16541of alignment.
16542With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
16543With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
16544source pointer is aligned to at least double the alignment of the type.
16545
16546@item aarch64-stp-policy
16547Fine-grained policy for store pairs.
16548With @option{--param=aarch64-stp-policy=default}, use the policy of the
16549tuning structure. This is the current default.
16550With @option{--param=aarch64-stp-policy=always}, emit stp regardless
16551of alignment.
16552With @option{--param=aarch64-stp-policy=never}, do not emit stp.
16553With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
16554source pointer is aligned to at least double the alignment of the type.
16555
d77de738
ML
16556@item aarch64-loop-vect-issue-rate-niters
16557The tuning for some AArch64 CPUs tries to take both latencies and issue
16558rates into account when deciding whether a loop should be vectorized
16559using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16560If this parameter is set to @var{n}, GCC will not use this heuristic
16561for loops that are known to execute in fewer than @var{n} Advanced
16562SIMD iterations.
16563
16564@item aarch64-vect-unroll-limit
16565The vectorizer will use available tuning information to determine whether it
16566would be beneficial to unroll the main vectorized loop and by how much. This
16567parameter set's the upper bound of how much the vectorizer will unroll the main
16568loop. The default value is four.
16569
16570@end table
16571
16572The following choices of @var{name} are available on i386 and x86_64 targets:
16573
16574@table @gcctabopt
16575@item x86-stlf-window-ninsns
16576Instructions number above which STFL stall penalty can be compensated.
16577
60101899
RB
16578@item x86-stv-max-visits
16579The maximum number of use and def visits when discovering a STV chain before
16580the discovery is aborted.
16581
d77de738
ML
16582@end table
16583
16584@end table
16585
16586@node Instrumentation Options
16587@section Program Instrumentation Options
16588@cindex instrumentation options
16589@cindex program instrumentation options
16590@cindex run-time error checking options
16591@cindex profiling options
16592@cindex options, program instrumentation
16593@cindex options, run-time error checking
16594@cindex options, profiling
16595
16596GCC supports a number of command-line options that control adding
16597run-time instrumentation to the code it normally generates.
16598For example, one purpose of instrumentation is collect profiling
16599statistics for use in finding program hot spots, code coverage
16600analysis, or profile-guided optimizations.
16601Another class of program instrumentation is adding run-time checking
16602to detect programming errors like invalid pointer
16603dereferences or out-of-bounds array accesses, as well as deliberately
16604hostile attacks such as stack smashing or C++ vtable hijacking.
16605There is also a general hook which can be used to implement other
16606forms of tracing or function-level instrumentation for debug or
16607program analysis purposes.
16608
16609@table @gcctabopt
16610@cindex @command{prof}
16611@cindex @command{gprof}
d77de738
ML
16612@opindex p
16613@opindex pg
ddf6fe37
AA
16614@item -p
16615@itemx -pg
d77de738
ML
16616Generate extra code to write profile information suitable for the
16617analysis program @command{prof} (for @option{-p}) or @command{gprof}
16618(for @option{-pg}). You must use this option when compiling
16619the source files you want data about, and you must also use it when
16620linking.
16621
16622You can use the function attribute @code{no_instrument_function} to
16623suppress profiling of individual functions when compiling with these options.
16624@xref{Common Function Attributes}.
16625
d77de738 16626@opindex fprofile-arcs
ddf6fe37 16627@item -fprofile-arcs
d77de738
ML
16628Add code so that program flow @dfn{arcs} are instrumented. During
16629execution the program records how many times each branch and call is
16630executed and how many times it is taken or returns. On targets that support
16631constructors with priority support, profiling properly handles constructors,
16632destructors and C++ constructors (and destructors) of classes which are used
16633as a type of a global variable.
16634
16635When the compiled
16636program exits it saves this data to a file called
16637@file{@var{auxname}.gcda} for each source file. The data may be used for
16638profile-directed optimizations (@option{-fbranch-probabilities}), or for
16639test coverage analysis (@option{-ftest-coverage}). Each object file's
16640@var{auxname} is generated from the name of the output file, if
16641explicitly specified and it is not the final executable, otherwise it is
16642the basename of the source file. In both cases any suffix is removed
16643(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16644@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16645
16646Note that if a command line directly links source files, the corresponding
16647@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16648E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16649@file{binary-b.gcda} files.
16650
16651@xref{Cross-profiling}.
16652
16653@cindex @command{gcov}
d77de738 16654@opindex coverage
ddf6fe37 16655@item --coverage
d77de738
ML
16656
16657This option is used to compile and link code instrumented for coverage
16658analysis. The option is a synonym for @option{-fprofile-arcs}
16659@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16660linking). See the documentation for those options for more details.
16661
16662@itemize
16663
16664@item
16665Compile the source files with @option{-fprofile-arcs} plus optimization
16666and code generation options. For test coverage analysis, use the
16667additional @option{-ftest-coverage} option. You do not need to profile
16668every source file in a program.
16669
16670@item
16671Compile the source files additionally with @option{-fprofile-abs-path}
16672to create absolute path names in the @file{.gcno} files. This allows
16673@command{gcov} to find the correct sources in projects where compilations
16674occur with different working directories.
16675
16676@item
16677Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16678(the latter implies the former).
16679
16680@item
16681Run the program on a representative workload to generate the arc profile
16682information. This may be repeated any number of times. You can run
16683concurrent instances of your program, and provided that the file system
16684supports locking, the data files will be correctly updated. Unless
16685a strict ISO C dialect option is in effect, @code{fork} calls are
16686detected and correctly handled without double counting.
16687
16688Moreover, an object file can be recompiled multiple times
16689and the corresponding @file{.gcda} file merges as long as
16690the source file and the compiler options are unchanged.
16691
16692@item
16693For profile-directed optimizations, compile the source files again with
16694the same optimization and code generation options plus
16695@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16696Control Optimization}).
16697
16698@item
16699For test coverage analysis, use @command{gcov} to produce human readable
16700information from the @file{.gcno} and @file{.gcda} files. Refer to the
16701@command{gcov} documentation for further information.
16702
16703@end itemize
16704
16705With @option{-fprofile-arcs}, for each function of your program GCC
16706creates a program flow graph, then finds a spanning tree for the graph.
16707Only arcs that are not on the spanning tree have to be instrumented: the
16708compiler adds code to count the number of times that these arcs are
16709executed. When an arc is the only exit or only entrance to a block, the
16710instrumentation code can be added to the block; otherwise, a new basic
16711block must be created to hold the instrumentation code.
16712
16713@need 2000
d77de738 16714@opindex ftest-coverage
ddf6fe37 16715@item -ftest-coverage
d77de738
ML
16716Produce a notes file that the @command{gcov} code-coverage utility
16717(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16718show program coverage. Each source file's note file is called
16719@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16720above for a description of @var{auxname} and instructions on how to
16721generate test coverage data. Coverage data matches the source files
16722more closely if you do not optimize.
16723
d77de738 16724@opindex fprofile-abs-path
ddf6fe37 16725@item -fprofile-abs-path
d77de738
ML
16726Automatically convert relative source file names to absolute path names
16727in the @file{.gcno} files. This allows @command{gcov} to find the correct
16728sources in projects where compilations occur with different working
16729directories.
16730
d77de738 16731@opindex fprofile-dir
ddf6fe37 16732@item -fprofile-dir=@var{path}
d77de738
ML
16733
16734Set the directory to search for the profile data files in to @var{path}.
16735This option affects only the profile data generated by
16736@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16737and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16738and its related options. Both absolute and relative paths can be used.
16739By default, GCC uses the current directory as @var{path}, thus the
16740profile data file appears in the same directory as the object file.
16741In order to prevent the file name clashing, if the object file name is
16742not an absolute path, we mangle the absolute path of the
16743@file{@var{sourcename}.gcda} file and use it as the file name of a
16744@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16745See similar option @option{-fprofile-note}.
16746
16747When an executable is run in a massive parallel environment, it is recommended
16748to save profile to different folders. That can be done with variables
16749in @var{path} that are exported during run-time:
16750
16751@table @gcctabopt
16752
16753@item %p
16754process ID.
16755
16756@item %q@{VAR@}
16757value of environment variable @var{VAR}
16758
16759@end table
16760
ddf6fe37 16761@opindex fprofile-generate
d77de738
ML
16762@item -fprofile-generate
16763@itemx -fprofile-generate=@var{path}
d77de738
ML
16764
16765Enable options usually used for instrumenting application to produce
16766profile useful for later recompilation with profile feedback based
16767optimization. You must use @option{-fprofile-generate} both when
16768compiling and when linking your program.
16769
16770The following options are enabled:
16771@option{-fprofile-arcs}, @option{-fprofile-values},
16772@option{-finline-functions}, and @option{-fipa-bit-cp}.
16773
16774If @var{path} is specified, GCC looks at the @var{path} to find
16775the profile feedback data files. See @option{-fprofile-dir}.
16776
16777To optimize the program based on the collected profile information, use
16778@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16779
ddf6fe37 16780@opindex fprofile-info-section
d77de738
ML
16781@item -fprofile-info-section
16782@itemx -fprofile-info-section=@var{name}
d77de738
ML
16783
16784Register the profile information in the specified section instead of using a
16785constructor/destructor. The section name is @var{name} if it is specified,
16786otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16787profile information generated by @option{-fprofile-arcs} is placed in the
16788specified section for each translation unit. This option disables the profile
16789information registration through a constructor and it disables the profile
16790information processing through a destructor. This option is not intended to be
16791used in hosted environments such as GNU/Linux. It targets freestanding
16792environments (for example embedded systems) with limited resources which do not
16793support constructors/destructors or the C library file I/O.
16794
16795The linker could collect the input sections in a continuous memory block and
16796define start and end symbols. A GNU linker script example which defines a
16797linker output section follows:
16798
16799@smallexample
16800 .gcov_info :
16801 @{
16802 PROVIDE (__gcov_info_start = .);
16803 KEEP (*(.gcov_info))
16804 PROVIDE (__gcov_info_end = .);
16805 @}
16806@end smallexample
16807
16808The program could dump the profiling information registered in this linker set
16809for example like this:
16810
16811@smallexample
16812#include <gcov.h>
16813#include <stdio.h>
16814#include <stdlib.h>
16815
16816extern const struct gcov_info *const __gcov_info_start[];
16817extern const struct gcov_info *const __gcov_info_end[];
16818
16819static void
16820dump (const void *d, unsigned n, void *arg)
16821@{
16822 const unsigned char *c = d;
16823
16824 for (unsigned i = 0; i < n; ++i)
16825 printf ("%02x", c[i]);
16826@}
16827
16828static void
16829filename (const char *f, void *arg)
16830@{
16831 __gcov_filename_to_gcfn (f, dump, arg );
16832@}
16833
16834static void *
16835allocate (unsigned length, void *arg)
16836@{
16837 return malloc (length);
16838@}
16839
16840static void
16841dump_gcov_info (void)
16842@{
16843 const struct gcov_info *const *info = __gcov_info_start;
16844 const struct gcov_info *const *end = __gcov_info_end;
16845
16846 /* Obfuscate variable to prevent compiler optimizations. */
16847 __asm__ ("" : "+r" (info));
16848
16849 while (info != end)
16850 @{
16851 void *arg = NULL;
16852 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16853 putchar ('\n');
16854 ++info;
16855 @}
16856@}
16857
16858int
16859main (void)
16860@{
16861 dump_gcov_info ();
16862 return 0;
16863@}
16864@end smallexample
16865
16866The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16867deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16868@code{__gcov_info_to_gcda} functions and merge the profile information into
16869@file{.gcda} files on the host filesystem.
16870
d77de738 16871@opindex fprofile-note
ddf6fe37 16872@item -fprofile-note=@var{path}
d77de738
ML
16873
16874If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16875location. If you combine the option with multiple source files,
16876the @file{.gcno} file will be overwritten.
16877
d77de738 16878@opindex fprofile-prefix-path
ddf6fe37 16879@item -fprofile-prefix-path=@var{path}
d77de738
ML
16880
16881This option can be used in combination with
16882@option{profile-generate=}@var{profile_dir} and
16883@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16884directory of built source tree. By default @var{profile_dir} will contain
16885files with mangled absolute paths of all object files in the built project.
16886This is not desirable when directory used to build the instrumented binary
16887differs from the directory used to build the binary optimized with profile
16888feedback because the profile data will not be found during the optimized build.
16889In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16890pointing to the base directory of the build can be used to strip the irrelevant
16891part of the path and keep all file names relative to the main build directory.
16892
d77de738 16893@opindex fprofile-prefix-map
ddf6fe37 16894@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16895When compiling files residing in directory @file{@var{old}}, record
16896profiling information (with @option{--coverage})
16897describing them as if the files resided in
16898directory @file{@var{new}} instead.
2eb0191a 16899See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16900
d77de738 16901@opindex fprofile-update
ddf6fe37 16902@item -fprofile-update=@var{method}
d77de738
ML
16903
16904Alter the update method for an application instrumented for profile
16905feedback based optimization. The @var{method} argument should be one of
16906@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16907The first one is useful for single-threaded applications,
16908while the second one prevents profile corruption by emitting thread-safe code.
16909
16910@strong{Warning:} When an application does not properly join all threads
16911(or creates an detached thread), a profile file can be still corrupted.
16912
16913Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16914when supported by a target, or to @samp{single} otherwise. The GCC driver
16915automatically selects @samp{prefer-atomic} when @option{-pthread}
16916is present in the command line.
16917
d77de738 16918@opindex fprofile-filter-files
ddf6fe37 16919@item -fprofile-filter-files=@var{regex}
d77de738
ML
16920
16921Instrument only functions from files whose name matches
16922any of the regular expressions (separated by semi-colons).
16923
16924For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16925only @file{main.c} and all C files starting with 'module'.
16926
d77de738 16927@opindex fprofile-exclude-files
ddf6fe37 16928@item -fprofile-exclude-files=@var{regex}
d77de738
ML
16929
16930Instrument only functions from files whose name does not match
16931any of the regular expressions (separated by semi-colons).
16932
16933For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16934of all files that are located in the @file{/usr/} folder.
16935
d77de738 16936@opindex fprofile-reproducible
ddf6fe37 16937@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
16938Control level of reproducibility of profile gathered by
16939@code{-fprofile-generate}. This makes it possible to rebuild program
16940with same outcome which is useful, for example, for distribution
16941packages.
16942
16943With @option{-fprofile-reproducible=serial} the profile gathered by
16944@option{-fprofile-generate} is reproducible provided the trained program
16945behaves the same at each invocation of the train run, it is not
16946multi-threaded and profile data streaming is always done in the same
16947order. Note that profile streaming happens at the end of program run but
16948also before @code{fork} function is invoked.
16949
16950Note that it is quite common that execution counts of some part of
16951programs depends, for example, on length of temporary file names or
16952memory space randomization (that may affect hash-table collision rate).
16953Such non-reproducible part of programs may be annotated by
16954@code{no_instrument_function} function attribute. @command{gcov-dump} with
16955@option{-l} can be used to dump gathered data and verify that they are
16956indeed reproducible.
16957
16958With @option{-fprofile-reproducible=parallel-runs} collected profile
16959stays reproducible regardless the order of streaming of the data into
16960gcda files. This setting makes it possible to run multiple instances of
16961instrumented program in parallel (such as with @code{make -j}). This
16962reduces quality of gathered data, in particular of indirect call
16963profiling.
16964
d77de738 16965@opindex fsanitize=address
ddf6fe37 16966@item -fsanitize=address
d77de738
ML
16967Enable AddressSanitizer, a fast memory error detector.
16968Memory access instructions are instrumented to detect
16969out-of-bounds and use-after-free bugs.
16970The option enables @option{-fsanitize-address-use-after-scope}.
16971See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16972more details. The run-time behavior can be influenced using the
16973@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16974the available options are shown at startup of the instrumented program. See
16975@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16976for a list of supported options.
16977The option cannot be combined with @option{-fsanitize=thread} or
16978@option{-fsanitize=hwaddress}. Note that the only target
16979@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16980
6a07798c
MP
16981To get more accurate stack traces, it is possible to use options such as
16982@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16983most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16984optimizing sibling and tail recursive calls; this option is implicit for
16985@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16986disables Identical Code Folding for functions). Since multiple runs of the
16987program may yield backtraces with different addresses due to ASLR (Address
16988Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16989this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16990
d77de738 16991@opindex fsanitize=kernel-address
f33d7a88 16992@item -fsanitize=kernel-address
d77de738 16993Enable AddressSanitizer for Linux kernel.
a0bf71be 16994See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 16995
d77de738 16996@opindex fsanitize=hwaddress
f33d7a88 16997@item -fsanitize=hwaddress
d77de738
ML
16998Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16999ignore the top byte of a pointer to allow the detection of memory errors with
17000a low memory overhead.
17001Memory access instructions are instrumented to detect out-of-bounds and
17002use-after-free bugs.
17003The option enables @option{-fsanitize-address-use-after-scope}.
17004See
17005@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
17006for more details. The run-time behavior can be influenced using the
17007@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
17008the available options are shown at startup of the instrumented program.
17009The option cannot be combined with @option{-fsanitize=thread} or
17010@option{-fsanitize=address}, and is currently only available on AArch64.
17011
d77de738 17012@opindex fsanitize=kernel-hwaddress
ddf6fe37 17013@item -fsanitize=kernel-hwaddress
d77de738
ML
17014Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
17015Similar to @option{-fsanitize=kernel-address} but using an alternate
17016instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
17017instrumentation differences necessary for compiling the Linux kernel.
17018These differences are to avoid hwasan library initialization calls and to
17019account for the stack pointer having a different value in its top byte.
17020
17021@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
17022Instrumenting the stack and alloca calls are not on by default but are still
17023possible by specifying the command-line options
17024@option{--param hwasan-instrument-stack=1} and
17025@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
17026tag is not implemented for kernel instrumentation.
17027
d77de738 17028@opindex fsanitize=pointer-compare
ddf6fe37 17029@item -fsanitize=pointer-compare
d77de738
ML
17030Instrument comparison operation (<, <=, >, >=) with pointer operands.
17031The option must be combined with either @option{-fsanitize=kernel-address} or
17032@option{-fsanitize=address}
17033The option cannot be combined with @option{-fsanitize=thread}.
17034Note: By default the check is disabled at run time. To enable it,
17035add @code{detect_invalid_pointer_pairs=2} to the environment variable
17036@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17037invalid operation only when both pointers are non-null.
17038
d77de738 17039@opindex fsanitize=pointer-subtract
ddf6fe37 17040@item -fsanitize=pointer-subtract
d77de738
ML
17041Instrument subtraction with pointer operands.
17042The option must be combined with either @option{-fsanitize=kernel-address} or
17043@option{-fsanitize=address}
17044The option cannot be combined with @option{-fsanitize=thread}.
17045Note: By default the check is disabled at run time. To enable it,
17046add @code{detect_invalid_pointer_pairs=2} to the environment variable
17047@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17048invalid operation only when both pointers are non-null.
17049
d77de738 17050@opindex fsanitize=shadow-call-stack
ddf6fe37 17051@item -fsanitize=shadow-call-stack
d77de738
ML
17052Enable ShadowCallStack, a security enhancement mechanism used to protect
17053programs against return address overwrites (e.g. stack buffer overflows.)
17054It works by saving a function's return address to a separately allocated
17055shadow call stack in the function prologue and restoring the return address
17056from the shadow call stack in the function epilogue. Instrumentation only
17057occurs in functions that need to save the return address to the stack.
17058
17059Currently it only supports the aarch64 platform. It is specifically
17060designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
17061For the user space programs, runtime support is not currently provided
17062in libc and libgcc. Users who want to use this feature in user space need
17063to provide their own support for the runtime. It should be noted that
17064this may cause the ABI rules to be broken.
17065
17066On aarch64, the instrumentation makes use of the platform register @code{x18}.
17067This generally means that any code that may run on the same thread as code
17068compiled with ShadowCallStack must be compiled with the flag
17069@option{-ffixed-x18}, otherwise functions compiled without
17070@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
17071stack pointer.
17072
17073Also, because there is no userspace runtime support, code compiled with
17074ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
17075to turn off exceptions.
17076
17077See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
17078details.
17079
d77de738 17080@opindex fsanitize=thread
ddf6fe37 17081@item -fsanitize=thread
d77de738
ML
17082Enable ThreadSanitizer, a fast data race detector.
17083Memory access instructions are instrumented to detect
17084data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
17085details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
17086environment variable; see
17087@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
17088supported options.
17089The option cannot be combined with @option{-fsanitize=address},
17090@option{-fsanitize=leak}.
17091
17092Note that sanitized atomic builtins cannot throw exceptions when
17093operating on invalid memory addresses with non-call exceptions
17094(@option{-fnon-call-exceptions}).
17095
d77de738 17096@opindex fsanitize=leak
ddf6fe37 17097@item -fsanitize=leak
d77de738 17098Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
17099This option only matters for linking of executables.
17100The executable is linked against a library that overrides @code{malloc}
d77de738
ML
17101and other allocator functions. See
17102@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
17103details. The run-time behavior can be influenced using the
17104@env{LSAN_OPTIONS} environment variable.
17105The option cannot be combined with @option{-fsanitize=thread}.
17106
d77de738 17107@opindex fsanitize=undefined
ddf6fe37 17108@item -fsanitize=undefined
d77de738
ML
17109Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
17110Various computations are instrumented to detect undefined behavior
17111at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
17112@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
17113
17114@table @gcctabopt
17115
d77de738 17116@opindex fsanitize=shift
ddf6fe37 17117@item -fsanitize=shift
d77de738
ML
17118This option enables checking that the result of a shift operation is
17119not undefined. Note that what exactly is considered undefined differs
17120slightly between C and C++, as well as between ISO C90 and C99, etc.
17121This option has two suboptions, @option{-fsanitize=shift-base} and
17122@option{-fsanitize=shift-exponent}.
17123
d77de738 17124@opindex fsanitize=shift-exponent
ddf6fe37 17125@item -fsanitize=shift-exponent
d77de738
ML
17126This option enables checking that the second argument of a shift operation
17127is not negative and is smaller than the precision of the promoted first
17128argument.
17129
d77de738 17130@opindex fsanitize=shift-base
ddf6fe37 17131@item -fsanitize=shift-base
d77de738
ML
17132If the second argument of a shift operation is within range, check that the
17133result of a shift operation is not undefined. Note that what exactly is
17134considered undefined differs slightly between C and C++, as well as between
17135ISO C90 and C99, etc.
17136
d77de738 17137@opindex fsanitize=integer-divide-by-zero
ddf6fe37 17138@item -fsanitize=integer-divide-by-zero
d77de738
ML
17139Detect integer division by zero.
17140
d77de738 17141@opindex fsanitize=unreachable
ddf6fe37 17142@item -fsanitize=unreachable
d77de738
ML
17143With this option, the compiler turns the @code{__builtin_unreachable}
17144call into a diagnostics message call instead. When reaching the
17145@code{__builtin_unreachable} call, the behavior is undefined.
17146
d77de738 17147@opindex fsanitize=vla-bound
ddf6fe37 17148@item -fsanitize=vla-bound
d77de738
ML
17149This option instructs the compiler to check that the size of a variable
17150length array is positive.
17151
d77de738 17152@opindex fsanitize=null
ddf6fe37 17153@item -fsanitize=null
d77de738
ML
17154This option enables pointer checking. Particularly, the application
17155built with this option turned on will issue an error message when it
17156tries to dereference a NULL pointer, or if a reference (possibly an
17157rvalue reference) is bound to a NULL pointer, or if a method is invoked
17158on an object pointed by a NULL pointer.
17159
d77de738 17160@opindex fsanitize=return
ddf6fe37 17161@item -fsanitize=return
d77de738
ML
17162This option enables return statement checking. Programs
17163built with this option turned on will issue an error message
17164when the end of a non-void function is reached without actually
17165returning a value. This option works in C++ only.
17166
d77de738 17167@opindex fsanitize=signed-integer-overflow
ddf6fe37 17168@item -fsanitize=signed-integer-overflow
d77de738
ML
17169This option enables signed integer overflow checking. We check that
17170the result of @code{+}, @code{*}, and both unary and binary @code{-}
17171does not overflow in the signed arithmetics. This also detects
17172@code{INT_MIN / -1} signed division. Note, integer promotion
17173rules must be taken into account. That is, the following is not an
17174overflow:
17175@smallexample
17176signed char a = SCHAR_MAX;
17177a++;
17178@end smallexample
17179
d77de738 17180@opindex fsanitize=bounds
ddf6fe37 17181@item -fsanitize=bounds
d77de738
ML
17182This option enables instrumentation of array bounds. Various out of bounds
17183accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
17184arrays, and initializers of variables with static storage are not
17185instrumented, with the exception of flexible array member-like arrays
17186for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
17187options or @code{strict_flex_array} attributes say they shouldn't be treated
17188like flexible array member-like arrays.
d77de738 17189
d77de738 17190@opindex fsanitize=bounds-strict
ddf6fe37 17191@item -fsanitize=bounds-strict
d77de738 17192This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
17193accesses are detected, including flexible array member-like arrays.
17194Initializers of variables with static storage are not instrumented.
d77de738 17195
d77de738 17196@opindex fsanitize=alignment
ddf6fe37 17197@item -fsanitize=alignment
d77de738
ML
17198
17199This option enables checking of alignment of pointers when they are
17200dereferenced, or when a reference is bound to insufficiently aligned target,
17201or when a method or constructor is invoked on insufficiently aligned object.
17202
d77de738 17203@opindex fsanitize=object-size
ddf6fe37 17204@item -fsanitize=object-size
d77de738 17205This option enables instrumentation of memory references using the
7283380a
SP
17206@code{__builtin_dynamic_object_size} function. Various out of bounds
17207pointer accesses are detected.
d77de738 17208
d77de738 17209@opindex fsanitize=float-divide-by-zero
ddf6fe37 17210@item -fsanitize=float-divide-by-zero
d77de738
ML
17211Detect floating-point division by zero. Unlike other similar options,
17212@option{-fsanitize=float-divide-by-zero} is not enabled by
17213@option{-fsanitize=undefined}, since floating-point division by zero can
17214be a legitimate way of obtaining infinities and NaNs.
17215
d77de738 17216@opindex fsanitize=float-cast-overflow
ddf6fe37 17217@item -fsanitize=float-cast-overflow
d77de738
ML
17218This option enables floating-point type to integer conversion checking.
17219We check that the result of the conversion does not overflow.
17220Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17221not enabled by @option{-fsanitize=undefined}.
17222This option does not work well with @code{FE_INVALID} exceptions enabled.
17223
d77de738 17224@opindex fsanitize=nonnull-attribute
ddf6fe37 17225@item -fsanitize=nonnull-attribute
d77de738
ML
17226
17227This option enables instrumentation of calls, checking whether null values
17228are not passed to arguments marked as requiring a non-null value by the
17229@code{nonnull} function attribute.
17230
d77de738 17231@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 17232@item -fsanitize=returns-nonnull-attribute
d77de738
ML
17233
17234This option enables instrumentation of return statements in functions
17235marked with @code{returns_nonnull} function attribute, to detect returning
17236of null values from such functions.
17237
d77de738 17238@opindex fsanitize=bool
ddf6fe37 17239@item -fsanitize=bool
d77de738
ML
17240
17241This option enables instrumentation of loads from bool. If a value other
17242than 0/1 is loaded, a run-time error is issued.
17243
d77de738 17244@opindex fsanitize=enum
ddf6fe37 17245@item -fsanitize=enum
d77de738
ML
17246
17247This option enables instrumentation of loads from an enum type. If
17248a value outside the range of values for the enum type is loaded,
17249a run-time error is issued.
17250
d77de738 17251@opindex fsanitize=vptr
ddf6fe37 17252@item -fsanitize=vptr
d77de738
ML
17253
17254This option enables instrumentation of C++ member function calls, member
17255accesses and some conversions between pointers to base and derived classes,
17256to verify the referenced object has the correct dynamic type.
17257
d77de738 17258@opindex fsanitize=pointer-overflow
ddf6fe37 17259@item -fsanitize=pointer-overflow
d77de738
ML
17260
17261This option enables instrumentation of pointer arithmetics. If the pointer
17262arithmetics overflows, a run-time error is issued.
17263
d77de738 17264@opindex fsanitize=builtin
ddf6fe37 17265@item -fsanitize=builtin
d77de738
ML
17266
17267This option enables instrumentation of arguments to selected builtin
17268functions. If an invalid value is passed to such arguments, a run-time
17269error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17270or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17271by this option.
17272
17273@end table
17274
17275Note that sanitizers tend to increase the rate of false positive
17276warnings, most notably those around @option{-Wmaybe-uninitialized}.
17277We recommend against combining @option{-Werror} and [the use of]
17278sanitizers.
17279
17280While @option{-ftrapv} causes traps for signed overflows to be emitted,
17281@option{-fsanitize=undefined} gives a diagnostic message.
17282This currently works only for the C family of languages.
17283
d77de738 17284@opindex fno-sanitize=all
ddf6fe37 17285@item -fno-sanitize=all
d77de738
ML
17286
17287This option disables all previously enabled sanitizers.
17288@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17289together.
17290
d77de738 17291@opindex fasan-shadow-offset
ddf6fe37 17292@item -fasan-shadow-offset=@var{number}
d77de738
ML
17293This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17294It is useful for experimenting with different shadow memory layouts in
17295Kernel AddressSanitizer.
17296
d77de738 17297@opindex fsanitize-sections
ddf6fe37 17298@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
17299Sanitize global variables in selected user-defined sections. @var{si} may
17300contain wildcards.
17301
d77de738
ML
17302@opindex fsanitize-recover
17303@opindex fno-sanitize-recover
ddf6fe37 17304@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17305@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17306mentioned in comma-separated list of @var{opts}. Enabling this option
17307for a sanitizer component causes it to attempt to continue
17308running the program as if no error happened. This means multiple
17309runtime errors can be reported in a single program run, and the exit
17310code of the program may indicate success even when errors
17311have been reported. The @option{-fno-sanitize-recover=} option
17312can be used to alter
17313this behavior: only the first detected error is reported
17314and program then exits with a non-zero exit code.
17315
17316Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17317except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17318@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17319@option{-fsanitize=bounds-strict},
17320@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17321For these sanitizers error recovery is turned on by default,
17322except @option{-fsanitize=address}, for which this feature is experimental.
17323@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17324accepted, the former enables recovery for all sanitizers that support it,
17325the latter disables recovery for all sanitizers that support it.
17326
17327Even if a recovery mode is turned on the compiler side, it needs to be also
17328enabled on the runtime library side, otherwise the failures are still fatal.
17329The runtime library defaults to @code{halt_on_error=0} for
17330ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17331AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17332setting the @code{halt_on_error} flag in the corresponding environment variable.
17333
17334Syntax without an explicit @var{opts} parameter is deprecated. It is
17335equivalent to specifying an @var{opts} list of:
17336
17337@smallexample
17338undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17339@end smallexample
17340
d77de738 17341@opindex fsanitize-address-use-after-scope
ddf6fe37 17342@item -fsanitize-address-use-after-scope
d77de738
ML
17343Enable sanitization of local variables to detect use-after-scope bugs.
17344The option sets @option{-fstack-reuse} to @samp{none}.
17345
d77de738
ML
17346@opindex fsanitize-trap
17347@opindex fno-sanitize-trap
ddf6fe37 17348@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17349The @option{-fsanitize-trap=} option instructs the compiler to
17350report for sanitizers mentioned in comma-separated list of @var{opts}
17351undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17352library routine. If this option is enabled for certain sanitizer,
17353it takes precedence over the @option{-fsanitizer-recover=} for that
17354sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17355of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17356
17357The advantage of this is that the @code{libubsan} library is not needed
17358and is not linked in, so this is usable even in freestanding environments.
17359
17360Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17361except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17362@option{-fsanitize=float-divide-by-zero} and
17363@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17364specified, which enables it for @code{undefined} suboptions,
17365@option{-fsanitize=float-cast-overflow},
17366@option{-fsanitize=float-divide-by-zero} and
17367@option{-fsanitize=bounds-strict}.
17368If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17369and @code{-fsanitize=vptr} is enabled on the command line, the
17370instrumentation is silently ignored as the instrumentation always needs
17371@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17372
d77de738 17373@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17374@item -fsanitize-undefined-trap-on-error
d77de738
ML
17375The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17376equivalent of @option{-fsanitize-trap=all}.
17377
d77de738 17378@opindex fsanitize-coverage=trace-pc
ddf6fe37 17379@item -fsanitize-coverage=trace-pc
d77de738
ML
17380Enable coverage-guided fuzzing code instrumentation.
17381Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17382
d77de738 17383@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17384@item -fsanitize-coverage=trace-cmp
d77de738
ML
17385Enable dataflow guided fuzzing code instrumentation.
17386Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17387@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17388@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17389variable or @code{__sanitizer_cov_trace_const_cmp1},
17390@code{__sanitizer_cov_trace_const_cmp2},
17391@code{__sanitizer_cov_trace_const_cmp4} or
17392@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17393operand constant, @code{__sanitizer_cov_trace_cmpf} or
17394@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17395@code{__sanitizer_cov_trace_switch} for switch statements.
17396
d77de738 17397@opindex fcf-protection
ddf6fe37 17398@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17399Enable code instrumentation of control-flow transfers to increase
17400program security by checking that target addresses of control-flow
17401transfer instructions (such as indirect function call, function return,
17402indirect jump) are valid. This prevents diverting the flow of control
17403to an unexpected target. This is intended to protect against such
17404threats as Return-oriented Programming (ROP), and similarly
17405call/jmp-oriented programming (COP/JOP).
17406
17407The value @code{branch} tells the compiler to implement checking of
17408validity of control-flow transfer at the point of indirect branch
17409instructions, i.e.@: call/jmp instructions. The value @code{return}
17410implements checking of validity at the point of returning from a
17411function. The value @code{full} is an alias for specifying both
17412@code{branch} and @code{return}. The value @code{none} turns off
17413instrumentation.
17414
17415The value @code{check} is used for the final link with link-time
17416optimization (LTO). An error is issued if LTO object files are
17417compiled with different @option{-fcf-protection} values. The
17418value @code{check} is ignored at the compile time.
17419
17420The macro @code{__CET__} is defined when @option{-fcf-protection} is
17421used. The first bit of @code{__CET__} is set to 1 for the value
17422@code{branch} and the second bit of @code{__CET__} is set to 1 for
17423the @code{return}.
17424
17425You can also use the @code{nocf_check} attribute to identify
17426which functions and calls should be skipped from instrumentation
17427(@pxref{Function Attributes}).
17428
17429Currently the x86 GNU/Linux target provides an implementation based
17430on Intel Control-flow Enforcement Technology (CET) which works for
17431i686 processor or newer.
17432
d77de738 17433@opindex fharden-compares
ddf6fe37 17434@item -fharden-compares
d77de738
ML
17435For every logical test that survives gimple optimizations and is
17436@emph{not} the condition in a conditional branch (for example,
17437conditions tested for conditional moves, or to store in boolean
17438variables), emit extra code to compute and verify the reversed
17439condition, and to call @code{__builtin_trap} if the results do not
17440match. Use with @samp{-fharden-conditional-branches} to cover all
17441conditionals.
17442
d77de738 17443@opindex fharden-conditional-branches
ddf6fe37 17444@item -fharden-conditional-branches
d77de738
ML
17445For every non-vectorized conditional branch that survives gimple
17446optimizations, emit extra code to compute and verify the reversed
17447condition, and to call @code{__builtin_trap} if the result is
17448unexpected. Use with @samp{-fharden-compares} to cover all
17449conditionals.
17450
d77de738 17451@opindex fstack-protector
ddf6fe37 17452@item -fstack-protector
d77de738
ML
17453Emit extra code to check for buffer overflows, such as stack smashing
17454attacks. This is done by adding a guard variable to functions with
17455vulnerable objects. This includes functions that call @code{alloca}, and
17456functions with buffers larger than or equal to 8 bytes. The guards are
17457initialized when a function is entered and then checked when the function
17458exits. If a guard check fails, an error message is printed and the program
17459exits. Only variables that are actually allocated on the stack are
17460considered, optimized away variables or variables allocated in registers
17461don't count.
17462
d77de738 17463@opindex fstack-protector-all
ddf6fe37 17464@item -fstack-protector-all
d77de738
ML
17465Like @option{-fstack-protector} except that all functions are protected.
17466
d77de738 17467@opindex fstack-protector-strong
ddf6fe37 17468@item -fstack-protector-strong
d77de738
ML
17469Like @option{-fstack-protector} but includes additional functions to
17470be protected --- those that have local array definitions, or have
17471references to local frame addresses. Only variables that are actually
17472allocated on the stack are considered, optimized away variables or variables
17473allocated in registers don't count.
17474
d77de738 17475@opindex fstack-protector-explicit
ddf6fe37 17476@item -fstack-protector-explicit
d77de738
ML
17477Like @option{-fstack-protector} but only protects those functions which
17478have the @code{stack_protect} attribute.
17479
d77de738 17480@opindex fstack-check
ddf6fe37 17481@item -fstack-check
d77de738
ML
17482Generate code to verify that you do not go beyond the boundary of the
17483stack. You should specify this flag if you are running in an
17484environment with multiple threads, but you only rarely need to specify it in
17485a single-threaded environment since stack overflow is automatically
17486detected on nearly all systems if there is only one stack.
17487
17488Note that this switch does not actually cause checking to be done; the
17489operating system or the language runtime must do that. The switch causes
17490generation of code to ensure that they see the stack being extended.
17491
17492You can additionally specify a string parameter: @samp{no} means no
17493checking, @samp{generic} means force the use of old-style checking,
17494@samp{specific} means use the best checking method and is equivalent
17495to bare @option{-fstack-check}.
17496
17497Old-style checking is a generic mechanism that requires no specific
17498target support in the compiler but comes with the following drawbacks:
17499
17500@enumerate
17501@item
17502Modified allocation strategy for large objects: they are always
17503allocated dynamically if their size exceeds a fixed threshold. Note this
17504may change the semantics of some code.
17505
17506@item
17507Fixed limit on the size of the static frame of functions: when it is
17508topped by a particular function, stack checking is not reliable and
17509a warning is issued by the compiler.
17510
17511@item
17512Inefficiency: because of both the modified allocation strategy and the
17513generic implementation, code performance is hampered.
17514@end enumerate
17515
17516Note that old-style stack checking is also the fallback method for
17517@samp{specific} if no target support has been added in the compiler.
17518
17519@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17520and stack overflows. @samp{specific} is an excellent choice when compiling
17521Ada code. It is not generally sufficient to protect against stack-clash
17522attacks. To protect against those you want @samp{-fstack-clash-protection}.
17523
d77de738 17524@opindex fstack-clash-protection
ddf6fe37 17525@item -fstack-clash-protection
d77de738
ML
17526Generate code to prevent stack clash style attacks. When this option is
17527enabled, the compiler will only allocate one page of stack space at a time
17528and each page is accessed immediately after allocation. Thus, it prevents
17529allocations from jumping over any stack guard page provided by the
17530operating system.
17531
17532Most targets do not fully support stack clash protection. However, on
17533those targets @option{-fstack-clash-protection} will protect dynamic stack
17534allocations. @option{-fstack-clash-protection} may also provide limited
17535protection for static stack allocations if the target supports
17536@option{-fstack-check=specific}.
17537
d77de738
ML
17538@opindex fstack-limit-register
17539@opindex fstack-limit-symbol
17540@opindex fno-stack-limit
ddf6fe37
AA
17541@item -fstack-limit-register=@var{reg}
17542@itemx -fstack-limit-symbol=@var{sym}
17543@itemx -fno-stack-limit
d77de738
ML
17544Generate code to ensure that the stack does not grow beyond a certain value,
17545either the value of a register or the address of a symbol. If a larger
17546stack is required, a signal is raised at run time. For most targets,
17547the signal is raised before the stack overruns the boundary, so
17548it is possible to catch the signal without taking special precautions.
17549
17550For instance, if the stack starts at absolute address @samp{0x80000000}
17551and grows downwards, you can use the flags
17552@option{-fstack-limit-symbol=__stack_limit} and
17553@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17554of 128KB@. Note that this may only work with the GNU linker.
17555
17556You can locally override stack limit checking by using the
17557@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17558
d77de738 17559@opindex fsplit-stack
ddf6fe37 17560@item -fsplit-stack
d77de738
ML
17561Generate code to automatically split the stack before it overflows.
17562The resulting program has a discontiguous stack which can only
17563overflow if the program is unable to allocate any more memory. This
17564is most useful when running threaded programs, as it is no longer
17565necessary to calculate a good stack size to use for each thread. This
17566is currently only implemented for the x86 targets running
17567GNU/Linux.
17568
17569When code compiled with @option{-fsplit-stack} calls code compiled
17570without @option{-fsplit-stack}, there may not be much stack space
17571available for the latter code to run. If compiling all code,
17572including library code, with @option{-fsplit-stack} is not an option,
17573then the linker can fix up these calls so that the code compiled
17574without @option{-fsplit-stack} always has a large stack. Support for
17575this is implemented in the gold linker in GNU binutils release 2.21
17576and later.
17577
d77de738 17578@opindex fvtable-verify
ddf6fe37 17579@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17580This option is only available when compiling C++ code.
17581It turns on (or off, if using @option{-fvtable-verify=none}) the security
17582feature that verifies at run time, for every virtual call, that
17583the vtable pointer through which the call is made is valid for the type of
17584the object, and has not been corrupted or overwritten. If an invalid vtable
17585pointer is detected at run time, an error is reported and execution of the
17586program is immediately halted.
17587
17588This option causes run-time data structures to be built at program startup,
17589which are used for verifying the vtable pointers.
17590The options @samp{std} and @samp{preinit}
17591control the timing of when these data structures are built. In both cases the
17592data structures are built before execution reaches @code{main}. Using
17593@option{-fvtable-verify=std} causes the data structures to be built after
17594shared libraries have been loaded and initialized.
17595@option{-fvtable-verify=preinit} causes them to be built before shared
17596libraries have been loaded and initialized.
17597
17598If this option appears multiple times in the command line with different
17599values specified, @samp{none} takes highest priority over both @samp{std} and
17600@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17601
d77de738 17602@opindex fvtv-debug
ddf6fe37 17603@item -fvtv-debug
d77de738
ML
17604When used in conjunction with @option{-fvtable-verify=std} or
17605@option{-fvtable-verify=preinit}, causes debug versions of the
17606runtime functions for the vtable verification feature to be called.
17607This flag also causes the compiler to log information about which
17608vtable pointers it finds for each class.
17609This information is written to a file named @file{vtv_set_ptr_data.log}
17610in the directory named by the environment variable @env{VTV_LOGS_DIR}
17611if that is defined or the current working directory otherwise.
17612
17613Note: This feature @emph{appends} data to the log file. If you want a fresh log
17614file, be sure to delete any existing one.
17615
d77de738 17616@opindex fvtv-counts
ddf6fe37 17617@item -fvtv-counts
d77de738
ML
17618This is a debugging flag. When used in conjunction with
17619@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17620causes the compiler to keep track of the total number of virtual calls
17621it encounters and the number of verifications it inserts. It also
17622counts the number of calls to certain run-time library functions
17623that it inserts and logs this information for each compilation unit.
17624The compiler writes this information to a file named
17625@file{vtv_count_data.log} in the directory named by the environment
17626variable @env{VTV_LOGS_DIR} if that is defined or the current working
17627directory otherwise. It also counts the size of the vtable pointer sets
17628for each class, and writes this information to @file{vtv_class_set_sizes.log}
17629in the same directory.
17630
17631Note: This feature @emph{appends} data to the log files. To get fresh log
17632files, be sure to delete any existing ones.
17633
d77de738 17634@opindex finstrument-functions
ddf6fe37 17635@item -finstrument-functions
d77de738
ML
17636Generate instrumentation calls for entry and exit to functions. Just
17637after function entry and just before function exit, the following
17638profiling functions are called with the address of the current
17639function and its call site. (On some platforms,
17640@code{__builtin_return_address} does not work beyond the current
17641function, so the call site information may not be available to the
17642profiling functions otherwise.)
17643
17644@smallexample
17645void __cyg_profile_func_enter (void *this_fn,
17646 void *call_site);
17647void __cyg_profile_func_exit (void *this_fn,
17648 void *call_site);
17649@end smallexample
17650
17651The first argument is the address of the start of the current function,
17652which may be looked up exactly in the symbol table.
17653
17654This instrumentation is also done for functions expanded inline in other
17655functions. The profiling calls indicate where, conceptually, the
17656inline function is entered and exited. This means that addressable
17657versions of such functions must be available. If all your uses of a
17658function are expanded inline, this may mean an additional expansion of
17659code size. If you use @code{extern inline} in your C code, an
17660addressable version of such functions must be provided. (This is
17661normally the case anyway, but if you get lucky and the optimizer always
17662expands the functions inline, you might have gotten away without
17663providing static copies.)
17664
17665A function may be given the attribute @code{no_instrument_function}, in
17666which case this instrumentation is not done. This can be used, for
17667example, for the profiling functions listed above, high-priority
17668interrupt routines, and any functions from which the profiling functions
17669cannot safely be called (perhaps signal handlers, if the profiling
17670routines generate output or allocate memory).
17671@xref{Common Function Attributes}.
17672
9c19597c 17673@opindex finstrument-functions-once
ddf6fe37 17674@item -finstrument-functions-once
d77de738
ML
17675This is similar to @option{-finstrument-functions}, but the profiling
17676functions are called only once per instrumented function, i.e. the first
17677profiling function is called after the first entry into the instrumented
17678function and the second profiling function is called before the exit
17679corresponding to this first entry.
17680
17681The definition of @code{once} for the purpose of this option is a little
17682vague because the implementation is not protected against data races.
17683As a result, the implementation only guarantees that the profiling
17684functions are called at @emph{least} once per process and at @emph{most}
17685once per thread, but the calls are always paired, that is to say, if a
17686thread calls the first function, then it will call the second function,
17687unless it never reaches the exit of the instrumented function.
17688
d77de738 17689@opindex finstrument-functions-exclude-file-list
ddf6fe37 17690@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17691
17692Set the list of functions that are excluded from instrumentation (see
17693the description of @option{-finstrument-functions}). If the file that
17694contains a function definition matches with one of @var{file}, then
17695that function is not instrumented. The match is done on substrings:
17696if the @var{file} parameter is a substring of the file name, it is
17697considered to be a match.
17698
17699For example:
17700
17701@smallexample
17702-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17703@end smallexample
17704
17705@noindent
17706excludes any inline function defined in files whose pathnames
17707contain @file{/bits/stl} or @file{include/sys}.
17708
17709If, for some reason, you want to include letter @samp{,} in one of
17710@var{sym}, write @samp{\,}. For example,
17711@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17712(note the single quote surrounding the option).
17713
d77de738 17714@opindex finstrument-functions-exclude-function-list
ddf6fe37 17715@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17716
17717This is similar to @option{-finstrument-functions-exclude-file-list},
17718but this option sets the list of function names to be excluded from
17719instrumentation. The function name to be matched is its user-visible
17720name, such as @code{vector<int> blah(const vector<int> &)}, not the
17721internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17722match is done on substrings: if the @var{sym} parameter is a substring
17723of the function name, it is considered to be a match. For C99 and C++
17724extended identifiers, the function name must be given in UTF-8, not
17725using universal character names.
17726
d77de738 17727@opindex fpatchable-function-entry
ddf6fe37 17728@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17729Generate @var{N} NOPs right at the beginning
17730of each function, with the function entry point before the @var{M}th NOP.
17731If @var{M} is omitted, it defaults to @code{0} so the
17732function entry points to the address just at the first NOP.
17733The NOP instructions reserve extra space which can be used to patch in
17734any desired instrumentation at run time, provided that the code segment
17735is writable. The amount of space is controllable indirectly via
17736the number of NOPs; the NOP instruction used corresponds to the instruction
17737emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17738is target-specific and may also depend on the architecture variant and/or
17739other compilation options.
17740
17741For run-time identification, the starting addresses of these areas,
17742which correspond to their respective function entries minus @var{M},
17743are additionally collected in the @code{__patchable_function_entries}
17744section of the resulting binary.
17745
17746Note that the value of @code{__attribute__ ((patchable_function_entry
17747(N,M)))} takes precedence over command-line option
17748@option{-fpatchable-function-entry=N,M}. This can be used to increase
17749the area size or to remove it completely on a single function.
17750If @code{N=0}, no pad location is recorded.
17751
17752The NOP instructions are inserted at---and maybe before, depending on
17753@var{M}---the function entry address, even before the prologue. On
17754PowerPC with the ELFv2 ABI, for a function with dual entry points,
17755the local entry point is this function entry address.
17756
17757The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17758ELFv2 ABI, for a function with dual entry points, the supported values
17759for @var{M} are 0, 2, 6 and 14.
17760@end table
17761
17762
17763@node Preprocessor Options
17764@section Options Controlling the Preprocessor
17765@cindex preprocessor options
17766@cindex options, preprocessor
17767
17768These options control the C preprocessor, which is run on each C source
17769file before actual compilation.
17770
17771If you use the @option{-E} option, nothing is done except preprocessing.
17772Some of these options make sense only together with @option{-E} because
17773they cause the preprocessor output to be unsuitable for actual
17774compilation.
17775
17776In addition to the options listed here, there are a number of options
17777to control search paths for include files documented in
17778@ref{Directory Options}.
17779Options to control preprocessor diagnostics are listed in
17780@ref{Warning Options}.
17781
17782@table @gcctabopt
17783@include cppopts.texi
17784
d77de738 17785@opindex Wp
ddf6fe37 17786@item -Wp,@var{option}
d77de738
ML
17787You can use @option{-Wp,@var{option}} to bypass the compiler driver
17788and pass @var{option} directly through to the preprocessor. If
17789@var{option} contains commas, it is split into multiple options at the
17790commas. However, many options are modified, translated or interpreted
17791by the compiler driver before being passed to the preprocessor, and
17792@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17793interface is undocumented and subject to change, so whenever possible
17794you should avoid using @option{-Wp} and let the driver handle the
17795options instead.
17796
d77de738 17797@opindex Xpreprocessor
ddf6fe37 17798@item -Xpreprocessor @var{option}
d77de738
ML
17799Pass @var{option} as an option to the preprocessor. You can use this to
17800supply system-specific preprocessor options that GCC does not
17801recognize.
17802
17803If you want to pass an option that takes an argument, you must use
17804@option{-Xpreprocessor} twice, once for the option and once for the argument.
17805
d77de738 17806@opindex no-integrated-cpp
ddf6fe37 17807@item -no-integrated-cpp
d77de738
ML
17808Perform preprocessing as a separate pass before compilation.
17809By default, GCC performs preprocessing as an integrated part of
17810input tokenization and parsing.
17811If this option is provided, the appropriate language front end
17812(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17813and Objective-C, respectively) is instead invoked twice,
17814once for preprocessing only and once for actual compilation
17815of the preprocessed input.
17816This option may be useful in conjunction with the @option{-B} or
17817@option{-wrapper} options to specify an alternate preprocessor or
17818perform additional processing of the program source between
17819normal preprocessing and compilation.
17820
d77de738 17821@opindex flarge-source-files
ddf6fe37 17822@item -flarge-source-files
d77de738
ML
17823Adjust GCC to expect large source files, at the expense of slower
17824compilation and higher memory usage.
17825
17826Specifically, GCC normally tracks both column numbers and line numbers
17827within source files and it normally prints both of these numbers in
17828diagnostics. However, once it has processed a certain number of source
17829lines, it stops tracking column numbers and only tracks line numbers.
17830This means that diagnostics for later lines do not include column numbers.
17831It also means that options like @option{-Wmisleading-indentation} cease to work
17832at that point, although the compiler prints a note if this happens.
17833Passing @option{-flarge-source-files} significantly increases the number
17834of source lines that GCC can process before it stops tracking columns.
17835
17836@end table
17837
17838@node Assembler Options
17839@section Passing Options to the Assembler
17840
17841@c prevent bad page break with this line
17842You can pass options to the assembler.
17843
17844@table @gcctabopt
d77de738 17845@opindex Wa
ddf6fe37 17846@item -Wa,@var{option}
d77de738
ML
17847Pass @var{option} as an option to the assembler. If @var{option}
17848contains commas, it is split into multiple options at the commas.
17849
d77de738 17850@opindex Xassembler
ddf6fe37 17851@item -Xassembler @var{option}
d77de738
ML
17852Pass @var{option} as an option to the assembler. You can use this to
17853supply system-specific assembler options that GCC does not
17854recognize.
17855
17856If you want to pass an option that takes an argument, you must use
17857@option{-Xassembler} twice, once for the option and once for the argument.
17858
17859@end table
17860
17861@node Link Options
17862@section Options for Linking
17863@cindex link options
17864@cindex options, linking
17865
17866These options come into play when the compiler links object files into
17867an executable output file. They are meaningless if the compiler is
17868not doing a link step.
17869
17870@table @gcctabopt
17871@cindex file names
17872@item @var{object-file-name}
17873A file name that does not end in a special recognized suffix is
17874considered to name an object file or library. (Object files are
17875distinguished from libraries by the linker according to the file
17876contents.) If linking is done, these object files are used as input
17877to the linker.
17878
d77de738
ML
17879@opindex c
17880@opindex S
17881@opindex E
ddf6fe37
AA
17882@item -c
17883@itemx -S
17884@itemx -E
d77de738
ML
17885If any of these options is used, then the linker is not run, and
17886object file names should not be used as arguments. @xref{Overall
17887Options}.
17888
d77de738 17889@opindex flinker-output
ddf6fe37 17890@item -flinker-output=@var{type}
d77de738
ML
17891This option controls code generation of the link-time optimizer. By
17892default the linker output is automatically determined by the linker
17893plugin. For debugging the compiler and if incremental linking with a
17894non-LTO object file is desired, it may be useful to control the type
17895manually.
17896
17897If @var{type} is @samp{exec}, code generation produces a static
17898binary. In this case @option{-fpic} and @option{-fpie} are both
17899disabled.
17900
17901If @var{type} is @samp{dyn}, code generation produces a shared
17902library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17903but not enabled automatically. This allows to build shared libraries
17904without position-independent code on architectures where this is
17905possible, i.e.@: on x86.
17906
17907If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17908executable. This results in similar optimizations as @samp{exec}
17909except that @option{-fpie} is not disabled if specified at compilation
17910time.
17911
17912If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17913done. The sections containing intermediate code for link-time optimization are
17914merged, pre-optimized, and output to the resulting object file. In addition, if
17915@option{-ffat-lto-objects} is specified, binary code is produced for future
17916non-LTO linking. The object file produced by incremental linking is smaller
17917than a static library produced from the same object files. At link time the
17918result of incremental linking also loads faster than a static
17919library assuming that the majority of objects in the library are used.
17920
17921Finally @samp{nolto-rel} configures the compiler for incremental linking where
17922code generation is forced, a final binary is produced, and the intermediate
17923code for later link-time optimization is stripped. When multiple object files
17924are linked together the resulting code is better optimized than with
17925link-time optimizations disabled (for example, cross-module inlining
17926happens), but most of benefits of whole program optimizations are lost.
17927
17928During the incremental link (by @option{-r}) the linker plugin defaults to
17929@option{rel}. With current interfaces to GNU Binutils it is however not
17930possible to incrementally link LTO objects and non-LTO objects into a single
17931mixed object file. If any of object files in incremental link cannot
17932be used for link-time optimization, the linker plugin issues a warning and
17933uses @samp{nolto-rel}. To maintain whole program optimization, it is
17934recommended to link such objects into static library instead. Alternatively it
17935is possible to use H.J. Lu's binutils with support for mixed objects.
17936
d77de738 17937@opindex fuse-ld=bfd
ddf6fe37 17938@item -fuse-ld=bfd
d77de738
ML
17939Use the @command{bfd} linker instead of the default linker.
17940
d77de738 17941@opindex fuse-ld=gold
ddf6fe37 17942@item -fuse-ld=gold
d77de738
ML
17943Use the @command{gold} linker instead of the default linker.
17944
d77de738 17945@opindex fuse-ld=lld
ddf6fe37 17946@item -fuse-ld=lld
d77de738
ML
17947Use the LLVM @command{lld} linker instead of the default linker.
17948
d77de738 17949@opindex fuse-ld=mold
ddf6fe37 17950@item -fuse-ld=mold
d77de738
ML
17951Use the Modern Linker (@command{mold}) instead of the default linker.
17952
17953@cindex Libraries
ddf6fe37 17954@opindex l
d77de738
ML
17955@item -l@var{library}
17956@itemx -l @var{library}
d77de738
ML
17957Search the library named @var{library} when linking. (The second
17958alternative with the library as a separate argument is only for
17959POSIX compliance and is not recommended.)
17960
17961The @option{-l} option is passed directly to the linker by GCC. Refer
17962to your linker documentation for exact details. The general
17963description below applies to the GNU linker.
17964
17965The linker searches a standard list of directories for the library.
17966The directories searched include several standard system directories
17967plus any that you specify with @option{-L}.
17968
17969Static libraries are archives of object files, and have file names
17970like @file{lib@var{library}.a}. Some targets also support shared
17971libraries, which typically have names like @file{lib@var{library}.so}.
17972If both static and shared libraries are found, the linker gives
17973preference to linking with the shared library unless the
17974@option{-static} option is used.
17975
17976It makes a difference where in the command you write this option; the
17977linker searches and processes libraries and object files in the order they
17978are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17979after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17980to functions in @samp{z}, those functions may not be loaded.
17981
d77de738 17982@opindex lobjc
ddf6fe37 17983@item -lobjc
d77de738
ML
17984You need this special case of the @option{-l} option in order to
17985link an Objective-C or Objective-C++ program.
17986
d77de738 17987@opindex nostartfiles
ddf6fe37 17988@item -nostartfiles
d77de738
ML
17989Do not use the standard system startup files when linking.
17990The standard system libraries are used normally, unless @option{-nostdlib},
17991@option{-nolibc}, or @option{-nodefaultlibs} is used.
17992
d77de738 17993@opindex nodefaultlibs
ddf6fe37 17994@item -nodefaultlibs
d77de738
ML
17995Do not use the standard system libraries when linking.
17996Only the libraries you specify are passed to the linker, and options
17997specifying linkage of the system libraries, such as @option{-static-libgcc}
17998or @option{-shared-libgcc}, are ignored.
17999The standard startup files are used normally, unless @option{-nostartfiles}
18000is used.
18001
18002The compiler may generate calls to @code{memcmp},
18003@code{memset}, @code{memcpy} and @code{memmove}.
18004These entries are usually resolved by entries in
18005libc. These entry points should be supplied through some other
18006mechanism when this option is specified.
18007
d77de738 18008@opindex nolibc
ddf6fe37 18009@item -nolibc
d77de738
ML
18010Do not use the C library or system libraries tightly coupled with it when
18011linking. Still link with the startup files, @file{libgcc} or toolchain
18012provided language support libraries such as @file{libgnat}, @file{libgfortran}
18013or @file{libstdc++} unless options preventing their inclusion are used as
18014well. This typically removes @option{-lc} from the link command line, as well
18015as system libraries that normally go with it and become meaningless when
18016absence of a C library is assumed, for example @option{-lpthread} or
18017@option{-lm} in some configurations. This is intended for bare-board
18018targets when there is indeed no C library available.
18019
d77de738 18020@opindex nostdlib
ddf6fe37 18021@item -nostdlib
d77de738
ML
18022Do not use the standard system startup files or libraries when linking.
18023No startup files and only the libraries you specify are passed to
18024the linker, and options specifying linkage of the system libraries, such as
18025@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
18026
18027The compiler may generate calls to @code{memcmp}, @code{memset},
18028@code{memcpy} and @code{memmove}.
18029These entries are usually resolved by entries in
18030libc. These entry points should be supplied through some other
18031mechanism when this option is specified.
18032
18033@cindex @option{-lgcc}, use with @option{-nostdlib}
18034@cindex @option{-nostdlib} and unresolved references
18035@cindex unresolved references and @option{-nostdlib}
18036@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
18037@cindex @option{-nodefaultlibs} and unresolved references
18038@cindex unresolved references and @option{-nodefaultlibs}
18039One of the standard libraries bypassed by @option{-nostdlib} and
18040@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
18041which GCC uses to overcome shortcomings of particular machines, or special
18042needs for some languages.
18043(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
18044Collection (GCC) Internals},
18045for more discussion of @file{libgcc.a}.)
18046In most cases, you need @file{libgcc.a} even when you want to avoid
18047other standard libraries. In other words, when you specify @option{-nostdlib}
18048or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
18049This ensures that you have no unresolved references to internal GCC
18050library subroutines.
18051(An example of such an internal subroutine is @code{__main}, used to ensure C++
18052constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
18053GNU Compiler Collection (GCC) Internals}.)
18054
d77de738 18055@opindex nostdlib++
ddf6fe37 18056@item -nostdlib++
d77de738
ML
18057Do not implicitly link with standard C++ libraries.
18058
d77de738
ML
18059@opindex e
18060@opindex entry
ddf6fe37
AA
18061@item -e @var{entry}
18062@itemx --entry=@var{entry}
d77de738
ML
18063
18064Specify that the program entry point is @var{entry}. The argument is
18065interpreted by the linker; the GNU linker accepts either a symbol name
18066or an address.
18067
d77de738 18068@opindex pie
ddf6fe37 18069@item -pie
d77de738
ML
18070Produce a dynamically linked position independent executable on targets
18071that support it. For predictable results, you must also specify the same
18072set of options used for compilation (@option{-fpie}, @option{-fPIE},
18073or model suboptions) when you specify this linker option.
18074
d77de738 18075@opindex no-pie
ddf6fe37 18076@item -no-pie
d77de738
ML
18077Don't produce a dynamically linked position independent executable.
18078
d77de738 18079@opindex static-pie
ddf6fe37 18080@item -static-pie
d77de738
ML
18081Produce a static position independent executable on targets that support
18082it. A static position independent executable is similar to a static
18083executable, but can be loaded at any address without a dynamic linker.
18084For predictable results, you must also specify the same set of options
18085used for compilation (@option{-fpie}, @option{-fPIE}, or model
18086suboptions) when you specify this linker option.
18087
d77de738 18088@opindex pthread
ddf6fe37 18089@item -pthread
d77de738
ML
18090Link with the POSIX threads library. This option is supported on
18091GNU/Linux targets, most other Unix derivatives, and also on
18092x86 Cygwin and MinGW targets. On some targets this option also sets
18093flags for the preprocessor, so it should be used consistently for both
18094compilation and linking.
18095
d77de738 18096@opindex r
ddf6fe37 18097@item -r
d77de738
ML
18098Produce a relocatable object as output. This is also known as partial
18099linking.
18100
d77de738 18101@opindex rdynamic
ddf6fe37 18102@item -rdynamic
d77de738
ML
18103Pass the flag @option{-export-dynamic} to the ELF linker, on targets
18104that support it. This instructs the linker to add all symbols, not
18105only used ones, to the dynamic symbol table. This option is needed
18106for some uses of @code{dlopen} or to allow obtaining backtraces
18107from within a program.
18108
d77de738 18109@opindex s
ddf6fe37 18110@item -s
d77de738
ML
18111Remove all symbol table and relocation information from the executable.
18112
d77de738 18113@opindex static
ddf6fe37 18114@item -static
d77de738
ML
18115On systems that support dynamic linking, this overrides @option{-pie}
18116and prevents linking with the shared libraries. On other systems, this
18117option has no effect.
18118
d77de738 18119@opindex shared
ddf6fe37 18120@item -shared
d77de738
ML
18121Produce a shared object which can then be linked with other objects to
18122form an executable. Not all systems support this option. For predictable
18123results, you must also specify the same set of options used for compilation
18124(@option{-fpic}, @option{-fPIC}, or model suboptions) when
18125you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
18126needs to build supplementary stub code for constructors to work. On
18127multi-libbed systems, @samp{gcc -shared} must select the correct support
18128libraries to link against. Failing to supply the correct flags may lead
18129to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
18130is innocuous. @option{-shared} suppresses the addition of startup code
18131to alter the floating-point environment as done with @option{-ffast-math},
18132@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 18133
d77de738
ML
18134@opindex shared-libgcc
18135@opindex static-libgcc
ddf6fe37
AA
18136@item -shared-libgcc
18137@itemx -static-libgcc
d77de738
ML
18138On systems that provide @file{libgcc} as a shared library, these options
18139force the use of either the shared or static version, respectively.
18140If no shared version of @file{libgcc} was built when the compiler was
18141configured, these options have no effect.
18142
18143There are several situations in which an application should use the
18144shared @file{libgcc} instead of the static version. The most common
18145of these is when the application wishes to throw and catch exceptions
18146across different shared libraries. In that case, each of the libraries
18147as well as the application itself should use the shared @file{libgcc}.
18148
18149Therefore, the G++ driver automatically adds @option{-shared-libgcc}
18150whenever you build a shared library or a main executable, because C++
18151programs typically use exceptions, so this is the right thing to do.
18152
18153If, instead, you use the GCC driver to create shared libraries, you may
18154find that they are not always linked with the shared @file{libgcc}.
18155If GCC finds, at its configuration time, that you have a non-GNU linker
18156or a GNU linker that does not support option @option{--eh-frame-hdr},
18157it links the shared version of @file{libgcc} into shared libraries
18158by default. Otherwise, it takes advantage of the linker and optimizes
18159away the linking with the shared version of @file{libgcc}, linking with
18160the static version of libgcc by default. This allows exceptions to
18161propagate through such shared libraries, without incurring relocation
18162costs at library load time.
18163
18164However, if a library or main executable is supposed to throw or catch
18165exceptions, you must link it using the G++ driver, or using the option
18166@option{-shared-libgcc}, such that it is linked with the shared
18167@file{libgcc}.
18168
d77de738 18169@opindex static-libasan
ddf6fe37 18170@item -static-libasan
d77de738
ML
18171When the @option{-fsanitize=address} option is used to link a program,
18172the GCC driver automatically links against @option{libasan}. If
18173@file{libasan} is available as a shared library, and the @option{-static}
18174option is not used, then this links against the shared version of
18175@file{libasan}. The @option{-static-libasan} option directs the GCC
18176driver to link @file{libasan} statically, without necessarily linking
18177other libraries statically.
18178
d77de738 18179@opindex static-libtsan
ddf6fe37 18180@item -static-libtsan
d77de738
ML
18181When the @option{-fsanitize=thread} option is used to link a program,
18182the GCC driver automatically links against @option{libtsan}. If
18183@file{libtsan} is available as a shared library, and the @option{-static}
18184option is not used, then this links against the shared version of
18185@file{libtsan}. The @option{-static-libtsan} option directs the GCC
18186driver to link @file{libtsan} statically, without necessarily linking
18187other libraries statically.
18188
d77de738 18189@opindex static-liblsan
ddf6fe37 18190@item -static-liblsan
d77de738
ML
18191When the @option{-fsanitize=leak} option is used to link a program,
18192the GCC driver automatically links against @option{liblsan}. If
18193@file{liblsan} is available as a shared library, and the @option{-static}
18194option is not used, then this links against the shared version of
18195@file{liblsan}. The @option{-static-liblsan} option directs the GCC
18196driver to link @file{liblsan} statically, without necessarily linking
18197other libraries statically.
18198
d77de738 18199@opindex static-libubsan
ddf6fe37 18200@item -static-libubsan
d77de738
ML
18201When the @option{-fsanitize=undefined} option is used to link a program,
18202the GCC driver automatically links against @option{libubsan}. If
18203@file{libubsan} is available as a shared library, and the @option{-static}
18204option is not used, then this links against the shared version of
18205@file{libubsan}. The @option{-static-libubsan} option directs the GCC
18206driver to link @file{libubsan} statically, without necessarily linking
18207other libraries statically.
18208
d77de738 18209@opindex static-libstdc++
ddf6fe37 18210@item -static-libstdc++
d77de738
ML
18211When the @command{g++} program is used to link a C++ program, it
18212normally automatically links against @option{libstdc++}. If
18213@file{libstdc++} is available as a shared library, and the
18214@option{-static} option is not used, then this links against the
18215shared version of @file{libstdc++}. That is normally fine. However, it
18216is sometimes useful to freeze the version of @file{libstdc++} used by
18217the program without going all the way to a fully static link. The
18218@option{-static-libstdc++} option directs the @command{g++} driver to
18219link @file{libstdc++} statically, without necessarily linking other
18220libraries statically.
18221
d77de738 18222@opindex symbolic
ddf6fe37 18223@item -symbolic
d77de738
ML
18224Bind references to global symbols when building a shared object. Warn
18225about any unresolved references (unless overridden by the link editor
18226option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18227this option.
18228
d77de738
ML
18229@opindex T
18230@cindex linker script
f33d7a88 18231@item -T @var{script}
d77de738
ML
18232Use @var{script} as the linker script. This option is supported by most
18233systems using the GNU linker. On some targets, such as bare-board
18234targets without an operating system, the @option{-T} option may be required
18235when linking to avoid references to undefined symbols.
18236
d77de738 18237@opindex Xlinker
ddf6fe37 18238@item -Xlinker @var{option}
d77de738
ML
18239Pass @var{option} as an option to the linker. You can use this to
18240supply system-specific linker options that GCC does not recognize.
18241
18242If you want to pass an option that takes a separate argument, you must use
18243@option{-Xlinker} twice, once for the option and once for the argument.
18244For example, to pass @option{-assert definitions}, you must write
18245@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18246@option{-Xlinker "-assert definitions"}, because this passes the entire
18247string as a single argument, which is not what the linker expects.
18248
18249When using the GNU linker, it is usually more convenient to pass
18250arguments to linker options using the @option{@var{option}=@var{value}}
18251syntax than as separate arguments. For example, you can specify
18252@option{-Xlinker -Map=output.map} rather than
18253@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18254this syntax for command-line options.
18255
d77de738 18256@opindex Wl
ddf6fe37 18257@item -Wl,@var{option}
d77de738
ML
18258Pass @var{option} as an option to the linker. If @var{option} contains
18259commas, it is split into multiple options at the commas. You can use this
18260syntax to pass an argument to the option.
18261For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18262linker. When using the GNU linker, you can also get the same effect with
18263@option{-Wl,-Map=output.map}.
18264
d77de738 18265@opindex u
ddf6fe37 18266@item -u @var{symbol}
d77de738
ML
18267Pretend the symbol @var{symbol} is undefined, to force linking of
18268library modules to define it. You can use @option{-u} multiple times with
18269different symbols to force loading of additional library modules.
18270
d77de738 18271@opindex z
ddf6fe37 18272@item -z @var{keyword}
d77de738
ML
18273@option{-z} is passed directly on to the linker along with the keyword
18274@var{keyword}. See the section in the documentation of your linker for
18275permitted values and their meanings.
18276@end table
18277
18278@node Directory Options
18279@section Options for Directory Search
18280@cindex directory options
18281@cindex options, directory search
18282@cindex search path
18283
18284These options specify directories to search for header files, for
18285libraries and for parts of the compiler:
18286
18287@table @gcctabopt
18288@include cppdiropts.texi
18289
d77de738 18290@opindex iplugindir=
ddf6fe37 18291@item -iplugindir=@var{dir}
d77de738
ML
18292Set the directory to search for plugins that are passed
18293by @option{-fplugin=@var{name}} instead of
18294@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18295to be used by the user, but only passed by the driver.
18296
d77de738 18297@opindex L
ddf6fe37 18298@item -L@var{dir}
d77de738
ML
18299Add directory @var{dir} to the list of directories to be searched
18300for @option{-l}.
18301
d77de738 18302@opindex B
ddf6fe37 18303@item -B@var{prefix}
d77de738
ML
18304This option specifies where to find the executables, libraries,
18305include files, and data files of the compiler itself.
18306
18307The compiler driver program runs one or more of the subprograms
18308@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18309@var{prefix} as a prefix for each program it tries to run, both with and
18310without @samp{@var{machine}/@var{version}/} for the corresponding target
18311machine and compiler version.
18312
18313For each subprogram to be run, the compiler driver first tries the
18314@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18315is not specified, the driver tries two standard prefixes,
18316@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18317those results in a file name that is found, the unmodified program
18318name is searched for using the directories specified in your
18319@env{PATH} environment variable.
18320
18321The compiler checks to see if the path provided by @option{-B}
18322refers to a directory, and if necessary it adds a directory
18323separator character at the end of the path.
18324
18325@option{-B} prefixes that effectively specify directory names also apply
18326to libraries in the linker, because the compiler translates these
18327options into @option{-L} options for the linker. They also apply to
18328include files in the preprocessor, because the compiler translates these
18329options into @option{-isystem} options for the preprocessor. In this case,
18330the compiler appends @samp{include} to the prefix.
18331
18332The runtime support file @file{libgcc.a} can also be searched for using
18333the @option{-B} prefix, if needed. If it is not found there, the two
18334standard prefixes above are tried, and that is all. The file is left
18335out of the link if it is not found by those means.
18336
18337Another way to specify a prefix much like the @option{-B} prefix is to use
18338the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18339Variables}.
18340
18341As a special kludge, if the path provided by @option{-B} is
18342@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
183439, then it is replaced by @file{[dir/]include}. This is to help
18344with boot-strapping the compiler.
18345
d77de738 18346@opindex no-canonical-prefixes
ddf6fe37 18347@item -no-canonical-prefixes
d77de738
ML
18348Do not expand any symbolic links, resolve references to @samp{/../}
18349or @samp{/./}, or make the path absolute when generating a relative
18350prefix.
18351
d77de738 18352@opindex sysroot
ddf6fe37 18353@item --sysroot=@var{dir}
d77de738
ML
18354Use @var{dir} as the logical root directory for headers and libraries.
18355For example, if the compiler normally searches for headers in
18356@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18357searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18358
18359If you use both this option and the @option{-isysroot} option, then
18360the @option{--sysroot} option applies to libraries, but the
18361@option{-isysroot} option applies to header files.
18362
18363The GNU linker (beginning with version 2.16) has the necessary support
18364for this option. If your linker does not support this option, the
18365header file aspect of @option{--sysroot} still works, but the
18366library aspect does not.
18367
d77de738 18368@opindex no-sysroot-suffix
ddf6fe37 18369@item --no-sysroot-suffix
d77de738
ML
18370For some targets, a suffix is added to the root directory specified
18371with @option{--sysroot}, depending on the other options used, so that
18372headers may for example be found in
18373@file{@var{dir}/@var{suffix}/usr/include} instead of
18374@file{@var{dir}/usr/include}. This option disables the addition of
18375such a suffix.
18376
18377@end table
18378
18379@node Code Gen Options
18380@section Options for Code Generation Conventions
18381@cindex code generation conventions
18382@cindex options, code generation
18383@cindex run-time options
18384
18385These machine-independent options control the interface conventions
18386used in code generation.
18387
18388Most of them have both positive and negative forms; the negative form
18389of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18390one of the forms is listed---the one that is not the default. You
18391can figure out the other form by either removing @samp{no-} or adding
18392it.
18393
18394@table @gcctabopt
d77de738 18395@opindex fstack_reuse
ddf6fe37 18396@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18397This option controls stack space reuse for user declared local/auto variables
18398and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18399@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18400local variables and temporaries, @samp{named_vars} enables the reuse only for
18401user defined local variables with names, and @samp{none} disables stack reuse
18402completely. The default value is @samp{all}. The option is needed when the
18403program extends the lifetime of a scoped local variable or a compiler generated
18404temporary beyond the end point defined by the language. When a lifetime of
18405a variable ends, and if the variable lives in memory, the optimizing compiler
18406has the freedom to reuse its stack space with other temporaries or scoped
18407local variables whose live range does not overlap with it. Legacy code extending
18408local lifetime is likely to break with the stack reuse optimization.
18409
18410For example,
18411
18412@smallexample
18413 int *p;
18414 @{
18415 int local1;
18416
18417 p = &local1;
18418 local1 = 10;
18419 ....
18420 @}
18421 @{
18422 int local2;
18423 local2 = 20;
18424 ...
18425 @}
18426
18427 if (*p == 10) // out of scope use of local1
18428 @{
18429
18430 @}
18431@end smallexample
18432
18433Another example:
18434@smallexample
18435
18436 struct A
18437 @{
18438 A(int k) : i(k), j(k) @{ @}
18439 int i;
18440 int j;
18441 @};
18442
18443 A *ap;
18444
18445 void foo(const A& ar)
18446 @{
18447 ap = &ar;
18448 @}
18449
18450 void bar()
18451 @{
18452 foo(A(10)); // temp object's lifetime ends when foo returns
18453
18454 @{
18455 A a(20);
18456 ....
18457 @}
18458 ap->i+= 10; // ap references out of scope temp whose space
18459 // is reused with a. What is the value of ap->i?
18460 @}
18461
18462@end smallexample
18463
18464The lifetime of a compiler generated temporary is well defined by the C++
18465standard. When a lifetime of a temporary ends, and if the temporary lives
18466in memory, the optimizing compiler has the freedom to reuse its stack
18467space with other temporaries or scoped local variables whose live range
18468does not overlap with it. However some of the legacy code relies on
18469the behavior of older compilers in which temporaries' stack space is
18470not reused, the aggressive stack reuse can lead to runtime errors. This
18471option is used to control the temporary stack reuse optimization.
18472
d77de738 18473@opindex ftrapv
ddf6fe37 18474@item -ftrapv
d77de738
ML
18475This option generates traps for signed overflow on addition, subtraction,
18476multiplication operations.
18477The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18478@option{-ftrapv} @option{-fwrapv} on the command-line results in
18479@option{-fwrapv} being effective. Note that only active options override, so
18480using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18481results in @option{-ftrapv} being effective.
18482
d77de738 18483@opindex fwrapv
ddf6fe37 18484@item -fwrapv
d77de738
ML
18485This option instructs the compiler to assume that signed arithmetic
18486overflow of addition, subtraction and multiplication wraps around
18487using twos-complement representation. This flag enables some optimizations
18488and disables others.
18489The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18490@option{-ftrapv} @option{-fwrapv} on the command-line results in
18491@option{-fwrapv} being effective. Note that only active options override, so
18492using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18493results in @option{-ftrapv} being effective.
18494
d77de738 18495@opindex fwrapv-pointer
ddf6fe37 18496@item -fwrapv-pointer
d77de738
ML
18497This option instructs the compiler to assume that pointer arithmetic
18498overflow on addition and subtraction wraps around using twos-complement
18499representation. This flag disables some optimizations which assume
18500pointer overflow is invalid.
18501
d77de738 18502@opindex fstrict-overflow
ddf6fe37 18503@item -fstrict-overflow
d77de738
ML
18504This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18505negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18506
d77de738 18507@opindex fexceptions
ddf6fe37 18508@item -fexceptions
d77de738
ML
18509Enable exception handling. Generates extra code needed to propagate
18510exceptions. For some targets, this implies GCC generates frame
18511unwind information for all functions, which can produce significant data
18512size overhead, although it does not affect execution. If you do not
18513specify this option, GCC enables it by default for languages like
18514C++ that normally require exception handling, and disables it for
18515languages like C that do not normally require it. However, you may need
18516to enable this option when compiling C code that needs to interoperate
18517properly with exception handlers written in C++. You may also wish to
18518disable this option if you are compiling older C++ programs that don't
18519use exception handling.
18520
d77de738 18521@opindex fnon-call-exceptions
ddf6fe37 18522@item -fnon-call-exceptions
d77de738
ML
18523Generate code that allows trapping instructions to throw exceptions.
18524Note that this requires platform-specific runtime support that does
18525not exist everywhere. Moreover, it only allows @emph{trapping}
18526instructions to throw exceptions, i.e.@: memory references or floating-point
18527instructions. It does not allow exceptions to be thrown from
18528arbitrary signal handlers such as @code{SIGALRM}. This enables
18529@option{-fexceptions}.
18530
d77de738 18531@opindex fdelete-dead-exceptions
ddf6fe37 18532@item -fdelete-dead-exceptions
d77de738
ML
18533Consider that instructions that may throw exceptions but don't otherwise
18534contribute to the execution of the program can be optimized away.
18535This does not affect calls to functions except those with the
18536@code{pure} or @code{const} attributes.
18537This option is enabled by default for the Ada and C++ compilers, as permitted by
18538the language specifications.
18539Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18540
d77de738 18541@opindex funwind-tables
ddf6fe37 18542@item -funwind-tables
d77de738
ML
18543Similar to @option{-fexceptions}, except that it just generates any needed
18544static data, but does not affect the generated code in any other way.
18545You normally do not need to enable this option; instead, a language processor
18546that needs this handling enables it on your behalf.
18547
d77de738 18548@opindex fasynchronous-unwind-tables
ddf6fe37 18549@item -fasynchronous-unwind-tables
d77de738
ML
18550Generate unwind table in DWARF format, if supported by target machine. The
18551table is exact at each instruction boundary, so it can be used for stack
18552unwinding from asynchronous events (such as debugger or garbage collector).
18553
d77de738
ML
18554@opindex fno-gnu-unique
18555@opindex fgnu-unique
ddf6fe37 18556@item -fno-gnu-unique
d77de738
ML
18557On systems with recent GNU assembler and C library, the C++ compiler
18558uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18559of template static data members and static local variables in inline
18560functions are unique even in the presence of @code{RTLD_LOCAL}; this
18561is necessary to avoid problems with a library used by two different
18562@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18563therefore disagreeing with the other one about the binding of the
18564symbol. But this causes @code{dlclose} to be ignored for affected
18565DSOs; if your program relies on reinitialization of a DSO via
18566@code{dlclose} and @code{dlopen}, you can use
18567@option{-fno-gnu-unique}.
18568
d77de738 18569@opindex fpcc-struct-return
ddf6fe37 18570@item -fpcc-struct-return
d77de738
ML
18571Return ``short'' @code{struct} and @code{union} values in memory like
18572longer ones, rather than in registers. This convention is less
18573efficient, but it has the advantage of allowing intercallability between
18574GCC-compiled files and files compiled with other compilers, particularly
18575the Portable C Compiler (pcc).
18576
18577The precise convention for returning structures in memory depends
18578on the target configuration macros.
18579
18580Short structures and unions are those whose size and alignment match
18581that of some integer type.
18582
18583@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18584switch is not binary compatible with code compiled with the
18585@option{-freg-struct-return} switch.
18586Use it to conform to a non-default application binary interface.
18587
d77de738 18588@opindex freg-struct-return
ddf6fe37 18589@item -freg-struct-return
d77de738
ML
18590Return @code{struct} and @code{union} values in registers when possible.
18591This is more efficient for small structures than
18592@option{-fpcc-struct-return}.
18593
18594If you specify neither @option{-fpcc-struct-return} nor
18595@option{-freg-struct-return}, GCC defaults to whichever convention is
18596standard for the target. If there is no standard convention, GCC
18597defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18598the principal compiler. In those cases, we can choose the standard, and
18599we chose the more efficient register return alternative.
18600
18601@strong{Warning:} code compiled with the @option{-freg-struct-return}
18602switch is not binary compatible with code compiled with the
18603@option{-fpcc-struct-return} switch.
18604Use it to conform to a non-default application binary interface.
18605
d77de738 18606@opindex fshort-enums
ddf6fe37 18607@item -fshort-enums
d77de738
ML
18608Allocate to an @code{enum} type only as many bytes as it needs for the
18609declared range of possible values. Specifically, the @code{enum} type
18610is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
18611This option has no effect for an enumeration type with a fixed underlying
18612type.
d77de738
ML
18613
18614@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18615code that is not binary compatible with code generated without that switch.
18616Use it to conform to a non-default application binary interface.
18617
d77de738 18618@opindex fshort-wchar
ddf6fe37 18619@item -fshort-wchar
d77de738
ML
18620Override the underlying type for @code{wchar_t} to be @code{short
18621unsigned int} instead of the default for the target. This option is
18622useful for building programs to run under WINE@.
18623
18624@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18625code that is not binary compatible with code generated without that switch.
18626Use it to conform to a non-default application binary interface.
18627
d77de738
ML
18628@opindex fcommon
18629@opindex fno-common
18630@cindex tentative definitions
f33d7a88 18631@item -fcommon
d77de738
ML
18632In C code, this option controls the placement of global variables
18633defined without an initializer, known as @dfn{tentative definitions}
18634in the C standard. Tentative definitions are distinct from declarations
18635of a variable with the @code{extern} keyword, which do not allocate storage.
18636
18637The default is @option{-fno-common}, which specifies that the compiler places
18638uninitialized global variables in the BSS section of the object file.
18639This inhibits the merging of tentative definitions by the linker so you get a
18640multiple-definition error if the same variable is accidentally defined in more
18641than one compilation unit.
18642
18643The @option{-fcommon} places uninitialized global variables in a common block.
18644This allows the linker to resolve all tentative definitions of the same variable
18645in different compilation units to the same object, or to a non-tentative
18646definition. This behavior is inconsistent with C++, and on many targets implies
18647a speed and code size penalty on global variable references. It is mainly
18648useful to enable legacy code to link without errors.
18649
d77de738
ML
18650@opindex fno-ident
18651@opindex fident
ddf6fe37 18652@item -fno-ident
d77de738
ML
18653Ignore the @code{#ident} directive.
18654
d77de738 18655@opindex finhibit-size-directive
ddf6fe37 18656@item -finhibit-size-directive
d77de738
ML
18657Don't output a @code{.size} assembler directive, or anything else that
18658would cause trouble if the function is split in the middle, and the
18659two halves are placed at locations far apart in memory. This option is
18660used when compiling @file{crtstuff.c}; you should not need to use it
18661for anything else.
18662
d77de738 18663@opindex fverbose-asm
ddf6fe37 18664@item -fverbose-asm
d77de738
ML
18665Put extra commentary information in the generated assembly code to
18666make it more readable. This option is generally only of use to those
18667who actually need to read the generated assembly code (perhaps while
18668debugging the compiler itself).
18669
18670@option{-fno-verbose-asm}, the default, causes the
18671extra information to be omitted and is useful when comparing two assembler
18672files.
18673
18674The added comments include:
18675
18676@itemize @bullet
18677
18678@item
18679information on the compiler version and command-line options,
18680
18681@item
18682the source code lines associated with the assembly instructions,
18683in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18684
18685@item
18686hints on which high-level expressions correspond to
18687the various assembly instruction operands.
18688
18689@end itemize
18690
18691For example, given this C source file:
18692
18693@smallexample
18694int test (int n)
18695@{
18696 int i;
18697 int total = 0;
18698
18699 for (i = 0; i < n; i++)
18700 total += i * i;
18701
18702 return total;
18703@}
18704@end smallexample
18705
18706compiling to (x86_64) assembly via @option{-S} and emitting the result
18707direct to stdout via @option{-o} @option{-}
18708
18709@smallexample
18710gcc -S test.c -fverbose-asm -Os -o -
18711@end smallexample
18712
18713gives output similar to this:
18714
18715@smallexample
18716 .file "test.c"
18717# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18718 [...snip...]
18719# options passed:
18720 [...snip...]
18721
18722 .text
18723 .globl test
18724 .type test, @@function
18725test:
18726.LFB0:
18727 .cfi_startproc
18728# test.c:4: int total = 0;
18729 xorl %eax, %eax # <retval>
18730# test.c:6: for (i = 0; i < n; i++)
18731 xorl %edx, %edx # i
18732.L2:
18733# test.c:6: for (i = 0; i < n; i++)
18734 cmpl %edi, %edx # n, i
18735 jge .L5 #,
18736# test.c:7: total += i * i;
18737 movl %edx, %ecx # i, tmp92
18738 imull %edx, %ecx # i, tmp92
18739# test.c:6: for (i = 0; i < n; i++)
18740 incl %edx # i
18741# test.c:7: total += i * i;
18742 addl %ecx, %eax # tmp92, <retval>
18743 jmp .L2 #
18744.L5:
18745# test.c:10: @}
18746 ret
18747 .cfi_endproc
18748.LFE0:
18749 .size test, .-test
18750 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18751 .section .note.GNU-stack,"",@@progbits
18752@end smallexample
18753
18754The comments are intended for humans rather than machines and hence the
18755precise format of the comments is subject to change.
18756
d77de738 18757@opindex frecord-gcc-switches
ddf6fe37 18758@item -frecord-gcc-switches
d77de738
ML
18759This switch causes the command line used to invoke the
18760compiler to be recorded into the object file that is being created.
18761This switch is only implemented on some targets and the exact format
18762of the recording is target and binary file format dependent, but it
18763usually takes the form of a section containing ASCII text. This
18764switch is related to the @option{-fverbose-asm} switch, but that
18765switch only records information in the assembler output file as
18766comments, so it never reaches the object file.
18767See also @option{-grecord-gcc-switches} for another
18768way of storing compiler options into the object file.
18769
d77de738
ML
18770@opindex fpic
18771@cindex global offset table
18772@cindex PIC
f33d7a88 18773@item -fpic
d77de738
ML
18774Generate position-independent code (PIC) suitable for use in a shared
18775library, if supported for the target machine. Such code accesses all
18776constant addresses through a global offset table (GOT)@. The dynamic
18777loader resolves the GOT entries when the program starts (the dynamic
18778loader is not part of GCC; it is part of the operating system). If
18779the GOT size for the linked executable exceeds a machine-specific
18780maximum size, you get an error message from the linker indicating that
18781@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18782instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18783on the m68k and RS/6000. The x86 has no such limit.)
18784
18785Position-independent code requires special support, and therefore works
18786only on certain machines. For the x86, GCC supports PIC for System V
18787but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18788position-independent.
18789
18790When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18791are defined to 1.
18792
d77de738 18793@opindex fPIC
ddf6fe37 18794@item -fPIC
d77de738
ML
18795If supported for the target machine, emit position-independent code,
18796suitable for dynamic linking and avoiding any limit on the size of the
18797global offset table. This option makes a difference on AArch64, m68k,
18798PowerPC and SPARC@.
18799
18800Position-independent code requires special support, and therefore works
18801only on certain machines.
18802
18803When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18804are defined to 2.
18805
d77de738
ML
18806@opindex fpie
18807@opindex fPIE
ddf6fe37
AA
18808@item -fpie
18809@itemx -fPIE
d77de738
ML
18810These options are similar to @option{-fpic} and @option{-fPIC}, but the
18811generated position-independent code can be only linked into executables.
18812Usually these options are used to compile code that will be linked using
18813the @option{-pie} GCC option.
18814
18815@option{-fpie} and @option{-fPIE} both define the macros
18816@code{__pie__} and @code{__PIE__}. The macros have the value 1
18817for @option{-fpie} and 2 for @option{-fPIE}.
18818
d77de738
ML
18819@opindex fno-plt
18820@opindex fplt
ddf6fe37 18821@item -fno-plt
d77de738
ML
18822Do not use the PLT for external function calls in position-independent code.
18823Instead, load the callee address at call sites from the GOT and branch to it.
18824This leads to more efficient code by eliminating PLT stubs and exposing
18825GOT loads to optimizations. On architectures such as 32-bit x86 where
18826PLT stubs expect the GOT pointer in a specific register, this gives more
18827register allocation freedom to the compiler.
18828Lazy binding requires use of the PLT;
18829with @option{-fno-plt} all external symbols are resolved at load time.
18830
18831Alternatively, the function attribute @code{noplt} can be used to avoid calls
18832through the PLT for specific external functions.
18833
18834In position-dependent code, a few targets also convert calls to
18835functions that are marked to not use the PLT to use the GOT instead.
18836
d77de738
ML
18837@opindex fno-jump-tables
18838@opindex fjump-tables
ddf6fe37 18839@item -fno-jump-tables
d77de738
ML
18840Do not use jump tables for switch statements even where it would be
18841more efficient than other code generation strategies. This option is
18842of use in conjunction with @option{-fpic} or @option{-fPIC} for
18843building code that forms part of a dynamic linker and cannot
18844reference the address of a jump table. On some targets, jump tables
18845do not require a GOT and this option is not needed.
18846
d77de738
ML
18847@opindex fno-bit-tests
18848@opindex fbit-tests
ddf6fe37 18849@item -fno-bit-tests
d77de738
ML
18850Do not use bit tests for switch statements even where it would be
18851more efficient than other code generation strategies.
18852
d77de738 18853@opindex ffixed
ddf6fe37 18854@item -ffixed-@var{reg}
d77de738
ML
18855Treat the register named @var{reg} as a fixed register; generated code
18856should never refer to it (except perhaps as a stack pointer, frame
18857pointer or in some other fixed role).
18858
18859@var{reg} must be the name of a register. The register names accepted
18860are machine-specific and are defined in the @code{REGISTER_NAMES}
18861macro in the machine description macro file.
18862
18863This flag does not have a negative form, because it specifies a
18864three-way choice.
18865
d77de738 18866@opindex fcall-used
ddf6fe37 18867@item -fcall-used-@var{reg}
d77de738
ML
18868Treat the register named @var{reg} as an allocable register that is
18869clobbered by function calls. It may be allocated for temporaries or
18870variables that do not live across a call. Functions compiled this way
18871do not save and restore the register @var{reg}.
18872
18873It is an error to use this flag with the frame pointer or stack pointer.
18874Use of this flag for other registers that have fixed pervasive roles in
18875the machine's execution model produces disastrous results.
18876
18877This flag does not have a negative form, because it specifies a
18878three-way choice.
18879
d77de738 18880@opindex fcall-saved
ddf6fe37 18881@item -fcall-saved-@var{reg}
d77de738
ML
18882Treat the register named @var{reg} as an allocable register saved by
18883functions. It may be allocated even for temporaries or variables that
18884live across a call. Functions compiled this way save and restore
18885the register @var{reg} if they use it.
18886
18887It is an error to use this flag with the frame pointer or stack pointer.
18888Use of this flag for other registers that have fixed pervasive roles in
18889the machine's execution model produces disastrous results.
18890
18891A different sort of disaster results from the use of this flag for
18892a register in which function values may be returned.
18893
18894This flag does not have a negative form, because it specifies a
18895three-way choice.
18896
d77de738 18897@opindex fpack-struct
ddf6fe37 18898@item -fpack-struct[=@var{n}]
d77de738
ML
18899Without a value specified, pack all structure members together without
18900holes. When a value is specified (which must be a small power of two), pack
18901structure members according to this value, representing the maximum
18902alignment (that is, objects with default alignment requirements larger than
18903this are output potentially unaligned at the next fitting location.
18904
18905@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18906code that is not binary compatible with code generated without that switch.
18907Additionally, it makes the code suboptimal.
18908Use it to conform to a non-default application binary interface.
18909
d77de738 18910@opindex fleading-underscore
ddf6fe37 18911@item -fleading-underscore
d77de738
ML
18912This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18913change the way C symbols are represented in the object file. One use
18914is to help link with legacy assembly code.
18915
18916@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18917generate code that is not binary compatible with code generated without that
18918switch. Use it to conform to a non-default application binary interface.
18919Not all targets provide complete support for this switch.
18920
d77de738 18921@opindex ftls-model
ddf6fe37 18922@item -ftls-model=@var{model}
d77de738
ML
18923Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18924The @var{model} argument should be one of @samp{global-dynamic},
18925@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18926Note that the choice is subject to optimization: the compiler may use
18927a more efficient model for symbols not visible outside of the translation
18928unit, or if @option{-fpic} is not given on the command line.
18929
18930The default without @option{-fpic} is @samp{initial-exec}; with
18931@option{-fpic} the default is @samp{global-dynamic}.
18932
d77de738 18933@opindex ftrampolines
ddf6fe37 18934@item -ftrampolines
d77de738
ML
18935For targets that normally need trampolines for nested functions, always
18936generate them instead of using descriptors. Otherwise, for targets that
18937do not need them, like for example HP-PA or IA-64, do nothing.
18938
18939A trampoline is a small piece of code that is created at run time on the
18940stack when the address of a nested function is taken, and is used to call
18941the nested function indirectly. Therefore, it requires the stack to be
18942made executable in order for the program to work properly.
18943
18944@option{-fno-trampolines} is enabled by default on a language by language
18945basis to let the compiler avoid generating them, if it computes that this
18946is safe, and replace them with descriptors. Descriptors are made up of data
18947only, but the generated code must be prepared to deal with them. As of this
18948writing, @option{-fno-trampolines} is enabled by default only for Ada.
18949
18950Moreover, code compiled with @option{-ftrampolines} and code compiled with
18951@option{-fno-trampolines} are not binary compatible if nested functions are
18952present. This option must therefore be used on a program-wide basis and be
18953manipulated with extreme care.
18954
18955For languages other than Ada, the @code{-ftrampolines} and
18956@code{-fno-trampolines} options currently have no effect, and
18957trampolines are always generated on platforms that need them
18958for nested functions.
18959
d77de738 18960@opindex fvisibility
ddf6fe37 18961@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
18962Set the default ELF image symbol visibility to the specified option---all
18963symbols are marked with this unless overridden within the code.
18964Using this feature can very substantially improve linking and
18965load times of shared object libraries, produce more optimized
18966code, provide near-perfect API export and prevent symbol clashes.
18967It is @strong{strongly} recommended that you use this in any shared objects
18968you distribute.
18969
18970Despite the nomenclature, @samp{default} always means public; i.e.,
18971available to be linked against from outside the shared object.
18972@samp{protected} and @samp{internal} are pretty useless in real-world
18973usage so the only other commonly used option is @samp{hidden}.
18974The default if @option{-fvisibility} isn't specified is
18975@samp{default}, i.e., make every symbol public.
18976
18977A good explanation of the benefits offered by ensuring ELF
18978symbols have the correct visibility is given by ``How To Write
18979Shared Libraries'' by Ulrich Drepper (which can be found at
18980@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18981solution made possible by this option to marking things hidden when
18982the default is public is to make the default hidden and mark things
18983public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18984and @code{__attribute__ ((visibility("default")))} instead of
18985@code{__declspec(dllexport)} you get almost identical semantics with
18986identical syntax. This is a great boon to those working with
18987cross-platform projects.
18988
18989For those adding visibility support to existing code, you may find
18990@code{#pragma GCC visibility} of use. This works by you enclosing
18991the declarations you wish to set visibility for with (for example)
18992@code{#pragma GCC visibility push(hidden)} and
18993@code{#pragma GCC visibility pop}.
18994Bear in mind that symbol visibility should be viewed @strong{as
18995part of the API interface contract} and thus all new code should
18996always specify visibility when it is not the default; i.e., declarations
18997only for use within the local DSO should @strong{always} be marked explicitly
18998as hidden as so to avoid PLT indirection overheads---making this
18999abundantly clear also aids readability and self-documentation of the code.
19000Note that due to ISO C++ specification requirements, @code{operator new} and
19001@code{operator delete} must always be of default visibility.
19002
19003Be aware that headers from outside your project, in particular system
19004headers and headers from any other library you use, may not be
19005expecting to be compiled with visibility other than the default. You
19006may need to explicitly say @code{#pragma GCC visibility push(default)}
19007before including any such headers.
19008
19009@code{extern} declarations are not affected by @option{-fvisibility}, so
19010a lot of code can be recompiled with @option{-fvisibility=hidden} with
19011no modifications. However, this means that calls to @code{extern}
19012functions with no explicit visibility use the PLT, so it is more
19013effective to use @code{__attribute ((visibility))} and/or
19014@code{#pragma GCC visibility} to tell the compiler which @code{extern}
19015declarations should be treated as hidden.
19016
19017Note that @option{-fvisibility} does affect C++ vague linkage
19018entities. This means that, for instance, an exception class that is
19019be thrown between DSOs must be explicitly marked with default
19020visibility so that the @samp{type_info} nodes are unified between
19021the DSOs.
19022
19023An overview of these techniques, their benefits and how to use them
19024is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
19025
d77de738 19026@opindex fstrict-volatile-bitfields
ddf6fe37 19027@item -fstrict-volatile-bitfields
d77de738
ML
19028This option should be used if accesses to volatile bit-fields (or other
19029structure fields, although the compiler usually honors those types
19030anyway) should use a single access of the width of the
19031field's type, aligned to a natural alignment if possible. For
19032example, targets with memory-mapped peripheral registers might require
19033all such accesses to be 16 bits wide; with this flag you can
19034declare all peripheral bit-fields as @code{unsigned short} (assuming short
19035is 16 bits on these targets) to force GCC to use 16-bit accesses
19036instead of, perhaps, a more efficient 32-bit access.
19037
19038If this option is disabled, the compiler uses the most efficient
19039instruction. In the previous example, that might be a 32-bit load
19040instruction, even though that accesses bytes that do not contain
19041any portion of the bit-field, or memory-mapped registers unrelated to
19042the one being updated.
19043
19044In some cases, such as when the @code{packed} attribute is applied to a
19045structure field, it may not be possible to access the field with a single
19046read or write that is correctly aligned for the target machine. In this
19047case GCC falls back to generating multiple accesses rather than code that
19048will fault or truncate the result at run time.
19049
19050Note: Due to restrictions of the C/C++11 memory model, write accesses are
19051not allowed to touch non bit-field members. It is therefore recommended
19052to define all bits of the field's type as bit-field members.
19053
19054The default value of this option is determined by the application binary
19055interface for the target processor.
19056
d77de738 19057@opindex fsync-libcalls
ddf6fe37 19058@item -fsync-libcalls
d77de738
ML
19059This option controls whether any out-of-line instance of the @code{__sync}
19060family of functions may be used to implement the C++11 @code{__atomic}
19061family of functions.
19062
19063The default value of this option is enabled, thus the only useful form
19064of the option is @option{-fno-sync-libcalls}. This option is used in
19065the implementation of the @file{libatomic} runtime library.
19066
19067@end table
19068
19069@node Developer Options
19070@section GCC Developer Options
19071@cindex developer options
19072@cindex debugging GCC
19073@cindex debug dump options
19074@cindex dump options
19075@cindex compilation statistics
19076
19077This section describes command-line options that are primarily of
19078interest to GCC developers, including options to support compiler
19079testing and investigation of compiler bugs and compile-time
19080performance problems. This includes options that produce debug dumps
19081at various points in the compilation; that print statistics such as
19082memory use and execution time; and that print information about GCC's
19083configuration, such as where it searches for libraries. You should
19084rarely need to use any of these options for ordinary compilation and
19085linking tasks.
19086
19087Many developer options that cause GCC to dump output to a file take an
19088optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
19089or @samp{-} to dump to standard output, and @samp{stderr} for standard
19090error.
19091
19092If @samp{=@var{filename}} is omitted, a default dump file name is
19093constructed by concatenating the base dump file name, a pass number,
19094phase letter, and pass name. The base dump file name is the name of
19095output file produced by the compiler if explicitly specified and not
19096an executable; otherwise it is the source file name.
19097The pass number is determined by the order passes are registered with
19098the compiler's pass manager.
19099This is generally the same as the order of execution, but passes
19100registered by plugins, target-specific passes, or passes that are
19101otherwise registered late are numbered higher than the pass named
19102@samp{final}, even if they are executed earlier. The phase letter is
19103one of @samp{i} (inter-procedural analysis), @samp{l}
19104(language-specific), @samp{r} (RTL), or @samp{t} (tree).
19105The files are created in the directory of the output file.
19106
19107@table @gcctabopt
19108
ddf6fe37 19109@opindex fcallgraph-info
d77de738
ML
19110@item -fcallgraph-info
19111@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
19112Makes the compiler output callgraph information for the program, on a
19113per-object-file basis. The information is generated in the common VCG
19114format. It can be decorated with additional, per-node and/or per-edge
19115information, if a list of comma-separated markers is additionally
19116specified. When the @code{su} marker is specified, the callgraph is
19117decorated with stack usage information; it is equivalent to
19118@option{-fstack-usage}. When the @code{da} marker is specified, the
19119callgraph is decorated with information about dynamically allocated
19120objects.
19121
19122When compiling with @option{-flto}, no callgraph information is output
19123along with the object file. At LTO link time, @option{-fcallgraph-info}
19124may generate multiple callgraph information files next to intermediate
19125LTO output files.
19126
ddf6fe37
AA
19127@opindex d
19128@opindex fdump-rtl-@var{pass}
d77de738
ML
19129@item -d@var{letters}
19130@itemx -fdump-rtl-@var{pass}
19131@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
19132Says to make debugging dumps during compilation at times specified by
19133@var{letters}. This is used for debugging the RTL-based passes of the
19134compiler.
19135
19136Some @option{-d@var{letters}} switches have different meaning when
19137@option{-E} is used for preprocessing. @xref{Preprocessor Options},
19138for information about preprocessor-specific dump options.
19139
19140Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
19141@option{-d} option @var{letters}. Here are the possible
19142letters for use in @var{pass} and @var{letters}, and their meanings:
19143
19144@table @gcctabopt
19145
d77de738 19146@opindex fdump-rtl-alignments
ddf6fe37 19147@item -fdump-rtl-alignments
d77de738
ML
19148Dump after branch alignments have been computed.
19149
d77de738 19150@opindex fdump-rtl-asmcons
ddf6fe37 19151@item -fdump-rtl-asmcons
d77de738
ML
19152Dump after fixing rtl statements that have unsatisfied in/out constraints.
19153
d77de738 19154@opindex fdump-rtl-auto_inc_dec
ddf6fe37 19155@item -fdump-rtl-auto_inc_dec
d77de738
ML
19156Dump after auto-inc-dec discovery. This pass is only run on
19157architectures that have auto inc or auto dec instructions.
19158
d77de738 19159@opindex fdump-rtl-barriers
ddf6fe37 19160@item -fdump-rtl-barriers
d77de738
ML
19161Dump after cleaning up the barrier instructions.
19162
d77de738 19163@opindex fdump-rtl-bbpart
ddf6fe37 19164@item -fdump-rtl-bbpart
d77de738
ML
19165Dump after partitioning hot and cold basic blocks.
19166
d77de738 19167@opindex fdump-rtl-bbro
ddf6fe37 19168@item -fdump-rtl-bbro
d77de738
ML
19169Dump after block reordering.
19170
d77de738
ML
19171@opindex fdump-rtl-btl2
19172@opindex fdump-rtl-btl2
ddf6fe37
AA
19173@item -fdump-rtl-btl1
19174@itemx -fdump-rtl-btl2
d77de738
ML
19175@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
19176after the two branch
19177target load optimization passes.
19178
d77de738 19179@opindex fdump-rtl-bypass
ddf6fe37 19180@item -fdump-rtl-bypass
d77de738
ML
19181Dump after jump bypassing and control flow optimizations.
19182
d77de738 19183@opindex fdump-rtl-combine
ddf6fe37 19184@item -fdump-rtl-combine
d77de738
ML
19185Dump after the RTL instruction combination pass.
19186
d77de738 19187@opindex fdump-rtl-compgotos
ddf6fe37 19188@item -fdump-rtl-compgotos
d77de738
ML
19189Dump after duplicating the computed gotos.
19190
d77de738
ML
19191@opindex fdump-rtl-ce1
19192@opindex fdump-rtl-ce2
19193@opindex fdump-rtl-ce3
ddf6fe37
AA
19194@item -fdump-rtl-ce1
19195@itemx -fdump-rtl-ce2
19196@itemx -fdump-rtl-ce3
d77de738
ML
19197@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
19198@option{-fdump-rtl-ce3} enable dumping after the three
19199if conversion passes.
19200
d77de738 19201@opindex fdump-rtl-cprop_hardreg
ddf6fe37 19202@item -fdump-rtl-cprop_hardreg
d77de738
ML
19203Dump after hard register copy propagation.
19204
d77de738 19205@opindex fdump-rtl-csa
ddf6fe37 19206@item -fdump-rtl-csa
d77de738
ML
19207Dump after combining stack adjustments.
19208
d77de738
ML
19209@opindex fdump-rtl-cse1
19210@opindex fdump-rtl-cse2
ddf6fe37
AA
19211@item -fdump-rtl-cse1
19212@itemx -fdump-rtl-cse2
d77de738
ML
19213@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
19214the two common subexpression elimination passes.
19215
d77de738 19216@opindex fdump-rtl-dce
ddf6fe37 19217@item -fdump-rtl-dce
d77de738
ML
19218Dump after the standalone dead code elimination passes.
19219
d77de738 19220@opindex fdump-rtl-dbr
ddf6fe37 19221@item -fdump-rtl-dbr
d77de738
ML
19222Dump after delayed branch scheduling.
19223
d77de738
ML
19224@opindex fdump-rtl-dce1
19225@opindex fdump-rtl-dce2
ddf6fe37
AA
19226@item -fdump-rtl-dce1
19227@itemx -fdump-rtl-dce2
d77de738
ML
19228@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19229the two dead store elimination passes.
19230
d77de738 19231@opindex fdump-rtl-eh
ddf6fe37 19232@item -fdump-rtl-eh
d77de738
ML
19233Dump after finalization of EH handling code.
19234
d77de738 19235@opindex fdump-rtl-eh_ranges
ddf6fe37 19236@item -fdump-rtl-eh_ranges
d77de738
ML
19237Dump after conversion of EH handling range regions.
19238
d77de738 19239@opindex fdump-rtl-expand
ddf6fe37 19240@item -fdump-rtl-expand
d77de738
ML
19241Dump after RTL generation.
19242
d77de738
ML
19243@opindex fdump-rtl-fwprop1
19244@opindex fdump-rtl-fwprop2
ddf6fe37
AA
19245@item -fdump-rtl-fwprop1
19246@itemx -fdump-rtl-fwprop2
d77de738
ML
19247@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19248dumping after the two forward propagation passes.
19249
d77de738
ML
19250@opindex fdump-rtl-gcse1
19251@opindex fdump-rtl-gcse2
ddf6fe37
AA
19252@item -fdump-rtl-gcse1
19253@itemx -fdump-rtl-gcse2
d77de738
ML
19254@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19255after global common subexpression elimination.
19256
d77de738 19257@opindex fdump-rtl-init-regs
ddf6fe37 19258@item -fdump-rtl-init-regs
d77de738
ML
19259Dump after the initialization of the registers.
19260
d77de738 19261@opindex fdump-rtl-initvals
ddf6fe37 19262@item -fdump-rtl-initvals
d77de738
ML
19263Dump after the computation of the initial value sets.
19264
d77de738 19265@opindex fdump-rtl-into_cfglayout
ddf6fe37 19266@item -fdump-rtl-into_cfglayout
d77de738
ML
19267Dump after converting to cfglayout mode.
19268
d77de738 19269@opindex fdump-rtl-ira
ddf6fe37 19270@item -fdump-rtl-ira
d77de738
ML
19271Dump after iterated register allocation.
19272
d77de738 19273@opindex fdump-rtl-jump
ddf6fe37 19274@item -fdump-rtl-jump
d77de738
ML
19275Dump after the second jump optimization.
19276
d77de738 19277@opindex fdump-rtl-loop2
ddf6fe37 19278@item -fdump-rtl-loop2
d77de738
ML
19279@option{-fdump-rtl-loop2} enables dumping after the rtl
19280loop optimization passes.
19281
d77de738 19282@opindex fdump-rtl-mach
ddf6fe37 19283@item -fdump-rtl-mach
d77de738
ML
19284Dump after performing the machine dependent reorganization pass, if that
19285pass exists.
19286
d77de738 19287@opindex fdump-rtl-mode_sw
ddf6fe37 19288@item -fdump-rtl-mode_sw
d77de738
ML
19289Dump after removing redundant mode switches.
19290
d77de738 19291@opindex fdump-rtl-rnreg
ddf6fe37 19292@item -fdump-rtl-rnreg
d77de738
ML
19293Dump after register renumbering.
19294
d77de738 19295@opindex fdump-rtl-outof_cfglayout
ddf6fe37 19296@item -fdump-rtl-outof_cfglayout
d77de738
ML
19297Dump after converting from cfglayout mode.
19298
d77de738 19299@opindex fdump-rtl-peephole2
ddf6fe37 19300@item -fdump-rtl-peephole2
d77de738
ML
19301Dump after the peephole pass.
19302
d77de738 19303@opindex fdump-rtl-postreload
ddf6fe37 19304@item -fdump-rtl-postreload
d77de738
ML
19305Dump after post-reload optimizations.
19306
d77de738 19307@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19308@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19309Dump after generating the function prologues and epilogues.
19310
d77de738
ML
19311@opindex fdump-rtl-sched1
19312@opindex fdump-rtl-sched2
ddf6fe37
AA
19313@item -fdump-rtl-sched1
19314@itemx -fdump-rtl-sched2
d77de738
ML
19315@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19316after the basic block scheduling passes.
19317
d77de738 19318@opindex fdump-rtl-ree
ddf6fe37 19319@item -fdump-rtl-ree
d77de738
ML
19320Dump after sign/zero extension elimination.
19321
d77de738 19322@opindex fdump-rtl-seqabstr
ddf6fe37 19323@item -fdump-rtl-seqabstr
d77de738
ML
19324Dump after common sequence discovery.
19325
d77de738 19326@opindex fdump-rtl-shorten
ddf6fe37 19327@item -fdump-rtl-shorten
d77de738
ML
19328Dump after shortening branches.
19329
d77de738 19330@opindex fdump-rtl-sibling
ddf6fe37 19331@item -fdump-rtl-sibling
d77de738
ML
19332Dump after sibling call optimizations.
19333
d77de738
ML
19334@opindex fdump-rtl-split1
19335@opindex fdump-rtl-split2
19336@opindex fdump-rtl-split3
19337@opindex fdump-rtl-split4
19338@opindex fdump-rtl-split5
ddf6fe37
AA
19339@item -fdump-rtl-split1
19340@itemx -fdump-rtl-split2
19341@itemx -fdump-rtl-split3
19342@itemx -fdump-rtl-split4
19343@itemx -fdump-rtl-split5
d77de738
ML
19344These options enable dumping after five rounds of
19345instruction splitting.
19346
d77de738 19347@opindex fdump-rtl-sms
ddf6fe37 19348@item -fdump-rtl-sms
d77de738
ML
19349Dump after modulo scheduling. This pass is only run on some
19350architectures.
19351
d77de738 19352@opindex fdump-rtl-stack
ddf6fe37 19353@item -fdump-rtl-stack
d77de738
ML
19354Dump after conversion from GCC's ``flat register file'' registers to the
19355x87's stack-like registers. This pass is only run on x86 variants.
19356
d77de738
ML
19357@opindex fdump-rtl-subreg1
19358@opindex fdump-rtl-subreg2
ddf6fe37
AA
19359@item -fdump-rtl-subreg1
19360@itemx -fdump-rtl-subreg2
d77de738
ML
19361@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19362the two subreg expansion passes.
19363
d77de738 19364@opindex fdump-rtl-unshare
ddf6fe37 19365@item -fdump-rtl-unshare
d77de738
ML
19366Dump after all rtl has been unshared.
19367
d77de738 19368@opindex fdump-rtl-vartrack
ddf6fe37 19369@item -fdump-rtl-vartrack
d77de738
ML
19370Dump after variable tracking.
19371
d77de738 19372@opindex fdump-rtl-vregs
ddf6fe37 19373@item -fdump-rtl-vregs
d77de738
ML
19374Dump after converting virtual registers to hard registers.
19375
d77de738 19376@opindex fdump-rtl-web
ddf6fe37 19377@item -fdump-rtl-web
d77de738
ML
19378Dump after live range splitting.
19379
d77de738
ML
19380@opindex fdump-rtl-regclass
19381@opindex fdump-rtl-subregs_of_mode_init
19382@opindex fdump-rtl-subregs_of_mode_finish
19383@opindex fdump-rtl-dfinit
19384@opindex fdump-rtl-dfinish
ddf6fe37
AA
19385@item -fdump-rtl-regclass
19386@itemx -fdump-rtl-subregs_of_mode_init
19387@itemx -fdump-rtl-subregs_of_mode_finish
19388@itemx -fdump-rtl-dfinit
19389@itemx -fdump-rtl-dfinish
d77de738
ML
19390These dumps are defined but always produce empty files.
19391
d77de738
ML
19392@opindex da
19393@opindex fdump-rtl-all
ddf6fe37
AA
19394@item -da
19395@itemx -fdump-rtl-all
d77de738
ML
19396Produce all the dumps listed above.
19397
d77de738 19398@opindex dA
ddf6fe37 19399@item -dA
d77de738
ML
19400Annotate the assembler output with miscellaneous debugging information.
19401
d77de738 19402@opindex dD
ddf6fe37 19403@item -dD
d77de738
ML
19404Dump all macro definitions, at the end of preprocessing, in addition to
19405normal output.
19406
d77de738 19407@opindex dH
ddf6fe37 19408@item -dH
d77de738
ML
19409Produce a core dump whenever an error occurs.
19410
d77de738 19411@opindex dp
ddf6fe37 19412@item -dp
d77de738
ML
19413Annotate the assembler output with a comment indicating which
19414pattern and alternative is used. The length and cost of each instruction are
19415also printed.
19416
d77de738 19417@opindex dP
ddf6fe37 19418@item -dP
d77de738
ML
19419Dump the RTL in the assembler output as a comment before each instruction.
19420Also turns on @option{-dp} annotation.
19421
d77de738 19422@opindex dx
ddf6fe37 19423@item -dx
d77de738
ML
19424Just generate RTL for a function instead of compiling it. Usually used
19425with @option{-fdump-rtl-expand}.
19426@end table
19427
d77de738 19428@opindex fdump-debug
ddf6fe37 19429@item -fdump-debug
d77de738
ML
19430Dump debugging information generated during the debug
19431generation phase.
19432
d77de738 19433@opindex fdump-earlydebug
ddf6fe37 19434@item -fdump-earlydebug
d77de738
ML
19435Dump debugging information generated during the early debug
19436generation phase.
19437
d77de738 19438@opindex fdump-noaddr
ddf6fe37 19439@item -fdump-noaddr
d77de738
ML
19440When doing debugging dumps, suppress address output. This makes it more
19441feasible to use diff on debugging dumps for compiler invocations with
19442different compiler binaries and/or different
19443text / bss / data / heap / stack / dso start locations.
19444
d77de738 19445@opindex freport-bug
ddf6fe37 19446@item -freport-bug
d77de738
ML
19447Collect and dump debug information into a temporary file if an
19448internal compiler error (ICE) occurs.
19449
d77de738 19450@opindex fdump-unnumbered
ddf6fe37 19451@item -fdump-unnumbered
d77de738
ML
19452When doing debugging dumps, suppress instruction numbers and address output.
19453This makes it more feasible to use diff on debugging dumps for compiler
19454invocations with different options, in particular with and without
19455@option{-g}.
19456
d77de738 19457@opindex fdump-unnumbered-links
ddf6fe37 19458@item -fdump-unnumbered-links
d77de738
ML
19459When doing debugging dumps (see @option{-d} option above), suppress
19460instruction numbers for the links to the previous and next instructions
19461in a sequence.
19462
ddf6fe37 19463@opindex fdump-ipa
d77de738
ML
19464@item -fdump-ipa-@var{switch}
19465@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19466Control the dumping at various stages of inter-procedural analysis
19467language tree to a file. The file name is generated by appending a
19468switch specific suffix to the source file name, and the file is created
19469in the same directory as the output file. The following dumps are
19470possible:
19471
19472@table @samp
19473@item all
19474Enables all inter-procedural analysis dumps.
19475
19476@item cgraph
19477Dumps information about call-graph optimization, unused function removal,
19478and inlining decisions.
19479
19480@item inline
19481Dump after function inlining.
19482
19483@end table
19484
19485Additionally, the options @option{-optimized}, @option{-missed},
19486@option{-note}, and @option{-all} can be provided, with the same meaning
19487as for @option{-fopt-info}, defaulting to @option{-optimized}.
19488
19489For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19490information on callsites that were inlined, along with callsites
19491that were not inlined.
19492
19493By default, the dump will contain messages about successful
19494optimizations (equivalent to @option{-optimized}) together with
19495low-level details about the analysis.
19496
d77de738 19497@opindex fdump-lang
ddf6fe37 19498@item -fdump-lang
d77de738
ML
19499Dump language-specific information. The file name is made by appending
19500@file{.lang} to the source file name.
19501
ddf6fe37
AA
19502@opindex fdump-lang-all
19503@opindex fdump-lang
d77de738
ML
19504@item -fdump-lang-all
19505@itemx -fdump-lang-@var{switch}
19506@itemx -fdump-lang-@var{switch}-@var{options}
19507@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19508Control the dumping of language-specific information. The @var{options}
19509and @var{filename} portions behave as described in the
19510@option{-fdump-tree} option. The following @var{switch} values are
19511accepted:
19512
19513@table @samp
19514@item all
19515
19516Enable all language-specific dumps.
19517
19518@item class
19519Dump class hierarchy information. Virtual table information is emitted
19520unless '@option{slim}' is specified. This option is applicable to C++ only.
19521
19522@item module
19523Dump module information. Options @option{lineno} (locations),
19524@option{graph} (reachability), @option{blocks} (clusters),
19525@option{uid} (serialization), @option{alias} (mergeable),
19526@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19527(macros) may provide additional information. This option is
19528applicable to C++ only.
19529
19530@item raw
19531Dump the raw internal tree data. This option is applicable to C++ only.
19532
19533@end table
19534
d77de738 19535@opindex fdump-passes
ddf6fe37 19536@item -fdump-passes
d77de738
ML
19537Print on @file{stderr} the list of optimization passes that are turned
19538on and off by the current command-line options.
19539
d77de738 19540@opindex fdump-statistics
ddf6fe37 19541@item -fdump-statistics-@var{option}
d77de738
ML
19542Enable and control dumping of pass statistics in a separate file. The
19543file name is generated by appending a suffix ending in
19544@samp{.statistics} to the source file name, and the file is created in
19545the same directory as the output file. If the @samp{-@var{option}}
19546form is used, @samp{-stats} causes counters to be summed over the
19547whole compilation unit while @samp{-details} dumps every event as
19548the passes generate them. The default with no option is to sum
19549counters for each function compiled.
19550
ddf6fe37
AA
19551@opindex fdump-tree-all
19552@opindex fdump-tree
d77de738
ML
19553@item -fdump-tree-all
19554@itemx -fdump-tree-@var{switch}
19555@itemx -fdump-tree-@var{switch}-@var{options}
19556@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19557Control the dumping at various stages of processing the intermediate
19558language tree to a file. If the @samp{-@var{options}}
19559form is used, @var{options} is a list of @samp{-} separated options
19560which control the details of the dump. Not all options are applicable
19561to all dumps; those that are not meaningful are ignored. The
19562following options are available
19563
19564@table @samp
19565@item address
19566Print the address of each node. Usually this is not meaningful as it
19567changes according to the environment and source file. Its primary use
19568is for tying up a dump file with a debug environment.
19569@item asmname
19570If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19571in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19572use working backward from mangled names in the assembly file.
19573@item slim
19574When dumping front-end intermediate representations, inhibit dumping
19575of members of a scope or body of a function merely because that scope
19576has been reached. Only dump such items when they are directly reachable
19577by some other path.
19578
19579When dumping pretty-printed trees, this option inhibits dumping the
19580bodies of control structures.
19581
19582When dumping RTL, print the RTL in slim (condensed) form instead of
19583the default LISP-like representation.
19584@item raw
19585Print a raw representation of the tree. By default, trees are
19586pretty-printed into a C-like representation.
19587@item details
19588Enable more detailed dumps (not honored by every dump option). Also
19589include information from the optimization passes.
19590@item stats
19591Enable dumping various statistics about the pass (not honored by every dump
19592option).
19593@item blocks
19594Enable showing basic block boundaries (disabled in raw dumps).
19595@item graph
19596For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19597dump a representation of the control flow graph suitable for viewing with
19598GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19599the file is pretty-printed as a subgraph, so that GraphViz can render them
19600all in a single plot.
19601
19602This option currently only works for RTL dumps, and the RTL is always
19603dumped in slim form.
19604@item vops
19605Enable showing virtual operands for every statement.
19606@item lineno
19607Enable showing line numbers for statements.
19608@item uid
19609Enable showing the unique ID (@code{DECL_UID}) for each variable.
19610@item verbose
19611Enable showing the tree dump for each statement.
19612@item eh
19613Enable showing the EH region number holding each statement.
19614@item scev
19615Enable showing scalar evolution analysis details.
19616@item optimized
19617Enable showing optimization information (only available in certain
19618passes).
19619@item missed
19620Enable showing missed optimization information (only available in certain
19621passes).
19622@item note
19623Enable other detailed optimization information (only available in
19624certain passes).
19625@item all
19626Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19627and @option{lineno}.
19628@item optall
19629Turn on all optimization options, i.e., @option{optimized},
19630@option{missed}, and @option{note}.
19631@end table
19632
19633To determine what tree dumps are available or find the dump for a pass
19634of interest follow the steps below.
19635
19636@enumerate
19637@item
19638Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19639look for a code that corresponds to the pass you are interested in.
19640For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19641@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19642The number at the end distinguishes distinct invocations of the same pass.
19643@item
19644To enable the creation of the dump file, append the pass code to
19645the @option{-fdump-} option prefix and invoke GCC with it. For example,
19646to enable the dump from the Early Value Range Propagation pass, invoke
19647GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19648specify the name of the dump file. If you don't specify one, GCC
19649creates as described below.
19650@item
19651Find the pass dump in a file whose name is composed of three components
19652separated by a period: the name of the source file GCC was invoked to
19653compile, a numeric suffix indicating the pass number followed by the
19654letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19655and finally the pass code. For example, the Early VRP pass dump might
19656be in a file named @file{myfile.c.038t.evrp} in the current working
19657directory. Note that the numeric codes are not stable and may change
19658from one version of GCC to another.
19659@end enumerate
19660
ddf6fe37 19661@opindex fopt-info
d77de738
ML
19662@item -fopt-info
19663@itemx -fopt-info-@var{options}
19664@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19665Controls optimization dumps from various optimization passes. If the
19666@samp{-@var{options}} form is used, @var{options} is a list of
19667@samp{-} separated option keywords to select the dump details and
19668optimizations.
19669
19670The @var{options} can be divided into three groups:
19671@enumerate
19672@item
19673options describing what kinds of messages should be emitted,
19674@item
19675options describing the verbosity of the dump, and
19676@item
19677options describing which optimizations should be included.
19678@end enumerate
19679The options from each group can be freely mixed as they are
19680non-overlapping. However, in case of any conflicts,
19681the later options override the earlier options on the command
19682line.
19683
19684The following options control which kinds of messages should be emitted:
19685
19686@table @samp
19687@item optimized
19688Print information when an optimization is successfully applied. It is
19689up to a pass to decide which information is relevant. For example, the
19690vectorizer passes print the source location of loops which are
19691successfully vectorized.
19692@item missed
19693Print information about missed optimizations. Individual passes
19694control which information to include in the output.
19695@item note
19696Print verbose information about optimizations, such as certain
19697transformations, more detailed messages about decisions etc.
19698@item all
19699Print detailed optimization information. This includes
19700@samp{optimized}, @samp{missed}, and @samp{note}.
19701@end table
19702
19703The following option controls the dump verbosity:
19704
19705@table @samp
19706@item internals
19707By default, only ``high-level'' messages are emitted. This option enables
19708additional, more detailed, messages, which are likely to only be of interest
19709to GCC developers.
19710@end table
19711
19712One or more of the following option keywords can be used to describe a
19713group of optimizations:
19714
19715@table @samp
19716@item ipa
19717Enable dumps from all interprocedural optimizations.
19718@item loop
19719Enable dumps from all loop optimizations.
19720@item inline
19721Enable dumps from all inlining optimizations.
19722@item omp
19723Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19724@item vec
19725Enable dumps from all vectorization optimizations.
19726@item optall
19727Enable dumps from all optimizations. This is a superset of
19728the optimization groups listed above.
19729@end table
19730
19731If @var{options} is
19732omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19733about successful optimizations from all the passes, omitting messages
19734that are treated as ``internals''.
19735
19736If the @var{filename} is provided, then the dumps from all the
19737applicable optimizations are concatenated into the @var{filename}.
19738Otherwise the dump is output onto @file{stderr}. Though multiple
19739@option{-fopt-info} options are accepted, only one of them can include
19740a @var{filename}. If other filenames are provided then all but the
19741first such option are ignored.
19742
19743Note that the output @var{filename} is overwritten
19744in case of multiple translation units. If a combined output from
19745multiple translation units is desired, @file{stderr} should be used
19746instead.
19747
19748In the following example, the optimization info is output to
19749@file{stderr}:
19750
19751@smallexample
19752gcc -O3 -fopt-info
19753@end smallexample
19754
19755This example:
19756@smallexample
19757gcc -O3 -fopt-info-missed=missed.all
19758@end smallexample
19759
19760@noindent
19761outputs missed optimization report from all the passes into
19762@file{missed.all}, and this one:
19763
19764@smallexample
19765gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19766@end smallexample
19767
19768@noindent
19769prints information about missed optimization opportunities from
19770vectorization passes on @file{stderr}.
19771Note that @option{-fopt-info-vec-missed} is equivalent to
19772@option{-fopt-info-missed-vec}. The order of the optimization group
19773names and message types listed after @option{-fopt-info} does not matter.
19774
19775As another example,
19776@smallexample
19777gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19778@end smallexample
19779
19780@noindent
19781outputs information about missed optimizations as well as
19782optimized locations from all the inlining passes into
19783@file{inline.txt}.
19784
19785Finally, consider:
19786
19787@smallexample
19788gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19789@end smallexample
19790
19791@noindent
19792Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19793in conflict since only one output file is allowed. In this case, only
19794the first option takes effect and the subsequent options are
19795ignored. Thus only @file{vec.miss} is produced which contains
19796dumps from the vectorizer about missed opportunities.
19797
d77de738 19798@opindex fsave-optimization-record
ddf6fe37 19799@item -fsave-optimization-record
d77de738
ML
19800Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19801were performed, for those optimizations that support @option{-fopt-info}.
19802
19803This option is experimental and the format of the data within the
19804compressed JSON file is subject to change.
19805
19806It is roughly equivalent to a machine-readable version of
19807@option{-fopt-info-all}, as a collection of messages with source file,
19808line number and column number, with the following additional data for
19809each message:
19810
19811@itemize @bullet
19812
19813@item
19814the execution count of the code being optimized, along with metadata about
19815whether this was from actual profile data, or just an estimate, allowing
19816consumers to prioritize messages by code hotness,
19817
19818@item
19819the function name of the code being optimized, where applicable,
19820
19821@item
19822the ``inlining chain'' for the code being optimized, so that when
19823a function is inlined into several different places (which might
19824themselves be inlined), the reader can distinguish between the copies,
19825
19826@item
19827objects identifying those parts of the message that refer to expressions,
19828statements or symbol-table nodes, which of these categories they are, and,
19829when available, their source code location,
19830
19831@item
19832the GCC pass that emitted the message, and
19833
19834@item
19835the location in GCC's own code from which the message was emitted
19836
19837@end itemize
19838
19839Additionally, some messages are logically nested within other
19840messages, reflecting implementation details of the optimization
19841passes.
19842
d77de738 19843@opindex fsched-verbose
ddf6fe37 19844@item -fsched-verbose=@var{n}
d77de738
ML
19845On targets that use instruction scheduling, this option controls the
19846amount of debugging output the scheduler prints to the dump files.
19847
19848For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19849same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19850For @var{n} greater than one, it also output basic block probabilities,
19851detailed ready list information and unit/insn info. For @var{n} greater
19852than two, it includes RTL at abort point, control-flow and regions info.
19853And for @var{n} over four, @option{-fsched-verbose} also includes
19854dependence info.
19855
19856
19857
d77de738
ML
19858@opindex fdisable-
19859@opindex fenable-
ddf6fe37
AA
19860@item -fenable-@var{kind}-@var{pass}
19861@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
19862
19863This is a set of options that are used to explicitly disable/enable
19864optimization passes. These options are intended for use for debugging GCC.
19865Compiler users should use regular options for enabling/disabling
19866passes instead.
19867
19868@table @gcctabopt
19869
19870@item -fdisable-ipa-@var{pass}
19871Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19872statically invoked in the compiler multiple times, the pass name should be
19873appended with a sequential number starting from 1.
19874
19875@item -fdisable-rtl-@var{pass}
19876@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19877Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19878statically invoked in the compiler multiple times, the pass name should be
19879appended with a sequential number starting from 1. @var{range-list} is a
19880comma-separated list of function ranges or assembler names. Each range is a number
19881pair separated by a colon. The range is inclusive in both ends. If the range
19882is trivial, the number pair can be simplified as a single number. If the
19883function's call graph node's @var{uid} falls within one of the specified ranges,
19884the @var{pass} is disabled for that function. The @var{uid} is shown in the
19885function header of a dump file, and the pass names can be dumped by using
19886option @option{-fdump-passes}.
19887
19888@item -fdisable-tree-@var{pass}
19889@itemx -fdisable-tree-@var{pass}=@var{range-list}
19890Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19891option arguments.
19892
19893@item -fenable-ipa-@var{pass}
19894Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19895statically invoked in the compiler multiple times, the pass name should be
19896appended with a sequential number starting from 1.
19897
19898@item -fenable-rtl-@var{pass}
19899@itemx -fenable-rtl-@var{pass}=@var{range-list}
19900Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19901description and examples.
19902
19903@item -fenable-tree-@var{pass}
19904@itemx -fenable-tree-@var{pass}=@var{range-list}
19905Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19906of option arguments.
19907
19908@end table
19909
19910Here are some examples showing uses of these options.
19911
19912@smallexample
19913
19914# disable ccp1 for all functions
19915 -fdisable-tree-ccp1
19916# disable complete unroll for function whose cgraph node uid is 1
19917 -fenable-tree-cunroll=1
19918# disable gcse2 for functions at the following ranges [1,1],
19919# [300,400], and [400,1000]
19920# disable gcse2 for functions foo and foo2
19921 -fdisable-rtl-gcse2=foo,foo2
19922# disable early inlining
19923 -fdisable-tree-einline
19924# disable ipa inlining
19925 -fdisable-ipa-inline
19926# enable tree full unroll
19927 -fenable-tree-unroll
19928
19929@end smallexample
19930
d77de738
ML
19931@opindex fchecking
19932@opindex fno-checking
ddf6fe37
AA
19933@item -fchecking
19934@itemx -fchecking=@var{n}
d77de738
ML
19935Enable internal consistency checking. The default depends on
19936the compiler configuration. @option{-fchecking=2} enables further
19937internal consistency checking that might affect code generation.
19938
d77de738 19939@opindex frandom-seed
ddf6fe37 19940@item -frandom-seed=@var{string}
d77de738
ML
19941This option provides a seed that GCC uses in place of
19942random numbers in generating certain symbol names
19943that have to be different in every compiled file. It is also used to
19944place unique stamps in coverage data files and the object files that
19945produce them. You can use the @option{-frandom-seed} option to produce
19946reproducibly identical object files.
19947
19948The @var{string} can either be a number (decimal, octal or hex) or an
19949arbitrary string (in which case it's converted to a number by
19950computing CRC32).
19951
19952The @var{string} should be different for every file you compile.
19953
d77de738 19954@opindex save-temps
ddf6fe37 19955@item -save-temps
d77de738
ML
19956Store the usual ``temporary'' intermediate files permanently; name them
19957as auxiliary output files, as specified described under
19958@option{-dumpbase} and @option{-dumpdir}.
19959
19960When used in combination with the @option{-x} command-line option,
19961@option{-save-temps} is sensible enough to avoid overwriting an
19962input source file with the same extension as an intermediate file.
19963The corresponding intermediate file may be obtained by renaming the
19964source file before using @option{-save-temps}.
19965
d77de738 19966@opindex save-temps=cwd
ddf6fe37 19967@item -save-temps=cwd
d77de738
ML
19968Equivalent to @option{-save-temps -dumpdir ./}.
19969
d77de738 19970@opindex save-temps=obj
ddf6fe37 19971@item -save-temps=obj
d77de738
ML
19972Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19973@file{outdir/} is the directory of the output file specified after the
19974@option{-o} option, including any directory separators. If the
19975@option{-o} option is not used, the @option{-save-temps=obj} switch
19976behaves like @option{-save-temps=cwd}.
19977
d77de738 19978@opindex time
ddf6fe37 19979@item -time@r{[}=@var{file}@r{]}
d77de738
ML
19980Report the CPU time taken by each subprocess in the compilation
19981sequence. For C source files, this is the compiler proper and assembler
19982(plus the linker if linking is done).
19983
19984Without the specification of an output file, the output looks like this:
19985
19986@smallexample
19987# cc1 0.12 0.01
19988# as 0.00 0.01
19989@end smallexample
19990
19991The first number on each line is the ``user time'', that is time spent
19992executing the program itself. The second number is ``system time'',
19993time spent executing operating system routines on behalf of the program.
19994Both numbers are in seconds.
19995
19996With the specification of an output file, the output is appended to the
19997named file, and it looks like this:
19998
19999@smallexample
200000.12 0.01 cc1 @var{options}
200010.00 0.01 as @var{options}
20002@end smallexample
20003
20004The ``user time'' and the ``system time'' are moved before the program
20005name, and the options passed to the program are displayed, so that one
20006can later tell what file was being compiled, and with which options.
20007
d77de738 20008@opindex fdump-final-insns
ddf6fe37 20009@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
20010Dump the final internal representation (RTL) to @var{file}. If the
20011optional argument is omitted (or if @var{file} is @code{.}), the name
20012of the dump file is determined by appending @code{.gkd} to the
20013dump base name, see @option{-dumpbase}.
20014
d77de738
ML
20015@opindex fcompare-debug
20016@opindex fno-compare-debug
ddf6fe37 20017@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
20018If no error occurs during compilation, run the compiler a second time,
20019adding @var{opts} and @option{-fcompare-debug-second} to the arguments
20020passed to the second compilation. Dump the final internal
20021representation in both compilations, and print an error if they differ.
20022
20023If the equal sign is omitted, the default @option{-gtoggle} is used.
20024
20025The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
20026and nonzero, implicitly enables @option{-fcompare-debug}. If
20027@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
20028then it is used for @var{opts}, otherwise the default @option{-gtoggle}
20029is used.
20030
20031@option{-fcompare-debug=}, with the equal sign but without @var{opts},
20032is equivalent to @option{-fno-compare-debug}, which disables the dumping
20033of the final representation and the second compilation, preventing even
20034@env{GCC_COMPARE_DEBUG} from taking effect.
20035
20036To verify full coverage during @option{-fcompare-debug} testing, set
20037@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
20038which GCC rejects as an invalid option in any actual compilation
20039(rather than preprocessing, assembly or linking). To get just a
20040warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
20041not overridden} will do.
20042
d77de738 20043@opindex fcompare-debug-second
ddf6fe37 20044@item -fcompare-debug-second
d77de738
ML
20045This option is implicitly passed to the compiler for the second
20046compilation requested by @option{-fcompare-debug}, along with options to
20047silence warnings, and omitting other options that would cause the compiler
20048to produce output to files or to standard output as a side effect. Dump
20049files and preserved temporary files are renamed so as to contain the
20050@code{.gk} additional extension during the second compilation, to avoid
20051overwriting those generated by the first.
20052
20053When this option is passed to the compiler driver, it causes the
20054@emph{first} compilation to be skipped, which makes it useful for little
20055other than debugging the compiler proper.
20056
d77de738 20057@opindex gtoggle
ddf6fe37 20058@item -gtoggle
d77de738
ML
20059Turn off generation of debug info, if leaving out this option
20060generates it, or turn it on at level 2 otherwise. The position of this
20061argument in the command line does not matter; it takes effect after all
20062other options are processed, and it does so only once, no matter how
20063many times it is given. This is mainly intended to be used with
20064@option{-fcompare-debug}.
20065
d77de738
ML
20066@opindex fvar-tracking-assignments-toggle
20067@opindex fno-var-tracking-assignments-toggle
ddf6fe37 20068@item -fvar-tracking-assignments-toggle
d77de738
ML
20069Toggle @option{-fvar-tracking-assignments}, in the same way that
20070@option{-gtoggle} toggles @option{-g}.
20071
d77de738 20072@opindex Q
ddf6fe37 20073@item -Q
d77de738
ML
20074Makes the compiler print out each function name as it is compiled, and
20075print some statistics about each pass when it finishes.
20076
d77de738 20077@opindex ftime-report
ddf6fe37 20078@item -ftime-report
75d62394
DM
20079Makes the compiler print some statistics to stderr about the time consumed
20080by each pass when it finishes.
20081
20082If SARIF output of diagnostics was requested via
20083@option{-fdiagnostics-format=sarif-file} or
20084@option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
20085information is instead emitted in JSON form as part of SARIF output. The
20086precise format of this JSON data is subject to change, and the values may
20087not exactly match those emitted to stderr due to being written out at a
20088slightly different place within the compiler.
d77de738 20089
d77de738 20090@opindex ftime-report-details
ddf6fe37 20091@item -ftime-report-details
d77de738
ML
20092Record the time consumed by infrastructure parts separately for each pass.
20093
d77de738 20094@opindex fira-verbose
ddf6fe37 20095@item -fira-verbose=@var{n}
d77de738
ML
20096Control the verbosity of the dump file for the integrated register allocator.
20097The default value is 5. If the value @var{n} is greater or equal to 10,
20098the dump output is sent to stderr using the same format as @var{n} minus 10.
20099
d77de738 20100@opindex flto-report
ddf6fe37 20101@item -flto-report
d77de738
ML
20102Prints a report with internal details on the workings of the link-time
20103optimizer. The contents of this report vary from version to version.
20104It is meant to be useful to GCC developers when processing object
20105files in LTO mode (via @option{-flto}).
20106
20107Disabled by default.
20108
d77de738 20109@opindex flto-report-wpa
ddf6fe37 20110@item -flto-report-wpa
d77de738
ML
20111Like @option{-flto-report}, but only print for the WPA phase of link-time
20112optimization.
20113
d77de738 20114@opindex fmem-report
ddf6fe37 20115@item -fmem-report
d77de738
ML
20116Makes the compiler print some statistics about permanent memory
20117allocation when it finishes.
20118
d77de738 20119@opindex fmem-report-wpa
ddf6fe37 20120@item -fmem-report-wpa
d77de738
ML
20121Makes the compiler print some statistics about permanent memory
20122allocation for the WPA phase only.
20123
d77de738 20124@opindex fpre-ipa-mem-report
d77de738 20125@opindex fpost-ipa-mem-report
ddf6fe37
AA
20126@item -fpre-ipa-mem-report
20127@item -fpost-ipa-mem-report
d77de738
ML
20128Makes the compiler print some statistics about permanent memory
20129allocation before or after interprocedural optimization.
20130
d77de738 20131@opindex fmultiflags
ddf6fe37 20132@item -fmultiflags
d77de738
ML
20133This option enables multilib-aware @code{TFLAGS} to be used to build
20134target libraries with options different from those the compiler is
20135configured to use by default, through the use of specs (@xref{Spec
20136Files}) set up by compiler internals, by the target, or by builders at
20137configure time.
20138
20139Like @code{TFLAGS}, this allows the target libraries to be built for
20140portable baseline environments, while the compiler defaults to more
20141demanding ones. That's useful because users can easily override the
20142defaults the compiler is configured to use to build their own programs,
20143if the defaults are not ideal for their target environment, whereas
20144rebuilding the runtime libraries is usually not as easy or desirable.
20145
20146Unlike @code{TFLAGS}, the use of specs enables different flags to be
20147selected for different multilibs. The way to accomplish that is to
20148build with @samp{make TFLAGS=-fmultiflags}, after configuring
20149@samp{--with-specs=%@{fmultiflags:...@}}.
20150
20151This option is discarded by the driver once it's done processing driver
20152self spec.
20153
20154It is also useful to check that @code{TFLAGS} are being used to build
20155all target libraries, by configuring a non-bootstrap compiler
20156@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
20157the compiler and target libraries.
20158
d77de738 20159@opindex fprofile-report
ddf6fe37 20160@item -fprofile-report
d77de738
ML
20161Makes the compiler print some statistics about consistency of the
20162(estimated) profile and effect of individual passes.
20163
d77de738 20164@opindex fstack-usage
ddf6fe37 20165@item -fstack-usage
d77de738
ML
20166Makes the compiler output stack usage information for the program, on a
20167per-function basis. The filename for the dump is made by appending
20168@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
20169the output file, if explicitly specified and it is not an executable,
20170otherwise it is the basename of the source file. An entry is made up
20171of three fields:
20172
20173@itemize
20174@item
20175The name of the function.
20176@item
20177A number of bytes.
20178@item
20179One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
20180@end itemize
20181
20182The qualifier @code{static} means that the function manipulates the stack
20183statically: a fixed number of bytes are allocated for the frame on function
20184entry and released on function exit; no stack adjustments are otherwise made
20185in the function. The second field is this fixed number of bytes.
20186
20187The qualifier @code{dynamic} means that the function manipulates the stack
20188dynamically: in addition to the static allocation described above, stack
20189adjustments are made in the body of the function, for example to push/pop
20190arguments around function calls. If the qualifier @code{bounded} is also
20191present, the amount of these adjustments is bounded at compile time and
20192the second field is an upper bound of the total amount of stack used by
20193the function. If it is not present, the amount of these adjustments is
20194not bounded at compile time and the second field only represents the
20195bounded part.
20196
d77de738 20197@opindex fstats
ddf6fe37 20198@item -fstats
d77de738
ML
20199Emit statistics about front-end processing at the end of the compilation.
20200This option is supported only by the C++ front end, and
20201the information is generally only useful to the G++ development team.
20202
d77de738 20203@opindex fdbg-cnt-list
ddf6fe37 20204@item -fdbg-cnt-list
d77de738
ML
20205Print the name and the counter upper bound for all debug counters.
20206
20207
d77de738 20208@opindex fdbg-cnt
ddf6fe37 20209@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
20210Set the internal debug counter lower and upper bound. @var{counter-value-list}
20211is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
20212[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
20213the name of the counter and list of closed intervals.
20214The @var{lower_bound} is optional and is zero
20215initialized if not set.
20216For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
20217@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
20218eleventh invocation.
20219For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
20220
d77de738 20221@opindex print-file-name
ddf6fe37 20222@item -print-file-name=@var{library}
d77de738
ML
20223Print the full absolute name of the library file @var{library} that
20224would be used when linking---and don't do anything else. With this
20225option, GCC does not compile or link anything; it just prints the
20226file name.
20227
d77de738 20228@opindex print-multi-directory
ddf6fe37 20229@item -print-multi-directory
d77de738
ML
20230Print the directory name corresponding to the multilib selected by any
20231other switches present in the command line. This directory is supposed
20232to exist in @env{GCC_EXEC_PREFIX}.
20233
d77de738 20234@opindex print-multi-lib
ddf6fe37 20235@item -print-multi-lib
d77de738
ML
20236Print the mapping from multilib directory names to compiler switches
20237that enable them. The directory name is separated from the switches by
20238@samp{;}, and each switch starts with an @samp{@@} instead of the
20239@samp{-}, without spaces between multiple switches. This is supposed to
20240ease shell processing.
20241
d77de738 20242@opindex print-multi-os-directory
ddf6fe37 20243@item -print-multi-os-directory
d77de738
ML
20244Print the path to OS libraries for the selected
20245multilib, relative to some @file{lib} subdirectory. If OS libraries are
20246present in the @file{lib} subdirectory and no multilibs are used, this is
20247usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20248sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20249@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20250subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20251
d77de738 20252@opindex print-multiarch
ddf6fe37 20253@item -print-multiarch
d77de738
ML
20254Print the path to OS libraries for the selected multiarch,
20255relative to some @file{lib} subdirectory.
20256
d77de738 20257@opindex print-prog-name
ddf6fe37 20258@item -print-prog-name=@var{program}
d77de738
ML
20259Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20260
d77de738 20261@opindex print-libgcc-file-name
ddf6fe37 20262@item -print-libgcc-file-name
d77de738
ML
20263Same as @option{-print-file-name=libgcc.a}.
20264
20265This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20266but you do want to link with @file{libgcc.a}. You can do:
20267
20268@smallexample
20269gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20270@end smallexample
20271
d77de738 20272@opindex print-search-dirs
ddf6fe37 20273@item -print-search-dirs
d77de738
ML
20274Print the name of the configured installation directory and a list of
20275program and library directories @command{gcc} searches---and don't do anything else.
20276
20277This is useful when @command{gcc} prints the error message
20278@samp{installation problem, cannot exec cpp0: No such file or directory}.
20279To resolve this you either need to put @file{cpp0} and the other compiler
20280components where @command{gcc} expects to find them, or you can set the environment
20281variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20282Don't forget the trailing @samp{/}.
20283@xref{Environment Variables}.
20284
d77de738 20285@opindex print-sysroot
ddf6fe37 20286@item -print-sysroot
d77de738
ML
20287Print the target sysroot directory that is used during
20288compilation. This is the target sysroot specified either at configure
20289time or using the @option{--sysroot} option, possibly with an extra
20290suffix that depends on compilation options. If no target sysroot is
20291specified, the option prints nothing.
20292
d77de738 20293@opindex print-sysroot-headers-suffix
ddf6fe37 20294@item -print-sysroot-headers-suffix
d77de738
ML
20295Print the suffix added to the target sysroot when searching for
20296headers, or give an error if the compiler is not configured with such
20297a suffix---and don't do anything else.
20298
d77de738 20299@opindex dumpmachine
ddf6fe37 20300@item -dumpmachine
d77de738
ML
20301Print the compiler's target machine (for example,
20302@samp{i686-pc-linux-gnu})---and don't do anything else.
20303
d77de738 20304@opindex dumpversion
ddf6fe37 20305@item -dumpversion
d77de738
ML
20306Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20307anything else. This is the compiler version used in filesystem paths and
20308specs. Depending on how the compiler has been configured it can be just
20309a single number (major version), two numbers separated by a dot (major and
20310minor version) or three numbers separated by dots (major, minor and patchlevel
20311version).
20312
d77de738 20313@opindex dumpfullversion
ddf6fe37 20314@item -dumpfullversion
d77de738
ML
20315Print the full compiler version---and don't do anything else. The output is
20316always three numbers separated by dots, major, minor and patchlevel version.
20317
d77de738 20318@opindex dumpspecs
ddf6fe37 20319@item -dumpspecs
d77de738
ML
20320Print the compiler's built-in specs---and don't do anything else. (This
20321is used when GCC itself is being built.) @xref{Spec Files}.
20322@end table
20323
20324@node Submodel Options
20325@section Machine-Dependent Options
20326@cindex submodel options
20327@cindex specifying hardware config
20328@cindex hardware models and configurations, specifying
20329@cindex target-dependent options
20330@cindex machine-dependent options
20331
20332Each target machine supported by GCC can have its own options---for
20333example, to allow you to compile for a particular processor variant or
20334ABI, or to control optimizations specific to that machine. By
20335convention, the names of machine-specific options start with
20336@samp{-m}.
20337
20338Some configurations of the compiler also support additional target-specific
20339options, usually for compatibility with other compilers on the same
20340platform.
20341
20342@c This list is ordered alphanumerically by subsection name.
20343@c It should be the same order and spelling as these options are listed
20344@c in Machine Dependent Options
20345
20346@menu
20347* AArch64 Options::
20348* Adapteva Epiphany Options::
20349* AMD GCN Options::
20350* ARC Options::
20351* ARM Options::
20352* AVR Options::
20353* Blackfin Options::
20354* C6X Options::
20355* CRIS Options::
20356* C-SKY Options::
20357* Darwin Options::
20358* DEC Alpha Options::
20359* eBPF Options::
20360* FR30 Options::
20361* FT32 Options::
20362* FRV Options::
20363* GNU/Linux Options::
20364* H8/300 Options::
20365* HPPA Options::
20366* IA-64 Options::
20367* LM32 Options::
20368* LoongArch Options::
20369* M32C Options::
20370* M32R/D Options::
20371* M680x0 Options::
20372* MCore Options::
d77de738
ML
20373* MicroBlaze Options::
20374* MIPS Options::
20375* MMIX Options::
20376* MN10300 Options::
20377* Moxie Options::
20378* MSP430 Options::
20379* NDS32 Options::
20380* Nios II Options::
20381* Nvidia PTX Options::
20382* OpenRISC Options::
20383* PDP-11 Options::
d77de738
ML
20384* PowerPC Options::
20385* PRU Options::
20386* RISC-V Options::
20387* RL78 Options::
20388* RS/6000 and PowerPC Options::
20389* RX Options::
20390* S/390 and zSeries Options::
d77de738
ML
20391* SH Options::
20392* Solaris 2 Options::
20393* SPARC Options::
20394* System V Options::
20395* V850 Options::
20396* VAX Options::
20397* Visium Options::
20398* VMS Options::
20399* VxWorks Options::
20400* x86 Options::
20401* x86 Windows Options::
20402* Xstormy16 Options::
20403* Xtensa Options::
20404* zSeries Options::
20405@end menu
20406
20407@node AArch64 Options
20408@subsection AArch64 Options
20409@cindex AArch64 Options
20410
20411These options are defined for AArch64 implementations:
20412
20413@table @gcctabopt
20414
d77de738 20415@opindex mabi
ddf6fe37 20416@item -mabi=@var{name}
d77de738
ML
20417Generate code for the specified data model. Permissible values
20418are @samp{ilp32} for SysV-like data model where int, long int and pointers
20419are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20420but long int and pointers are 64 bits.
20421
20422The default depends on the specific target configuration. Note that
20423the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20424entire program with the same ABI, and link with a compatible set of libraries.
20425
d77de738 20426@opindex mbig-endian
ddf6fe37 20427@item -mbig-endian
d77de738
ML
20428Generate big-endian code. This is the default when GCC is configured for an
20429@samp{aarch64_be-*-*} target.
20430
d77de738 20431@opindex mgeneral-regs-only
ddf6fe37 20432@item -mgeneral-regs-only
d77de738
ML
20433Generate code which uses only the general-purpose registers. This will prevent
20434the compiler from using floating-point and Advanced SIMD registers but will not
20435impose any restrictions on the assembler.
20436
d77de738 20437@opindex mlittle-endian
ddf6fe37 20438@item -mlittle-endian
d77de738
ML
20439Generate little-endian code. This is the default when GCC is configured for an
20440@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20441
d77de738 20442@opindex mcmodel=tiny
ddf6fe37 20443@item -mcmodel=tiny
d77de738
ML
20444Generate code for the tiny code model. The program and its statically defined
20445symbols must be within 1MB of each other. Programs can be statically or
20446dynamically linked.
20447
d77de738 20448@opindex mcmodel=small
ddf6fe37 20449@item -mcmodel=small
d77de738
ML
20450Generate code for the small code model. The program and its statically defined
20451symbols must be within 4GB of each other. Programs can be statically or
20452dynamically linked. This is the default code model.
20453
d77de738 20454@opindex mcmodel=large
ddf6fe37 20455@item -mcmodel=large
d77de738
ML
20456Generate code for the large code model. This makes no assumptions about
20457addresses and sizes of sections. Programs can be statically linked only. The
20458@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20459@option{-fpic} and @option{-fPIC}.
20460
573624ec
KT
20461@item -mtp=@var{name}
20462@opindex mtp
20463Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
20464are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
20465@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
20466@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
20467The default setting is @samp{tpidr_el0}. It is recommended to compile all
20468code intended to interoperate with the same value of this option to avoid
20469accessing a different thread pointer from the wrong exception level.
573624ec 20470
d77de738
ML
20471@opindex mstrict-align
20472@opindex mno-strict-align
ddf6fe37
AA
20473@item -mstrict-align
20474@itemx -mno-strict-align
d77de738
ML
20475Avoid or allow generating memory accesses that may not be aligned on a natural
20476object boundary as described in the architecture specification.
20477
d77de738
ML
20478@opindex momit-leaf-frame-pointer
20479@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20480@item -momit-leaf-frame-pointer
20481@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20482Omit or keep the frame pointer in leaf functions. The former behavior is the
20483default.
20484
d77de738
ML
20485@opindex mstack-protector-guard
20486@opindex mstack-protector-guard-reg
20487@opindex mstack-protector-guard-offset
ddf6fe37
AA
20488@item -mstack-protector-guard=@var{guard}
20489@itemx -mstack-protector-guard-reg=@var{reg}
20490@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20491Generate stack protection code using canary at @var{guard}. Supported
20492locations are @samp{global} for a global canary or @samp{sysreg} for a
20493canary in an appropriate system register.
20494
20495With the latter choice the options
20496@option{-mstack-protector-guard-reg=@var{reg}} and
20497@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20498which system register to use as base register for reading the canary,
20499and from what offset from that base register. There is no default
20500register or offset as this is entirely for use within the Linux
20501kernel.
20502
d77de738 20503@opindex mtls-dialect=desc
ddf6fe37 20504@item -mtls-dialect=desc
d77de738
ML
20505Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20506of TLS variables. This is the default.
20507
d77de738 20508@opindex mtls-dialect=traditional
ddf6fe37 20509@item -mtls-dialect=traditional
d77de738
ML
20510Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20511of TLS variables.
20512
d77de738 20513@opindex mtls-size
ddf6fe37 20514@item -mtls-size=@var{size}
d77de738
ML
20515Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20516This option requires binutils 2.26 or newer.
20517
d77de738
ML
20518@opindex mfix-cortex-a53-835769
20519@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20520@item -mfix-cortex-a53-835769
20521@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20522Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20523This involves inserting a NOP instruction between memory instructions and
2052464-bit integer multiply-accumulate instructions.
20525
d77de738
ML
20526@opindex mfix-cortex-a53-843419
20527@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20528@item -mfix-cortex-a53-843419
20529@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20530Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20531This erratum workaround is made at link time and this will only pass the
20532corresponding flag to the linker.
20533
d77de738
ML
20534@opindex mlow-precision-recip-sqrt
20535@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20536@item -mlow-precision-recip-sqrt
20537@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20538Enable or disable the reciprocal square root approximation.
20539This option only has an effect if @option{-ffast-math} or
20540@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20541precision of reciprocal square root results to about 16 bits for
20542single precision and to 32 bits for double precision.
20543
d77de738
ML
20544@opindex mlow-precision-sqrt
20545@opindex mno-low-precision-sqrt
ddf6fe37
AA
20546@item -mlow-precision-sqrt
20547@itemx -mno-low-precision-sqrt
d77de738
ML
20548Enable or disable the square root approximation.
20549This option only has an effect if @option{-ffast-math} or
20550@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20551precision of square root results to about 16 bits for
20552single precision and to 32 bits for double precision.
20553If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20554
d77de738
ML
20555@opindex mlow-precision-div
20556@opindex mno-low-precision-div
ddf6fe37
AA
20557@item -mlow-precision-div
20558@itemx -mno-low-precision-div
d77de738
ML
20559Enable or disable the division approximation.
20560This option only has an effect if @option{-ffast-math} or
20561@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20562precision of division results to about 16 bits for
20563single precision and to 32 bits for double precision.
20564
20565@item -mtrack-speculation
20566@itemx -mno-track-speculation
20567Enable or disable generation of additional code to track speculative
20568execution through conditional branches. The tracking state can then
20569be used by the compiler when expanding calls to
20570@code{__builtin_speculation_safe_copy} to permit a more efficient code
20571sequence to be generated.
20572
20573@item -moutline-atomics
20574@itemx -mno-outline-atomics
20575Enable or disable calls to out-of-line helpers to implement atomic operations.
20576These helpers will, at runtime, determine if the LSE instructions from
20577ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20578instructions that are present in the base ARMv8.0 ISA.
20579
20580This option is only applicable when compiling for the base ARMv8.0
20581instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20582or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20583used directly. The same applies when using @option{-mcpu=} when the
20584selected cpu supports the @samp{lse} feature.
20585This option is on by default.
20586
d77de738 20587@opindex march
ddf6fe37 20588@item -march=@var{name}
d77de738
ML
20589Specify the name of the target architecture and, optionally, one or
20590more feature modifiers. This option has the form
20591@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20592
20593The table below summarizes the permissible values for @var{arch}
20594and the features that they enable by default:
20595
20596@multitable @columnfractions 0.20 0.20 0.60
20597@headitem @var{arch} value @tab Architecture @tab Includes by default
20598@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20599@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20600@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20601@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20602@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20603@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20604@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20605@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20606@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20607@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20608@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20609@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20610@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20611@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20612@end multitable
20613
20614The value @samp{native} is available on native AArch64 GNU/Linux and
20615causes the compiler to pick the architecture of the host system. This
20616option has no effect if the compiler is unable to recognize the
20617architecture of the host system,
20618
20619The permissible values for @var{feature} are listed in the sub-section
20620on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20621Feature Modifiers}. Where conflicting feature modifiers are
20622specified, the right-most feature is used.
20623
20624GCC uses @var{name} to determine what kind of instructions it can emit
20625when generating assembly code. If @option{-march} is specified
20626without either of @option{-mtune} or @option{-mcpu} also being
20627specified, the code is tuned to perform well across a range of target
20628processors implementing the target architecture.
20629
d77de738 20630@opindex mtune
ddf6fe37 20631@item -mtune=@var{name}
d77de738
ML
20632Specify the name of the target processor for which GCC should tune the
20633performance of the code. Permissible values for this option are:
20634@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20635@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20636@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20637@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20638@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20639@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20640@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20641@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20642@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20643@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20644@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20645@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20646@samp{octeontx2f95mm},
20647@samp{a64fx},
20648@samp{thunderx}, @samp{thunderxt88},
20649@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20650@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20651@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20652@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20653@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20654@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
3bfde22c
SJ
20655@samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520},
20656@samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1},
20657@samp{ampere1a}, and @samp{native}.
d77de738
ML
20658
20659The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20660@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20661@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20662should tune for a big.LITTLE system.
20663
20664The value @samp{neoverse-512tvb} specifies that GCC should tune
20665for Neoverse cores that (a) implement SVE and (b) have a total vector
20666bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20667tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20668instructions a cycle and that can execute an equivalent number of SVE
20669arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20670This is more general than tuning for a specific core like Neoverse V1
20671but is more specific than the default tuning described below.
20672
20673Additionally on native AArch64 GNU/Linux systems the value
20674@samp{native} tunes performance to the host system. This option has no effect
20675if the compiler is unable to recognize the processor of the host system.
20676
20677Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20678are specified, the code is tuned to perform well across a range
20679of target processors.
20680
20681This option cannot be suffixed by feature modifiers.
20682
d77de738 20683@opindex mcpu
ddf6fe37 20684@item -mcpu=@var{name}
d77de738
ML
20685Specify the name of the target processor, optionally suffixed by one
20686or more feature modifiers. This option has the form
20687@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20688the permissible values for @var{cpu} are the same as those available
20689for @option{-mtune}. The permissible values for @var{feature} are
20690documented in the sub-section on
20691@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20692Feature Modifiers}. Where conflicting feature modifiers are
20693specified, the right-most feature is used.
20694
20695GCC uses @var{name} to determine what kind of instructions it can emit when
20696generating assembly code (as if by @option{-march}) and to determine
20697the target processor for which to tune for performance (as if
20698by @option{-mtune}). Where this option is used in conjunction
20699with @option{-march} or @option{-mtune}, those options take precedence
20700over the appropriate part of this option.
20701
20702@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20703to a specific core, but instead refers to all Neoverse cores that
20704(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20705a cycle. Unless overridden by @option{-march},
20706@option{-mcpu=neoverse-512tvb} generates code that can run on a
20707Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20708these properties. Unless overridden by @option{-mtune},
20709@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20710@option{-mtune=neoverse-512tvb}.
20711
d77de738 20712@opindex moverride
ddf6fe37 20713@item -moverride=@var{string}
d77de738
ML
20714Override tuning decisions made by the back-end in response to a
20715@option{-mtune=} switch. The syntax, semantics, and accepted values
20716for @var{string} in this option are not guaranteed to be consistent
20717across releases.
20718
20719This option is only intended to be useful when developing GCC.
20720
d77de738 20721@opindex mverbose-cost-dump
ddf6fe37 20722@item -mverbose-cost-dump
d77de738
ML
20723Enable verbose cost model dumping in the debug dump files. This option is
20724provided for use in debugging the compiler.
20725
d77de738
ML
20726@opindex mpc-relative-literal-loads
20727@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20728@item -mpc-relative-literal-loads
20729@itemx -mno-pc-relative-literal-loads
d77de738
ML
20730Enable or disable PC-relative literal loads. With this option literal pools are
20731accessed using a single instruction and emitted after each function. This
20732limits the maximum size of functions to 1MB. This is enabled by default for
20733@option{-mcmodel=tiny}.
20734
d77de738 20735@opindex msign-return-address
ddf6fe37 20736@item -msign-return-address=@var{scope}
d77de738
ML
20737Select the function scope on which return address signing will be applied.
20738Permissible values are @samp{none}, which disables return address signing,
20739@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20740functions, and @samp{all}, which enables pointer signing for all functions. The
20741default value is @samp{none}. This option has been deprecated by
20742-mbranch-protection.
20743
d77de738 20744@opindex mbranch-protection
ddf6fe37 20745@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20746Select the branch protection features to use.
20747@samp{none} is the default and turns off all types of branch protection.
20748@samp{standard} turns on all types of branch protection features. If a feature
20749has additional tuning options, then @samp{standard} sets it to its standard
20750level.
20751@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20752level: signing functions that save the return address to memory (non-leaf
20753functions will practically always do this) using the a-key. The optional
20754argument @samp{leaf} can be used to extend the signing to include leaf
20755functions. The optional argument @samp{b-key} can be used to sign the functions
20756with the B-key instead of the A-key.
20757@samp{bti} turns on branch target identification mechanism.
20758
d77de738 20759@opindex mharden-sls
ddf6fe37 20760@item -mharden-sls=@var{opts}
d77de738
ML
20761Enable compiler hardening against straight line speculation (SLS).
20762@var{opts} is a comma-separated list of the following options:
20763@table @samp
20764@item retbr
20765@item blr
20766@end table
20767In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20768@samp{-mharden-sls=none} disables all SLS hardening.
20769
d77de738 20770@opindex msve-vector-bits
ddf6fe37 20771@item -msve-vector-bits=@var{bits}
d77de738
ML
20772Specify the number of bits in an SVE vector register. This option only has
20773an effect when SVE is enabled.
20774
20775GCC supports two forms of SVE code generation: ``vector-length
20776agnostic'' output that works with any size of vector register and
20777``vector-length specific'' output that allows GCC to make assumptions
20778about the vector length when it is useful for optimization reasons.
20779The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20780@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20781Specifying @samp{scalable} selects vector-length agnostic
20782output. At present @samp{-msve-vector-bits=128} also generates vector-length
20783agnostic output for big-endian targets. All other values generate
20784vector-length specific code. The behavior of these values may change
20785in future releases and no value except @samp{scalable} should be
20786relied on for producing code that is portable across different
20787hardware SVE vector lengths.
20788
20789The default is @samp{-msve-vector-bits=scalable}, which produces
20790vector-length agnostic code.
20791@end table
20792
20793@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20794@anchor{aarch64-feature-modifiers}
20795@cindex @option{-march} feature modifiers
20796@cindex @option{-mcpu} feature modifiers
20797Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20798the following and their inverses @option{no@var{feature}}:
20799
20800@table @samp
20801@item crc
20802Enable CRC extension. This is on by default for
20803@option{-march=armv8.1-a}.
20804@item crypto
20805Enable Crypto extension. This also enables Advanced SIMD and floating-point
20806instructions.
20807@item fp
20808Enable floating-point instructions. This is on by default for all possible
20809values for options @option{-march} and @option{-mcpu}.
20810@item simd
20811Enable Advanced SIMD instructions. This also enables floating-point
20812instructions. This is on by default for all possible values for options
20813@option{-march} and @option{-mcpu}.
20814@item sve
20815Enable Scalable Vector Extension instructions. This also enables Advanced
20816SIMD and floating-point instructions.
20817@item lse
20818Enable Large System Extension instructions. This is on by default for
20819@option{-march=armv8.1-a}.
20820@item rdma
20821Enable Round Double Multiply Accumulate instructions. This is on by default
20822for @option{-march=armv8.1-a}.
20823@item fp16
20824Enable FP16 extension. This also enables floating-point instructions.
20825@item fp16fml
20826Enable FP16 fmla extension. This also enables FP16 extensions and
20827floating-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.
20828
20829@item rcpc
0431e8ae
AV
20830Enable the RCpc extension. This enables the use of the LDAPR instructions for
20831load-acquire atomic semantics, and passes it on to the assembler, enabling
20832inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20833@item dotprod
20834Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20835@item aes
20836Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20837SIMD instructions.
20838@item sha2
20839Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20840@item sha3
20841Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20842instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20843@item sm4
20844Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20845Use of this option with architectures prior to Armv8.2-A is not supported.
20846@item profile
20847Enable the Statistical Profiling extension. This option is only to enable the
20848extension at the assembler level and does not affect code generation.
20849@item rng
20850Enable the Armv8.5-a Random Number instructions. This option is only to
20851enable the extension at the assembler level and does not affect code
20852generation.
20853@item memtag
20854Enable the Armv8.5-a Memory Tagging Extensions.
20855Use of this option with architectures prior to Armv8.5-A is not supported.
20856@item sb
20857Enable the Armv8-a Speculation Barrier instruction. This option is only to
20858enable the extension at the assembler level and does not affect code
20859generation. This option is enabled by default for @option{-march=armv8.5-a}.
20860@item ssbs
20861Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20862is only to enable the extension at the assembler level and does not affect code
20863generation. This option is enabled by default for @option{-march=armv8.5-a}.
20864@item predres
20865Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20866This option is only to enable the extension at the assembler level and does
20867not affect code generation. This option is enabled by default for
20868@option{-march=armv8.5-a}.
20869@item sve2
20870Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20871instructions.
20872@item sve2-bitperm
20873Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20874@item sve2-sm4
20875Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20876@item sve2-aes
20877Enable SVE2 aes instructions. This also enables SVE2 instructions.
20878@item sve2-sha3
20879Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20880@item tme
20881Enable the Transactional Memory Extension.
20882@item i8mm
20883Enable 8-bit Integer Matrix Multiply instructions. This also enables
20884Advanced SIMD and floating-point instructions. This option is enabled by
20885default for @option{-march=armv8.6-a}. Use of this option with architectures
20886prior to Armv8.2-A is not supported.
20887@item f32mm
20888Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20889SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20890not supported.
20891@item f64mm
20892Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20893SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20894not supported.
20895@item bf16
20896Enable brain half-precision floating-point instructions. This also enables
20897Advanced SIMD and floating-point instructions. This option is enabled by
20898default for @option{-march=armv8.6-a}. Use of this option with architectures
20899prior to Armv8.2-A is not supported.
20900@item ls64
20901Enable the 64-byte atomic load and store instructions for accelerators.
20902This option is enabled by default for @option{-march=armv8.7-a}.
20903@item mops
20904Enable the instructions to accelerate memory operations like @code{memcpy},
20905@code{memmove}, @code{memset}. This option is enabled by default for
20906@option{-march=armv8.8-a}
20907@item flagm
20908Enable the Flag Manipulation instructions Extension.
20909@item pauth
20910Enable the Pointer Authentication Extension.
d758d190
KT
20911@item cssc
20912Enable the Common Short Sequence Compression instructions.
d77de738
ML
20913
20914@end table
20915
20916Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20917which implies @option{fp}.
20918Conversely, @option{nofp} implies @option{nosimd}, which implies
20919@option{nocrypto}, @option{noaes} and @option{nosha2}.
20920
20921@node Adapteva Epiphany Options
20922@subsection Adapteva Epiphany Options
20923
20924These @samp{-m} options are defined for Adapteva Epiphany:
20925
20926@table @gcctabopt
d77de738 20927@opindex mhalf-reg-file
ddf6fe37 20928@item -mhalf-reg-file
d77de738
ML
20929Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20930That allows code to run on hardware variants that lack these registers.
20931
d77de738 20932@opindex mprefer-short-insn-regs
ddf6fe37 20933@item -mprefer-short-insn-regs
d77de738
ML
20934Preferentially allocate registers that allow short instruction generation.
20935This can result in increased instruction count, so this may either reduce or
20936increase overall code size.
20937
d77de738 20938@opindex mbranch-cost
ddf6fe37 20939@item -mbranch-cost=@var{num}
d77de738
ML
20940Set the cost of branches to roughly @var{num} ``simple'' instructions.
20941This cost is only a heuristic and is not guaranteed to produce
20942consistent results across releases.
20943
d77de738 20944@opindex mcmove
ddf6fe37 20945@item -mcmove
d77de738
ML
20946Enable the generation of conditional moves.
20947
d77de738 20948@opindex mnops
ddf6fe37 20949@item -mnops=@var{num}
d77de738
ML
20950Emit @var{num} NOPs before every other generated instruction.
20951
d77de738
ML
20952@opindex mno-soft-cmpsf
20953@opindex msoft-cmpsf
ddf6fe37 20954@item -mno-soft-cmpsf
d77de738
ML
20955For single-precision floating-point comparisons, emit an @code{fsub} instruction
20956and test the flags. This is faster than a software comparison, but can
20957get incorrect results in the presence of NaNs, or when two different small
20958numbers are compared such that their difference is calculated as zero.
20959The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20960software comparisons.
20961
d77de738 20962@opindex mstack-offset
ddf6fe37 20963@item -mstack-offset=@var{num}
d77de738
ML
20964Set the offset between the top of the stack and the stack pointer.
20965E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20966can be used by leaf functions without stack allocation.
20967Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20968Note also that this option changes the ABI; compiling a program with a
20969different stack offset than the libraries have been compiled with
20970generally does not work.
20971This option can be useful if you want to evaluate if a different stack
20972offset would give you better code, but to actually use a different stack
20973offset to build working programs, it is recommended to configure the
20974toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20975
d77de738
ML
20976@opindex mno-round-nearest
20977@opindex mround-nearest
ddf6fe37 20978@item -mno-round-nearest
d77de738
ML
20979Make the scheduler assume that the rounding mode has been set to
20980truncating. The default is @option{-mround-nearest}.
20981
d77de738 20982@opindex mlong-calls
ddf6fe37 20983@item -mlong-calls
d77de738
ML
20984If not otherwise specified by an attribute, assume all calls might be beyond
20985the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20986function address into a register before performing a (otherwise direct) call.
20987This is the default.
20988
d77de738 20989@opindex short-calls
ddf6fe37 20990@item -mshort-calls
d77de738
ML
20991If not otherwise specified by an attribute, assume all direct calls are
20992in the range of the @code{b} / @code{bl} instructions, so use these instructions
20993for direct calls. The default is @option{-mlong-calls}.
20994
d77de738 20995@opindex msmall16
ddf6fe37 20996@item -msmall16
d77de738
ML
20997Assume addresses can be loaded as 16-bit unsigned values. This does not
20998apply to function addresses for which @option{-mlong-calls} semantics
20999are in effect.
21000
d77de738 21001@opindex mfp-mode
ddf6fe37 21002@item -mfp-mode=@var{mode}
d77de738
ML
21003Set the prevailing mode of the floating-point unit.
21004This determines the floating-point mode that is provided and expected
21005at function call and return time. Making this mode match the mode you
21006predominantly need at function start can make your programs smaller and
21007faster by avoiding unnecessary mode switches.
21008
21009@var{mode} can be set to one the following values:
21010
21011@table @samp
21012@item caller
21013Any mode at function entry is valid, and retained or restored when
21014the function returns, and when it calls other functions.
21015This mode is useful for compiling libraries or other compilation units
21016you might want to incorporate into different programs with different
21017prevailing FPU modes, and the convenience of being able to use a single
21018object file outweighs the size and speed overhead for any extra
21019mode switching that might be needed, compared with what would be needed
21020with a more specific choice of prevailing FPU mode.
21021
21022@item truncate
21023This is the mode used for floating-point calculations with
21024truncating (i.e.@: round towards zero) rounding mode. That includes
21025conversion from floating point to integer.
21026
21027@item round-nearest
21028This is the mode used for floating-point calculations with
21029round-to-nearest-or-even rounding mode.
21030
21031@item int
21032This is the mode used to perform integer calculations in the FPU, e.g.@:
21033integer multiply, or integer multiply-and-accumulate.
21034@end table
21035
21036The default is @option{-mfp-mode=caller}
21037
d77de738
ML
21038@opindex mno-split-lohi
21039@opindex msplit-lohi
21040@opindex mno-postinc
21041@opindex mpostinc
21042@opindex mno-postmodify
21043@opindex mpostmodify
ddf6fe37
AA
21044@item -mno-split-lohi
21045@itemx -mno-postinc
21046@itemx -mno-postmodify
d77de738
ML
21047Code generation tweaks that disable, respectively, splitting of 32-bit
21048loads, generation of post-increment addresses, and generation of
21049post-modify addresses. The defaults are @option{msplit-lohi},
21050@option{-mpost-inc}, and @option{-mpost-modify}.
21051
d77de738
ML
21052@opindex mno-vect-double
21053@opindex mvect-double
ddf6fe37 21054@item -mnovect-double
d77de738
ML
21055Change the preferred SIMD mode to SImode. The default is
21056@option{-mvect-double}, which uses DImode as preferred SIMD mode.
21057
d77de738 21058@opindex max-vect-align
ddf6fe37 21059@item -max-vect-align=@var{num}
d77de738
ML
21060The maximum alignment for SIMD vector mode types.
21061@var{num} may be 4 or 8. The default is 8.
21062Note that this is an ABI change, even though many library function
21063interfaces are unaffected if they don't use SIMD vector modes
21064in places that affect size and/or alignment of relevant types.
21065
d77de738 21066@opindex msplit-vecmove-early
ddf6fe37 21067@item -msplit-vecmove-early
d77de738
ML
21068Split vector moves into single word moves before reload. In theory this
21069can give better register allocation, but so far the reverse seems to be
21070generally the case.
21071
d77de738 21072@opindex m1reg-
ddf6fe37 21073@item -m1reg-@var{reg}
d77de738
ML
21074Specify a register to hold the constant @minus{}1, which makes loading small negative
21075constants and certain bitmasks faster.
21076Allowable values for @var{reg} are @samp{r43} and @samp{r63},
21077which specify use of that register as a fixed register,
21078and @samp{none}, which means that no register is used for this
21079purpose. The default is @option{-m1reg-none}.
21080
21081@end table
21082
21083@node AMD GCN Options
21084@subsection AMD GCN Options
21085@cindex AMD GCN Options
21086
21087These options are defined specifically for the AMD GCN port.
21088
21089@table @gcctabopt
21090
d77de738 21091@opindex march
d77de738 21092@opindex mtune
ddf6fe37
AA
21093@item -march=@var{gpu}
21094@itemx -mtune=@var{gpu}
d77de738
ML
21095Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
21096are
21097
21098@table @samp
21099@item fiji
21100Compile for GCN3 Fiji devices (gfx803).
21101
21102@item gfx900
21103Compile for GCN5 Vega 10 devices (gfx900).
21104
21105@item gfx906
21106Compile for GCN5 Vega 20 devices (gfx906).
21107
21108@item gfx908
21109Compile for CDNA1 Instinct MI100 series devices (gfx908).
21110
21111@item gfx90a
21112Compile for CDNA2 Instinct MI200 series devices (gfx90a).
21113
21114@end table
21115
ddf6fe37 21116@opindex msram-ecc
d77de738
ML
21117@item -msram-ecc=on
21118@itemx -msram-ecc=off
21119@itemx -msram-ecc=any
d77de738
ML
21120Compile binaries suitable for devices with the SRAM-ECC feature enabled,
21121disabled, or either mode. This feature can be enabled per-process on some
21122devices. The compiled code must match the device mode. The default is
21123@samp{any}, for devices that support it.
21124
d77de738 21125@opindex mstack-size
ddf6fe37 21126@item -mstack-size=@var{bytes}
d77de738
ML
21127Specify how many @var{bytes} of stack space will be requested for each GPU
21128thread (wave-front). Beware that there may be many threads and limited memory
21129available. The size of the stack allocation may also have an impact on
21130run-time performance. The default is 32KB when using OpenACC or OpenMP, and
211311MB otherwise.
21132
d77de738 21133@opindex mxnack
366e3d30
TB
21134@item -mxnack=on
21135@itemx -mxnack=off
21136@itemx -mxnack=any
21137Compile binaries suitable for devices with the XNACK feature enabled, disabled,
21138or either mode. Some devices always require XNACK and some allow the user to
21139configure XNACK. The compiled code must match the device mode.
21140@c The default is @samp{-mxnack=any}.
21141At present this option is a placeholder for support that is not yet implemented.
d77de738
ML
21142
21143@end table
21144
21145@node ARC Options
21146@subsection ARC Options
21147@cindex ARC options
21148
21149The following options control the architecture variant for which code
21150is being compiled:
21151
21152@c architecture variants
21153@table @gcctabopt
21154
d77de738 21155@opindex mbarrel-shifter
ddf6fe37 21156@item -mbarrel-shifter
d77de738
ML
21157Generate instructions supported by barrel shifter. This is the default
21158unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
21159
d77de738 21160@opindex mjli-always
ddf6fe37 21161@item -mjli-always
d77de738
ML
21162Force to call a function using jli_s instruction. This option is
21163valid only for ARCv2 architecture.
21164
d77de738 21165@opindex mcpu
ddf6fe37 21166@item -mcpu=@var{cpu}
d77de738
ML
21167Set architecture type, register usage, and instruction scheduling
21168parameters for @var{cpu}. There are also shortcut alias options
21169available for backward compatibility and convenience. Supported
21170values for @var{cpu} are
21171
21172@table @samp
21173@opindex mA6
21174@opindex mARC600
21175@item arc600
21176Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
21177
d77de738 21178@opindex mARC601
ddf6fe37 21179@item arc601
d77de738
ML
21180Compile for ARC601. Alias: @option{-mARC601}.
21181
d77de738
ML
21182@opindex mA7
21183@opindex mARC700
ddf6fe37 21184@item arc700
d77de738
ML
21185Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
21186This is the default when configured with @option{--with-cpu=arc700}@.
21187
21188@item arcem
21189Compile for ARC EM.
21190
21191@item archs
21192Compile for ARC HS.
21193
21194@item em
21195Compile for ARC EM CPU with no hardware extensions.
21196
21197@item em4
21198Compile for ARC EM4 CPU.
21199
21200@item em4_dmips
21201Compile for ARC EM4 DMIPS CPU.
21202
21203@item em4_fpus
21204Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
21205extension.
21206
21207@item em4_fpuda
21208Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
21209double assist instructions.
21210
21211@item hs
21212Compile for ARC HS CPU with no hardware extensions except the atomic
21213instructions.
21214
21215@item hs34
21216Compile for ARC HS34 CPU.
21217
21218@item hs38
21219Compile for ARC HS38 CPU.
21220
21221@item hs38_linux
21222Compile for ARC HS38 CPU with all hardware extensions on.
21223
21224@item hs4x
21225Compile for ARC HS4x CPU.
21226
21227@item hs4xd
21228Compile for ARC HS4xD CPU.
21229
21230@item hs4x_rel31
21231Compile for ARC HS4x CPU release 3.10a.
21232
21233@item arc600_norm
21234Compile for ARC 600 CPU with @code{norm} instructions enabled.
21235
21236@item arc600_mul32x16
21237Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21238instructions enabled.
21239
21240@item arc600_mul64
21241Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21242instructions enabled.
21243
21244@item arc601_norm
21245Compile for ARC 601 CPU with @code{norm} instructions enabled.
21246
21247@item arc601_mul32x16
21248Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21249instructions enabled.
21250
21251@item arc601_mul64
21252Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21253instructions enabled.
21254
21255@item nps400
21256Compile for ARC 700 on NPS400 chip.
21257
21258@item em_mini
21259Compile for ARC EM minimalist configuration featuring reduced register
21260set.
21261
21262@end table
21263
d77de738 21264@opindex mdpfp
d77de738 21265@opindex mdpfp-compact
ddf6fe37
AA
21266@item -mdpfp
21267@itemx -mdpfp-compact
d77de738
ML
21268Generate double-precision FPX instructions, tuned for the compact
21269implementation.
21270
d77de738 21271@opindex mdpfp-fast
ddf6fe37 21272@item -mdpfp-fast
d77de738
ML
21273Generate double-precision FPX instructions, tuned for the fast
21274implementation.
21275
d77de738 21276@opindex mno-dpfp-lrsr
ddf6fe37 21277@item -mno-dpfp-lrsr
d77de738
ML
21278Disable @code{lr} and @code{sr} instructions from using FPX extension
21279aux registers.
21280
d77de738 21281@opindex mea
ddf6fe37 21282@item -mea
d77de738
ML
21283Generate extended arithmetic instructions. Currently only
21284@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21285supported. Only valid for @option{-mcpu=ARC700}.
21286
d77de738
ML
21287@opindex mno-mpy
21288@opindex mmpy
ddf6fe37 21289@item -mno-mpy
d77de738
ML
21290Do not generate @code{mpy}-family instructions for ARC700. This option is
21291deprecated.
21292
d77de738 21293@opindex mmul32x16
ddf6fe37 21294@item -mmul32x16
d77de738
ML
21295Generate 32x16-bit multiply and multiply-accumulate instructions.
21296
d77de738 21297@opindex mmul64
ddf6fe37 21298@item -mmul64
d77de738
ML
21299Generate @code{mul64} and @code{mulu64} instructions.
21300Only valid for @option{-mcpu=ARC600}.
21301
d77de738 21302@opindex mnorm
ddf6fe37 21303@item -mnorm
d77de738
ML
21304Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21305is in effect.
21306
d77de738 21307@opindex mspfp
d77de738 21308@opindex mspfp-compact
ddf6fe37
AA
21309@item -mspfp
21310@itemx -mspfp-compact
d77de738
ML
21311Generate single-precision FPX instructions, tuned for the compact
21312implementation.
21313
d77de738 21314@opindex mspfp-fast
ddf6fe37 21315@item -mspfp-fast
d77de738
ML
21316Generate single-precision FPX instructions, tuned for the fast
21317implementation.
21318
d77de738 21319@opindex msimd
ddf6fe37 21320@item -msimd
d77de738
ML
21321Enable generation of ARC SIMD instructions via target-specific
21322builtins. Only valid for @option{-mcpu=ARC700}.
21323
d77de738 21324@opindex msoft-float
ddf6fe37 21325@item -msoft-float
d77de738
ML
21326This option ignored; it is provided for compatibility purposes only.
21327Software floating-point code is emitted by default, and this default
21328can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
21329@option{-mspfp-fast} for single precision, and @option{-mdpfp},
21330@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
21331
d77de738 21332@opindex mswap
ddf6fe37 21333@item -mswap
d77de738
ML
21334Generate @code{swap} instructions.
21335
d77de738 21336@opindex matomic
ddf6fe37 21337@item -matomic
d77de738
ML
21338This enables use of the locked load/store conditional extension to implement
21339atomic memory built-in functions. Not available for ARC 6xx or ARC
21340EM cores.
21341
d77de738 21342@opindex mdiv-rem
ddf6fe37 21343@item -mdiv-rem
d77de738
ML
21344Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21345
d77de738 21346@opindex mcode-density
ddf6fe37 21347@item -mcode-density
d77de738
ML
21348Enable code density instructions for ARC EM.
21349This option is on by default for ARC HS.
21350
d77de738 21351@opindex mll64
ddf6fe37 21352@item -mll64
d77de738
ML
21353Enable double load/store operations for ARC HS cores.
21354
d77de738 21355@opindex mtp-regno
ddf6fe37 21356@item -mtp-regno=@var{regno}
d77de738
ML
21357Specify thread pointer register number.
21358
d77de738 21359@opindex mmpy-option
ddf6fe37 21360@item -mmpy-option=@var{multo}
d77de738
ML
21361Compile ARCv2 code with a multiplier design option. You can specify
21362the option using either a string or numeric value for @var{multo}.
21363@samp{wlh1} is the default value. The recognized values are:
21364
21365@table @samp
21366@item 0
21367@itemx none
21368No multiplier available.
21369
21370@item 1
21371@itemx w
2137216x16 multiplier, fully pipelined.
21373The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21374
21375@item 2
21376@itemx wlh1
2137732x32 multiplier, fully
21378pipelined (1 stage). The following instructions are additionally
21379enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21380
21381@item 3
21382@itemx wlh2
2138332x32 multiplier, fully pipelined
21384(2 stages). The following instructions are additionally enabled: @code{mpy},
21385@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21386
21387@item 4
21388@itemx wlh3
21389Two 16x16 multipliers, blocking,
21390sequential. The following instructions are additionally enabled: @code{mpy},
21391@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21392
21393@item 5
21394@itemx wlh4
21395One 16x16 multiplier, blocking,
21396sequential. The following instructions are additionally enabled: @code{mpy},
21397@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21398
21399@item 6
21400@itemx wlh5
21401One 32x4 multiplier, blocking,
21402sequential. The following instructions are additionally enabled: @code{mpy},
21403@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21404
21405@item 7
21406@itemx plus_dmpy
21407ARC HS SIMD support.
21408
21409@item 8
21410@itemx plus_macd
21411ARC HS SIMD support.
21412
21413@item 9
21414@itemx plus_qmacw
21415ARC HS SIMD support.
21416
21417@end table
21418
21419This option is only available for ARCv2 cores@.
21420
d77de738 21421@opindex mfpu
ddf6fe37 21422@item -mfpu=@var{fpu}
d77de738
ML
21423Enables support for specific floating-point hardware extensions for ARCv2
21424cores. Supported values for @var{fpu} are:
21425
21426@table @samp
21427
21428@item fpus
21429Enables support for single-precision floating-point hardware
21430extensions@.
21431
21432@item fpud
21433Enables support for double-precision floating-point hardware
21434extensions. The single-precision floating-point extension is also
21435enabled. Not available for ARC EM@.
21436
21437@item fpuda
21438Enables support for double-precision floating-point hardware
21439extensions using double-precision assist instructions. The single-precision
21440floating-point extension is also enabled. This option is
21441only available for ARC EM@.
21442
21443@item fpuda_div
21444Enables support for double-precision floating-point hardware
21445extensions using double-precision assist instructions.
21446The single-precision floating-point, square-root, and divide
21447extensions are also enabled. This option is
21448only available for ARC EM@.
21449
21450@item fpuda_fma
21451Enables support for double-precision floating-point hardware
21452extensions using double-precision assist instructions.
21453The single-precision floating-point and fused multiply and add
21454hardware extensions are also enabled. This option is
21455only available for ARC EM@.
21456
21457@item fpuda_all
21458Enables support for double-precision floating-point hardware
21459extensions using double-precision assist instructions.
21460All single-precision floating-point hardware extensions are also
21461enabled. This option is only available for ARC EM@.
21462
21463@item fpus_div
21464Enables support for single-precision floating-point, square-root and divide
21465hardware extensions@.
21466
21467@item fpud_div
21468Enables support for double-precision floating-point, square-root and divide
21469hardware extensions. This option
21470includes option @samp{fpus_div}. Not available for ARC EM@.
21471
21472@item fpus_fma
21473Enables support for single-precision floating-point and
21474fused multiply and add hardware extensions@.
21475
21476@item fpud_fma
21477Enables support for double-precision floating-point and
21478fused multiply and add hardware extensions. This option
21479includes option @samp{fpus_fma}. Not available for ARC EM@.
21480
21481@item fpus_all
21482Enables support for all single-precision floating-point hardware
21483extensions@.
21484
21485@item fpud_all
21486Enables support for all single- and double-precision floating-point
21487hardware extensions. Not available for ARC EM@.
21488
21489@end table
21490
d77de738 21491@opindex mirq-ctrl-saved
ddf6fe37 21492@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21493Specifies general-purposes registers that the processor automatically
21494saves/restores on interrupt entry and exit. @var{register-range} is
21495specified as two registers separated by a dash. The register range
21496always starts with @code{r0}, the upper limit is @code{fp} register.
21497@var{blink} and @var{lp_count} are optional. This option is only
21498valid for ARC EM and ARC HS cores.
21499
d77de738 21500@opindex mrgf-banked-regs
ddf6fe37 21501@item -mrgf-banked-regs=@var{number}
d77de738
ML
21502Specifies the number of registers replicated in second register bank
21503on entry to fast interrupt. Fast interrupts are interrupts with the
21504highest priority level P0. These interrupts save only PC and STATUS32
21505registers to avoid memory transactions during interrupt entry and exit
21506sequences. Use this option when you are using fast interrupts in an
21507ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21508
d77de738 21509@opindex mlpc-width
ddf6fe37 21510@item -mlpc-width=@var{width}
d77de738
ML
21511Specify the width of the @code{lp_count} register. Valid values for
21512@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21513fixed to 32 bits. If the width is less than 32, the compiler does not
21514attempt to transform loops in your program to use the zero-delay loop
21515mechanism unless it is known that the @code{lp_count} register can
21516hold the required loop-counter value. Depending on the width
21517specified, the compiler and run-time library might continue to use the
21518loop mechanism for various needs. This option defines macro
21519@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21520
d77de738 21521@opindex mrf16
ddf6fe37 21522@item -mrf16
d77de738
ML
21523This option instructs the compiler to generate code for a 16-entry
21524register file. This option defines the @code{__ARC_RF16__}
21525preprocessor macro.
21526
d77de738 21527@opindex mbranch-index
ddf6fe37 21528@item -mbranch-index
d77de738
ML
21529Enable use of @code{bi} or @code{bih} instructions to implement jump
21530tables.
21531
21532@end table
21533
21534The following options are passed through to the assembler, and also
21535define preprocessor macro symbols.
21536
21537@c Flags used by the assembler, but for which we define preprocessor
21538@c macro symbols as well.
21539@table @gcctabopt
d77de738 21540@opindex mdsp-packa
ddf6fe37 21541@item -mdsp-packa
d77de738
ML
21542Passed down to the assembler to enable the DSP Pack A extensions.
21543Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21544deprecated.
21545
d77de738 21546@opindex mdvbf
ddf6fe37 21547@item -mdvbf
d77de738
ML
21548Passed down to the assembler to enable the dual Viterbi butterfly
21549extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21550option is deprecated.
21551
21552@c ARC700 4.10 extension instruction
d77de738 21553@opindex mlock
ddf6fe37 21554@item -mlock
d77de738
ML
21555Passed down to the assembler to enable the locked load/store
21556conditional extension. Also sets the preprocessor symbol
21557@code{__Xlock}.
21558
d77de738 21559@opindex mmac-d16
ddf6fe37 21560@item -mmac-d16
d77de738
ML
21561Passed down to the assembler. Also sets the preprocessor symbol
21562@code{__Xxmac_d16}. This option is deprecated.
21563
d77de738 21564@opindex mmac-24
ddf6fe37 21565@item -mmac-24
d77de738
ML
21566Passed down to the assembler. Also sets the preprocessor symbol
21567@code{__Xxmac_24}. This option is deprecated.
21568
21569@c ARC700 4.10 extension instruction
d77de738 21570@opindex mrtsc
ddf6fe37 21571@item -mrtsc
d77de738
ML
21572Passed down to the assembler to enable the 64-bit time-stamp counter
21573extension instruction. Also sets the preprocessor symbol
21574@code{__Xrtsc}. This option is deprecated.
21575
21576@c ARC700 4.10 extension instruction
d77de738 21577@opindex mswape
ddf6fe37 21578@item -mswape
d77de738
ML
21579Passed down to the assembler to enable the swap byte ordering
21580extension instruction. Also sets the preprocessor symbol
21581@code{__Xswape}.
21582
d77de738 21583@opindex mtelephony
ddf6fe37 21584@item -mtelephony
d77de738
ML
21585Passed down to the assembler to enable dual- and single-operand
21586instructions for telephony. Also sets the preprocessor symbol
21587@code{__Xtelephony}. This option is deprecated.
21588
d77de738 21589@opindex mxy
ddf6fe37 21590@item -mxy
d77de738
ML
21591Passed down to the assembler to enable the XY memory extension. Also
21592sets the preprocessor symbol @code{__Xxy}.
21593
21594@end table
21595
21596The following options control how the assembly code is annotated:
21597
21598@c Assembly annotation options
21599@table @gcctabopt
d77de738 21600@opindex misize
ddf6fe37 21601@item -misize
d77de738
ML
21602Annotate assembler instructions with estimated addresses.
21603
d77de738 21604@opindex mannotate-align
ddf6fe37 21605@item -mannotate-align
e4b19406 21606Does nothing. Preserved for backward compatibility.
d77de738
ML
21607
21608@end table
21609
21610The following options are passed through to the linker:
21611
21612@c options passed through to the linker
21613@table @gcctabopt
d77de738 21614@opindex marclinux
ddf6fe37 21615@item -marclinux
d77de738
ML
21616Passed through to the linker, to specify use of the @code{arclinux} emulation.
21617This option is enabled by default in tool chains built for
21618@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21619when profiling is not requested.
21620
d77de738 21621@opindex marclinux_prof
ddf6fe37 21622@item -marclinux_prof
d77de738
ML
21623Passed through to the linker, to specify use of the
21624@code{arclinux_prof} emulation. This option is enabled by default in
21625tool chains built for @w{@code{arc-linux-uclibc}} and
21626@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21627
21628@end table
21629
21630The following options control the semantics of generated code:
21631
21632@c semantically relevant code generation options
21633@table @gcctabopt
d77de738 21634@opindex mlong-calls
ddf6fe37 21635@item -mlong-calls
d77de738
ML
21636Generate calls as register indirect calls, thus providing access
21637to the full 32-bit address range.
21638
d77de738 21639@opindex mmedium-calls
ddf6fe37 21640@item -mmedium-calls
d77de738
ML
21641Don't use less than 25-bit addressing range for calls, which is the
21642offset available for an unconditional branch-and-link
21643instruction. Conditional execution of function calls is suppressed, to
21644allow use of the 25-bit range, rather than the 21-bit range with
21645conditional branch-and-link. This is the default for tool chains built
21646for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21647
d77de738 21648@opindex G
ddf6fe37 21649@item -G @var{num}
d77de738
ML
21650Put definitions of externally-visible data in a small data section if
21651that data is no bigger than @var{num} bytes. The default value of
21652@var{num} is 4 for any ARC configuration, or 8 when we have double
21653load/store operations.
21654
d77de738
ML
21655@opindex mno-sdata
21656@opindex msdata
ddf6fe37 21657@item -mno-sdata
d77de738
ML
21658Do not generate sdata references. This is the default for tool chains
21659built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21660targets.
21661
d77de738 21662@opindex mvolatile-cache
ddf6fe37 21663@item -mvolatile-cache
d77de738
ML
21664Use ordinarily cached memory accesses for volatile references. This is the
21665default.
21666
d77de738
ML
21667@opindex mno-volatile-cache
21668@opindex mvolatile-cache
ddf6fe37 21669@item -mno-volatile-cache
d77de738
ML
21670Enable cache bypass for volatile references.
21671
21672@end table
21673
21674The following options fine tune code generation:
21675@c code generation tuning options
21676@table @gcctabopt
d77de738 21677@opindex malign-call
ddf6fe37 21678@item -malign-call
d77de738
ML
21679Does nothing. Preserved for backward compatibility.
21680
d77de738 21681@opindex mauto-modify-reg
ddf6fe37 21682@item -mauto-modify-reg
d77de738
ML
21683Enable the use of pre/post modify with register displacement.
21684
d77de738 21685@opindex mbbit-peephole
ddf6fe37 21686@item -mbbit-peephole
07f7615c 21687Does nothing. Preserved for backward compatibility.
d77de738 21688
d77de738 21689@opindex mno-brcc
ddf6fe37 21690@item -mno-brcc
d77de738
ML
21691This option disables a target-specific pass in @file{arc_reorg} to
21692generate compare-and-branch (@code{br@var{cc}}) instructions.
21693It has no effect on
21694generation of these instructions driven by the combiner pass.
21695
d77de738 21696@opindex mcase-vector-pcrel
ddf6fe37 21697@item -mcase-vector-pcrel
d77de738
ML
21698Use PC-relative switch case tables to enable case table shortening.
21699This is the default for @option{-Os}.
21700
d77de738 21701@opindex mcompact-casesi
ddf6fe37 21702@item -mcompact-casesi
d77de738
ML
21703Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21704and only available for ARCv1 cores. This option is deprecated.
21705
d77de738 21706@opindex mno-cond-exec
ddf6fe37 21707@item -mno-cond-exec
d77de738
ML
21708Disable the ARCompact-specific pass to generate conditional
21709execution instructions.
21710
21711Due to delay slot scheduling and interactions between operand numbers,
21712literal sizes, instruction lengths, and the support for conditional execution,
21713the target-independent pass to generate conditional execution is often lacking,
21714so the ARC port has kept a special pass around that tries to find more
21715conditional execution generation opportunities after register allocation,
21716branch shortening, and delay slot scheduling have been done. This pass
21717generally, but not always, improves performance and code size, at the cost of
21718extra compilation time, which is why there is an option to switch it off.
21719If you have a problem with call instructions exceeding their allowable
21720offset range because they are conditionalized, you should consider using
21721@option{-mmedium-calls} instead.
21722
d77de738 21723@opindex mearly-cbranchsi
ddf6fe37 21724@item -mearly-cbranchsi
d77de738
ML
21725Enable pre-reload use of the @code{cbranchsi} pattern.
21726
d77de738 21727@opindex mexpand-adddi
ddf6fe37 21728@item -mexpand-adddi
d77de738
ML
21729Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21730@code{add.f}, @code{adc} etc. This option is deprecated.
21731
d77de738 21732@opindex mindexed-loads
ddf6fe37 21733@item -mindexed-loads
d77de738
ML
21734Enable the use of indexed loads. This can be problematic because some
21735optimizers then assume that indexed stores exist, which is not
21736the case.
21737
d77de738 21738@opindex mlra
ddf6fe37 21739@item -mlra
d77de738
ML
21740Enable Local Register Allocation. This is still experimental for ARC,
21741so by default the compiler uses standard reload
21742(i.e.@: @option{-mno-lra}).
21743
d77de738 21744@opindex mlra-priority-none
ddf6fe37 21745@item -mlra-priority-none
d77de738
ML
21746Don't indicate any priority for target registers.
21747
d77de738 21748@opindex mlra-priority-compact
ddf6fe37 21749@item -mlra-priority-compact
d77de738
ML
21750Indicate target register priority for r0..r3 / r12..r15.
21751
d77de738 21752@opindex mlra-priority-noncompact
ddf6fe37 21753@item -mlra-priority-noncompact
d77de738
ML
21754Reduce target register priority for r0..r3 / r12..r15.
21755
d77de738 21756@opindex mmillicode
ddf6fe37 21757@item -mmillicode
d77de738
ML
21758When optimizing for size (using @option{-Os}), prologues and epilogues
21759that have to save or restore a large number of registers are often
21760shortened by using call to a special function in libgcc; this is
21761referred to as a @emph{millicode} call. As these calls can pose
21762performance issues, and/or cause linking issues when linking in a
21763nonstandard way, this option is provided to turn on or off millicode
21764call generation.
21765
d77de738 21766@opindex mcode-density-frame
ddf6fe37 21767@item -mcode-density-frame
d77de738
ML
21768This option enable the compiler to emit @code{enter} and @code{leave}
21769instructions. These instructions are only valid for CPUs with
21770code-density feature.
21771
d77de738 21772@opindex mmixed-code
ddf6fe37 21773@item -mmixed-code
d77de738
ML
21774Does nothing. Preserved for backward compatibility.
21775
d77de738 21776@opindex mq-class
ddf6fe37 21777@item -mq-class
d77de738
ML
21778Ths option is deprecated. Enable @samp{q} instruction alternatives.
21779This is the default for @option{-Os}.
21780
d77de738 21781@opindex mRcq
ddf6fe37 21782@item -mRcq
d77de738
ML
21783Does nothing. Preserved for backward compatibility.
21784
d77de738 21785@opindex mRcw
ddf6fe37 21786@item -mRcw
d77de738
ML
21787Does nothing. Preserved for backward compatibility.
21788
d77de738 21789@opindex msize-level
ddf6fe37 21790@item -msize-level=@var{level}
d77de738
ML
21791Fine-tune size optimization with regards to instruction lengths and alignment.
21792The recognized values for @var{level} are:
21793@table @samp
21794@item 0
21795No size optimization. This level is deprecated and treated like @samp{1}.
21796
21797@item 1
21798Short instructions are used opportunistically.
21799
21800@item 2
21801In addition, alignment of loops and of code after barriers are dropped.
21802
21803@item 3
21804In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21805
21806@end table
21807
21808This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21809the behavior when this is not set is equivalent to level @samp{1}.
21810
d77de738 21811@opindex mtune
ddf6fe37 21812@item -mtune=@var{cpu}
d77de738
ML
21813Set instruction scheduling parameters for @var{cpu}, overriding any implied
21814by @option{-mcpu=}.
21815
21816Supported values for @var{cpu} are
21817
21818@table @samp
21819@item ARC600
21820Tune for ARC600 CPU.
21821
21822@item ARC601
21823Tune for ARC601 CPU.
21824
21825@item ARC700
21826Tune for ARC700 CPU with standard multiplier block.
21827
21828@item ARC700-xmac
21829Tune for ARC700 CPU with XMAC block.
21830
21831@item ARC725D
21832Tune for ARC725D CPU.
21833
21834@item ARC750D
21835Tune for ARC750D CPU.
21836
21837@item core3
21838Tune for ARCv2 core3 type CPU. This option enable usage of
21839@code{dbnz} instruction.
21840
21841@item release31a
21842Tune for ARC4x release 3.10a.
21843
21844@end table
21845
d77de738 21846@opindex mmultcost
ddf6fe37 21847@item -mmultcost=@var{num}
d77de738
ML
21848Cost to assume for a multiply instruction, with @samp{4} being equal to a
21849normal instruction.
21850
d77de738 21851@opindex munalign-prob-threshold
ddf6fe37 21852@item -munalign-prob-threshold=@var{probability}
d77de738
ML
21853Does nothing. Preserved for backward compatibility.
21854
21855@end table
21856
21857The following options are maintained for backward compatibility, but
21858are now deprecated and will be removed in a future release:
21859
21860@c Deprecated options
21861@table @gcctabopt
21862
d77de738 21863@opindex margonaut
ddf6fe37 21864@item -margonaut
d77de738
ML
21865Obsolete FPX.
21866
d77de738 21867@opindex mbig-endian
d77de738 21868@opindex EB
ddf6fe37
AA
21869@item -mbig-endian
21870@itemx -EB
d77de738
ML
21871Compile code for big-endian targets. Use of these options is now
21872deprecated. Big-endian code is supported by configuring GCC to build
21873@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21874for which big endian is the default.
21875
d77de738 21876@opindex mlittle-endian
d77de738 21877@opindex EL
ddf6fe37
AA
21878@item -mlittle-endian
21879@itemx -EL
d77de738
ML
21880Compile code for little-endian targets. Use of these options is now
21881deprecated. Little-endian code is supported by configuring GCC to build
21882@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21883for which little endian is the default.
21884
d77de738 21885@opindex mbarrel_shifter
ddf6fe37 21886@item -mbarrel_shifter
d77de738
ML
21887Replaced by @option{-mbarrel-shifter}.
21888
d77de738 21889@opindex mdpfp_compact
ddf6fe37 21890@item -mdpfp_compact
d77de738
ML
21891Replaced by @option{-mdpfp-compact}.
21892
d77de738 21893@opindex mdpfp_fast
ddf6fe37 21894@item -mdpfp_fast
d77de738
ML
21895Replaced by @option{-mdpfp-fast}.
21896
d77de738 21897@opindex mdsp_packa
ddf6fe37 21898@item -mdsp_packa
d77de738
ML
21899Replaced by @option{-mdsp-packa}.
21900
d77de738 21901@opindex mEA
ddf6fe37 21902@item -mEA
d77de738
ML
21903Replaced by @option{-mea}.
21904
d77de738 21905@opindex mmac_24
ddf6fe37 21906@item -mmac_24
d77de738
ML
21907Replaced by @option{-mmac-24}.
21908
d77de738 21909@opindex mmac_d16
ddf6fe37 21910@item -mmac_d16
d77de738
ML
21911Replaced by @option{-mmac-d16}.
21912
d77de738 21913@opindex mspfp_compact
ddf6fe37 21914@item -mspfp_compact
d77de738
ML
21915Replaced by @option{-mspfp-compact}.
21916
d77de738 21917@opindex mspfp_fast
ddf6fe37 21918@item -mspfp_fast
d77de738
ML
21919Replaced by @option{-mspfp-fast}.
21920
d77de738 21921@opindex mtune
ddf6fe37 21922@item -mtune=@var{cpu}
d77de738
ML
21923Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21924@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21925@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21926
d77de738 21927@opindex multcost
ddf6fe37 21928@item -multcost=@var{num}
d77de738
ML
21929Replaced by @option{-mmultcost}.
21930
21931@end table
21932
21933@node ARM Options
21934@subsection ARM Options
21935@cindex ARM options
21936
21937These @samp{-m} options are defined for the ARM port:
21938
21939@table @gcctabopt
d77de738 21940@opindex mabi
ddf6fe37 21941@item -mabi=@var{name}
d77de738
ML
21942Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21943@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21944
d77de738 21945@opindex mapcs-frame
ddf6fe37 21946@item -mapcs-frame
d77de738
ML
21947Generate a stack frame that is compliant with the ARM Procedure Call
21948Standard for all functions, even if this is not strictly necessary for
21949correct execution of the code. Specifying @option{-fomit-frame-pointer}
21950with this option causes the stack frames not to be generated for
21951leaf functions. The default is @option{-mno-apcs-frame}.
21952This option is deprecated.
21953
d77de738 21954@opindex mapcs
ddf6fe37 21955@item -mapcs
d77de738
ML
21956This is a synonym for @option{-mapcs-frame} and is deprecated.
21957
21958@ignore
21959@c not currently implemented
d77de738 21960@opindex mapcs-stack-check
ddf6fe37 21961@item -mapcs-stack-check
d77de738
ML
21962Generate code to check the amount of stack space available upon entry to
21963every function (that actually uses some stack space). If there is
21964insufficient space available then either the function
21965@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21966called, depending upon the amount of stack space required. The runtime
21967system is required to provide these functions. The default is
21968@option{-mno-apcs-stack-check}, since this produces smaller code.
21969
21970@c not currently implemented
d77de738 21971@opindex mapcs-reentrant
ddf6fe37 21972@item -mapcs-reentrant
d77de738
ML
21973Generate reentrant, position-independent code. The default is
21974@option{-mno-apcs-reentrant}.
21975@end ignore
21976
d77de738 21977@opindex mthumb-interwork
ddf6fe37 21978@item -mthumb-interwork
d77de738
ML
21979Generate code that supports calling between the ARM and Thumb
21980instruction sets. Without this option, on pre-v5 architectures, the
21981two instruction sets cannot be reliably used inside one program. The
21982default is @option{-mno-thumb-interwork}, since slightly larger code
21983is generated when @option{-mthumb-interwork} is specified. In AAPCS
21984configurations this option is meaningless.
21985
d77de738
ML
21986@opindex mno-sched-prolog
21987@opindex msched-prolog
ddf6fe37 21988@item -mno-sched-prolog
d77de738
ML
21989Prevent the reordering of instructions in the function prologue, or the
21990merging of those instruction with the instructions in the function's
21991body. This means that all functions start with a recognizable set
21992of instructions (or in fact one of a choice from a small set of
21993different function prologues), and this information can be used to
21994locate the start of functions inside an executable piece of code. The
21995default is @option{-msched-prolog}.
21996
d77de738 21997@opindex mfloat-abi
ddf6fe37 21998@item -mfloat-abi=@var{name}
d77de738
ML
21999Specifies which floating-point ABI to use. Permissible values
22000are: @samp{soft}, @samp{softfp} and @samp{hard}.
22001
22002Specifying @samp{soft} causes GCC to generate output containing
22003library calls for floating-point operations.
22004@samp{softfp} allows the generation of code using hardware floating-point
22005instructions, but still uses the soft-float calling conventions.
22006@samp{hard} allows generation of floating-point instructions
22007and uses FPU-specific calling conventions.
22008
22009The default depends on the specific target configuration. Note that
22010the hard-float and soft-float ABIs are not link-compatible; you must
22011compile your entire program with the same ABI, and link with a
22012compatible set of libraries.
22013
d77de738 22014@opindex mgeneral-regs-only
ddf6fe37 22015@item -mgeneral-regs-only
d77de738
ML
22016Generate code which uses only the general-purpose registers. This will prevent
22017the compiler from using floating-point and Advanced SIMD registers but will not
22018impose any restrictions on the assembler.
22019
d77de738 22020@opindex mlittle-endian
ddf6fe37 22021@item -mlittle-endian
d77de738
ML
22022Generate code for a processor running in little-endian mode. This is
22023the default for all standard configurations.
22024
d77de738 22025@opindex mbig-endian
ddf6fe37 22026@item -mbig-endian
d77de738
ML
22027Generate code for a processor running in big-endian mode; the default is
22028to compile code for a little-endian processor.
22029
ddf6fe37 22030@opindex mbe8
d77de738
ML
22031@item -mbe8
22032@itemx -mbe32
d77de738
ML
22033When linking a big-endian image select between BE8 and BE32 formats.
22034The option has no effect for little-endian images and is ignored. The
22035default is dependent on the selected target architecture. For ARMv6
22036and later architectures the default is BE8, for older architectures
22037the default is BE32. BE32 format has been deprecated by ARM.
22038
d77de738 22039@opindex march
ddf6fe37 22040@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22041This specifies the name of the target ARM architecture. GCC uses this
22042name to determine what kind of instructions it can emit when generating
22043assembly code. This option can be used in conjunction with or instead
22044of the @option{-mcpu=} option.
22045
22046Permissible names are:
22047@samp{armv4t},
22048@samp{armv5t}, @samp{armv5te},
22049@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
22050@samp{armv6z}, @samp{armv6zk},
22051@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
22052@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
22053@samp{armv8.4-a},
22054@samp{armv8.5-a},
22055@samp{armv8.6-a},
22056@samp{armv9-a},
22057@samp{armv7-r},
22058@samp{armv8-r},
22059@samp{armv6-m}, @samp{armv6s-m},
22060@samp{armv7-m}, @samp{armv7e-m},
22061@samp{armv8-m.base}, @samp{armv8-m.main},
22062@samp{armv8.1-m.main},
22063@samp{armv9-a},
22064@samp{iwmmxt} and @samp{iwmmxt2}.
22065
22066Additionally, the following architectures, which lack support for the
22067Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
22068
22069Many of the architectures support extensions. These can be added by
22070appending @samp{+@var{extension}} to the architecture name. Extension
22071options are processed in order and capabilities accumulate. An extension
22072will also enable any necessary base extensions
22073upon which it depends. For example, the @samp{+crypto} extension
22074will always enable the @samp{+simd} extension. The exception to the
22075additive construction is for extensions that are prefixed with
22076@samp{+no@dots{}}: these extensions disable the specified option and
22077any other extensions that may depend on the presence of that
22078extension.
22079
22080For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
22081writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
22082entirely disabled by the @samp{+nofp} option that follows it.
22083
22084Most extension names are generically named, but have an effect that is
22085dependent upon the architecture to which it is applied. For example,
22086the @samp{+simd} option can be applied to both @samp{armv7-a} and
22087@samp{armv8-a} architectures, but will enable the original ARMv7-A
22088Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
22089variant for @samp{armv8-a}.
22090
22091The table below lists the supported extensions for each architecture.
22092Architectures not mentioned do not support any extensions.
22093
22094@table @samp
22095@item armv5te
22096@itemx armv6
22097@itemx armv6j
22098@itemx armv6k
22099@itemx armv6kz
22100@itemx armv6t2
22101@itemx armv6z
22102@itemx armv6zk
22103@table @samp
22104@item +fp
22105The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
22106used as an alias for this extension.
22107
22108@item +nofp
22109Disable the floating-point instructions.
22110@end table
22111
22112@item armv7
22113The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
22114@table @samp
22115@item +fp
22116The VFPv3 floating-point instructions, with 16 double-precision
22117registers. The extension @samp{+vfpv3-d16} can be used as an alias
22118for this extension. Note that floating-point is not supported by the
22119base ARMv7-M architecture, but is compatible with both the ARMv7-A and
22120ARMv7-R architectures.
22121
22122@item +nofp
22123Disable the floating-point instructions.
22124@end table
22125
22126@item armv7-a
22127@table @samp
22128@item +mp
22129The multiprocessing extension.
22130
22131@item +sec
22132The security extension.
22133
22134@item +fp
22135The VFPv3 floating-point instructions, with 16 double-precision
22136registers. The extension @samp{+vfpv3-d16} can be used as an alias
22137for this extension.
22138
22139@item +simd
22140The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22141The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
22142for this extension.
22143
22144@item +vfpv3
22145The VFPv3 floating-point instructions, with 32 double-precision
22146registers.
22147
22148@item +vfpv3-d16-fp16
22149The VFPv3 floating-point instructions, with 16 double-precision
22150registers and the half-precision floating-point conversion operations.
22151
22152@item +vfpv3-fp16
22153The VFPv3 floating-point instructions, with 32 double-precision
22154registers and the half-precision floating-point conversion operations.
22155
22156@item +vfpv4-d16
22157The VFPv4 floating-point instructions, with 16 double-precision
22158registers.
22159
22160@item +vfpv4
22161The VFPv4 floating-point instructions, with 32 double-precision
22162registers.
22163
22164@item +neon-fp16
22165The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22166the half-precision floating-point conversion operations.
22167
22168@item +neon-vfpv4
22169The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
22170
22171@item +nosimd
22172Disable the Advanced SIMD instructions (does not disable floating point).
22173
22174@item +nofp
22175Disable the floating-point and Advanced SIMD instructions.
22176@end table
22177
22178@item armv7ve
22179The extended version of the ARMv7-A architecture with support for
22180virtualization.
22181@table @samp
22182@item +fp
22183The VFPv4 floating-point instructions, with 16 double-precision registers.
22184The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
22185
22186@item +simd
22187The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
22188extension @samp{+neon-vfpv4} can be used as an alias for this extension.
22189
22190@item +vfpv3-d16
22191The VFPv3 floating-point instructions, with 16 double-precision
22192registers.
22193
22194@item +vfpv3
22195The VFPv3 floating-point instructions, with 32 double-precision
22196registers.
22197
22198@item +vfpv3-d16-fp16
22199The VFPv3 floating-point instructions, with 16 double-precision
22200registers and the half-precision floating-point conversion operations.
22201
22202@item +vfpv3-fp16
22203The VFPv3 floating-point instructions, with 32 double-precision
22204registers and the half-precision floating-point conversion operations.
22205
22206@item +vfpv4-d16
22207The VFPv4 floating-point instructions, with 16 double-precision
22208registers.
22209
22210@item +vfpv4
22211The VFPv4 floating-point instructions, with 32 double-precision
22212registers.
22213
22214@item +neon
22215The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22216The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
22217
22218@item +neon-fp16
22219The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22220the half-precision floating-point conversion operations.
22221
22222@item +nosimd
22223Disable the Advanced SIMD instructions (does not disable floating point).
22224
22225@item +nofp
22226Disable the floating-point and Advanced SIMD instructions.
22227@end table
22228
22229@item armv8-a
22230@table @samp
22231@item +crc
22232The Cyclic Redundancy Check (CRC) instructions.
22233@item +simd
22234The ARMv8-A Advanced SIMD and floating-point instructions.
22235@item +crypto
22236The cryptographic instructions.
22237@item +nocrypto
22238Disable the cryptographic instructions.
22239@item +nofp
22240Disable the floating-point, Advanced SIMD and cryptographic instructions.
22241@item +sb
22242Speculation Barrier Instruction.
22243@item +predres
22244Execution and Data Prediction Restriction Instructions.
22245@end table
22246
22247@item armv8.1-a
22248@table @samp
22249@item +simd
22250The ARMv8.1-A Advanced SIMD and floating-point instructions.
22251
22252@item +crypto
22253The cryptographic instructions. This also enables the Advanced SIMD and
22254floating-point instructions.
22255
22256@item +nocrypto
22257Disable the cryptographic instructions.
22258
22259@item +nofp
22260Disable the floating-point, Advanced SIMD and cryptographic instructions.
22261
22262@item +sb
22263Speculation Barrier Instruction.
22264
22265@item +predres
22266Execution and Data Prediction Restriction Instructions.
22267@end table
22268
22269@item armv8.2-a
22270@itemx armv8.3-a
22271@table @samp
22272@item +fp16
22273The half-precision floating-point data processing instructions.
22274This also enables the Advanced SIMD and floating-point instructions.
22275
22276@item +fp16fml
22277The half-precision floating-point fmla extension. This also enables
22278the half-precision floating-point extension and Advanced SIMD and
22279floating-point instructions.
22280
22281@item +simd
22282The ARMv8.1-A Advanced SIMD and floating-point instructions.
22283
22284@item +crypto
22285The cryptographic instructions. This also enables the Advanced SIMD and
22286floating-point instructions.
22287
22288@item +dotprod
22289Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22290
22291@item +nocrypto
22292Disable the cryptographic extension.
22293
22294@item +nofp
22295Disable the floating-point, Advanced SIMD and cryptographic instructions.
22296
22297@item +sb
22298Speculation Barrier Instruction.
22299
22300@item +predres
22301Execution and Data Prediction Restriction Instructions.
22302
22303@item +i8mm
223048-bit Integer Matrix Multiply instructions.
22305This also enables Advanced SIMD and floating-point instructions.
22306
22307@item +bf16
22308Brain half-precision floating-point instructions.
22309This also enables Advanced SIMD and floating-point instructions.
22310@end table
22311
22312@item armv8.4-a
22313@table @samp
22314@item +fp16
22315The half-precision floating-point data processing instructions.
22316This also enables the Advanced SIMD and floating-point instructions as well
22317as the Dot Product extension and the half-precision floating-point fmla
22318extension.
22319
22320@item +simd
22321The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22322Dot Product extension.
22323
22324@item +crypto
22325The cryptographic instructions. This also enables the Advanced SIMD and
22326floating-point instructions as well as the Dot Product extension.
22327
22328@item +nocrypto
22329Disable the cryptographic extension.
22330
22331@item +nofp
22332Disable the floating-point, Advanced SIMD and cryptographic instructions.
22333
22334@item +sb
22335Speculation Barrier Instruction.
22336
22337@item +predres
22338Execution and Data Prediction Restriction Instructions.
22339
22340@item +i8mm
223418-bit Integer Matrix Multiply instructions.
22342This also enables Advanced SIMD and floating-point instructions.
22343
22344@item +bf16
22345Brain half-precision floating-point instructions.
22346This also enables Advanced SIMD and floating-point instructions.
22347@end table
22348
22349@item armv8.5-a
22350@table @samp
22351@item +fp16
22352The half-precision floating-point data processing instructions.
22353This also enables the Advanced SIMD and floating-point instructions as well
22354as the Dot Product extension and the half-precision floating-point fmla
22355extension.
22356
22357@item +simd
22358The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22359Dot Product extension.
22360
22361@item +crypto
22362The cryptographic instructions. This also enables the Advanced SIMD and
22363floating-point instructions as well as the Dot Product extension.
22364
22365@item +nocrypto
22366Disable the cryptographic extension.
22367
22368@item +nofp
22369Disable the floating-point, Advanced SIMD and cryptographic instructions.
22370
22371@item +i8mm
223728-bit Integer Matrix Multiply instructions.
22373This also enables Advanced SIMD and floating-point instructions.
22374
22375@item +bf16
22376Brain half-precision floating-point instructions.
22377This also enables Advanced SIMD and floating-point instructions.
22378@end table
22379
22380@item armv8.6-a
22381@table @samp
22382@item +fp16
22383The half-precision floating-point data processing instructions.
22384This also enables the Advanced SIMD and floating-point instructions as well
22385as the Dot Product extension and the half-precision floating-point fmla
22386extension.
22387
22388@item +simd
22389The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22390Dot Product extension.
22391
22392@item +crypto
22393The cryptographic instructions. This also enables the Advanced SIMD and
22394floating-point instructions as well as the Dot Product extension.
22395
22396@item +nocrypto
22397Disable the cryptographic extension.
22398
22399@item +nofp
22400Disable the floating-point, Advanced SIMD and cryptographic instructions.
22401
22402@item +i8mm
224038-bit Integer Matrix Multiply instructions.
22404This also enables Advanced SIMD and floating-point instructions.
22405
22406@item +bf16
22407Brain half-precision floating-point instructions.
22408This also enables Advanced SIMD and floating-point instructions.
22409@end table
22410
22411@item armv7-r
22412@table @samp
22413@item +fp.sp
22414The single-precision VFPv3 floating-point instructions. The extension
22415@samp{+vfpv3xd} can be used as an alias for this extension.
22416
22417@item +fp
22418The VFPv3 floating-point instructions with 16 double-precision registers.
22419The extension +vfpv3-d16 can be used as an alias for this extension.
22420
22421@item +vfpv3xd-d16-fp16
22422The single-precision VFPv3 floating-point instructions with 16 double-precision
22423registers and the half-precision floating-point conversion operations.
22424
22425@item +vfpv3-d16-fp16
22426The VFPv3 floating-point instructions with 16 double-precision
22427registers and the half-precision floating-point conversion operations.
22428
22429@item +nofp
22430Disable the floating-point extension.
22431
22432@item +idiv
22433The ARM-state integer division instructions.
22434
22435@item +noidiv
22436Disable the ARM-state integer division extension.
22437@end table
22438
22439@item armv7e-m
22440@table @samp
22441@item +fp
22442The single-precision VFPv4 floating-point instructions.
22443
22444@item +fpv5
22445The single-precision FPv5 floating-point instructions.
22446
22447@item +fp.dp
22448The single- and double-precision FPv5 floating-point instructions.
22449
22450@item +nofp
22451Disable the floating-point extensions.
22452@end table
22453
22454@item armv8.1-m.main
22455@table @samp
22456
22457@item +dsp
22458The DSP instructions.
22459
22460@item +mve
22461The M-Profile Vector Extension (MVE) integer instructions.
22462
22463@item +mve.fp
22464The M-Profile Vector Extension (MVE) integer and single precision
22465floating-point instructions.
22466
22467@item +fp
22468The single-precision floating-point instructions.
22469
22470@item +fp.dp
22471The single- and double-precision floating-point instructions.
22472
22473@item +nofp
22474Disable the floating-point extension.
22475
22476@item +cdecp0, +cdecp1, ... , +cdecp7
22477Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22478to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22479
22480@item +pacbti
22481Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22482@end table
22483
22484@item armv8-m.main
22485@table @samp
22486@item +dsp
22487The DSP instructions.
22488
22489@item +nodsp
22490Disable the DSP extension.
22491
22492@item +fp
22493The single-precision floating-point instructions.
22494
22495@item +fp.dp
22496The single- and double-precision floating-point instructions.
22497
22498@item +nofp
22499Disable the floating-point extension.
22500
22501@item +cdecp0, +cdecp1, ... , +cdecp7
22502Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22503to the numbers given in the options in the range 0 to 7.
22504@end table
22505
22506@item armv8-r
22507@table @samp
22508@item +crc
22509The Cyclic Redundancy Check (CRC) instructions.
22510@item +fp.sp
22511The single-precision FPv5 floating-point instructions.
22512@item +simd
22513The ARMv8-A Advanced SIMD and floating-point instructions.
22514@item +crypto
22515The cryptographic instructions.
22516@item +nocrypto
22517Disable the cryptographic instructions.
22518@item +nofp
22519Disable the floating-point, Advanced SIMD and cryptographic instructions.
22520@end table
22521
22522@end table
22523
22524@option{-march=native} causes the compiler to auto-detect the architecture
22525of the build computer. At present, this feature is only supported on
22526GNU/Linux, and not all architectures are recognized. If the auto-detect
22527is unsuccessful the option has no effect.
22528
d77de738 22529@opindex mtune
ddf6fe37 22530@item -mtune=@var{name}
d77de738
ML
22531This option specifies the name of the target ARM processor for
22532which GCC should tune the performance of the code.
22533For some ARM implementations better performance can be obtained by using
22534this option.
22535Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22536@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22537@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22538@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22539@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22540@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22541@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22542@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22543@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22544@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22545@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22546@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22547@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22548@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22549@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22550@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22551@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22552@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22553@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22554@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22555@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22556@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22557@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22558@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22559@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22560@samp{xgene1}.
22561
22562Additionally, this option can specify that GCC should tune the performance
22563of the code for a big.LITTLE system. Permissible names are:
22564@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22565@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22566@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22567@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22568
22569@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22570performance for a blend of processors within architecture @var{arch}.
22571The aim is to generate code that run well on the current most popular
22572processors, balancing between optimizations that benefit some CPUs in the
22573range, and avoiding performance pitfalls of other CPUs. The effects of
22574this option may change in future GCC versions as CPU models come and go.
22575
22576@option{-mtune} permits the same extension options as @option{-mcpu}, but
22577the extension options do not affect the tuning of the generated code.
22578
22579@option{-mtune=native} causes the compiler to auto-detect the CPU
22580of the build computer. At present, this feature is only supported on
22581GNU/Linux, and not all architectures are recognized. If the auto-detect is
22582unsuccessful the option has no effect.
22583
d77de738 22584@opindex mcpu
ddf6fe37 22585@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22586This specifies the name of the target ARM processor. GCC uses this name
22587to derive the name of the target ARM architecture (as if specified
22588by @option{-march}) and the ARM processor type for which to tune for
22589performance (as if specified by @option{-mtune}). Where this option
22590is used in conjunction with @option{-march} or @option{-mtune},
22591those options take precedence over the appropriate part of this option.
22592
22593Many of the supported CPUs implement optional architectural
22594extensions. Where this is so the architectural extensions are
22595normally enabled by default. If implementations that lack the
22596extension exist, then the extension syntax can be used to disable
22597those extensions that have been omitted. For floating-point and
22598Advanced SIMD (Neon) instructions, the settings of the options
22599@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22600floating-point and Advanced SIMD instructions will only be used if
22601@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22602@option{-mfpu} other than @samp{auto} will override the available
22603floating-point and SIMD extension instructions.
22604
22605For example, @samp{cortex-a9} can be found in three major
22606configurations: integer only, with just a floating-point unit or with
22607floating-point and Advanced SIMD. The default is to enable all the
22608instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22609be used to disable just the SIMD or both the SIMD and floating-point
22610instructions respectively.
22611
22612Permissible names for this option are the same as those for
22613@option{-mtune}.
22614
22615The following extension options are common to the listed CPUs:
22616
22617@table @samp
22618@item +nodsp
ccfd1e7f
SP
22619Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22620@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22621Extension (MVE) integer and single precision floating-point instructions on
22622@samp{cortex-m55} and @samp{cortex-m85}.
22623
22624@item +nopacbti
22625Disable the Pointer Authentication and Branch Target Identification Extension
22626on @samp{cortex-m85}.
d77de738
ML
22627
22628@item +nomve
22629Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22630floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22631
22632@item +nomve.fp
22633Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22634instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22635
798a0d05
SP
22636@item +cdecp0, +cdecp1, ... , +cdecp7
22637Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22638to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22639
d77de738
ML
22640@item +nofp
22641Disables the floating-point instructions on @samp{arm9e},
22642@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22643@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22644@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22645@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22646@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22647@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22648Disables the floating-point and SIMD instructions on
22649@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22650@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22651@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22652@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22653@samp{cortex-a53} and @samp{cortex-a55}.
22654
22655@item +nofp.dp
22656Disables the double-precision component of the floating-point instructions
22657on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22658@samp{cortex-r52plus} and @samp{cortex-m7}.
22659
22660@item +nosimd
22661Disables the SIMD (but not floating-point) instructions on
22662@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22663and @samp{cortex-a9}.
22664
22665@item +crypto
22666Enables the cryptographic instructions on @samp{cortex-a32},
22667@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22668@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22669@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22670@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22671@samp{cortex-a75.cortex-a55}.
22672@end table
22673
22674Additionally the @samp{generic-armv7-a} pseudo target defaults to
22675VFPv3 with 16 double-precision registers. It supports the following
22676extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22677@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22678@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22679@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22680the extensions to @option{-march=armv7-a}.
22681
22682@option{-mcpu=generic-@var{arch}} is also permissible, and is
22683equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22684See @option{-mtune} for more information.
22685
22686@option{-mcpu=native} causes the compiler to auto-detect the CPU
22687of the build computer. At present, this feature is only supported on
22688GNU/Linux, and not all architectures are recognized. If the auto-detect
22689is unsuccessful the option has no effect.
22690
d77de738 22691@opindex mfpu
ddf6fe37 22692@item -mfpu=@var{name}
d77de738
ML
22693This specifies what floating-point hardware (or hardware emulation) is
22694available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22695@samp{vfpv3},
22696@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22697@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22698@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22699@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22700@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22701Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22702is an alias for @samp{vfpv2}.
22703
22704The setting @samp{auto} is the default and is special. It causes the
22705compiler to select the floating-point and Advanced SIMD instructions
22706based on the settings of @option{-mcpu} and @option{-march}.
22707
22708If the selected floating-point hardware includes the NEON extension
22709(e.g.@: @option{-mfpu=neon}), note that floating-point
22710operations are not generated by GCC's auto-vectorization pass unless
22711@option{-funsafe-math-optimizations} is also specified. This is
22712because NEON hardware does not fully implement the IEEE 754 standard for
22713floating-point arithmetic (in particular denormal values are treated as
22714zero), so the use of NEON instructions may lead to a loss of precision.
22715
22716You 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}).
22717
d77de738 22718@opindex mfp16-format
ddf6fe37 22719@item -mfp16-format=@var{name}
d77de738
ML
22720Specify the format of the @code{__fp16} half-precision floating-point type.
22721Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22722the default is @samp{none}, in which case the @code{__fp16} type is not
22723defined. @xref{Half-Precision}, for more information.
22724
d77de738 22725@opindex mstructure-size-boundary
ddf6fe37 22726@item -mstructure-size-boundary=@var{n}
d77de738
ML
22727The sizes of all structures and unions are rounded up to a multiple
22728of the number of bits set by this option. Permissible values are 8, 32
22729and 64. The default value varies for different toolchains. For the COFF
22730targeted toolchain the default value is 8. A value of 64 is only allowed
22731if the underlying ABI supports it.
22732
22733Specifying a larger number can produce faster, more efficient code, but
22734can also increase the size of the program. Different values are potentially
22735incompatible. Code compiled with one value cannot necessarily expect to
22736work with code or libraries compiled with another value, if they exchange
22737information using structures or unions.
22738
22739This option is deprecated.
22740
d77de738 22741@opindex mabort-on-noreturn
ddf6fe37 22742@item -mabort-on-noreturn
d77de738
ML
22743Generate a call to the function @code{abort} at the end of a
22744@code{noreturn} function. It is executed if the function tries to
22745return.
22746
d77de738
ML
22747@opindex mlong-calls
22748@opindex mno-long-calls
ddf6fe37
AA
22749@item -mlong-calls
22750@itemx -mno-long-calls
d77de738
ML
22751Tells the compiler to perform function calls by first loading the
22752address of the function into a register and then performing a subroutine
22753call on this register. This switch is needed if the target function
22754lies outside of the 64-megabyte addressing range of the offset-based
22755version of subroutine call instruction.
22756
22757Even if this switch is enabled, not all function calls are turned
22758into long calls. The heuristic is that static functions, functions
22759that have the @code{short_call} attribute, functions that are inside
22760the scope of a @code{#pragma no_long_calls} directive, and functions whose
22761definitions have already been compiled within the current compilation
22762unit are not turned into long calls. The exceptions to this rule are
22763that weak function definitions, functions with the @code{long_call}
22764attribute or the @code{section} attribute, and functions that are within
22765the scope of a @code{#pragma long_calls} directive are always
22766turned into long calls.
22767
22768This feature is not enabled by default. Specifying
22769@option{-mno-long-calls} restores the default behavior, as does
22770placing the function calls within the scope of a @code{#pragma
22771long_calls_off} directive. Note these switches have no effect on how
22772the compiler generates code to handle function calls via function
22773pointers.
22774
d77de738 22775@opindex msingle-pic-base
ddf6fe37 22776@item -msingle-pic-base
d77de738
ML
22777Treat the register used for PIC addressing as read-only, rather than
22778loading it in the prologue for each function. The runtime system is
22779responsible for initializing this register with an appropriate value
22780before execution begins.
22781
d77de738 22782@opindex mpic-register
ddf6fe37 22783@item -mpic-register=@var{reg}
d77de738
ML
22784Specify the register to be used for PIC addressing.
22785For standard PIC base case, the default is any suitable register
22786determined by compiler. For single PIC base case, the default is
22787@samp{R9} if target is EABI based or stack-checking is enabled,
22788otherwise the default is @samp{R10}.
22789
d77de738 22790@opindex mpic-data-is-text-relative
ddf6fe37 22791@item -mpic-data-is-text-relative
d77de738
ML
22792Assume that the displacement between the text and data segments is fixed
22793at static link time. This permits using PC-relative addressing
22794operations to access data known to be in the data segment. For
22795non-VxWorks RTP targets, this option is enabled by default. When
22796disabled on such targets, it will enable @option{-msingle-pic-base} by
22797default.
22798
d77de738 22799@opindex mpoke-function-name
ddf6fe37 22800@item -mpoke-function-name
d77de738
ML
22801Write the name of each function into the text section, directly
22802preceding the function prologue. The generated code is similar to this:
22803
22804@smallexample
22805 t0
22806 .ascii "arm_poke_function_name", 0
22807 .align
22808 t1
22809 .word 0xff000000 + (t1 - t0)
22810 arm_poke_function_name
22811 mov ip, sp
22812 stmfd sp!, @{fp, ip, lr, pc@}
22813 sub fp, ip, #4
22814@end smallexample
22815
22816When performing a stack backtrace, code can inspect the value of
22817@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22818location @code{pc - 12} and the top 8 bits are set, then we know that
22819there is a function name embedded immediately preceding this location
22820and has length @code{((pc[-3]) & 0xff000000)}.
22821
d77de738
ML
22822@opindex marm
22823@opindex mthumb
ddf6fe37
AA
22824@item -mthumb
22825@itemx -marm
d77de738
ML
22826
22827Select between generating code that executes in ARM and Thumb
22828states. The default for most configurations is to generate code
22829that executes in ARM state, but the default can be changed by
22830configuring GCC with the @option{--with-mode=}@var{state}
22831configure option.
22832
22833You can also override the ARM and Thumb mode for each function
22834by using the @code{target("thumb")} and @code{target("arm")} function attributes
22835(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22836
d77de738 22837@opindex mflip-thumb
ddf6fe37 22838@item -mflip-thumb
d77de738
ML
22839Switch ARM/Thumb modes on alternating functions.
22840This option is provided for regression testing of mixed Thumb/ARM code
22841generation, and is not intended for ordinary use in compiling code.
22842
d77de738 22843@opindex mtpcs-frame
ddf6fe37 22844@item -mtpcs-frame
d77de738
ML
22845Generate a stack frame that is compliant with the Thumb Procedure Call
22846Standard for all non-leaf functions. (A leaf function is one that does
22847not call any other functions.) The default is @option{-mno-tpcs-frame}.
22848
d77de738 22849@opindex mtpcs-leaf-frame
ddf6fe37 22850@item -mtpcs-leaf-frame
d77de738
ML
22851Generate a stack frame that is compliant with the Thumb Procedure Call
22852Standard for all leaf functions. (A leaf function is one that does
22853not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22854
d77de738 22855@opindex mcallee-super-interworking
ddf6fe37 22856@item -mcallee-super-interworking
d77de738
ML
22857Gives all externally visible functions in the file being compiled an ARM
22858instruction set header which switches to Thumb mode before executing the
22859rest of the function. This allows these functions to be called from
22860non-interworking code. This option is not valid in AAPCS configurations
22861because interworking is enabled by default.
22862
d77de738 22863@opindex mcaller-super-interworking
ddf6fe37 22864@item -mcaller-super-interworking
d77de738
ML
22865Allows calls via function pointers (including virtual functions) to
22866execute correctly regardless of whether the target code has been
22867compiled for interworking or not. There is a small overhead in the cost
22868of executing a function pointer if this option is enabled. This option
22869is not valid in AAPCS configurations because interworking is enabled
22870by default.
22871
d77de738 22872@opindex mtp
ddf6fe37 22873@item -mtp=@var{name}
cca8d9e5
KT
22874Specify the access model for the thread local storage pointer. The model
22875@samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
22876models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
22877the thread pointer from the corresponding system register directly
22878(supported from the arm6k architecture and later). These system registers
22879are accessed through the CP15 co-processor interface and the argument
22880@samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
22881The argument @samp{auto} uses the best available method for the selected
22882processor. The default setting is @samp{auto}.
d77de738 22883
d77de738 22884@opindex mtls-dialect
ddf6fe37 22885@item -mtls-dialect=@var{dialect}
d77de738
ML
22886Specify the dialect to use for accessing thread local storage. Two
22887@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22888@samp{gnu} dialect selects the original GNU scheme for supporting
22889local and global dynamic TLS models. The @samp{gnu2} dialect
22890selects the GNU descriptor scheme, which provides better performance
22891for shared libraries. The GNU descriptor scheme is compatible with
22892the original scheme, but does require new assembler, linker and
22893library support. Initial and local exec TLS models are unaffected by
22894this option and always use the original scheme.
22895
d77de738 22896@opindex mword-relocations
ddf6fe37 22897@item -mword-relocations
d77de738
ML
22898Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22899This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22900loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22901is specified. This option conflicts with @option{-mslow-flash-data}.
22902
d77de738 22903@opindex mfix-cortex-m3-ldrd
ddf6fe37 22904@item -mfix-cortex-m3-ldrd
d77de738
ML
22905Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22906with overlapping destination and base registers are used. This option avoids
22907generating these instructions. This option is enabled by default when
22908@option{-mcpu=cortex-m3} is specified.
22909
22910@item -mfix-cortex-a57-aes-1742098
22911@itemx -mno-fix-cortex-a57-aes-1742098
22912@itemx -mfix-cortex-a72-aes-1655431
22913@itemx -mno-fix-cortex-a72-aes-1655431
22914Enable (disable) mitigation for an erratum on Cortex-A57 and
22915Cortex-A72 that affects the AES cryptographic instructions. This
22916option is enabled by default when either @option{-mcpu=cortex-a57} or
22917@option{-mcpu=cortex-a72} is specified.
22918
d77de738
ML
22919@opindex munaligned-access
22920@opindex mno-unaligned-access
ddf6fe37
AA
22921@item -munaligned-access
22922@itemx -mno-unaligned-access
d77de738
ML
22923Enables (or disables) reading and writing of 16- and 32- bit values
22924from addresses that are not 16- or 32- bit aligned. By default
22925unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22926ARMv8-M Baseline architectures, and enabled for all other
22927architectures. If unaligned access is not enabled then words in packed
22928data structures are accessed a byte at a time.
22929
22930The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22931generated object file to either true or false, depending upon the
22932setting of this option. If unaligned access is enabled then the
22933preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22934defined.
22935
d77de738 22936@opindex mneon-for-64bits
ddf6fe37 22937@item -mneon-for-64bits
d77de738
ML
22938This option is deprecated and has no effect.
22939
d77de738 22940@opindex mslow-flash-data
ddf6fe37 22941@item -mslow-flash-data
d77de738
ML
22942Assume loading data from flash is slower than fetching instruction.
22943Therefore literal load is minimized for better performance.
22944This option is only supported when compiling for ARMv7 M-profile and
22945off by default. It conflicts with @option{-mword-relocations}.
22946
d77de738 22947@opindex masm-syntax-unified
ddf6fe37 22948@item -masm-syntax-unified
d77de738
ML
22949Assume inline assembler is using unified asm syntax. The default is
22950currently off which implies divided syntax. This option has no impact
22951on Thumb2. However, this may change in future releases of GCC.
22952Divided syntax should be considered deprecated.
22953
d77de738 22954@opindex mrestrict-it
ddf6fe37 22955@item -mrestrict-it
d77de738
ML
22956Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22957IT blocks can only contain a single 16-bit instruction from a select
22958set of instructions. This option is on by default for ARMv8-A Thumb mode.
22959
d77de738 22960@opindex mprint-tune-info
ddf6fe37 22961@item -mprint-tune-info
d77de738
ML
22962Print CPU tuning information as comment in assembler file. This is
22963an option used only for regression testing of the compiler and not
22964intended for ordinary use in compiling code. This option is disabled
22965by default.
22966
d77de738 22967@opindex mverbose-cost-dump
ddf6fe37 22968@item -mverbose-cost-dump
d77de738
ML
22969Enable verbose cost model dumping in the debug dump files. This option is
22970provided for use in debugging the compiler.
22971
d77de738 22972@opindex mpure-code
ddf6fe37 22973@item -mpure-code
d77de738
ML
22974Do not allow constant data to be placed in code sections.
22975Additionally, when compiling for ELF object format give all text sections the
22976ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22977is only available when generating non-pic code for M-profile targets.
22978
d77de738 22979@opindex mcmse
ddf6fe37 22980@item -mcmse
d77de738
ML
22981Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22982Development Tools Engineering Specification", which can be found on
22983@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22984
d77de738 22985@opindex mfix-cmse-cve-2021-35465
ddf6fe37 22986@item -mfix-cmse-cve-2021-35465
d77de738
ML
22987Mitigate against a potential security issue with the @code{VLLDM} instruction
22988in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22989enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
22990@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22991or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22992to disable the mitigation.
d77de738 22993
d77de738
ML
22994@opindex mstack-protector-guard
22995@opindex mstack-protector-guard-offset
ddf6fe37
AA
22996@item -mstack-protector-guard=@var{guard}
22997@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
22998Generate stack protection code using canary at @var{guard}. Supported
22999locations are @samp{global} for a global canary or @samp{tls} for a
23000canary accessible via the TLS register. The option
23001@option{-mstack-protector-guard-offset=} is for use with
23002@option{-fstack-protector-guard=tls} and not for use in user-land code.
23003
d77de738
ML
23004@opindex mfdpic
23005@opindex mno-fdpic
ddf6fe37
AA
23006@item -mfdpic
23007@itemx -mno-fdpic
d77de738
ML
23008Select the FDPIC ABI, which uses 64-bit function descriptors to
23009represent pointers to functions. When the compiler is configured for
23010@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
23011and implies @option{-fPIE} if none of the PIC/PIE-related options is
23012provided. On other targets, it only enables the FDPIC-specific code
23013generation features, and the user should explicitly provide the
23014PIC/PIE-related options as needed.
23015
23016Note that static linking is not supported because it would still
23017involve the dynamic linker when the program self-relocates. If such
23018behavior is acceptable, use -static and -Wl,-dynamic-linker options.
23019
23020The opposite @option{-mno-fdpic} option is useful (and required) to
23021build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
23022toolchain as the one used to build the userland programs.
23023
14fab5fb 23024@opindex mbranch-protection
ddf6fe37 23025@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
23026Enable branch protection features (armv8.1-m.main only).
23027@samp{none} generate code without branch protection or return address
23028signing.
23029@samp{standard[+@var{leaf}]} generate code with all branch protection
23030features enabled at their standard level.
23031@samp{pac-ret[+@var{leaf}]} generate code with return address signing
23032set to its standard level, which is to sign all functions that save
23033the return address to memory.
23034@samp{leaf} When return address signing is enabled, also sign leaf
23035functions even if they do not write the return address to memory.
23036+@samp{bti} Add landing-pad instructions at the permitted targets of
23037indirect branch instructions.
23038
23039If the @samp{+pacbti} architecture extension is not enabled, then all
23040branch protection and return address signing operations are
23041constrained to use only the instructions defined in the
23042architectural-NOP space. The generated code will remain
23043backwards-compatible with earlier versions of the architecture, but
23044the additional security can be enabled at run time on processors that
23045support the @samp{PACBTI} extension.
23046
23047Branch target enforcement using BTI can only be enabled at runtime if
23048all code in the application has been compiled with at least
23049@samp{-mbranch-protection=bti}.
23050
23051Any setting other than @samp{none} is supported only on armv8-m.main
23052or later.
23053
23054The default is to generate code without branch protection or return
23055address signing.
23056
d77de738
ML
23057@end table
23058
23059@node AVR Options
23060@subsection AVR Options
23061@cindex AVR Options
23062
23063These options are defined for AVR implementations:
23064
23065@table @gcctabopt
d77de738 23066@opindex mmcu
ddf6fe37 23067@item -mmcu=@var{mcu}
d77de738
ML
23068Specify Atmel AVR instruction set architectures (ISA) or MCU type.
23069
23070The default for this option is@tie{}@samp{avr2}.
23071
23072GCC supports the following AVR devices and ISAs:
23073
23074@include avr-mmcu.texi
23075
d77de738 23076@opindex mabsdata
ddf6fe37 23077@item -mabsdata
d77de738
ML
23078
23079Assume that all data in static storage can be accessed by LDS / STS
23080instructions. This option has only an effect on reduced Tiny devices like
23081ATtiny40. See also the @code{absdata}
23082@ref{AVR Variable Attributes,variable attribute}.
23083
d77de738 23084@opindex maccumulate-args
ddf6fe37 23085@item -maccumulate-args
d77de738
ML
23086Accumulate outgoing function arguments and acquire/release the needed
23087stack space for outgoing function arguments once in function
23088prologue/epilogue. Without this option, outgoing arguments are pushed
23089before calling a function and popped afterwards.
23090
23091Popping the arguments after the function call can be expensive on
23092AVR so that accumulating the stack space might lead to smaller
23093executables because arguments need not be removed from the
23094stack after such a function call.
23095
23096This option can lead to reduced code size for functions that perform
23097several calls to functions that get their arguments on the stack like
23098calls to printf-like functions.
23099
d77de738 23100@opindex mbranch-cost
ddf6fe37 23101@item -mbranch-cost=@var{cost}
d77de738
ML
23102Set the branch costs for conditional branch instructions to
23103@var{cost}. Reasonable values for @var{cost} are small, non-negative
23104integers. The default branch cost is 0.
23105
d77de738 23106@opindex mcall-prologues
ddf6fe37 23107@item -mcall-prologues
d77de738
ML
23108Functions prologues/epilogues are expanded as calls to appropriate
23109subroutines. Code size is smaller.
23110
d77de738
ML
23111@opindex mdouble
23112@opindex mlong-double
ddf6fe37
AA
23113@item -mdouble=@var{bits}
23114@itemx -mlong-double=@var{bits}
d77de738
ML
23115Set the size (in bits) of the @code{double} or @code{long double} type,
23116respectively. Possible values for @var{bits} are 32 and 64.
23117Whether or not a specific value for @var{bits} is allowed depends on
23118the @code{--with-double=} and @code{--with-long-double=}
23119@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
23120and the same applies for the default values of the options.
23121
d77de738 23122@opindex mgas-isr-prologues
ddf6fe37 23123@item -mgas-isr-prologues
d77de738
ML
23124Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
23125instruction supported by GNU Binutils.
23126If this option is on, the feature can still be disabled for individual
23127ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
23128function attribute. This feature is activated per default
23129if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
23130and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
23131
d77de738 23132@opindex mint8
ddf6fe37 23133@item -mint8
d77de738
ML
23134Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
23135@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
23136and @code{long long} is 4 bytes. Please note that this option does not
23137conform to the C standards, but it results in smaller code
23138size.
23139
d77de738 23140@opindex mmain-is-OS_task
ddf6fe37 23141@item -mmain-is-OS_task
d77de738
ML
23142Do not save registers in @code{main}. The effect is the same like
23143attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
23144to @code{main}. It is activated per default if optimization is on.
23145
d77de738 23146@opindex mn-flash
ddf6fe37 23147@item -mn-flash=@var{num}
d77de738
ML
23148Assume that the flash memory has a size of
23149@var{num} times 64@tie{}KiB.
23150
d77de738 23151@opindex mno-interrupts
ddf6fe37 23152@item -mno-interrupts
d77de738
ML
23153Generated code is not compatible with hardware interrupts.
23154Code size is smaller.
23155
d77de738 23156@opindex mrelax
ddf6fe37 23157@item -mrelax
d77de738
ML
23158Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
23159@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
23160Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
23161the assembler's command line and the @option{--relax} option to the
23162linker's command line.
23163
23164Jump relaxing is performed by the linker because jump offsets are not
23165known before code is located. Therefore, the assembler code generated by the
23166compiler is the same, but the instructions in the executable may
23167differ from instructions in the assembler code.
23168
23169Relaxing must be turned on if linker stubs are needed, see the
23170section on @code{EIND} and linker stubs below.
23171
d77de738 23172@opindex mrmw
ddf6fe37 23173@item -mrmw
d77de738
ML
23174Assume that the device supports the Read-Modify-Write
23175instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
23176
d77de738 23177@opindex mshort-calls
ddf6fe37 23178@item -mshort-calls
d77de738
ML
23179
23180Assume that @code{RJMP} and @code{RCALL} can target the whole
23181program memory.
23182
23183This option is used internally for multilib selection. It is
23184not an optimization option, and you don't need to set it by hand.
23185
d77de738 23186@opindex msp8
ddf6fe37 23187@item -msp8
d77de738
ML
23188Treat the stack pointer register as an 8-bit register,
23189i.e.@: assume the high byte of the stack pointer is zero.
23190In general, you don't need to set this option by hand.
23191
23192This option is used internally by the compiler to select and
23193build multilibs for architectures @code{avr2} and @code{avr25}.
23194These architectures mix devices with and without @code{SPH}.
23195For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
23196the compiler driver adds or removes this option from the compiler
23197proper's command line, because the compiler then knows if the device
23198or architecture has an 8-bit stack pointer and thus no @code{SPH}
23199register or not.
23200
d77de738 23201@opindex mstrict-X
ddf6fe37 23202@item -mstrict-X
d77de738
ML
23203Use address register @code{X} in a way proposed by the hardware. This means
23204that @code{X} is only used in indirect, post-increment or
23205pre-decrement addressing.
23206
23207Without this option, the @code{X} register may be used in the same way
23208as @code{Y} or @code{Z} which then is emulated by additional
23209instructions.
23210For example, loading a value with @code{X+const} addressing with a
23211small non-negative @code{const < 64} to a register @var{Rn} is
23212performed as
23213
23214@example
23215adiw r26, const ; X += const
23216ld @var{Rn}, X ; @var{Rn} = *X
23217sbiw r26, const ; X -= const
23218@end example
23219
d77de738 23220@opindex mtiny-stack
ddf6fe37 23221@item -mtiny-stack
d77de738
ML
23222Only change the lower 8@tie{}bits of the stack pointer.
23223
d77de738 23224@opindex mfract-convert-truncate
ddf6fe37 23225@item -mfract-convert-truncate
d77de738
ML
23226Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
23227
d77de738 23228@opindex nodevicelib
ddf6fe37 23229@item -nodevicelib
d77de738
ML
23230Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23231
d77de738 23232@opindex nodevicespecs
ddf6fe37 23233@item -nodevicespecs
d77de738
ML
23234Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23235command line. The user takes responsibility for supplying the sub-processes
23236like compiler proper, assembler and linker with appropriate command line
23237options. This means that the user has to supply her private device specs
23238file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23239more need for option @option{-mmcu=@var{mcu}}.
23240
23241This option can also serve as a replacement for the older way of
23242specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23243which contains a folder named @code{device-specs} which contains a specs file named
23244@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23245
d77de738
ML
23246@opindex Waddr-space-convert
23247@opindex Wno-addr-space-convert
ddf6fe37 23248@item -Waddr-space-convert
d77de738
ML
23249Warn about conversions between address spaces in the case where the
23250resulting address space is not contained in the incoming address space.
23251
d77de738
ML
23252@opindex Wmisspelled-isr
23253@opindex Wno-misspelled-isr
ddf6fe37 23254@item -Wmisspelled-isr
d77de738
ML
23255Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23256Enabled by default.
23257@end table
23258
23259@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23260@cindex @code{EIND}
23261Pointers in the implementation are 16@tie{}bits wide.
23262The address of a function or label is represented as word address so
23263that indirect jumps and calls can target any code address in the
23264range of 64@tie{}Ki words.
23265
23266In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23267bytes of program memory space, there is a special function register called
23268@code{EIND} that serves as most significant part of the target address
23269when @code{EICALL} or @code{EIJMP} instructions are used.
23270
23271Indirect jumps and calls on these devices are handled as follows by
23272the compiler and are subject to some limitations:
23273
23274@itemize @bullet
23275
23276@item
23277The compiler never sets @code{EIND}.
23278
23279@item
23280The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23281instructions or might read @code{EIND} directly in order to emulate an
23282indirect call/jump by means of a @code{RET} instruction.
23283
23284@item
23285The compiler assumes that @code{EIND} never changes during the startup
23286code or during the application. In particular, @code{EIND} is not
23287saved/restored in function or interrupt service routine
23288prologue/epilogue.
23289
23290@item
23291For indirect calls to functions and computed goto, the linker
23292generates @emph{stubs}. Stubs are jump pads sometimes also called
23293@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23294The stub contains a direct jump to the desired address.
23295
23296@item
23297Linker relaxation must be turned on so that the linker generates
23298the stubs correctly in all situations. See the compiler option
23299@option{-mrelax} and the linker option @option{--relax}.
23300There are corner cases where the linker is supposed to generate stubs
23301but aborts without relaxation and without a helpful error message.
23302
23303@item
23304The default linker script is arranged for code with @code{EIND = 0}.
23305If code is supposed to work for a setup with @code{EIND != 0}, a custom
23306linker script has to be used in order to place the sections whose
23307name start with @code{.trampolines} into the segment where @code{EIND}
23308points to.
23309
23310@item
23311The startup code from libgcc never sets @code{EIND}.
23312Notice that startup code is a blend of code from libgcc and AVR-LibC.
23313For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23314@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23315
23316@item
23317It is legitimate for user-specific startup code to set up @code{EIND}
23318early, for example by means of initialization code located in
23319section @code{.init3}. Such code runs prior to general startup code
23320that initializes RAM and calls constructors, but after the bit
23321of startup code from AVR-LibC that sets @code{EIND} to the segment
23322where the vector table is located.
23323@example
23324#include <avr/io.h>
23325
23326static void
23327__attribute__((section(".init3"),naked,used,no_instrument_function))
23328init3_set_eind (void)
23329@{
23330 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
23331 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
23332@}
23333@end example
23334
23335@noindent
23336The @code{__trampolines_start} symbol is defined in the linker script.
23337
23338@item
23339Stubs are generated automatically by the linker if
23340the following two conditions are met:
23341@itemize @minus
23342
23343@item The address of a label is taken by means of the @code{gs} modifier
23344(short for @emph{generate stubs}) like so:
23345@example
23346LDI r24, lo8(gs(@var{func}))
23347LDI r25, hi8(gs(@var{func}))
23348@end example
23349@item The final location of that label is in a code segment
23350@emph{outside} the segment where the stubs are located.
23351@end itemize
23352
23353@item
23354The compiler emits such @code{gs} modifiers for code labels in the
23355following situations:
23356@itemize @minus
23357@item Taking address of a function or code label.
23358@item Computed goto.
23359@item If prologue-save function is used, see @option{-mcall-prologues}
23360command-line option.
23361@item Switch/case dispatch tables. If you do not want such dispatch
23362tables you can specify the @option{-fno-jump-tables} command-line option.
23363@item C and C++ constructors/destructors called during startup/shutdown.
23364@item If the tools hit a @code{gs()} modifier explained above.
23365@end itemize
23366
23367@item
23368Jumping to non-symbolic addresses like so is @emph{not} supported:
23369
23370@example
23371int main (void)
23372@{
23373 /* Call function at word address 0x2 */
23374 return ((int(*)(void)) 0x2)();
23375@}
23376@end example
23377
23378Instead, a stub has to be set up, i.e.@: the function has to be called
23379through a symbol (@code{func_4} in the example):
23380
23381@example
23382int main (void)
23383@{
23384 extern int func_4 (void);
23385
23386 /* Call function at byte address 0x4 */
23387 return func_4();
23388@}
23389@end example
23390
23391and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23392Alternatively, @code{func_4} can be defined in the linker script.
23393@end itemize
23394
23395@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23396@cindex @code{RAMPD}
23397@cindex @code{RAMPX}
23398@cindex @code{RAMPY}
23399@cindex @code{RAMPZ}
23400Some AVR devices support memories larger than the 64@tie{}KiB range
23401that can be accessed with 16-bit pointers. To access memory locations
23402outside this 64@tie{}KiB range, the content of a @code{RAMP}
23403register is used as high part of the address:
23404The @code{X}, @code{Y}, @code{Z} address register is concatenated
23405with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23406register, respectively, to get a wide address. Similarly,
23407@code{RAMPD} is used together with direct addressing.
23408
23409@itemize
23410@item
23411The startup code initializes the @code{RAMP} special function
23412registers with zero.
23413
23414@item
23415If a @ref{AVR Named Address Spaces,named address space} other than
23416generic or @code{__flash} is used, then @code{RAMPZ} is set
23417as needed before the operation.
23418
23419@item
23420If the device supports RAM larger than 64@tie{}KiB and the compiler
23421needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23422is reset to zero after the operation.
23423
23424@item
23425If the device comes with a specific @code{RAMP} register, the ISR
23426prologue/epilogue saves/restores that SFR and initializes it with
23427zero in case the ISR code might (implicitly) use it.
23428
23429@item
23430RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23431If you use inline assembler to read from locations outside the
2343216-bit address range and change one of the @code{RAMP} registers,
23433you must reset it to zero after the access.
23434
23435@end itemize
23436
23437@subsubsection AVR Built-in Macros
23438
23439GCC defines several built-in macros so that the user code can test
23440for the presence or absence of features. Almost any of the following
23441built-in macros are deduced from device capabilities and thus
23442triggered by the @option{-mmcu=} command-line option.
23443
23444For even more AVR-specific built-in macros see
23445@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23446
23447@table @code
23448
23449@item __AVR_ARCH__
23450Build-in macro that resolves to a decimal number that identifies the
23451architecture and depends on the @option{-mmcu=@var{mcu}} option.
23452Possible values are:
23453
23454@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23455@code{4}, @code{5}, @code{51}, @code{6}
23456
23457for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23458@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23459
23460respectively and
23461
23462@code{100},
23463@code{102}, @code{103}, @code{104},
23464@code{105}, @code{106}, @code{107}
23465
23466for @var{mcu}=@code{avrtiny},
23467@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23468@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23469If @var{mcu} specifies a device, this built-in macro is set
23470accordingly. For example, with @option{-mmcu=atmega8} the macro is
23471defined to @code{4}.
23472
23473@item __AVR_@var{Device}__
23474Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23475the device's name. For example, @option{-mmcu=atmega8} defines the
23476built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23477@code{__AVR_ATtiny261A__}, etc.
23478
23479The built-in macros' names follow
23480the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23481the device name as from the AVR user manual. The difference between
23482@var{Device} in the built-in macro and @var{device} in
23483@option{-mmcu=@var{device}} is that the latter is always lowercase.
23484
23485If @var{device} is not a device but only a core architecture like
23486@samp{avr51}, this macro is not defined.
23487
23488@item __AVR_DEVICE_NAME__
23489Setting @option{-mmcu=@var{device}} defines this built-in macro to
23490the device's name. For example, with @option{-mmcu=atmega8} the macro
23491is defined to @code{atmega8}.
23492
23493If @var{device} is not a device but only a core architecture like
23494@samp{avr51}, this macro is not defined.
23495
23496@item __AVR_XMEGA__
23497The device / architecture belongs to the XMEGA family of devices.
23498
23499@item __AVR_HAVE_ELPM__
23500The device has the @code{ELPM} instruction.
23501
23502@item __AVR_HAVE_ELPMX__
23503The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23504R@var{n},Z+} instructions.
23505
23506@item __AVR_HAVE_MOVW__
23507The device has the @code{MOVW} instruction to perform 16-bit
23508register-register moves.
23509
23510@item __AVR_HAVE_LPMX__
23511The device has the @code{LPM R@var{n},Z} and
23512@code{LPM R@var{n},Z+} instructions.
23513
23514@item __AVR_HAVE_MUL__
23515The device has a hardware multiplier.
23516
23517@item __AVR_HAVE_JMP_CALL__
23518The device has the @code{JMP} and @code{CALL} instructions.
23519This is the case for devices with more than 8@tie{}KiB of program
23520memory.
23521
23522@item __AVR_HAVE_EIJMP_EICALL__
23523@itemx __AVR_3_BYTE_PC__
23524The device has the @code{EIJMP} and @code{EICALL} instructions.
23525This is the case for devices with more than 128@tie{}KiB of program memory.
23526This also means that the program counter
23527(PC) is 3@tie{}bytes wide.
23528
23529@item __AVR_2_BYTE_PC__
23530The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23531with up to 128@tie{}KiB of program memory.
23532
23533@item __AVR_HAVE_8BIT_SP__
23534@itemx __AVR_HAVE_16BIT_SP__
23535The stack pointer (SP) register is treated as 8-bit respectively
2353616-bit register by the compiler.
23537The definition of these macros is affected by @option{-mtiny-stack}.
23538
23539@item __AVR_HAVE_SPH__
23540@itemx __AVR_SP8__
23541The device has the SPH (high part of stack pointer) special function
23542register or has an 8-bit stack pointer, respectively.
23543The definition of these macros is affected by @option{-mmcu=} and
23544in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23545by @option{-msp8}.
23546
23547@item __AVR_HAVE_RAMPD__
23548@itemx __AVR_HAVE_RAMPX__
23549@itemx __AVR_HAVE_RAMPY__
23550@itemx __AVR_HAVE_RAMPZ__
23551The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23552@code{RAMPZ} special function register, respectively.
23553
23554@item __NO_INTERRUPTS__
23555This macro reflects the @option{-mno-interrupts} command-line option.
23556
23557@item __AVR_ERRATA_SKIP__
23558@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23559Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23560instructions because of a hardware erratum. Skip instructions are
23561@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23562The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23563set.
23564
23565@item __AVR_ISA_RMW__
23566The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23567
23568@item __AVR_SFR_OFFSET__=@var{offset}
23569Instructions that can address I/O special function registers directly
23570like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23571address as if addressed by an instruction to access RAM like @code{LD}
23572or @code{STS}. This offset depends on the device architecture and has
23573to be subtracted from the RAM address in order to get the
23574respective I/O@tie{}address.
23575
23576@item __AVR_SHORT_CALLS__
23577The @option{-mshort-calls} command line option is set.
23578
23579@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23580Some devices support reading from flash memory by means of @code{LD*}
23581instructions. The flash memory is seen in the data address space
23582at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23583is not defined, this feature is not available. If defined,
23584the address space is linear and there is no need to put
23585@code{.rodata} into RAM. This is handled by the default linker
23586description file, and is currently available for
23587@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23588there is no need to use address spaces like @code{__flash} or
23589features like attribute @code{progmem} and @code{pgm_read_*}.
23590
23591@item __WITH_AVRLIBC__
23592The compiler is configured to be used together with AVR-Libc.
23593See the @option{--with-avrlibc} configure option.
23594
23595@item __HAVE_DOUBLE_MULTILIB__
23596Defined if @option{-mdouble=} acts as a multilib option.
23597
23598@item __HAVE_DOUBLE32__
23599@itemx __HAVE_DOUBLE64__
23600Defined if the compiler supports 32-bit double resp. 64-bit double.
23601The actual layout is specified by option @option{-mdouble=}.
23602
23603@item __DEFAULT_DOUBLE__
23604The size in bits of @code{double} if @option{-mdouble=} is not set.
23605To test the layout of @code{double} in a program, use the built-in
23606macro @code{__SIZEOF_DOUBLE__}.
23607
23608@item __HAVE_LONG_DOUBLE32__
23609@itemx __HAVE_LONG_DOUBLE64__
23610@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23611@itemx __DEFAULT_LONG_DOUBLE__
23612Same as above, but for @code{long double} instead of @code{double}.
23613
23614@item __WITH_DOUBLE_COMPARISON__
23615Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23616@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23617and is defined to @code{2} or @code{3}.
23618
23619@item __WITH_LIBF7_LIBGCC__
23620@itemx __WITH_LIBF7_MATH__
23621@itemx __WITH_LIBF7_MATH_SYMBOLS__
23622Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23623@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23624
23625@end table
23626
23627@node Blackfin Options
23628@subsection Blackfin Options
23629@cindex Blackfin Options
23630
23631@table @gcctabopt
d77de738 23632@opindex mcpu=
ddf6fe37 23633@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23634Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23635can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23636@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23637@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23638@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23639@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23640@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23641@samp{bf561}, @samp{bf592}.
23642
23643The optional @var{sirevision} specifies the silicon revision of the target
23644Blackfin processor. Any workarounds available for the targeted silicon revision
23645are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23646If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23647are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23648hexadecimal digits representing the major and minor numbers in the silicon
23649revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23650is not defined. If @var{sirevision} is @samp{any}, the
23651@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23652If this optional @var{sirevision} is not used, GCC assumes the latest known
23653silicon revision of the targeted Blackfin processor.
23654
23655GCC defines a preprocessor macro for the specified @var{cpu}.
23656For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23657provided by libgloss to be linked in if @option{-msim} is not given.
23658
23659Without this option, @samp{bf532} is used as the processor by default.
23660
23661Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23662only the preprocessor macro is defined.
23663
d77de738 23664@opindex msim
ddf6fe37 23665@item -msim
d77de738
ML
23666Specifies that the program will be run on the simulator. This causes
23667the simulator BSP provided by libgloss to be linked in. This option
23668has effect only for @samp{bfin-elf} toolchain.
23669Certain other options, such as @option{-mid-shared-library} and
23670@option{-mfdpic}, imply @option{-msim}.
23671
d77de738 23672@opindex momit-leaf-frame-pointer
ddf6fe37 23673@item -momit-leaf-frame-pointer
d77de738
ML
23674Don't keep the frame pointer in a register for leaf functions. This
23675avoids the instructions to save, set up and restore frame pointers and
23676makes an extra register available in leaf functions.
23677
d77de738 23678@opindex mspecld-anomaly
ddf6fe37 23679@item -mspecld-anomaly
d77de738
ML
23680When enabled, the compiler ensures that the generated code does not
23681contain speculative loads after jump instructions. If this option is used,
23682@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23683
d77de738
ML
23684@opindex mno-specld-anomaly
23685@opindex mspecld-anomaly
ddf6fe37 23686@item -mno-specld-anomaly
d77de738
ML
23687Don't generate extra code to prevent speculative loads from occurring.
23688
d77de738 23689@opindex mcsync-anomaly
ddf6fe37 23690@item -mcsync-anomaly
d77de738
ML
23691When enabled, the compiler ensures that the generated code does not
23692contain CSYNC or SSYNC instructions too soon after conditional branches.
23693If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23694
d77de738
ML
23695@opindex mno-csync-anomaly
23696@opindex mcsync-anomaly
ddf6fe37 23697@item -mno-csync-anomaly
d77de738
ML
23698Don't generate extra code to prevent CSYNC or SSYNC instructions from
23699occurring too soon after a conditional branch.
23700
d77de738 23701@opindex mlow64k
ddf6fe37 23702@item -mlow64k
d77de738
ML
23703When enabled, the compiler is free to take advantage of the knowledge that
23704the entire program fits into the low 64k of memory.
23705
d77de738 23706@opindex mno-low64k
ddf6fe37 23707@item -mno-low64k
d77de738
ML
23708Assume that the program is arbitrarily large. This is the default.
23709
d77de738 23710@opindex mstack-check-l1
ddf6fe37 23711@item -mstack-check-l1
d77de738
ML
23712Do stack checking using information placed into L1 scratchpad memory by the
23713uClinux kernel.
23714
d77de738 23715@opindex mid-shared-library
ddf6fe37 23716@item -mid-shared-library
d77de738
ML
23717Generate code that supports shared libraries via the library ID method.
23718This allows for execute in place and shared libraries in an environment
23719without virtual memory management. This option implies @option{-fPIC}.
23720With a @samp{bfin-elf} target, this option implies @option{-msim}.
23721
d77de738
ML
23722@opindex mno-id-shared-library
23723@opindex mid-shared-library
ddf6fe37 23724@item -mno-id-shared-library
d77de738
ML
23725Generate code that doesn't assume ID-based shared libraries are being used.
23726This is the default.
23727
d77de738 23728@opindex mleaf-id-shared-library
ddf6fe37 23729@item -mleaf-id-shared-library
d77de738
ML
23730Generate code that supports shared libraries via the library ID method,
23731but assumes that this library or executable won't link against any other
23732ID shared libraries. That allows the compiler to use faster code for jumps
23733and calls.
23734
d77de738
ML
23735@opindex mno-leaf-id-shared-library
23736@opindex mleaf-id-shared-library
ddf6fe37 23737@item -mno-leaf-id-shared-library
d77de738
ML
23738Do not assume that the code being compiled won't link against any ID shared
23739libraries. Slower code is generated for jump and call insns.
23740
d77de738 23741@opindex mshared-library-id
ddf6fe37 23742@item -mshared-library-id=n
d77de738
ML
23743Specifies the identification number of the ID-based shared library being
23744compiled. Specifying a value of 0 generates more compact code; specifying
23745other values forces the allocation of that number to the current
23746library but is no more space- or time-efficient than omitting this option.
23747
d77de738 23748@opindex msep-data
ddf6fe37 23749@item -msep-data
d77de738
ML
23750Generate code that allows the data segment to be located in a different
23751area of memory from the text segment. This allows for execute in place in
23752an environment without virtual memory management by eliminating relocations
23753against the text section.
23754
d77de738
ML
23755@opindex mno-sep-data
23756@opindex msep-data
ddf6fe37 23757@item -mno-sep-data
d77de738
ML
23758Generate code that assumes that the data segment follows the text segment.
23759This is the default.
23760
d77de738
ML
23761@opindex mlong-calls
23762@opindex mno-long-calls
ddf6fe37
AA
23763@item -mlong-calls
23764@itemx -mno-long-calls
d77de738
ML
23765Tells the compiler to perform function calls by first loading the
23766address of the function into a register and then performing a subroutine
23767call on this register. This switch is needed if the target function
23768lies outside of the 24-bit addressing range of the offset-based
23769version of subroutine call instruction.
23770
23771This feature is not enabled by default. Specifying
23772@option{-mno-long-calls} restores the default behavior. Note these
23773switches have no effect on how the compiler generates code to handle
23774function calls via function pointers.
23775
d77de738 23776@opindex mfast-fp
ddf6fe37 23777@item -mfast-fp
d77de738
ML
23778Link with the fast floating-point library. This library relaxes some of
23779the IEEE floating-point standard's rules for checking inputs against
23780Not-a-Number (NAN), in the interest of performance.
23781
d77de738 23782@opindex minline-plt
ddf6fe37 23783@item -minline-plt
d77de738
ML
23784Enable inlining of PLT entries in function calls to functions that are
23785not known to bind locally. It has no effect without @option{-mfdpic}.
23786
d77de738 23787@opindex mmulticore
ddf6fe37 23788@item -mmulticore
d77de738
ML
23789Build a standalone application for multicore Blackfin processors.
23790This option causes proper start files and link scripts supporting
23791multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23792It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23793
23794This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23795selects the one-application-per-core programming model. Without
23796@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23797programming model is used. In this model, the main function of Core B
23798should be named as @code{coreb_main}.
23799
23800If this option is not used, the single-core application programming
23801model is used.
23802
d77de738 23803@opindex mcorea
ddf6fe37 23804@item -mcorea
d77de738
ML
23805Build a standalone application for Core A of BF561 when using
23806the one-application-per-core programming model. Proper start files
23807and link scripts are used to support Core A, and the macro
23808@code{__BFIN_COREA} is defined.
23809This option can only be used in conjunction with @option{-mmulticore}.
23810
d77de738 23811@opindex mcoreb
ddf6fe37 23812@item -mcoreb
d77de738
ML
23813Build a standalone application for Core B of BF561 when using
23814the one-application-per-core programming model. Proper start files
23815and link scripts are used to support Core B, and the macro
23816@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23817should be used instead of @code{main}.
23818This option can only be used in conjunction with @option{-mmulticore}.
23819
d77de738 23820@opindex msdram
ddf6fe37 23821@item -msdram
d77de738
ML
23822Build a standalone application for SDRAM. Proper start files and
23823link scripts are used to put the application into SDRAM, and the macro
23824@code{__BFIN_SDRAM} is defined.
23825The loader should initialize SDRAM before loading the application.
23826
d77de738 23827@opindex micplb
ddf6fe37 23828@item -micplb
d77de738
ML
23829Assume that ICPLBs are enabled at run time. This has an effect on certain
23830anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23831are enabled; for standalone applications the default is off.
23832@end table
23833
23834@node C6X Options
23835@subsection C6X Options
23836@cindex C6X Options
23837
23838@table @gcctabopt
d77de738 23839@opindex march
ddf6fe37 23840@item -march=@var{name}
d77de738
ML
23841This specifies the name of the target architecture. GCC uses this
23842name to determine what kind of instructions it can emit when generating
23843assembly code. Permissible names are: @samp{c62x},
23844@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23845
d77de738 23846@opindex mbig-endian
ddf6fe37 23847@item -mbig-endian
d77de738
ML
23848Generate code for a big-endian target.
23849
d77de738 23850@opindex mlittle-endian
ddf6fe37 23851@item -mlittle-endian
d77de738
ML
23852Generate code for a little-endian target. This is the default.
23853
d77de738 23854@opindex msim
ddf6fe37 23855@item -msim
d77de738
ML
23856Choose startup files and linker script suitable for the simulator.
23857
d77de738 23858@opindex msdata=default
ddf6fe37 23859@item -msdata=default
d77de738
ML
23860Put small global and static data in the @code{.neardata} section,
23861which is pointed to by register @code{B14}. Put small uninitialized
23862global and static data in the @code{.bss} section, which is adjacent
23863to the @code{.neardata} section. Put small read-only data into the
23864@code{.rodata} section. The corresponding sections used for large
23865pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23866
d77de738 23867@opindex msdata=all
ddf6fe37 23868@item -msdata=all
d77de738
ML
23869Put all data, not just small objects, into the sections reserved for
23870small data, and use addressing relative to the @code{B14} register to
23871access them.
23872
d77de738 23873@opindex msdata=none
ddf6fe37 23874@item -msdata=none
d77de738
ML
23875Make no use of the sections reserved for small data, and use absolute
23876addresses to access all data. Put all initialized global and static
23877data in the @code{.fardata} section, and all uninitialized data in the
23878@code{.far} section. Put all constant data into the @code{.const}
23879section.
23880@end table
23881
23882@node CRIS Options
23883@subsection CRIS Options
23884@cindex CRIS Options
23885
23886These options are defined specifically for the CRIS ports.
23887
23888@table @gcctabopt
d77de738
ML
23889@opindex march
23890@opindex mcpu
ddf6fe37
AA
23891@item -march=@var{architecture-type}
23892@itemx -mcpu=@var{architecture-type}
d77de738
ML
23893Generate code for the specified architecture. The choices for
23894@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23895respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23896Default is @samp{v0}.
23897
d77de738 23898@opindex mtune
ddf6fe37 23899@item -mtune=@var{architecture-type}
d77de738
ML
23900Tune to @var{architecture-type} everything applicable about the generated
23901code, except for the ABI and the set of available instructions. The
23902choices for @var{architecture-type} are the same as for
23903@option{-march=@var{architecture-type}}.
23904
d77de738 23905@opindex mmax-stack-frame
ddf6fe37 23906@item -mmax-stack-frame=@var{n}
d77de738
ML
23907Warn when the stack frame of a function exceeds @var{n} bytes.
23908
d77de738
ML
23909@opindex metrax4
23910@opindex metrax100
ddf6fe37
AA
23911@item -metrax4
23912@itemx -metrax100
d77de738
ML
23913The options @option{-metrax4} and @option{-metrax100} are synonyms for
23914@option{-march=v3} and @option{-march=v8} respectively.
23915
d77de738
ML
23916@opindex mmul-bug-workaround
23917@opindex mno-mul-bug-workaround
ddf6fe37
AA
23918@item -mmul-bug-workaround
23919@itemx -mno-mul-bug-workaround
d77de738
ML
23920Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23921models where it applies. This option is disabled by default.
23922
d77de738 23923@opindex mpdebug
ddf6fe37 23924@item -mpdebug
d77de738
ML
23925Enable CRIS-specific verbose debug-related information in the assembly
23926code. This option also has the effect of turning off the @samp{#NO_APP}
23927formatted-code indicator to the assembler at the beginning of the
23928assembly file.
23929
d77de738 23930@opindex mcc-init
ddf6fe37 23931@item -mcc-init
d77de738
ML
23932Do not use condition-code results from previous instruction; always emit
23933compare and test instructions before use of condition codes.
23934
d77de738
ML
23935@opindex mno-side-effects
23936@opindex mside-effects
ddf6fe37 23937@item -mno-side-effects
d77de738
ML
23938Do not emit instructions with side effects in addressing modes other than
23939post-increment.
23940
d77de738
ML
23941@opindex mstack-align
23942@opindex mno-stack-align
23943@opindex mdata-align
23944@opindex mno-data-align
23945@opindex mconst-align
23946@opindex mno-const-align
ddf6fe37
AA
23947@item -mstack-align
23948@itemx -mno-stack-align
23949@itemx -mdata-align
23950@itemx -mno-data-align
23951@itemx -mconst-align
23952@itemx -mno-const-align
d77de738
ML
23953These options (@samp{no-} options) arrange (eliminate arrangements) for the
23954stack frame, individual data and constants to be aligned for the maximum
23955single data access size for the chosen CPU model. The default is to
23956arrange for 32-bit alignment. ABI details such as structure layout are
23957not affected by these options.
23958
d77de738
ML
23959@opindex m32-bit
23960@opindex m16-bit
23961@opindex m8-bit
ddf6fe37
AA
23962@item -m32-bit
23963@itemx -m16-bit
23964@itemx -m8-bit
d77de738
ML
23965Similar to the stack- data- and const-align options above, these options
23966arrange for stack frame, writable data and constants to all be 32-bit,
2396716-bit or 8-bit aligned. The default is 32-bit alignment.
23968
d77de738
ML
23969@opindex mno-prologue-epilogue
23970@opindex mprologue-epilogue
ddf6fe37
AA
23971@item -mno-prologue-epilogue
23972@itemx -mprologue-epilogue
d77de738
ML
23973With @option{-mno-prologue-epilogue}, the normal function prologue and
23974epilogue which set up the stack frame are omitted and no return
23975instructions or return sequences are generated in the code. Use this
23976option only together with visual inspection of the compiled code: no
23977warnings or errors are generated when call-saved registers must be saved,
23978or storage for local variables needs to be allocated.
23979
d77de738 23980@opindex melf
ddf6fe37 23981@item -melf
d77de738
ML
23982Legacy no-op option.
23983
d77de738 23984@opindex sim
ddf6fe37 23985@item -sim
d77de738
ML
23986This option arranges
23987to link with input-output functions from a simulator library. Code,
23988initialized data and zero-initialized data are allocated consecutively.
23989
d77de738 23990@opindex sim2
ddf6fe37 23991@item -sim2
d77de738
ML
23992Like @option{-sim}, but pass linker options to locate initialized data at
239930x40000000 and zero-initialized data at 0x80000000.
23994@end table
23995
23996@node C-SKY Options
23997@subsection C-SKY Options
23998@cindex C-SKY Options
23999
24000GCC supports these options when compiling for C-SKY V2 processors.
24001
24002@table @gcctabopt
24003
d77de738 24004@opindex march=
ddf6fe37 24005@item -march=@var{arch}
d77de738
ML
24006Specify the C-SKY target architecture. Valid values for @var{arch} are:
24007@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
24008The default is @samp{ck810}.
24009
d77de738 24010@opindex mcpu=
ddf6fe37 24011@item -mcpu=@var{cpu}
d77de738
ML
24012Specify the C-SKY target processor. Valid values for @var{cpu} are:
24013@samp{ck801}, @samp{ck801t},
24014@samp{ck802}, @samp{ck802t}, @samp{ck802j},
24015@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
24016@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
24017@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
24018@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
24019@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
24020@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
24021@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
24022@samp{ck803eftr1}, @samp{ck803efhtr1},
24023@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
24024@samp{ck803sef}, @samp{ck803seft},
24025@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
24026@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
24027@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
24028@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
24029
d77de738 24030@opindex mbig-endian
d77de738 24031@opindex EB
d77de738 24032@opindex mlittle-endian
d77de738 24033@opindex EL
ddf6fe37
AA
24034@item -mbig-endian
24035@itemx -EB
24036@itemx -mlittle-endian
24037@itemx -EL
d77de738
ML
24038
24039Select big- or little-endian code. The default is little-endian.
24040
d77de738 24041@opindex mfloat-abi
ddf6fe37 24042@item -mfloat-abi=@var{name}
d77de738
ML
24043Specifies which floating-point ABI to use. Permissible values
24044are: @samp{soft}, @samp{softfp} and @samp{hard}.
24045
24046Specifying @samp{soft} causes GCC to generate output containing
24047library calls for floating-point operations.
24048@samp{softfp} allows the generation of code using hardware floating-point
24049instructions, but still uses the soft-float calling conventions.
24050@samp{hard} allows generation of floating-point instructions
24051and uses FPU-specific calling conventions.
24052
24053The default depends on the specific target configuration. Note that
24054the hard-float and soft-float ABIs are not link-compatible; you must
24055compile your entire program with the same ABI, and link with a
24056compatible set of libraries.
24057
d77de738 24058@opindex mhard-float
d77de738 24059@opindex msoft-float
ddf6fe37
AA
24060@item -mhard-float
24061@itemx -msoft-float
d77de738
ML
24062
24063Select hardware or software floating-point implementations.
24064The default is soft float.
24065
ddf6fe37 24066@opindex mdouble-float
d77de738
ML
24067@item -mdouble-float
24068@itemx -mno-double-float
d77de738
ML
24069When @option{-mhard-float} is in effect, enable generation of
24070double-precision float instructions. This is the default except
24071when compiling for CK803.
24072
ddf6fe37 24073@opindex mfdivdu
d77de738
ML
24074@item -mfdivdu
24075@itemx -mno-fdivdu
d77de738
ML
24076When @option{-mhard-float} is in effect, enable generation of
24077@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
24078This is the default except when compiling for CK803.
24079
d77de738 24080@opindex mfpu=
ddf6fe37 24081@item -mfpu=@var{fpu}
d77de738
ML
24082Select the floating-point processor. This option can only be used with
24083@option{-mhard-float}.
24084Values for @var{fpu} are
24085@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
24086@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
24087@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
24088
ddf6fe37 24089@opindex melrw
d77de738
ML
24090@item -melrw
24091@itemx -mno-elrw
d77de738
ML
24092Enable the extended @code{lrw} instruction. This option defaults to on
24093for CK801 and off otherwise.
24094
ddf6fe37 24095@opindex mistack
d77de738
ML
24096@item -mistack
24097@itemx -mno-istack
d77de738
ML
24098Enable interrupt stack instructions; the default is off.
24099
24100The @option{-mistack} option is required to handle the
24101@code{interrupt} and @code{isr} function attributes
24102(@pxref{C-SKY Function Attributes}).
24103
d77de738 24104@opindex mmp
ddf6fe37 24105@item -mmp
d77de738
ML
24106Enable multiprocessor instructions; the default is off.
24107
d77de738 24108@opindex mcp
ddf6fe37 24109@item -mcp
d77de738
ML
24110Enable coprocessor instructions; the default is off.
24111
d77de738 24112@opindex mcache
ddf6fe37 24113@item -mcache
d77de738
ML
24114Enable coprocessor instructions; the default is off.
24115
d77de738 24116@opindex msecurity
ddf6fe37 24117@item -msecurity
d77de738
ML
24118Enable C-SKY security instructions; the default is off.
24119
d77de738 24120@opindex mtrust
ddf6fe37 24121@item -mtrust
d77de738
ML
24122Enable C-SKY trust instructions; the default is off.
24123
d77de738 24124@opindex mdsp
d77de738 24125@opindex medsp
d77de738 24126@opindex mvdsp
ddf6fe37
AA
24127@item -mdsp
24128@itemx -medsp
24129@itemx -mvdsp
d77de738
ML
24130Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
24131All of these options default to off.
24132
ddf6fe37 24133@opindex mdiv
d77de738
ML
24134@item -mdiv
24135@itemx -mno-div
d77de738
ML
24136Generate divide instructions. Default is off.
24137
ddf6fe37 24138@opindex msmart
d77de738
ML
24139@item -msmart
24140@itemx -mno-smart
d77de738
ML
24141Generate code for Smart Mode, using only registers numbered 0-7 to allow
24142use of 16-bit instructions. This option is ignored for CK801 where this
24143is the required behavior, and it defaults to on for CK802.
24144For other targets, the default is off.
24145
ddf6fe37 24146@opindex mhigh-registers
d77de738
ML
24147@item -mhigh-registers
24148@itemx -mno-high-registers
d77de738
ML
24149Generate code using the high registers numbered 16-31. This option
24150is not supported on CK801, CK802, or CK803, and is enabled by default
24151for other processors.
24152
ddf6fe37 24153@opindex manchor
d77de738
ML
24154@item -manchor
24155@itemx -mno-anchor
d77de738
ML
24156Generate code using global anchor symbol addresses.
24157
ddf6fe37 24158@opindex mpushpop
d77de738
ML
24159@item -mpushpop
24160@itemx -mno-pushpop
d77de738
ML
24161Generate code using @code{push} and @code{pop} instructions. This option
24162defaults to on.
24163
ddf6fe37 24164@opindex mmultiple-stld
d77de738
ML
24165@item -mmultiple-stld
24166@itemx -mstm
24167@itemx -mno-multiple-stld
24168@itemx -mno-stm
d77de738
ML
24169Generate code using @code{stm} and @code{ldm} instructions. This option
24170isn't supported on CK801 but is enabled by default on other processors.
24171
ddf6fe37 24172@opindex mconstpool
d77de738
ML
24173@item -mconstpool
24174@itemx -mno-constpool
d77de738
ML
24175Create constant pools in the compiler instead of deferring it to the
24176assembler. This option is the default and required for correct code
24177generation on CK801 and CK802, and is optional on other processors.
24178
ddf6fe37 24179@opindex mstack-size
d77de738
ML
24180@item -mstack-size
24181@item -mno-stack-size
d77de738
ML
24182Emit @code{.stack_size} directives for each function in the assembly
24183output. This option defaults to off.
24184
ddf6fe37 24185@opindex mccrt
d77de738
ML
24186@item -mccrt
24187@itemx -mno-ccrt
d77de738
ML
24188Generate code for the C-SKY compiler runtime instead of libgcc. This
24189option defaults to off.
24190
d77de738 24191@opindex mbranch-cost=
ddf6fe37 24192@item -mbranch-cost=@var{n}
d77de738
ML
24193Set the branch costs to roughly @code{n} instructions. The default is 1.
24194
ddf6fe37 24195@opindex msched-prolog
d77de738
ML
24196@item -msched-prolog
24197@itemx -mno-sched-prolog
d77de738
ML
24198Permit scheduling of function prologue and epilogue sequences. Using
24199this option can result in code that is not compliant with the C-SKY V2 ABI
24200prologue requirements and that cannot be debugged or backtraced.
24201It is disabled by default.
24202
d77de738 24203@opindex msim
ddf6fe37 24204@item -msim
d77de738
ML
24205Links the library libsemi.a which is in compatible with simulator. Applicable
24206to ELF compiler only.
24207
24208@end table
24209
24210@node Darwin Options
24211@subsection Darwin Options
24212@cindex Darwin options
24213
24214These options are defined for all architectures running the Darwin operating
24215system.
24216
24217FSF GCC on Darwin does not create ``fat'' object files; it creates
24218an object file for the single architecture that GCC was built to
24219target. Apple's GCC on Darwin does create ``fat'' files if multiple
24220@option{-arch} options are used; it does so by running the compiler or
24221linker multiple times and joining the results together with
24222@file{lipo}.
24223
24224The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
24225@samp{i686}) is determined by the flags that specify the ISA
24226that GCC is targeting, like @option{-mcpu} or @option{-march}. The
24227@option{-force_cpusubtype_ALL} option can be used to override this.
24228
24229The Darwin tools vary in their behavior when presented with an ISA
24230mismatch. The assembler, @file{as}, only permits instructions to
24231be used that are valid for the subtype of the file it is generating,
24232so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24233The linker for shared libraries, @file{/usr/bin/libtool}, fails
24234and prints an error if asked to create a shared library with a less
24235restrictive subtype than its input files (for instance, trying to put
24236a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24237for executables, @command{ld}, quietly gives the executable the most
24238restrictive subtype of any of its input files.
24239
24240@table @gcctabopt
d77de738 24241@opindex F
ddf6fe37 24242@item -F@var{dir}
d77de738
ML
24243Add the framework directory @var{dir} to the head of the list of
24244directories to be searched for header files. These directories are
24245interleaved with those specified by @option{-I} options and are
24246scanned in a left-to-right order.
24247
24248A framework directory is a directory with frameworks in it. A
24249framework is a directory with a @file{Headers} and/or
24250@file{PrivateHeaders} directory contained directly in it that ends
24251in @file{.framework}. The name of a framework is the name of this
24252directory excluding the @file{.framework}. Headers associated with
24253the framework are found in one of those two directories, with
24254@file{Headers} being searched first. A subframework is a framework
24255directory that is in a framework's @file{Frameworks} directory.
24256Includes of subframework headers can only appear in a header of a
24257framework that contains the subframework, or in a sibling subframework
24258header. Two subframeworks are siblings if they occur in the same
24259framework. A subframework should not have the same name as a
24260framework; a warning is issued if this is violated. Currently a
24261subframework cannot have subframeworks; in the future, the mechanism
24262may be extended to support this. The standard frameworks can be found
24263in @file{/System/Library/Frameworks} and
24264@file{/Library/Frameworks}. An example include looks like
24265@code{#include <Framework/header.h>}, where @file{Framework} denotes
24266the name of the framework and @file{header.h} is found in the
24267@file{PrivateHeaders} or @file{Headers} directory.
24268
d77de738 24269@opindex iframework
ddf6fe37 24270@item -iframework@var{dir}
d77de738
ML
24271Like @option{-F} except the directory is a treated as a system
24272directory. The main difference between this @option{-iframework} and
24273@option{-F} is that with @option{-iframework} the compiler does not
24274warn about constructs contained within header files found via
24275@var{dir}. This option is valid only for the C family of languages.
24276
d77de738 24277@opindex gused
ddf6fe37 24278@item -gused
d77de738
ML
24279Emit debugging information for symbols that are used. For stabs
24280debugging format, this enables @option{-feliminate-unused-debug-symbols}.
24281This is by default ON@.
24282
d77de738 24283@opindex gfull
ddf6fe37 24284@item -gfull
d77de738
ML
24285Emit debugging information for all symbols and types.
24286
cdd4b3c0
IS
24287@opindex fconstant-cfstrings
24288@item -fconstant-cfstrings
24289The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
24290
24291@opindex mconstant-cfstrings
24292@item -mconstant-cfstrings
24293When the NeXT runtime is being used (the default on these systems), override
24294any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
24295literals to be laid out as constant CoreFoundation strings.
24296
24297@opindex mmacosx-version-min
d77de738 24298@item -mmacosx-version-min=@var{version}
cdd4b3c0
IS
24299The earliest version of MacOS X that this executable will run on is
24300@var{version}. Typical values supported for @var{version} include @code{12},
24301@code{10.12}, and @code{10.5.8}.
d77de738
ML
24302
24303If the compiler was built to use the system's headers by default,
24304then the default for this option is the system version on which the
24305compiler is running, otherwise the default is to make choices that
24306are compatible with as many systems and code bases as possible.
24307
d77de738 24308@opindex mkernel
ddf6fe37 24309@item -mkernel
d77de738
ML
24310Enable kernel development mode. The @option{-mkernel} option sets
24311@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
24312@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
24313@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
24314applicable. This mode also sets @option{-mno-altivec},
24315@option{-msoft-float}, @option{-fno-builtin} and
24316@option{-mlong-branch} for PowerPC targets.
24317
d77de738 24318@opindex mone-byte-bool
ddf6fe37 24319@item -mone-byte-bool
d77de738
ML
24320Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
24321By default @code{sizeof(bool)} is @code{4} when compiling for
24322Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
24323option has no effect on x86.
24324
24325@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
24326to generate code that is not binary compatible with code generated
24327without that switch. Using this switch may require recompiling all
24328other modules in a program, including system libraries. Use this
24329switch to conform to a non-default data model.
24330
d77de738
ML
24331@opindex mfix-and-continue
24332@opindex ffix-and-continue
24333@opindex findirect-data
ddf6fe37
AA
24334@item -mfix-and-continue
24335@itemx -ffix-and-continue
24336@itemx -findirect-data
d77de738
ML
24337Generate code suitable for fast turnaround development, such as to
24338allow GDB to dynamically load @file{.o} files into already-running
24339programs. @option{-findirect-data} and @option{-ffix-and-continue}
24340are provided for backwards compatibility.
24341
d77de738 24342@opindex all_load
ddf6fe37 24343@item -all_load
d77de738
ML
24344Loads all members of static archive libraries.
24345See man ld(1) for more information.
24346
d77de738 24347@opindex arch_errors_fatal
ddf6fe37 24348@item -arch_errors_fatal
d77de738
ML
24349Cause the errors having to do with files that have the wrong architecture
24350to be fatal.
24351
d77de738 24352@opindex bind_at_load
ddf6fe37 24353@item -bind_at_load
d77de738
ML
24354Causes the output file to be marked such that the dynamic linker will
24355bind all undefined references when the file is loaded or launched.
24356
d77de738 24357@opindex bundle
ddf6fe37 24358@item -bundle
d77de738
ML
24359Produce a Mach-o bundle format file.
24360See man ld(1) for more information.
24361
d77de738 24362@opindex bundle_loader
ddf6fe37 24363@item -bundle_loader @var{executable}
d77de738
ML
24364This option specifies the @var{executable} that will load the build
24365output file being linked. See man ld(1) for more information.
24366
d77de738 24367@opindex dynamiclib
ddf6fe37 24368@item -dynamiclib
d77de738
ML
24369When passed this option, GCC produces a dynamic library instead of
24370an executable when linking, using the Darwin @file{libtool} command.
24371
d77de738 24372@opindex force_cpusubtype_ALL
ddf6fe37 24373@item -force_cpusubtype_ALL
d77de738
ML
24374This causes GCC's output file to have the @samp{ALL} subtype, instead of
24375one controlled by the @option{-mcpu} or @option{-march} option.
24376
24377@item -allowable_client @var{client_name}
24378@itemx -client_name
24379@itemx -compatibility_version
24380@itemx -current_version
24381@itemx -dead_strip
24382@itemx -dependency-file
24383@itemx -dylib_file
24384@itemx -dylinker_install_name
24385@itemx -dynamic
24386@itemx -exported_symbols_list
24387@itemx -filelist
24388@need 800
24389@itemx -flat_namespace
24390@itemx -force_flat_namespace
24391@itemx -headerpad_max_install_names
24392@itemx -image_base
24393@itemx -init
24394@itemx -install_name
24395@itemx -keep_private_externs
24396@itemx -multi_module
24397@itemx -multiply_defined
24398@itemx -multiply_defined_unused
24399@need 800
24400@itemx -noall_load
24401@itemx -no_dead_strip_inits_and_terms
24402@itemx -nofixprebinding
24403@itemx -nomultidefs
24404@itemx -noprebind
24405@itemx -noseglinkedit
24406@itemx -pagezero_size
24407@itemx -prebind
24408@itemx -prebind_all_twolevel_modules
24409@itemx -private_bundle
24410@need 800
24411@itemx -read_only_relocs
24412@itemx -sectalign
24413@itemx -sectobjectsymbols
24414@itemx -whyload
24415@itemx -seg1addr
24416@itemx -sectcreate
24417@itemx -sectobjectsymbols
24418@itemx -sectorder
24419@itemx -segaddr
24420@itemx -segs_read_only_addr
24421@need 800
24422@itemx -segs_read_write_addr
24423@itemx -seg_addr_table
24424@itemx -seg_addr_table_filename
24425@itemx -seglinkedit
24426@itemx -segprot
24427@itemx -segs_read_only_addr
24428@itemx -segs_read_write_addr
24429@itemx -single_module
24430@itemx -static
24431@itemx -sub_library
24432@need 800
d77de738
ML
24433@opindex allowable_client
24434@opindex client_name
24435@opindex compatibility_version
24436@opindex current_version
24437@opindex dead_strip
24438@opindex dependency-file
24439@opindex dylib_file
24440@opindex dylinker_install_name
24441@opindex dynamic
24442@opindex exported_symbols_list
24443@opindex filelist
24444@opindex flat_namespace
24445@opindex force_flat_namespace
24446@opindex headerpad_max_install_names
24447@opindex image_base
24448@opindex init
24449@opindex install_name
24450@opindex keep_private_externs
24451@opindex multi_module
24452@opindex multiply_defined
24453@opindex multiply_defined_unused
24454@opindex noall_load
24455@opindex no_dead_strip_inits_and_terms
24456@opindex nofixprebinding
24457@opindex nomultidefs
24458@opindex noprebind
24459@opindex noseglinkedit
24460@opindex pagezero_size
24461@opindex prebind
24462@opindex prebind_all_twolevel_modules
24463@opindex private_bundle
24464@opindex read_only_relocs
24465@opindex sectalign
24466@opindex sectobjectsymbols
24467@opindex whyload
24468@opindex seg1addr
24469@opindex sectcreate
24470@opindex sectobjectsymbols
24471@opindex sectorder
24472@opindex segaddr
24473@opindex segs_read_only_addr
24474@opindex segs_read_write_addr
24475@opindex seg_addr_table
24476@opindex seg_addr_table_filename
24477@opindex seglinkedit
24478@opindex segprot
24479@opindex segs_read_only_addr
24480@opindex segs_read_write_addr
24481@opindex single_module
24482@opindex static
24483@opindex sub_library
24484@opindex sub_umbrella
24485@opindex twolevel_namespace
24486@opindex umbrella
24487@opindex undefined
24488@opindex unexported_symbols_list
24489@opindex weak_reference_mismatches
24490@opindex whatsloaded
ddf6fe37
AA
24491@itemx -sub_umbrella
24492@itemx -twolevel_namespace
24493@itemx -umbrella
24494@itemx -undefined
24495@itemx -unexported_symbols_list
24496@itemx -weak_reference_mismatches
24497@itemx -whatsloaded
d77de738
ML
24498These options are passed to the Darwin linker. The Darwin linker man page
24499describes them in detail.
24500@end table
24501
24502@node DEC Alpha Options
24503@subsection DEC Alpha Options
24504
24505These @samp{-m} options are defined for the DEC Alpha implementations:
24506
24507@table @gcctabopt
d77de738
ML
24508@opindex mno-soft-float
24509@opindex msoft-float
ddf6fe37
AA
24510@item -mno-soft-float
24511@itemx -msoft-float
d77de738
ML
24512Use (do not use) the hardware floating-point instructions for
24513floating-point operations. When @option{-msoft-float} is specified,
24514functions in @file{libgcc.a} are used to perform floating-point
24515operations. Unless they are replaced by routines that emulate the
24516floating-point operations, or compiled in such a way as to call such
24517emulations routines, these routines issue floating-point
24518operations. If you are compiling for an Alpha without floating-point
24519operations, you must ensure that the library is built so as not to call
24520them.
24521
24522Note that Alpha implementations without floating-point operations are
24523required to have floating-point registers.
24524
d77de738
ML
24525@opindex mfp-reg
24526@opindex mno-fp-regs
ddf6fe37
AA
24527@item -mfp-reg
24528@itemx -mno-fp-regs
d77de738
ML
24529Generate code that uses (does not use) the floating-point register set.
24530@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24531register set is not used, floating-point operands are passed in integer
24532registers as if they were integers and floating-point results are passed
24533in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24534so any function with a floating-point argument or return value called by code
24535compiled with @option{-mno-fp-regs} must also be compiled with that
24536option.
24537
24538A typical use of this option is building a kernel that does not use,
24539and hence need not save and restore, any floating-point registers.
24540
d77de738 24541@opindex mieee
ddf6fe37 24542@item -mieee
d77de738
ML
24543The Alpha architecture implements floating-point hardware optimized for
24544maximum performance. It is mostly compliant with the IEEE floating-point
24545standard. However, for full compliance, software assistance is
24546required. This option generates code fully IEEE-compliant code
24547@emph{except} that the @var{inexact-flag} is not maintained (see below).
24548If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24549defined during compilation. The resulting code is less efficient but is
24550able to correctly support denormalized numbers and exceptional IEEE
24551values such as not-a-number and plus/minus infinity. Other Alpha
24552compilers call this option @option{-ieee_with_no_inexact}.
24553
d77de738 24554@opindex mieee-with-inexact
ddf6fe37 24555@item -mieee-with-inexact
d77de738
ML
24556This is like @option{-mieee} except the generated code also maintains
24557the IEEE @var{inexact-flag}. Turning on this option causes the
24558generated code to implement fully-compliant IEEE math. In addition to
24559@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24560macro. On some Alpha implementations the resulting code may execute
24561significantly slower than the code generated by default. Since there is
24562very little code that depends on the @var{inexact-flag}, you should
24563normally not specify this option. Other Alpha compilers call this
24564option @option{-ieee_with_inexact}.
24565
d77de738 24566@opindex mfp-trap-mode
ddf6fe37 24567@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24568This option controls what floating-point related traps are enabled.
24569Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24570The trap mode can be set to one of four values:
24571
24572@table @samp
24573@item n
24574This is the default (normal) setting. The only traps that are enabled
24575are the ones that cannot be disabled in software (e.g., division by zero
24576trap).
24577
24578@item u
24579In addition to the traps enabled by @samp{n}, underflow traps are enabled
24580as well.
24581
24582@item su
24583Like @samp{u}, but the instructions are marked to be safe for software
24584completion (see Alpha architecture manual for details).
24585
24586@item sui
24587Like @samp{su}, but inexact traps are enabled as well.
24588@end table
24589
d77de738 24590@opindex mfp-rounding-mode
ddf6fe37 24591@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24592Selects the IEEE rounding mode. Other Alpha compilers call this option
24593@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24594of:
24595
24596@table @samp
24597@item n
24598Normal IEEE rounding mode. Floating-point numbers are rounded towards
24599the nearest machine number or towards the even machine number in case
24600of a tie.
24601
24602@item m
24603Round towards minus infinity.
24604
24605@item c
24606Chopped rounding mode. Floating-point numbers are rounded towards zero.
24607
24608@item d
24609Dynamic rounding mode. A field in the floating-point control register
24610(@var{fpcr}, see Alpha architecture reference manual) controls the
24611rounding mode in effect. The C library initializes this register for
24612rounding towards plus infinity. Thus, unless your program modifies the
24613@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24614@end table
24615
d77de738 24616@opindex mtrap-precision
ddf6fe37 24617@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24618In the Alpha architecture, floating-point traps are imprecise. This
24619means without software assistance it is impossible to recover from a
24620floating trap and program execution normally needs to be terminated.
24621GCC can generate code that can assist operating system trap handlers
24622in determining the exact location that caused a floating-point trap.
24623Depending on the requirements of an application, different levels of
24624precisions can be selected:
24625
24626@table @samp
24627@item p
24628Program precision. This option is the default and means a trap handler
24629can only identify which program caused a floating-point exception.
24630
24631@item f
24632Function precision. The trap handler can determine the function that
24633caused a floating-point exception.
24634
24635@item i
24636Instruction precision. The trap handler can determine the exact
24637instruction that caused a floating-point exception.
24638@end table
24639
24640Other Alpha compilers provide the equivalent options called
24641@option{-scope_safe} and @option{-resumption_safe}.
24642
d77de738 24643@opindex mieee-conformant
ddf6fe37 24644@item -mieee-conformant
d77de738
ML
24645This option marks the generated code as IEEE conformant. You must not
24646use this option unless you also specify @option{-mtrap-precision=i} and either
24647@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24648is to emit the line @samp{.eflag 48} in the function prologue of the
24649generated assembly file.
24650
d77de738 24651@opindex mbuild-constants
ddf6fe37 24652@item -mbuild-constants
d77de738
ML
24653Normally GCC examines a 32- or 64-bit integer constant to
24654see if it can construct it from smaller constants in two or three
24655instructions. If it cannot, it outputs the constant as a literal and
24656generates code to load it from the data segment at run time.
24657
24658Use this option to require GCC to construct @emph{all} integer constants
24659using code, even if it takes more instructions (the maximum is six).
24660
24661You typically use this option to build a shared library dynamic
24662loader. Itself a shared library, it must relocate itself in memory
24663before it can find the variables and constants in its own data segment.
24664
d77de738
ML
24665@opindex mbwx
24666@opindex mno-bwx
24667@opindex mcix
24668@opindex mno-cix
24669@opindex mfix
24670@opindex mno-fix
24671@opindex mmax
24672@opindex mno-max
ddf6fe37
AA
24673@item -mbwx
24674@itemx -mno-bwx
24675@itemx -mcix
24676@itemx -mno-cix
24677@itemx -mfix
24678@itemx -mno-fix
24679@itemx -mmax
24680@itemx -mno-max
d77de738
ML
24681Indicate whether GCC should generate code to use the optional BWX,
24682CIX, FIX and MAX instruction sets. The default is to use the instruction
24683sets supported by the CPU type specified via @option{-mcpu=} option or that
24684of the CPU on which GCC was built if none is specified.
24685
d77de738
ML
24686@opindex mfloat-vax
24687@opindex mfloat-ieee
ddf6fe37
AA
24688@item -mfloat-vax
24689@itemx -mfloat-ieee
d77de738
ML
24690Generate code that uses (does not use) VAX F and G floating-point
24691arithmetic instead of IEEE single and double precision.
24692
d77de738
ML
24693@opindex mexplicit-relocs
24694@opindex mno-explicit-relocs
ddf6fe37
AA
24695@item -mexplicit-relocs
24696@itemx -mno-explicit-relocs
d77de738
ML
24697Older Alpha assemblers provided no way to generate symbol relocations
24698except via assembler macros. Use of these macros does not allow
24699optimal instruction scheduling. GNU binutils as of version 2.12
24700supports a new syntax that allows the compiler to explicitly mark
24701which relocations should apply to which instructions. This option
24702is mostly useful for debugging, as GCC detects the capabilities of
24703the assembler when it is built and sets the default accordingly.
24704
d77de738
ML
24705@opindex msmall-data
24706@opindex mlarge-data
ddf6fe37
AA
24707@item -msmall-data
24708@itemx -mlarge-data
d77de738
ML
24709When @option{-mexplicit-relocs} is in effect, static data is
24710accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24711is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24712(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2471316-bit relocations off of the @code{$gp} register. This limits the
24714size of the small data area to 64KB, but allows the variables to be
24715directly accessed via a single instruction.
24716
24717The default is @option{-mlarge-data}. With this option the data area
24718is limited to just below 2GB@. Programs that require more than 2GB of
24719data must use @code{malloc} or @code{mmap} to allocate the data in the
24720heap instead of in the program's data segment.
24721
24722When generating code for shared libraries, @option{-fpic} implies
24723@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24724
d77de738
ML
24725@opindex msmall-text
24726@opindex mlarge-text
ddf6fe37
AA
24727@item -msmall-text
24728@itemx -mlarge-text
d77de738
ML
24729When @option{-msmall-text} is used, the compiler assumes that the
24730code of the entire program (or shared library) fits in 4MB, and is
24731thus reachable with a branch instruction. When @option{-msmall-data}
24732is used, the compiler can assume that all local symbols share the
24733same @code{$gp} value, and thus reduce the number of instructions
24734required for a function call from 4 to 1.
24735
24736The default is @option{-mlarge-text}.
24737
d77de738 24738@opindex mcpu
ddf6fe37 24739@item -mcpu=@var{cpu_type}
d77de738
ML
24740Set the instruction set and instruction scheduling parameters for
24741machine type @var{cpu_type}. You can specify either the @samp{EV}
24742style name or the corresponding chip number. GCC supports scheduling
24743parameters for the EV4, EV5 and EV6 family of processors and
24744chooses the default values for the instruction set from the processor
24745you specify. If you do not specify a processor type, GCC defaults
24746to the processor on which the compiler was built.
24747
24748Supported values for @var{cpu_type} are
24749
24750@table @samp
24751@item ev4
24752@itemx ev45
24753@itemx 21064
24754Schedules as an EV4 and has no instruction set extensions.
24755
24756@item ev5
24757@itemx 21164
24758Schedules as an EV5 and has no instruction set extensions.
24759
24760@item ev56
24761@itemx 21164a
24762Schedules as an EV5 and supports the BWX extension.
24763
24764@item pca56
24765@itemx 21164pc
24766@itemx 21164PC
24767Schedules as an EV5 and supports the BWX and MAX extensions.
24768
24769@item ev6
24770@itemx 21264
24771Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24772
24773@item ev67
24774@itemx 21264a
24775Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24776@end table
24777
24778Native toolchains also support the value @samp{native},
24779which selects the best architecture option for the host processor.
24780@option{-mcpu=native} has no effect if GCC does not recognize
24781the processor.
24782
d77de738 24783@opindex mtune
ddf6fe37 24784@item -mtune=@var{cpu_type}
d77de738
ML
24785Set only the instruction scheduling parameters for machine type
24786@var{cpu_type}. The instruction set is not changed.
24787
24788Native toolchains also support the value @samp{native},
24789which selects the best architecture option for the host processor.
24790@option{-mtune=native} has no effect if GCC does not recognize
24791the processor.
24792
d77de738 24793@opindex mmemory-latency
ddf6fe37 24794@item -mmemory-latency=@var{time}
d77de738
ML
24795Sets the latency the scheduler should assume for typical memory
24796references as seen by the application. This number is highly
24797dependent on the memory access patterns used by the application
24798and the size of the external cache on the machine.
24799
24800Valid options for @var{time} are
24801
24802@table @samp
24803@item @var{number}
24804A decimal number representing clock cycles.
24805
24806@item L1
24807@itemx L2
24808@itemx L3
24809@itemx main
24810The compiler contains estimates of the number of clock cycles for
24811``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24812(also called Dcache, Scache, and Bcache), as well as to main memory.
24813Note that L3 is only valid for EV5.
24814
24815@end table
24816@end table
24817
24818@node eBPF Options
24819@subsection eBPF Options
24820@cindex eBPF Options
24821
24822@table @gcctabopt
24823@item -mframe-limit=@var{bytes}
24824This specifies the hard limit for frame sizes, in bytes. Currently,
24825the value that can be specified should be less than or equal to
24826@samp{32767}. Defaults to whatever limit is imposed by the version of
24827the Linux kernel targeted.
24828
d77de738 24829@opindex mbig-endian
ddf6fe37 24830@item -mbig-endian
d77de738
ML
24831Generate code for a big-endian target.
24832
d77de738 24833@opindex mlittle-endian
ddf6fe37 24834@item -mlittle-endian
d77de738
ML
24835Generate code for a little-endian target. This is the default.
24836
d77de738 24837@opindex mjmpext
ddf6fe37 24838@item -mjmpext
9cbf4286
DF
24839@itemx -mno-jmpext
24840Enable or disable generation of extra conditional-branch instructions.
d77de738
ML
24841Enabled for CPU v2 and above.
24842
d77de738 24843@opindex mjmp32
ddf6fe37 24844@item -mjmp32
9cbf4286
DF
24845@itemx -mno-jmp32
24846Enable or disable generation of 32-bit jump instructions.
24847Enabled for CPU v3 and above.
d77de738 24848
d77de738 24849@opindex malu32
ddf6fe37 24850@item -malu32
9cbf4286
DF
24851@itemx -mno-alu32
24852Enable or disable generation of 32-bit ALU instructions.
24853Enabled for CPU v3 and above.
24854
24855@opindex mv3-atomics
24856@item -mv3-atomics
24857@itemx -mno-v3-atomics
24858Enable or disable instructions for general atomic operations introduced
24859in CPU v3. Enabled for CPU v3 and above.
d77de738 24860
f1e34551
JM
24861@opindex mbswap
24862@item -mbswap
9cbf4286
DF
24863@itemx -mno-bswap
24864Enable or disable byte swap instructions. Enabled for CPU v4 and above.
f1e34551 24865
4be3919f
JM
24866@opindex msdiv
24867@item -msdiv
9cbf4286
DF
24868@itemx -mno-sdiv
24869Enable or disable signed division and modulus instructions. Enabled for
24870CPU v4 and above.
db189d02 24871
14dab1a1
DF
24872@opindex msmov
24873@item -msmov
24874@itemx -mno-smov
24875Enable or disable sign-extending move and memory load instructions.
24876Enabled for CPU v4 and above.
24877
d77de738 24878@opindex mcpu
ddf6fe37 24879@item -mcpu=@var{version}
d77de738 24880This specifies which version of the eBPF ISA to target. Newer versions
f1e34551 24881may not be supported by all kernels. The default is @samp{v4}.
d77de738
ML
24882
24883Supported values for @var{version} are:
24884
24885@table @samp
24886@item v1
24887The first stable eBPF ISA with no special features or extensions.
24888
24889@item v2
24890Supports the jump extensions, as in @option{-mjmpext}.
24891
24892@item v3
24893All features of v2, plus:
24894@itemize @minus
24895@item 32-bit jump operations, as in @option{-mjmp32}
24896@item 32-bit ALU operations, as in @option{-malu32}
db189d02 24897@item general atomic operations, as in @option{-mv3-atomics}
d77de738
ML
24898@end itemize
24899
f1e34551
JM
24900@item v4
24901All features of v3, plus:
24902@itemize @minus
24903@item Byte swap instructions, as in @option{-mbswap}
9cbf4286 24904@item Signed division and modulus instructions, as in @option{-msdiv}
14dab1a1 24905@item Sign-extending move and memory load instructions, as in @option{-msmov}
f1e34551 24906@end itemize
d77de738
ML
24907@end table
24908
d77de738 24909@opindex mco-re
ddf6fe37 24910@item -mco-re
d77de738
ML
24911Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24912is implied by @option{-gbtf}.
24913
d77de738 24914@opindex mno-co-re
ddf6fe37 24915@item -mno-co-re
d77de738
ML
24916Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24917support is enabled by default when generating BTF debug information for
24918the BPF target.
24919
24920@item -mxbpf
24921Generate code for an expanded version of BPF, which relaxes some of
24922the restrictions imposed by the BPF architecture:
24923@itemize @minus
24924@item Save and restore callee-saved registers at function entry and
24925exit, respectively.
24926@end itemize
77d0f9ec
CM
24927
24928@opindex masm=@var{dialect}
24929@item -masm=@var{dialect}
24930Outputs assembly instructions using eBPF selected @var{dialect}. The default
24931is @samp{normal}.
24932
24933Supported values for @var{dialect} are:
24934
24935@table @samp
24936@item normal
24937Outputs normal assembly dialect.
24938
24939@item pseudoc
24940Outputs pseudo-c assembly dialect.
24941
24942@end table
24943
d77de738
ML
24944@end table
24945
24946@node FR30 Options
24947@subsection FR30 Options
24948@cindex FR30 Options
24949
24950These options are defined specifically for the FR30 port.
24951
24952@table @gcctabopt
24953
d77de738 24954@opindex msmall-model
ddf6fe37 24955@item -msmall-model
d77de738
ML
24956Use the small address space model. This can produce smaller code, but
24957it does assume that all symbolic values and addresses fit into a
2495820-bit range.
24959
d77de738 24960@opindex mno-lsim
ddf6fe37 24961@item -mno-lsim
d77de738
ML
24962Assume that runtime support has been provided and so there is no need
24963to include the simulator library (@file{libsim.a}) on the linker
24964command line.
24965
24966@end table
24967
24968@node FT32 Options
24969@subsection FT32 Options
24970@cindex FT32 Options
24971
24972These options are defined specifically for the FT32 port.
24973
24974@table @gcctabopt
24975
d77de738 24976@opindex msim
ddf6fe37 24977@item -msim
d77de738
ML
24978Specifies that the program will be run on the simulator. This causes
24979an alternate runtime startup and library to be linked.
24980You must not use this option when generating programs that will run on
24981real hardware; you must provide your own runtime library for whatever
24982I/O functions are needed.
24983
d77de738 24984@opindex mlra
ddf6fe37 24985@item -mlra
d77de738
ML
24986Enable Local Register Allocation. This is still experimental for FT32,
24987so by default the compiler uses standard reload.
24988
d77de738 24989@opindex mnodiv
ddf6fe37 24990@item -mnodiv
d77de738
ML
24991Do not use div and mod instructions.
24992
d77de738 24993@opindex mft32b
ddf6fe37 24994@item -mft32b
d77de738
ML
24995Enable use of the extended instructions of the FT32B processor.
24996
d77de738 24997@opindex mcompress
ddf6fe37 24998@item -mcompress
d77de738
ML
24999Compress all code using the Ft32B code compression scheme.
25000
d77de738 25001@opindex mnopm
ddf6fe37 25002@item -mnopm
d77de738
ML
25003Do not generate code that reads program memory.
25004
25005@end table
25006
25007@node FRV Options
25008@subsection FRV Options
25009@cindex FRV Options
25010
25011@table @gcctabopt
d77de738 25012@opindex mgpr-32
ddf6fe37 25013@item -mgpr-32
d77de738
ML
25014
25015Only use the first 32 general-purpose registers.
25016
d77de738 25017@opindex mgpr-64
ddf6fe37 25018@item -mgpr-64
d77de738
ML
25019
25020Use all 64 general-purpose registers.
25021
d77de738 25022@opindex mfpr-32
ddf6fe37 25023@item -mfpr-32
d77de738
ML
25024
25025Use only the first 32 floating-point registers.
25026
d77de738 25027@opindex mfpr-64
ddf6fe37 25028@item -mfpr-64
d77de738
ML
25029
25030Use all 64 floating-point registers.
25031
d77de738 25032@opindex mhard-float
ddf6fe37 25033@item -mhard-float
d77de738
ML
25034
25035Use hardware instructions for floating-point operations.
25036
d77de738 25037@opindex msoft-float
ddf6fe37 25038@item -msoft-float
d77de738
ML
25039
25040Use library routines for floating-point operations.
25041
d77de738 25042@opindex malloc-cc
ddf6fe37 25043@item -malloc-cc
d77de738
ML
25044
25045Dynamically allocate condition code registers.
25046
d77de738 25047@opindex mfixed-cc
ddf6fe37 25048@item -mfixed-cc
d77de738
ML
25049
25050Do not try to dynamically allocate condition code registers, only
25051use @code{icc0} and @code{fcc0}.
25052
d77de738 25053@opindex mdword
ddf6fe37 25054@item -mdword
d77de738
ML
25055
25056Change ABI to use double word insns.
25057
d77de738
ML
25058@opindex mno-dword
25059@opindex mdword
ddf6fe37 25060@item -mno-dword
d77de738
ML
25061
25062Do not use double word instructions.
25063
d77de738 25064@opindex mdouble
ddf6fe37 25065@item -mdouble
d77de738
ML
25066
25067Use floating-point double instructions.
25068
d77de738 25069@opindex mno-double
ddf6fe37 25070@item -mno-double
d77de738
ML
25071
25072Do not use floating-point double instructions.
25073
d77de738 25074@opindex mmedia
ddf6fe37 25075@item -mmedia
d77de738
ML
25076
25077Use media instructions.
25078
d77de738 25079@opindex mno-media
ddf6fe37 25080@item -mno-media
d77de738
ML
25081
25082Do not use media instructions.
25083
d77de738 25084@opindex mmuladd
ddf6fe37 25085@item -mmuladd
d77de738
ML
25086
25087Use multiply and add/subtract instructions.
25088
d77de738 25089@opindex mno-muladd
ddf6fe37 25090@item -mno-muladd
d77de738
ML
25091
25092Do not use multiply and add/subtract instructions.
25093
d77de738 25094@opindex mfdpic
ddf6fe37 25095@item -mfdpic
d77de738
ML
25096
25097Select the FDPIC ABI, which uses function descriptors to represent
25098pointers to functions. Without any PIC/PIE-related options, it
25099implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
25100assumes GOT entries and small data are within a 12-bit range from the
25101GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
25102are computed with 32 bits.
25103With a @samp{bfin-elf} target, this option implies @option{-msim}.
25104
d77de738 25105@opindex minline-plt
ddf6fe37 25106@item -minline-plt
d77de738
ML
25107
25108Enable inlining of PLT entries in function calls to functions that are
25109not known to bind locally. It has no effect without @option{-mfdpic}.
25110It's enabled by default if optimizing for speed and compiling for
25111shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
25112optimization option such as @option{-O3} or above is present in the
25113command line.
25114
d77de738 25115@opindex mTLS
ddf6fe37 25116@item -mTLS
d77de738
ML
25117
25118Assume a large TLS segment when generating thread-local code.
25119
d77de738 25120@opindex mtls
ddf6fe37 25121@item -mtls
d77de738
ML
25122
25123Do not assume a large TLS segment when generating thread-local code.
25124
d77de738 25125@opindex mgprel-ro
ddf6fe37 25126@item -mgprel-ro
d77de738
ML
25127
25128Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
25129that is known to be in read-only sections. It's enabled by default,
25130except for @option{-fpic} or @option{-fpie}: even though it may help
25131make the global offset table smaller, it trades 1 instruction for 4.
25132With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
25133one of which may be shared by multiple symbols, and it avoids the need
25134for a GOT entry for the referenced symbol, so it's more likely to be a
25135win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
25136
d77de738 25137@opindex multilib-library-pic
ddf6fe37 25138@item -multilib-library-pic
d77de738
ML
25139
25140Link with the (library, not FD) pic libraries. It's implied by
25141@option{-mlibrary-pic}, as well as by @option{-fPIC} and
25142@option{-fpic} without @option{-mfdpic}. You should never have to use
25143it explicitly.
25144
d77de738 25145@opindex mlinked-fp
ddf6fe37 25146@item -mlinked-fp
d77de738
ML
25147
25148Follow the EABI requirement of always creating a frame pointer whenever
25149a stack frame is allocated. This option is enabled by default and can
25150be disabled with @option{-mno-linked-fp}.
25151
d77de738 25152@opindex mlong-calls
ddf6fe37 25153@item -mlong-calls
d77de738
ML
25154
25155Use indirect addressing to call functions outside the current
25156compilation unit. This allows the functions to be placed anywhere
25157within the 32-bit address space.
25158
d77de738 25159@opindex malign-labels
ddf6fe37 25160@item -malign-labels
d77de738
ML
25161
25162Try to align labels to an 8-byte boundary by inserting NOPs into the
25163previous packet. This option only has an effect when VLIW packing
25164is enabled. It doesn't create new packets; it merely adds NOPs to
25165existing ones.
25166
d77de738 25167@opindex mlibrary-pic
ddf6fe37 25168@item -mlibrary-pic
d77de738
ML
25169
25170Generate position-independent EABI code.
25171
d77de738 25172@opindex macc-4
ddf6fe37 25173@item -macc-4
d77de738
ML
25174
25175Use only the first four media accumulator registers.
25176
d77de738 25177@opindex macc-8
ddf6fe37 25178@item -macc-8
d77de738
ML
25179
25180Use all eight media accumulator registers.
25181
d77de738 25182@opindex mpack
ddf6fe37 25183@item -mpack
d77de738
ML
25184
25185Pack VLIW instructions.
25186
d77de738 25187@opindex mno-pack
ddf6fe37 25188@item -mno-pack
d77de738
ML
25189
25190Do not pack VLIW instructions.
25191
d77de738 25192@opindex mno-eflags
ddf6fe37 25193@item -mno-eflags
d77de738
ML
25194
25195Do not mark ABI switches in e_flags.
25196
d77de738 25197@opindex mcond-move
ddf6fe37 25198@item -mcond-move
d77de738
ML
25199
25200Enable the use of conditional-move instructions (default).
25201
25202This switch is mainly for debugging the compiler and will likely be removed
25203in a future version.
25204
d77de738 25205@opindex mno-cond-move
ddf6fe37 25206@item -mno-cond-move
d77de738
ML
25207
25208Disable the use of conditional-move instructions.
25209
25210This switch is mainly for debugging the compiler and will likely be removed
25211in a future version.
25212
d77de738 25213@opindex mscc
ddf6fe37 25214@item -mscc
d77de738
ML
25215
25216Enable the use of conditional set instructions (default).
25217
25218This switch is mainly for debugging the compiler and will likely be removed
25219in a future version.
25220
d77de738 25221@opindex mno-scc
ddf6fe37 25222@item -mno-scc
d77de738
ML
25223
25224Disable the use of conditional set instructions.
25225
25226This switch is mainly for debugging the compiler and will likely be removed
25227in a future version.
25228
d77de738 25229@opindex mcond-exec
ddf6fe37 25230@item -mcond-exec
d77de738
ML
25231
25232Enable the use of conditional execution (default).
25233
25234This switch is mainly for debugging the compiler and will likely be removed
25235in a future version.
25236
d77de738 25237@opindex mno-cond-exec
ddf6fe37 25238@item -mno-cond-exec
d77de738
ML
25239
25240Disable the use of conditional execution.
25241
25242This switch is mainly for debugging the compiler and will likely be removed
25243in a future version.
25244
d77de738 25245@opindex mvliw-branch
ddf6fe37 25246@item -mvliw-branch
d77de738
ML
25247
25248Run a pass to pack branches into VLIW instructions (default).
25249
25250This switch is mainly for debugging the compiler and will likely be removed
25251in a future version.
25252
d77de738 25253@opindex mno-vliw-branch
ddf6fe37 25254@item -mno-vliw-branch
d77de738
ML
25255
25256Do not run a pass to pack branches into VLIW instructions.
25257
25258This switch is mainly for debugging the compiler and will likely be removed
25259in a future version.
25260
d77de738 25261@opindex mmulti-cond-exec
ddf6fe37 25262@item -mmulti-cond-exec
d77de738
ML
25263
25264Enable optimization of @code{&&} and @code{||} in conditional execution
25265(default).
25266
25267This switch is mainly for debugging the compiler and will likely be removed
25268in a future version.
25269
d77de738 25270@opindex mno-multi-cond-exec
ddf6fe37 25271@item -mno-multi-cond-exec
d77de738
ML
25272
25273Disable optimization of @code{&&} and @code{||} in conditional execution.
25274
25275This switch is mainly for debugging the compiler and will likely be removed
25276in a future version.
25277
d77de738 25278@opindex mnested-cond-exec
ddf6fe37 25279@item -mnested-cond-exec
d77de738
ML
25280
25281Enable nested conditional execution optimizations (default).
25282
25283This switch is mainly for debugging the compiler and will likely be removed
25284in a future version.
25285
d77de738 25286@opindex mno-nested-cond-exec
ddf6fe37 25287@item -mno-nested-cond-exec
d77de738
ML
25288
25289Disable nested conditional execution optimizations.
25290
25291This switch is mainly for debugging the compiler and will likely be removed
25292in a future version.
25293
d77de738 25294@opindex moptimize-membar
ddf6fe37 25295@item -moptimize-membar
d77de738
ML
25296
25297This switch removes redundant @code{membar} instructions from the
25298compiler-generated code. It is enabled by default.
25299
d77de738
ML
25300@opindex mno-optimize-membar
25301@opindex moptimize-membar
ddf6fe37 25302@item -mno-optimize-membar
d77de738
ML
25303
25304This switch disables the automatic removal of redundant @code{membar}
25305instructions from the generated code.
25306
d77de738 25307@opindex mtomcat-stats
ddf6fe37 25308@item -mtomcat-stats
d77de738
ML
25309
25310Cause gas to print out tomcat statistics.
25311
d77de738 25312@opindex mcpu
ddf6fe37 25313@item -mcpu=@var{cpu}
d77de738
ML
25314
25315Select the processor type for which to generate code. Possible values are
25316@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
25317@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
25318
25319@end table
25320
25321@node GNU/Linux Options
25322@subsection GNU/Linux Options
25323
25324These @samp{-m} options are defined for GNU/Linux targets:
25325
25326@table @gcctabopt
d77de738 25327@opindex mglibc
ddf6fe37 25328@item -mglibc
d77de738
ML
25329Use the GNU C library. This is the default except
25330on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
25331@samp{*-*-linux-*android*} targets.
25332
d77de738 25333@opindex muclibc
ddf6fe37 25334@item -muclibc
d77de738
ML
25335Use uClibc C library. This is the default on
25336@samp{*-*-linux-*uclibc*} targets.
25337
d77de738 25338@opindex mmusl
ddf6fe37 25339@item -mmusl
d77de738
ML
25340Use the musl C library. This is the default on
25341@samp{*-*-linux-*musl*} targets.
25342
d77de738 25343@opindex mbionic
ddf6fe37 25344@item -mbionic
d77de738
ML
25345Use Bionic C library. This is the default on
25346@samp{*-*-linux-*android*} targets.
25347
d77de738 25348@opindex mandroid
ddf6fe37 25349@item -mandroid
d77de738
ML
25350Compile code compatible with Android platform. This is the default on
25351@samp{*-*-linux-*android*} targets.
25352
25353When compiling, this option enables @option{-mbionic}, @option{-fPIC},
25354@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
25355this option makes the GCC driver pass Android-specific options to the linker.
25356Finally, this option causes the preprocessor macro @code{__ANDROID__}
25357to be defined.
25358
d77de738 25359@opindex tno-android-cc
ddf6fe37 25360@item -tno-android-cc
d77de738
ML
25361Disable compilation effects of @option{-mandroid}, i.e., do not enable
25362@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
25363@option{-fno-rtti} by default.
25364
d77de738 25365@opindex tno-android-ld
ddf6fe37 25366@item -tno-android-ld
d77de738
ML
25367Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
25368linking options to the linker.
25369
25370@end table
25371
25372@node H8/300 Options
25373@subsection H8/300 Options
25374
25375These @samp{-m} options are defined for the H8/300 implementations:
25376
25377@table @gcctabopt
d77de738 25378@opindex mrelax
ddf6fe37 25379@item -mrelax
d77de738
ML
25380Shorten some address references at link time, when possible; uses the
25381linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
25382ld, Using ld}, for a fuller description.
25383
d77de738 25384@opindex mh
ddf6fe37 25385@item -mh
d77de738
ML
25386Generate code for the H8/300H@.
25387
d77de738 25388@opindex ms
ddf6fe37 25389@item -ms
d77de738
ML
25390Generate code for the H8S@.
25391
d77de738 25392@opindex mn
ddf6fe37 25393@item -mn
d77de738
ML
25394Generate code for the H8S and H8/300H in the normal mode. This switch
25395must be used either with @option{-mh} or @option{-ms}.
25396
d77de738 25397@opindex ms2600
ddf6fe37 25398@item -ms2600
d77de738
ML
25399Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25400
d77de738 25401@opindex mexr
ddf6fe37 25402@item -mexr
d77de738
ML
25403Extended registers are stored on stack before execution of function
25404with monitor attribute. Default option is @option{-mexr}.
25405This option is valid only for H8S targets.
25406
d77de738
ML
25407@opindex mno-exr
25408@opindex mexr
ddf6fe37 25409@item -mno-exr
d77de738
ML
25410Extended registers are not stored on stack before execution of function
25411with monitor attribute. Default option is @option{-mno-exr}.
25412This option is valid only for H8S targets.
25413
d77de738 25414@opindex mint32
ddf6fe37 25415@item -mint32
d77de738
ML
25416Make @code{int} data 32 bits by default.
25417
d77de738 25418@opindex malign-300
ddf6fe37 25419@item -malign-300
d77de738
ML
25420On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25421The default for the H8/300H and H8S is to align longs and floats on
254224-byte boundaries.
25423@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25424This option has no effect on the H8/300.
25425@end table
25426
25427@node HPPA Options
25428@subsection HPPA Options
25429@cindex HPPA Options
25430
25431These @samp{-m} options are defined for the HPPA family of computers:
25432
25433@table @gcctabopt
d77de738 25434@opindex march
ddf6fe37 25435@item -march=@var{architecture-type}
d77de738
ML
25436Generate code for the specified architecture. The choices for
25437@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
254381.1, and @samp{2.0} for PA 2.0 processors. Refer to
25439@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25440architecture option for your machine. Code compiled for lower numbered
25441architectures runs on higher numbered architectures, but not the
25442other way around.
25443
d77de738
ML
25444@opindex mpa-risc-1-0
25445@opindex mpa-risc-1-1
25446@opindex mpa-risc-2-0
ddf6fe37
AA
25447@item -mpa-risc-1-0
25448@itemx -mpa-risc-1-1
25449@itemx -mpa-risc-2-0
d77de738
ML
25450Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25451
cf467fb9
JDA
25452@opindex matomic-libcalls
25453@opindex mno-atomic-libcalls
ddf6fe37 25454@item -matomic-libcalls
cf467fb9
JDA
25455Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25456This option is enabled by default. It only affects the generation of
25457atomic libcalls by the HPPA backend.
25458
25459Both the sync and @file{libatomic} libcall implementations use locking.
25460As a result, processor stores are not atomic with respect to other
25461atomic operations. Processor loads up to DImode are atomic with
25462respect to other atomic operations provided they are implemented as
25463a single access.
25464
25465The PA-RISC architecture does not support any atomic operations in
25466hardware except for the @code{ldcw} instruction. Thus, all atomic
25467support is implemented using sync and atomic libcalls. Sync libcall
25468support is in @file{libgcc.a}. Atomic libcall support is in
25469@file{libatomic}.
25470
25471This option generates @code{__atomic_exchange} calls for atomic stores.
25472It also provides special handling for atomic DImode accesses on 32-bit
25473targets.
25474
cf467fb9 25475@opindex mbig-switch
ddf6fe37 25476@item -mbig-switch
cf467fb9
JDA
25477Does nothing. Preserved for backward compatibility.
25478
d77de738 25479@opindex mcaller-copies
ddf6fe37 25480@item -mcaller-copies
d77de738
ML
25481The caller copies function arguments passed by hidden reference. This
25482option should be used with care as it is not compatible with the default
2548332-bit runtime. However, only aggregates larger than eight bytes are
25484passed by hidden reference and the option provides better compatibility
25485with OpenMP.
25486
cf467fb9 25487@opindex mcoherent-ldcw
ddf6fe37 25488@item -mcoherent-ldcw
cf467fb9 25489Use ldcw/ldcd coherent cache-control hint.
d77de738 25490
d77de738 25491@opindex mdisable-fpregs
ddf6fe37 25492@item -mdisable-fpregs
cf467fb9 25493Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25494
d77de738 25495@opindex mdisable-indexing
ddf6fe37 25496@item -mdisable-indexing
d77de738
ML
25497Prevent the compiler from using indexing address modes. This avoids some
25498rather obscure problems when compiling MIG generated code under MACH@.
25499
d77de738 25500@opindex mfast-indirect-calls
ddf6fe37 25501@item -mfast-indirect-calls
d77de738
ML
25502Generate code that assumes calls never cross space boundaries. This
25503allows GCC to emit code that performs faster indirect calls.
25504
25505This option does not work in the presence of shared libraries or nested
25506functions.
25507
d77de738 25508@opindex mfixed-range
ddf6fe37 25509@item -mfixed-range=@var{register-range}
d77de738
ML
25510Generate code treating the given register range as fixed registers.
25511A fixed register is one that the register allocator cannot use. This is
25512useful when compiling kernel code. A register range is specified as
25513two registers separated by a dash. Multiple register ranges can be
25514specified separated by a comma.
25515
d77de738 25516@opindex mgas
ddf6fe37 25517@item -mgas
d77de738
ML
25518Enable the use of assembler directives only GAS understands.
25519
d77de738 25520@opindex mgnu-ld
ddf6fe37 25521@item -mgnu-ld
d77de738
ML
25522Use options specific to GNU @command{ld}.
25523This passes @option{-shared} to @command{ld} when
25524building a shared library. It is the default when GCC is configured,
25525explicitly or implicitly, with the GNU linker. This option does not
25526affect which @command{ld} is called; it only changes what parameters
25527are passed to that @command{ld}.
25528The @command{ld} that is called is determined by the
25529@option{--with-ld} configure option, GCC's program search path, and
25530finally by the user's @env{PATH}. The linker used by GCC can be printed
25531using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25532on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25533
d77de738 25534@opindex mhp-ld
ddf6fe37 25535@item -mhp-ld
d77de738
ML
25536Use options specific to HP @command{ld}.
25537This passes @option{-b} to @command{ld} when building
25538a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25539links. It is the default when GCC is configured, explicitly or
25540implicitly, with the HP linker. This option does not affect
25541which @command{ld} is called; it only changes what parameters are passed to that
25542@command{ld}.
25543The @command{ld} that is called is determined by the @option{--with-ld}
25544configure option, GCC's program search path, and finally by the user's
25545@env{PATH}. The linker used by GCC can be printed using @samp{which
25546`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25547HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25548
cf467fb9 25549@opindex mlinker-opt
ddf6fe37 25550@item -mlinker-opt
cf467fb9
JDA
25551Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25552debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25553linkers in which they give bogus error messages when linking some programs.
25554
d77de738
ML
25555@opindex mno-long-calls
25556@opindex mlong-calls
ddf6fe37 25557@item -mlong-calls
d77de738
ML
25558Generate code that uses long call sequences. This ensures that a call
25559is always able to reach linker generated stubs. The default is to generate
25560long calls only when the distance from the call site to the beginning
25561of the function or translation unit, as the case may be, exceeds a
25562predefined limit set by the branch type being used. The limits for
25563normal calls are 7,600,000 and 240,000 bytes, respectively for the
25564PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25565240,000 bytes.
25566
25567Distances are measured from the beginning of functions when using the
25568@option{-ffunction-sections} option, or when using the @option{-mgas}
25569and @option{-mno-portable-runtime} options together under HP-UX with
25570the SOM linker.
25571
25572It is normally not desirable to use this option as it degrades
25573performance. However, it may be useful in large applications,
25574particularly when partial linking is used to build the application.
25575
25576The types of long calls used depends on the capabilities of the
25577assembler and linker, and the type of code being generated. The
25578impact on systems that support long absolute calls, and long pic
25579symbol-difference or pc-relative calls should be relatively small.
25580However, an indirect call is used on 32-bit ELF systems in pic code
25581and it is quite long.
25582
cf467fb9 25583@opindex mlong-load-store
ddf6fe37 25584@item -mlong-load-store
cf467fb9
JDA
25585Generate 3-instruction load and store sequences as sometimes required by
25586the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25587the HP compilers.
25588
cf467fb9 25589@opindex mjump-in-delay
ddf6fe37 25590@item -mjump-in-delay
cf467fb9
JDA
25591This option is ignored and provided for compatibility purposes only.
25592
cf467fb9
JDA
25593@opindex mno-space-regs
25594@opindex mspace-regs
ddf6fe37 25595@item -mno-space-regs
cf467fb9
JDA
25596Generate code that assumes the target has no space registers. This allows
25597GCC to generate faster indirect calls and use unscaled index address modes.
25598
25599Such code is suitable for level 0 PA systems and kernels.
25600
cf467fb9 25601@opindex mordered
ddf6fe37 25602@item -mordered
cf467fb9
JDA
25603Assume memory references are ordered and barriers are not needed.
25604
cf467fb9 25605@opindex mportable-runtime
ddf6fe37 25606@item -mportable-runtime
cf467fb9
JDA
25607Use the portable calling conventions proposed by HP for ELF systems.
25608
cf467fb9 25609@opindex mschedule
ddf6fe37 25610@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25611Schedule code according to the constraints for the machine type
25612@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25613@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25614to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25615proper scheduling option for your machine. The default scheduling is
25616@samp{8000}.
25617
cf467fb9 25618@opindex msio
ddf6fe37 25619@item -msio
cf467fb9
JDA
25620Generate the predefine, @code{_SIO}, for server IO@. The default is
25621@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25622@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25623options are available under HP-UX and HI-UX@.
25624
cf467fb9 25625@opindex msoft-float
ddf6fe37 25626@item -msoft-float
cf467fb9
JDA
25627Generate output containing library calls for floating point.
25628@strong{Warning:} the requisite libraries are not available for all HPPA
25629targets. Normally the facilities of the machine's usual C compiler are
25630used, but this cannot be done directly in cross-compilation. You must make
25631your own arrangements to provide suitable library functions for
25632cross-compilation.
25633
25634@option{-msoft-float} changes the calling convention in the output file;
25635therefore, it is only useful if you compile @emph{all} of a program with
25636this option. In particular, you need to compile @file{libgcc.a}, the
25637library that comes with GCC, with @option{-msoft-float} in order for
25638this to work.
25639
cf467fb9 25640@opindex msoft-mult
ddf6fe37 25641@item -msoft-mult
cf467fb9
JDA
25642Use software integer multiplication.
25643
25644This disables the use of the @code{xmpyu} instruction.
25645
d77de738 25646@opindex march
ddf6fe37 25647@item -munix=@var{unix-std}
d77de738
ML
25648Generate compiler predefines and select a startfile for the specified
25649UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25650and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25651is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2565211.11 and later. The default values are @samp{93} for HP-UX 10.00,
25653@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25654and later.
25655
25656@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25657@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25658and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25659@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25660@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25661@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25662
25663It is @emph{important} to note that this option changes the interfaces
25664for various library routines. It also affects the operational behavior
25665of the C library. Thus, @emph{extreme} care is needed in using this
25666option.
25667
25668Library code that is intended to operate with more than one UNIX
25669standard must test, set and restore the variable @code{__xpg4_extended_mask}
25670as appropriate. Most GNU software doesn't provide this capability.
25671
d77de738 25672@opindex nolibdld
ddf6fe37 25673@item -nolibdld
d77de738
ML
25674Suppress the generation of link options to search libdld.sl when the
25675@option{-static} option is specified on HP-UX 10 and later.
25676
d77de738 25677@opindex static
ddf6fe37 25678@item -static
d77de738
ML
25679The HP-UX implementation of setlocale in libc has a dependency on
25680libdld.sl. There isn't an archive version of libdld.sl. Thus,
25681when the @option{-static} option is specified, special link options
25682are needed to resolve this dependency.
25683
25684On HP-UX 10 and later, the GCC driver adds the necessary options to
25685link with libdld.sl when the @option{-static} option is specified.
25686This causes the resulting binary to be dynamic. On the 64-bit port,
25687the linkers generate dynamic binaries by default in any case. The
25688@option{-nolibdld} option can be used to prevent the GCC driver from
25689adding these link options.
25690
d77de738 25691@opindex threads
ddf6fe37 25692@item -threads
d77de738
ML
25693Add support for multithreading with the @dfn{dce thread} library
25694under HP-UX@. This option sets flags for both the preprocessor and
25695linker.
25696@end table
25697
25698@node IA-64 Options
25699@subsection IA-64 Options
25700@cindex IA-64 Options
25701
25702These are the @samp{-m} options defined for the Intel IA-64 architecture.
25703
25704@table @gcctabopt
d77de738 25705@opindex mbig-endian
ddf6fe37 25706@item -mbig-endian
d77de738
ML
25707Generate code for a big-endian target. This is the default for HP-UX@.
25708
d77de738 25709@opindex mlittle-endian
ddf6fe37 25710@item -mlittle-endian
d77de738
ML
25711Generate code for a little-endian target. This is the default for AIX5
25712and GNU/Linux.
25713
d77de738
ML
25714@opindex mgnu-as
25715@opindex mno-gnu-as
ddf6fe37
AA
25716@item -mgnu-as
25717@itemx -mno-gnu-as
d77de738
ML
25718Generate (or don't) code for the GNU assembler. This is the default.
25719@c Also, this is the default if the configure option @option{--with-gnu-as}
25720@c is used.
25721
d77de738
ML
25722@opindex mgnu-ld
25723@opindex mno-gnu-ld
ddf6fe37
AA
25724@item -mgnu-ld
25725@itemx -mno-gnu-ld
d77de738
ML
25726Generate (or don't) code for the GNU linker. This is the default.
25727@c Also, this is the default if the configure option @option{--with-gnu-ld}
25728@c is used.
25729
d77de738 25730@opindex mno-pic
ddf6fe37 25731@item -mno-pic
d77de738
ML
25732Generate code that does not use a global pointer register. The result
25733is not position independent code, and violates the IA-64 ABI@.
25734
d77de738
ML
25735@opindex mvolatile-asm-stop
25736@opindex mno-volatile-asm-stop
ddf6fe37
AA
25737@item -mvolatile-asm-stop
25738@itemx -mno-volatile-asm-stop
d77de738
ML
25739Generate (or don't) a stop bit immediately before and after volatile asm
25740statements.
25741
d77de738
ML
25742@opindex mregister-names
25743@opindex mno-register-names
ddf6fe37
AA
25744@item -mregister-names
25745@itemx -mno-register-names
d77de738
ML
25746Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25747the stacked registers. This may make assembler output more readable.
25748
d77de738
ML
25749@opindex mno-sdata
25750@opindex msdata
ddf6fe37
AA
25751@item -mno-sdata
25752@itemx -msdata
d77de738
ML
25753Disable (or enable) optimizations that use the small data section. This may
25754be useful for working around optimizer bugs.
25755
d77de738 25756@opindex mconstant-gp
ddf6fe37 25757@item -mconstant-gp
d77de738
ML
25758Generate code that uses a single constant global pointer value. This is
25759useful when compiling kernel code.
25760
d77de738 25761@opindex mauto-pic
ddf6fe37 25762@item -mauto-pic
d77de738
ML
25763Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25764This is useful when compiling firmware code.
25765
d77de738 25766@opindex minline-float-divide-min-latency
ddf6fe37 25767@item -minline-float-divide-min-latency
d77de738
ML
25768Generate code for inline divides of floating-point values
25769using the minimum latency algorithm.
25770
d77de738 25771@opindex minline-float-divide-max-throughput
ddf6fe37 25772@item -minline-float-divide-max-throughput
d77de738
ML
25773Generate code for inline divides of floating-point values
25774using the maximum throughput algorithm.
25775
d77de738 25776@opindex mno-inline-float-divide
ddf6fe37 25777@item -mno-inline-float-divide
d77de738
ML
25778Do not generate inline code for divides of floating-point values.
25779
d77de738 25780@opindex minline-int-divide-min-latency
ddf6fe37 25781@item -minline-int-divide-min-latency
d77de738
ML
25782Generate code for inline divides of integer values
25783using the minimum latency algorithm.
25784
d77de738 25785@opindex minline-int-divide-max-throughput
ddf6fe37 25786@item -minline-int-divide-max-throughput
d77de738
ML
25787Generate code for inline divides of integer values
25788using the maximum throughput algorithm.
25789
d77de738
ML
25790@opindex mno-inline-int-divide
25791@opindex minline-int-divide
ddf6fe37 25792@item -mno-inline-int-divide
d77de738
ML
25793Do not generate inline code for divides of integer values.
25794
d77de738 25795@opindex minline-sqrt-min-latency
ddf6fe37 25796@item -minline-sqrt-min-latency
d77de738
ML
25797Generate code for inline square roots
25798using the minimum latency algorithm.
25799
d77de738 25800@opindex minline-sqrt-max-throughput
ddf6fe37 25801@item -minline-sqrt-max-throughput
d77de738
ML
25802Generate code for inline square roots
25803using the maximum throughput algorithm.
25804
d77de738 25805@opindex mno-inline-sqrt
ddf6fe37 25806@item -mno-inline-sqrt
d77de738
ML
25807Do not generate inline code for @code{sqrt}.
25808
d77de738
ML
25809@opindex mfused-madd
25810@opindex mno-fused-madd
ddf6fe37
AA
25811@item -mfused-madd
25812@itemx -mno-fused-madd
d77de738
ML
25813Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25814instructions. The default is to use these instructions.
25815
d77de738
ML
25816@opindex mno-dwarf2-asm
25817@opindex mdwarf2-asm
ddf6fe37
AA
25818@item -mno-dwarf2-asm
25819@itemx -mdwarf2-asm
d77de738
ML
25820Don't (or do) generate assembler code for the DWARF line number debugging
25821info. This may be useful when not using the GNU assembler.
25822
d77de738
ML
25823@opindex mearly-stop-bits
25824@opindex mno-early-stop-bits
ddf6fe37
AA
25825@item -mearly-stop-bits
25826@itemx -mno-early-stop-bits
d77de738
ML
25827Allow stop bits to be placed earlier than immediately preceding the
25828instruction that triggered the stop bit. This can improve instruction
25829scheduling, but does not always do so.
25830
d77de738 25831@opindex mfixed-range
ddf6fe37 25832@item -mfixed-range=@var{register-range}
d77de738
ML
25833Generate code treating the given register range as fixed registers.
25834A fixed register is one that the register allocator cannot use. This is
25835useful when compiling kernel code. A register range is specified as
25836two registers separated by a dash. Multiple register ranges can be
25837specified separated by a comma.
25838
d77de738 25839@opindex mtls-size
ddf6fe37 25840@item -mtls-size=@var{tls-size}
d77de738
ML
25841Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2584264.
25843
d77de738 25844@opindex mtune
ddf6fe37 25845@item -mtune=@var{cpu-type}
d77de738
ML
25846Tune the instruction scheduling for a particular CPU, Valid values are
25847@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25848and @samp{mckinley}.
25849
d77de738
ML
25850@opindex milp32
25851@opindex mlp64
ddf6fe37
AA
25852@item -milp32
25853@itemx -mlp64
d77de738
ML
25854Generate code for a 32-bit or 64-bit environment.
25855The 32-bit environment sets int, long and pointer to 32 bits.
25856The 64-bit environment sets int to 32 bits and long and pointer
25857to 64 bits. These are HP-UX specific flags.
25858
d77de738
ML
25859@opindex mno-sched-br-data-spec
25860@opindex msched-br-data-spec
ddf6fe37
AA
25861@item -mno-sched-br-data-spec
25862@itemx -msched-br-data-spec
d77de738
ML
25863(Dis/En)able data speculative scheduling before reload.
25864This results in generation of @code{ld.a} instructions and
25865the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25866The default setting is disabled.
25867
d77de738
ML
25868@opindex msched-ar-data-spec
25869@opindex mno-sched-ar-data-spec
ddf6fe37
AA
25870@item -msched-ar-data-spec
25871@itemx -mno-sched-ar-data-spec
d77de738
ML
25872(En/Dis)able data speculative scheduling after reload.
25873This results in generation of @code{ld.a} instructions and
25874the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25875The default setting is enabled.
25876
d77de738
ML
25877@opindex mno-sched-control-spec
25878@opindex msched-control-spec
ddf6fe37
AA
25879@item -mno-sched-control-spec
25880@itemx -msched-control-spec
d77de738
ML
25881(Dis/En)able control speculative scheduling. This feature is
25882available only during region scheduling (i.e.@: before reload).
25883This results in generation of the @code{ld.s} instructions and
25884the corresponding check instructions @code{chk.s}.
25885The default setting is disabled.
25886
d77de738
ML
25887@opindex msched-br-in-data-spec
25888@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
25889@item -msched-br-in-data-spec
25890@itemx -mno-sched-br-in-data-spec
d77de738
ML
25891(En/Dis)able speculative scheduling of the instructions that
25892are dependent on the data speculative loads before reload.
25893This is effective only with @option{-msched-br-data-spec} enabled.
25894The default setting is enabled.
25895
d77de738
ML
25896@opindex msched-ar-in-data-spec
25897@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
25898@item -msched-ar-in-data-spec
25899@itemx -mno-sched-ar-in-data-spec
d77de738
ML
25900(En/Dis)able speculative scheduling of the instructions that
25901are dependent on the data speculative loads after reload.
25902This is effective only with @option{-msched-ar-data-spec} enabled.
25903The default setting is enabled.
25904
d77de738
ML
25905@opindex msched-in-control-spec
25906@opindex mno-sched-in-control-spec
ddf6fe37
AA
25907@item -msched-in-control-spec
25908@itemx -mno-sched-in-control-spec
d77de738
ML
25909(En/Dis)able speculative scheduling of the instructions that
25910are dependent on the control speculative loads.
25911This is effective only with @option{-msched-control-spec} enabled.
25912The default setting is enabled.
25913
d77de738
ML
25914@opindex mno-sched-prefer-non-data-spec-insns
25915@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
25916@item -mno-sched-prefer-non-data-spec-insns
25917@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
25918If enabled, data-speculative instructions are chosen for schedule
25919only if there are no other choices at the moment. This makes
25920the use of the data speculation much more conservative.
25921The default setting is disabled.
25922
d77de738
ML
25923@opindex mno-sched-prefer-non-control-spec-insns
25924@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
25925@item -mno-sched-prefer-non-control-spec-insns
25926@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
25927If enabled, control-speculative instructions are chosen for schedule
25928only if there are no other choices at the moment. This makes
25929the use of the control speculation much more conservative.
25930The default setting is disabled.
25931
d77de738
ML
25932@opindex mno-sched-count-spec-in-critical-path
25933@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
25934@item -mno-sched-count-spec-in-critical-path
25935@itemx -msched-count-spec-in-critical-path
d77de738
ML
25936If enabled, speculative dependencies are considered during
25937computation of the instructions priorities. This makes the use of the
25938speculation a bit more conservative.
25939The default setting is disabled.
25940
d77de738 25941@opindex msched-spec-ldc
ddf6fe37 25942@item -msched-spec-ldc
d77de738
ML
25943Use a simple data speculation check. This option is on by default.
25944
d77de738 25945@opindex msched-spec-ldc
ddf6fe37 25946@item -msched-control-spec-ldc
d77de738
ML
25947Use a simple check for control speculation. This option is on by default.
25948
d77de738 25949@opindex msched-stop-bits-after-every-cycle
ddf6fe37 25950@item -msched-stop-bits-after-every-cycle
d77de738
ML
25951Place a stop bit after every cycle when scheduling. This option is on
25952by default.
25953
d77de738 25954@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 25955@item -msched-fp-mem-deps-zero-cost
d77de738
ML
25956Assume that floating-point stores and loads are not likely to cause a conflict
25957when placed into the same instruction group. This option is disabled by
25958default.
25959
d77de738 25960@opindex msel-sched-dont-check-control-spec
ddf6fe37 25961@item -msel-sched-dont-check-control-spec
d77de738
ML
25962Generate checks for control speculation in selective scheduling.
25963This flag is disabled by default.
25964
d77de738 25965@opindex msched-max-memory-insns
ddf6fe37 25966@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
25967Limit on the number of memory insns per instruction group, giving lower
25968priority to subsequent memory insns attempting to schedule in the same
25969instruction group. Frequently useful to prevent cache bank conflicts.
25970The default value is 1.
25971
d77de738 25972@opindex msched-max-memory-insns-hard-limit
ddf6fe37 25973@item -msched-max-memory-insns-hard-limit
d77de738
ML
25974Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25975disallowing more than that number in an instruction group.
25976Otherwise, the limit is ``soft'', meaning that non-memory operations
25977are preferred when the limit is reached, but memory operations may still
25978be scheduled.
25979
25980@end table
25981
25982@node LM32 Options
25983@subsection LM32 Options
25984@cindex LM32 options
25985
25986These @option{-m} options are defined for the LatticeMico32 architecture:
25987
25988@table @gcctabopt
d77de738 25989@opindex mbarrel-shift-enabled
ddf6fe37 25990@item -mbarrel-shift-enabled
d77de738
ML
25991Enable barrel-shift instructions.
25992
d77de738 25993@opindex mdivide-enabled
ddf6fe37 25994@item -mdivide-enabled
d77de738
ML
25995Enable divide and modulus instructions.
25996
d77de738 25997@opindex multiply-enabled
ddf6fe37 25998@item -mmultiply-enabled
d77de738
ML
25999Enable multiply instructions.
26000
d77de738 26001@opindex msign-extend-enabled
ddf6fe37 26002@item -msign-extend-enabled
d77de738
ML
26003Enable sign extend instructions.
26004
d77de738 26005@opindex muser-enabled
ddf6fe37 26006@item -muser-enabled
d77de738
ML
26007Enable user-defined instructions.
26008
26009@end table
26010
26011@node LoongArch Options
26012@subsection LoongArch Options
26013@cindex LoongArch Options
26014
26015These command-line options are defined for LoongArch targets:
26016
26017@table @gcctabopt
9c19597c 26018@opindex march
ddf6fe37 26019@item -march=@var{cpu-type}
d77de738
ML
26020Generate instructions for the machine type @var{cpu-type}. In contrast to
26021@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
26022for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
26023to generate code that may not run at all on processors other than the one
26024indicated. Specifying @option{-march=@var{cpu-type}} implies
26025@option{-mtune=@var{cpu-type}}, except where noted otherwise.
26026
26027The choices for @var{cpu-type} are:
26028
26029@table @samp
26030@item native
26031This selects the CPU to generate code for at compilation time by determining
26032the processor type of the compiling machine. Using @option{-march=native}
26033enables all instruction subsets supported by the local machine (hence
26034the result might not run on different machines). Using @option{-mtune=native}
26035produces code optimized for the local machine under the constraints
26036of the selected instruction set.
26037@item loongarch64
26038A generic CPU with 64-bit extensions.
26039@item la464
26040LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
26041@end table
26042
d77de738 26043@opindex mtune
ddf6fe37 26044@item -mtune=@var{cpu-type}
d77de738
ML
26045Optimize the output for the given processor, specified by microarchitecture
26046name.
26047
d77de738 26048@opindex mabi
ddf6fe37 26049@item -mabi=@var{base-abi-type}
d77de738
ML
26050Generate code for the specified calling convention.
26051@var{base-abi-type} can be one of:
26052@table @samp
26053@item lp64d
26054Uses 64-bit general purpose registers and 32/64-bit floating-point
26055registers for parameter passing. Data model is LP64, where @samp{int}
26056is 32 bits, while @samp{long int} and pointers are 64 bits.
26057@item lp64f
26058Uses 64-bit general purpose registers and 32-bit floating-point
26059registers for parameter passing. Data model is LP64, where @samp{int}
26060is 32 bits, while @samp{long int} and pointers are 64 bits.
26061@item lp64s
26062Uses 64-bit general purpose registers and no floating-point
26063registers for parameter passing. Data model is LP64, where @samp{int}
26064is 32 bits, while @samp{long int} and pointers are 64 bits.
26065@end table
26066
d77de738 26067@opindex mfpu
ddf6fe37 26068@item -mfpu=@var{fpu-type}
d77de738
ML
26069Generate code for the specified FPU type, which can be one of:
26070@table @samp
26071@item 64
26072Allow the use of hardware floating-point instructions for 32-bit
26073and 64-bit operations.
26074@item 32
26075Allow the use of hardware floating-point instructions for 32-bit
26076operations.
26077@item none
26078@item 0
26079Prevent the use of hardware floating-point instructions.
26080@end table
26081
bb4a8198
YY
26082@opindex msimd
26083@item -msimd=@var{simd-type}
26084Enable generation of LoongArch SIMD instructions for vectorization
26085and via builtin functions. The value can be one of:
26086@table @samp
26087@item lasx
26088Enable generating instructions from the 256-bit LoongArch Advanced
26089SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
26090@item lsx
26091Enable generating instructions from the 128-bit LoongArch SIMD
26092Extension (LSX).
26093@item none
26094No LoongArch SIMD instruction may be generated.
26095@end table
26096
d77de738 26097@opindex msoft-float
ddf6fe37 26098@item -msoft-float
d77de738
ML
26099Force @option{-mfpu=none} and prevents the use of floating-point
26100registers for parameter passing. This option may change the target
26101ABI.
26102
9c19597c 26103@opindex msingle-float
ddf6fe37 26104@item -msingle-float
d77de738
ML
26105Force @option{-mfpu=32} and allow the use of 32-bit floating-point
26106registers for parameter passing. This option may change the target
26107ABI.
26108
9c19597c 26109@opindex mdouble-float
ddf6fe37 26110@item -mdouble-float
d77de738
ML
26111Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
26112registers for parameter passing. This option may change the target
26113ABI.
26114
bb4a8198
YY
26115@opindex ml[a]sx
26116@item -mlasx
26117@itemx -mno-lasx
26118@item -mlsx
26119@itemx -mno-lsx
26120Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
26121that can be used by the compiler for code generation. Enabling LASX with
26122@option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
26123automatically disables LASX. These driver-only options act upon the final
26124@option{msimd} configuration state and make incremental chagnes in the order
26125they appear on the GCC driver's command line, deriving the final / canonicalized
26126@option{msimd} option that is passed to the compiler proper.
26127
9c19597c 26128@opindex mbranch-cost
ddf6fe37 26129@item -mbranch-cost=@var{n}
d77de738
ML
26130Set the cost of branches to roughly @var{n} instructions.
26131
ddf6fe37 26132@opindex mcheck-zero-division
d77de738
ML
26133@item -mcheck-zero-division
26134@itemx -mno-check-zero-divison
d77de738
ML
26135Trap (do not trap) on integer division by zero. The default is
26136@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
26137@option{-mno-check-zero-division} for other optimization levels.
26138
ddf6fe37 26139@opindex mcond-move-int
d77de738
ML
26140@item -mcond-move-int
26141@itemx -mno-cond-move-int
d77de738
ML
26142Conditional moves for integral data in general-purpose registers
26143are enabled (disabled). The default is @option{-mcond-move-int}.
26144
ddf6fe37 26145@opindex mcond-move-float
d77de738
ML
26146@item -mcond-move-float
26147@itemx -mno-cond-move-float
d77de738
ML
26148Conditional moves for floating-point registers are enabled (disabled).
26149The default is @option{-mcond-move-float}.
26150
ddf6fe37 26151@opindex mmemcpy
d77de738
ML
26152@item -mmemcpy
26153@itemx -mno-memcpy
d77de738
ML
26154Force (do not force) the use of @code{memcpy} for non-trivial block moves.
26155The default is @option{-mno-memcpy}, which allows GCC to inline most
26156constant-sized copies. Setting optimization level to @option{-Os} also
26157forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
26158behavior if explicitly specified, regardless of the order these options on
26159the command line.
26160
ddf6fe37 26161@opindex mstrict-align
d77de738
ML
26162@item -mstrict-align
26163@itemx -mno-strict-align
d77de738
ML
26164Avoid or allow generating memory accesses that may not be aligned on a natural
26165object boundary as described in the architecture specification. The default is
26166@option{-mno-strict-align}.
26167
9c19597c 26168@opindex msmall-data-limit
ddf6fe37 26169@item -msmall-data-limit=@var{number}
d77de738
ML
26170Put global and static data smaller than @var{number} bytes into a special
26171section (on some targets). The default value is 0.
26172
9c19597c 26173@opindex mmax-inline-memcpy-size
ddf6fe37 26174@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
26175Inline all block moves (such as calls to @code{memcpy} or structure copies)
26176less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
26177
26178@item -mcmodel=@var{code-model}
26179Set the code model to one of:
26180@table @samp
26181@item tiny-static (Not implemented yet)
26182@item tiny (Not implemented yet)
26183
26184@item normal
26185The text segment must be within 128MB addressing space. The data segment must
26186be within 2GB addressing space.
26187
26188@item medium
26189The text segment and data segment must be within 2GB addressing space.
26190
26191@item large (Not implemented yet)
26192
26193@item extreme
26194This mode does not limit the size of the code segment and data segment.
26195The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
26196@option{-mno-explicit-relocs}.
26197@end table
26198The default code model is @code{normal}.
26199
d77de738
ML
26200@opindex mexplicit-relocs
26201@opindex mno-explicit-relocs
ddf6fe37
AA
26202@item -mexplicit-relocs
26203@itemx -mno-explicit-relocs
d77de738
ML
26204Use or do not use assembler relocation operators when dealing with symbolic
26205addresses. The alternative is to use assembler macros instead, which may
c25d6f15
XR
26206limit instruction scheduling but allow linker relaxation. The default
26207value for the option is determined during GCC build-time by detecting
26208corresponding assembler support:
26209@code{-mno-explicit-relocs} if the assembler supports relaxation or it
26210does not support relocation operators at all,
26211@code{-mexplicit-relocs} otherwise. This option is mostly useful for
d77de738
ML
26212debugging, or interoperation with assemblers different from the build-time
26213one.
26214
ddf6fe37 26215@opindex mdirect-extern-access
d77de738
ML
26216@item -mdirect-extern-access
26217@itemx -mno-direct-extern-access
d77de738
ML
26218Do not use or use GOT to access external symbols. The default is
26219@option{-mno-direct-extern-access}: GOT is used for external symbols with
26220default visibility, but not used for other external symbols.
26221
26222With @option{-mdirect-extern-access}, GOT is not used and all external
26223symbols are PC-relatively addressed. It is @strong{only} suitable for
26224environments where no dynamic link is performed, like firmwares, OS
26225kernels, executables linked with @option{-static} or @option{-static-pie}.
26226@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
26227@option{-fpic}.
26228@end table
26229
bb4a8198 26230
d77de738
ML
26231@node M32C Options
26232@subsection M32C Options
26233@cindex M32C options
26234
26235@table @gcctabopt
d77de738 26236@opindex mcpu=
ddf6fe37 26237@item -mcpu=@var{name}
d77de738
ML
26238Select the CPU for which code is generated. @var{name} may be one of
26239@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
26240/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
26241the M32C/80 series.
26242
d77de738 26243@opindex msim
ddf6fe37 26244@item -msim
d77de738
ML
26245Specifies that the program will be run on the simulator. This causes
26246an alternate runtime library to be linked in which supports, for
26247example, file I/O@. You must not use this option when generating
26248programs that will run on real hardware; you must provide your own
26249runtime library for whatever I/O functions are needed.
26250
d77de738 26251@opindex memregs=
ddf6fe37 26252@item -memregs=@var{number}
d77de738
ML
26253Specifies the number of memory-based pseudo-registers GCC uses
26254during code generation. These pseudo-registers are used like real
26255registers, so there is a tradeoff between GCC's ability to fit the
26256code into available registers, and the performance penalty of using
26257memory instead of registers. Note that all modules in a program must
26258be compiled with the same value for this option. Because of that, you
26259must not use this option with GCC's default runtime libraries.
26260
26261@end table
26262
26263@node M32R/D Options
26264@subsection M32R/D Options
26265@cindex M32R/D options
26266
26267These @option{-m} options are defined for Renesas M32R/D architectures:
26268
26269@table @gcctabopt
d77de738 26270@opindex m32r2
ddf6fe37 26271@item -m32r2
d77de738
ML
26272Generate code for the M32R/2@.
26273
d77de738 26274@opindex m32rx
ddf6fe37 26275@item -m32rx
d77de738
ML
26276Generate code for the M32R/X@.
26277
d77de738 26278@opindex m32r
ddf6fe37 26279@item -m32r
d77de738
ML
26280Generate code for the M32R@. This is the default.
26281
d77de738 26282@opindex mmodel=small
ddf6fe37 26283@item -mmodel=small
d77de738
ML
26284Assume all objects live in the lower 16MB of memory (so that their addresses
26285can be loaded with the @code{ld24} instruction), and assume all subroutines
26286are reachable with the @code{bl} instruction.
26287This is the default.
26288
26289The addressability of a particular object can be set with the
26290@code{model} attribute.
26291
d77de738 26292@opindex mmodel=medium
ddf6fe37 26293@item -mmodel=medium
d77de738
ML
26294Assume objects may be anywhere in the 32-bit address space (the compiler
26295generates @code{seth/add3} instructions to load their addresses), and
26296assume all subroutines are reachable with the @code{bl} instruction.
26297
d77de738 26298@opindex mmodel=large
ddf6fe37 26299@item -mmodel=large
d77de738
ML
26300Assume objects may be anywhere in the 32-bit address space (the compiler
26301generates @code{seth/add3} instructions to load their addresses), and
26302assume subroutines may not be reachable with the @code{bl} instruction
26303(the compiler generates the much slower @code{seth/add3/jl}
26304instruction sequence).
26305
d77de738 26306@opindex msdata=none
ddf6fe37 26307@item -msdata=none
d77de738
ML
26308Disable use of the small data area. Variables are put into
26309one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
26310@code{section} attribute has been specified).
26311This is the default.
26312
26313The small data area consists of sections @code{.sdata} and @code{.sbss}.
26314Objects may be explicitly put in the small data area with the
26315@code{section} attribute using one of these sections.
26316
d77de738 26317@opindex msdata=sdata
ddf6fe37 26318@item -msdata=sdata
d77de738
ML
26319Put small global and static data in the small data area, but do not
26320generate special code to reference them.
26321
d77de738 26322@opindex msdata=use
ddf6fe37 26323@item -msdata=use
d77de738
ML
26324Put small global and static data in the small data area, and generate
26325special instructions to reference them.
26326
d77de738
ML
26327@opindex G
26328@cindex smaller data references
f33d7a88 26329@item -G @var{num}
d77de738
ML
26330Put global and static objects less than or equal to @var{num} bytes
26331into the small data or BSS sections instead of the normal data or BSS
26332sections. The default value of @var{num} is 8.
26333The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
26334for this option to have any effect.
26335
26336All modules should be compiled with the same @option{-G @var{num}} value.
26337Compiling with different values of @var{num} may or may not work; if it
26338doesn't the linker gives an error message---incorrect code is not
26339generated.
26340
d77de738 26341@opindex mdebug
ddf6fe37 26342@item -mdebug
d77de738
ML
26343Makes the M32R-specific code in the compiler display some statistics
26344that might help in debugging programs.
26345
d77de738 26346@opindex malign-loops
ddf6fe37 26347@item -malign-loops
d77de738
ML
26348Align all loops to a 32-byte boundary.
26349
d77de738 26350@opindex mno-align-loops
ddf6fe37 26351@item -mno-align-loops
d77de738
ML
26352Do not enforce a 32-byte alignment for loops. This is the default.
26353
d77de738 26354@opindex missue-rate=@var{number}
ddf6fe37 26355@item -missue-rate=@var{number}
d77de738
ML
26356Issue @var{number} instructions per cycle. @var{number} can only be 1
26357or 2.
26358
d77de738 26359@opindex mbranch-cost=@var{number}
ddf6fe37 26360@item -mbranch-cost=@var{number}
d77de738
ML
26361@var{number} can only be 1 or 2. If it is 1 then branches are
26362preferred over conditional code, if it is 2, then the opposite applies.
26363
d77de738 26364@opindex mflush-trap=@var{number}
ddf6fe37 26365@item -mflush-trap=@var{number}
d77de738
ML
26366Specifies the trap number to use to flush the cache. The default is
2636712. Valid numbers are between 0 and 15 inclusive.
26368
d77de738 26369@opindex mno-flush-trap
ddf6fe37 26370@item -mno-flush-trap
d77de738
ML
26371Specifies that the cache cannot be flushed by using a trap.
26372
d77de738 26373@opindex mflush-func=@var{name}
ddf6fe37 26374@item -mflush-func=@var{name}
d77de738
ML
26375Specifies the name of the operating system function to call to flush
26376the cache. The default is @samp{_flush_cache}, but a function call
26377is only used if a trap is not available.
26378
d77de738 26379@opindex mno-flush-func
ddf6fe37 26380@item -mno-flush-func
d77de738
ML
26381Indicates that there is no OS function for flushing the cache.
26382
26383@end table
26384
26385@node M680x0 Options
26386@subsection M680x0 Options
26387@cindex M680x0 options
26388
26389These are the @samp{-m} options defined for M680x0 and ColdFire processors.
26390The default settings depend on which architecture was selected when
26391the compiler was configured; the defaults for the most common choices
26392are given below.
26393
26394@table @gcctabopt
d77de738 26395@opindex march
ddf6fe37 26396@item -march=@var{arch}
d77de738
ML
26397Generate code for a specific M680x0 or ColdFire instruction set
26398architecture. Permissible values of @var{arch} for M680x0
26399architectures are: @samp{68000}, @samp{68010}, @samp{68020},
26400@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
26401architectures are selected according to Freescale's ISA classification
26402and the permissible values are: @samp{isaa}, @samp{isaaplus},
26403@samp{isab} and @samp{isac}.
26404
26405GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
26406code for a ColdFire target. The @var{arch} in this macro is one of the
26407@option{-march} arguments given above.
26408
26409When used together, @option{-march} and @option{-mtune} select code
26410that runs on a family of similar processors but that is optimized
26411for a particular microarchitecture.
26412
d77de738 26413@opindex mcpu
ddf6fe37 26414@item -mcpu=@var{cpu}
d77de738
ML
26415Generate code for a specific M680x0 or ColdFire processor.
26416The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
26417@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
26418and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
26419below, which also classifies the CPUs into families:
26420
26421@multitable @columnfractions 0.20 0.80
26422@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
26423@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}
26424@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
26425@item @samp{5206e} @tab @samp{5206e}
26426@item @samp{5208} @tab @samp{5207} @samp{5208}
26427@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26428@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26429@item @samp{5216} @tab @samp{5214} @samp{5216}
26430@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26431@item @samp{5225} @tab @samp{5224} @samp{5225}
26432@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26433@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26434@item @samp{5249} @tab @samp{5249}
26435@item @samp{5250} @tab @samp{5250}
26436@item @samp{5271} @tab @samp{5270} @samp{5271}
26437@item @samp{5272} @tab @samp{5272}
26438@item @samp{5275} @tab @samp{5274} @samp{5275}
26439@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26440@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26441@item @samp{5307} @tab @samp{5307}
26442@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26443@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26444@item @samp{5407} @tab @samp{5407}
26445@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}
26446@end multitable
26447
26448@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26449@var{arch} is compatible with @var{cpu}. Other combinations of
26450@option{-mcpu} and @option{-march} are rejected.
26451
26452GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26453@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26454where the value of @var{family} is given by the table above.
26455
d77de738 26456@opindex mtune
ddf6fe37 26457@item -mtune=@var{tune}
d77de738
ML
26458Tune the code for a particular microarchitecture within the
26459constraints set by @option{-march} and @option{-mcpu}.
26460The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26461@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26462and @samp{cpu32}. The ColdFire microarchitectures
26463are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26464
26465You can also use @option{-mtune=68020-40} for code that needs
26466to run relatively well on 68020, 68030 and 68040 targets.
26467@option{-mtune=68020-60} is similar but includes 68060 targets
26468as well. These two options select the same tuning decisions as
26469@option{-m68020-40} and @option{-m68020-60} respectively.
26470
26471GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26472when tuning for 680x0 architecture @var{arch}. It also defines
26473@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26474option is used. If GCC is tuning for a range of architectures,
26475as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26476it defines the macros for every architecture in the range.
26477
26478GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26479ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26480of the arguments given above.
26481
d77de738
ML
26482@opindex m68000
26483@opindex mc68000
ddf6fe37
AA
26484@item -m68000
26485@itemx -mc68000
d77de738
ML
26486Generate output for a 68000. This is the default
26487when the compiler is configured for 68000-based systems.
26488It is equivalent to @option{-march=68000}.
26489
26490Use this option for microcontrollers with a 68000 or EC000 core,
26491including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26492
d77de738 26493@opindex m68010
ddf6fe37 26494@item -m68010
d77de738
ML
26495Generate output for a 68010. This is the default
26496when the compiler is configured for 68010-based systems.
26497It is equivalent to @option{-march=68010}.
26498
d77de738
ML
26499@opindex m68020
26500@opindex mc68020
ddf6fe37
AA
26501@item -m68020
26502@itemx -mc68020
d77de738
ML
26503Generate output for a 68020. This is the default
26504when the compiler is configured for 68020-based systems.
26505It is equivalent to @option{-march=68020}.
26506
d77de738 26507@opindex m68030
ddf6fe37 26508@item -m68030
d77de738
ML
26509Generate output for a 68030. This is the default when the compiler is
26510configured for 68030-based systems. It is equivalent to
26511@option{-march=68030}.
26512
d77de738 26513@opindex m68040
ddf6fe37 26514@item -m68040
d77de738
ML
26515Generate output for a 68040. This is the default when the compiler is
26516configured for 68040-based systems. It is equivalent to
26517@option{-march=68040}.
26518
26519This option inhibits the use of 68881/68882 instructions that have to be
26520emulated by software on the 68040. Use this option if your 68040 does not
26521have code to emulate those instructions.
26522
d77de738 26523@opindex m68060
ddf6fe37 26524@item -m68060
d77de738
ML
26525Generate output for a 68060. This is the default when the compiler is
26526configured for 68060-based systems. It is equivalent to
26527@option{-march=68060}.
26528
26529This option inhibits the use of 68020 and 68881/68882 instructions that
26530have to be emulated by software on the 68060. Use this option if your 68060
26531does not have code to emulate those instructions.
26532
d77de738 26533@opindex mcpu32
ddf6fe37 26534@item -mcpu32
d77de738
ML
26535Generate output for a CPU32. This is the default
26536when the compiler is configured for CPU32-based systems.
26537It is equivalent to @option{-march=cpu32}.
26538
26539Use this option for microcontrollers with a
26540CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2654168336, 68340, 68341, 68349 and 68360.
26542
d77de738 26543@opindex m5200
ddf6fe37 26544@item -m5200
d77de738
ML
26545Generate output for a 520X ColdFire CPU@. This is the default
26546when the compiler is configured for 520X-based systems.
26547It is equivalent to @option{-mcpu=5206}, and is now deprecated
26548in favor of that option.
26549
26550Use this option for microcontroller with a 5200 core, including
26551the MCF5202, MCF5203, MCF5204 and MCF5206.
26552
d77de738 26553@opindex m5206e
ddf6fe37 26554@item -m5206e
d77de738
ML
26555Generate output for a 5206e ColdFire CPU@. The option is now
26556deprecated in favor of the equivalent @option{-mcpu=5206e}.
26557
d77de738 26558@opindex m528x
ddf6fe37 26559@item -m528x
d77de738
ML
26560Generate output for a member of the ColdFire 528X family.
26561The option is now deprecated in favor of the equivalent
26562@option{-mcpu=528x}.
26563
d77de738 26564@opindex m5307
ddf6fe37 26565@item -m5307
d77de738
ML
26566Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26567in favor of the equivalent @option{-mcpu=5307}.
26568
d77de738 26569@opindex m5407
ddf6fe37 26570@item -m5407
d77de738
ML
26571Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26572in favor of the equivalent @option{-mcpu=5407}.
26573
d77de738 26574@opindex mcfv4e
ddf6fe37 26575@item -mcfv4e
d77de738
ML
26576Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26577This includes use of hardware floating-point instructions.
26578The option is equivalent to @option{-mcpu=547x}, and is now
26579deprecated in favor of that option.
26580
d77de738 26581@opindex m68020-40
ddf6fe37 26582@item -m68020-40
d77de738
ML
26583Generate output for a 68040, without using any of the new instructions.
26584This results in code that can run relatively efficiently on either a
2658568020/68881 or a 68030 or a 68040. The generated code does use the
2658668881 instructions that are emulated on the 68040.
26587
26588The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26589
d77de738 26590@opindex m68020-60
ddf6fe37 26591@item -m68020-60
d77de738
ML
26592Generate output for a 68060, without using any of the new instructions.
26593This results in code that can run relatively efficiently on either a
2659468020/68881 or a 68030 or a 68040. The generated code does use the
2659568881 instructions that are emulated on the 68060.
26596
26597The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26598
d77de738
ML
26599@opindex mhard-float
26600@opindex m68881
ddf6fe37
AA
26601@item -mhard-float
26602@itemx -m68881
d77de738
ML
26603Generate floating-point instructions. This is the default for 68020
26604and above, and for ColdFire devices that have an FPU@. It defines the
26605macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26606on ColdFire targets.
26607
d77de738 26608@opindex msoft-float
ddf6fe37 26609@item -msoft-float
d77de738
ML
26610Do not generate floating-point instructions; use library calls instead.
26611This is the default for 68000, 68010, and 68832 targets. It is also
26612the default for ColdFire devices that have no FPU.
26613
d77de738
ML
26614@opindex mdiv
26615@opindex mno-div
ddf6fe37
AA
26616@item -mdiv
26617@itemx -mno-div
d77de738
ML
26618Generate (do not generate) ColdFire hardware divide and remainder
26619instructions. If @option{-march} is used without @option{-mcpu},
26620the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26621architectures. Otherwise, the default is taken from the target CPU
26622(either the default CPU, or the one specified by @option{-mcpu}). For
26623example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26624@option{-mcpu=5206e}.
26625
26626GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26627
d77de738 26628@opindex mshort
ddf6fe37 26629@item -mshort
d77de738
ML
26630Consider type @code{int} to be 16 bits wide, like @code{short int}.
26631Additionally, parameters passed on the stack are also aligned to a
2663216-bit boundary even on targets whose API mandates promotion to 32-bit.
26633
d77de738 26634@opindex mno-short
ddf6fe37 26635@item -mno-short
d77de738
ML
26636Do not consider type @code{int} to be 16 bits wide. This is the default.
26637
d77de738
ML
26638@opindex mnobitfield
26639@opindex mno-bitfield
ddf6fe37
AA
26640@item -mnobitfield
26641@itemx -mno-bitfield
d77de738
ML
26642Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26643and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26644
d77de738 26645@opindex mbitfield
ddf6fe37 26646@item -mbitfield
d77de738
ML
26647Do use the bit-field instructions. The @option{-m68020} option implies
26648@option{-mbitfield}. This is the default if you use a configuration
26649designed for a 68020.
26650
d77de738 26651@opindex mrtd
ddf6fe37 26652@item -mrtd
d77de738
ML
26653Use a different function-calling convention, in which functions
26654that take a fixed number of arguments return with the @code{rtd}
26655instruction, which pops their arguments while returning. This
26656saves one instruction in the caller since there is no need to pop
26657the arguments there.
26658
26659This calling convention is incompatible with the one normally
26660used on Unix, so you cannot use it if you need to call libraries
26661compiled with the Unix compiler.
26662
26663Also, you must provide function prototypes for all functions that
26664take variable numbers of arguments (including @code{printf});
26665otherwise incorrect code is generated for calls to those
26666functions.
26667
26668In addition, seriously incorrect code results if you call a
26669function with too many arguments. (Normally, extra arguments are
26670harmlessly ignored.)
26671
26672The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2667368040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26674
26675The default is @option{-mno-rtd}.
26676
d77de738
ML
26677@opindex malign-int
26678@opindex mno-align-int
ddf6fe37
AA
26679@item -malign-int
26680@itemx -mno-align-int
d77de738
ML
26681Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26682@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26683boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26684Aligning variables on 32-bit boundaries produces code that runs somewhat
26685faster on processors with 32-bit busses at the expense of more memory.
26686
26687@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26688aligns structures containing the above types differently than
26689most published application binary interface specifications for the m68k.
26690
26691@opindex mpcrel
26692Use the pc-relative addressing mode of the 68000 directly, instead of
26693using a global offset table. At present, this option implies @option{-fpic},
26694allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26695not presently supported with @option{-mpcrel}, though this could be supported for
2669668020 and higher processors.
26697
d77de738
ML
26698@opindex mno-strict-align
26699@opindex mstrict-align
ddf6fe37
AA
26700@item -mno-strict-align
26701@itemx -mstrict-align
d77de738
ML
26702Do not (do) assume that unaligned memory references are handled by
26703the system.
26704
26705@item -msep-data
26706Generate code that allows the data segment to be located in a different
26707area of memory from the text segment. This allows for execute-in-place in
26708an environment without virtual memory management. This option implies
26709@option{-fPIC}.
26710
26711@item -mno-sep-data
26712Generate code that assumes that the data segment follows the text segment.
26713This is the default.
26714
26715@item -mid-shared-library
26716Generate code that supports shared libraries via the library ID method.
26717This allows for execute-in-place and shared libraries in an environment
26718without virtual memory management. This option implies @option{-fPIC}.
26719
26720@item -mno-id-shared-library
26721Generate code that doesn't assume ID-based shared libraries are being used.
26722This is the default.
26723
26724@item -mshared-library-id=n
26725Specifies the identification number of the ID-based shared library being
26726compiled. Specifying a value of 0 generates more compact code; specifying
26727other values forces the allocation of that number to the current
26728library, but is no more space- or time-efficient than omitting this option.
26729
d77de738
ML
26730@opindex mxgot
26731@opindex mno-xgot
ddf6fe37
AA
26732@item -mxgot
26733@itemx -mno-xgot
d77de738
ML
26734When generating position-independent code for ColdFire, generate code
26735that works if the GOT has more than 8192 entries. This code is
26736larger and slower than code generated without this option. On M680x0
26737processors, this option is not needed; @option{-fPIC} suffices.
26738
26739GCC normally uses a single instruction to load values from the GOT@.
26740While this is relatively efficient, it only works if the GOT
26741is smaller than about 64k. Anything larger causes the linker
26742to report an error such as:
26743
26744@cindex relocation truncated to fit (ColdFire)
26745@smallexample
26746relocation truncated to fit: R_68K_GOT16O foobar
26747@end smallexample
26748
26749If this happens, you should recompile your code with @option{-mxgot}.
26750It should then work with very large GOTs. However, code generated with
26751@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26752the value of a global symbol.
26753
26754Note that some linkers, including newer versions of the GNU linker,
26755can create multiple GOTs and sort GOT entries. If you have such a linker,
26756you should only need to use @option{-mxgot} when compiling a single
26757object file that accesses more than 8192 GOT entries. Very few do.
26758
26759These options have no effect unless GCC is generating
26760position-independent code.
26761
d77de738 26762@opindex mlong-jump-table-offsets
ddf6fe37 26763@item -mlong-jump-table-offsets
d77de738
ML
26764Use 32-bit offsets in @code{switch} tables. The default is to use
2676516-bit offsets.
26766
26767@end table
26768
26769@node MCore Options
26770@subsection MCore Options
26771@cindex MCore options
26772
26773These are the @samp{-m} options defined for the Motorola M*Core
26774processors.
26775
26776@table @gcctabopt
26777
d77de738
ML
26778@opindex mhardlit
26779@opindex mno-hardlit
ddf6fe37
AA
26780@item -mhardlit
26781@itemx -mno-hardlit
d77de738
ML
26782Inline constants into the code stream if it can be done in two
26783instructions or less.
26784
d77de738
ML
26785@opindex mdiv
26786@opindex mno-div
ddf6fe37
AA
26787@item -mdiv
26788@itemx -mno-div
d77de738
ML
26789Use the divide instruction. (Enabled by default).
26790
d77de738
ML
26791@opindex mrelax-immediate
26792@opindex mno-relax-immediate
ddf6fe37
AA
26793@item -mrelax-immediate
26794@itemx -mno-relax-immediate
d77de738
ML
26795Allow arbitrary-sized immediates in bit operations.
26796
d77de738
ML
26797@opindex mwide-bitfields
26798@opindex mno-wide-bitfields
ddf6fe37
AA
26799@item -mwide-bitfields
26800@itemx -mno-wide-bitfields
d77de738
ML
26801Always treat bit-fields as @code{int}-sized.
26802
d77de738
ML
26803@opindex m4byte-functions
26804@opindex mno-4byte-functions
ddf6fe37
AA
26805@item -m4byte-functions
26806@itemx -mno-4byte-functions
d77de738
ML
26807Force all functions to be aligned to a 4-byte boundary.
26808
d77de738
ML
26809@opindex mcallgraph-data
26810@opindex mno-callgraph-data
ddf6fe37
AA
26811@item -mcallgraph-data
26812@itemx -mno-callgraph-data
d77de738
ML
26813Emit callgraph information.
26814
d77de738
ML
26815@opindex mslow-bytes
26816@opindex mno-slow-bytes
ddf6fe37
AA
26817@item -mslow-bytes
26818@itemx -mno-slow-bytes
d77de738
ML
26819Prefer word access when reading byte quantities.
26820
d77de738
ML
26821@opindex mlittle-endian
26822@opindex mbig-endian
ddf6fe37
AA
26823@item -mlittle-endian
26824@itemx -mbig-endian
d77de738
ML
26825Generate code for a little-endian target.
26826
d77de738
ML
26827@opindex m210
26828@opindex m340
ddf6fe37
AA
26829@item -m210
26830@itemx -m340
d77de738
ML
26831Generate code for the 210 processor.
26832
d77de738 26833@opindex mno-lsim
ddf6fe37 26834@item -mno-lsim
d77de738
ML
26835Assume that runtime support has been provided and so omit the
26836simulator library (@file{libsim.a)} from the linker command line.
26837
d77de738 26838@opindex mstack-increment
ddf6fe37 26839@item -mstack-increment=@var{size}
d77de738
ML
26840Set the maximum amount for a single stack increment operation. Large
26841values can increase the speed of programs that contain functions
26842that need a large amount of stack space, but they can also trigger a
26843segmentation fault if the stack is extended too much. The default
26844value is 0x1000.
26845
26846@end table
26847
d77de738
ML
26848@node MicroBlaze Options
26849@subsection MicroBlaze Options
26850@cindex MicroBlaze Options
26851
26852@table @gcctabopt
26853
d77de738 26854@opindex msoft-float
ddf6fe37 26855@item -msoft-float
d77de738
ML
26856Use software emulation for floating point (default).
26857
d77de738 26858@opindex mhard-float
ddf6fe37 26859@item -mhard-float
d77de738
ML
26860Use hardware floating-point instructions.
26861
d77de738 26862@opindex mmemcpy
ddf6fe37 26863@item -mmemcpy
d77de738
ML
26864Do not optimize block moves, use @code{memcpy}.
26865
d77de738 26866@opindex mno-clearbss
ddf6fe37 26867@item -mno-clearbss
d77de738
ML
26868This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26869
d77de738 26870@opindex mcpu=
ddf6fe37 26871@item -mcpu=@var{cpu-type}
d77de738
ML
26872Use features of, and schedule code for, the given CPU.
26873Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26874where @var{X} is a major version, @var{YY} is the minor version, and
26875@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26876@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26877
d77de738 26878@opindex mxl-soft-mul
ddf6fe37 26879@item -mxl-soft-mul
d77de738
ML
26880Use software multiply emulation (default).
26881
d77de738 26882@opindex mxl-soft-div
ddf6fe37 26883@item -mxl-soft-div
d77de738
ML
26884Use software emulation for divides (default).
26885
d77de738 26886@opindex mxl-barrel-shift
ddf6fe37 26887@item -mxl-barrel-shift
d77de738
ML
26888Use the hardware barrel shifter.
26889
d77de738 26890@opindex mxl-pattern-compare
ddf6fe37 26891@item -mxl-pattern-compare
d77de738
ML
26892Use pattern compare instructions.
26893
d77de738 26894@opindex msmall-divides
ddf6fe37 26895@item -msmall-divides
d77de738
ML
26896Use table lookup optimization for small signed integer divisions.
26897
d77de738 26898@opindex mxl-stack-check
ddf6fe37 26899@item -mxl-stack-check
d77de738
ML
26900This option is deprecated. Use @option{-fstack-check} instead.
26901
d77de738 26902@opindex mxl-gp-opt
ddf6fe37 26903@item -mxl-gp-opt
d77de738
ML
26904Use GP-relative @code{.sdata}/@code{.sbss} sections.
26905
d77de738 26906@opindex mxl-multiply-high
ddf6fe37 26907@item -mxl-multiply-high
d77de738
ML
26908Use multiply high instructions for high part of 32x32 multiply.
26909
d77de738 26910@opindex mxl-float-convert
ddf6fe37 26911@item -mxl-float-convert
d77de738
ML
26912Use hardware floating-point conversion instructions.
26913
d77de738 26914@opindex mxl-float-sqrt
ddf6fe37 26915@item -mxl-float-sqrt
d77de738
ML
26916Use hardware floating-point square root instruction.
26917
d77de738 26918@opindex mbig-endian
ddf6fe37 26919@item -mbig-endian
d77de738
ML
26920Generate code for a big-endian target.
26921
d77de738 26922@opindex mlittle-endian
ddf6fe37 26923@item -mlittle-endian
d77de738
ML
26924Generate code for a little-endian target.
26925
d77de738 26926@opindex mxl-reorder
ddf6fe37 26927@item -mxl-reorder
d77de738
ML
26928Use reorder instructions (swap and byte reversed load/store).
26929
26930@item -mxl-mode-@var{app-model}
26931Select application model @var{app-model}. Valid models are
26932@table @samp
26933@item executable
26934normal executable (default), uses startup code @file{crt0.o}.
26935
26936@item xmdstub
26937for use with Xilinx Microprocessor Debugger (XMD) based
26938software intrusive debug agent called xmdstub. This uses startup file
26939@file{crt1.o} and sets the start address of the program to 0x800.
26940
26941@item bootstrap
26942for applications that are loaded using a bootloader.
26943This model uses startup file @file{crt2.o} which does not contain a processor
26944reset vector handler. This is suitable for transferring control on a
26945processor reset to the bootloader rather than the application.
26946
26947@item novectors
26948for applications that do not require any of the
26949MicroBlaze vectors. This option may be useful for applications running
26950within a monitoring application. This model uses @file{crt3.o} as a startup file.
26951@end table
26952
26953Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26954@option{-mxl-mode-@var{app-model}}.
26955
d77de738 26956@opindex mpic-data-is-text-relative
ddf6fe37 26957@item -mpic-data-is-text-relative
d77de738
ML
26958Assume that the displacement between the text and data segments is fixed
26959at static link time. This allows data to be referenced by offset from start of
26960text address instead of GOT since PC-relative addressing is not supported.
26961
26962@end table
26963
26964@node MIPS Options
26965@subsection MIPS Options
26966@cindex MIPS options
26967
26968@table @gcctabopt
26969
d77de738 26970@opindex EB
ddf6fe37 26971@item -EB
d77de738
ML
26972Generate big-endian code.
26973
d77de738 26974@opindex EL
ddf6fe37 26975@item -EL
d77de738
ML
26976Generate little-endian code. This is the default for @samp{mips*el-*-*}
26977configurations.
26978
d77de738 26979@opindex march
ddf6fe37 26980@item -march=@var{arch}
d77de738
ML
26981Generate code that runs on @var{arch}, which can be the name of a
26982generic MIPS ISA, or the name of a particular processor.
26983The ISA names are:
26984@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26985@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26986@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26987@samp{mips64r5} and @samp{mips64r6}.
26988The processor names are:
26989@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26990@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26991@samp{5kc}, @samp{5kf},
26992@samp{20kc},
26993@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26994@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26995@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26996@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26997@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26998@samp{i6400}, @samp{i6500},
26999@samp{interaptiv},
27000@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
27001@samp{gs464e}, @samp{gs264e},
27002@samp{m4k},
27003@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
27004@samp{m5100}, @samp{m5101},
27005@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
27006@samp{orion},
27007@samp{p5600}, @samp{p6600},
27008@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
27009@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
27010@samp{r6000}, @samp{r8000},
27011@samp{rm7000}, @samp{rm9000},
27012@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
27013@samp{sb1},
27014@samp{sr71000},
27015@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
27016@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
27017@samp{xlr} and @samp{xlp}.
27018The special value @samp{from-abi} selects the
27019most compatible architecture for the selected ABI (that is,
27020@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
27021
27022The native Linux/GNU toolchain also supports the value @samp{native},
27023which selects the best architecture option for the host processor.
27024@option{-march=native} has no effect if GCC does not recognize
27025the processor.
27026
27027In processor names, a final @samp{000} can be abbreviated as @samp{k}
27028(for example, @option{-march=r2k}). Prefixes are optional, and
27029@samp{vr} may be written @samp{r}.
27030
27031Names of the form @samp{@var{n}f2_1} refer to processors with
27032FPUs clocked at half the rate of the core, names of the form
27033@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
27034rate as the core, and names of the form @samp{@var{n}f3_2} refer to
27035processors with FPUs clocked a ratio of 3:2 with respect to the core.
27036For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
27037for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
27038accepted as synonyms for @samp{@var{n}f1_1}.
27039
27040GCC defines two macros based on the value of this option. The first
27041is @code{_MIPS_ARCH}, which gives the name of target architecture, as
27042a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
27043where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
27044For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
27045to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
27046
27047Note that the @code{_MIPS_ARCH} macro uses the processor names given
27048above. In other words, it has the full prefix and does not
27049abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
27050the macro names the resolved architecture (either @code{"mips1"} or
27051@code{"mips3"}). It names the default architecture when no
27052@option{-march} option is given.
27053
d77de738 27054@opindex mtune
ddf6fe37 27055@item -mtune=@var{arch}
d77de738
ML
27056Optimize for @var{arch}. Among other things, this option controls
27057the way instructions are scheduled, and the perceived cost of arithmetic
27058operations. The list of @var{arch} values is the same as for
27059@option{-march}.
27060
27061When this option is not used, GCC optimizes for the processor
27062specified by @option{-march}. By using @option{-march} and
27063@option{-mtune} together, it is possible to generate code that
27064runs on a family of processors, but optimize the code for one
27065particular member of that family.
27066
27067@option{-mtune} defines the macros @code{_MIPS_TUNE} and
27068@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
27069@option{-march} ones described above.
27070
d77de738 27071@opindex mips1
ddf6fe37 27072@item -mips1
d77de738
ML
27073Equivalent to @option{-march=mips1}.
27074
d77de738 27075@opindex mips2
ddf6fe37 27076@item -mips2
d77de738
ML
27077Equivalent to @option{-march=mips2}.
27078
d77de738 27079@opindex mips3
ddf6fe37 27080@item -mips3
d77de738
ML
27081Equivalent to @option{-march=mips3}.
27082
d77de738 27083@opindex mips4
ddf6fe37 27084@item -mips4
d77de738
ML
27085Equivalent to @option{-march=mips4}.
27086
d77de738 27087@opindex mips32
ddf6fe37 27088@item -mips32
d77de738
ML
27089Equivalent to @option{-march=mips32}.
27090
d77de738 27091@opindex mips32r3
ddf6fe37 27092@item -mips32r3
d77de738
ML
27093Equivalent to @option{-march=mips32r3}.
27094
d77de738 27095@opindex mips32r5
ddf6fe37 27096@item -mips32r5
d77de738
ML
27097Equivalent to @option{-march=mips32r5}.
27098
d77de738 27099@opindex mips32r6
ddf6fe37 27100@item -mips32r6
d77de738
ML
27101Equivalent to @option{-march=mips32r6}.
27102
d77de738 27103@opindex mips64
ddf6fe37 27104@item -mips64
d77de738
ML
27105Equivalent to @option{-march=mips64}.
27106
d77de738 27107@opindex mips64r2
ddf6fe37 27108@item -mips64r2
d77de738
ML
27109Equivalent to @option{-march=mips64r2}.
27110
d77de738 27111@opindex mips64r3
ddf6fe37 27112@item -mips64r3
d77de738
ML
27113Equivalent to @option{-march=mips64r3}.
27114
d77de738 27115@opindex mips64r5
ddf6fe37 27116@item -mips64r5
d77de738
ML
27117Equivalent to @option{-march=mips64r5}.
27118
d77de738 27119@opindex mips64r6
ddf6fe37 27120@item -mips64r6
d77de738
ML
27121Equivalent to @option{-march=mips64r6}.
27122
d77de738
ML
27123@opindex mips16
27124@opindex mno-mips16
ddf6fe37
AA
27125@item -mips16
27126@itemx -mno-mips16
d77de738
ML
27127Generate (do not generate) MIPS16 code. If GCC is targeting a
27128MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
27129
27130MIPS16 code generation can also be controlled on a per-function basis
27131by means of @code{mips16} and @code{nomips16} attributes.
27132@xref{Function Attributes}, for more information.
27133
926f2d09
JM
27134@opindex mmips16e2
27135@opindex mno-mips16e2
27136@item -mmips16e2
27137@itemx -mno-mips16e2
27138Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
27139of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
27140
d77de738 27141@opindex mflip-mips16
ddf6fe37 27142@item -mflip-mips16
d77de738
ML
27143Generate MIPS16 code on alternating functions. This option is provided
27144for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
27145not intended for ordinary use in compiling user code.
27146
d77de738
ML
27147@opindex minterlink-compressed
27148@opindex mno-interlink-compressed
ddf6fe37
AA
27149@item -minterlink-compressed
27150@itemx -mno-interlink-compressed
d77de738
ML
27151Require (do not require) that code using the standard (uncompressed) MIPS ISA
27152be link-compatible with MIPS16 and microMIPS code, and vice versa.
27153
27154For example, code using the standard ISA encoding cannot jump directly
27155to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
27156@option{-minterlink-compressed} therefore disables direct jumps unless GCC
27157knows that the target of the jump is not compressed.
27158
d77de738
ML
27159@opindex minterlink-mips16
27160@opindex mno-interlink-mips16
ddf6fe37
AA
27161@item -minterlink-mips16
27162@itemx -mno-interlink-mips16
d77de738
ML
27163Aliases of @option{-minterlink-compressed} and
27164@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
27165and are retained for backwards compatibility.
27166
d77de738
ML
27167@opindex mabi=32
27168@opindex mabi=o64
27169@opindex mabi=n32
27170@opindex mabi=64
27171@opindex mabi=eabi
ddf6fe37
AA
27172@item -mabi=32
27173@itemx -mabi=o64
27174@itemx -mabi=n32
27175@itemx -mabi=64
27176@itemx -mabi=eabi
d77de738
ML
27177Generate code for the given ABI@.
27178
27179Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
27180generates 64-bit code when you select a 64-bit architecture, but you
27181can use @option{-mgp32} to get 32-bit code instead.
27182
27183For information about the O64 ABI, see
27184@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
27185
27186GCC supports a variant of the o32 ABI in which floating-point registers
27187are 64 rather than 32 bits wide. You can select this combination with
27188@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
27189and @code{mfhc1} instructions and is therefore only supported for
27190MIPS32R2, MIPS32R3 and MIPS32R5 processors.
27191
27192The register assignments for arguments and return values remain the
27193same, but each scalar value is passed in a single 64-bit register
27194rather than a pair of 32-bit registers. For example, scalar
27195floating-point values are returned in @samp{$f0} only, not a
27196@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
27197remains the same in that the even-numbered double-precision registers
27198are saved.
27199
27200Two additional variants of the o32 ABI are supported to enable
27201a transition from 32-bit to 64-bit registers. These are FPXX
27202(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
27203The FPXX extension mandates that all code must execute correctly
27204when run using 32-bit or 64-bit registers. The code can be interlinked
27205with either FP32 or FP64, but not both.
27206The FP64A extension is similar to the FP64 extension but forbids the
27207use of odd-numbered single-precision registers. This can be used
27208in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
27209processors and allows both FP32 and FP64A code to interlink and
27210run in the same process without changing FPU modes.
27211
d77de738
ML
27212@opindex mabicalls
27213@opindex mno-abicalls
ddf6fe37
AA
27214@item -mabicalls
27215@itemx -mno-abicalls
d77de738
ML
27216Generate (do not generate) code that is suitable for SVR4-style
27217dynamic objects. @option{-mabicalls} is the default for SVR4-based
27218systems.
27219
27220@item -mshared
27221@itemx -mno-shared
27222Generate (do not generate) code that is fully position-independent,
27223and that can therefore be linked into shared libraries. This option
27224only affects @option{-mabicalls}.
27225
27226All @option{-mabicalls} code has traditionally been position-independent,
27227regardless of options like @option{-fPIC} and @option{-fpic}. However,
27228as an extension, the GNU toolchain allows executables to use absolute
27229accesses for locally-binding symbols. It can also use shorter GP
27230initialization sequences and generate direct calls to locally-defined
27231functions. This mode is selected by @option{-mno-shared}.
27232
27233@option{-mno-shared} depends on binutils 2.16 or higher and generates
27234objects that can only be linked by the GNU linker. However, the option
27235does not affect the ABI of the final executable; it only affects the ABI
27236of relocatable objects. Using @option{-mno-shared} generally makes
27237executables both smaller and quicker.
27238
27239@option{-mshared} is the default.
27240
d77de738
ML
27241@opindex mplt
27242@opindex mno-plt
ddf6fe37
AA
27243@item -mplt
27244@itemx -mno-plt
d77de738
ML
27245Assume (do not assume) that the static and dynamic linkers
27246support PLTs and copy relocations. This option only affects
27247@option{-mno-shared -mabicalls}. For the n64 ABI, this option
27248has no effect without @option{-msym32}.
27249
27250You can make @option{-mplt} the default by configuring
27251GCC with @option{--with-mips-plt}. The default is
27252@option{-mno-plt} otherwise.
27253
d77de738
ML
27254@opindex mxgot
27255@opindex mno-xgot
ddf6fe37
AA
27256@item -mxgot
27257@itemx -mno-xgot
d77de738
ML
27258Lift (do not lift) the usual restrictions on the size of the global
27259offset table.
27260
27261GCC normally uses a single instruction to load values from the GOT@.
27262While this is relatively efficient, it only works if the GOT
27263is smaller than about 64k. Anything larger causes the linker
27264to report an error such as:
27265
27266@cindex relocation truncated to fit (MIPS)
27267@smallexample
27268relocation truncated to fit: R_MIPS_GOT16 foobar
27269@end smallexample
27270
27271If this happens, you should recompile your code with @option{-mxgot}.
27272This works with very large GOTs, although the code is also
27273less efficient, since it takes three instructions to fetch the
27274value of a global symbol.
27275
27276Note that some linkers can create multiple GOTs. If you have such a
27277linker, you should only need to use @option{-mxgot} when a single object
27278file accesses more than 64k's worth of GOT entries. Very few do.
27279
27280These options have no effect unless GCC is generating position
27281independent code.
27282
d77de738 27283@opindex mgp32
ddf6fe37 27284@item -mgp32
d77de738
ML
27285Assume that general-purpose registers are 32 bits wide.
27286
d77de738 27287@opindex mgp64
ddf6fe37 27288@item -mgp64
d77de738
ML
27289Assume that general-purpose registers are 64 bits wide.
27290
d77de738 27291@opindex mfp32
ddf6fe37 27292@item -mfp32
d77de738
ML
27293Assume that floating-point registers are 32 bits wide.
27294
d77de738 27295@opindex mfp64
ddf6fe37 27296@item -mfp64
d77de738
ML
27297Assume that floating-point registers are 64 bits wide.
27298
d77de738 27299@opindex mfpxx
ddf6fe37 27300@item -mfpxx
d77de738
ML
27301Do not assume the width of floating-point registers.
27302
d77de738 27303@opindex mhard-float
ddf6fe37 27304@item -mhard-float
d77de738
ML
27305Use floating-point coprocessor instructions.
27306
d77de738 27307@opindex msoft-float
ddf6fe37 27308@item -msoft-float
d77de738
ML
27309Do not use floating-point coprocessor instructions. Implement
27310floating-point calculations using library calls instead.
27311
d77de738 27312@opindex mno-float
ddf6fe37 27313@item -mno-float
d77de738
ML
27314Equivalent to @option{-msoft-float}, but additionally asserts that the
27315program being compiled does not perform any floating-point operations.
27316This option is presently supported only by some bare-metal MIPS
27317configurations, where it may select a special set of libraries
27318that lack all floating-point support (including, for example, the
27319floating-point @code{printf} formats).
27320If code compiled with @option{-mno-float} accidentally contains
27321floating-point operations, it is likely to suffer a link-time
27322or run-time failure.
27323
d77de738 27324@opindex msingle-float
ddf6fe37 27325@item -msingle-float
d77de738
ML
27326Assume that the floating-point coprocessor only supports single-precision
27327operations.
27328
d77de738 27329@opindex mdouble-float
ddf6fe37 27330@item -mdouble-float
d77de738
ML
27331Assume that the floating-point coprocessor supports double-precision
27332operations. This is the default.
27333
d77de738
ML
27334@opindex modd-spreg
27335@opindex mno-odd-spreg
ddf6fe37
AA
27336@item -modd-spreg
27337@itemx -mno-odd-spreg
d77de738
ML
27338Enable the use of odd-numbered single-precision floating-point registers
27339for the o32 ABI. This is the default for processors that are known to
27340support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
27341is set by default.
27342
d77de738
ML
27343@opindex mabs=2008
27344@opindex mabs=legacy
ddf6fe37
AA
27345@item -mabs=2008
27346@itemx -mabs=legacy
d77de738
ML
27347These options control the treatment of the special not-a-number (NaN)
27348IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
27349@code{neg.@i{fmt}} machine instructions.
27350
27351By default or when @option{-mabs=legacy} is used the legacy
27352treatment is selected. In this case these instructions are considered
27353arithmetic and avoided where correct operation is required and the
27354input operand might be a NaN. A longer sequence of instructions that
27355manipulate the sign bit of floating-point datum manually is used
27356instead unless the @option{-ffinite-math-only} option has also been
27357specified.
27358
27359The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
27360this case these instructions are considered non-arithmetic and therefore
27361operating correctly in all cases, including in particular where the
27362input operand is a NaN. These instructions are therefore always used
27363for the respective operations.
27364
d77de738
ML
27365@opindex mnan=2008
27366@opindex mnan=legacy
ddf6fe37
AA
27367@item -mnan=2008
27368@itemx -mnan=legacy
d77de738
ML
27369These options control the encoding of the special not-a-number (NaN)
27370IEEE 754 floating-point data.
27371
27372The @option{-mnan=legacy} option selects the legacy encoding. In this
27373case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
27374significand field being 0, whereas signaling NaNs (sNaNs) are denoted
27375by the first bit of their trailing significand field being 1.
27376
27377The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
27378this case qNaNs are denoted by the first bit of their trailing
27379significand field being 1, whereas sNaNs are denoted by the first bit of
27380their trailing significand field being 0.
27381
27382The default is @option{-mnan=legacy} unless GCC has been configured with
27383@option{--with-nan=2008}.
27384
d77de738
ML
27385@opindex mllsc
27386@opindex mno-llsc
ddf6fe37
AA
27387@item -mllsc
27388@itemx -mno-llsc
d77de738
ML
27389Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
27390implement atomic memory built-in functions. When neither option is
27391specified, GCC uses the instructions if the target architecture
27392supports them.
27393
27394@option{-mllsc} is useful if the runtime environment can emulate the
27395instructions and @option{-mno-llsc} can be useful when compiling for
27396nonstandard ISAs. You can make either option the default by
27397configuring GCC with @option{--with-llsc} and @option{--without-llsc}
27398respectively. @option{--with-llsc} is the default for some
27399configurations; see the installation documentation for details.
27400
d77de738
ML
27401@opindex mdsp
27402@opindex mno-dsp
ddf6fe37
AA
27403@item -mdsp
27404@itemx -mno-dsp
d77de738
ML
27405Use (do not use) revision 1 of the MIPS DSP ASE@.
27406@xref{MIPS DSP Built-in Functions}. This option defines the
27407preprocessor macro @code{__mips_dsp}. It also defines
27408@code{__mips_dsp_rev} to 1.
27409
d77de738
ML
27410@opindex mdspr2
27411@opindex mno-dspr2
ddf6fe37
AA
27412@item -mdspr2
27413@itemx -mno-dspr2
d77de738
ML
27414Use (do not use) revision 2 of the MIPS DSP ASE@.
27415@xref{MIPS DSP Built-in Functions}. This option defines the
27416preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
27417It also defines @code{__mips_dsp_rev} to 2.
27418
d77de738
ML
27419@opindex msmartmips
27420@opindex mno-smartmips
ddf6fe37
AA
27421@item -msmartmips
27422@itemx -mno-smartmips
d77de738
ML
27423Use (do not use) the MIPS SmartMIPS ASE.
27424
d77de738
ML
27425@opindex mpaired-single
27426@opindex mno-paired-single
ddf6fe37
AA
27427@item -mpaired-single
27428@itemx -mno-paired-single
d77de738
ML
27429Use (do not use) paired-single floating-point instructions.
27430@xref{MIPS Paired-Single Support}. This option requires
27431hardware floating-point support to be enabled.
27432
d77de738
ML
27433@opindex mdmx
27434@opindex mno-mdmx
ddf6fe37
AA
27435@item -mdmx
27436@itemx -mno-mdmx
d77de738
ML
27437Use (do not use) MIPS Digital Media Extension instructions.
27438This option can only be used when generating 64-bit code and requires
27439hardware floating-point support to be enabled.
27440
d77de738
ML
27441@opindex mips3d
27442@opindex mno-mips3d
ddf6fe37
AA
27443@item -mips3d
27444@itemx -mno-mips3d
d77de738
ML
27445Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27446The option @option{-mips3d} implies @option{-mpaired-single}.
27447
d77de738
ML
27448@opindex mmicromips
27449@opindex mno-mmicromips
ddf6fe37
AA
27450@item -mmicromips
27451@itemx -mno-micromips
d77de738
ML
27452Generate (do not generate) microMIPS code.
27453
27454MicroMIPS code generation can also be controlled on a per-function basis
27455by means of @code{micromips} and @code{nomicromips} attributes.
27456@xref{Function Attributes}, for more information.
27457
d77de738
ML
27458@opindex mmt
27459@opindex mno-mt
ddf6fe37
AA
27460@item -mmt
27461@itemx -mno-mt
d77de738
ML
27462Use (do not use) MT Multithreading instructions.
27463
d77de738
ML
27464@opindex mmcu
27465@opindex mno-mcu
ddf6fe37
AA
27466@item -mmcu
27467@itemx -mno-mcu
d77de738
ML
27468Use (do not use) the MIPS MCU ASE instructions.
27469
d77de738
ML
27470@opindex meva
27471@opindex mno-eva
ddf6fe37
AA
27472@item -meva
27473@itemx -mno-eva
d77de738
ML
27474Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27475
d77de738
ML
27476@opindex mvirt
27477@opindex mno-virt
ddf6fe37
AA
27478@item -mvirt
27479@itemx -mno-virt
d77de738
ML
27480Use (do not use) the MIPS Virtualization (VZ) instructions.
27481
d77de738
ML
27482@opindex mxpa
27483@opindex mno-xpa
ddf6fe37
AA
27484@item -mxpa
27485@itemx -mno-xpa
d77de738
ML
27486Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27487
d77de738
ML
27488@opindex mcrc
27489@opindex mno-crc
ddf6fe37
AA
27490@item -mcrc
27491@itemx -mno-crc
d77de738
ML
27492Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27493
d77de738
ML
27494@opindex mginv
27495@opindex mno-ginv
ddf6fe37
AA
27496@item -mginv
27497@itemx -mno-ginv
d77de738
ML
27498Use (do not use) the MIPS Global INValidate (GINV) instructions.
27499
d77de738
ML
27500@opindex mloongson-mmi
27501@opindex mno-loongson-mmi
ddf6fe37
AA
27502@item -mloongson-mmi
27503@itemx -mno-loongson-mmi
d77de738
ML
27504Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27505
d77de738
ML
27506@opindex mloongson-ext
27507@opindex mno-loongson-ext
ddf6fe37
AA
27508@item -mloongson-ext
27509@itemx -mno-loongson-ext
d77de738
ML
27510Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27511
d77de738
ML
27512@opindex mloongson-ext2
27513@opindex mno-loongson-ext2
ddf6fe37
AA
27514@item -mloongson-ext2
27515@itemx -mno-loongson-ext2
d77de738
ML
27516Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27517
d77de738 27518@opindex mlong64
ddf6fe37 27519@item -mlong64
d77de738
ML
27520Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27521an explanation of the default and the way that the pointer size is
27522determined.
27523
d77de738 27524@opindex mlong32
ddf6fe37 27525@item -mlong32
d77de738
ML
27526Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27527
27528The default size of @code{int}s, @code{long}s and pointers depends on
27529the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27530uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2753132-bit @code{long}s. Pointers are the same size as @code{long}s,
27532or the same size as integer registers, whichever is smaller.
27533
d77de738
ML
27534@opindex msym32
27535@opindex mno-sym32
ddf6fe37
AA
27536@item -msym32
27537@itemx -mno-sym32
d77de738
ML
27538Assume (do not assume) that all symbols have 32-bit values, regardless
27539of the selected ABI@. This option is useful in combination with
27540@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27541to generate shorter and faster references to symbolic addresses.
27542
d77de738 27543@opindex G
ddf6fe37 27544@item -G @var{num}
d77de738
ML
27545Put definitions of externally-visible data in a small data section
27546if that data is no bigger than @var{num} bytes. GCC can then generate
27547more efficient accesses to the data; see @option{-mgpopt} for details.
27548
27549The default @option{-G} option depends on the configuration.
27550
d77de738
ML
27551@opindex mlocal-sdata
27552@opindex mno-local-sdata
ddf6fe37
AA
27553@item -mlocal-sdata
27554@itemx -mno-local-sdata
d77de738
ML
27555Extend (do not extend) the @option{-G} behavior to local data too,
27556such as to static variables in C@. @option{-mlocal-sdata} is the
27557default for all configurations.
27558
27559If the linker complains that an application is using too much small data,
27560you might want to try rebuilding the less performance-critical parts with
27561@option{-mno-local-sdata}. You might also want to build large
27562libraries with @option{-mno-local-sdata}, so that the libraries leave
27563more room for the main program.
27564
d77de738
ML
27565@opindex mextern-sdata
27566@opindex mno-extern-sdata
ddf6fe37
AA
27567@item -mextern-sdata
27568@itemx -mno-extern-sdata
d77de738
ML
27569Assume (do not assume) that externally-defined data is in
27570a small data section if the size of that data is within the @option{-G} limit.
27571@option{-mextern-sdata} is the default for all configurations.
27572
27573If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27574@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27575that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27576is placed in a small data section. If @var{Var} is defined by another
27577module, you must either compile that module with a high-enough
27578@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27579definition. If @var{Var} is common, you must link the application
27580with a high-enough @option{-G} setting.
27581
27582The easiest way of satisfying these restrictions is to compile
27583and link every module with the same @option{-G} option. However,
27584you may wish to build a library that supports several different
27585small data limits. You can do this by compiling the library with
27586the highest supported @option{-G} setting and additionally using
27587@option{-mno-extern-sdata} to stop the library from making assumptions
27588about externally-defined data.
27589
d77de738
ML
27590@opindex mgpopt
27591@opindex mno-gpopt
ddf6fe37
AA
27592@item -mgpopt
27593@itemx -mno-gpopt
d77de738
ML
27594Use (do not use) GP-relative accesses for symbols that are known to be
27595in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27596@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27597configurations.
27598
27599@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27600might not hold the value of @code{_gp}. For example, if the code is
27601part of a library that might be used in a boot monitor, programs that
27602call boot monitor routines pass an unknown value in @code{$gp}.
27603(In such situations, the boot monitor itself is usually compiled
27604with @option{-G0}.)
27605
27606@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27607@option{-mno-extern-sdata}.
27608
d77de738
ML
27609@opindex membedded-data
27610@opindex mno-embedded-data
ddf6fe37
AA
27611@item -membedded-data
27612@itemx -mno-embedded-data
d77de738
ML
27613Allocate variables to the read-only data section first if possible, then
27614next in the small data section if possible, otherwise in data. This gives
27615slightly slower code than the default, but reduces the amount of RAM required
27616when executing, and thus may be preferred for some embedded systems.
27617
d77de738
ML
27618@opindex muninit-const-in-rodata
27619@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27620@item -muninit-const-in-rodata
27621@itemx -mno-uninit-const-in-rodata
d77de738
ML
27622Put uninitialized @code{const} variables in the read-only data section.
27623This option is only meaningful in conjunction with @option{-membedded-data}.
27624
d77de738 27625@opindex mcode-readable
ddf6fe37 27626@item -mcode-readable=@var{setting}
d77de738
ML
27627Specify whether GCC may generate code that reads from executable sections.
27628There are three possible settings:
27629
27630@table @gcctabopt
27631@item -mcode-readable=yes
27632Instructions may freely access executable sections. This is the
27633default setting.
27634
27635@item -mcode-readable=pcrel
27636MIPS16 PC-relative load instructions can access executable sections,
27637but other instructions must not do so. This option is useful on 4KSc
27638and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27639It is also useful on processors that can be configured to have a dual
27640instruction/data SRAM interface and that, like the M4K, automatically
27641redirect PC-relative loads to the instruction RAM.
27642
27643@item -mcode-readable=no
27644Instructions must not access executable sections. This option can be
27645useful on targets that are configured to have a dual instruction/data
27646SRAM interface but that (unlike the M4K) do not automatically redirect
27647PC-relative loads to the instruction RAM.
27648@end table
27649
d77de738
ML
27650@opindex msplit-addresses
27651@opindex mno-split-addresses
ddf6fe37
AA
27652@item -msplit-addresses
27653@itemx -mno-split-addresses
d77de738
ML
27654Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27655relocation operators. This option has been superseded by
27656@option{-mexplicit-relocs} but is retained for backwards compatibility.
27657
d77de738
ML
27658@opindex mexplicit-relocs
27659@opindex mno-explicit-relocs
ddf6fe37
AA
27660@item -mexplicit-relocs
27661@itemx -mno-explicit-relocs
d77de738
ML
27662Use (do not use) assembler relocation operators when dealing with symbolic
27663addresses. The alternative, selected by @option{-mno-explicit-relocs},
27664is to use assembler macros instead.
27665
27666@option{-mexplicit-relocs} is the default if GCC was configured
27667to use an assembler that supports relocation operators.
27668
d77de738
ML
27669@opindex mcheck-zero-division
27670@opindex mno-check-zero-division
ddf6fe37
AA
27671@item -mcheck-zero-division
27672@itemx -mno-check-zero-division
d77de738
ML
27673Trap (do not trap) on integer division by zero.
27674
27675The default is @option{-mcheck-zero-division}.
27676
d77de738
ML
27677@opindex mdivide-traps
27678@opindex mdivide-breaks
ddf6fe37
AA
27679@item -mdivide-traps
27680@itemx -mdivide-breaks
d77de738
ML
27681MIPS systems check for division by zero by generating either a
27682conditional trap or a break instruction. Using traps results in
27683smaller code, but is only supported on MIPS II and later. Also, some
27684versions of the Linux kernel have a bug that prevents trap from
27685generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27686allow conditional traps on architectures that support them and
27687@option{-mdivide-breaks} to force the use of breaks.
27688
27689The default is usually @option{-mdivide-traps}, but this can be
27690overridden at configure time using @option{--with-divide=breaks}.
27691Divide-by-zero checks can be completely disabled using
27692@option{-mno-check-zero-division}.
27693
d77de738
ML
27694@opindex mload-store-pairs
27695@opindex mno-load-store-pairs
ddf6fe37
AA
27696@item -mload-store-pairs
27697@itemx -mno-load-store-pairs
d77de738
ML
27698Enable (disable) an optimization that pairs consecutive load or store
27699instructions to enable load/store bonding. This option is enabled by
27700default but only takes effect when the selected architecture is known
27701to support bonding.
27702
d77de738
ML
27703@opindex munaligned-access
27704@opindex mno-unaligned-access
ddf6fe37
AA
27705@item -munaligned-access
27706@itemx -mno-unaligned-access
d77de738
ML
27707Enable (disable) direct unaligned access for MIPS Release 6.
27708MIPSr6 requires load/store unaligned-access support,
27709by hardware or trap&emulate.
27710So @option{-mno-unaligned-access} may be needed by kernel.
27711
d77de738
ML
27712@opindex mmemcpy
27713@opindex mno-memcpy
ddf6fe37
AA
27714@item -mmemcpy
27715@itemx -mno-memcpy
d77de738
ML
27716Force (do not force) the use of @code{memcpy} for non-trivial block
27717moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27718most constant-sized copies.
27719
d77de738
ML
27720@opindex mlong-calls
27721@opindex mno-long-calls
ddf6fe37
AA
27722@item -mlong-calls
27723@itemx -mno-long-calls
d77de738
ML
27724Disable (do not disable) use of the @code{jal} instruction. Calling
27725functions using @code{jal} is more efficient but requires the caller
27726and callee to be in the same 256 megabyte segment.
27727
27728This option has no effect on abicalls code. The default is
27729@option{-mno-long-calls}.
27730
d77de738
ML
27731@opindex mmad
27732@opindex mno-mad
ddf6fe37
AA
27733@item -mmad
27734@itemx -mno-mad
d77de738
ML
27735Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27736instructions, as provided by the R4650 ISA@.
27737
d77de738
ML
27738@opindex mimadd
27739@opindex mno-imadd
ddf6fe37
AA
27740@item -mimadd
27741@itemx -mno-imadd
d77de738
ML
27742Enable (disable) use of the @code{madd} and @code{msub} integer
27743instructions. The default is @option{-mimadd} on architectures
27744that support @code{madd} and @code{msub} except for the 74k
27745architecture where it was found to generate slower code.
27746
d77de738
ML
27747@opindex mfused-madd
27748@opindex mno-fused-madd
ddf6fe37
AA
27749@item -mfused-madd
27750@itemx -mno-fused-madd
d77de738
ML
27751Enable (disable) use of the floating-point multiply-accumulate
27752instructions, when they are available. The default is
27753@option{-mfused-madd}.
27754
27755On the R8000 CPU when multiply-accumulate instructions are used,
27756the intermediate product is calculated to infinite precision
27757and is not subject to the FCSR Flush to Zero bit. This may be
27758undesirable in some circumstances. On other processors the result
27759is numerically identical to the equivalent computation using
27760separate multiply, add, subtract and negate instructions.
27761
d77de738 27762@opindex nocpp
ddf6fe37 27763@item -nocpp
d77de738
ML
27764Tell the MIPS assembler to not run its preprocessor over user
27765assembler files (with a @samp{.s} suffix) when assembling them.
27766
d77de738
ML
27767@opindex mfix-24k
27768@opindex mno-fix-24k
ddf6fe37
AA
27769@item -mfix-24k
27770@itemx -mno-fix-24k
d77de738
ML
27771Work around the 24K E48 (lost data on stores during refill) errata.
27772The workarounds are implemented by the assembler rather than by GCC@.
27773
d77de738
ML
27774@opindex mfix-r4000
27775@opindex mno-fix-r4000
ddf6fe37
AA
27776@item -mfix-r4000
27777@itemx -mno-fix-r4000
d77de738
ML
27778Work around certain R4000 CPU errata:
27779@itemize @minus
27780@item
27781A double-word or a variable shift may give an incorrect result if executed
27782immediately after starting an integer division.
27783@item
27784A double-word or a variable shift may give an incorrect result if executed
27785while an integer multiplication is in progress.
27786@item
27787An integer division may give an incorrect result if started in a delay slot
27788of a taken branch or a jump.
27789@end itemize
27790
d77de738
ML
27791@opindex mfix-r4400
27792@opindex mno-fix-r4400
ddf6fe37
AA
27793@item -mfix-r4400
27794@itemx -mno-fix-r4400
d77de738
ML
27795Work around certain R4400 CPU errata:
27796@itemize @minus
27797@item
27798A double-word or a variable shift may give an incorrect result if executed
27799immediately after starting an integer division.
27800@end itemize
27801
d77de738
ML
27802@opindex mfix-r10000
27803@opindex mno-fix-r10000
ddf6fe37
AA
27804@item -mfix-r10000
27805@itemx -mno-fix-r10000
d77de738
ML
27806Work around certain R10000 errata:
27807@itemize @minus
27808@item
27809@code{ll}/@code{sc} sequences may not behave atomically on revisions
27810prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27811@end itemize
27812
27813This option can only be used if the target architecture supports
27814branch-likely instructions. @option{-mfix-r10000} is the default when
27815@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27816otherwise.
27817
ddf6fe37 27818@opindex mfix-r5900
d77de738
ML
27819@item -mfix-r5900
27820@itemx -mno-fix-r5900
d77de738
ML
27821Do not attempt to schedule the preceding instruction into the delay slot
27822of a branch instruction placed at the end of a short loop of six
27823instructions or fewer and always schedule a @code{nop} instruction there
27824instead. The short loop bug under certain conditions causes loops to
27825execute only once or twice, due to a hardware bug in the R5900 chip. The
27826workaround is implemented by the assembler rather than by GCC@.
27827
ddf6fe37 27828@opindex mfix-rm7000
d77de738
ML
27829@item -mfix-rm7000
27830@itemx -mno-fix-rm7000
d77de738
ML
27831Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27832workarounds are implemented by the assembler rather than by GCC@.
27833
ddf6fe37 27834@opindex mfix-vr4120
d77de738
ML
27835@item -mfix-vr4120
27836@itemx -mno-fix-vr4120
d77de738
ML
27837Work around certain VR4120 errata:
27838@itemize @minus
27839@item
27840@code{dmultu} does not always produce the correct result.
27841@item
27842@code{div} and @code{ddiv} do not always produce the correct result if one
27843of the operands is negative.
27844@end itemize
27845The workarounds for the division errata rely on special functions in
27846@file{libgcc.a}. At present, these functions are only provided by
27847the @code{mips64vr*-elf} configurations.
27848
27849Other VR4120 errata require a NOP to be inserted between certain pairs of
27850instructions. These errata are handled by the assembler, not by GCC itself.
27851
d77de738 27852@opindex mfix-vr4130
ddf6fe37 27853@item -mfix-vr4130
d77de738
ML
27854Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27855workarounds are implemented by the assembler rather than by GCC,
27856although GCC avoids using @code{mflo} and @code{mfhi} if the
27857VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27858instructions are available instead.
27859
ddf6fe37 27860@opindex mfix-sb1
d77de738
ML
27861@item -mfix-sb1
27862@itemx -mno-fix-sb1
d77de738
ML
27863Work around certain SB-1 CPU core errata.
27864(This flag currently works around the SB-1 revision 2
27865``F1'' and ``F2'' floating-point errata.)
27866
d77de738 27867@opindex mr10k-cache-barrier
ddf6fe37 27868@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
27869Specify whether GCC should insert cache barriers to avoid the
27870side effects of speculation on R10K processors.
27871
27872In common with many processors, the R10K tries to predict the outcome
27873of a conditional branch and speculatively executes instructions from
27874the ``taken'' branch. It later aborts these instructions if the
27875predicted outcome is wrong. However, on the R10K, even aborted
27876instructions can have side effects.
27877
27878This problem only affects kernel stores and, depending on the system,
27879kernel loads. As an example, a speculatively-executed store may load
27880the target memory into cache and mark the cache line as dirty, even if
27881the store itself is later aborted. If a DMA operation writes to the
27882same area of memory before the ``dirty'' line is flushed, the cached
27883data overwrites the DMA-ed data. See the R10K processor manual
27884for a full description, including other potential problems.
27885
27886One workaround is to insert cache barrier instructions before every memory
27887access that might be speculatively executed and that might have side
27888effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27889controls GCC's implementation of this workaround. It assumes that
27890aborted accesses to any byte in the following regions does not have
27891side effects:
27892
27893@enumerate
27894@item
27895the memory occupied by the current function's stack frame;
27896
27897@item
27898the memory occupied by an incoming stack argument;
27899
27900@item
27901the memory occupied by an object with a link-time-constant address.
27902@end enumerate
27903
27904It is the kernel's responsibility to ensure that speculative
27905accesses to these regions are indeed safe.
27906
27907If the input program contains a function declaration such as:
27908
27909@smallexample
27910void foo (void);
27911@end smallexample
27912
27913then the implementation of @code{foo} must allow @code{j foo} and
27914@code{jal foo} to be executed speculatively. GCC honors this
27915restriction for functions it compiles itself. It expects non-GCC
27916functions (such as hand-written assembly code) to do the same.
27917
27918The option has three forms:
27919
27920@table @gcctabopt
27921@item -mr10k-cache-barrier=load-store
27922Insert a cache barrier before a load or store that might be
27923speculatively executed and that might have side effects even
27924if aborted.
27925
27926@item -mr10k-cache-barrier=store
27927Insert a cache barrier before a store that might be speculatively
27928executed and that might have side effects even if aborted.
27929
27930@item -mr10k-cache-barrier=none
27931Disable the insertion of cache barriers. This is the default setting.
27932@end table
27933
ddf6fe37 27934@opindex mflush-func
d77de738
ML
27935@item -mflush-func=@var{func}
27936@itemx -mno-flush-func
d77de738
ML
27937Specifies the function to call to flush the I and D caches, or to not
27938call any such function. If called, the function must take the same
27939arguments as the common @code{_flush_func}, that is, the address of the
27940memory range for which the cache is being flushed, the size of the
27941memory range, and the number 3 (to flush both caches). The default
27942depends on the target GCC was configured for, but commonly is either
27943@code{_flush_func} or @code{__cpu_flush}.
27944
d77de738 27945@opindex mbranch-cost
ddf6fe37 27946@item mbranch-cost=@var{num}
d77de738
ML
27947Set the cost of branches to roughly @var{num} ``simple'' instructions.
27948This cost is only a heuristic and is not guaranteed to produce
27949consistent results across releases. A zero cost redundantly selects
27950the default, which is based on the @option{-mtune} setting.
27951
d77de738
ML
27952@opindex mbranch-likely
27953@opindex mno-branch-likely
ddf6fe37
AA
27954@item -mbranch-likely
27955@itemx -mno-branch-likely
d77de738
ML
27956Enable or disable use of Branch Likely instructions, regardless of the
27957default for the selected architecture. By default, Branch Likely
27958instructions may be generated if they are supported by the selected
27959architecture. An exception is for the MIPS32 and MIPS64 architectures
27960and processors that implement those architectures; for those, Branch
27961Likely instructions are not be generated by default because the MIPS32
27962and MIPS64 architectures specifically deprecate their use.
27963
d77de738
ML
27964@opindex mcompact-branches=never
27965@opindex mcompact-branches=optimal
27966@opindex mcompact-branches=always
ddf6fe37
AA
27967@item -mcompact-branches=never
27968@itemx -mcompact-branches=optimal
27969@itemx -mcompact-branches=always
d77de738
ML
27970These options control which form of branches will be generated. The
27971default is @option{-mcompact-branches=optimal}.
27972
27973The @option{-mcompact-branches=never} option ensures that compact branch
27974instructions will never be generated.
27975
27976The @option{-mcompact-branches=always} option ensures that a compact
27977branch instruction will be generated if available for MIPS Release 6 onwards.
27978If a compact branch instruction is not available (or pre-R6),
27979a delay slot form of the branch will be used instead.
27980
27981If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27982The behaviour for MIPS16/microMIPS may change in future,
27983since they do have some compact branch instructions.
27984
27985The @option{-mcompact-branches=optimal} option will cause a delay slot
27986branch to be used if one is available in the current ISA and the delay
27987slot is successfully filled. If the delay slot is not filled, a compact
27988branch will be chosen if one is available.
27989
ddf6fe37 27990@opindex mfp-exceptions
d77de738
ML
27991@item -mfp-exceptions
27992@itemx -mno-fp-exceptions
d77de738
ML
27993Specifies whether FP exceptions are enabled. This affects how
27994FP instructions are scheduled for some processors.
27995The default is that FP exceptions are
27996enabled.
27997
27998For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2799964-bit code, then we can use both FP pipes. Otherwise, we can only use one
28000FP pipe.
28001
ddf6fe37 28002@opindex mvr4130-align
d77de738
ML
28003@item -mvr4130-align
28004@itemx -mno-vr4130-align
d77de738
ML
28005The VR4130 pipeline is two-way superscalar, but can only issue two
28006instructions together if the first one is 8-byte aligned. When this
28007option is enabled, GCC aligns pairs of instructions that it
28008thinks should execute in parallel.
28009
28010This option only has an effect when optimizing for the VR4130.
28011It normally makes code faster, but at the expense of making it bigger.
28012It is enabled by default at optimization level @option{-O3}.
28013
ddf6fe37 28014@opindex msynci
d77de738
ML
28015@item -msynci
28016@itemx -mno-synci
d77de738
ML
28017Enable (disable) generation of @code{synci} instructions on
28018architectures that support it. The @code{synci} instructions (if
28019enabled) are generated when @code{__builtin___clear_cache} is
28020compiled.
28021
28022This option defaults to @option{-mno-synci}, but the default can be
28023overridden by configuring GCC with @option{--with-synci}.
28024
28025When compiling code for single processor systems, it is generally safe
28026to use @code{synci}. However, on many multi-core (SMP) systems, it
28027does not invalidate the instruction caches on all cores and may lead
28028to undefined behavior.
28029
ddf6fe37 28030@opindex mrelax-pic-calls
d77de738
ML
28031@item -mrelax-pic-calls
28032@itemx -mno-relax-pic-calls
d77de738
ML
28033Try to turn PIC calls that are normally dispatched via register
28034@code{$25} into direct calls. This is only possible if the linker can
28035resolve the destination at link time and if the destination is within
28036range for a direct call.
28037
28038@option{-mrelax-pic-calls} is the default if GCC was configured to use
28039an assembler and a linker that support the @code{.reloc} assembly
28040directive and @option{-mexplicit-relocs} is in effect. With
28041@option{-mno-explicit-relocs}, this optimization can be performed by the
28042assembler and the linker alone without help from the compiler.
28043
d77de738
ML
28044@opindex mmcount-ra-address
28045@opindex mno-mcount-ra-address
ddf6fe37
AA
28046@item -mmcount-ra-address
28047@itemx -mno-mcount-ra-address
d77de738
ML
28048Emit (do not emit) code that allows @code{_mcount} to modify the
28049calling function's return address. When enabled, this option extends
28050the usual @code{_mcount} interface with a new @var{ra-address}
28051parameter, which has type @code{intptr_t *} and is passed in register
28052@code{$12}. @code{_mcount} can then modify the return address by
28053doing both of the following:
28054@itemize
28055@item
28056Returning the new address in register @code{$31}.
28057@item
28058Storing the new address in @code{*@var{ra-address}},
28059if @var{ra-address} is nonnull.
28060@end itemize
28061
28062The default is @option{-mno-mcount-ra-address}.
28063
ddf6fe37 28064@opindex mframe-header-opt
d77de738
ML
28065@item -mframe-header-opt
28066@itemx -mno-frame-header-opt
d77de738
ML
28067Enable (disable) frame header optimization in the o32 ABI. When using the
28068o32 ABI, calling functions will allocate 16 bytes on the stack for the called
28069function to write out register arguments. When enabled, this optimization
28070will suppress the allocation of the frame header if it can be determined that
28071it is unused.
28072
28073This optimization is off by default at all optimization levels.
28074
ddf6fe37 28075@opindex mlxc1-sxc1
d77de738
ML
28076@item -mlxc1-sxc1
28077@itemx -mno-lxc1-sxc1
d77de738
ML
28078When applicable, enable (disable) the generation of @code{lwxc1},
28079@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
28080
ddf6fe37 28081@opindex mmadd4
d77de738
ML
28082@item -mmadd4
28083@itemx -mno-madd4
d77de738
ML
28084When applicable, enable (disable) the generation of 4-operand @code{madd.s},
28085@code{madd.d} and related instructions. Enabled by default.
28086
28087@end table
28088
28089@node MMIX Options
28090@subsection MMIX Options
28091@cindex MMIX Options
28092
28093These options are defined for the MMIX:
28094
28095@table @gcctabopt
d77de738
ML
28096@opindex mlibfuncs
28097@opindex mno-libfuncs
ddf6fe37
AA
28098@item -mlibfuncs
28099@itemx -mno-libfuncs
d77de738
ML
28100Specify that intrinsic library functions are being compiled, passing all
28101values in registers, no matter the size.
28102
d77de738
ML
28103@opindex mepsilon
28104@opindex mno-epsilon
ddf6fe37
AA
28105@item -mepsilon
28106@itemx -mno-epsilon
d77de738
ML
28107Generate floating-point comparison instructions that compare with respect
28108to the @code{rE} epsilon register.
28109
d77de738
ML
28110@opindex mabi=mmixware
28111@opindex mabi=gnu
ddf6fe37
AA
28112@item -mabi=mmixware
28113@itemx -mabi=gnu
d77de738
ML
28114Generate code that passes function parameters and return values that (in
28115the called function) are seen as registers @code{$0} and up, as opposed to
28116the GNU ABI which uses global registers @code{$231} and up.
28117
d77de738
ML
28118@opindex mzero-extend
28119@opindex mno-zero-extend
ddf6fe37
AA
28120@item -mzero-extend
28121@itemx -mno-zero-extend
d77de738
ML
28122When reading data from memory in sizes shorter than 64 bits, use (do not
28123use) zero-extending load instructions by default, rather than
28124sign-extending ones.
28125
d77de738
ML
28126@opindex mknuthdiv
28127@opindex mno-knuthdiv
ddf6fe37
AA
28128@item -mknuthdiv
28129@itemx -mno-knuthdiv
d77de738
ML
28130Make the result of a division yielding a remainder have the same sign as
28131the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
28132remainder follows the sign of the dividend. Both methods are
28133arithmetically valid, the latter being almost exclusively used.
28134
d77de738
ML
28135@opindex mtoplevel-symbols
28136@opindex mno-toplevel-symbols
ddf6fe37
AA
28137@item -mtoplevel-symbols
28138@itemx -mno-toplevel-symbols
d77de738
ML
28139Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
28140code can be used with the @code{PREFIX} assembly directive.
28141
d77de738 28142@opindex melf
ddf6fe37 28143@item -melf
d77de738
ML
28144Generate an executable in the ELF format, rather than the default
28145@samp{mmo} format used by the @command{mmix} simulator.
28146
d77de738
ML
28147@opindex mbranch-predict
28148@opindex mno-branch-predict
ddf6fe37
AA
28149@item -mbranch-predict
28150@itemx -mno-branch-predict
d77de738
ML
28151Use (do not use) the probable-branch instructions, when static branch
28152prediction indicates a probable branch.
28153
d77de738
ML
28154@opindex mbase-addresses
28155@opindex mno-base-addresses
ddf6fe37
AA
28156@item -mbase-addresses
28157@itemx -mno-base-addresses
d77de738
ML
28158Generate (do not generate) code that uses @emph{base addresses}. Using a
28159base address automatically generates a request (handled by the assembler
28160and the linker) for a constant to be set up in a global register. The
28161register is used for one or more base address requests within the range 0
28162to 255 from the value held in the register. The generally leads to short
28163and fast code, but the number of different data items that can be
28164addressed is limited. This means that a program that uses lots of static
28165data may require @option{-mno-base-addresses}.
28166
d77de738
ML
28167@opindex msingle-exit
28168@opindex mno-single-exit
ddf6fe37
AA
28169@item -msingle-exit
28170@itemx -mno-single-exit
d77de738
ML
28171Force (do not force) generated code to have a single exit point in each
28172function.
28173@end table
28174
28175@node MN10300 Options
28176@subsection MN10300 Options
28177@cindex MN10300 options
28178
28179These @option{-m} options are defined for Matsushita MN10300 architectures:
28180
28181@table @gcctabopt
d77de738 28182@opindex mmult-bug
ddf6fe37 28183@item -mmult-bug
d77de738
ML
28184Generate code to avoid bugs in the multiply instructions for the MN10300
28185processors. This is the default.
28186
d77de738 28187@opindex mno-mult-bug
ddf6fe37 28188@item -mno-mult-bug
d77de738
ML
28189Do not generate code to avoid bugs in the multiply instructions for the
28190MN10300 processors.
28191
d77de738 28192@opindex mam33
ddf6fe37 28193@item -mam33
d77de738
ML
28194Generate code using features specific to the AM33 processor.
28195
d77de738 28196@opindex mno-am33
ddf6fe37 28197@item -mno-am33
d77de738
ML
28198Do not generate code using features specific to the AM33 processor. This
28199is the default.
28200
d77de738 28201@opindex mam33-2
ddf6fe37 28202@item -mam33-2
d77de738
ML
28203Generate code using features specific to the AM33/2.0 processor.
28204
d77de738 28205@opindex mam34
ddf6fe37 28206@item -mam34
d77de738
ML
28207Generate code using features specific to the AM34 processor.
28208
d77de738 28209@opindex mtune
ddf6fe37 28210@item -mtune=@var{cpu-type}
d77de738
ML
28211Use the timing characteristics of the indicated CPU type when
28212scheduling instructions. This does not change the targeted processor
28213type. The CPU type must be one of @samp{mn10300}, @samp{am33},
28214@samp{am33-2} or @samp{am34}.
28215
d77de738 28216@opindex mreturn-pointer-on-d0
ddf6fe37 28217@item -mreturn-pointer-on-d0
d77de738
ML
28218When generating a function that returns a pointer, return the pointer
28219in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
28220only in @code{a0}, and attempts to call such functions without a prototype
28221result in errors. Note that this option is on by default; use
28222@option{-mno-return-pointer-on-d0} to disable it.
28223
d77de738 28224@opindex mno-crt0
ddf6fe37 28225@item -mno-crt0
d77de738
ML
28226Do not link in the C run-time initialization object file.
28227
d77de738 28228@opindex mrelax
ddf6fe37 28229@item -mrelax
d77de738
ML
28230Indicate to the linker that it should perform a relaxation optimization pass
28231to shorten branches, calls and absolute memory addresses. This option only
28232has an effect when used on the command line for the final link step.
28233
28234This option makes symbolic debugging impossible.
28235
d77de738 28236@opindex mliw
ddf6fe37 28237@item -mliw
d77de738
ML
28238Allow the compiler to generate @emph{Long Instruction Word}
28239instructions if the target is the @samp{AM33} or later. This is the
28240default. This option defines the preprocessor macro @code{__LIW__}.
28241
d77de738 28242@opindex mno-liw
ddf6fe37 28243@item -mno-liw
d77de738
ML
28244Do not allow the compiler to generate @emph{Long Instruction Word}
28245instructions. This option defines the preprocessor macro
28246@code{__NO_LIW__}.
28247
d77de738 28248@opindex msetlb
ddf6fe37 28249@item -msetlb
d77de738
ML
28250Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
28251instructions if the target is the @samp{AM33} or later. This is the
28252default. This option defines the preprocessor macro @code{__SETLB__}.
28253
d77de738 28254@opindex mno-setlb
ddf6fe37 28255@item -mno-setlb
d77de738
ML
28256Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
28257instructions. This option defines the preprocessor macro
28258@code{__NO_SETLB__}.
28259
28260@end table
28261
28262@node Moxie Options
28263@subsection Moxie Options
28264@cindex Moxie Options
28265
28266@table @gcctabopt
28267
d77de738 28268@opindex meb
ddf6fe37 28269@item -meb
d77de738
ML
28270Generate big-endian code. This is the default for @samp{moxie-*-*}
28271configurations.
28272
d77de738 28273@opindex mel
ddf6fe37 28274@item -mel
d77de738
ML
28275Generate little-endian code.
28276
d77de738 28277@opindex mmul.x
ddf6fe37 28278@item -mmul.x
d77de738
ML
28279Generate mul.x and umul.x instructions. This is the default for
28280@samp{moxiebox-*-*} configurations.
28281
d77de738 28282@opindex mno-crt0
ddf6fe37 28283@item -mno-crt0
d77de738
ML
28284Do not link in the C run-time initialization object file.
28285
28286@end table
28287
28288@node MSP430 Options
28289@subsection MSP430 Options
28290@cindex MSP430 Options
28291
28292These options are defined for the MSP430:
28293
28294@table @gcctabopt
28295
d77de738 28296@opindex masm-hex
ddf6fe37 28297@item -masm-hex
d77de738
ML
28298Force assembly output to always use hex constants. Normally such
28299constants are signed decimals, but this option is available for
28300testsuite and/or aesthetic purposes.
28301
d77de738 28302@opindex mmcu=
ddf6fe37 28303@item -mmcu=
d77de738
ML
28304Select the MCU to target. This is used to create a C preprocessor
28305symbol based upon the MCU name, converted to upper case and pre- and
28306post-fixed with @samp{__}. This in turn is used by the
28307@file{msp430.h} header file to select an MCU-specific supplementary
28308header file.
28309
28310The option also sets the ISA to use. If the MCU name is one that is
28311known to only support the 430 ISA then that is selected, otherwise the
28312430X ISA is selected. A generic MCU name of @samp{msp430} can also be
28313used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
28314name selects the 430X ISA.
28315
28316In addition an MCU-specific linker script is added to the linker
28317command line. The script's name is the name of the MCU with
28318@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
28319command line defines the C preprocessor symbol @code{__XXX__} and
28320cause the linker to search for a script called @file{xxx.ld}.
28321
28322The ISA and hardware multiply supported for the different MCUs is hard-coded
28323into GCC. However, an external @samp{devices.csv} file can be used to
28324extend device support beyond those that have been hard-coded.
28325
28326GCC searches for the @samp{devices.csv} file using the following methods in the
28327given precedence order, where the first method takes precendence over the
28328second which takes precedence over the third.
28329
28330@table @asis
28331@item Include path specified with @code{-I} and @code{-L}
28332@samp{devices.csv} will be searched for in each of the directories specified by
28333include paths and linker library search paths.
28334@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
28335Define the value of the global environment variable
28336@samp{MSP430_GCC_INCLUDE_DIR}
28337to the full path to the directory containing devices.csv, and GCC will search
28338this directory for devices.csv. If devices.csv is found, this directory will
28339also be registered as an include path, and linker library path. Header files
28340and linker scripts in this directory can therefore be used without manually
28341specifying @code{-I} and @code{-L} on the command line.
28342@item The @samp{msp430-elf@{,bare@}/include/devices} directory
28343Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
28344toolchain root directory. This directory does not exist in a default
28345installation, but if the user has created it and copied @samp{devices.csv}
28346there, then the MCU data will be read. As above, this directory will
28347also be registered as an include path, and linker library path.
28348
28349@end table
28350If none of the above search methods find @samp{devices.csv}, then the
28351hard-coded MCU data is used.
28352
28353
d77de738
ML
28354@opindex mwarn-mcu
28355@opindex mno-warn-mcu
ddf6fe37
AA
28356@item -mwarn-mcu
28357@itemx -mno-warn-mcu
d77de738
ML
28358This option enables or disables warnings about conflicts between the
28359MCU name specified by the @option{-mmcu} option and the ISA set by the
28360@option{-mcpu} option and/or the hardware multiply support set by the
28361@option{-mhwmult} option. It also toggles warnings about unrecognized
28362MCU names. This option is on by default.
28363
d77de738 28364@opindex mcpu=
ddf6fe37 28365@item -mcpu=
d77de738
ML
28366Specifies the ISA to use. Accepted values are @samp{msp430},
28367@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
28368@option{-mmcu=} option should be used to select the ISA.
28369
d77de738 28370@opindex msim
ddf6fe37 28371@item -msim
d77de738
ML
28372Link to the simulator runtime libraries and linker script. Overrides
28373any scripts that would be selected by the @option{-mmcu=} option.
28374
d77de738 28375@opindex mlarge
ddf6fe37 28376@item -mlarge
d77de738
ML
28377Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
28378
d77de738 28379@opindex msmall
ddf6fe37 28380@item -msmall
d77de738
ML
28381Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
28382
d77de738 28383@opindex mrelax
ddf6fe37 28384@item -mrelax
d77de738
ML
28385This option is passed to the assembler and linker, and allows the
28386linker to perform certain optimizations that cannot be done until
28387the final link.
28388
d77de738 28389@opindex mhwmult=
ddf6fe37 28390@item mhwmult=
d77de738
ML
28391Describes the type of hardware multiply supported by the target.
28392Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
28393for the original 16-bit-only multiply supported by early MCUs.
28394@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
28395@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
28396A value of @samp{auto} can also be given. This tells GCC to deduce
28397the hardware multiply support based upon the MCU name provided by the
28398@option{-mmcu} option. If no @option{-mmcu} option is specified or if
28399the MCU name is not recognized then no hardware multiply support is
28400assumed. @code{auto} is the default setting.
28401
28402Hardware multiplies are normally performed by calling a library
28403routine. This saves space in the generated code. When compiling at
28404@option{-O3} or higher however the hardware multiplier is invoked
28405inline. This makes for bigger, but faster code.
28406
28407The hardware multiply routines disable interrupts whilst running and
28408restore the previous interrupt state when they finish. This makes
28409them safe to use inside interrupt handlers as well as in normal code.
28410
d77de738 28411@opindex minrt
ddf6fe37 28412@item -minrt
d77de738
ML
28413Enable the use of a minimum runtime environment - no static
28414initializers or constructors. This is intended for memory-constrained
28415devices. The compiler includes special symbols in some objects
28416that tell the linker and runtime which code fragments are required.
28417
d77de738 28418@opindex mtiny-printf
ddf6fe37 28419@item -mtiny-printf
d77de738
ML
28420Enable reduced code size @code{printf} and @code{puts} library functions.
28421The @samp{tiny} implementations of these functions are not reentrant, so
28422must be used with caution in multi-threaded applications.
28423
28424Support for streams has been removed and the string to be printed will
28425always be sent to stdout via the @code{write} syscall. The string is not
28426buffered before it is sent to write.
28427
28428This option requires Newlib Nano IO, so GCC must be configured with
28429@samp{--enable-newlib-nano-formatted-io}.
28430
d77de738 28431@opindex mmax-inline-shift=
ddf6fe37 28432@item -mmax-inline-shift=
d77de738
ML
28433This option takes an integer between 0 and 64 inclusive, and sets
28434the maximum number of inline shift instructions which should be emitted to
28435perform a shift operation by a constant amount. When this value needs to be
28436exceeded, an mspabi helper function is used instead. The default value is 4.
28437
28438This only affects cases where a shift by multiple positions cannot be
28439completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28440
28441Shifts of a 32-bit value are at least twice as costly, so the value passed for
28442this option is divided by 2 and the resulting value used instead.
28443
d77de738
ML
28444@opindex mcode-region
28445@opindex mdata-region
ddf6fe37
AA
28446@item -mcode-region=
28447@itemx -mdata-region=
d77de738
ML
28448These options tell the compiler where to place functions and data that
28449do not have one of the @code{lower}, @code{upper}, @code{either} or
28450@code{section} attributes. Possible values are @code{lower},
28451@code{upper}, @code{either} or @code{any}. The first three behave
28452like the corresponding attribute. The fourth possible value -
28453@code{any} - is the default. It leaves placement entirely up to the
28454linker script and how it assigns the standard sections
28455(@code{.text}, @code{.data}, etc) to the memory regions.
28456
d77de738 28457@opindex msilicon-errata
ddf6fe37 28458@item -msilicon-errata=
d77de738
ML
28459This option passes on a request to assembler to enable the fixes for
28460the named silicon errata.
28461
d77de738 28462@opindex msilicon-errata-warn
ddf6fe37 28463@item -msilicon-errata-warn=
d77de738
ML
28464This option passes on a request to the assembler to enable warning
28465messages when a silicon errata might need to be applied.
28466
d77de738
ML
28467@opindex mwarn-devices-csv
28468@opindex mno-warn-devices-csv
ddf6fe37
AA
28469@item -mwarn-devices-csv
28470@itemx -mno-warn-devices-csv
d77de738
ML
28471Warn if @samp{devices.csv} is not found or there are problem parsing it
28472(default: on).
28473
28474@end table
28475
28476@node NDS32 Options
28477@subsection NDS32 Options
28478@cindex NDS32 Options
28479
28480These options are defined for NDS32 implementations:
28481
28482@table @gcctabopt
28483
d77de738 28484@opindex mbig-endian
ddf6fe37 28485@item -mbig-endian
d77de738
ML
28486Generate code in big-endian mode.
28487
d77de738 28488@opindex mlittle-endian
ddf6fe37 28489@item -mlittle-endian
d77de738
ML
28490Generate code in little-endian mode.
28491
d77de738 28492@opindex mreduced-regs
ddf6fe37 28493@item -mreduced-regs
d77de738
ML
28494Use reduced-set registers for register allocation.
28495
d77de738 28496@opindex mfull-regs
ddf6fe37 28497@item -mfull-regs
d77de738
ML
28498Use full-set registers for register allocation.
28499
d77de738 28500@opindex mcmov
ddf6fe37 28501@item -mcmov
d77de738
ML
28502Generate conditional move instructions.
28503
d77de738 28504@opindex mno-cmov
ddf6fe37 28505@item -mno-cmov
d77de738
ML
28506Do not generate conditional move instructions.
28507
d77de738 28508@opindex mext-perf
ddf6fe37 28509@item -mext-perf
d77de738
ML
28510Generate performance extension instructions.
28511
d77de738 28512@opindex mno-ext-perf
ddf6fe37 28513@item -mno-ext-perf
d77de738
ML
28514Do not generate performance extension instructions.
28515
d77de738 28516@opindex mext-perf2
ddf6fe37 28517@item -mext-perf2
d77de738
ML
28518Generate performance extension 2 instructions.
28519
d77de738 28520@opindex mno-ext-perf2
ddf6fe37 28521@item -mno-ext-perf2
d77de738
ML
28522Do not generate performance extension 2 instructions.
28523
d77de738 28524@opindex mext-string
ddf6fe37 28525@item -mext-string
d77de738
ML
28526Generate string extension instructions.
28527
d77de738 28528@opindex mno-ext-string
ddf6fe37 28529@item -mno-ext-string
d77de738
ML
28530Do not generate string extension instructions.
28531
d77de738 28532@opindex mv3push
ddf6fe37 28533@item -mv3push
d77de738
ML
28534Generate v3 push25/pop25 instructions.
28535
d77de738 28536@opindex mno-v3push
ddf6fe37 28537@item -mno-v3push
d77de738
ML
28538Do not generate v3 push25/pop25 instructions.
28539
d77de738 28540@opindex m16-bit
ddf6fe37 28541@item -m16-bit
d77de738
ML
28542Generate 16-bit instructions.
28543
d77de738 28544@opindex mno-16-bit
ddf6fe37 28545@item -mno-16-bit
d77de738
ML
28546Do not generate 16-bit instructions.
28547
d77de738 28548@opindex misr-vector-size
ddf6fe37 28549@item -misr-vector-size=@var{num}
d77de738
ML
28550Specify the size of each interrupt vector, which must be 4 or 16.
28551
d77de738 28552@opindex mcache-block-size
ddf6fe37 28553@item -mcache-block-size=@var{num}
d77de738
ML
28554Specify the size of each cache block,
28555which must be a power of 2 between 4 and 512.
28556
d77de738 28557@opindex march
ddf6fe37 28558@item -march=@var{arch}
d77de738
ML
28559Specify the name of the target architecture.
28560
d77de738 28561@opindex mcmodel
ddf6fe37 28562@item -mcmodel=@var{code-model}
d77de738
ML
28563Set the code model to one of
28564@table @asis
28565@item @samp{small}
28566All the data and read-only data segments must be within 512KB addressing space.
28567The text segment must be within 16MB addressing space.
28568@item @samp{medium}
28569The data segment must be within 512KB while the read-only data segment can be
28570within 4GB addressing space. The text segment should be still within 16MB
28571addressing space.
28572@item @samp{large}
28573All the text and data segments can be within 4GB addressing space.
28574@end table
28575
d77de738 28576@opindex mctor-dtor
ddf6fe37 28577@item -mctor-dtor
d77de738
ML
28578Enable constructor/destructor feature.
28579
d77de738 28580@opindex mrelax
ddf6fe37 28581@item -mrelax
d77de738
ML
28582Guide linker to relax instructions.
28583
28584@end table
28585
28586@node Nios II Options
28587@subsection Nios II Options
28588@cindex Nios II options
28589@cindex Altera Nios II options
28590
28591These are the options defined for the Altera Nios II processor.
28592
28593@table @gcctabopt
28594
d77de738
ML
28595@opindex G
28596@cindex smaller data references
f33d7a88 28597@item -G @var{num}
d77de738
ML
28598Put global and static objects less than or equal to @var{num} bytes
28599into the small data or BSS sections instead of the normal data or BSS
28600sections. The default value of @var{num} is 8.
28601
ddf6fe37
AA
28602@opindex mgpopt
28603@opindex mno-gpopt
d77de738
ML
28604@item -mgpopt=@var{option}
28605@itemx -mgpopt
28606@itemx -mno-gpopt
d77de738
ML
28607Generate (do not generate) GP-relative accesses. The following
28608@var{option} names are recognized:
28609
28610@table @samp
28611
28612@item none
28613Do not generate GP-relative accesses.
28614
28615@item local
28616Generate GP-relative accesses for small data objects that are not
28617external, weak, or uninitialized common symbols.
28618Also use GP-relative addressing for objects that
28619have been explicitly placed in a small data section via a @code{section}
28620attribute.
28621
28622@item global
28623As for @samp{local}, but also generate GP-relative accesses for
28624small data objects that are external, weak, or common. If you use this option,
28625you must ensure that all parts of your program (including libraries) are
28626compiled with the same @option{-G} setting.
28627
28628@item data
28629Generate GP-relative accesses for all data objects in the program. If you
28630use this option, the entire data and BSS segments
28631of your program must fit in 64K of memory and you must use an appropriate
28632linker script to allocate them within the addressable range of the
28633global pointer.
28634
28635@item all
28636Generate GP-relative addresses for function pointers as well as data
28637pointers. If you use this option, the entire text, data, and BSS segments
28638of your program must fit in 64K of memory and you must use an appropriate
28639linker script to allocate them within the addressable range of the
28640global pointer.
28641
28642@end table
28643
28644@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28645@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28646
28647The default is @option{-mgpopt} except when @option{-fpic} or
28648@option{-fPIC} is specified to generate position-independent code.
28649Note that the Nios II ABI does not permit GP-relative accesses from
28650shared libraries.
28651
28652You may need to specify @option{-mno-gpopt} explicitly when building
28653programs that include large amounts of small data, including large
28654GOT data sections. In this case, the 16-bit offset for GP-relative
28655addressing may not be large enough to allow access to the entire
28656small data section.
28657
d77de738 28658@opindex mgprel-sec
ddf6fe37 28659@item -mgprel-sec=@var{regexp}
d77de738
ML
28660This option specifies additional section names that can be accessed via
28661GP-relative addressing. It is most useful in conjunction with
28662@code{section} attributes on variable declarations
28663(@pxref{Common Variable Attributes}) and a custom linker script.
28664The @var{regexp} is a POSIX Extended Regular Expression.
28665
28666This option does not affect the behavior of the @option{-G} option, and
28667the specified sections are in addition to the standard @code{.sdata}
28668and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28669
d77de738 28670@opindex mr0rel-sec
ddf6fe37 28671@item -mr0rel-sec=@var{regexp}
d77de738
ML
28672This option specifies names of sections that can be accessed via a
2867316-bit offset from @code{r0}; that is, in the low 32K or high 32K
28674of the 32-bit address space. It is most useful in conjunction with
28675@code{section} attributes on variable declarations
28676(@pxref{Common Variable Attributes}) and a custom linker script.
28677The @var{regexp} is a POSIX Extended Regular Expression.
28678
28679In contrast to the use of GP-relative addressing for small data,
28680zero-based addressing is never generated by default and there are no
28681conventional section names used in standard linker scripts for sections
28682in the low or high areas of memory.
28683
d77de738
ML
28684@opindex mel
28685@opindex meb
ddf6fe37
AA
28686@item -mel
28687@itemx -meb
d77de738
ML
28688Generate little-endian (default) or big-endian (experimental) code,
28689respectively.
28690
d77de738 28691@opindex march
ddf6fe37 28692@item -march=@var{arch}
d77de738
ML
28693This specifies the name of the target Nios II architecture. GCC uses this
28694name to determine what kind of instructions it can emit when generating
28695assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28696
28697The preprocessor macro @code{__nios2_arch__} is available to programs,
28698with value 1 or 2, indicating the targeted ISA level.
28699
d77de738
ML
28700@opindex mno-bypass-cache
28701@opindex mbypass-cache
ddf6fe37
AA
28702@item -mbypass-cache
28703@itemx -mno-bypass-cache
d77de738
ML
28704Force all load and store instructions to always bypass cache by
28705using I/O variants of the instructions. The default is not to
28706bypass the cache.
28707
d77de738
ML
28708@opindex mcache-volatile
28709@opindex mno-cache-volatile
ddf6fe37
AA
28710@item -mno-cache-volatile
28711@itemx -mcache-volatile
d77de738
ML
28712Volatile memory access bypass the cache using the I/O variants of
28713the load and store instructions. The default is not to bypass the cache.
28714
d77de738
ML
28715@opindex mno-fast-sw-div
28716@opindex mfast-sw-div
ddf6fe37
AA
28717@item -mno-fast-sw-div
28718@itemx -mfast-sw-div
d77de738
ML
28719Do not use table-based fast divide for small numbers. The default
28720is to use the fast divide at @option{-O3} and above.
28721
d77de738
ML
28722@opindex mno-hw-mul
28723@opindex mhw-mul
28724@opindex mno-hw-mulx
28725@opindex mhw-mulx
28726@opindex mno-hw-div
28727@opindex mhw-div
ddf6fe37
AA
28728@item -mno-hw-mul
28729@itemx -mhw-mul
28730@itemx -mno-hw-mulx
28731@itemx -mhw-mulx
28732@itemx -mno-hw-div
28733@itemx -mhw-div
d77de738
ML
28734Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28735instructions by the compiler. The default is to emit @code{mul}
28736and not emit @code{div} and @code{mulx}.
28737
28738@item -mbmx
28739@itemx -mno-bmx
28740@itemx -mcdx
28741@itemx -mno-cdx
28742Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28743CDX (code density) instructions. Enabling these instructions also
28744requires @option{-march=r2}. Since these instructions are optional
28745extensions to the R2 architecture, the default is not to emit them.
28746
d77de738
ML
28747@opindex mcustom-@var{insn}
28748@opindex mno-custom-@var{insn}
ddf6fe37
AA
28749@item -mcustom-@var{insn}=@var{N}
28750@itemx -mno-custom-@var{insn}
d77de738
ML
28751Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28752custom instruction with encoding @var{N} when generating code that uses
28753@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28754instruction 253 for single-precision floating-point add operations instead
28755of the default behavior of using a library call.
28756
28757The following values of @var{insn} are supported. Except as otherwise
28758noted, floating-point operations are expected to be implemented with
28759normal IEEE 754 semantics and correspond directly to the C operators or the
28760equivalent GCC built-in functions (@pxref{Other Builtins}).
28761
28762Single-precision floating point:
28763@table @asis
28764
28765@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28766Binary arithmetic operations.
28767
28768@item @samp{fnegs}
28769Unary negation.
28770
28771@item @samp{fabss}
28772Unary absolute value.
28773
28774@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28775Comparison operations.
28776
28777@item @samp{fmins}, @samp{fmaxs}
28778Floating-point minimum and maximum. These instructions are only
28779generated if @option{-ffinite-math-only} is specified.
28780
28781@item @samp{fsqrts}
28782Unary square root operation.
28783
28784@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28785Floating-point trigonometric and exponential functions. These instructions
28786are only generated if @option{-funsafe-math-optimizations} is also specified.
28787
28788@end table
28789
28790Double-precision floating point:
28791@table @asis
28792
28793@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28794Binary arithmetic operations.
28795
28796@item @samp{fnegd}
28797Unary negation.
28798
28799@item @samp{fabsd}
28800Unary absolute value.
28801
28802@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28803Comparison operations.
28804
28805@item @samp{fmind}, @samp{fmaxd}
28806Double-precision minimum and maximum. These instructions are only
28807generated if @option{-ffinite-math-only} is specified.
28808
28809@item @samp{fsqrtd}
28810Unary square root operation.
28811
28812@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28813Double-precision trigonometric and exponential functions. These instructions
28814are only generated if @option{-funsafe-math-optimizations} is also specified.
28815
28816@end table
28817
28818Conversions:
28819@table @asis
28820@item @samp{fextsd}
28821Conversion from single precision to double precision.
28822
28823@item @samp{ftruncds}
28824Conversion from double precision to single precision.
28825
28826@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28827Conversion from floating point to signed or unsigned integer types, with
28828truncation towards zero.
28829
28830@item @samp{round}
28831Conversion from single-precision floating point to signed integer,
28832rounding to the nearest integer and ties away from zero.
28833This corresponds to the @code{__builtin_lroundf} function when
28834@option{-fno-math-errno} is used.
28835
28836@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28837Conversion from signed or unsigned integer types to floating-point types.
28838
28839@end table
28840
28841In addition, all of the following transfer instructions for internal
28842registers X and Y must be provided to use any of the double-precision
28843floating-point instructions. Custom instructions taking two
28844double-precision source operands expect the first operand in the
2884564-bit register X. The other operand (or only operand of a unary
28846operation) is given to the custom arithmetic instruction with the
28847least significant half in source register @var{src1} and the most
28848significant half in @var{src2}. A custom instruction that returns a
28849double-precision result returns the most significant 32 bits in the
28850destination register and the other half in 32-bit register Y.
28851GCC automatically generates the necessary code sequences to write
28852register X and/or read register Y when double-precision floating-point
28853instructions are used.
28854
28855@table @asis
28856
28857@item @samp{fwrx}
28858Write @var{src1} into the least significant half of X and @var{src2} into
28859the most significant half of X.
28860
28861@item @samp{fwry}
28862Write @var{src1} into Y.
28863
28864@item @samp{frdxhi}, @samp{frdxlo}
28865Read the most or least (respectively) significant half of X and store it in
28866@var{dest}.
28867
28868@item @samp{frdy}
28869Read the value of Y and store it into @var{dest}.
28870@end table
28871
28872Note that you can gain more local control over generation of Nios II custom
28873instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28874and @code{target("no-custom-@var{insn}")} function attributes
28875(@pxref{Function Attributes})
28876or pragmas (@pxref{Function Specific Option Pragmas}).
28877
d77de738 28878@opindex mcustom-fpu-cfg
ddf6fe37 28879@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
28880
28881This option enables a predefined, named set of custom instruction encodings
28882(see @option{-mcustom-@var{insn}} above).
28883Currently, the following sets are defined:
28884
28885@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
28886@gccoptlist{-mcustom-fmuls=252
28887-mcustom-fadds=253
28888-mcustom-fsubs=254
d77de738
ML
28889-fsingle-precision-constant}
28890
28891@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
28892@gccoptlist{-mcustom-fmuls=252
28893-mcustom-fadds=253
28894-mcustom-fsubs=254
28895-mcustom-fdivs=255
d77de738
ML
28896-fsingle-precision-constant}
28897
28898@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
28899@gccoptlist{-mcustom-floatus=243
28900-mcustom-fixsi=244
28901-mcustom-floatis=245
28902-mcustom-fcmpgts=246
28903-mcustom-fcmples=249
28904-mcustom-fcmpeqs=250
28905-mcustom-fcmpnes=251
28906-mcustom-fmuls=252
28907-mcustom-fadds=253
28908-mcustom-fsubs=254
28909-mcustom-fdivs=255
d77de738
ML
28910-fsingle-precision-constant}
28911
28912@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
28913@gccoptlist{-mcustom-fabss=224
28914-mcustom-fnegs=225
28915-mcustom-fcmpnes=226
28916-mcustom-fcmpeqs=227
28917-mcustom-fcmpges=228
28918-mcustom-fcmpgts=229
28919-mcustom-fcmples=230
28920-mcustom-fcmplts=231
28921-mcustom-fmaxs=232
28922-mcustom-fmins=233
28923-mcustom-round=248
28924-mcustom-fixsi=249
28925-mcustom-floatis=250
28926-mcustom-fsqrts=251
28927-mcustom-fmuls=252
28928-mcustom-fadds=253
28929-mcustom-fsubs=254
28930-mcustom-fdivs=255}
d77de738
ML
28931
28932Custom instruction assignments given by individual
28933@option{-mcustom-@var{insn}=} options override those given by
28934@option{-mcustom-fpu-cfg=}, regardless of the
28935order of the options on the command line.
28936
28937Note that you can gain more local control over selection of a FPU
28938configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28939function attribute (@pxref{Function Attributes})
28940or pragma (@pxref{Function Specific Option Pragmas}).
28941
28942The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28943Hardware 2 Component}. Please note that the custom instructions enabled by
28944@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28945if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28946@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28947specified. In contrast to the other configurations,
28948@option{-fsingle-precision-constant} is not set.
28949
28950@end table
28951
28952These additional @samp{-m} options are available for the Altera Nios II
28953ELF (bare-metal) target:
28954
28955@table @gcctabopt
28956
d77de738 28957@opindex mhal
ddf6fe37 28958@item -mhal
d77de738
ML
28959Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28960startup and termination code, and is typically used in conjunction with
28961@option{-msys-crt0=} to specify the location of the alternate startup code
28962provided by the HAL BSP.
28963
d77de738 28964@opindex msmallc
ddf6fe37 28965@item -msmallc
d77de738
ML
28966Link with a limited version of the C library, @option{-lsmallc}, rather than
28967Newlib.
28968
d77de738 28969@opindex msys-crt0
ddf6fe37 28970@item -msys-crt0=@var{startfile}
d77de738
ML
28971@var{startfile} is the file name of the startfile (crt0) to use
28972when linking. This option is only useful in conjunction with @option{-mhal}.
28973
d77de738 28974@opindex msys-lib
ddf6fe37 28975@item -msys-lib=@var{systemlib}
d77de738
ML
28976@var{systemlib} is the library name of the library that provides
28977low-level system calls required by the C library,
28978e.g.@: @code{read} and @code{write}.
28979This option is typically used to link with a library provided by a HAL BSP.
28980
28981@end table
28982
28983@node Nvidia PTX Options
28984@subsection Nvidia PTX Options
28985@cindex Nvidia PTX options
28986@cindex nvptx options
28987
28988These options are defined for Nvidia PTX:
28989
28990@table @gcctabopt
28991
d77de738 28992@opindex m64
ddf6fe37 28993@item -m64
d77de738
ML
28994Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28995supported.
28996
d77de738 28997@opindex march
ddf6fe37 28998@item -march=@var{architecture-string}
d77de738
ML
28999Generate code for the specified PTX ISA target architecture
29000(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
29001@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
29002@samp{sm_80}.
29003The default depends on how the compiler has been configured, see
29004@option{--with-arch}.
29005
29006This option sets the value of the preprocessor macro
29007@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
29008@samp{350}.
29009
d77de738 29010@opindex misa
ddf6fe37 29011@item -misa=@var{architecture-string}
d77de738
ML
29012Alias of @option{-march=}.
29013
d77de738 29014@opindex march
ddf6fe37 29015@item -march-map=@var{architecture-string}
d77de738
ML
29016Select the closest available @option{-march=} value that is not more
29017capable. For instance, for @option{-march-map=sm_50} select
29018@option{-march=sm_35}, and for @option{-march-map=sm_53} select
29019@option{-march=sm_53}.
29020
d77de738 29021@opindex mptx
ddf6fe37 29022@item -mptx=@var{version-string}
d77de738
ML
29023Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
29024Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
29025@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
29026version is required for specified PTX ISA target architecture via
29027option @option{-march=}.
29028
29029This option sets the values of the preprocessor macros
29030@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
29031for instance, for @samp{3.1} the macros have the values @samp{3} and
29032@samp{1}, respectively.
29033
d77de738 29034@opindex mmainkernel
ddf6fe37 29035@item -mmainkernel
d77de738
ML
29036Link in code for a __main kernel. This is for stand-alone instead of
29037offloading execution.
29038
d77de738 29039@opindex moptimize
ddf6fe37 29040@item -moptimize
d77de738
ML
29041Apply partitioned execution optimizations. This is the default when any
29042level of optimization is selected.
29043
d77de738 29044@opindex msoft-stack
ddf6fe37 29045@item -msoft-stack
d77de738
ML
29046Generate code that does not use @code{.local} memory
29047directly for stack storage. Instead, a per-warp stack pointer is
29048maintained explicitly. This enables variable-length stack allocation (with
29049variable-length arrays or @code{alloca}), and when global memory is used for
29050underlying storage, makes it possible to access automatic variables from other
29051threads, or with atomic instructions. This code generation variant is used
29052for OpenMP offloading, but the option is exposed on its own for the purpose
29053of testing the compiler; to generate code suitable for linking into programs
29054using OpenMP offloading, use option @option{-mgomp}.
29055
d77de738 29056@opindex muniform-simt
ddf6fe37 29057@item -muniform-simt
d77de738
ML
29058Switch to code generation variant that allows to execute all threads in each
29059warp, while maintaining memory state and side effects as if only one thread
29060in each warp was active outside of OpenMP SIMD regions. All atomic operations
29061and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
29062current lane index equals the master lane index), and the register being
29063assigned is copied via a shuffle instruction from the master lane. Outside of
29064SIMD regions lane 0 is the master; inside, each thread sees itself as the
29065master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
29066all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
29067regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
29068with current lane index to compute the master lane index.
29069
d77de738 29070@opindex mgomp
ddf6fe37 29071@item -mgomp
d77de738
ML
29072Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
29073@option{-muniform-simt} options, and selects corresponding multilib variant.
29074
29075@end table
29076
29077@node OpenRISC Options
29078@subsection OpenRISC Options
29079@cindex OpenRISC Options
29080
29081These options are defined for OpenRISC:
29082
29083@table @gcctabopt
29084
d77de738 29085@opindex mboard
ddf6fe37 29086@item -mboard=@var{name}
d77de738
ML
29087Configure a board specific runtime. This will be passed to the linker for
29088newlib board library linking. The default is @code{or1ksim}.
29089
d77de738 29090@opindex mnewlib
ddf6fe37 29091@item -mnewlib
d77de738
ML
29092This option is ignored; it is for compatibility purposes only. This used to
29093select linker and preprocessor options for use with newlib.
29094
d77de738
ML
29095@opindex msoft-div
29096@opindex mhard-div
ddf6fe37
AA
29097@item -msoft-div
29098@itemx -mhard-div
d77de738
ML
29099Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
29100This default is hardware divide.
29101
d77de738
ML
29102@opindex msoft-mul
29103@opindex mhard-mul
ddf6fe37
AA
29104@item -msoft-mul
29105@itemx -mhard-mul
d77de738
ML
29106Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
29107This default is hardware multiply.
29108
d77de738
ML
29109@opindex msoft-float
29110@opindex mhard-float
ddf6fe37
AA
29111@item -msoft-float
29112@itemx -mhard-float
d77de738
ML
29113Select software or hardware for floating point operations.
29114The default is software.
29115
d77de738 29116@opindex mdouble-float
ddf6fe37 29117@item -mdouble-float
d77de738
ML
29118When @option{-mhard-float} is selected, enables generation of double-precision
29119floating point instructions. By default functions from @file{libgcc} are used
29120to perform double-precision floating point operations.
29121
d77de738 29122@opindex munordered-float
ddf6fe37 29123@item -munordered-float
d77de738
ML
29124When @option{-mhard-float} is selected, enables generation of unordered
29125floating point compare and set flag (@code{lf.sfun*}) instructions. By default
29126functions from @file{libgcc} are used to perform unordered floating point
29127compare and set flag operations.
29128
d77de738 29129@opindex mcmov
ddf6fe37 29130@item -mcmov
d77de738
ML
29131Enable generation of conditional move (@code{l.cmov}) instructions. By
29132default the equivalent will be generated using set and branch.
29133
d77de738 29134@opindex mror
ddf6fe37 29135@item -mror
d77de738
ML
29136Enable generation of rotate right (@code{l.ror}) instructions. By default
29137functions from @file{libgcc} are used to perform rotate right operations.
29138
d77de738 29139@opindex mrori
ddf6fe37 29140@item -mrori
d77de738
ML
29141Enable generation of rotate right with immediate (@code{l.rori}) instructions.
29142By default functions from @file{libgcc} are used to perform rotate right with
29143immediate operations.
29144
d77de738 29145@opindex msext
ddf6fe37 29146@item -msext
d77de738
ML
29147Enable generation of sign extension (@code{l.ext*}) instructions. By default
29148memory loads are used to perform sign extension.
29149
d77de738 29150@opindex msfimm
ddf6fe37 29151@item -msfimm
d77de738
ML
29152Enable generation of compare and set flag with immediate (@code{l.sf*i})
29153instructions. By default extra instructions will be generated to store the
29154immediate to a register first.
29155
d77de738 29156@opindex mshftimm
ddf6fe37 29157@item -mshftimm
d77de738
ML
29158Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
29159@code{l.slli}) instructions. By default extra instructions will be generated
29160to store the immediate to a register first.
29161
d77de738 29162@opindex mcmodel=small
ddf6fe37 29163@item -mcmodel=small
d77de738
ML
29164Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
29165the default model.
29166
d77de738 29167@opindex mcmodel=large
ddf6fe37 29168@item -mcmodel=large
d77de738
ML
29169Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
29170
29171
29172@end table
29173
29174@node PDP-11 Options
29175@subsection PDP-11 Options
29176@cindex PDP-11 Options
29177
29178These options are defined for the PDP-11:
29179
29180@table @gcctabopt
d77de738 29181@opindex mfpu
ddf6fe37 29182@item -mfpu
d77de738
ML
29183Use hardware FPP floating point. This is the default. (FIS floating
29184point on the PDP-11/40 is not supported.) Implies -m45.
29185
d77de738 29186@opindex msoft-float
ddf6fe37 29187@item -msoft-float
d77de738
ML
29188Do not use hardware floating point.
29189
d77de738 29190@opindex mac0
ddf6fe37 29191@item -mac0
d77de738
ML
29192Return floating-point results in ac0 (fr0 in Unix assembler syntax).
29193
d77de738 29194@opindex mno-ac0
ddf6fe37 29195@item -mno-ac0
d77de738
ML
29196Return floating-point results in memory. This is the default.
29197
d77de738 29198@opindex m40
ddf6fe37 29199@item -m40
d77de738
ML
29200Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
29201
d77de738 29202@opindex m45
ddf6fe37 29203@item -m45
d77de738
ML
29204Generate code for a PDP-11/45. This is the default.
29205
d77de738 29206@opindex m10
ddf6fe37 29207@item -m10
d77de738
ML
29208Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
29209
d77de738
ML
29210@opindex mint16
29211@opindex mno-int32
ddf6fe37
AA
29212@item -mint16
29213@itemx -mno-int32
d77de738
ML
29214Use 16-bit @code{int}. This is the default.
29215
d77de738
ML
29216@opindex mint32
29217@opindex mno-int16
ddf6fe37
AA
29218@item -mint32
29219@itemx -mno-int16
d77de738
ML
29220Use 32-bit @code{int}.
29221
d77de738 29222@opindex msplit
ddf6fe37 29223@item -msplit
d77de738
ML
29224Target has split instruction and data space. Implies -m45.
29225
d77de738 29226@opindex munix-asm
ddf6fe37 29227@item -munix-asm
d77de738
ML
29228Use Unix assembler syntax.
29229
d77de738 29230@opindex mdec-asm
ddf6fe37 29231@item -mdec-asm
d77de738
ML
29232Use DEC assembler syntax.
29233
d77de738 29234@opindex mgnu-asm
ddf6fe37 29235@item -mgnu-asm
d77de738
ML
29236Use GNU assembler syntax. This is the default.
29237
d77de738 29238@opindex mlra
ddf6fe37 29239@item -mlra
d77de738
ML
29240Use the new LRA register allocator. By default, the old ``reload''
29241allocator is used.
29242@end table
29243
d77de738
ML
29244@node PowerPC Options
29245@subsection PowerPC Options
29246@cindex PowerPC options
29247
29248These are listed under @xref{RS/6000 and PowerPC Options}.
29249
29250@node PRU Options
29251@subsection PRU Options
29252@cindex PRU Options
29253
29254These command-line options are defined for PRU target:
29255
29256@table @gcctabopt
d77de738 29257@opindex minrt
ddf6fe37 29258@item -minrt
d77de738
ML
29259Link with a minimum runtime environment, with no support for static
29260initializers and constructors. Using this option can significantly reduce
29261the size of the final ELF binary. Beware that the compiler could still
29262generate code with static initializers and constructors. It is up to the
29263programmer to ensure that the source program will not use those features.
29264
d77de738 29265@opindex mmcu
ddf6fe37 29266@item -mmcu=@var{mcu}
d77de738
ML
29267Specify the PRU MCU variant to use. Check Newlib for the exact list of
29268supported MCUs.
29269
d77de738 29270@opindex mno-relax
ddf6fe37 29271@item -mno-relax
d77de738
ML
29272Make GCC pass the @option{--no-relax} command-line option to the linker
29273instead of the @option{--relax} option.
29274
d77de738 29275@opindex mloop
ddf6fe37 29276@item -mloop
d77de738
ML
29277Allow (or do not allow) GCC to use the LOOP instruction.
29278
d77de738 29279@opindex mabi
ddf6fe37 29280@item -mabi=@var{variant}
d77de738
ML
29281Specify the ABI variant to output code for. @option{-mabi=ti} selects the
29282unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
29283more naturally with certain GCC assumptions. These are the differences:
29284
29285@table @samp
29286@item Function Pointer Size
29287TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
29288supports only 32-bit data and code pointers.
29289
29290@item Optional Return Value Pointer
29291Function return values larger than 64 bits are passed by using a hidden
29292pointer as the first argument of the function. TI ABI, though, mandates that
29293the pointer can be NULL in case the caller is not using the returned value.
29294GNU always passes and expects a valid return value pointer.
29295
29296@end table
29297
29298The current @option{-mabi=ti} implementation simply raises a compile error
29299when any of the above code constructs is detected. As a consequence
29300the standard C library cannot be built and it is omitted when linking with
29301@option{-mabi=ti}.
29302
29303Relaxation is a GNU feature and for safety reasons is disabled when using
29304@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
29305instructions, so the GNU linker cannot adjust them when shortening adjacent
29306LDI32 pseudo instructions.
29307
29308@end table
29309
29310@node RISC-V Options
29311@subsection RISC-V Options
29312@cindex RISC-V Options
29313
29314These command-line options are defined for RISC-V targets:
29315
29316@table @gcctabopt
d77de738 29317@opindex mbranch-cost
ddf6fe37 29318@item -mbranch-cost=@var{n}
d77de738
ML
29319Set the cost of branches to roughly @var{n} instructions.
29320
ddf6fe37 29321@opindex plt
d77de738
ML
29322@item -mplt
29323@itemx -mno-plt
d77de738
ML
29324When generating PIC code, do or don't allow the use of PLTs. Ignored for
29325non-PIC. The default is @option{-mplt}.
29326
d77de738 29327@opindex mabi
ddf6fe37 29328@item -mabi=@var{ABI-string}
d77de738
ML
29329Specify integer and floating-point calling convention. @var{ABI-string}
29330contains two parts: the size of integer types and the registers used for
29331floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
29332@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2933332-bit), and that floating-point values up to 64 bits wide are passed in F
29334registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
29335allows the compiler to generate code that uses the F and D extensions but only
29336allows floating-point values up to 32 bits long to be passed in registers; or
29337@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
29338passed in registers.
29339
29340The default for this argument is system dependent, users who want a specific
29341calling convention should specify one explicitly. The valid calling
29342conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
29343@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
29344implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
29345invalid because the ABI requires 64-bit values be passed in F registers, but F
29346registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
29347only be used with the @samp{rv32e} architecture. This ABI is not well
29348specified at present, and is subject to change.
29349
ddf6fe37 29350@opindex mfdiv
d77de738
ML
29351@item -mfdiv
29352@itemx -mno-fdiv
d77de738
ML
29353Do or don't use hardware floating-point divide and square root instructions.
29354This requires the F or D extensions for floating-point registers. The default
29355is to use them if the specified architecture has these instructions.
29356
ddf6fe37 29357@opindex mdiv
d77de738
ML
29358@item -mdiv
29359@itemx -mno-div
d77de738
ML
29360Do or don't use hardware instructions for integer division. This requires the
29361M extension. The default is to use them if the specified architecture has
29362these instructions.
29363
d77de738 29364@opindex misa-spec
ddf6fe37 29365@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
29366Specify the version of the RISC-V Unprivileged (formerly User-Level)
29367ISA specification to produce code conforming to. The possibilities
29368for @var{ISA-spec-string} are:
29369@table @code
29370@item 2.2
29371Produce code conforming to version 2.2.
29372@item 20190608
29373Produce code conforming to version 20190608.
29374@item 20191213
29375Produce code conforming to version 20191213.
29376@end table
29377The default is @option{-misa-spec=20191213} unless GCC has been configured
29378with @option{--with-isa-spec=} specifying a different default version.
29379
d77de738 29380@opindex march
ddf6fe37 29381@item -march=@var{ISA-string}
d77de738
ML
29382Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
29383lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
29384@samp{rv32imaf}.
29385
29386When @option{-march=} is not specified, use the setting from @option{-mcpu}.
29387
29388If both @option{-march} and @option{-mcpu=} are not specified, the default for
29389this argument is system dependent, users who want a specific architecture
29390extensions should specify one explicitly.
29391
d77de738 29392@opindex mcpu
ddf6fe37 29393@item -mcpu=@var{processor-string}
d77de738
ML
29394Use architecture of and optimize the output for the given processor, specified
29395by particular CPU name.
29396Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
29397@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
29398@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 29399@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 29400
d77de738 29401@opindex mtune
ddf6fe37 29402@item -mtune=@var{processor-string}
d77de738
ML
29403Optimize the output for the given processor, specified by microarchitecture or
29404particular CPU name. Permissible values for this option are: @samp{rocket},
29405@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 29406@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
29407
29408When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
29409the default is @samp{rocket} if both are not specified.
29410
29411The @samp{size} choice is not intended for use by end-users. This is used
29412when @option{-Os} is specified. It overrides the instruction cost info
29413provided by @option{-mtune=}, but does not override the pipeline info. This
29414helps reduce code size while still giving good performance.
29415
d77de738 29416@opindex mpreferred-stack-boundary
ddf6fe37 29417@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
29418Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
29419byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
29420the default is 4 (16 bytes or 128-bits).
29421
29422@strong{Warning:} If you use this switch, then you must build all modules with
29423the same value, including any libraries. This includes the system libraries
29424and startup modules.
29425
d77de738 29426@opindex msmall-data-limit
ddf6fe37 29427@item -msmall-data-limit=@var{n}
d77de738
ML
29428Put global and static data smaller than @var{n} bytes into a special section
29429(on some targets).
29430
ddf6fe37 29431@opindex msave-restore
d77de738
ML
29432@item -msave-restore
29433@itemx -mno-save-restore
d77de738
ML
29434Do or don't use smaller but slower prologue and epilogue code that uses
29435library function calls. The default is to use fast inline prologues and
29436epilogues.
29437
f797260a
PN
29438@opindex minline-atomics
29439@item -minline-atomics
29440@itemx -mno-inline-atomics
29441Do or don't use smaller but slower subword atomic emulation code that uses
29442libatomic function calls. The default is to use fast inline subword atomics
29443that do not require libatomic.
29444
df48285b
CM
29445@opindex minline-strlen
29446@item -minline-strlen
29447@itemx -mno-inline-strlen
29448Do or do not attempt to inline strlen calls if possible.
29449Inlining will only be done if the string is properly aligned
29450and instructions for accelerated processing are available.
29451The default is to not inline strlen calls.
29452
949f1ccf
CM
29453@opindex minline-strcmp
29454@item -minline-strcmp
29455@itemx -mno-inline-strcmp
29456Do or do not attempt to inline strcmp calls if possible.
29457Inlining will only be done if the strings are properly aligned
29458and instructions for accelerated processing are available.
29459The default is to not inline strcmp calls.
29460
29461@opindex minline-strncmp
29462@item -minline-strncmp
29463@itemx -mno-inline-strncmp
29464Do or do not attempt to inline strncmp calls if possible.
29465Inlining will only be done if the strings are properly aligned
29466and instructions for accelerated processing are available.
29467The default is to not inline strncmp calls.
29468
ddf6fe37 29469@opindex mshorten-memrefs
d77de738
ML
29470@item -mshorten-memrefs
29471@itemx -mno-shorten-memrefs
d77de738
ML
29472Do or do not attempt to make more use of compressed load/store instructions by
29473replacing a load/store of 'base register + large offset' with a new load/store
29474of 'new base + small offset'. If the new base gets stored in a compressed
29475register, then the new load/store can be compressed. Currently targets 32-bit
29476integer load/stores only.
29477
ddf6fe37 29478@opindex mstrict-align
d77de738
ML
29479@item -mstrict-align
29480@itemx -mno-strict-align
d77de738
ML
29481Do not or do generate unaligned memory accesses. The default is set depending
29482on whether the processor we are optimizing for supports fast unaligned access
29483or not.
29484
d77de738 29485@opindex mcmodel=medlow
ddf6fe37 29486@item -mcmodel=medlow
d77de738
ML
29487Generate code for the medium-low code model. The program and its statically
29488defined symbols must lie within a single 2 GiB address range and must lie
29489between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29490statically or dynamically linked. This is the default code model.
29491
d77de738 29492@opindex mcmodel=medany
ddf6fe37 29493@item -mcmodel=medany
d77de738
ML
29494Generate code for the medium-any code model. The program and its statically
29495defined symbols must be within any single 2 GiB address range. Programs can be
29496statically or dynamically linked.
29497
29498The code generated by the medium-any code model is position-independent, but is
29499not guaranteed to function correctly when linked into position-independent
29500executables or libraries.
29501
29502@item -mexplicit-relocs
29503@itemx -mno-exlicit-relocs
29504Use or do not use assembler relocation operators when dealing with symbolic
29505addresses. The alternative is to use assembler macros instead, which may
29506limit optimization.
29507
ddf6fe37 29508@opindex mrelax
d77de738
ML
29509@item -mrelax
29510@itemx -mno-relax
d77de738
ML
29511Take advantage of linker relaxations to reduce the number of instructions
29512required to materialize symbol addresses. The default is to take advantage of
29513linker relaxations.
29514
ddf6fe37 29515@opindex mriscv-attribute
d77de738
ML
29516@item -mriscv-attribute
29517@itemx -mno-riscv-attribute
d77de738
ML
29518Emit (do not emit) RISC-V attribute to record extra information into ELF
29519objects. This feature requires at least binutils 2.32.
29520
ddf6fe37 29521@opindex mcsr-check
d77de738
ML
29522@item -mcsr-check
29523@itemx -mno-csr-check
d77de738
ML
29524Enables or disables the CSR checking.
29525
d77de738 29526@opindex malign-data
ddf6fe37 29527@item -malign-data=@var{type}
d77de738
ML
29528Control how GCC aligns variables and constants of array, structure, or union
29529types. Supported values for @var{type} are @samp{xlen} which uses x register
29530width as the alignment value, and @samp{natural} which uses natural alignment.
29531@samp{xlen} is the default.
29532
d77de738 29533@opindex mbig-endian
ddf6fe37 29534@item -mbig-endian
d77de738
ML
29535Generate big-endian code. This is the default when GCC is configured for a
29536@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29537
d77de738 29538@opindex mlittle-endian
ddf6fe37 29539@item -mlittle-endian
d77de738
ML
29540Generate little-endian code. This is the default when GCC is configured for a
29541@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29542@samp{riscv32be-*-*} target.
29543
d77de738
ML
29544@opindex mstack-protector-guard
29545@opindex mstack-protector-guard-reg
29546@opindex mstack-protector-guard-offset
ddf6fe37
AA
29547@item -mstack-protector-guard=@var{guard}
29548@itemx -mstack-protector-guard-reg=@var{reg}
29549@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29550Generate stack protection code using canary at @var{guard}. Supported
29551locations are @samp{global} for a global canary or @samp{tls} for per-thread
29552canary in the TLS block.
29553
29554With the latter choice the options
29555@option{-mstack-protector-guard-reg=@var{reg}} and
29556@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29557which register to use as base register for reading the canary,
29558and from what offset from that base register. There is no default
29559register or offset as this is entirely for use within the Linux
29560kernel.
29561@end table
29562
29563@node RL78 Options
29564@subsection RL78 Options
29565@cindex RL78 Options
29566
29567@table @gcctabopt
29568
d77de738 29569@opindex msim
ddf6fe37 29570@item -msim
d77de738
ML
29571Links in additional target libraries to support operation within a
29572simulator.
29573
ddf6fe37 29574@opindex mmul
d77de738
ML
29575@item -mmul=none
29576@itemx -mmul=g10
29577@itemx -mmul=g13
29578@itemx -mmul=g14
29579@itemx -mmul=rl78
d77de738
ML
29580Specifies the type of hardware multiplication and division support to
29581be used. The simplest is @code{none}, which uses software for both
29582multiplication and division. This is the default. The @code{g13}
29583value is for the hardware multiply/divide peripheral found on the
29584RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29585the multiplication and division instructions supported by the RL78/G14
29586(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29587the value @code{mg10} is an alias for @code{none}.
29588
29589In addition a C preprocessor macro is defined, based upon the setting
29590of this option. Possible values are: @code{__RL78_MUL_NONE__},
29591@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29592
ddf6fe37 29593@opindex mcpu
d77de738
ML
29594@item -mcpu=g10
29595@itemx -mcpu=g13
29596@itemx -mcpu=g14
29597@itemx -mcpu=rl78
d77de738
ML
29598Specifies the RL78 core to target. The default is the G14 core, also
29599known as an S3 core or just RL78. The G13 or S2 core does not have
29600multiply or divide instructions, instead it uses a hardware peripheral
29601for these operations. The G10 or S1 core does not have register
29602banks, so it uses a different calling convention.
29603
29604If this option is set it also selects the type of hardware multiply
29605support to use, unless this is overridden by an explicit
29606@option{-mmul=none} option on the command line. Thus specifying
29607@option{-mcpu=g13} enables the use of the G13 hardware multiply
29608peripheral and specifying @option{-mcpu=g10} disables the use of
29609hardware multiplications altogether.
29610
29611Note, although the RL78/G14 core is the default target, specifying
29612@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29613change the behavior of the toolchain since it also enables G14
29614hardware multiply support. If these options are not specified on the
29615command line then software multiplication routines will be used even
29616though the code targets the RL78 core. This is for backwards
29617compatibility with older toolchains which did not have hardware
29618multiply and divide support.
29619
29620In addition a C preprocessor macro is defined, based upon the setting
29621of this option. Possible values are: @code{__RL78_G10__},
29622@code{__RL78_G13__} or @code{__RL78_G14__}.
29623
d77de738
ML
29624@opindex mg10
29625@opindex mg13
29626@opindex mg14
29627@opindex mrl78
ddf6fe37
AA
29628@item -mg10
29629@itemx -mg13
29630@itemx -mg14
29631@itemx -mrl78
d77de738
ML
29632These are aliases for the corresponding @option{-mcpu=} option. They
29633are provided for backwards compatibility.
29634
d77de738 29635@opindex mallregs
ddf6fe37 29636@item -mallregs
d77de738
ML
29637Allow the compiler to use all of the available registers. By default
29638registers @code{r24..r31} are reserved for use in interrupt handlers.
29639With this option enabled these registers can be used in ordinary
29640functions as well.
29641
d77de738
ML
29642@opindex m64bit-doubles
29643@opindex m32bit-doubles
ddf6fe37
AA
29644@item -m64bit-doubles
29645@itemx -m32bit-doubles
d77de738
ML
29646Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29647or 32 bits (@option{-m32bit-doubles}) in size. The default is
29648@option{-m32bit-doubles}.
29649
d77de738
ML
29650@opindex msave-mduc-in-interrupts
29651@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29652@item -msave-mduc-in-interrupts
29653@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29654Specifies that interrupt handler functions should preserve the
29655MDUC registers. This is only necessary if normal code might use
29656the MDUC registers, for example because it performs multiplication
29657and division operations. The default is to ignore the MDUC registers
29658as this makes the interrupt handlers faster. The target option -mg13
29659needs to be passed for this to work as this feature is only available
29660on the G13 target (S2 core). The MDUC registers will only be saved
29661if the interrupt handler performs a multiplication or division
29662operation or it calls another function.
29663
29664@end table
29665
29666@node RS/6000 and PowerPC Options
29667@subsection IBM RS/6000 and PowerPC Options
29668@cindex RS/6000 and PowerPC Options
29669@cindex IBM RS/6000 and PowerPC Options
29670
29671These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29672@table @gcctabopt
29673@item -mpowerpc-gpopt
29674@itemx -mno-powerpc-gpopt
29675@itemx -mpowerpc-gfxopt
29676@itemx -mno-powerpc-gfxopt
29677@need 800
29678@itemx -mpowerpc64
29679@itemx -mno-powerpc64
29680@itemx -mmfcrf
29681@itemx -mno-mfcrf
29682@itemx -mpopcntb
29683@itemx -mno-popcntb
29684@itemx -mpopcntd
29685@itemx -mno-popcntd
29686@itemx -mfprnd
29687@itemx -mno-fprnd
29688@need 800
d77de738
ML
29689@opindex mpowerpc-gpopt
29690@opindex mno-powerpc-gpopt
29691@opindex mpowerpc-gfxopt
29692@opindex mno-powerpc-gfxopt
29693@opindex mpowerpc64
29694@opindex mno-powerpc64
29695@opindex mmfcrf
29696@opindex mno-mfcrf
29697@opindex mpopcntb
29698@opindex mno-popcntb
29699@opindex mpopcntd
29700@opindex mno-popcntd
29701@opindex mfprnd
29702@opindex mno-fprnd
29703@opindex mcmpb
29704@opindex mno-cmpb
29705@opindex mhard-dfp
29706@opindex mno-hard-dfp
ddf6fe37
AA
29707@itemx -mcmpb
29708@itemx -mno-cmpb
29709@itemx -mhard-dfp
29710@itemx -mno-hard-dfp
d77de738
ML
29711You use these options to specify which instructions are available on the
29712processor you are using. The default value of these options is
29713determined when configuring GCC@. Specifying the
29714@option{-mcpu=@var{cpu_type}} overrides the specification of these
29715options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29716rather than the options listed above.
29717
29718Specifying @option{-mpowerpc-gpopt} allows
29719GCC to use the optional PowerPC architecture instructions in the
29720General Purpose group, including floating-point square root. Specifying
29721@option{-mpowerpc-gfxopt} allows GCC to
29722use the optional PowerPC architecture instructions in the Graphics
29723group, including floating-point select.
29724
29725The @option{-mmfcrf} option allows GCC to generate the move from
29726condition register field instruction implemented on the POWER4
29727processor and other processors that support the PowerPC V2.01
29728architecture.
29729The @option{-mpopcntb} option allows GCC to generate the popcount and
29730double-precision FP reciprocal estimate instruction implemented on the
29731POWER5 processor and other processors that support the PowerPC V2.02
29732architecture.
29733The @option{-mpopcntd} option allows GCC to generate the popcount
29734instruction implemented on the POWER7 processor and other processors
29735that support the PowerPC V2.06 architecture.
29736The @option{-mfprnd} option allows GCC to generate the FP round to
29737integer instructions implemented on the POWER5+ processor and other
29738processors that support the PowerPC V2.03 architecture.
29739The @option{-mcmpb} option allows GCC to generate the compare bytes
29740instruction implemented on the POWER6 processor and other processors
29741that support the PowerPC V2.05 architecture.
29742The @option{-mhard-dfp} option allows GCC to generate the decimal
29743floating-point instructions implemented on some POWER processors.
29744
29745The @option{-mpowerpc64} option allows GCC to generate the additional
2974664-bit instructions that are found in the full PowerPC64 architecture
29747and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29748@option{-mno-powerpc64}.
29749
d77de738 29750@opindex mcpu
ddf6fe37 29751@item -mcpu=@var{cpu_type}
d77de738
ML
29752Set architecture type, register usage, and
29753instruction scheduling parameters for machine type @var{cpu_type}.
29754Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29755@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29756@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29757@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29758@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29759@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29760@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29761@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29762@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29763@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29764@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29765@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29766
29767@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29768@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29769endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29770architecture machine types, with an appropriate, generic processor
29771model assumed for scheduling purposes.
29772
29773Specifying @samp{native} as cpu type detects and selects the
29774architecture option that corresponds to the host processor of the
29775system performing the compilation.
29776@option{-mcpu=native} has no effect if GCC does not recognize the
29777processor.
29778
29779The other options specify a specific processor. Code generated under
29780those options runs best on that processor, and may not run at all on
29781others.
29782
29783The @option{-mcpu} options automatically enable or disable the
29784following options:
29785
43b72ede
AA
29786@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
29787-mpopcntb -mpopcntd -mpowerpc64
29788-mpowerpc-gpopt -mpowerpc-gfxopt
29789-mmulhw -mdlmzb -mmfpgpr -mvsx
29790-mcrypto -mhtm -mpower8-fusion -mpower8-vector
29791-mquad-memory -mquad-memory-atomic -mfloat128
29792-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
29793-mrop-protect}
29794
29795The particular options set for any particular CPU varies between
29796compiler versions, depending on what setting seems to produce optimal
29797code for that CPU; it doesn't necessarily reflect the actual hardware's
29798capabilities. If you wish to set an individual option to a particular
29799value, you may specify it after the @option{-mcpu} option, like
29800@option{-mcpu=970 -mno-altivec}.
29801
29802On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29803not enabled or disabled by the @option{-mcpu} option at present because
29804AIX does not have full support for these options. You may still
29805enable or disable them individually if you're sure it'll work in your
29806environment.
29807
d77de738 29808@opindex mtune
ddf6fe37 29809@item -mtune=@var{cpu_type}
d77de738
ML
29810Set the instruction scheduling parameters for machine type
29811@var{cpu_type}, but do not set the architecture type or register usage,
29812as @option{-mcpu=@var{cpu_type}} does. The same
29813values for @var{cpu_type} are used for @option{-mtune} as for
29814@option{-mcpu}. If both are specified, the code generated uses the
29815architecture and registers set by @option{-mcpu}, but the
29816scheduling parameters set by @option{-mtune}.
29817
d77de738 29818@opindex mcmodel=small
ddf6fe37 29819@item -mcmodel=small
d77de738
ML
29820Generate PowerPC64 code for the small model: The TOC is limited to
2982164k.
29822
d77de738 29823@opindex mcmodel=medium
ddf6fe37 29824@item -mcmodel=medium
d77de738
ML
29825Generate PowerPC64 code for the medium model: The TOC and other static
29826data may be up to a total of 4G in size. This is the default for 64-bit
29827Linux.
29828
d77de738 29829@opindex mcmodel=large
ddf6fe37 29830@item -mcmodel=large
d77de738
ML
29831Generate PowerPC64 code for the large model: The TOC may be up to 4G
29832in size. Other data and code is only limited by the 64-bit address
29833space.
29834
d77de738
ML
29835@opindex maltivec
29836@opindex mno-altivec
ddf6fe37
AA
29837@item -maltivec
29838@itemx -mno-altivec
d77de738
ML
29839Generate code that uses (does not use) AltiVec instructions, and also
29840enable the use of built-in functions that allow more direct access to
29841the AltiVec instruction set. You may also need to set
29842@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29843enhancements.
29844
29845When @option{-maltivec} is used, the element order for AltiVec intrinsics
29846such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29847match array element order corresponding to the endianness of the
29848target. That is, element zero identifies the leftmost element in a
29849vector register when targeting a big-endian platform, and identifies
29850the rightmost element in a vector register when targeting a
29851little-endian platform.
29852
d77de738
ML
29853@opindex mvrsave
29854@opindex mno-vrsave
ddf6fe37
AA
29855@item -mvrsave
29856@itemx -mno-vrsave
d77de738
ML
29857Generate VRSAVE instructions when generating AltiVec code.
29858
d77de738 29859@opindex msecure-plt
ddf6fe37 29860@item -msecure-plt
d77de738
ML
29861Generate code that allows @command{ld} and @command{ld.so}
29862to build executables and shared
29863libraries with non-executable @code{.plt} and @code{.got} sections.
29864This is a PowerPC
2986532-bit SYSV ABI option.
29866
d77de738 29867@opindex mbss-plt
ddf6fe37 29868@item -mbss-plt
d77de738
ML
29869Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29870fills in, and
29871requires @code{.plt} and @code{.got}
29872sections that are both writable and executable.
29873This is a PowerPC 32-bit SYSV ABI option.
29874
d77de738
ML
29875@opindex misel
29876@opindex mno-isel
ddf6fe37
AA
29877@item -misel
29878@itemx -mno-isel
d77de738
ML
29879This switch enables or disables the generation of ISEL instructions.
29880
d77de738
ML
29881@opindex mvsx
29882@opindex mno-vsx
ddf6fe37
AA
29883@item -mvsx
29884@itemx -mno-vsx
d77de738
ML
29885Generate code that uses (does not use) vector/scalar (VSX)
29886instructions, and also enable the use of built-in functions that allow
29887more direct access to the VSX instruction set.
29888
d77de738
ML
29889@opindex mcrypto
29890@opindex mno-crypto
ddf6fe37
AA
29891@item -mcrypto
29892@itemx -mno-crypto
d77de738
ML
29893Enable the use (disable) of the built-in functions that allow direct
29894access to the cryptographic instructions that were added in version
298952.07 of the PowerPC ISA.
29896
d77de738
ML
29897@opindex mhtm
29898@opindex mno-htm
ddf6fe37
AA
29899@item -mhtm
29900@itemx -mno-htm
d77de738
ML
29901Enable (disable) the use of the built-in functions that allow direct
29902access to the Hardware Transactional Memory (HTM) instructions that
29903were added in version 2.07 of the PowerPC ISA.
29904
d77de738
ML
29905@opindex mpower8-fusion
29906@opindex mno-power8-fusion
ddf6fe37
AA
29907@item -mpower8-fusion
29908@itemx -mno-power8-fusion
d77de738
ML
29909Generate code that keeps (does not keeps) some integer operations
29910adjacent so that the instructions can be fused together on power8 and
29911later processors.
29912
d77de738
ML
29913@opindex mpower8-vector
29914@opindex mno-power8-vector
ddf6fe37
AA
29915@item -mpower8-vector
29916@itemx -mno-power8-vector
d77de738
ML
29917Generate code that uses (does not use) the vector and scalar
29918instructions that were added in version 2.07 of the PowerPC ISA. Also
29919enable the use of built-in functions that allow more direct access to
29920the vector instructions.
29921
d77de738
ML
29922@opindex mquad-memory
29923@opindex mno-quad-memory
ddf6fe37
AA
29924@item -mquad-memory
29925@itemx -mno-quad-memory
d77de738
ML
29926Generate code that uses (does not use) the non-atomic quad word memory
29927instructions. The @option{-mquad-memory} option requires use of
2992864-bit mode.
29929
d77de738
ML
29930@opindex mquad-memory-atomic
29931@opindex mno-quad-memory-atomic
ddf6fe37
AA
29932@item -mquad-memory-atomic
29933@itemx -mno-quad-memory-atomic
d77de738
ML
29934Generate code that uses (does not use) the atomic quad word memory
29935instructions. The @option{-mquad-memory-atomic} option requires use of
2993664-bit mode.
29937
d77de738
ML
29938@opindex mfloat128
29939@opindex mno-float128
ddf6fe37
AA
29940@item -mfloat128
29941@itemx -mno-float128
d77de738
ML
29942Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29943and use either software emulation for IEEE 128-bit floating point or
29944hardware instructions.
29945
29946The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29947128-bit floating point support. The IEEE 128-bit floating point is only
29948supported on Linux.
29949
29950The default for @option{-mfloat128} is enabled on PowerPC Linux
29951systems using the VSX instruction set, and disabled on other systems.
29952
29953If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29954@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29955point support will also enable the generation of ISA 3.0 IEEE 128-bit
29956floating point instructions. Otherwise, if you do not specify to
29957generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29958system, IEEE 128-bit floating point will be done with software
29959emulation.
29960
d77de738
ML
29961@opindex mfloat128-hardware
29962@opindex mno-float128-hardware
ddf6fe37
AA
29963@item -mfloat128-hardware
29964@itemx -mno-float128-hardware
d77de738
ML
29965Enable/disable using ISA 3.0 hardware instructions to support the
29966@var{__float128} data type.
29967
29968The default for @option{-mfloat128-hardware} is enabled on PowerPC
29969Linux systems using the ISA 3.0 instruction set, and disabled on other
29970systems.
29971
d77de738
ML
29972@opindex m32
29973@opindex m64
ddf6fe37
AA
29974@item -m32
29975@itemx -m64
d77de738
ML
29976Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29977targets (including GNU/Linux). The 32-bit environment sets int, long
29978and pointer to 32 bits and generates code that runs on any PowerPC
29979variant. The 64-bit environment sets int to 32 bits and long and
29980pointer to 64 bits, and generates code for PowerPC64, as for
29981@option{-mpowerpc64}.
29982
d77de738
ML
29983@opindex mfull-toc
29984@opindex mno-fp-in-toc
29985@opindex mno-sum-in-toc
29986@opindex mminimal-toc
ddf6fe37
AA
29987@item -mfull-toc
29988@itemx -mno-fp-in-toc
29989@itemx -mno-sum-in-toc
29990@itemx -mminimal-toc
d77de738
ML
29991Modify generation of the TOC (Table Of Contents), which is created for
29992every executable file. The @option{-mfull-toc} option is selected by
29993default. In that case, GCC allocates at least one TOC entry for
29994each unique non-automatic variable reference in your program. GCC
29995also places floating-point constants in the TOC@. However, only
2999616,384 entries are available in the TOC@.
29997
29998If you receive a linker error message that saying you have overflowed
29999the available TOC space, you can reduce the amount of TOC space used
30000with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
30001@option{-mno-fp-in-toc} prevents GCC from putting floating-point
30002constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
30003generate code to calculate the sum of an address and a constant at
30004run time instead of putting that sum into the TOC@. You may specify one
30005or both of these options. Each causes GCC to produce very slightly
30006slower and larger code at the expense of conserving TOC space.
30007
30008If you still run out of space in the TOC even when you specify both of
30009these options, specify @option{-mminimal-toc} instead. This option causes
30010GCC to make only one TOC entry for every file. When you specify this
30011option, GCC produces code that is slower and larger but which
30012uses extremely little TOC space. You may wish to use this option
30013only on files that contain less frequently-executed code.
30014
d77de738
ML
30015@opindex maix64
30016@opindex maix32
ddf6fe37
AA
30017@item -maix64
30018@itemx -maix32
d77de738
ML
30019Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
30020@code{long} type, and the infrastructure needed to support them.
30021Specifying @option{-maix64} implies @option{-mpowerpc64},
30022while @option{-maix32} disables the 64-bit ABI and
30023implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
30024
d77de738
ML
30025@opindex mxl-compat
30026@opindex mno-xl-compat
ddf6fe37
AA
30027@item -mxl-compat
30028@itemx -mno-xl-compat
d77de738
ML
30029Produce code that conforms more closely to IBM XL compiler semantics
30030when using AIX-compatible ABI@. Pass floating-point arguments to
30031prototyped functions beyond the register save area (RSA) on the stack
30032in addition to argument FPRs. Do not assume that most significant
30033double in 128-bit long double value is properly rounded when comparing
30034values and converting to double. Use XL symbol names for long double
30035support routines.
30036
30037The AIX calling convention was extended but not initially documented to
30038handle an obscure K&R C case of calling a function that takes the
30039address of its arguments with fewer arguments than declared. IBM XL
30040compilers access floating-point arguments that do not fit in the
30041RSA from the stack when a subroutine is compiled without
30042optimization. Because always storing floating-point arguments on the
30043stack is inefficient and rarely needed, this option is not enabled by
30044default and only is necessary when calling subroutines compiled by IBM
30045XL compilers without optimization.
30046
d77de738 30047@opindex mpe
ddf6fe37 30048@item -mpe
d77de738
ML
30049Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
30050application written to use message passing with special startup code to
30051enable the application to run. The system must have PE installed in the
30052standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
30053must be overridden with the @option{-specs=} option to specify the
30054appropriate directory location. The Parallel Environment does not
30055support threads, so the @option{-mpe} option and the @option{-pthread}
30056option are incompatible.
30057
d77de738
ML
30058@opindex malign-natural
30059@opindex malign-power
ddf6fe37
AA
30060@item -malign-natural
30061@itemx -malign-power
d77de738
ML
30062On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
30063@option{-malign-natural} overrides the ABI-defined alignment of larger
30064types, such as floating-point doubles, on their natural size-based boundary.
30065The option @option{-malign-power} instructs GCC to follow the ABI-specified
30066alignment rules. GCC defaults to the standard alignment defined in the ABI@.
30067
30068On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
30069is not supported.
30070
d77de738
ML
30071@opindex msoft-float
30072@opindex mhard-float
ddf6fe37
AA
30073@item -msoft-float
30074@itemx -mhard-float
d77de738
ML
30075Generate code that does not use (uses) the floating-point register set.
30076Software floating-point emulation is provided if you use the
30077@option{-msoft-float} option, and pass the option to GCC when linking.
30078
d77de738
ML
30079@opindex mmultiple
30080@opindex mno-multiple
ddf6fe37
AA
30081@item -mmultiple
30082@itemx -mno-multiple
d77de738
ML
30083Generate code that uses (does not use) the load multiple word
30084instructions and the store multiple word instructions. These
30085instructions are generated by default on POWER systems, and not
30086generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
30087PowerPC systems, since those instructions do not work when the
30088processor is in little-endian mode. The exceptions are PPC740 and
30089PPC750 which permit these instructions in little-endian mode.
30090
d77de738
ML
30091@opindex mupdate
30092@opindex mno-update
ddf6fe37
AA
30093@item -mupdate
30094@itemx -mno-update
d77de738
ML
30095Generate code that uses (does not use) the load or store instructions
30096that update the base register to the address of the calculated memory
30097location. These instructions are generated by default. If you use
30098@option{-mno-update}, there is a small window between the time that the
30099stack pointer is updated and the address of the previous frame is
30100stored, which means code that walks the stack frame across interrupts or
30101signals may get corrupted data.
30102
d77de738
ML
30103@opindex mavoid-indexed-addresses
30104@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
30105@item -mavoid-indexed-addresses
30106@itemx -mno-avoid-indexed-addresses
d77de738
ML
30107Generate code that tries to avoid (not avoid) the use of indexed load
30108or store instructions. These instructions can incur a performance
30109penalty on Power6 processors in certain situations, such as when
30110stepping through large arrays that cross a 16M boundary. This option
30111is enabled by default when targeting Power6 and disabled otherwise.
30112
d77de738
ML
30113@opindex mfused-madd
30114@opindex mno-fused-madd
ddf6fe37
AA
30115@item -mfused-madd
30116@itemx -mno-fused-madd
d77de738
ML
30117Generate code that uses (does not use) the floating-point multiply and
30118accumulate instructions. These instructions are generated by default
30119if hardware floating point is used. The machine-dependent
30120@option{-mfused-madd} option is now mapped to the machine-independent
30121@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
30122mapped to @option{-ffp-contract=off}.
30123
d77de738
ML
30124@opindex mmulhw
30125@opindex mno-mulhw
ddf6fe37
AA
30126@item -mmulhw
30127@itemx -mno-mulhw
d77de738
ML
30128Generate code that uses (does not use) the half-word multiply and
30129multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
30130These instructions are generated by default when targeting those
30131processors.
30132
d77de738
ML
30133@opindex mdlmzb
30134@opindex mno-dlmzb
ddf6fe37
AA
30135@item -mdlmzb
30136@itemx -mno-dlmzb
d77de738
ML
30137Generate code that uses (does not use) the string-search @samp{dlmzb}
30138instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
30139generated by default when targeting those processors.
30140
d77de738
ML
30141@opindex mno-bit-align
30142@opindex mbit-align
ddf6fe37
AA
30143@item -mno-bit-align
30144@itemx -mbit-align
d77de738
ML
30145On System V.4 and embedded PowerPC systems do not (do) force structures
30146and unions that contain bit-fields to be aligned to the base type of the
30147bit-field.
30148
30149For example, by default a structure containing nothing but 8
30150@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
30151boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
30152the structure is aligned to a 1-byte boundary and is 1 byte in
30153size.
30154
d77de738
ML
30155@opindex mno-strict-align
30156@opindex mstrict-align
ddf6fe37
AA
30157@item -mno-strict-align
30158@itemx -mstrict-align
d77de738
ML
30159On System V.4 and embedded PowerPC systems do not (do) assume that
30160unaligned memory references are handled by the system.
30161
d77de738
ML
30162@opindex mrelocatable
30163@opindex mno-relocatable
ddf6fe37
AA
30164@item -mrelocatable
30165@itemx -mno-relocatable
d77de738
ML
30166Generate code that allows (does not allow) a static executable to be
30167relocated to a different address at run time. A simple embedded
30168PowerPC system loader should relocate the entire contents of
30169@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
30170a table of 32-bit addresses generated by this option. For this to
30171work, all objects linked together must be compiled with
30172@option{-mrelocatable} or @option{-mrelocatable-lib}.
30173@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
30174
d77de738
ML
30175@opindex mrelocatable-lib
30176@opindex mno-relocatable-lib
ddf6fe37
AA
30177@item -mrelocatable-lib
30178@itemx -mno-relocatable-lib
d77de738
ML
30179Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
30180@code{.fixup} section to allow static executables to be relocated at
30181run time, but @option{-mrelocatable-lib} does not use the smaller stack
30182alignment of @option{-mrelocatable}. Objects compiled with
30183@option{-mrelocatable-lib} may be linked with objects compiled with
30184any combination of the @option{-mrelocatable} options.
30185
d77de738
ML
30186@opindex mno-toc
30187@opindex mtoc
ddf6fe37
AA
30188@item -mno-toc
30189@itemx -mtoc
d77de738
ML
30190On System V.4 and embedded PowerPC systems do not (do) assume that
30191register 2 contains a pointer to a global area pointing to the addresses
30192used in the program.
30193
d77de738
ML
30194@opindex mlittle
30195@opindex mlittle-endian
ddf6fe37
AA
30196@item -mlittle
30197@itemx -mlittle-endian
d77de738
ML
30198On System V.4 and embedded PowerPC systems compile code for the
30199processor in little-endian mode. The @option{-mlittle-endian} option is
30200the same as @option{-mlittle}.
30201
d77de738
ML
30202@opindex mbig
30203@opindex mbig-endian
ddf6fe37
AA
30204@item -mbig
30205@itemx -mbig-endian
d77de738
ML
30206On System V.4 and embedded PowerPC systems compile code for the
30207processor in big-endian mode. The @option{-mbig-endian} option is
30208the same as @option{-mbig}.
30209
d77de738 30210@opindex mdynamic-no-pic
ddf6fe37 30211@item -mdynamic-no-pic
a335cf24 30212On Darwin / macOS systems, compile code so that it is not
d77de738
ML
30213relocatable, but that its external references are relocatable. The
30214resulting code is suitable for applications, but not shared
30215libraries.
30216
d77de738 30217@opindex msingle-pic-base
ddf6fe37 30218@item -msingle-pic-base
d77de738
ML
30219Treat the register used for PIC addressing as read-only, rather than
30220loading it in the prologue for each function. The runtime system is
30221responsible for initializing this register with an appropriate value
30222before execution begins.
30223
d77de738 30224@opindex mprioritize-restricted-insns
ddf6fe37 30225@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
30226This option controls the priority that is assigned to
30227dispatch-slot restricted instructions during the second scheduling
30228pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
30229or @samp{2} to assign no, highest, or second-highest (respectively)
30230priority to dispatch-slot restricted
30231instructions.
30232
d77de738 30233@opindex msched-costly-dep
ddf6fe37 30234@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
30235This option controls which dependences are considered costly
30236by the target during instruction scheduling. The argument
30237@var{dependence_type} takes one of the following values:
30238
30239@table @asis
30240@item @samp{no}
30241No dependence is costly.
30242
30243@item @samp{all}
30244All dependences are costly.
30245
30246@item @samp{true_store_to_load}
30247A true dependence from store to load is costly.
30248
30249@item @samp{store_to_load}
30250Any dependence from store to load is costly.
30251
30252@item @var{number}
30253Any dependence for which the latency is greater than or equal to
30254@var{number} is costly.
30255@end table
30256
d77de738 30257@opindex minsert-sched-nops
ddf6fe37 30258@item -minsert-sched-nops=@var{scheme}
d77de738
ML
30259This option controls which NOP insertion scheme is used during
30260the second scheduling pass. The argument @var{scheme} takes one of the
30261following values:
30262
30263@table @asis
30264@item @samp{no}
30265Don't insert NOPs.
30266
30267@item @samp{pad}
30268Pad with NOPs any dispatch group that has vacant issue slots,
30269according to the scheduler's grouping.
30270
30271@item @samp{regroup_exact}
30272Insert NOPs to force costly dependent insns into
30273separate groups. Insert exactly as many NOPs as needed to force an insn
30274to a new group, according to the estimated processor grouping.
30275
30276@item @var{number}
30277Insert NOPs to force costly dependent insns into
30278separate groups. Insert @var{number} NOPs to force an insn to a new group.
30279@end table
30280
d77de738 30281@opindex mcall-sysv
ddf6fe37 30282@item -mcall-sysv
d77de738
ML
30283On System V.4 and embedded PowerPC systems compile code using calling
30284conventions that adhere to the March 1995 draft of the System V
30285Application Binary Interface, PowerPC processor supplement. This is the
30286default unless you configured GCC using @samp{powerpc-*-eabiaix}.
30287
d77de738
ML
30288@opindex mcall-sysv-eabi
30289@opindex mcall-eabi
ddf6fe37
AA
30290@item -mcall-sysv-eabi
30291@itemx -mcall-eabi
d77de738
ML
30292Specify both @option{-mcall-sysv} and @option{-meabi} options.
30293
d77de738 30294@opindex mcall-sysv-noeabi
ddf6fe37 30295@item -mcall-sysv-noeabi
d77de738
ML
30296Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
30297
d7971cf7 30298@opindex mcall-aixdesc
ddf6fe37 30299@item -mcall-aixdesc
d77de738
ML
30300On System V.4 and embedded PowerPC systems compile code for the AIX
30301operating system.
30302
d77de738 30303@opindex mcall-linux
ddf6fe37 30304@item -mcall-linux
d77de738
ML
30305On System V.4 and embedded PowerPC systems compile code for the
30306Linux-based GNU system.
30307
d77de738 30308@opindex mcall-freebsd
ddf6fe37 30309@item -mcall-freebsd
d77de738
ML
30310On System V.4 and embedded PowerPC systems compile code for the
30311FreeBSD operating system.
30312
d77de738 30313@opindex mcall-netbsd
ddf6fe37 30314@item -mcall-netbsd
d77de738
ML
30315On System V.4 and embedded PowerPC systems compile code for the
30316NetBSD operating system.
30317
d7971cf7 30318@opindex mcall-openbsd
ddf6fe37 30319@item -mcall-openbsd
d77de738
ML
30320On System V.4 and embedded PowerPC systems compile code for the
30321OpenBSD operating system.
30322
d77de738 30323@opindex mtraceback
ddf6fe37 30324@item -mtraceback=@var{traceback_type}
d77de738
ML
30325Select the type of traceback table. Valid values for @var{traceback_type}
30326are @samp{full}, @samp{part}, and @samp{no}.
30327
d77de738 30328@opindex maix-struct-return
ddf6fe37 30329@item -maix-struct-return
d77de738
ML
30330Return all structures in memory (as specified by the AIX ABI)@.
30331
d77de738 30332@opindex msvr4-struct-return
ddf6fe37 30333@item -msvr4-struct-return
d77de738
ML
30334Return structures smaller than 8 bytes in registers (as specified by the
30335SVR4 ABI)@.
30336
d77de738 30337@opindex mabi
ddf6fe37 30338@item -mabi=@var{abi-type}
d77de738
ML
30339Extend the current ABI with a particular extension, or remove such extension.
30340Valid values are: @samp{altivec}, @samp{no-altivec},
30341@samp{ibmlongdouble}, @samp{ieeelongdouble},
30342@samp{elfv1}, @samp{elfv2},
30343and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
30344
d77de738 30345@opindex mabi=ibmlongdouble
ddf6fe37 30346@item -mabi=ibmlongdouble
d77de738
ML
30347Change the current ABI to use IBM extended-precision long double.
30348This is not likely to work if your system defaults to using IEEE
30349extended-precision long double. If you change the long double type
30350from IEEE extended-precision, the compiler will issue a warning unless
30351you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30352to be enabled.
30353
d77de738 30354@opindex mabi=ieeelongdouble
ddf6fe37 30355@item -mabi=ieeelongdouble
d77de738
ML
30356Change the current ABI to use IEEE extended-precision long double.
30357This is not likely to work if your system defaults to using IBM
30358extended-precision long double. If you change the long double type
30359from IBM extended-precision, the compiler will issue a warning unless
30360you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30361to be enabled.
30362
d77de738 30363@opindex mabi=elfv1
ddf6fe37 30364@item -mabi=elfv1
d77de738
ML
30365Change the current ABI to use the ELFv1 ABI.
30366This is the default ABI for big-endian PowerPC 64-bit Linux.
30367Overriding the default ABI requires special system support and is
30368likely to fail in spectacular ways.
30369
d77de738 30370@opindex mabi=elfv2
ddf6fe37 30371@item -mabi=elfv2
d77de738
ML
30372Change the current ABI to use the ELFv2 ABI.
30373This is the default ABI for little-endian PowerPC 64-bit Linux.
30374Overriding the default ABI requires special system support and is
30375likely to fail in spectacular ways.
30376
d77de738
ML
30377@opindex mgnu-attribute
30378@opindex mno-gnu-attribute
ddf6fe37
AA
30379@item -mgnu-attribute
30380@itemx -mno-gnu-attribute
d77de738
ML
30381Emit .gnu_attribute assembly directives to set tag/value pairs in a
30382.gnu.attributes section that specify ABI variations in function
30383parameters or return values.
30384
d77de738
ML
30385@opindex mprototype
30386@opindex mno-prototype
ddf6fe37
AA
30387@item -mprototype
30388@itemx -mno-prototype
d77de738
ML
30389On System V.4 and embedded PowerPC systems assume that all calls to
30390variable argument functions are properly prototyped. Otherwise, the
30391compiler must insert an instruction before every non-prototyped call to
30392set or clear bit 6 of the condition code register (@code{CR}) to
30393indicate whether floating-point values are passed in the floating-point
30394registers in case the function takes variable arguments. With
30395@option{-mprototype}, only calls to prototyped variable argument functions
30396set or clear the bit.
30397
d77de738 30398@opindex msim
ddf6fe37 30399@item -msim
d77de738
ML
30400On embedded PowerPC systems, assume that the startup module is called
30401@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
30402@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
30403configurations.
30404
d77de738 30405@opindex mmvme
ddf6fe37 30406@item -mmvme
d77de738
ML
30407On embedded PowerPC systems, assume that the startup module is called
30408@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
30409@file{libc.a}.
30410
d77de738 30411@opindex mads
ddf6fe37 30412@item -mads
d77de738
ML
30413On embedded PowerPC systems, assume that the startup module is called
30414@file{crt0.o} and the standard C libraries are @file{libads.a} and
30415@file{libc.a}.
30416
d77de738 30417@opindex myellowknife
ddf6fe37 30418@item -myellowknife
d77de738
ML
30419On embedded PowerPC systems, assume that the startup module is called
30420@file{crt0.o} and the standard C libraries are @file{libyk.a} and
30421@file{libc.a}.
30422
d77de738 30423@opindex mvxworks
ddf6fe37 30424@item -mvxworks
d77de738
ML
30425On System V.4 and embedded PowerPC systems, specify that you are
30426compiling for a VxWorks system.
30427
d77de738 30428@opindex memb
ddf6fe37 30429@item -memb
d77de738
ML
30430On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
30431header to indicate that @samp{eabi} extended relocations are used.
30432
d77de738
ML
30433@opindex meabi
30434@opindex mno-eabi
ddf6fe37
AA
30435@item -meabi
30436@itemx -mno-eabi
d77de738
ML
30437On System V.4 and embedded PowerPC systems do (do not) adhere to the
30438Embedded Applications Binary Interface (EABI), which is a set of
30439modifications to the System V.4 specifications. Selecting @option{-meabi}
30440means that the stack is aligned to an 8-byte boundary, a function
30441@code{__eabi} is called from @code{main} to set up the EABI
30442environment, and the @option{-msdata} option can use both @code{r2} and
30443@code{r13} to point to two separate small data areas. Selecting
30444@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
30445no EABI initialization function is called from @code{main}, and the
30446@option{-msdata} option only uses @code{r13} to point to a single
30447small data area. The @option{-meabi} option is on by default if you
30448configured GCC using one of the @samp{powerpc*-*-eabi*} options.
30449
d77de738 30450@opindex msdata=eabi
ddf6fe37 30451@item -msdata=eabi
d77de738
ML
30452On System V.4 and embedded PowerPC systems, put small initialized
30453@code{const} global and static data in the @code{.sdata2} section, which
30454is pointed to by register @code{r2}. Put small initialized
30455non-@code{const} global and static data in the @code{.sdata} section,
30456which is pointed to by register @code{r13}. Put small uninitialized
30457global and static data in the @code{.sbss} section, which is adjacent to
30458the @code{.sdata} section. The @option{-msdata=eabi} option is
30459incompatible with the @option{-mrelocatable} option. The
30460@option{-msdata=eabi} option also sets the @option{-memb} option.
30461
d77de738 30462@opindex msdata=sysv
ddf6fe37 30463@item -msdata=sysv
d77de738
ML
30464On System V.4 and embedded PowerPC systems, put small global and static
30465data in the @code{.sdata} section, which is pointed to by register
30466@code{r13}. Put small uninitialized global and static data in the
30467@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30468The @option{-msdata=sysv} option is incompatible with the
30469@option{-mrelocatable} option.
30470
d77de738
ML
30471@opindex msdata=default
30472@opindex msdata
ddf6fe37
AA
30473@item -msdata=default
30474@itemx -msdata
d77de738
ML
30475On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30476compile code the same as @option{-msdata=eabi}, otherwise compile code the
30477same as @option{-msdata=sysv}.
30478
d77de738 30479@opindex msdata=data
ddf6fe37 30480@item -msdata=data
d77de738
ML
30481On System V.4 and embedded PowerPC systems, put small global
30482data in the @code{.sdata} section. Put small uninitialized global
30483data in the @code{.sbss} section. Do not use register @code{r13}
30484to address small data however. This is the default behavior unless
30485other @option{-msdata} options are used.
30486
d77de738
ML
30487@opindex msdata=none
30488@opindex mno-sdata
ddf6fe37
AA
30489@item -msdata=none
30490@itemx -mno-sdata
d77de738
ML
30491On embedded PowerPC systems, put all initialized global and static data
30492in the @code{.data} section, and all uninitialized data in the
30493@code{.bss} section.
30494
d77de738
ML
30495@opindex mreadonly-in-sdata
30496@opindex mno-readonly-in-sdata
ddf6fe37 30497@item -mreadonly-in-sdata
d77de738
ML
30498Put read-only objects in the @code{.sdata} section as well. This is the
30499default.
30500
d77de738 30501@opindex mblock-move-inline-limit
ddf6fe37 30502@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30503Inline all block moves (such as calls to @code{memcpy} or structure
30504copies) less than or equal to @var{num} bytes. The minimum value for
30505@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30506targets. The default value is target-specific.
30507
d77de738 30508@opindex mblock-compare-inline-limit
ddf6fe37 30509@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30510Generate non-looping inline code for all block compares (such as calls
30511to @code{memcmp} or structure compares) less than or equal to @var{num}
30512bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30513block compare is disabled. The default value is target-specific.
30514
d77de738 30515@opindex mblock-compare-inline-loop-limit
ddf6fe37 30516@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30517Generate an inline expansion using loop code for all block compares that
30518are less than or equal to @var{num} bytes, but greater than the limit
30519for non-loop inline block compare expansion. If the block length is not
30520constant, at most @var{num} bytes will be compared before @code{memcmp}
30521is called to compare the remainder of the block. The default value is
30522target-specific.
30523
d77de738 30524@opindex mstring-compare-inline-limit
ddf6fe37 30525@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30526Compare at most @var{num} string bytes with inline code.
30527If the difference or end of string is not found at the
30528end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30529take care of the rest of the comparison. The default is 64 bytes.
30530
d77de738
ML
30531@opindex G
30532@cindex smaller data references (PowerPC)
30533@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30534@item -G @var{num}
d77de738
ML
30535On embedded PowerPC systems, put global and static items less than or
30536equal to @var{num} bytes into the small data or BSS sections instead of
30537the normal data or BSS section. By default, @var{num} is 8. The
30538@option{-G @var{num}} switch is also passed to the linker.
30539All modules should be compiled with the same @option{-G @var{num}} value.
30540
d77de738
ML
30541@opindex mregnames
30542@opindex mno-regnames
ddf6fe37
AA
30543@item -mregnames
30544@itemx -mno-regnames
d77de738
ML
30545On System V.4 and embedded PowerPC systems do (do not) emit register
30546names in the assembly language output using symbolic forms.
30547
d77de738
ML
30548@opindex mlongcall
30549@opindex mno-longcall
ddf6fe37
AA
30550@item -mlongcall
30551@itemx -mno-longcall
d77de738
ML
30552By default assume that all calls are far away so that a longer and more
30553expensive calling sequence is required. This is required for calls
30554farther than 32 megabytes (33,554,432 bytes) from the current location.
30555A short call is generated if the compiler knows
30556the call cannot be that far away. This setting can be overridden by
30557the @code{shortcall} function attribute, or by @code{#pragma
30558longcall(0)}.
30559
30560Some linkers are capable of detecting out-of-range calls and generating
30561glue code on the fly. On these systems, long calls are unnecessary and
30562generate slower code. As of this writing, the AIX linker can do this,
30563as can the GNU linker for PowerPC/64. It is planned to add this feature
30564to the GNU linker for 32-bit PowerPC systems as well.
30565
30566On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30567GCC can generate long calls using an inline PLT call sequence (see
30568@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30569ELFv1 (big-endian) do not support inline PLT calls.
30570
30571On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30572callee, L42}, plus a @dfn{branch island} (glue code). The two target
30573addresses represent the callee and the branch island. The
30574Darwin/PPC linker prefers the first address and generates a @code{bl
30575callee} if the PPC @code{bl} instruction reaches the callee directly;
30576otherwise, the linker generates @code{bl L42} to call the branch
30577island. The branch island is appended to the body of the
30578calling function; it computes the full 32-bit address of the callee
30579and jumps to it.
30580
30581On Mach-O (Darwin) systems, this option directs the compiler emit to
30582the glue for every direct call, and the Darwin linker decides whether
30583to use or discard it.
30584
30585In the future, GCC may ignore all longcall specifications
30586when the linker is known to generate glue.
30587
d77de738
ML
30588@opindex mpltseq
30589@opindex mno-pltseq
ddf6fe37
AA
30590@item -mpltseq
30591@itemx -mno-pltseq
d77de738
ML
30592Implement (do not implement) -fno-plt and long calls using an inline
30593PLT call sequence that supports lazy linking and long calls to
30594functions in dlopen'd shared libraries. Inline PLT calls are only
30595supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30596linkers, and are enabled by default if the support is detected when
30597configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30598configured with @option{--enable-secureplt}. @option{-mpltseq} code
30599and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30600linked together.
30601
d77de738
ML
30602@opindex mtls-markers
30603@opindex mno-tls-markers
ddf6fe37
AA
30604@item -mtls-markers
30605@itemx -mno-tls-markers
d77de738
ML
30606Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30607specifying the function argument. The relocation allows the linker to
30608reliably associate function call with argument setup instructions for
30609TLS optimization, which in turn allows GCC to better schedule the
30610sequence.
30611
ddf6fe37 30612@opindex mrecip
d77de738
ML
30613@item -mrecip
30614@itemx -mno-recip
d77de738
ML
30615This option enables use of the reciprocal estimate and
30616reciprocal square root estimate instructions with additional
30617Newton-Raphson steps to increase precision instead of doing a divide or
30618square root and divide for floating-point arguments. You should use
30619the @option{-ffast-math} option when using @option{-mrecip} (or at
30620least @option{-funsafe-math-optimizations},
30621@option{-ffinite-math-only}, @option{-freciprocal-math} and
30622@option{-fno-trapping-math}). Note that while the throughput of the
30623sequence is generally higher than the throughput of the non-reciprocal
30624instruction, the precision of the sequence can be decreased by up to 2
30625ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30626roots.
30627
d77de738 30628@opindex mrecip=opt
ddf6fe37 30629@item -mrecip=@var{opt}
d77de738
ML
30630This option controls which reciprocal estimate instructions
30631may be used. @var{opt} is a comma-separated list of options, which may
30632be preceded by a @code{!} to invert the option:
30633
30634@table @samp
30635
30636@item all
30637Enable all estimate instructions.
30638
30639@item default
30640Enable the default instructions, equivalent to @option{-mrecip}.
30641
30642@item none
30643Disable all estimate instructions, equivalent to @option{-mno-recip}.
30644
30645@item div
30646Enable the reciprocal approximation instructions for both
30647single and double precision.
30648
30649@item divf
30650Enable the single-precision reciprocal approximation instructions.
30651
30652@item divd
30653Enable the double-precision reciprocal approximation instructions.
30654
30655@item rsqrt
30656Enable the reciprocal square root approximation instructions for both
30657single and double precision.
30658
30659@item rsqrtf
30660Enable the single-precision reciprocal square root approximation instructions.
30661
30662@item rsqrtd
30663Enable the double-precision reciprocal square root approximation instructions.
30664
30665@end table
30666
30667So, for example, @option{-mrecip=all,!rsqrtd} enables
30668all of the reciprocal estimate instructions, except for the
30669@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30670which handle the double-precision reciprocal square root calculations.
30671
ddf6fe37 30672@opindex mrecip-precision
d77de738
ML
30673@item -mrecip-precision
30674@itemx -mno-recip-precision
d77de738
ML
30675Assume (do not assume) that the reciprocal estimate instructions
30676provide higher-precision estimates than is mandated by the PowerPC
30677ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30678@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30679The double-precision square root estimate instructions are not generated by
30680default on low-precision machines, since they do not provide an
30681estimate that converges after three steps.
30682
d77de738 30683@opindex mveclibabi
ddf6fe37 30684@item -mveclibabi=@var{type}
d77de738
ML
30685Specifies the ABI type to use for vectorizing intrinsics using an
30686external library. The only type supported at present is @samp{mass},
30687which specifies to use IBM's Mathematical Acceleration Subsystem
30688(MASS) libraries for vectorizing intrinsics using external libraries.
30689GCC currently emits calls to @code{acosd2}, @code{acosf4},
30690@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30691@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30692@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30693@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30694@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30695@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30696@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30697@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30698@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30699@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30700@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30701@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30702@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30703for power7. Both @option{-ftree-vectorize} and
30704@option{-funsafe-math-optimizations} must also be enabled. The MASS
30705libraries must be specified at link time.
30706
ddf6fe37 30707@opindex mfriz
d77de738
ML
30708@item -mfriz
30709@itemx -mno-friz
d77de738
ML
30710Generate (do not generate) the @code{friz} instruction when the
30711@option{-funsafe-math-optimizations} option is used to optimize
30712rounding of floating-point values to 64-bit integer and back to floating
30713point. The @code{friz} instruction does not return the same value if
30714the floating-point number is too large to fit in an integer.
30715
ddf6fe37 30716@opindex mpointers-to-nested-functions
d77de738
ML
30717@item -mpointers-to-nested-functions
30718@itemx -mno-pointers-to-nested-functions
d77de738
ML
30719Generate (do not generate) code to load up the static chain register
30720(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30721systems where a function pointer points to a 3-word descriptor giving
30722the function address, TOC value to be loaded in register @code{r2}, and
30723static chain value to be loaded in register @code{r11}. The
30724@option{-mpointers-to-nested-functions} is on by default. You cannot
30725call through pointers to nested functions or pointers
30726to functions compiled in other languages that use the static chain if
30727you use @option{-mno-pointers-to-nested-functions}.
30728
ddf6fe37 30729@opindex msave-toc-indirect
d77de738
ML
30730@item -msave-toc-indirect
30731@itemx -mno-save-toc-indirect
d77de738
ML
30732Generate (do not generate) code to save the TOC value in the reserved
30733stack location in the function prologue if the function calls through
30734a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30735saved in the prologue, it is saved just before the call through the
30736pointer. The @option{-mno-save-toc-indirect} option is the default.
30737
ddf6fe37 30738@opindex mcompat-align-parm
d77de738
ML
30739@item -mcompat-align-parm
30740@itemx -mno-compat-align-parm
d77de738
ML
30741Generate (do not generate) code to pass structure parameters with a
30742maximum alignment of 64 bits, for compatibility with older versions
30743of GCC.
30744
30745Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30746structure parameter on a 128-bit boundary when that structure contained
30747a member requiring 128-bit alignment. This is corrected in more
30748recent versions of GCC. This option may be used to generate code
30749that is compatible with functions compiled with older versions of
30750GCC.
30751
30752The @option{-mno-compat-align-parm} option is the default.
30753
d77de738
ML
30754@opindex mstack-protector-guard
30755@opindex mstack-protector-guard-reg
30756@opindex mstack-protector-guard-offset
30757@opindex mstack-protector-guard-symbol
ddf6fe37
AA
30758@item -mstack-protector-guard=@var{guard}
30759@itemx -mstack-protector-guard-reg=@var{reg}
30760@itemx -mstack-protector-guard-offset=@var{offset}
30761@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
30762Generate stack protection code using canary at @var{guard}. Supported
30763locations are @samp{global} for global canary or @samp{tls} for per-thread
30764canary in the TLS block (the default with GNU libc version 2.4 or later).
30765
30766With the latter choice the options
30767@option{-mstack-protector-guard-reg=@var{reg}} and
30768@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30769which register to use as base register for reading the canary, and from what
30770offset from that base register. The default for those is as specified in the
30771relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30772the offset with a symbol reference to a canary in the TLS block.
30773
d77de738
ML
30774@opindex mpcrel
30775@opindex mno-pcrel
ddf6fe37
AA
30776@item -mpcrel
30777@itemx -mno-pcrel
d77de738
ML
30778Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30779option requires that the medium code model (@option{-mcmodel=medium})
30780and prefixed addressing (@option{-mprefixed}) options are enabled.
30781
d77de738
ML
30782@opindex mprefixed
30783@opindex mno-prefixed
ddf6fe37
AA
30784@item -mprefixed
30785@itemx -mno-prefixed
d77de738
ML
30786Generate (do not generate) addressing modes using prefixed load and
30787store instructions. The @option{-mprefixed} option requires that
30788the option @option{-mcpu=power10} (or later) is enabled.
30789
d77de738
ML
30790@opindex mmma
30791@opindex mno-mma
ddf6fe37
AA
30792@item -mmma
30793@itemx -mno-mma
d77de738
ML
30794Generate (do not generate) the MMA instructions. The @option{-mma}
30795option requires that the option @option{-mcpu=power10} (or later)
30796is enabled.
30797
d77de738
ML
30798@opindex mrop-protect
30799@opindex mno-rop-protect
ddf6fe37
AA
30800@item -mrop-protect
30801@itemx -mno-rop-protect
d77de738
ML
30802Generate (do not generate) ROP protection instructions when the target
30803processor supports them. Currently this option disables the shrink-wrap
30804optimization (@option{-fshrink-wrap}).
30805
d77de738
ML
30806@opindex mprivileged
30807@opindex mno-privileged
ddf6fe37
AA
30808@item -mprivileged
30809@itemx -mno-privileged
d77de738
ML
30810Generate (do not generate) code that will run in privileged state.
30811
d77de738
ML
30812@opindex block-ops-unaligned-vsx
30813@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
30814@item -mblock-ops-unaligned-vsx
30815@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
30816Generate (do not generate) unaligned vsx loads and stores for
30817inline expansion of @code{memcpy} and @code{memmove}.
30818
30819@item --param rs6000-vect-unroll-limit=
30820The vectorizer will check with target information to determine whether it
30821would be beneficial to unroll the main vectorized loop and by how much. This
30822parameter sets the upper bound of how much the vectorizer will unroll the main
30823loop. The default value is four.
30824
30825@end table
30826
30827@node RX Options
30828@subsection RX Options
30829@cindex RX Options
30830
30831These command-line options are defined for RX targets:
30832
30833@table @gcctabopt
d77de738
ML
30834@opindex m64bit-doubles
30835@opindex m32bit-doubles
ddf6fe37
AA
30836@item -m64bit-doubles
30837@itemx -m32bit-doubles
d77de738
ML
30838Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30839or 32 bits (@option{-m32bit-doubles}) in size. The default is
30840@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30841works on 32-bit values, which is why the default is
30842@option{-m32bit-doubles}.
30843
d77de738
ML
30844@opindex fpu
30845@opindex nofpu
ddf6fe37
AA
30846@item -fpu
30847@itemx -nofpu
d77de738
ML
30848Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30849floating-point hardware. The default is enabled for the RX600
30850series and disabled for the RX200 series.
30851
30852Floating-point instructions are only generated for 32-bit floating-point
30853values, however, so the FPU hardware is not used for doubles if the
30854@option{-m64bit-doubles} option is used.
30855
30856@emph{Note} If the @option{-fpu} option is enabled then
30857@option{-funsafe-math-optimizations} is also enabled automatically.
30858This is because the RX FPU instructions are themselves unsafe.
30859
d77de738 30860@opindex mcpu
ddf6fe37 30861@item -mcpu=@var{name}
d77de738
ML
30862Selects the type of RX CPU to be targeted. Currently three types are
30863supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30864the specific @samp{RX610} CPU. The default is @samp{RX600}.
30865
30866The only difference between @samp{RX600} and @samp{RX610} is that the
30867@samp{RX610} does not support the @code{MVTIPL} instruction.
30868
30869The @samp{RX200} series does not have a hardware floating-point unit
30870and so @option{-nofpu} is enabled by default when this type is
30871selected.
30872
d77de738
ML
30873@opindex mbig-endian-data
30874@opindex mlittle-endian-data
ddf6fe37
AA
30875@item -mbig-endian-data
30876@itemx -mlittle-endian-data
d77de738
ML
30877Store data (but not code) in the big-endian format. The default is
30878@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30879format.
30880
d77de738 30881@opindex msmall-data-limit
ddf6fe37 30882@item -msmall-data-limit=@var{N}
d77de738
ML
30883Specifies the maximum size in bytes of global and static variables
30884which can be placed into the small data area. Using the small data
30885area can lead to smaller and faster code, but the size of area is
30886limited and it is up to the programmer to ensure that the area does
30887not overflow. Also when the small data area is used one of the RX's
30888registers (usually @code{r13}) is reserved for use pointing to this
30889area, so it is no longer available for use by the compiler. This
30890could result in slower and/or larger code if variables are pushed onto
30891the stack instead of being held in this register.
30892
30893Note, common variables (variables that have not been initialized) and
30894constants are not placed into the small data area as they are assigned
30895to other sections in the output executable.
30896
30897The default value is zero, which disables this feature. Note, this
30898feature is not enabled by default with higher optimization levels
30899(@option{-O2} etc) because of the potentially detrimental effects of
30900reserving a register. It is up to the programmer to experiment and
30901discover whether this feature is of benefit to their program. See the
30902description of the @option{-mpid} option for a description of how the
30903actual register to hold the small data area pointer is chosen.
30904
d77de738
ML
30905@opindex msim
30906@opindex mno-sim
ddf6fe37
AA
30907@item -msim
30908@itemx -mno-sim
d77de738
ML
30909Use the simulator runtime. The default is to use the libgloss
30910board-specific runtime.
30911
d77de738
ML
30912@opindex mas100-syntax
30913@opindex mno-as100-syntax
ddf6fe37
AA
30914@item -mas100-syntax
30915@itemx -mno-as100-syntax
d77de738
ML
30916When generating assembler output use a syntax that is compatible with
30917Renesas's AS100 assembler. This syntax can also be handled by the GAS
30918assembler, but it has some restrictions so it is not generated by default.
30919
d77de738 30920@opindex mmax-constant-size
ddf6fe37 30921@item -mmax-constant-size=@var{N}
d77de738
ML
30922Specifies the maximum size, in bytes, of a constant that can be used as
30923an operand in a RX instruction. Although the RX instruction set does
30924allow constants of up to 4 bytes in length to be used in instructions,
30925a longer value equates to a longer instruction. Thus in some
30926circumstances it can be beneficial to restrict the size of constants
30927that are used in instructions. Constants that are too big are instead
30928placed into a constant pool and referenced via register indirection.
30929
30930The value @var{N} can be between 0 and 4. A value of 0 (the default)
30931or 4 means that constants of any size are allowed.
30932
d77de738 30933@opindex mrelax
ddf6fe37 30934@item -mrelax
d77de738
ML
30935Enable linker relaxation. Linker relaxation is a process whereby the
30936linker attempts to reduce the size of a program by finding shorter
30937versions of various instructions. Disabled by default.
30938
d77de738 30939@opindex mint-register
ddf6fe37 30940@item -mint-register=@var{N}
d77de738
ML
30941Specify the number of registers to reserve for fast interrupt handler
30942functions. The value @var{N} can be between 0 and 4. A value of 1
30943means that register @code{r13} is reserved for the exclusive use
30944of fast interrupt handlers. A value of 2 reserves @code{r13} and
30945@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30946@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30947A value of 0, the default, does not reserve any registers.
30948
d77de738 30949@opindex msave-acc-in-interrupts
ddf6fe37 30950@item -msave-acc-in-interrupts
d77de738
ML
30951Specifies that interrupt handler functions should preserve the
30952accumulator register. This is only necessary if normal code might use
30953the accumulator register, for example because it performs 64-bit
30954multiplications. The default is to ignore the accumulator as this
30955makes the interrupt handlers faster.
30956
d77de738
ML
30957@opindex mpid
30958@opindex mno-pid
ddf6fe37
AA
30959@item -mpid
30960@itemx -mno-pid
d77de738
ML
30961Enables the generation of position independent data. When enabled any
30962access to constant data is done via an offset from a base address
30963held in a register. This allows the location of constant data to be
30964determined at run time without requiring the executable to be
30965relocated, which is a benefit to embedded applications with tight
30966memory constraints. Data that can be modified is not affected by this
30967option.
30968
30969Note, using this feature reserves a register, usually @code{r13}, for
30970the constant data base address. This can result in slower and/or
30971larger code, especially in complicated functions.
30972
30973The actual register chosen to hold the constant data base address
30974depends upon whether the @option{-msmall-data-limit} and/or the
30975@option{-mint-register} command-line options are enabled. Starting
30976with register @code{r13} and proceeding downwards, registers are
30977allocated first to satisfy the requirements of @option{-mint-register},
30978then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30979is possible for the small data area register to be @code{r8} if both
30980@option{-mint-register=4} and @option{-mpid} are specified on the
30981command line.
30982
30983By default this feature is not enabled. The default can be restored
30984via the @option{-mno-pid} command-line option.
30985
d77de738
ML
30986@opindex mno-warn-multiple-fast-interrupts
30987@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
30988@item -mno-warn-multiple-fast-interrupts
30989@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
30990Prevents GCC from issuing a warning message if it finds more than one
30991fast interrupt handler when it is compiling a file. The default is to
30992issue a warning for each extra fast interrupt handler found, as the RX
30993only supports one such interrupt.
30994
d77de738
ML
30995@opindex mallow-string-insns
30996@opindex mno-allow-string-insns
ddf6fe37
AA
30997@item -mallow-string-insns
30998@itemx -mno-allow-string-insns
d77de738
ML
30999Enables or disables the use of the string manipulation instructions
31000@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
31001@code{SWHILE} and also the @code{RMPA} instruction. These
31002instructions may prefetch data, which is not safe to do if accessing
31003an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
31004for more information).
31005
31006The default is to allow these instructions, but it is not possible for
31007GCC to reliably detect all circumstances where a string instruction
31008might be used to access an I/O register, so their use cannot be
31009disabled automatically. Instead it is reliant upon the programmer to
31010use the @option{-mno-allow-string-insns} option if their program
31011accesses I/O space.
31012
31013When the instructions are enabled GCC defines the C preprocessor
31014symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
31015symbol @code{__RX_DISALLOW_STRING_INSNS__}.
31016
d77de738
ML
31017@opindex mjsr
31018@opindex mno-jsr
ddf6fe37
AA
31019@item -mjsr
31020@itemx -mno-jsr
d77de738
ML
31021Use only (or not only) @code{JSR} instructions to access functions.
31022This option can be used when code size exceeds the range of @code{BSR}
31023instructions. Note that @option{-mno-jsr} does not mean to not use
31024@code{JSR} but instead means that any type of branch may be used.
31025@end table
31026
31027@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
31028has special significance to the RX port when used with the
31029@code{interrupt} function attribute. This attribute indicates a
31030function intended to process fast interrupts. GCC ensures
31031that it only uses the registers @code{r10}, @code{r11}, @code{r12}
31032and/or @code{r13} and only provided that the normal use of the
31033corresponding registers have been restricted via the
31034@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
31035options.
31036
31037@node S/390 and zSeries Options
31038@subsection S/390 and zSeries Options
31039@cindex S/390 and zSeries Options
31040
31041These are the @samp{-m} options defined for the S/390 and zSeries architecture.
31042
31043@table @gcctabopt
d77de738
ML
31044@opindex mhard-float
31045@opindex msoft-float
ddf6fe37
AA
31046@item -mhard-float
31047@itemx -msoft-float
d77de738
ML
31048Use (do not use) the hardware floating-point instructions and registers
31049for floating-point operations. When @option{-msoft-float} is specified,
31050functions in @file{libgcc.a} are used to perform floating-point
31051operations. When @option{-mhard-float} is specified, the compiler
31052generates IEEE floating-point instructions. This is the default.
31053
d77de738
ML
31054@opindex mhard-dfp
31055@opindex mno-hard-dfp
ddf6fe37
AA
31056@item -mhard-dfp
31057@itemx -mno-hard-dfp
d77de738
ML
31058Use (do not use) the hardware decimal-floating-point instructions for
31059decimal-floating-point operations. When @option{-mno-hard-dfp} is
31060specified, functions in @file{libgcc.a} are used to perform
31061decimal-floating-point operations. When @option{-mhard-dfp} is
31062specified, the compiler generates decimal-floating-point hardware
31063instructions. This is the default for @option{-march=z9-ec} or higher.
31064
d77de738
ML
31065@opindex mlong-double-64
31066@opindex mlong-double-128
ddf6fe37
AA
31067@item -mlong-double-64
31068@itemx -mlong-double-128
d77de738
ML
31069These switches control the size of @code{long double} type. A size
31070of 64 bits makes the @code{long double} type equivalent to the @code{double}
31071type. This is the default.
31072
d77de738
ML
31073@opindex mbackchain
31074@opindex mno-backchain
ddf6fe37
AA
31075@item -mbackchain
31076@itemx -mno-backchain
d77de738
ML
31077Store (do not store) the address of the caller's frame as backchain pointer
31078into the callee's stack frame.
31079A backchain may be needed to allow debugging using tools that do not understand
31080DWARF call frame information.
31081When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
31082at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
31083the backchain is placed into the topmost word of the 96/160 byte register
31084save area.
31085
31086In general, code compiled with @option{-mbackchain} is call-compatible with
31087code compiled with @option{-mno-backchain}; however, use of the backchain
31088for debugging purposes usually requires that the whole binary is built with
31089@option{-mbackchain}. Note that the combination of @option{-mbackchain},
31090@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31091to build a linux kernel use @option{-msoft-float}.
31092
31093The default is to not maintain the backchain.
31094
d77de738
ML
31095@opindex mpacked-stack
31096@opindex mno-packed-stack
ddf6fe37
AA
31097@item -mpacked-stack
31098@itemx -mno-packed-stack
d77de738
ML
31099Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
31100specified, the compiler uses the all fields of the 96/160 byte register save
31101area only for their default purpose; unused fields still take up stack space.
31102When @option{-mpacked-stack} is specified, register save slots are densely
31103packed at the top of the register save area; unused space is reused for other
31104purposes, allowing for more efficient use of the available stack space.
31105However, when @option{-mbackchain} is also in effect, the topmost word of
31106the save area is always used to store the backchain, and the return address
31107register is always saved two words below the backchain.
31108
31109As long as the stack frame backchain is not used, code generated with
31110@option{-mpacked-stack} is call-compatible with code generated with
31111@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
31112S/390 or zSeries generated code that uses the stack frame backchain at run
31113time, not just for debugging purposes. Such code is not call-compatible
31114with code compiled with @option{-mpacked-stack}. Also, note that the
31115combination of @option{-mbackchain},
31116@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31117to build a linux kernel use @option{-msoft-float}.
31118
31119The default is to not use the packed stack layout.
31120
d77de738
ML
31121@opindex msmall-exec
31122@opindex mno-small-exec
ddf6fe37
AA
31123@item -msmall-exec
31124@itemx -mno-small-exec
d77de738
ML
31125Generate (or do not generate) code using the @code{bras} instruction
31126to do subroutine calls.
31127This only works reliably if the total executable size does not
31128exceed 64k. The default is to use the @code{basr} instruction instead,
31129which does not have this limitation.
31130
d77de738
ML
31131@opindex m64
31132@opindex m31
ddf6fe37
AA
31133@item -m64
31134@itemx -m31
d77de738
ML
31135When @option{-m31} is specified, generate code compliant to the
31136GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
31137code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
31138particular to generate 64-bit instructions. For the @samp{s390}
31139targets, the default is @option{-m31}, while the @samp{s390x}
31140targets default to @option{-m64}.
31141
d77de738
ML
31142@opindex mzarch
31143@opindex mesa
ddf6fe37
AA
31144@item -mzarch
31145@itemx -mesa
d77de738
ML
31146When @option{-mzarch} is specified, generate code using the
31147instructions available on z/Architecture.
31148When @option{-mesa} is specified, generate code using the
31149instructions available on ESA/390. Note that @option{-mesa} is
31150not possible with @option{-m64}.
31151When generating code compliant to the GNU/Linux for S/390 ABI,
31152the default is @option{-mesa}. When generating code compliant
31153to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
31154
d77de738
ML
31155@opindex mhtm
31156@opindex mno-htm
ddf6fe37
AA
31157@item -mhtm
31158@itemx -mno-htm
d77de738
ML
31159The @option{-mhtm} option enables a set of builtins making use of
31160instructions available with the transactional execution facility
31161introduced with the IBM zEnterprise EC12 machine generation
31162@ref{S/390 System z Built-in Functions}.
31163@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
31164
d77de738
ML
31165@opindex mvx
31166@opindex mno-vx
ddf6fe37
AA
31167@item -mvx
31168@itemx -mno-vx
d77de738
ML
31169When @option{-mvx} is specified, generate code using the instructions
31170available with the vector extension facility introduced with the IBM
31171z13 machine generation.
31172This option changes the ABI for some vector type values with regard to
31173alignment and calling conventions. In case vector type values are
31174being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
31175command will be added to mark the resulting binary with the ABI used.
31176@option{-mvx} is enabled by default when using @option{-march=z13}.
31177
d77de738
ML
31178@opindex mzvector
31179@opindex mno-zvector
ddf6fe37
AA
31180@item -mzvector
31181@itemx -mno-zvector
d77de738
ML
31182The @option{-mzvector} option enables vector language extensions and
31183builtins using instructions available with the vector extension
31184facility introduced with the IBM z13 machine generation.
31185This option adds support for @samp{vector} to be used as a keyword to
31186define vector type variables and arguments. @samp{vector} is only
31187available when GNU extensions are enabled. It will not be expanded
31188when requesting strict standard compliance e.g.@: with @option{-std=c99}.
31189In addition to the GCC low-level builtins @option{-mzvector} enables
31190a set of builtins added for compatibility with AltiVec-style
31191implementations like Power and Cell. In order to make use of these
31192builtins the header file @file{vecintrin.h} needs to be included.
31193@option{-mzvector} is disabled by default.
31194
d77de738
ML
31195@opindex mmvcle
31196@opindex mno-mvcle
ddf6fe37
AA
31197@item -mmvcle
31198@itemx -mno-mvcle
d77de738
ML
31199Generate (or do not generate) code using the @code{mvcle} instruction
31200to perform block moves. When @option{-mno-mvcle} is specified,
31201use a @code{mvc} loop instead. This is the default unless optimizing for
31202size.
31203
d77de738
ML
31204@opindex mdebug
31205@opindex mno-debug
ddf6fe37
AA
31206@item -mdebug
31207@itemx -mno-debug
d77de738
ML
31208Print (or do not print) additional debug information when compiling.
31209The default is to not print debug information.
31210
d77de738 31211@opindex march
ddf6fe37 31212@item -march=@var{cpu-type}
d77de738
ML
31213Generate code that runs on @var{cpu-type}, which is the name of a
31214system representing a certain processor type. Possible values for
31215@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
31216@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
31217@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
31218@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
31219@samp{z16}/@samp{arch14}, and @samp{native}.
31220
31221The default is @option{-march=z900}.
31222
31223Specifying @samp{native} as cpu type can be used to select the best
31224architecture option for the host processor.
31225@option{-march=native} has no effect if GCC does not recognize the
31226processor.
31227
d77de738 31228@opindex mtune
ddf6fe37 31229@item -mtune=@var{cpu-type}
d77de738
ML
31230Tune to @var{cpu-type} everything applicable about the generated code,
31231except for the ABI and the set of available instructions.
31232The list of @var{cpu-type} values is the same as for @option{-march}.
31233The default is the value used for @option{-march}.
31234
d77de738
ML
31235@opindex mtpf-trace
31236@opindex mno-tpf-trace
ddf6fe37
AA
31237@item -mtpf-trace
31238@itemx -mno-tpf-trace
d77de738
ML
31239Generate code that adds (does not add) in TPF OS specific branches to trace
31240routines in the operating system. This option is off by default, even
31241when compiling for the TPF OS@.
31242
d77de738
ML
31243@opindex mtpf-trace-skip
31244@opindex mno-tpf-trace-skip
ddf6fe37
AA
31245@item -mtpf-trace-skip
31246@itemx -mno-tpf-trace-skip
d77de738
ML
31247Generate code that changes (does not change) the default branch
31248targets enabled by @option{-mtpf-trace} to point to specialized trace
31249routines providing the ability of selectively skipping function trace
31250entries for the TPF OS. This option is off by default, even when
31251compiling for the TPF OS and specifying @option{-mtpf-trace}.
31252
d77de738
ML
31253@opindex mfused-madd
31254@opindex mno-fused-madd
ddf6fe37
AA
31255@item -mfused-madd
31256@itemx -mno-fused-madd
d77de738
ML
31257Generate code that uses (does not use) the floating-point multiply and
31258accumulate instructions. These instructions are generated by default if
31259hardware floating point is used.
31260
d77de738 31261@opindex mwarn-framesize
ddf6fe37 31262@item -mwarn-framesize=@var{framesize}
d77de738
ML
31263Emit a warning if the current function exceeds the given frame size. Because
31264this is a compile-time check it doesn't need to be a real problem when the program
31265runs. It is intended to identify functions that most probably cause
31266a stack overflow. It is useful to be used in an environment with limited stack
31267size e.g.@: the linux kernel.
31268
d77de738 31269@opindex mwarn-dynamicstack
ddf6fe37 31270@item -mwarn-dynamicstack
d77de738
ML
31271Emit a warning if the function calls @code{alloca} or uses dynamically-sized
31272arrays. This is generally a bad idea with a limited stack size.
31273
d77de738
ML
31274@opindex mstack-guard
31275@opindex mstack-size
ddf6fe37
AA
31276@item -mstack-guard=@var{stack-guard}
31277@itemx -mstack-size=@var{stack-size}
d77de738
ML
31278If these options are provided the S/390 back end emits additional instructions in
31279the function prologue that trigger a trap if the stack size is @var{stack-guard}
31280bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
31281If the @var{stack-guard} option is omitted the smallest power of 2 larger than
31282the frame size of the compiled function is chosen.
31283These options are intended to be used to help debugging stack overflow problems.
31284The additionally emitted code causes only little overhead and hence can also be
31285used in production-like systems without greater performance degradation. The given
31286values have to be exact powers of 2 and @var{stack-size} has to be greater than
31287@var{stack-guard} without exceeding 64k.
31288In order to be efficient the extra code makes the assumption that the stack starts
31289at an address aligned to the value given by @var{stack-size}.
31290The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
31291
d77de738 31292@opindex mhotpatch
ddf6fe37 31293@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
31294If the hotpatch option is enabled, a ``hot-patching'' function
31295prologue is generated for all functions in the compilation unit.
31296The funtion label is prepended with the given number of two-byte
31297NOP instructions (@var{pre-halfwords}, maximum 1000000). After
31298the label, 2 * @var{post-halfwords} bytes are appended, using the
31299largest NOP like instructions the architecture allows (maximum
313001000000).
31301
31302If both arguments are zero, hotpatching is disabled.
31303
31304This option can be overridden for individual functions with the
31305@code{hotpatch} attribute.
31306@end table
31307
d77de738
ML
31308@node SH Options
31309@subsection SH Options
31310
31311These @samp{-m} options are defined for the SH implementations:
31312
31313@table @gcctabopt
d77de738 31314@opindex m1
ddf6fe37 31315@item -m1
d77de738
ML
31316Generate code for the SH1.
31317
d77de738 31318@opindex m2
ddf6fe37 31319@item -m2
d77de738
ML
31320Generate code for the SH2.
31321
31322@item -m2e
31323Generate code for the SH2e.
31324
d77de738 31325@opindex m2a-nofpu
ddf6fe37 31326@item -m2a-nofpu
d77de738
ML
31327Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
31328that the floating-point unit is not used.
31329
d77de738 31330@opindex m2a-single-only
ddf6fe37 31331@item -m2a-single-only
d77de738
ML
31332Generate code for the SH2a-FPU, in such a way that no double-precision
31333floating-point operations are used.
31334
d77de738 31335@opindex m2a-single
ddf6fe37 31336@item -m2a-single
d77de738
ML
31337Generate code for the SH2a-FPU assuming the floating-point unit is in
31338single-precision mode by default.
31339
d77de738 31340@opindex m2a
ddf6fe37 31341@item -m2a
d77de738
ML
31342Generate code for the SH2a-FPU assuming the floating-point unit is in
31343double-precision mode by default.
31344
d77de738 31345@opindex m3
ddf6fe37 31346@item -m3
d77de738
ML
31347Generate code for the SH3.
31348
d77de738 31349@opindex m3e
ddf6fe37 31350@item -m3e
d77de738
ML
31351Generate code for the SH3e.
31352
d77de738 31353@opindex m4-nofpu
ddf6fe37 31354@item -m4-nofpu
d77de738
ML
31355Generate code for the SH4 without a floating-point unit.
31356
d77de738 31357@opindex m4-single-only
ddf6fe37 31358@item -m4-single-only
d77de738
ML
31359Generate code for the SH4 with a floating-point unit that only
31360supports single-precision arithmetic.
31361
d77de738 31362@opindex m4-single
ddf6fe37 31363@item -m4-single
d77de738
ML
31364Generate code for the SH4 assuming the floating-point unit is in
31365single-precision mode by default.
31366
d77de738 31367@opindex m4
ddf6fe37 31368@item -m4
d77de738
ML
31369Generate code for the SH4.
31370
d77de738 31371@opindex m4-100
ddf6fe37 31372@item -m4-100
d77de738
ML
31373Generate code for SH4-100.
31374
d77de738 31375@opindex m4-100-nofpu
ddf6fe37 31376@item -m4-100-nofpu
d77de738
ML
31377Generate code for SH4-100 in such a way that the
31378floating-point unit is not used.
31379
d77de738 31380@opindex m4-100-single
ddf6fe37 31381@item -m4-100-single
d77de738
ML
31382Generate code for SH4-100 assuming the floating-point unit is in
31383single-precision mode by default.
31384
d77de738 31385@opindex m4-100-single-only
ddf6fe37 31386@item -m4-100-single-only
d77de738
ML
31387Generate code for SH4-100 in such a way that no double-precision
31388floating-point operations are used.
31389
d77de738 31390@opindex m4-200
ddf6fe37 31391@item -m4-200
d77de738
ML
31392Generate code for SH4-200.
31393
d77de738 31394@opindex m4-200-nofpu
ddf6fe37 31395@item -m4-200-nofpu
d77de738
ML
31396Generate code for SH4-200 without in such a way that the
31397floating-point unit is not used.
31398
d77de738 31399@opindex m4-200-single
ddf6fe37 31400@item -m4-200-single
d77de738
ML
31401Generate code for SH4-200 assuming the floating-point unit is in
31402single-precision mode by default.
31403
d77de738 31404@opindex m4-200-single-only
ddf6fe37 31405@item -m4-200-single-only
d77de738
ML
31406Generate code for SH4-200 in such a way that no double-precision
31407floating-point operations are used.
31408
d77de738 31409@opindex m4-300
ddf6fe37 31410@item -m4-300
d77de738
ML
31411Generate code for SH4-300.
31412
d77de738 31413@opindex m4-300-nofpu
ddf6fe37 31414@item -m4-300-nofpu
d77de738
ML
31415Generate code for SH4-300 without in such a way that the
31416floating-point unit is not used.
31417
d77de738 31418@opindex m4-300-single
ddf6fe37 31419@item -m4-300-single
d77de738
ML
31420Generate code for SH4-300 in such a way that no double-precision
31421floating-point operations are used.
31422
d77de738 31423@opindex m4-300-single-only
ddf6fe37 31424@item -m4-300-single-only
d77de738
ML
31425Generate code for SH4-300 in such a way that no double-precision
31426floating-point operations are used.
31427
d77de738 31428@opindex m4-340
ddf6fe37 31429@item -m4-340
d77de738
ML
31430Generate code for SH4-340 (no MMU, no FPU).
31431
d77de738 31432@opindex m4-500
ddf6fe37 31433@item -m4-500
d77de738
ML
31434Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
31435assembler.
31436
d77de738 31437@opindex m4a-nofpu
ddf6fe37 31438@item -m4a-nofpu
d77de738
ML
31439Generate code for the SH4al-dsp, or for a SH4a in such a way that the
31440floating-point unit is not used.
31441
d77de738 31442@opindex m4a-single-only
ddf6fe37 31443@item -m4a-single-only
d77de738
ML
31444Generate code for the SH4a, in such a way that no double-precision
31445floating-point operations are used.
31446
d77de738 31447@opindex m4a-single
ddf6fe37 31448@item -m4a-single
d77de738
ML
31449Generate code for the SH4a assuming the floating-point unit is in
31450single-precision mode by default.
31451
d77de738 31452@opindex m4a
ddf6fe37 31453@item -m4a
d77de738
ML
31454Generate code for the SH4a.
31455
d77de738 31456@opindex m4al
ddf6fe37 31457@item -m4al
d77de738
ML
31458Same as @option{-m4a-nofpu}, except that it implicitly passes
31459@option{-dsp} to the assembler. GCC doesn't generate any DSP
31460instructions at the moment.
31461
d77de738 31462@opindex mb
ddf6fe37 31463@item -mb
d77de738
ML
31464Compile code for the processor in big-endian mode.
31465
d77de738 31466@opindex ml
ddf6fe37 31467@item -ml
d77de738
ML
31468Compile code for the processor in little-endian mode.
31469
d77de738 31470@opindex mdalign
ddf6fe37 31471@item -mdalign
d77de738
ML
31472Align doubles at 64-bit boundaries. Note that this changes the calling
31473conventions, and thus some functions from the standard C library do
31474not work unless you recompile it first with @option{-mdalign}.
31475
d77de738 31476@opindex mrelax
ddf6fe37 31477@item -mrelax
d77de738
ML
31478Shorten some address references at link time, when possible; uses the
31479linker option @option{-relax}.
31480
d77de738 31481@opindex mbigtable
ddf6fe37 31482@item -mbigtable
d77de738
ML
31483Use 32-bit offsets in @code{switch} tables. The default is to use
3148416-bit offsets.
31485
d77de738 31486@opindex mbitops
ddf6fe37 31487@item -mbitops
d77de738
ML
31488Enable the use of bit manipulation instructions on SH2A.
31489
d77de738 31490@opindex mfmovd
ddf6fe37 31491@item -mfmovd
d77de738
ML
31492Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31493alignment constraints.
31494
d77de738 31495@opindex mrenesas
ddf6fe37 31496@item -mrenesas
d77de738
ML
31497Comply with the calling conventions defined by Renesas.
31498
d77de738 31499@opindex mno-renesas
ddf6fe37 31500@item -mno-renesas
d77de738
ML
31501Comply with the calling conventions defined for GCC before the Renesas
31502conventions were available. This option is the default for all
31503targets of the SH toolchain.
31504
d77de738 31505@opindex mnomacsave
ddf6fe37 31506@item -mnomacsave
d77de738
ML
31507Mark the @code{MAC} register as call-clobbered, even if
31508@option{-mrenesas} is given.
31509
d77de738
ML
31510@opindex mieee
31511@opindex mno-ieee
ddf6fe37
AA
31512@item -mieee
31513@itemx -mno-ieee
d77de738
ML
31514Control the IEEE compliance of floating-point comparisons, which affects the
31515handling of cases where the result of a comparison is unordered. By default
31516@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31517enabled @option{-mno-ieee} is implicitly set, which results in faster
31518floating-point greater-equal and less-equal comparisons. The implicit settings
31519can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31520
d77de738 31521@opindex minline-ic_invalidate
ddf6fe37 31522@item -minline-ic_invalidate
d77de738
ML
31523Inline code to invalidate instruction cache entries after setting up
31524nested function trampolines.
31525This option has no effect if @option{-musermode} is in effect and the selected
31526code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31527instruction.
31528If the selected code generation option does not allow the use of the @code{icbi}
31529instruction, and @option{-musermode} is not in effect, the inlined code
31530manipulates the instruction cache address array directly with an associative
31531write. This not only requires privileged mode at run time, but it also
31532fails if the cache line had been mapped via the TLB and has become unmapped.
31533
d77de738 31534@opindex misize
ddf6fe37 31535@item -misize
d77de738
ML
31536Dump instruction size and location in the assembly code.
31537
d77de738 31538@opindex mpadstruct
ddf6fe37 31539@item -mpadstruct
d77de738
ML
31540This option is deprecated. It pads structures to multiple of 4 bytes,
31541which is incompatible with the SH ABI@.
31542
d77de738 31543@opindex matomic-model=@var{model}
ddf6fe37 31544@item -matomic-model=@var{model}
d77de738
ML
31545Sets the model of atomic operations and additional parameters as a comma
31546separated list. For details on the atomic built-in functions see
31547@ref{__atomic Builtins}. The following models and parameters are supported:
31548
31549@table @samp
31550
31551@item none
31552Disable compiler generated atomic sequences and emit library calls for atomic
31553operations. This is the default if the target is not @code{sh*-*-linux*}.
31554
31555@item soft-gusa
31556Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31557built-in functions. The generated atomic sequences require additional support
31558from the interrupt/exception handling code of the system and are only suitable
31559for SH3* and SH4* single-core systems. This option is enabled by default when
31560the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31561this option also partially utilizes the hardware atomic instructions
31562@code{movli.l} and @code{movco.l} to create more efficient code, unless
31563@samp{strict} is specified.
31564
31565@item soft-tcb
31566Generate software atomic sequences that use a variable in the thread control
31567block. This is a variation of the gUSA sequences which can also be used on
31568SH1* and SH2* targets. The generated atomic sequences require additional
31569support from the interrupt/exception handling code of the system and are only
31570suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31571parameter has to be specified as well.
31572
31573@item soft-imask
31574Generate software atomic sequences that temporarily disable interrupts by
31575setting @code{SR.IMASK = 1111}. This model works only when the program runs
31576in privileged mode and is only suitable for single-core systems. Additional
31577support from the interrupt/exception handling code of the system is not
31578required. This model is enabled by default when the target is
31579@code{sh*-*-linux*} and SH1* or SH2*.
31580
31581@item hard-llcs
31582Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31583instructions only. This is only available on SH4A and is suitable for
31584multi-core systems. Since the hardware instructions support only 32 bit atomic
31585variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31586Code compiled with this option is also compatible with other software
31587atomic model interrupt/exception handling systems if executed on an SH4A
31588system. Additional support from the interrupt/exception handling code of the
31589system is not required for this model.
31590
31591@item gbr-offset=
31592This parameter specifies the offset in bytes of the variable in the thread
31593control block structure that should be used by the generated atomic sequences
31594when the @samp{soft-tcb} model has been selected. For other models this
31595parameter is ignored. The specified value must be an integer multiple of four
31596and in the range 0-1020.
31597
31598@item strict
31599This parameter prevents mixed usage of multiple atomic models, even if they
31600are compatible, and makes the compiler generate atomic sequences of the
31601specified model only.
31602
31603@end table
31604
d77de738 31605@opindex mtas
ddf6fe37 31606@item -mtas
d77de738
ML
31607Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31608Notice that depending on the particular hardware and software configuration
31609this can degrade overall performance due to the operand cache line flushes
31610that are implied by the @code{tas.b} instruction. On multi-core SH4A
31611processors the @code{tas.b} instruction must be used with caution since it
31612can result in data corruption for certain cache configurations.
31613
d77de738 31614@opindex mprefergot
ddf6fe37 31615@item -mprefergot
d77de738
ML
31616When generating position-independent code, emit function calls using
31617the Global Offset Table instead of the Procedure Linkage Table.
31618
d77de738
ML
31619@opindex musermode
31620@opindex mno-usermode
ddf6fe37
AA
31621@item -musermode
31622@itemx -mno-usermode
d77de738
ML
31623Don't allow (allow) the compiler generating privileged mode code. Specifying
31624@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31625inlined code would not work in user mode. @option{-musermode} is the default
31626when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31627@option{-musermode} has no effect, since there is no user mode.
31628
d77de738 31629@opindex multcost=@var{number}
ddf6fe37 31630@item -multcost=@var{number}
d77de738
ML
31631Set the cost to assume for a multiply insn.
31632
d77de738 31633@opindex mdiv=@var{strategy}
ddf6fe37 31634@item -mdiv=@var{strategy}
d77de738
ML
31635Set the division strategy to be used for integer division operations.
31636@var{strategy} can be one of:
31637
31638@table @samp
31639
31640@item call-div1
31641Calls a library function that uses the single-step division instruction
31642@code{div1} to perform the operation. Division by zero calculates an
31643unspecified result and does not trap. This is the default except for SH4,
31644SH2A and SHcompact.
31645
31646@item call-fp
31647Calls a library function that performs the operation in double precision
31648floating point. Division by zero causes a floating-point exception. This is
31649the default for SHcompact with FPU. Specifying this for targets that do not
31650have a double precision FPU defaults to @code{call-div1}.
31651
31652@item call-table
31653Calls a library function that uses a lookup table for small divisors and
31654the @code{div1} instruction with case distinction for larger divisors. Division
31655by zero calculates an unspecified result and does not trap. This is the default
31656for SH4. Specifying this for targets that do not have dynamic shift
31657instructions defaults to @code{call-div1}.
31658
31659@end table
31660
31661When a division strategy has not been specified the default strategy is
31662selected based on the current target. For SH2A the default strategy is to
31663use the @code{divs} and @code{divu} instructions instead of library function
31664calls.
31665
d77de738 31666@opindex maccumulate-outgoing-args
ddf6fe37 31667@item -maccumulate-outgoing-args
d77de738
ML
31668Reserve space once for outgoing arguments in the function prologue rather
31669than around each call. Generally beneficial for performance and size. Also
31670needed for unwinding to avoid changing the stack frame around conditional code.
31671
d77de738 31672@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31673@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31674Set the name of the library function used for 32-bit signed division to
31675@var{name}.
31676This only affects the name used in the @samp{call} division strategies, and
31677the compiler still expects the same sets of input/output/clobbered registers as
31678if this option were not present.
31679
d77de738 31680@opindex mfixed-range
ddf6fe37 31681@item -mfixed-range=@var{register-range}
d77de738
ML
31682Generate code treating the given register range as fixed registers.
31683A fixed register is one that the register allocator cannot use. This is
31684useful when compiling kernel code. A register range is specified as
31685two registers separated by a dash. Multiple register ranges can be
31686specified separated by a comma.
31687
d77de738 31688@opindex mbranch-cost=@var{num}
ddf6fe37 31689@item -mbranch-cost=@var{num}
d77de738
ML
31690Assume @var{num} to be the cost for a branch instruction. Higher numbers
31691make the compiler try to generate more branch-free code if possible.
31692If not specified the value is selected depending on the processor type that
31693is being compiled for.
31694
d77de738
ML
31695@opindex mzdcbranch
31696@opindex mno-zdcbranch
ddf6fe37
AA
31697@item -mzdcbranch
31698@itemx -mno-zdcbranch
d77de738
ML
31699Assume (do not assume) that zero displacement conditional branch instructions
31700@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31701compiler prefers zero displacement branch code sequences. This is
31702enabled by default when generating code for SH4 and SH4A. It can be explicitly
31703disabled by specifying @option{-mno-zdcbranch}.
31704
d77de738 31705@opindex mcbranch-force-delay-slot
ddf6fe37 31706@item -mcbranch-force-delay-slot
d77de738
ML
31707Force the usage of delay slots for conditional branches, which stuffs the delay
31708slot with a @code{nop} if a suitable instruction cannot be found. By default
31709this option is disabled. It can be enabled to work around hardware bugs as
31710found in the original SH7055.
31711
d77de738
ML
31712@opindex mfused-madd
31713@opindex mno-fused-madd
ddf6fe37
AA
31714@item -mfused-madd
31715@itemx -mno-fused-madd
d77de738
ML
31716Generate code that uses (does not use) the floating-point multiply and
31717accumulate instructions. These instructions are generated by default
31718if hardware floating point is used. The machine-dependent
31719@option{-mfused-madd} option is now mapped to the machine-independent
31720@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31721mapped to @option{-ffp-contract=off}.
31722
d77de738
ML
31723@opindex mfsca
31724@opindex mno-fsca
ddf6fe37
AA
31725@item -mfsca
31726@itemx -mno-fsca
d77de738
ML
31727Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31728and cosine approximations. The option @option{-mfsca} must be used in
31729combination with @option{-funsafe-math-optimizations}. It is enabled by default
31730when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31731approximations even if @option{-funsafe-math-optimizations} is in effect.
31732
d77de738
ML
31733@opindex mfsrra
31734@opindex mno-fsrra
ddf6fe37
AA
31735@item -mfsrra
31736@itemx -mno-fsrra
d77de738
ML
31737Allow or disallow the compiler to emit the @code{fsrra} instruction for
31738reciprocal square root approximations. The option @option{-mfsrra} must be used
31739in combination with @option{-funsafe-math-optimizations} and
31740@option{-ffinite-math-only}. It is enabled by default when generating code for
31741SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31742even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31743in effect.
31744
d77de738 31745@opindex mpretend-cmove
ddf6fe37 31746@item -mpretend-cmove
d77de738
ML
31747Prefer zero-displacement conditional branches for conditional move instruction
31748patterns. This can result in faster code on the SH4 processor.
31749
d77de738 31750@opindex fdpic
ddf6fe37 31751@item -mfdpic
d77de738
ML
31752Generate code using the FDPIC ABI.
31753
31754@end table
31755
31756@node Solaris 2 Options
31757@subsection Solaris 2 Options
31758@cindex Solaris 2 options
31759
31760These @samp{-m} options are supported on Solaris 2:
31761
31762@table @gcctabopt
d77de738 31763@opindex mclear-hwcap
ddf6fe37 31764@item -mclear-hwcap
d77de738
ML
31765@option{-mclear-hwcap} tells the compiler to remove the hardware
31766capabilities generated by the Solaris assembler. This is only necessary
31767when object files use ISA extensions not supported by the current
31768machine, but check at runtime whether or not to use them.
31769
d77de738 31770@opindex mimpure-text
ddf6fe37 31771@item -mimpure-text
d77de738
ML
31772@option{-mimpure-text}, used in addition to @option{-shared}, tells
31773the compiler to not pass @option{-z text} to the linker when linking a
31774shared object. Using this option, you can link position-dependent
31775code into a shared object.
31776
31777@option{-mimpure-text} suppresses the ``relocations remain against
31778allocatable but non-writable sections'' linker error message.
31779However, the necessary relocations trigger copy-on-write, and the
31780shared object is not actually shared across processes. Instead of
31781using @option{-mimpure-text}, you should compile all source code with
31782@option{-fpic} or @option{-fPIC}.
31783
31784@end table
31785
31786These switches are supported in addition to the above on Solaris 2:
31787
31788@table @gcctabopt
d77de738 31789@opindex pthreads
ddf6fe37 31790@item -pthreads
d77de738
ML
31791This is a synonym for @option{-pthread}.
31792@end table
31793
31794@node SPARC Options
31795@subsection SPARC Options
31796@cindex SPARC options
31797
31798These @samp{-m} options are supported on the SPARC:
31799
31800@table @gcctabopt
d77de738
ML
31801@opindex mno-app-regs
31802@opindex mapp-regs
ddf6fe37
AA
31803@item -mno-app-regs
31804@itemx -mapp-regs
d77de738
ML
31805Specify @option{-mapp-regs} to generate output using the global registers
318062 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31807global register 1, each global register 2 through 4 is then treated as an
31808allocable register that is clobbered by function calls. This is the default.
31809
31810To be fully SVR4 ABI-compliant at the cost of some performance loss,
31811specify @option{-mno-app-regs}. You should compile libraries and system
31812software with this option.
31813
d77de738
ML
31814@opindex mflat
31815@opindex mno-flat
ddf6fe37
AA
31816@item -mflat
31817@itemx -mno-flat
d77de738
ML
31818With @option{-mflat}, the compiler does not generate save/restore instructions
31819and uses a ``flat'' or single register window model. This model is compatible
31820with the regular register window model. The local registers and the input
31821registers (0--5) are still treated as ``call-saved'' registers and are
31822saved on the stack as needed.
31823
31824With @option{-mno-flat} (the default), the compiler generates save/restore
31825instructions (except for leaf functions). This is the normal operating mode.
31826
d77de738
ML
31827@opindex mfpu
31828@opindex mhard-float
ddf6fe37
AA
31829@item -mfpu
31830@itemx -mhard-float
d77de738
ML
31831Generate output containing floating-point instructions. This is the
31832default.
31833
d77de738
ML
31834@opindex mno-fpu
31835@opindex msoft-float
ddf6fe37
AA
31836@item -mno-fpu
31837@itemx -msoft-float
d77de738
ML
31838Generate output containing library calls for floating point.
31839@strong{Warning:} the requisite libraries are not available for all SPARC
31840targets. Normally the facilities of the machine's usual C compiler are
31841used, but this cannot be done directly in cross-compilation. You must make
31842your own arrangements to provide suitable library functions for
31843cross-compilation. The embedded targets @samp{sparc-*-aout} and
31844@samp{sparclite-*-*} do provide software floating-point support.
31845
31846@option{-msoft-float} changes the calling convention in the output file;
31847therefore, it is only useful if you compile @emph{all} of a program with
31848this option. In particular, you need to compile @file{libgcc.a}, the
31849library that comes with GCC, with @option{-msoft-float} in order for
31850this to work.
31851
d77de738 31852@opindex mhard-quad-float
ddf6fe37 31853@item -mhard-quad-float
d77de738
ML
31854Generate output containing quad-word (long double) floating-point
31855instructions.
31856
d77de738 31857@opindex msoft-quad-float
ddf6fe37 31858@item -msoft-quad-float
d77de738
ML
31859Generate output containing library calls for quad-word (long double)
31860floating-point instructions. The functions called are those specified
31861in the SPARC ABI@. This is the default.
31862
31863As of this writing, there are no SPARC implementations that have hardware
31864support for the quad-word floating-point instructions. They all invoke
31865a trap handler for one of these instructions, and then the trap handler
31866emulates the effect of the instruction. Because of the trap handler overhead,
31867this is much slower than calling the ABI library routines. Thus the
31868@option{-msoft-quad-float} option is the default.
31869
d77de738
ML
31870@opindex mno-unaligned-doubles
31871@opindex munaligned-doubles
ddf6fe37
AA
31872@item -mno-unaligned-doubles
31873@itemx -munaligned-doubles
d77de738
ML
31874Assume that doubles have 8-byte alignment. This is the default.
31875
31876With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31877alignment only if they are contained in another type, or if they have an
31878absolute address. Otherwise, it assumes they have 4-byte alignment.
31879Specifying this option avoids some rare compatibility problems with code
31880generated by other compilers. It is not the default because it results
31881in a performance loss, especially for floating-point code.
31882
d77de738
ML
31883@opindex muser-mode
31884@opindex mno-user-mode
ddf6fe37
AA
31885@item -muser-mode
31886@itemx -mno-user-mode
d77de738
ML
31887Do not generate code that can only run in supervisor mode. This is relevant
31888only for the @code{casa} instruction emitted for the LEON3 processor. This
31889is the default.
31890
d77de738
ML
31891@opindex mfaster-structs
31892@opindex mno-faster-structs
ddf6fe37
AA
31893@item -mfaster-structs
31894@itemx -mno-faster-structs
d77de738
ML
31895With @option{-mfaster-structs}, the compiler assumes that structures
31896should have 8-byte alignment. This enables the use of pairs of
31897@code{ldd} and @code{std} instructions for copies in structure
31898assignment, in place of twice as many @code{ld} and @code{st} pairs.
31899However, the use of this changed alignment directly violates the SPARC
31900ABI@. Thus, it's intended only for use on targets where the developer
31901acknowledges that their resulting code is not directly in line with
31902the rules of the ABI@.
31903
d77de738
ML
31904@opindex mstd-struct-return
31905@opindex mno-std-struct-return
ddf6fe37
AA
31906@item -mstd-struct-return
31907@itemx -mno-std-struct-return
d77de738
ML
31908With @option{-mstd-struct-return}, the compiler generates checking code
31909in functions returning structures or unions to detect size mismatches
31910between the two sides of function calls, as per the 32-bit ABI@.
31911
31912The default is @option{-mno-std-struct-return}. This option has no effect
31913in 64-bit mode.
31914
d77de738
ML
31915@opindex mlra
31916@opindex mno-lra
ddf6fe37
AA
31917@item -mlra
31918@itemx -mno-lra
d77de738
ML
31919Enable Local Register Allocation. This is the default for SPARC since GCC 7
31920so @option{-mno-lra} needs to be passed to get old Reload.
31921
d77de738 31922@opindex mcpu
ddf6fe37 31923@item -mcpu=@var{cpu_type}
d77de738
ML
31924Set the instruction set, register set, and instruction scheduling parameters
31925for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31926@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31927@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31928@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31929@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31930@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31931@samp{m8}.
31932
31933Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31934which selects the best architecture option for the host processor.
31935@option{-mcpu=native} has no effect if GCC does not recognize
31936the processor.
31937
31938Default instruction scheduling parameters are used for values that select
31939an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31940@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31941
31942Here is a list of each supported architecture and their supported
31943implementations.
31944
31945@table @asis
31946@item v7
31947cypress, leon3v7
31948
31949@item v8
31950supersparc, hypersparc, leon, leon3, leon5
31951
31952@item sparclite
31953f930, f934, sparclite86x
31954
31955@item sparclet
31956tsc701
31957
31958@item v9
31959ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31960niagara7, m8
31961@end table
31962
31963By default (unless configured otherwise), GCC generates code for the V7
31964variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31965additionally optimizes it for the Cypress CY7C602 chip, as used in the
31966SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31967SPARCStation 1, 2, IPX etc.
31968
31969With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31970architecture. The only difference from V7 code is that the compiler emits
31971the integer multiply and integer divide instructions which exist in SPARC-V8
31972but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31973optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
319742000 series.
31975
31976With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31977the SPARC architecture. This adds the integer multiply, integer divide step
31978and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31979With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31980Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31981@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31982MB86934 chip, which is the more recent SPARClite with FPU@.
31983
31984With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31985the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31986integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31987but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31988optimizes it for the TEMIC SPARClet chip.
31989
31990With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31991architecture. This adds 64-bit integer and floating-point move instructions,
319923 additional floating-point condition code registers and conditional move
31993instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31994optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31995@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31996Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31997@option{-mcpu=niagara}, the compiler additionally optimizes it for
31998Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31999additionally optimizes it for Sun UltraSPARC T2 chips. With
32000@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
32001UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
32002additionally optimizes it for Sun UltraSPARC T4 chips. With
32003@option{-mcpu=niagara7}, the compiler additionally optimizes it for
32004Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
32005additionally optimizes it for Oracle M8 chips.
32006
d77de738 32007@opindex mtune
ddf6fe37 32008@item -mtune=@var{cpu_type}
d77de738
ML
32009Set the instruction scheduling parameters for machine type
32010@var{cpu_type}, but do not set the instruction set or register set that the
32011option @option{-mcpu=@var{cpu_type}} does.
32012
32013The same values for @option{-mcpu=@var{cpu_type}} can be used for
32014@option{-mtune=@var{cpu_type}}, but the only useful values are those
32015that select a particular CPU implementation. Those are
32016@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
32017@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
32018@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
32019@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
32020@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
32021and GNU/Linux toolchains, @samp{native} can also be used.
32022
d77de738
ML
32023@opindex mv8plus
32024@opindex mno-v8plus
ddf6fe37
AA
32025@item -mv8plus
32026@itemx -mno-v8plus
d77de738
ML
32027With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
32028difference from the V8 ABI is that the global and out registers are
32029considered 64 bits wide. This is enabled by default on Solaris in 32-bit
32030mode for all SPARC-V9 processors.
32031
d77de738
ML
32032@opindex mvis
32033@opindex mno-vis
ddf6fe37
AA
32034@item -mvis
32035@itemx -mno-vis
d77de738
ML
32036With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
32037Visual Instruction Set extensions. The default is @option{-mno-vis}.
32038
d77de738
ML
32039@opindex mvis2
32040@opindex mno-vis2
ddf6fe37
AA
32041@item -mvis2
32042@itemx -mno-vis2
d77de738
ML
32043With @option{-mvis2}, GCC generates code that takes advantage of
32044version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
32045default is @option{-mvis2} when targeting a cpu that supports such
32046instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
32047also sets @option{-mvis}.
32048
d77de738
ML
32049@opindex mvis3
32050@opindex mno-vis3
ddf6fe37
AA
32051@item -mvis3
32052@itemx -mno-vis3
d77de738
ML
32053With @option{-mvis3}, GCC generates code that takes advantage of
32054version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
32055default is @option{-mvis3} when targeting a cpu that supports such
32056instructions, such as niagara-3 and later. Setting @option{-mvis3}
32057also sets @option{-mvis2} and @option{-mvis}.
32058
d77de738
ML
32059@opindex mvis4
32060@opindex mno-vis4
ddf6fe37
AA
32061@item -mvis4
32062@itemx -mno-vis4
d77de738
ML
32063With @option{-mvis4}, GCC generates code that takes advantage of
32064version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
32065default is @option{-mvis4} when targeting a cpu that supports such
32066instructions, such as niagara-7 and later. Setting @option{-mvis4}
32067also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
32068
d77de738
ML
32069@opindex mvis4b
32070@opindex mno-vis4b
ddf6fe37
AA
32071@item -mvis4b
32072@itemx -mno-vis4b
d77de738
ML
32073With @option{-mvis4b}, GCC generates code that takes advantage of
32074version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
32075the additional VIS instructions introduced in the Oracle SPARC
32076Architecture 2017. The default is @option{-mvis4b} when targeting a
32077cpu that supports such instructions, such as m8 and later. Setting
32078@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
32079@option{-mvis2} and @option{-mvis}.
32080
d77de738
ML
32081@opindex mcbcond
32082@opindex mno-cbcond
ddf6fe37
AA
32083@item -mcbcond
32084@itemx -mno-cbcond
d77de738
ML
32085With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
32086Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
32087when targeting a CPU that supports such instructions, such as Niagara-4 and
32088later.
32089
d77de738
ML
32090@opindex mfmaf
32091@opindex mno-fmaf
ddf6fe37
AA
32092@item -mfmaf
32093@itemx -mno-fmaf
d77de738
ML
32094With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
32095Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
32096when targeting a CPU that supports such instructions, such as Niagara-3 and
32097later.
32098
d77de738
ML
32099@opindex mfsmuld
32100@opindex mno-fsmuld
ddf6fe37
AA
32101@item -mfsmuld
32102@itemx -mno-fsmuld
d77de738
ML
32103With @option{-mfsmuld}, GCC generates code that takes advantage of the
32104Floating-point Multiply Single to Double (FsMULd) instruction. The default is
32105@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
32106or V9 with FPU except @option{-mcpu=leon}.
32107
d77de738
ML
32108@opindex mpopc
32109@opindex mno-popc
ddf6fe37
AA
32110@item -mpopc
32111@itemx -mno-popc
d77de738
ML
32112With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
32113Population Count instruction. The default is @option{-mpopc}
32114when targeting a CPU that supports such an instruction, such as Niagara-2 and
32115later.
32116
d77de738
ML
32117@opindex msubxc
32118@opindex mno-subxc
ddf6fe37
AA
32119@item -msubxc
32120@itemx -mno-subxc
d77de738
ML
32121With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
32122Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
32123when targeting a CPU that supports such an instruction, such as Niagara-7 and
32124later.
32125
d77de738 32126@opindex mfix-at697f
ddf6fe37 32127@item -mfix-at697f
d77de738
ML
32128Enable the documented workaround for the single erratum of the Atmel AT697F
32129processor (which corresponds to erratum #13 of the AT697E processor).
32130
d77de738 32131@opindex mfix-ut699
ddf6fe37 32132@item -mfix-ut699
d77de738
ML
32133Enable the documented workarounds for the floating-point errata and the data
32134cache nullify errata of the UT699 processor.
32135
d77de738 32136@opindex mfix-ut700
ddf6fe37 32137@item -mfix-ut700
d77de738
ML
32138Enable the documented workaround for the back-to-back store errata of
32139the UT699E/UT700 processor.
32140
d77de738 32141@opindex mfix-gr712rc
ddf6fe37 32142@item -mfix-gr712rc
d77de738
ML
32143Enable the documented workaround for the back-to-back store errata of
32144the GR712RC processor.
32145@end table
32146
32147These @samp{-m} options are supported in addition to the above
32148on SPARC-V9 processors in 64-bit environments:
32149
32150@table @gcctabopt
d77de738
ML
32151@opindex m32
32152@opindex m64
ddf6fe37
AA
32153@item -m32
32154@itemx -m64
d77de738
ML
32155Generate code for a 32-bit or 64-bit environment.
32156The 32-bit environment sets int, long and pointer to 32 bits.
32157The 64-bit environment sets int to 32 bits and long and pointer
32158to 64 bits.
32159
d77de738 32160@opindex mcmodel
ddf6fe37 32161@item -mcmodel=@var{which}
d77de738
ML
32162Set the code model to one of
32163
32164@table @samp
32165@item medlow
32166The Medium/Low code model: 64-bit addresses, programs
32167must be linked in the low 32 bits of memory. Programs can be statically
32168or dynamically linked.
32169
32170@item medmid
32171The Medium/Middle code model: 64-bit addresses, programs
32172must be linked in the low 44 bits of memory, the text and data segments must
32173be less than 2GB in size and the data segment must be located within 2GB of
32174the text segment.
32175
32176@item medany
32177The Medium/Anywhere code model: 64-bit addresses, programs
32178may be linked anywhere in memory, the text and data segments must be less
32179than 2GB in size and the data segment must be located within 2GB of the
32180text segment.
32181
32182@item embmedany
32183The Medium/Anywhere code model for embedded systems:
3218464-bit addresses, the text and data segments must be less than 2GB in
32185size, both starting anywhere in memory (determined at link time). The
32186global register %g4 points to the base of the data segment. Programs
32187are statically linked and PIC is not supported.
32188@end table
32189
d77de738 32190@opindex mmemory-model
ddf6fe37 32191@item -mmemory-model=@var{mem-model}
d77de738
ML
32192Set the memory model in force on the processor to one of
32193
32194@table @samp
32195@item default
32196The default memory model for the processor and operating system.
32197
32198@item rmo
32199Relaxed Memory Order
32200
32201@item pso
32202Partial Store Order
32203
32204@item tso
32205Total Store Order
32206
32207@item sc
32208Sequential Consistency
32209@end table
32210
32211These memory models are formally defined in Appendix D of the SPARC-V9
32212architecture manual, as set in the processor's @code{PSTATE.MM} field.
32213
d77de738
ML
32214@opindex mstack-bias
32215@opindex mno-stack-bias
ddf6fe37
AA
32216@item -mstack-bias
32217@itemx -mno-stack-bias
d77de738
ML
32218With @option{-mstack-bias}, GCC assumes that the stack pointer, and
32219frame pointer if present, are offset by @minus{}2047 which must be added back
32220when making stack frame references. This is the default in 64-bit mode.
32221Otherwise, assume no such offset is present.
32222@end table
32223
32224@node System V Options
32225@subsection Options for System V
32226
32227These additional options are available on System V Release 4 for
32228compatibility with other compilers on those systems:
32229
32230@table @gcctabopt
d77de738 32231@opindex G
ddf6fe37 32232@item -G
d77de738
ML
32233Create a shared object.
32234It is recommended that @option{-symbolic} or @option{-shared} be used instead.
32235
d77de738 32236@opindex Qy
ddf6fe37 32237@item -Qy
d77de738
ML
32238Identify the versions of each tool used by the compiler, in a
32239@code{.ident} assembler directive in the output.
32240
d77de738 32241@opindex Qn
ddf6fe37 32242@item -Qn
d77de738
ML
32243Refrain from adding @code{.ident} directives to the output file (this is
32244the default).
32245
d77de738 32246@opindex YP
ddf6fe37 32247@item -YP,@var{dirs}
d77de738
ML
32248Search the directories @var{dirs}, and no others, for libraries
32249specified with @option{-l}.
32250
d77de738 32251@opindex Ym
ddf6fe37 32252@item -Ym,@var{dir}
d77de738
ML
32253Look in the directory @var{dir} to find the M4 preprocessor.
32254The assembler uses this option.
32255@c This is supposed to go with a -Yd for predefined M4 macro files, but
32256@c the generic assembler that comes with Solaris takes just -Ym.
32257@end table
32258
32259@node V850 Options
32260@subsection V850 Options
32261@cindex V850 Options
32262
32263These @samp{-m} options are defined for V850 implementations:
32264
32265@table @gcctabopt
d77de738
ML
32266@opindex mlong-calls
32267@opindex mno-long-calls
ddf6fe37
AA
32268@item -mlong-calls
32269@itemx -mno-long-calls
d77de738
ML
32270Treat all calls as being far away (near). If calls are assumed to be
32271far away, the compiler always loads the function's address into a
32272register, and calls indirect through the pointer.
32273
d77de738
ML
32274@opindex mno-ep
32275@opindex mep
ddf6fe37
AA
32276@item -mno-ep
32277@itemx -mep
d77de738
ML
32278Do not optimize (do optimize) basic blocks that use the same index
32279pointer 4 or more times to copy pointer into the @code{ep} register, and
32280use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
32281option is on by default if you optimize.
32282
d77de738
ML
32283@opindex mno-prolog-function
32284@opindex mprolog-function
ddf6fe37
AA
32285@item -mno-prolog-function
32286@itemx -mprolog-function
d77de738
ML
32287Do not use (do use) external functions to save and restore registers
32288at the prologue and epilogue of a function. The external functions
32289are slower, but use less code space if more than one function saves
32290the same number of registers. The @option{-mprolog-function} option
32291is on by default if you optimize.
32292
d77de738 32293@opindex mspace
ddf6fe37 32294@item -mspace
d77de738
ML
32295Try to make the code as small as possible. At present, this just turns
32296on the @option{-mep} and @option{-mprolog-function} options.
32297
d77de738 32298@opindex mtda
ddf6fe37 32299@item -mtda=@var{n}
d77de738
ML
32300Put static or global variables whose size is @var{n} bytes or less into
32301the tiny data area that register @code{ep} points to. The tiny data
32302area can hold up to 256 bytes in total (128 bytes for byte references).
32303
d77de738 32304@opindex msda
ddf6fe37 32305@item -msda=@var{n}
d77de738
ML
32306Put static or global variables whose size is @var{n} bytes or less into
32307the small data area that register @code{gp} points to. The small data
32308area can hold up to 64 kilobytes.
32309
d77de738 32310@opindex mzda
ddf6fe37 32311@item -mzda=@var{n}
d77de738
ML
32312Put static or global variables whose size is @var{n} bytes or less into
32313the first 32 kilobytes of memory.
32314
d77de738 32315@opindex mv850
ddf6fe37 32316@item -mv850
d77de738
ML
32317Specify that the target processor is the V850.
32318
d77de738 32319@opindex mv850e3v5
ddf6fe37 32320@item -mv850e3v5
d77de738
ML
32321Specify that the target processor is the V850E3V5. The preprocessor
32322constant @code{__v850e3v5__} is defined if this option is used.
32323
d77de738 32324@opindex mv850e2v4
ddf6fe37 32325@item -mv850e2v4
d77de738
ML
32326Specify that the target processor is the V850E3V5. This is an alias for
32327the @option{-mv850e3v5} option.
32328
d77de738 32329@opindex mv850e2v3
ddf6fe37 32330@item -mv850e2v3
d77de738
ML
32331Specify that the target processor is the V850E2V3. The preprocessor
32332constant @code{__v850e2v3__} is defined if this option is used.
32333
d77de738 32334@opindex mv850e2
ddf6fe37 32335@item -mv850e2
d77de738
ML
32336Specify that the target processor is the V850E2. The preprocessor
32337constant @code{__v850e2__} is defined if this option is used.
32338
d77de738 32339@opindex mv850e1
ddf6fe37 32340@item -mv850e1
d77de738
ML
32341Specify that the target processor is the V850E1. The preprocessor
32342constants @code{__v850e1__} and @code{__v850e__} are defined if
32343this option is used.
32344
d77de738 32345@opindex mv850es
ddf6fe37 32346@item -mv850es
d77de738
ML
32347Specify that the target processor is the V850ES. This is an alias for
32348the @option{-mv850e1} option.
32349
d77de738 32350@opindex mv850e
ddf6fe37 32351@item -mv850e
d77de738
ML
32352Specify that the target processor is the V850E@. The preprocessor
32353constant @code{__v850e__} is defined if this option is used.
32354
32355If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
32356nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
32357are defined then a default target processor is chosen and the
32358relevant @samp{__v850*__} preprocessor constant is defined.
32359
32360The preprocessor constants @code{__v850} and @code{__v851__} are always
32361defined, regardless of which processor variant is the target.
32362
d77de738
ML
32363@opindex mdisable-callt
32364@opindex mno-disable-callt
ddf6fe37
AA
32365@item -mdisable-callt
32366@itemx -mno-disable-callt
d77de738
ML
32367This option suppresses generation of the @code{CALLT} instruction for the
32368v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
32369architecture.
32370
32371This option is enabled by default when the RH850 ABI is
32372in use (see @option{-mrh850-abi}), and disabled by default when the
32373GCC ABI is in use. If @code{CALLT} instructions are being generated
32374then the C preprocessor symbol @code{__V850_CALLT__} is defined.
32375
d77de738
ML
32376@opindex mrelax
32377@opindex mno-relax
ddf6fe37
AA
32378@item -mrelax
32379@itemx -mno-relax
d77de738
ML
32380Pass on (or do not pass on) the @option{-mrelax} command-line option
32381to the assembler.
32382
d77de738
ML
32383@opindex mlong-jumps
32384@opindex mno-long-jumps
ddf6fe37
AA
32385@item -mlong-jumps
32386@itemx -mno-long-jumps
d77de738
ML
32387Disable (or re-enable) the generation of PC-relative jump instructions.
32388
d77de738
ML
32389@opindex msoft-float
32390@opindex mhard-float
ddf6fe37
AA
32391@item -msoft-float
32392@itemx -mhard-float
d77de738
ML
32393Disable (or re-enable) the generation of hardware floating point
32394instructions. This option is only significant when the target
32395architecture is @samp{V850E2V3} or higher. If hardware floating point
32396instructions are being generated then the C preprocessor symbol
32397@code{__FPU_OK__} is defined, otherwise the symbol
32398@code{__NO_FPU__} is defined.
32399
d77de738 32400@opindex mloop
ddf6fe37 32401@item -mloop
d77de738
ML
32402Enables the use of the e3v5 LOOP instruction. The use of this
32403instruction is not enabled by default when the e3v5 architecture is
32404selected because its use is still experimental.
32405
d77de738
ML
32406@opindex mrh850-abi
32407@opindex mghs
ddf6fe37
AA
32408@item -mrh850-abi
32409@itemx -mghs
d77de738
ML
32410Enables support for the RH850 version of the V850 ABI. This is the
32411default. With this version of the ABI the following rules apply:
32412
32413@itemize
32414@item
32415Integer sized structures and unions are returned via a memory pointer
32416rather than a register.
32417
32418@item
32419Large structures and unions (more than 8 bytes in size) are passed by
32420value.
32421
32422@item
32423Functions are aligned to 16-bit boundaries.
32424
32425@item
32426The @option{-m8byte-align} command-line option is supported.
32427
32428@item
32429The @option{-mdisable-callt} command-line option is enabled by
32430default. The @option{-mno-disable-callt} command-line option is not
32431supported.
32432@end itemize
32433
32434When this version of the ABI is enabled the C preprocessor symbol
32435@code{__V850_RH850_ABI__} is defined.
32436
d77de738 32437@opindex mgcc-abi
ddf6fe37 32438@item -mgcc-abi
d77de738
ML
32439Enables support for the old GCC version of the V850 ABI. With this
32440version of the ABI the following rules apply:
32441
32442@itemize
32443@item
32444Integer sized structures and unions are returned in register @code{r10}.
32445
32446@item
32447Large structures and unions (more than 8 bytes in size) are passed by
32448reference.
32449
32450@item
32451Functions are aligned to 32-bit boundaries, unless optimizing for
32452size.
32453
32454@item
32455The @option{-m8byte-align} command-line option is not supported.
32456
32457@item
32458The @option{-mdisable-callt} command-line option is supported but not
32459enabled by default.
32460@end itemize
32461
32462When this version of the ABI is enabled the C preprocessor symbol
32463@code{__V850_GCC_ABI__} is defined.
32464
d77de738
ML
32465@opindex m8byte-align
32466@opindex mno-8byte-align
ddf6fe37
AA
32467@item -m8byte-align
32468@itemx -mno-8byte-align
d77de738
ML
32469Enables support for @code{double} and @code{long long} types to be
32470aligned on 8-byte boundaries. The default is to restrict the
32471alignment of all objects to at most 4-bytes. When
32472@option{-m8byte-align} is in effect the C preprocessor symbol
32473@code{__V850_8BYTE_ALIGN__} is defined.
32474
d77de738 32475@opindex mbig-switch
ddf6fe37 32476@item -mbig-switch
d77de738
ML
32477Generate code suitable for big switch tables. Use this option only if
32478the assembler/linker complain about out of range branches within a switch
32479table.
32480
d77de738 32481@opindex mapp-regs
ddf6fe37 32482@item -mapp-regs
d77de738
ML
32483This option causes r2 and r5 to be used in the code generated by
32484the compiler. This setting is the default.
32485
d77de738 32486@opindex mno-app-regs
ddf6fe37 32487@item -mno-app-regs
d77de738
ML
32488This option causes r2 and r5 to be treated as fixed registers.
32489
32490@end table
32491
32492@node VAX Options
32493@subsection VAX Options
32494@cindex VAX options
32495
32496These @samp{-m} options are defined for the VAX:
32497
32498@table @gcctabopt
d77de738 32499@opindex munix
ddf6fe37 32500@item -munix
d77de738
ML
32501Do not output certain jump instructions (@code{aobleq} and so on)
32502that the Unix assembler for the VAX cannot handle across long
32503ranges.
32504
d77de738 32505@opindex mgnu
ddf6fe37 32506@item -mgnu
d77de738
ML
32507Do output those jump instructions, on the assumption that the
32508GNU assembler is being used.
32509
d77de738 32510@opindex mg
ddf6fe37 32511@item -mg
d77de738
ML
32512Output code for G-format floating-point numbers instead of D-format.
32513
d77de738
ML
32514@opindex mlra
32515@opindex mno-lra
ddf6fe37
AA
32516@item -mlra
32517@itemx -mno-lra
d77de738
ML
32518Enable Local Register Allocation. This is still experimental for the VAX,
32519so by default the compiler uses standard reload.
32520@end table
32521
32522@node Visium Options
32523@subsection Visium Options
32524@cindex Visium options
32525
32526@table @gcctabopt
32527
d77de738 32528@opindex mdebug
ddf6fe37 32529@item -mdebug
d77de738
ML
32530A program which performs file I/O and is destined to run on an MCM target
32531should be linked with this option. It causes the libraries libc.a and
32532libdebug.a to be linked. The program should be run on the target under
32533the control of the GDB remote debugging stub.
32534
d77de738 32535@opindex msim
ddf6fe37 32536@item -msim
d77de738
ML
32537A program which performs file I/O and is destined to run on the simulator
32538should be linked with option. This causes libraries libc.a and libsim.a to
32539be linked.
32540
d77de738
ML
32541@opindex mfpu
32542@opindex mhard-float
ddf6fe37
AA
32543@item -mfpu
32544@itemx -mhard-float
d77de738
ML
32545Generate code containing floating-point instructions. This is the
32546default.
32547
d77de738
ML
32548@opindex mno-fpu
32549@opindex msoft-float
ddf6fe37
AA
32550@item -mno-fpu
32551@itemx -msoft-float
d77de738
ML
32552Generate code containing library calls for floating-point.
32553
32554@option{-msoft-float} changes the calling convention in the output file;
32555therefore, it is only useful if you compile @emph{all} of a program with
32556this option. In particular, you need to compile @file{libgcc.a}, the
32557library that comes with GCC, with @option{-msoft-float} in order for
32558this to work.
32559
d77de738 32560@opindex mcpu
ddf6fe37 32561@item -mcpu=@var{cpu_type}
d77de738
ML
32562Set the instruction set, register set, and instruction scheduling parameters
32563for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32564@samp{mcm}, @samp{gr5} and @samp{gr6}.
32565
32566@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32567
32568By default (unless configured otherwise), GCC generates code for the GR5
32569variant of the Visium architecture.
32570
32571With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32572architecture. The only difference from GR5 code is that the compiler will
32573generate block move instructions.
32574
d77de738 32575@opindex mtune
ddf6fe37 32576@item -mtune=@var{cpu_type}
d77de738
ML
32577Set the instruction scheduling parameters for machine type @var{cpu_type},
32578but do not set the instruction set or register set that the option
32579@option{-mcpu=@var{cpu_type}} would.
32580
d77de738 32581@opindex msv-mode
ddf6fe37 32582@item -msv-mode
d77de738
ML
32583Generate code for the supervisor mode, where there are no restrictions on
32584the access to general registers. This is the default.
32585
d77de738 32586@opindex muser-mode
ddf6fe37 32587@item -muser-mode
d77de738
ML
32588Generate code for the user mode, where the access to some general registers
32589is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32590mode; on the GR6, only registers r29 to r31 are affected.
32591@end table
32592
32593@node VMS Options
32594@subsection VMS Options
32595
32596These @samp{-m} options are defined for the VMS implementations:
32597
32598@table @gcctabopt
d77de738 32599@opindex mvms-return-codes
ddf6fe37 32600@item -mvms-return-codes
d77de738
ML
32601Return VMS condition codes from @code{main}. The default is to return POSIX-style
32602condition (e.g.@: error) codes.
32603
d77de738 32604@opindex mdebug-main=@var{prefix}
ddf6fe37 32605@item -mdebug-main=@var{prefix}
d77de738
ML
32606Flag the first routine whose name starts with @var{prefix} as the main
32607routine for the debugger.
32608
d77de738 32609@opindex mmalloc64
ddf6fe37 32610@item -mmalloc64
d77de738
ML
32611Default to 64-bit memory allocation routines.
32612
d77de738 32613@opindex mpointer-size=@var{size}
ddf6fe37 32614@item -mpointer-size=@var{size}
d77de738
ML
32615Set the default size of pointers. Possible options for @var{size} are
32616@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32617for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32618The later option disables @code{pragma pointer_size}.
32619@end table
32620
32621@node VxWorks Options
32622@subsection VxWorks Options
32623@cindex VxWorks Options
32624
32625The options in this section are defined for all VxWorks targets.
32626Options specific to the target hardware are listed with the other
32627options for that target.
32628
32629@table @gcctabopt
d77de738 32630@opindex mrtp
ddf6fe37 32631@item -mrtp
d77de738
ML
32632GCC can generate code for both VxWorks kernels and real time processes
32633(RTPs). This option switches from the former to the latter. It also
32634defines the preprocessor macro @code{__RTP__}.
32635
b6f4b000
AO
32636@opindex msmp
32637@item -msmp
32638Select SMP runtimes for linking. Not available on architectures other
32639than PowerPC, nor on VxWorks version 7 or later, in which the selection
32640is part of the VxWorks build configuration and the library paths are the
32641same for either choice.
32642
d77de738 32643@opindex non-static
ddf6fe37 32644@item -non-static
d77de738
ML
32645Link an RTP executable against shared libraries rather than static
32646libraries. The options @option{-static} and @option{-shared} can
32647also be used for RTPs (@pxref{Link Options}); @option{-static}
32648is the default.
32649
d77de738
ML
32650@opindex Bstatic
32651@opindex Bdynamic
ddf6fe37
AA
32652@item -Bstatic
32653@itemx -Bdynamic
d77de738
ML
32654These options are passed down to the linker. They are defined for
32655compatibility with Diab.
32656
d77de738 32657@opindex Xbind-lazy
ddf6fe37 32658@item -Xbind-lazy
d77de738
ML
32659Enable lazy binding of function calls. This option is equivalent to
32660@option{-Wl,-z,now} and is defined for compatibility with Diab.
32661
d77de738 32662@opindex Xbind-now
ddf6fe37 32663@item -Xbind-now
d77de738
ML
32664Disable lazy binding of function calls. This option is the default and
32665is defined for compatibility with Diab.
32666@end table
32667
32668@node x86 Options
32669@subsection x86 Options
32670@cindex x86 Options
32671
32672These @samp{-m} options are defined for the x86 family of computers.
32673
32674@table @gcctabopt
32675
d77de738 32676@opindex march
ddf6fe37 32677@item -march=@var{cpu-type}
d77de738
ML
32678Generate instructions for the machine type @var{cpu-type}. In contrast to
32679@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32680for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32681to generate code that may not run at all on processors other than the one
32682indicated. Specifying @option{-march=@var{cpu-type}} implies
32683@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32684
32685The choices for @var{cpu-type} are:
32686
32687@table @samp
32688@item native
32689This selects the CPU to generate code for at compilation time by determining
32690the processor type of the compiling machine. Using @option{-march=native}
32691enables all instruction subsets supported by the local machine (hence
32692the result might not run on different machines). Using @option{-mtune=native}
32693produces code optimized for the local machine under the constraints
32694of the selected instruction set.
32695
32696@item x86-64
32697A generic CPU with 64-bit extensions.
32698
32699@item x86-64-v2
32700@itemx x86-64-v3
32701@itemx x86-64-v4
32702These choices for @var{cpu-type} select the corresponding
32703micro-architecture level from the x86-64 psABI. On ABIs other than
32704the x86-64 psABI they select the same CPU features as the x86-64 psABI
32705documents for the particular micro-architecture level.
32706
32707Since these @var{cpu-type} values do not have a corresponding
32708@option{-mtune} setting, using @option{-march} with these values enables
32709generic tuning. Specific tuning can be enabled using the
32710@option{-mtune=@var{other-cpu-type}} option with an appropriate
32711@var{other-cpu-type} value.
32712
32713@item i386
32714Original Intel i386 CPU@.
32715
32716@item i486
32717Intel i486 CPU@. (No scheduling is implemented for this chip.)
32718
32719@item i586
32720@itemx pentium
32721Intel Pentium CPU with no MMX support.
32722
32723@item lakemont
32724Intel Lakemont MCU, based on Intel Pentium CPU.
32725
32726@item pentium-mmx
32727Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32728
32729@item pentiumpro
32730Intel Pentium Pro CPU@.
32731
32732@item i686
32733When used with @option{-march}, the Pentium Pro
32734instruction set is used, so the code runs on all i686 family chips.
32735When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32736
32737@item pentium2
32738Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32739set support.
32740
32741@item pentium3
32742@itemx pentium3m
32743Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32744instruction set support.
32745
32746@item pentium-m
32747Intel Pentium M; low-power version of Intel Pentium III CPU
32748with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32749notebooks.
32750
32751@item pentium4
32752@itemx pentium4m
32753Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32754
32755@item prescott
32756Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32757instruction set support.
32758
32759@item nocona
32760Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32761SSE2, SSE3 and FXSR instruction set support.
32762
32763@item core2
32764Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32765SAHF and FXSR instruction set support.
32766
32767@item nehalem
32768Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32769SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32770
32771@item westmere
32772Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32773SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32774
32775@item sandybridge
32776Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32777SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32778support.
32779
32780@item ivybridge
32781Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32782SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32783and F16C instruction set support.
32784
32785@item haswell
32786Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32787SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32788F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32789
32790@item broadwell
32791Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32792SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32793F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32794instruction set support.
32795
32796@item skylake
32797Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32798SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32799F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32800CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32801
32802@item bonnell
32803Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32804instruction set support.
32805
32806@item silvermont
32807Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32808SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32809instruction set support.
32810
32811@item goldmont
32812Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32813SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32814RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32815set support.
32816
32817@item goldmont-plus
32818Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32819SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32820SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32821RDPID and SGX instruction set support.
32822
32823@item tremont
32824Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32825SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32826RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32827SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32828support.
32829
32830@item sierraforest
32831Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32832SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32833XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32834MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32835PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
32836AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
32837support.
d77de738
ML
32838
32839@item grandridge
32840Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32841SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32842XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32843MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32844PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
32845AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT
32846instruction set support.
d77de738 32847
a5088dc3
MZ
32848@item arrowlake
32849Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32850SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32851XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32852MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32853PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32854AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32855
32856@item arrowlake-s
32857Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32858SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32859XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32860MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32861PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32862AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3
32863and SM4 instruction set support.
32864
7370c479
HJ
32865@item clearwaterforest
32866Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32867SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
32868XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
32869MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
32870LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32871AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4,
32872USER_MSR and PREFETCHI instruction set support.
32873
f019251a
HJ
32874@item pantherlake
32875Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32876SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32877XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32878MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32879PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32880AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4
32881and PREFETCHI instruction set support.
32882
d77de738
ML
32883@item knl
32884Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32885SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32886RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32887AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32888
32889@item knm
32890Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32891SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32892RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32893AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32894AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32895
32896@item skylake-avx512
32897Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32898SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32899RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32900AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32901AVX512DQ and AVX512CD instruction set support.
32902
32903@item cannonlake
32904Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32905SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32906FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32907PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32908AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32909support.
32910
32911@item icelake-client
32912Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32913SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32914RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32915AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32916AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32917, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32918
32919@item icelake-server
32920Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32921SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32922RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32923AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32924AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32925, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32926instruction set support.
32927
32928@item cascadelake
32929Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32930SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32931F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32932CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32933AVX512CD and AVX512VNNI instruction set support.
32934
32935@item cooperlake
32936Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32937SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32938F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32939CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32940AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32941
32942@item tigerlake
32943Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32944SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32945F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32946CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32947PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32948VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32949AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32950
32951@item sapphirerapids
32952Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32953SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32954RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32955AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32956AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32957VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32958MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 32959UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
32960instruction set support.
32961
32962@item alderlake
32963Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32964SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32965XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32966CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32967VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32968support.
32969
32970@item rocketlake
32971Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32972, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32973F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32974CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32975PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32976VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32977
32978@item graniterapids
32979Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32980SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32981RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32982AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32983AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32984VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
32985MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32986UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
32987and PREFETCHI instruction set support.
d77de738 32988
a0cb65d3
MZ
32989@item graniterapids-d
32990Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32991SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32992RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32993AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32994AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32995VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
32996MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32997UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
32998PREFETCHI and AMX-COMPLEX instruction set support.
a0cb65d3 32999
d77de738
ML
33000@item k6
33001AMD K6 CPU with MMX instruction set support.
33002
33003@item k6-2
33004@itemx k6-3
33005Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
33006
33007@item athlon
33008@itemx athlon-tbird
33009AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
33010support.
33011
33012@item athlon-4
33013@itemx athlon-xp
33014@itemx athlon-mp
33015Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
33016instruction set support.
33017
33018@item k8
33019@itemx opteron
33020@itemx athlon64
33021@itemx athlon-fx
33022Processors based on the AMD K8 core with x86-64 instruction set support,
33023including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
33024(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
33025instruction set extensions.)
33026
33027@item k8-sse3
33028@itemx opteron-sse3
33029@itemx athlon64-sse3
33030Improved versions of AMD K8 cores with SSE3 instruction set support.
33031
33032@item amdfam10
33033@itemx barcelona
33034CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
33035supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
33036instruction set extensions.)
33037
33038@item bdver1
33039CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
33040supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
33041SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
33042
33043@item bdver2
33044AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33045supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
33046SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
33047extensions.)
33048
33049@item bdver3
33050AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33051supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
33052PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3305364-bit instruction set extensions.)
33054
33055@item bdver4
33056AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33057supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
33058AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
33059SSE4.2, ABM and 64-bit instruction set extensions.)
33060
33061@item znver1
33062AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33063supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
33064SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
33065SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
33066instruction set extensions.)
33067
33068@item znver2
33069AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33070supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33071MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33072SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33073WBNOINVD, and 64-bit instruction set extensions.)
33074
33075@item znver3
33076AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33077supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33078MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33079SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33080WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
33081
33082@item znver4
33083AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33084supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33085MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33086SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33087WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
33088AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
33089AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
33090
33091@item btver1
33092CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
33093supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
33094instruction set extensions.)
33095
33096@item btver2
33097CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
33098includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
33099SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
33100
33101@item winchip-c6
33102IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
33103set support.
33104
33105@item winchip2
33106IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
33107instruction set support.
33108
33109@item c3
33110VIA C3 CPU with MMX and 3DNow!@: instruction set support.
33111(No scheduling is implemented for this chip.)
33112
33113@item c3-2
33114VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
33115(No scheduling is implemented for this chip.)
33116
33117@item c7
33118VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33119(No scheduling is implemented for this chip.)
33120
33121@item samuel-2
33122VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
33123(No scheduling is implemented for this chip.)
33124
33125@item nehemiah
33126VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
33127(No scheduling is implemented for this chip.)
33128
33129@item esther
33130VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33131(No scheduling is implemented for this chip.)
33132
33133@item eden-x2
33134VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
33135(No scheduling is implemented for this chip.)
33136
33137@item eden-x4
33138VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
33139AVX and AVX2 instruction set support.
33140(No scheduling is implemented for this chip.)
33141
33142@item nano
33143Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33144instruction set support.
33145(No scheduling is implemented for this chip.)
33146
33147@item nano-1000
33148VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33149instruction set support.
33150(No scheduling is implemented for this chip.)
33151
33152@item nano-2000
33153VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33154instruction set support.
33155(No scheduling is implemented for this chip.)
33156
33157@item nano-3000
33158VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33159instruction set support.
33160(No scheduling is implemented for this chip.)
33161
33162@item nano-x2
33163VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33164instruction set support.
33165(No scheduling is implemented for this chip.)
33166
33167@item nano-x4
33168VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33169instruction set support.
33170(No scheduling is implemented for this chip.)
33171
33172@item lujiazui
33173ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
33174SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
33175ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
33176
33177@item geode
33178AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
33179@end table
33180
d77de738 33181@opindex mtune
ddf6fe37 33182@item -mtune=@var{cpu-type}
d77de738
ML
33183Tune to @var{cpu-type} everything applicable about the generated code, except
33184for the ABI and the set of available instructions.
33185While picking a specific @var{cpu-type} schedules things appropriately
33186for that particular chip, the compiler does not generate any code that
33187cannot run on the default machine type unless you use a
33188@option{-march=@var{cpu-type}} option.
33189For example, if GCC is configured for i686-pc-linux-gnu
33190then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
33191but still runs on i686 machines.
33192
33193The choices for @var{cpu-type} are the same as for @option{-march}.
33194In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
33195
33196@table @samp
33197@item generic
33198Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
33199If you know the CPU on which your code will run, then you should use
33200the corresponding @option{-mtune} or @option{-march} option instead of
33201@option{-mtune=generic}. But, if you do not know exactly what CPU users
33202of your application will have, then you should use this option.
33203
33204As new processors are deployed in the marketplace, the behavior of this
33205option will change. Therefore, if you upgrade to a newer version of
33206GCC, code generation controlled by this option will change to reflect
33207the processors
33208that are most common at the time that version of GCC is released.
33209
33210There is no @option{-march=generic} option because @option{-march}
33211indicates the instruction set the compiler can use, and there is no
33212generic instruction set applicable to all processors. In contrast,
33213@option{-mtune} indicates the processor (or, in this case, collection of
33214processors) for which the code is optimized.
33215
33216@item intel
33217Produce code optimized for the most current Intel processors, which are
33218Haswell and Silvermont for this version of GCC. If you know the CPU
33219on which your code will run, then you should use the corresponding
33220@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
33221But, if you want your application performs better on both Haswell and
33222Silvermont, then you should use this option.
33223
33224As new Intel processors are deployed in the marketplace, the behavior of
33225this option will change. Therefore, if you upgrade to a newer version of
33226GCC, code generation controlled by this option will change to reflect
33227the most current Intel processors at the time that version of GCC is
33228released.
33229
33230There is no @option{-march=intel} option because @option{-march} indicates
33231the instruction set the compiler can use, and there is no common
33232instruction set applicable to all processors. In contrast,
33233@option{-mtune} indicates the processor (or, in this case, collection of
33234processors) for which the code is optimized.
33235@end table
33236
d77de738 33237@opindex mcpu
ddf6fe37 33238@item -mcpu=@var{cpu-type}
d77de738
ML
33239A deprecated synonym for @option{-mtune}.
33240
d77de738 33241@opindex mfpmath
ddf6fe37 33242@item -mfpmath=@var{unit}
d77de738
ML
33243Generate floating-point arithmetic for selected unit @var{unit}. The choices
33244for @var{unit} are:
33245
33246@table @samp
33247@item 387
33248Use the standard 387 floating-point coprocessor present on the majority of chips and
33249emulated otherwise. Code compiled with this option runs almost everywhere.
33250The temporary results are computed in 80-bit precision instead of the precision
33251specified by the type, resulting in slightly different results compared to most
33252of other chips. See @option{-ffloat-store} for more detailed description.
33253
33254This is the default choice for non-Darwin x86-32 targets.
33255
33256@item sse
33257Use scalar floating-point instructions present in the SSE instruction set.
33258This instruction set is supported by Pentium III and newer chips,
33259and in the AMD line
33260by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
33261instruction set supports only single-precision arithmetic, thus the double and
33262extended-precision arithmetic are still done using 387. A later version, present
33263only in Pentium 4 and AMD x86-64 chips, supports double-precision
33264arithmetic too.
33265
33266For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
33267or @option{-msse2} switches to enable SSE extensions and make this option
33268effective. For the x86-64 compiler, these extensions are enabled by default.
33269
33270The resulting code should be considerably faster in the majority of cases and avoid
33271the numerical instability problems of 387 code, but may break some existing
33272code that expects temporaries to be 80 bits.
33273
33274This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
33275and the default choice for x86-32 targets with the SSE2 instruction set
33276when @option{-ffast-math} is enabled.
33277
33278@item sse,387
33279@itemx sse+387
33280@itemx both
33281Attempt to utilize both instruction sets at once. This effectively doubles the
33282amount of available registers, and on chips with separate execution units for
33283387 and SSE the execution resources too. Use this option with care, as it is
33284still experimental, because the GCC register allocator does not model separate
33285functional units well, resulting in unstable performance.
33286@end table
33287
d77de738 33288@opindex masm=@var{dialect}
ddf6fe37 33289@item -masm=@var{dialect}
d77de738
ML
33290Output assembly instructions using selected @var{dialect}. Also affects
33291which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
33292extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
33293order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
33294not support @samp{intel}.
33295
d77de738
ML
33296@opindex mieee-fp
33297@opindex mno-ieee-fp
ddf6fe37
AA
33298@item -mieee-fp
33299@itemx -mno-ieee-fp
d77de738
ML
33300Control whether or not the compiler uses IEEE floating-point
33301comparisons. These correctly handle the case where the result of a
33302comparison is unordered.
33303
30348d30 33304@opindex m80387
d77de738 33305@opindex mhard-float
ddf6fe37
AA
33306@item -m80387
33307@itemx -mhard-float
d77de738
ML
33308Generate output containing 80387 instructions for floating point.
33309
d77de738
ML
33310@opindex no-80387
33311@opindex msoft-float
ddf6fe37
AA
33312@item -mno-80387
33313@itemx -msoft-float
d77de738
ML
33314Generate output containing library calls for floating point.
33315
33316@strong{Warning:} the requisite libraries are not part of GCC@.
33317Normally the facilities of the machine's usual C compiler are used, but
33318this cannot be done directly in cross-compilation. You must make your
33319own arrangements to provide suitable library functions for
33320cross-compilation.
33321
33322On machines where a function returns floating-point results in the 80387
33323register stack, some floating-point opcodes may be emitted even if
33324@option{-msoft-float} is used.
33325
d77de738
ML
33326@opindex mno-fp-ret-in-387
33327@opindex mfp-ret-in-387
ddf6fe37 33328@item -mno-fp-ret-in-387
d77de738
ML
33329Do not use the FPU registers for return values of functions.
33330
33331The usual calling convention has functions return values of types
33332@code{float} and @code{double} in an FPU register, even if there
33333is no FPU@. The idea is that the operating system should emulate
33334an FPU@.
33335
33336The option @option{-mno-fp-ret-in-387} causes such values to be returned
33337in ordinary CPU registers instead.
33338
d77de738
ML
33339@opindex mno-fancy-math-387
33340@opindex mfancy-math-387
ddf6fe37 33341@item -mno-fancy-math-387
d77de738
ML
33342Some 387 emulators do not support the @code{sin}, @code{cos} and
33343@code{sqrt} instructions for the 387. Specify this option to avoid
33344generating those instructions.
33345This option is overridden when @option{-march}
33346indicates that the target CPU always has an FPU and so the
33347instruction does not need emulation. These
33348instructions are not generated unless you also use the
33349@option{-funsafe-math-optimizations} switch.
33350
d77de738
ML
33351@opindex malign-double
33352@opindex mno-align-double
ddf6fe37
AA
33353@item -malign-double
33354@itemx -mno-align-double
d77de738
ML
33355Control whether GCC aligns @code{double}, @code{long double}, and
33356@code{long long} variables on a two-word boundary or a one-word
33357boundary. Aligning @code{double} variables on a two-word boundary
33358produces code that runs somewhat faster on a Pentium at the
33359expense of more memory.
33360
33361On x86-64, @option{-malign-double} is enabled by default.
33362
33363@strong{Warning:} if you use the @option{-malign-double} switch,
33364structures containing the above types are aligned differently than
33365the published application binary interface specifications for the x86-32
33366and are not binary compatible with structures in code compiled
33367without that switch.
33368
d77de738
ML
33369@opindex m96bit-long-double
33370@opindex m128bit-long-double
ddf6fe37
AA
33371@item -m96bit-long-double
33372@itemx -m128bit-long-double
d77de738
ML
33373These switches control the size of @code{long double} type. The x86-32
33374application binary interface specifies the size to be 96 bits,
33375so @option{-m96bit-long-double} is the default in 32-bit mode.
33376
33377Modern architectures (Pentium and newer) prefer @code{long double}
33378to be aligned to an 8- or 16-byte boundary. In arrays or structures
33379conforming to the ABI, this is not possible. So specifying
33380@option{-m128bit-long-double} aligns @code{long double}
33381to a 16-byte boundary by padding the @code{long double} with an additional
3338232-bit zero.
33383
33384In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
33385its ABI specifies that @code{long double} is aligned on 16-byte boundary.
33386
33387Notice that neither of these options enable any extra precision over the x87
33388standard of 80 bits for a @code{long double}.
33389
33390@strong{Warning:} if you override the default value for your target ABI, this
33391changes the size of
33392structures and arrays containing @code{long double} variables,
33393as well as modifying the function calling convention for functions taking
33394@code{long double}. Hence they are not binary-compatible
33395with code compiled without that switch.
33396
d77de738
ML
33397@opindex mlong-double-64
33398@opindex mlong-double-80
33399@opindex mlong-double-128
ddf6fe37
AA
33400@item -mlong-double-64
33401@itemx -mlong-double-80
33402@itemx -mlong-double-128
d77de738
ML
33403These switches control the size of @code{long double} type. A size
33404of 64 bits makes the @code{long double} type equivalent to the @code{double}
33405type. This is the default for 32-bit Bionic C library. A size
33406of 128 bits makes the @code{long double} type equivalent to the
33407@code{__float128} type. This is the default for 64-bit Bionic C library.
33408
33409@strong{Warning:} if you override the default value for your target ABI, this
33410changes the size of
33411structures and arrays containing @code{long double} variables,
33412as well as modifying the function calling convention for functions taking
33413@code{long double}. Hence they are not binary-compatible
33414with code compiled without that switch.
33415
d77de738 33416@opindex malign-data
ddf6fe37 33417@item -malign-data=@var{type}
d77de738
ML
33418Control how GCC aligns variables. Supported values for @var{type} are
33419@samp{compat} uses increased alignment value compatible uses GCC 4.8
33420and earlier, @samp{abi} uses alignment value as specified by the
33421psABI, and @samp{cacheline} uses increased alignment value to match
33422the cache line size. @samp{compat} is the default.
33423
d77de738 33424@opindex mlarge-data-threshold
ddf6fe37 33425@item -mlarge-data-threshold=@var{threshold}
1a64156c
UB
33426When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
33427objects larger than @var{threshold} are placed in large data sections. The
33428default is 65535.
d77de738 33429
d77de738 33430@opindex mrtd
ddf6fe37 33431@item -mrtd
d77de738
ML
33432Use a different function-calling convention, in which functions that
33433take a fixed number of arguments return with the @code{ret @var{num}}
33434instruction, which pops their arguments while returning. This saves one
33435instruction in the caller since there is no need to pop the arguments
33436there.
33437
33438You can specify that an individual function is called with this calling
33439sequence with the function attribute @code{stdcall}. You can also
33440override the @option{-mrtd} option by using the function attribute
33441@code{cdecl}. @xref{Function Attributes}.
33442
33443@strong{Warning:} this calling convention is incompatible with the one
33444normally used on Unix, so you cannot use it if you need to call
33445libraries compiled with the Unix compiler.
33446
33447Also, you must provide function prototypes for all functions that
33448take variable numbers of arguments (including @code{printf});
33449otherwise incorrect code is generated for calls to those
33450functions.
33451
33452In addition, seriously incorrect code results if you call a
33453function with too many arguments. (Normally, extra arguments are
33454harmlessly ignored.)
33455
d77de738 33456@opindex mregparm
ddf6fe37 33457@item -mregparm=@var{num}
d77de738
ML
33458Control how many registers are used to pass integer arguments. By
33459default, no registers are used to pass arguments, and at most 3
33460registers can be used. You can control this behavior for a specific
33461function by using the function attribute @code{regparm}.
33462@xref{Function Attributes}.
33463
33464@strong{Warning:} if you use this switch, and
33465@var{num} is nonzero, then you must build all modules with the same
33466value, including any libraries. This includes the system libraries and
33467startup modules.
33468
d77de738 33469@opindex msseregparm
ddf6fe37 33470@item -msseregparm
d77de738
ML
33471Use SSE register passing conventions for float and double arguments
33472and return values. You can control this behavior for a specific
33473function by using the function attribute @code{sseregparm}.
33474@xref{Function Attributes}.
33475
33476@strong{Warning:} if you use this switch then you must build all
33477modules with the same value, including any libraries. This includes
33478the system libraries and startup modules.
33479
d77de738 33480@opindex mvect8-ret-in-mem
ddf6fe37 33481@item -mvect8-ret-in-mem
d77de738
ML
33482Return 8-byte vectors in memory instead of MMX registers. This is the
33483default on VxWorks to match the ABI of the Sun Studio compilers until
33484version 12. @emph{Only} use this option if you need to remain
33485compatible with existing code produced by those previous compiler
33486versions or older versions of GCC@.
33487
d77de738
ML
33488@opindex mpc32
33489@opindex mpc64
33490@opindex mpc80
ddf6fe37
AA
33491@item -mpc32
33492@itemx -mpc64
33493@itemx -mpc80
d77de738
ML
33494
33495Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
33496is specified, the significands of results of floating-point operations are
33497rounded to 24 bits (single precision); @option{-mpc64} rounds the
33498significands of results of floating-point operations to 53 bits (double
33499precision) and @option{-mpc80} rounds the significands of results of
33500floating-point operations to 64 bits (extended double precision), which is
33501the default. When this option is used, floating-point operations in higher
33502precisions are not available to the programmer without setting the FPU
33503control word explicitly.
33504
33505Setting the rounding of floating-point operations to less than the default
3350680 bits can speed some programs by 2% or more. Note that some mathematical
33507libraries assume that extended-precision (80-bit) floating-point operations
33508are enabled by default; routines in such libraries could suffer significant
33509loss of accuracy, typically through so-called ``catastrophic cancellation'',
33510when this option is used to set the precision to less than extended precision.
33511
e54375d8 33512@opindex mdaz-ftz
ddf6fe37 33513@item -mdaz-ftz
e54375d8 33514
33515The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
33516are used to control floating-point calculations.SSE and AVX instructions
33517including scalar and vector instructions could benefit from enabling the FTZ
33518and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33519when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33520will set FTZ/DAZ flags even with @option{-shared}.
33521
d77de738 33522@opindex mstackrealign
ddf6fe37 33523@item -mstackrealign
d77de738
ML
33524Realign the stack at entry. On the x86, the @option{-mstackrealign}
33525option generates an alternate prologue and epilogue that realigns the
33526run-time stack if necessary. This supports mixing legacy codes that keep
335274-byte stack alignment with modern codes that keep 16-byte stack alignment for
33528SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33529applicable to individual functions.
33530
d77de738 33531@opindex mpreferred-stack-boundary
ddf6fe37 33532@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33533Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33534byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33535the default is 4 (16 bytes or 128 bits).
33536
33537@strong{Warning:} When generating code for the x86-64 architecture with
33538SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33539used to keep the stack boundary aligned to 8 byte boundary. Since
33540x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33541intended to be used in controlled environment where stack space is
33542important limitation. This option leads to wrong code when functions
33543compiled with 16 byte stack alignment (such as functions from a standard
33544library) are called with misaligned stack. In this case, SSE
33545instructions may lead to misaligned memory access traps. In addition,
33546variable arguments are handled incorrectly for 16 byte aligned
33547objects (including x87 long double and __int128), leading to wrong
33548results. You must build all modules with
33549@option{-mpreferred-stack-boundary=3}, including any libraries. This
33550includes the system libraries and startup modules.
33551
d77de738 33552@opindex mincoming-stack-boundary
ddf6fe37 33553@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33554Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33555boundary. If @option{-mincoming-stack-boundary} is not specified,
33556the one specified by @option{-mpreferred-stack-boundary} is used.
33557
33558On Pentium and Pentium Pro, @code{double} and @code{long double} values
33559should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33560suffer significant run time performance penalties. On Pentium III, the
33561Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33562properly if it is not 16-byte aligned.
33563
33564To ensure proper alignment of this values on the stack, the stack boundary
33565must be as aligned as that required by any value stored on the stack.
33566Further, every function must be generated such that it keeps the stack
33567aligned. Thus calling a function compiled with a higher preferred
33568stack boundary from a function compiled with a lower preferred stack
33569boundary most likely misaligns the stack. It is recommended that
33570libraries that use callbacks always use the default setting.
33571
33572This extra alignment does consume extra stack space, and generally
33573increases code size. Code that is sensitive to stack space usage, such
33574as embedded systems and operating system kernels, may want to reduce the
33575preferred alignment to @option{-mpreferred-stack-boundary=2}.
33576
33577@need 200
d77de738 33578@opindex mmmx
ddf6fe37 33579@item -mmmx
d77de738 33580@need 200
d77de738 33581@opindex msse
ddf6fe37 33582@itemx -msse
d77de738 33583@need 200
d77de738 33584@opindex msse2
ddf6fe37 33585@itemx -msse2
d77de738 33586@need 200
d77de738 33587@opindex msse3
ddf6fe37 33588@itemx -msse3
d77de738 33589@need 200
d77de738 33590@opindex mssse3
ddf6fe37 33591@itemx -mssse3
d77de738 33592@need 200
d77de738 33593@opindex msse4
ddf6fe37 33594@itemx -msse4
d77de738 33595@need 200
d77de738 33596@opindex msse4a
ddf6fe37 33597@itemx -msse4a
d77de738 33598@need 200
d77de738 33599@opindex msse4.1
ddf6fe37 33600@itemx -msse4.1
d77de738 33601@need 200
d77de738 33602@opindex msse4.2
ddf6fe37 33603@itemx -msse4.2
d77de738 33604@need 200
d77de738 33605@opindex mavx
ddf6fe37 33606@itemx -mavx
d77de738 33607@need 200
d77de738 33608@opindex mavx2
ddf6fe37 33609@itemx -mavx2
d77de738 33610@need 200
d77de738 33611@opindex mavx512f
ddf6fe37 33612@itemx -mavx512f
d77de738 33613@need 200
d77de738 33614@opindex mavx512pf
ddf6fe37 33615@itemx -mavx512pf
d77de738 33616@need 200
d77de738 33617@opindex mavx512er
ddf6fe37 33618@itemx -mavx512er
d77de738 33619@need 200
d77de738 33620@opindex mavx512cd
ddf6fe37 33621@itemx -mavx512cd
d77de738 33622@need 200
d77de738 33623@opindex mavx512vl
ddf6fe37 33624@itemx -mavx512vl
d77de738 33625@need 200
d77de738 33626@opindex mavx512bw
ddf6fe37 33627@itemx -mavx512bw
d77de738 33628@need 200
d77de738 33629@opindex mavx512dq
ddf6fe37 33630@itemx -mavx512dq
d77de738 33631@need 200
d77de738 33632@opindex mavx512ifma
ddf6fe37 33633@itemx -mavx512ifma
d77de738 33634@need 200
d77de738 33635@opindex mavx512vbmi
ddf6fe37 33636@itemx -mavx512vbmi
d77de738 33637@need 200
d77de738 33638@opindex msha
ddf6fe37 33639@itemx -msha
d77de738 33640@need 200
d77de738 33641@opindex maes
ddf6fe37 33642@itemx -maes
d77de738 33643@need 200
d77de738 33644@opindex mpclmul
ddf6fe37 33645@itemx -mpclmul
d77de738 33646@need 200
d77de738 33647@opindex mclflushopt
ddf6fe37 33648@itemx -mclflushopt
d77de738 33649@need 200
d77de738 33650@opindex mclwb
ddf6fe37 33651@itemx -mclwb
d77de738 33652@need 200
d77de738 33653@opindex mfsgsbase
ddf6fe37 33654@itemx -mfsgsbase
d77de738 33655@need 200
d77de738 33656@opindex mptwrite
ddf6fe37 33657@itemx -mptwrite
d77de738 33658@need 200
d77de738 33659@opindex mrdrnd
ddf6fe37 33660@itemx -mrdrnd
d77de738 33661@need 200
d77de738 33662@opindex mf16c
ddf6fe37 33663@itemx -mf16c
d77de738 33664@need 200
d77de738 33665@opindex mfma
ddf6fe37 33666@itemx -mfma
d77de738 33667@need 200
d77de738 33668@opindex mpconfig
ddf6fe37 33669@itemx -mpconfig
d77de738 33670@need 200
d77de738 33671@opindex mwbnoinvd
ddf6fe37 33672@itemx -mwbnoinvd
d77de738 33673@need 200
d77de738 33674@opindex mfma4
ddf6fe37 33675@itemx -mfma4
d77de738 33676@need 200
d77de738 33677@opindex mprfchw
ddf6fe37 33678@itemx -mprfchw
d77de738 33679@need 200
d77de738 33680@opindex mrdpid
ddf6fe37 33681@itemx -mrdpid
d77de738 33682@need 200
d77de738 33683@opindex mprefetchwt1
ddf6fe37 33684@itemx -mprefetchwt1
d77de738 33685@need 200
d77de738 33686@opindex mrdseed
ddf6fe37 33687@itemx -mrdseed
d77de738 33688@need 200
d77de738 33689@opindex msgx
ddf6fe37 33690@itemx -msgx
d77de738 33691@need 200
d77de738 33692@opindex mxop
ddf6fe37 33693@itemx -mxop
d77de738 33694@need 200
d77de738 33695@opindex mlwp
ddf6fe37 33696@itemx -mlwp
d77de738 33697@need 200
d77de738 33698@opindex m3dnow
ddf6fe37 33699@itemx -m3dnow
d77de738 33700@need 200
d77de738 33701@opindex m3dnowa
ddf6fe37 33702@itemx -m3dnowa
d77de738 33703@need 200
d77de738 33704@opindex mpopcnt
ddf6fe37 33705@itemx -mpopcnt
d77de738 33706@need 200
d77de738 33707@opindex mabm
ddf6fe37 33708@itemx -mabm
d77de738 33709@need 200
d77de738 33710@opindex madx
ddf6fe37 33711@itemx -madx
d77de738 33712@need 200
d77de738 33713@opindex mbmi
ddf6fe37 33714@itemx -mbmi
d77de738 33715@need 200
d77de738 33716@opindex mbmi2
ddf6fe37 33717@itemx -mbmi2
d77de738 33718@need 200
d77de738 33719@opindex mlzcnt
ddf6fe37 33720@itemx -mlzcnt
d77de738 33721@need 200
d77de738 33722@opindex mfxsr
ddf6fe37 33723@itemx -mfxsr
d77de738 33724@need 200
d77de738 33725@opindex mxsave
ddf6fe37 33726@itemx -mxsave
d77de738 33727@need 200
d77de738 33728@opindex mxsaveopt
ddf6fe37 33729@itemx -mxsaveopt
d77de738 33730@need 200
d77de738 33731@opindex mxsavec
ddf6fe37 33732@itemx -mxsavec
d77de738 33733@need 200
d77de738 33734@opindex mxsaves
ddf6fe37 33735@itemx -mxsaves
d77de738 33736@need 200
d77de738 33737@opindex mrtm
ddf6fe37 33738@itemx -mrtm
d77de738 33739@need 200
d77de738 33740@opindex mhle
ddf6fe37 33741@itemx -mhle
d77de738 33742@need 200
d77de738 33743@opindex mtbm
ddf6fe37 33744@itemx -mtbm
d77de738 33745@need 200
d77de738 33746@opindex mmwaitx
ddf6fe37 33747@itemx -mmwaitx
d77de738 33748@need 200
d77de738 33749@opindex mclzero
ddf6fe37 33750@itemx -mclzero
d77de738 33751@need 200
d77de738 33752@opindex mpku
ddf6fe37 33753@itemx -mpku
d77de738 33754@need 200
d77de738 33755@opindex mavx512vbmi2
ddf6fe37 33756@itemx -mavx512vbmi2
d77de738 33757@need 200
d77de738 33758@opindex mavx512bf16
ddf6fe37 33759@itemx -mavx512bf16
d77de738 33760@need 200
d77de738 33761@opindex mavx512fp16
ddf6fe37 33762@itemx -mavx512fp16
d77de738 33763@need 200
d77de738 33764@opindex mgfni
ddf6fe37 33765@itemx -mgfni
d77de738 33766@need 200
d77de738 33767@opindex mvaes
ddf6fe37 33768@itemx -mvaes
d77de738 33769@need 200
d77de738 33770@opindex mwaitpkg
ddf6fe37 33771@itemx -mwaitpkg
d77de738 33772@need 200
d77de738 33773@opindex mvpclmulqdq
ddf6fe37 33774@itemx -mvpclmulqdq
d77de738 33775@need 200
d77de738 33776@opindex mavx512bitalg
ddf6fe37 33777@itemx -mavx512bitalg
d77de738 33778@need 200
d77de738 33779@opindex mmovdiri
ddf6fe37 33780@itemx -mmovdiri
d77de738 33781@need 200
d77de738 33782@opindex mmovdir64b
ddf6fe37 33783@itemx -mmovdir64b
d77de738 33784@need 200
d77de738 33785@opindex menqcmd
d77de738 33786@opindex muintr
ddf6fe37
AA
33787@itemx -menqcmd
33788@itemx -muintr
d77de738 33789@need 200
d77de738 33790@opindex mtsxldtrk
ddf6fe37 33791@itemx -mtsxldtrk
d77de738 33792@need 200
d77de738 33793@opindex mavx512vpopcntdq
ddf6fe37 33794@itemx -mavx512vpopcntdq
d77de738 33795@need 200
d77de738 33796@opindex mavx512vp2intersect
ddf6fe37 33797@itemx -mavx512vp2intersect
d77de738 33798@need 200
d77de738 33799@opindex mavx5124fmaps
ddf6fe37 33800@itemx -mavx5124fmaps
d77de738 33801@need 200
d77de738 33802@opindex mavx512vnni
ddf6fe37 33803@itemx -mavx512vnni
d77de738 33804@need 200
d77de738 33805@opindex mavxvnni
ddf6fe37 33806@itemx -mavxvnni
d77de738 33807@need 200
d77de738 33808@opindex mavx5124vnniw
ddf6fe37 33809@itemx -mavx5124vnniw
d77de738 33810@need 200
d77de738 33811@opindex mcldemote
ddf6fe37 33812@itemx -mcldemote
d77de738 33813@need 200
d77de738 33814@opindex mserialize
ddf6fe37 33815@itemx -mserialize
d77de738 33816@need 200
d77de738 33817@opindex mamx-tile
ddf6fe37 33818@itemx -mamx-tile
d77de738 33819@need 200
d77de738 33820@opindex mamx-int8
ddf6fe37 33821@itemx -mamx-int8
d77de738 33822@need 200
d77de738 33823@opindex mamx-bf16
ddf6fe37 33824@itemx -mamx-bf16
d77de738 33825@need 200
d77de738 33826@opindex mhreset
d77de738 33827@opindex mkl
ddf6fe37
AA
33828@itemx -mhreset
33829@itemx -mkl
d77de738 33830@need 200
d77de738 33831@opindex mwidekl
ddf6fe37 33832@itemx -mwidekl
d77de738 33833@need 200
d77de738 33834@opindex mavxifma
ddf6fe37 33835@itemx -mavxifma
d77de738 33836@need 200
d77de738 33837@opindex mavxvnniint8
ddf6fe37 33838@itemx -mavxvnniint8
d77de738 33839@need 200
d77de738 33840@opindex mavxneconvert
ddf6fe37 33841@itemx -mavxneconvert
d77de738 33842@need 200
d77de738 33843@opindex mcmpccxadd
ddf6fe37 33844@itemx -mcmpccxadd
d77de738 33845@need 200
d77de738 33846@opindex mamx-fp16
ddf6fe37 33847@itemx -mamx-fp16
d77de738 33848@need 200
d77de738 33849@opindex mprefetchi
ddf6fe37 33850@itemx -mprefetchi
d77de738 33851@need 200
d77de738 33852@opindex mraoint
ddf6fe37 33853@itemx -mraoint
efa6a82b
HJ
33854@need 200
33855@opindex mamx-complex
33856@itemx -mamx-complex
1dbc1081
KL
33857@need 200
33858@opindex mavxvnniint16
33859@itemx -mavxvnniint16
8643bcba
HJ
33860@need 200
33861@opindex msm3
33862@itemx -msm3
86446132
HJ
33863@need 200
33864@opindex msha512
33865@itemx -msha512
37bdeb8f
HJ
33866@need 200
33867@opindex msm4
33868@itemx -msm4
e686416b
KL
33869@need 200
33870@opindex mapxf
33871@itemx -mapxf
5fbd91b1
HL
33872@need 200
33873@opindex musermsr
33874@itemx -musermsr
d77de738 33875These switches enable the use of instructions in the MMX, SSE,
d77de738
ML
33876AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33877AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33878WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
338793DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33880XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33881GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33882ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 33883UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b 33884AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
5fbd91b1
HL
33885AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR or CLDEMOTE
33886extended instruction sets. Each has a corresponding @option{-mno-} option
33887to disable use of these instructions.
d77de738
ML
33888
33889These extensions are also available as built-in functions: see
33890@ref{x86 Built-in Functions}, for details of the functions enabled and
33891disabled by these switches.
33892
33893To generate SSE/SSE2 instructions automatically from floating-point
33894code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33895
33896GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33897generates new AVX instructions or AVX equivalence for all SSEx instructions
33898when needed.
33899
33900These options enable GCC to use these extended instructions in
33901generated code, even without @option{-mfpmath=sse}. Applications that
33902perform run-time CPU detection must compile separate files for each
33903supported architecture, using the appropriate flags. In particular,
33904the file containing the CPU detection code should be compiled without
33905these options.
33906
d77de738 33907@opindex mdump-tune-features
ddf6fe37 33908@item -mdump-tune-features
d77de738
ML
33909This option instructs GCC to dump the names of the x86 performance
33910tuning features and default settings. The names can be used in
33911@option{-mtune-ctrl=@var{feature-list}}.
33912
d77de738 33913@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 33914@item -mtune-ctrl=@var{feature-list}
d77de738
ML
33915This option is used to do fine grain control of x86 code generation features.
33916@var{feature-list} is a comma separated list of @var{feature} names. See also
33917@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33918on if it is not preceded with @samp{^}, otherwise, it is turned off.
33919@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33920developers. Using it may lead to code paths not covered by testing and can
33921potentially result in compiler ICEs or runtime errors.
33922
d77de738 33923@opindex mno-default
ddf6fe37 33924@item -mno-default
d77de738
ML
33925This option instructs GCC to turn off all tunable features. See also
33926@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33927
d77de738 33928@opindex mcld
ddf6fe37 33929@item -mcld
d77de738
ML
33930This option instructs GCC to emit a @code{cld} instruction in the prologue
33931of functions that use string instructions. String instructions depend on
33932the DF flag to select between autoincrement or autodecrement mode. While the
33933ABI specifies the DF flag to be cleared on function entry, some operating
33934systems violate this specification by not clearing the DF flag in their
33935exception dispatchers. The exception handler can be invoked with the DF flag
33936set, which leads to wrong direction mode when string instructions are used.
33937This option can be enabled by default on 32-bit x86 targets by configuring
33938GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33939instructions can be suppressed with the @option{-mno-cld} compiler option
33940in this case.
33941
d77de738 33942@opindex mvzeroupper
ddf6fe37 33943@item -mvzeroupper
d77de738
ML
33944This option instructs GCC to emit a @code{vzeroupper} instruction
33945before a transfer of control flow out of the function to minimize
33946the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33947intrinsics.
33948
d77de738 33949@opindex mprefer-avx128
ddf6fe37 33950@item -mprefer-avx128
d77de738
ML
33951This option instructs GCC to use 128-bit AVX instructions instead of
33952256-bit AVX instructions in the auto-vectorizer.
33953
d77de738 33954@opindex mprefer-vector-width
ddf6fe37 33955@item -mprefer-vector-width=@var{opt}
d77de738
ML
33956This option instructs GCC to use @var{opt}-bit vector width in instructions
33957instead of default on the selected platform.
33958
ad5b757d
UB
33959@opindex mpartial-vector-fp-math
33960@item -mpartial-vector-fp-math
33961This option enables GCC to generate floating-point operations that might
33962affect the set of floating-point status flags on partial vectors, where
33963vector elements reside in the low part of the 128-bit SSE register. Unless
33964@option{-fno-trapping-math} is specified, the compiler guarantees correct
33965behavior by sanitizing all input operands to have zeroes in the unused
33966upper part of the vector register. Note that by using built-in functions
33967or inline assembly with partial vector arguments, NaNs, denormal or invalid
33968values can leak into the upper part of the vector, causing possible
33969performance issues when @option{-fno-trapping-math} is in effect. These
33970issues can be mitigated by manually sanitizing the upper part of the partial
33971vector argument register or by using @option{-mdaz-ftz} to set
33972denormals-are-zero (DAZ) flag in the MXCSR register.
33973
33974This option is enabled by default.
33975
d77de738 33976@opindex mmove-max
ddf6fe37 33977@item -mmove-max=@var{bits}
d77de738
ML
33978This option instructs GCC to set the maximum number of bits can be
33979moved from memory to memory efficiently to @var{bits}. The valid
33980@var{bits} are 128, 256 and 512.
33981
d77de738 33982@opindex mstore-max
ddf6fe37 33983@item -mstore-max=@var{bits}
d77de738
ML
33984This option instructs GCC to set the maximum number of bits can be
33985stored to memory efficiently to @var{bits}. The valid @var{bits} are
33986128, 256 and 512.
33987
33988@table @samp
33989@item none
33990No extra limitations applied to GCC other than defined by the selected platform.
33991
33992@item 128
33993Prefer 128-bit vector width for instructions.
33994
33995@item 256
33996Prefer 256-bit vector width for instructions.
33997
33998@item 512
33999Prefer 512-bit vector width for instructions.
34000@end table
34001
d77de738 34002@opindex mcx16
ddf6fe37 34003@item -mcx16
d77de738
ML
34004This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
34005code to implement compare-and-exchange operations on 16-byte aligned 128-bit
34006objects. This is useful for atomic updates of data structures exceeding one
34007machine word in size. The compiler uses this instruction to implement
34008@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
34009128-bit integers, a library call is always used.
34010
d77de738 34011@opindex msahf
ddf6fe37 34012@item -msahf
d77de738
ML
34013This option enables generation of @code{SAHF} instructions in 64-bit code.
34014Early Intel Pentium 4 CPUs with Intel 64 support,
34015prior to the introduction of Pentium 4 G1 step in December 2005,
34016lacked the @code{LAHF} and @code{SAHF} instructions
34017which are supported by AMD64.
34018These are load and store instructions, respectively, for certain status flags.
34019In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
34020@code{drem}, and @code{remainder} built-in functions;
34021see @ref{Other Builtins} for details.
34022
d77de738 34023@opindex mmovbe
ddf6fe37 34024@item -mmovbe
d77de738
ML
34025This option enables use of the @code{movbe} instruction to implement
34026@code{__builtin_bswap32} and @code{__builtin_bswap64}.
34027
d77de738 34028@opindex mshstk
ddf6fe37 34029@item -mshstk
d77de738
ML
34030The @option{-mshstk} option enables shadow stack built-in functions
34031from x86 Control-flow Enforcement Technology (CET).
34032
d77de738 34033@opindex mcrc32
ddf6fe37 34034@item -mcrc32
d77de738
ML
34035This option enables built-in functions @code{__builtin_ia32_crc32qi},
34036@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
34037@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
34038
d77de738 34039@opindex mmwait
ddf6fe37 34040@item -mmwait
d77de738
ML
34041This option enables built-in functions @code{__builtin_ia32_monitor},
34042and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
34043@code{mwait} machine instructions.
34044
d77de738 34045@opindex mrecip
ddf6fe37 34046@item -mrecip
d77de738
ML
34047This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
34048(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
34049with an additional Newton-Raphson step
34050to increase precision instead of @code{DIVSS} and @code{SQRTSS}
34051(and their vectorized
34052variants) for single-precision floating-point arguments. These instructions
34053are generated only when @option{-funsafe-math-optimizations} is enabled
34054together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
34055Note that while the throughput of the sequence is higher than the throughput
34056of the non-reciprocal instruction, the precision of the sequence can be
34057decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
34058
34059Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
34060(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
34061combination), and doesn't need @option{-mrecip}.
34062
34063Also note that GCC emits the above sequence with additional Newton-Raphson step
34064for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
34065already with @option{-ffast-math} (or the above option combination), and
34066doesn't need @option{-mrecip}.
34067
d77de738 34068@opindex mrecip=opt
ddf6fe37 34069@item -mrecip=@var{opt}
d77de738
ML
34070This option controls which reciprocal estimate instructions
34071may be used. @var{opt} is a comma-separated list of options, which may
34072be preceded by a @samp{!} to invert the option:
34073
34074@table @samp
34075@item all
34076Enable all estimate instructions.
34077
34078@item default
34079Enable the default instructions, equivalent to @option{-mrecip}.
34080
34081@item none
34082Disable all estimate instructions, equivalent to @option{-mno-recip}.
34083
34084@item div
34085Enable the approximation for scalar division.
34086
34087@item vec-div
34088Enable the approximation for vectorized division.
34089
34090@item sqrt
34091Enable the approximation for scalar square root.
34092
34093@item vec-sqrt
34094Enable the approximation for vectorized square root.
34095@end table
34096
34097So, for example, @option{-mrecip=all,!sqrt} enables
34098all of the reciprocal approximations, except for square root.
34099
d77de738 34100@opindex mveclibabi
ddf6fe37 34101@item -mveclibabi=@var{type}
d77de738
ML
34102Specifies the ABI type to use for vectorizing intrinsics using an
34103external library. Supported values for @var{type} are @samp{svml}
34104for the Intel short
34105vector math library and @samp{acml} for the AMD math core library.
34106To use this option, both @option{-ftree-vectorize} and
34107@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
34108ABI-compatible library must be specified at link time.
34109
34110GCC currently emits calls to @code{vmldExp2},
34111@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
34112@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
34113@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
34114@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
34115@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
34116@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
34117@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
34118@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
34119@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
34120function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
34121@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
34122@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
34123@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
34124@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
34125when @option{-mveclibabi=acml} is used.
34126
d77de738 34127@opindex mabi
ddf6fe37 34128@item -mabi=@var{name}
d77de738
ML
34129Generate code for the specified calling convention. Permissible values
34130are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
34131@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
34132ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
34133You can control this behavior for specific functions by
34134using the function attributes @code{ms_abi} and @code{sysv_abi}.
34135@xref{Function Attributes}.
34136
d77de738 34137@opindex mforce-indirect-call
ddf6fe37 34138@item -mforce-indirect-call
d77de738
ML
34139Force all calls to functions to be indirect. This is useful
34140when using Intel Processor Trace where it generates more precise timing
34141information for function calls.
34142
d77de738 34143@opindex mmanual-endbr
ddf6fe37 34144@item -mmanual-endbr
d77de738
ML
34145Insert ENDBR instruction at function entry only via the @code{cf_check}
34146function attribute. This is useful when used with the option
34147@option{-fcf-protection=branch} to control ENDBR insertion at the
34148function entry.
34149
d77de738 34150@opindex mcet-switch
ddf6fe37 34151@item -mcet-switch
d77de738
ML
34152By default, CET instrumentation is turned off on switch statements that
34153use a jump table and indirect branch track is disabled. Since jump
34154tables are stored in read-only memory, this does not result in a direct
34155loss of hardening. But if the jump table index is attacker-controlled,
34156the indirect jump may not be constrained by CET. This option turns on
34157CET instrumentation to enable indirect branch track for switch statements
34158with jump tables which leads to the jump targets reachable via any indirect
34159jumps.
34160
d77de738
ML
34161@opindex mcall-ms2sysv-xlogues
34162@opindex mno-call-ms2sysv-xlogues
ddf6fe37 34163@item -mcall-ms2sysv-xlogues
d77de738
ML
34164Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
34165System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
34166default, the code for saving and restoring these registers is emitted inline,
34167resulting in fairly lengthy prologues and epilogues. Using
34168@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
34169use stubs in the static portion of libgcc to perform these saves and restores,
34170thus reducing function size at the cost of a few extra instructions.
34171
d77de738 34172@opindex mtls-dialect
ddf6fe37 34173@item -mtls-dialect=@var{type}
d77de738
ML
34174Generate code to access thread-local storage using the @samp{gnu} or
34175@samp{gnu2} conventions. @samp{gnu} is the conservative default;
34176@samp{gnu2} is more efficient, but it may add compile- and run-time
34177requirements that cannot be satisfied on all systems.
34178
d77de738
ML
34179@opindex mpush-args
34180@opindex mno-push-args
ddf6fe37
AA
34181@item -mpush-args
34182@itemx -mno-push-args
d77de738
ML
34183Use PUSH operations to store outgoing parameters. This method is shorter
34184and usually equally fast as method using SUB/MOV operations and is enabled
34185by default. In some cases disabling it may improve performance because of
34186improved scheduling and reduced dependencies.
34187
d77de738 34188@opindex maccumulate-outgoing-args
ddf6fe37 34189@item -maccumulate-outgoing-args
d77de738
ML
34190If enabled, the maximum amount of space required for outgoing arguments is
34191computed in the function prologue. This is faster on most modern CPUs
34192because of reduced dependencies, improved scheduling and reduced stack usage
34193when the preferred stack boundary is not equal to 2. The drawback is a notable
34194increase in code size. This switch implies @option{-mno-push-args}.
34195
d77de738 34196@opindex mthreads
ddf6fe37 34197@item -mthreads
d77de738
ML
34198Support thread-safe exception handling on MinGW. Programs that rely
34199on thread-safe exception handling must compile and link all code with the
34200@option{-mthreads} option. When compiling, @option{-mthreads} defines
34201@option{-D_MT}; when linking, it links in a special thread helper library
34202@option{-lmingwthrd} which cleans up per-thread exception-handling data.
34203
d77de738
ML
34204@opindex mms-bitfields
34205@opindex mno-ms-bitfields
ddf6fe37
AA
34206@item -mms-bitfields
34207@itemx -mno-ms-bitfields
d77de738
ML
34208
34209Enable/disable bit-field layout compatible with the native Microsoft
34210Windows compiler.
34211
34212If @code{packed} is used on a structure, or if bit-fields are used,
34213it may be that the Microsoft ABI lays out the structure differently
34214than the way GCC normally does. Particularly when moving packed
34215data between functions compiled with GCC and the native Microsoft compiler
34216(either via function call or as data in a file), it may be necessary to access
34217either format.
34218
34219This option is enabled by default for Microsoft Windows
34220targets. This behavior can also be controlled locally by use of variable
34221or type attributes. For more information, see @ref{x86 Variable Attributes}
34222and @ref{x86 Type Attributes}.
34223
34224The Microsoft structure layout algorithm is fairly simple with the exception
34225of the bit-field packing.
34226The padding and alignment of members of structures and whether a bit-field
34227can straddle a storage-unit boundary are determine by these rules:
34228
34229@enumerate
34230@item Structure members are stored sequentially in the order in which they are
34231declared: the first member has the lowest memory address and the last member
34232the highest.
34233
34234@item Every data object has an alignment requirement. The alignment requirement
34235for all data except structures, unions, and arrays is either the size of the
34236object or the current packing size (specified with either the
34237@code{aligned} attribute or the @code{pack} pragma),
34238whichever is less. For structures, unions, and arrays,
34239the alignment requirement is the largest alignment requirement of its members.
34240Every object is allocated an offset so that:
34241
34242@smallexample
34243offset % alignment_requirement == 0
34244@end smallexample
34245
34246@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
34247unit if the integral types are the same size and if the next bit-field fits
34248into the current allocation unit without crossing the boundary imposed by the
34249common alignment requirements of the bit-fields.
34250@end enumerate
34251
34252MSVC interprets zero-length bit-fields in the following ways:
34253
34254@enumerate
34255@item If a zero-length bit-field is inserted between two bit-fields that
34256are normally coalesced, the bit-fields are not coalesced.
34257
34258For example:
34259
34260@smallexample
34261struct
34262 @{
34263 unsigned long bf_1 : 12;
34264 unsigned long : 0;
34265 unsigned long bf_2 : 12;
34266 @} t1;
34267@end smallexample
34268
34269@noindent
34270The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
34271zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
34272
34273@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
34274alignment of the zero-length bit-field is greater than the member that follows it,
34275@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
34276
34277For example:
34278
34279@smallexample
34280struct
34281 @{
34282 char foo : 4;
34283 short : 0;
34284 char bar;
34285 @} t2;
34286
34287struct
34288 @{
34289 char foo : 4;
34290 short : 0;
34291 double bar;
34292 @} t3;
34293@end smallexample
34294
34295@noindent
34296For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
34297Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
34298bit-field does not affect the alignment of @code{bar} or, as a result, the size
34299of the structure.
34300
34301Taking this into account, it is important to note the following:
34302
34303@enumerate
34304@item If a zero-length bit-field follows a normal bit-field, the type of the
34305zero-length bit-field may affect the alignment of the structure as whole. For
34306example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
34307normal bit-field, and is of type short.
34308
34309@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
34310still affect the alignment of the structure:
34311
34312@smallexample
34313struct
34314 @{
34315 char foo : 6;
34316 long : 0;
34317 @} t4;
34318@end smallexample
34319
34320@noindent
34321Here, @code{t4} takes up 4 bytes.
34322@end enumerate
34323
34324@item Zero-length bit-fields following non-bit-field members are ignored:
34325
34326@smallexample
34327struct
34328 @{
34329 char foo;
34330 long : 0;
34331 char bar;
34332 @} t5;
34333@end smallexample
34334
34335@noindent
34336Here, @code{t5} takes up 2 bytes.
34337@end enumerate
34338
34339
d77de738
ML
34340@opindex mno-align-stringops
34341@opindex malign-stringops
ddf6fe37 34342@item -mno-align-stringops
d77de738
ML
34343Do not align the destination of inlined string operations. This switch reduces
34344code size and improves performance in case the destination is already aligned,
34345but GCC doesn't know about it.
34346
d77de738 34347@opindex minline-all-stringops
ddf6fe37 34348@item -minline-all-stringops
d77de738
ML
34349By default GCC inlines string operations only when the destination is
34350known to be aligned to least a 4-byte boundary.
34351This enables more inlining and increases code
34352size, but may improve performance of code that depends on fast
34353@code{memcpy} and @code{memset} for short lengths.
34354The option enables inline expansion of @code{strlen} for all
34355pointer alignments.
34356
d77de738 34357@opindex minline-stringops-dynamically
ddf6fe37 34358@item -minline-stringops-dynamically
d77de738
ML
34359For string operations of unknown size, use run-time checks with
34360inline code for small blocks and a library call for large blocks.
34361
d77de738 34362@opindex mstringop-strategy=@var{alg}
ddf6fe37 34363@item -mstringop-strategy=@var{alg}
d77de738
ML
34364Override the internal decision heuristic for the particular algorithm to use
34365for inlining string operations. The allowed values for @var{alg} are:
34366
34367@table @samp
34368@item rep_byte
34369@itemx rep_4byte
34370@itemx rep_8byte
34371Expand using i386 @code{rep} prefix of the specified size.
34372
34373@item byte_loop
34374@itemx loop
34375@itemx unrolled_loop
34376Expand into an inline loop.
34377
34378@item libcall
34379Always use a library call.
34380@end table
34381
d77de738 34382@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 34383@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
34384Override the internal decision heuristic to decide if @code{__builtin_memcpy}
34385should be inlined and what inline algorithm to use when the expected size
34386of the copy operation is known. @var{strategy}
34387is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
34388@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
34389the max byte size with which inline algorithm @var{alg} is allowed. For the last
34390triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
34391in the list must be specified in increasing order. The minimal byte size for
34392@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
34393preceding range.
34394
d77de738 34395@opindex mmemset-strategy=@var{strategy}
ddf6fe37 34396@item -mmemset-strategy=@var{strategy}
d77de738
ML
34397The option is similar to @option{-mmemcpy-strategy=} except that it is to control
34398@code{__builtin_memset} expansion.
34399
d77de738 34400@opindex momit-leaf-frame-pointer
ddf6fe37 34401@item -momit-leaf-frame-pointer
d77de738
ML
34402Don't keep the frame pointer in a register for leaf functions. This
34403avoids the instructions to save, set up, and restore frame pointers and
34404makes an extra register available in leaf functions. The option
34405@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
34406which might make debugging harder.
34407
ddf6fe37 34408@opindex mtls-direct-seg-refs
d77de738
ML
34409@item -mtls-direct-seg-refs
34410@itemx -mno-tls-direct-seg-refs
d77de738
ML
34411Controls whether TLS variables may be accessed with offsets from the
34412TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
34413or whether the thread base pointer must be added. Whether or not this
34414is valid depends on the operating system, and whether it maps the
34415segment to cover the entire TLS area.
34416
34417For systems that use the GNU C Library, the default is on.
34418
ddf6fe37 34419@opindex msse2avx
d77de738
ML
34420@item -msse2avx
34421@itemx -mno-sse2avx
d77de738
ML
34422Specify that the assembler should encode SSE instructions with VEX
34423prefix. The option @option{-mavx} turns this on by default.
34424
ddf6fe37 34425@opindex mfentry
d77de738
ML
34426@item -mfentry
34427@itemx -mno-fentry
d77de738
ML
34428If profiling is active (@option{-pg}), put the profiling
34429counter call before the prologue.
34430Note: On x86 architectures the attribute @code{ms_hook_prologue}
34431isn't possible at the moment for @option{-mfentry} and @option{-pg}.
34432
ddf6fe37 34433@opindex mrecord-mcount
d77de738
ML
34434@item -mrecord-mcount
34435@itemx -mno-record-mcount
d77de738
ML
34436If profiling is active (@option{-pg}), generate a __mcount_loc section
34437that contains pointers to each profiling call. This is useful for
34438automatically patching and out calls.
34439
ddf6fe37 34440@opindex mnop-mcount
d77de738
ML
34441@item -mnop-mcount
34442@itemx -mno-nop-mcount
d77de738
ML
34443If profiling is active (@option{-pg}), generate the calls to
34444the profiling functions as NOPs. This is useful when they
34445should be patched in later dynamically. This is likely only
34446useful together with @option{-mrecord-mcount}.
34447
d77de738 34448@opindex minstrument-return
ddf6fe37 34449@item -minstrument-return=@var{type}
d77de738
ML
34450Instrument function exit in -pg -mfentry instrumented functions with
34451call to specified function. This only instruments true returns ending
34452with ret, but not sibling calls ending with jump. Valid types
34453are @var{none} to not instrument, @var{call} to generate a call to __return__,
34454or @var{nop5} to generate a 5 byte nop.
34455
ddf6fe37 34456@opindex mrecord-return
d77de738
ML
34457@item -mrecord-return
34458@itemx -mno-record-return
d77de738
ML
34459Generate a __return_loc section pointing to all return instrumentation code.
34460
d77de738 34461@opindex mfentry-name
ddf6fe37 34462@item -mfentry-name=@var{name}
d77de738
ML
34463Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
34464
d77de738 34465@opindex mfentry-section
ddf6fe37 34466@item -mfentry-section=@var{name}
d77de738
ML
34467Set name of section to record -mrecord-mcount calls (default __mcount_loc).
34468
ddf6fe37 34469@opindex mskip-rax-setup
d77de738
ML
34470@item -mskip-rax-setup
34471@itemx -mno-skip-rax-setup
d77de738
ML
34472When generating code for the x86-64 architecture with SSE extensions
34473disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
34474register when there are no variable arguments passed in vector registers.
34475
34476@strong{Warning:} Since RAX register is used to avoid unnecessarily
34477saving vector registers on stack when passing variable arguments, the
34478impacts of this option are callees may waste some stack space,
34479misbehave or jump to a random location. GCC 4.4 or newer don't have
34480those issues, regardless the RAX register value.
34481
ddf6fe37 34482@opindex m8bit-idiv
d77de738
ML
34483@item -m8bit-idiv
34484@itemx -mno-8bit-idiv
d77de738
ML
34485On some processors, like Intel Atom, 8-bit unsigned integer divide is
34486much faster than 32-bit/64-bit integer divide. This option generates a
34487run-time check. If both dividend and divisor are within range of 0
34488to 255, 8-bit unsigned integer divide is used instead of
3448932-bit/64-bit integer divide.
34490
d77de738
ML
34491@opindex mavx256-split-unaligned-load
34492@opindex mavx256-split-unaligned-store
ddf6fe37
AA
34493@item -mavx256-split-unaligned-load
34494@itemx -mavx256-split-unaligned-store
d77de738
ML
34495Split 32-byte AVX unaligned load and store.
34496
d77de738
ML
34497@opindex mstack-protector-guard
34498@opindex mstack-protector-guard-reg
34499@opindex mstack-protector-guard-offset
ddf6fe37
AA
34500@item -mstack-protector-guard=@var{guard}
34501@itemx -mstack-protector-guard-reg=@var{reg}
34502@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
34503Generate stack protection code using canary at @var{guard}. Supported
34504locations are @samp{global} for global canary or @samp{tls} for per-thread
34505canary in the TLS block (the default). This option has effect only when
34506@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
34507
34508With the latter choice the options
34509@option{-mstack-protector-guard-reg=@var{reg}} and
34510@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
34511which segment register (@code{%fs} or @code{%gs}) to use as base register
34512for reading the canary, and from what offset from that base register.
34513The default for those is as specified in the relevant ABI.
34514
d77de738 34515@opindex mgeneral-regs-only
ddf6fe37 34516@item -mgeneral-regs-only
d77de738
ML
34517Generate code that uses only the general-purpose registers. This
34518prevents the compiler from using floating-point, vector, mask and bound
34519registers.
34520
d77de738 34521@opindex mrelax-cmpxchg-loop
ddf6fe37 34522@item -mrelax-cmpxchg-loop
85966f0d
AM
34523When emitting a compare-and-swap loop for @ref{__sync Builtins}
34524and @ref{__atomic Builtins} lacking a native instruction, optimize
34525for the highly contended case by issuing an atomic load before the
34526@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
34527to save CPU power when restarting the loop.
d77de738 34528
d77de738 34529@opindex mindirect-branch
ddf6fe37 34530@item -mindirect-branch=@var{choice}
d77de738
ML
34531Convert indirect call and jump with @var{choice}. The default is
34532@samp{keep}, which keeps indirect call and jump unmodified.
34533@samp{thunk} converts indirect call and jump to call and return thunk.
34534@samp{thunk-inline} converts indirect call and jump to inlined call
34535and return thunk. @samp{thunk-extern} converts indirect call and jump
34536to external call and return thunk provided in a separate object file.
34537You can control this behavior for a specific function by using the
34538function attribute @code{indirect_branch}. @xref{Function Attributes}.
34539
34540Note that @option{-mcmodel=large} is incompatible with
34541@option{-mindirect-branch=thunk} and
34542@option{-mindirect-branch=thunk-extern} since the thunk function may
34543not be reachable in the large code model.
34544
34545Note that @option{-mindirect-branch=thunk-extern} is compatible with
34546@option{-fcf-protection=branch} since the external thunk can be made
34547to enable control-flow check.
34548
d77de738 34549@opindex mfunction-return
ddf6fe37 34550@item -mfunction-return=@var{choice}
d77de738
ML
34551Convert function return with @var{choice}. The default is @samp{keep},
34552which keeps function return unmodified. @samp{thunk} converts function
34553return to call and return thunk. @samp{thunk-inline} converts function
34554return to inlined call and return thunk. @samp{thunk-extern} converts
34555function return to external call and return thunk provided in a separate
34556object file. You can control this behavior for a specific function by
34557using the function attribute @code{function_return}.
34558@xref{Function Attributes}.
34559
34560Note that @option{-mindirect-return=thunk-extern} is compatible with
34561@option{-fcf-protection=branch} since the external thunk can be made
34562to enable control-flow check.
34563
34564Note that @option{-mcmodel=large} is incompatible with
34565@option{-mfunction-return=thunk} and
34566@option{-mfunction-return=thunk-extern} since the thunk function may
34567not be reachable in the large code model.
34568
34569
d77de738 34570@opindex mindirect-branch-register
ddf6fe37 34571@item -mindirect-branch-register
d77de738
ML
34572Force indirect call and jump via register.
34573
d77de738 34574@opindex mharden-sls
ddf6fe37 34575@item -mharden-sls=@var{choice}
d77de738
ML
34576Generate code to mitigate against straight line speculation (SLS) with
34577@var{choice}. The default is @samp{none} which disables all SLS
34578hardening. @samp{return} enables SLS hardening for function returns.
34579@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34580@samp{all} enables all SLS hardening.
34581
d77de738 34582@opindex mindirect-branch-cs-prefix
ddf6fe37 34583@item -mindirect-branch-cs-prefix
d77de738
ML
34584Add CS prefix to call and jmp to indirect thunk with branch target in
34585r8-r15 registers so that the call and jmp instruction length is 6 bytes
34586to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34587@samp{lfence; jmp *%r8-r15} at run-time.
34588
34589@end table
34590
34591These @samp{-m} switches are supported in addition to the above
34592on x86-64 processors in 64-bit environments.
34593
34594@table @gcctabopt
d77de738
ML
34595@opindex m32
34596@opindex m64
34597@opindex mx32
34598@opindex m16
34599@opindex miamcu
ddf6fe37
AA
34600@item -m32
34601@itemx -m64
34602@itemx -mx32
34603@itemx -m16
34604@itemx -miamcu
d77de738
ML
34605Generate code for a 16-bit, 32-bit or 64-bit environment.
34606The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34607to 32 bits, and
eeb92704 34608generates code that runs in 32-bit mode.
d77de738
ML
34609
34610The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34611types to 64 bits, and generates code for the x86-64 architecture.
34612For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34613and @option{-mdynamic-no-pic} options.
34614
34615The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34616to 32 bits, and
34617generates code for the x86-64 architecture.
34618
34619The @option{-m16} option is the same as @option{-m32}, except for that
34620it outputs the @code{.code16gcc} assembly directive at the beginning of
34621the assembly output so that the binary can run in 16-bit mode.
34622
34623The @option{-miamcu} option generates code which conforms to Intel MCU
34624psABI. It requires the @option{-m32} option to be turned on.
34625
d77de738
ML
34626@opindex mno-red-zone
34627@opindex mred-zone
ddf6fe37 34628@item -mno-red-zone
d77de738
ML
34629Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34630by the x86-64 ABI; it is a 128-byte area beyond the location of the
34631stack pointer that is not modified by signal or interrupt handlers
34632and therefore can be used for temporary data without adjusting the stack
34633pointer. The flag @option{-mno-red-zone} disables this red zone.
34634
d77de738 34635@opindex mcmodel=small
ddf6fe37 34636@item -mcmodel=small
d77de738
ML
34637Generate code for the small code model: the program and its symbols must
34638be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34639Programs can be statically or dynamically linked. This is the default
34640code model.
34641
d77de738 34642@opindex mcmodel=kernel
ddf6fe37 34643@item -mcmodel=kernel
d77de738
ML
34644Generate code for the kernel code model. The kernel runs in the
34645negative 2 GB of the address space.
34646This model has to be used for Linux kernel code.
34647
d77de738 34648@opindex mcmodel=medium
ddf6fe37 34649@item -mcmodel=medium
d77de738
ML
34650Generate code for the medium model: the program is linked in the lower 2
34651GB of the address space. Small symbols are also placed there. Symbols
34652with sizes larger than @option{-mlarge-data-threshold} are put into
34653large data or BSS sections and can be located above 2GB. Programs can
34654be statically or dynamically linked.
34655
d77de738 34656@opindex mcmodel=large
ddf6fe37 34657@item -mcmodel=large
d77de738
ML
34658Generate code for the large model. This model makes no assumptions
34659about addresses and sizes of sections.
34660
d77de738 34661@opindex maddress-mode=long
ddf6fe37 34662@item -maddress-mode=long
d77de738
ML
34663Generate code for long address mode. This is only supported for 64-bit
34664and x32 environments. It is the default address mode for 64-bit
34665environments.
34666
d77de738 34667@opindex maddress-mode=short
ddf6fe37 34668@item -maddress-mode=short
d77de738
ML
34669Generate code for short address mode. This is only supported for 32-bit
34670and x32 environments. It is the default address mode for 32-bit and
34671x32 environments.
34672
ddf6fe37 34673@opindex mneeded
d77de738
ML
34674@item -mneeded
34675@itemx -mno-needed
d77de738
ML
34676Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34677indicate the micro-architecture ISA level required to execute the binary.
34678
d77de738
ML
34679@opindex mno-direct-extern-access
34680@opindex mdirect-extern-access
ddf6fe37 34681@item -mno-direct-extern-access
d77de738
ML
34682Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34683to access external symbols. With @option{-fpic} or @option{-fPIC},
34684treat access to protected symbols as local symbols. The default is
34685@option{-mdirect-extern-access}.
34686
34687@strong{Warning:} shared libraries compiled with
34688@option{-mno-direct-extern-access} and executable compiled with
34689@option{-mdirect-extern-access} may not be binary compatible if
34690protected symbols are used in shared libraries and executable.
ce51e843 34691
ce51e843
ML
34692@opindex munroll-only-small-loops
34693@opindex mno-unroll-only-small-loops
ddf6fe37 34694@item -munroll-only-small-loops
ce51e843
ML
34695Controls conservative small loop unrolling. It is default enabled by
34696O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34697-f[no-]unroll-[all-]loops would disable this flag to avoid any
34698unintended unrolling behavior that user does not want.
bb576017 34699
bb576017 34700@opindex mlam
ddf6fe37 34701@item -mlam=@var{choice}
bb576017 34702LAM(linear-address masking) allows special bits in the pointer to be used
34703for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34704positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34705positions 62:57 can be used for metadata.
d77de738
ML
34706@end table
34707
34708@node x86 Windows Options
34709@subsection x86 Windows Options
34710@cindex x86 Windows Options
34711@cindex Windows Options for x86
34712
34713These additional options are available for Microsoft Windows targets:
34714
34715@table @gcctabopt
d77de738 34716@opindex mconsole
ddf6fe37 34717@item -mconsole
d77de738
ML
34718This option
34719specifies that a console application is to be generated, by
34720instructing the linker to set the PE header subsystem type
34721required for console applications.
34722This option is available for Cygwin and MinGW targets and is
34723enabled by default on those targets.
34724
453cb585
PR
34725@opindex mcrtdll
34726@item -mcrtdll=@var{library}
34727Preprocess, compile or link with specified C RunTime DLL @var{library}.
34728This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}
34729and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose
34730start file for CRT @var{library} and link with CRT @var{library}.
34731Recognized CRT library names for proprocessor are:
34732@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40},
34733@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90},
34734@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}.
34735If this options is not specified then the default MinGW import library
34736@code{msvcrt} is used for linking and no other adjustment for
34737preprocessor is done. MinGW import library @code{msvcrt} is just a
34738symlink to (or a copy of) another MinGW CRT import library
34739chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
34740is for Windows system CRT DLL library @code{msvcrt.dll} and
34741in most cases is the default MinGW import library.
34742Generally speaking, changing the CRT DLL requires recompiling
34743the entire MinGW CRT. This option is for experimental and testing
34744purposes only.
34745This option is available for MinGW targets.
34746
d77de738 34747@opindex mdll
ddf6fe37 34748@item -mdll
d77de738
ML
34749This option is available for Cygwin and MinGW targets. It
34750specifies that a DLL---a dynamic link library---is to be
34751generated, enabling the selection of the required runtime
34752startup object and entry point.
34753
d77de738 34754@opindex mnop-fun-dllimport
ddf6fe37 34755@item -mnop-fun-dllimport
d77de738
ML
34756This option is available for Cygwin and MinGW targets. It
34757specifies that the @code{dllimport} attribute should be ignored.
34758
d77de738 34759@opindex mthreads
ddf6fe37 34760@item -mthreads
d77de738
ML
34761This option is available for MinGW targets. It specifies
34762that MinGW-specific thread support is to be used.
34763
d77de738 34764@opindex municode
ddf6fe37 34765@item -municode
d77de738
ML
34766This option is available for MinGW-w64 targets. It causes
34767the @code{UNICODE} preprocessor macro to be predefined, and
34768chooses Unicode-capable runtime startup code.
34769
d77de738 34770@opindex mwin32
ddf6fe37 34771@item -mwin32
d77de738
ML
34772This option is available for Cygwin and MinGW targets. It
34773specifies that the typical Microsoft Windows predefined macros are to
34774be set in the pre-processor, but does not influence the choice
34775of runtime library/startup code.
34776
d77de738 34777@opindex mwindows
ddf6fe37 34778@item -mwindows
d77de738
ML
34779This option is available for Cygwin and MinGW targets. It
34780specifies that a GUI application is to be generated by
34781instructing the linker to set the PE header subsystem type
34782appropriately.
34783
d77de738
ML
34784@opindex fno-set-stack-executable
34785@opindex fset-stack-executable
ddf6fe37 34786@item -fno-set-stack-executable
d77de738
ML
34787This option is available for MinGW targets. It specifies that
34788the executable flag for the stack used by nested functions isn't
34789set. This is necessary for binaries running in kernel mode of
34790Microsoft Windows, as there the User32 API, which is used to set executable
34791privileges, isn't available.
34792
d77de738
ML
34793@opindex fno-writable-relocated-rdata
34794@opindex fwritable-relocated-rdata
ddf6fe37 34795@item -fwritable-relocated-rdata
d77de738
ML
34796This option is available for MinGW and Cygwin targets. It specifies
34797that relocated-data in read-only section is put into the @code{.data}
34798section. This is a necessary for older runtimes not supporting
34799modification of @code{.rdata} sections for pseudo-relocation.
34800
d77de738 34801@opindex mpe-aligned-commons
ddf6fe37 34802@item -mpe-aligned-commons
d77de738
ML
34803This option is available for Cygwin and MinGW targets. It
34804specifies that the GNU extension to the PE file format that
34805permits the correct alignment of COMMON variables should be
34806used when generating code. It is enabled by default if
34807GCC detects that the target assembler found during configuration
34808supports the feature.
34809@end table
34810
34811See also under @ref{x86 Options} for standard options.
34812
34813@node Xstormy16 Options
34814@subsection Xstormy16 Options
34815@cindex Xstormy16 Options
34816
34817These options are defined for Xstormy16:
34818
34819@table @gcctabopt
d77de738 34820@opindex msim
ddf6fe37 34821@item -msim
d77de738
ML
34822Choose startup files and linker script suitable for the simulator.
34823@end table
34824
34825@node Xtensa Options
34826@subsection Xtensa Options
34827@cindex Xtensa Options
34828
34829These options are supported for Xtensa targets:
34830
34831@table @gcctabopt
d77de738
ML
34832@opindex mconst16
34833@opindex mno-const16
ddf6fe37
AA
34834@item -mconst16
34835@itemx -mno-const16
d77de738
ML
34836Enable or disable use of @code{CONST16} instructions for loading
34837constant values. The @code{CONST16} instruction is currently not a
34838standard option from Tensilica. When enabled, @code{CONST16}
34839instructions are always used in place of the standard @code{L32R}
34840instructions. The use of @code{CONST16} is enabled by default only if
34841the @code{L32R} instruction is not available.
34842
d77de738
ML
34843@opindex mfused-madd
34844@opindex mno-fused-madd
ddf6fe37
AA
34845@item -mfused-madd
34846@itemx -mno-fused-madd
d77de738
ML
34847Enable or disable use of fused multiply/add and multiply/subtract
34848instructions in the floating-point option. This has no effect if the
34849floating-point option is not also enabled. Disabling fused multiply/add
34850and multiply/subtract instructions forces the compiler to use separate
34851instructions for the multiply and add/subtract operations. This may be
34852desirable in some cases where strict IEEE 754-compliant results are
34853required: the fused multiply add/subtract instructions do not round the
34854intermediate result, thereby producing results with @emph{more} bits of
34855precision than specified by the IEEE standard. Disabling fused multiply
34856add/subtract instructions also ensures that the program output is not
34857sensitive to the compiler's ability to combine multiply and add/subtract
34858operations.
34859
d77de738
ML
34860@opindex mserialize-volatile
34861@opindex mno-serialize-volatile
ddf6fe37
AA
34862@item -mserialize-volatile
34863@itemx -mno-serialize-volatile
d77de738
ML
34864When this option is enabled, GCC inserts @code{MEMW} instructions before
34865@code{volatile} memory references to guarantee sequential consistency.
34866The default is @option{-mserialize-volatile}. Use
34867@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34868
d77de738 34869@opindex mforce-no-pic
ddf6fe37 34870@item -mforce-no-pic
d77de738
ML
34871For targets, like GNU/Linux, where all user-mode Xtensa code must be
34872position-independent code (PIC), this option disables PIC for compiling
34873kernel code.
34874
d77de738
ML
34875@opindex mtext-section-literals
34876@opindex mno-text-section-literals
ddf6fe37
AA
34877@item -mtext-section-literals
34878@itemx -mno-text-section-literals
d77de738
ML
34879These options control the treatment of literal pools. The default is
34880@option{-mno-text-section-literals}, which places literals in a separate
34881section in the output file. This allows the literal pool to be placed
34882in a data RAM/ROM, and it also allows the linker to combine literal
34883pools from separate object files to remove redundant literals and
34884improve code size. With @option{-mtext-section-literals}, the literals
34885are interspersed in the text section in order to keep them as close as
34886possible to their references. This may be necessary for large assembly
34887files. Literals for each function are placed right before that function.
34888
d77de738
ML
34889@opindex mauto-litpools
34890@opindex mno-auto-litpools
ddf6fe37
AA
34891@item -mauto-litpools
34892@itemx -mno-auto-litpools
d77de738
ML
34893These options control the treatment of literal pools. The default is
34894@option{-mno-auto-litpools}, which places literals in a separate
34895section in the output file unless @option{-mtext-section-literals} is
34896used. With @option{-mauto-litpools} the literals are interspersed in
34897the text section by the assembler. Compiler does not produce explicit
34898@code{.literal} directives and loads literals into registers with
34899@code{MOVI} instructions instead of @code{L32R} to let the assembler
34900do relaxation and place literals as necessary. This option allows
34901assembler to create several literal pools per function and assemble
34902very big functions, which may not be possible with
34903@option{-mtext-section-literals}.
34904
d77de738
ML
34905@opindex mtarget-align
34906@opindex mno-target-align
ddf6fe37
AA
34907@item -mtarget-align
34908@itemx -mno-target-align
d77de738
ML
34909When this option is enabled, GCC instructs the assembler to
34910automatically align instructions to reduce branch penalties at the
34911expense of some code density. The assembler attempts to widen density
34912instructions to align branch targets and the instructions following call
34913instructions. If there are not enough preceding safe density
34914instructions to align a target, no widening is performed. The
34915default is @option{-mtarget-align}. These options do not affect the
34916treatment of auto-aligned instructions like @code{LOOP}, which the
34917assembler always aligns, either by widening density instructions or
34918by inserting NOP instructions.
34919
d77de738
ML
34920@opindex mlongcalls
34921@opindex mno-longcalls
ddf6fe37
AA
34922@item -mlongcalls
34923@itemx -mno-longcalls
d77de738
ML
34924When this option is enabled, GCC instructs the assembler to translate
34925direct calls to indirect calls unless it can determine that the target
34926of a direct call is in the range allowed by the call instruction. This
34927translation typically occurs for calls to functions in other source
34928files. Specifically, the assembler translates a direct @code{CALL}
34929instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34930The default is @option{-mno-longcalls}. This option should be used in
34931programs where the call target can potentially be out of range. This
34932option is implemented in the assembler, not the compiler, so the
34933assembly code generated by GCC still shows direct call
34934instructions---look at the disassembled object code to see the actual
34935instructions. Note that the assembler uses an indirect call for
34936every cross-file call, not just those that really are out of range.
34937
d77de738 34938@opindex mabi
ddf6fe37 34939@item -mabi=@var{name}
d77de738
ML
34940Generate code for the specified ABI@. Permissible values are: @samp{call0},
34941@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34942
d77de738 34943@opindex mabi=call0
ddf6fe37 34944@item -mabi=call0
d77de738
ML
34945When this option is enabled function parameters are passed in registers
34946@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34947caller-saved, and register @code{a15} may be used as a frame pointer.
34948When this version of the ABI is enabled the C preprocessor symbol
34949@code{__XTENSA_CALL0_ABI__} is defined.
34950
d77de738 34951@opindex mabi=windowed
ddf6fe37 34952@item -mabi=windowed
d77de738
ML
34953When this option is enabled function parameters are passed in registers
34954@code{a10} through @code{a15}, and called function rotates register window
34955by 8 registers on entry so that its arguments are found in registers
34956@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34957pointer. Register window is rotated 8 registers back upon return.
34958When this version of the ABI is enabled the C preprocessor symbol
34959@code{__XTENSA_WINDOWED_ABI__} is defined.
34960
d77de738 34961@opindex mextra-l32r-costs
ddf6fe37 34962@item -mextra-l32r-costs=@var{n}
d77de738
ML
34963Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34964instructions, in clock cycles. This affects, when optimizing for speed,
34965whether loading a constant from literal pool using @code{L32R} or
34966synthesizing the constant from a small one with a couple of arithmetic
34967instructions. The default value is 0.
675b390e
MF
34968
34969@opindex mstrict-align
34970@opindex mno-strict-align
34971@item -mstrict-align
34972@itemx -mno-strict-align
34973Avoid or allow generating memory accesses that may not be aligned on a natural
34974object boundary as described in the architecture specification.
34975The default is @option{-mno-strict-align} for cores that support both
34976unaligned loads and stores in hardware and @option{-mstrict-align} for all
34977other cores.
34978
d77de738
ML
34979@end table
34980
34981@node zSeries Options
34982@subsection zSeries Options
34983@cindex zSeries options
34984
34985These are listed under @xref{S/390 and zSeries Options}.
34986
34987
34988@c man end
34989
34990@node Spec Files
34991@section Specifying Subprocesses and the Switches to Pass to Them
34992@cindex Spec Files
34993
34994@command{gcc} is a driver program. It performs its job by invoking a
34995sequence of other programs to do the work of compiling, assembling and
34996linking. GCC interprets its command-line parameters and uses these to
34997deduce which programs it should invoke, and which command-line options
34998it ought to place on their command lines. This behavior is controlled
34999by @dfn{spec strings}. In most cases there is one spec string for each
35000program that GCC can invoke, but a few programs have multiple spec
35001strings to control their behavior. The spec strings built into GCC can
35002be overridden by using the @option{-specs=} command-line switch to specify
35003a spec file.
35004
35005@dfn{Spec files} are plain-text files that are used to construct spec
35006strings. They consist of a sequence of directives separated by blank
35007lines. The type of directive is determined by the first non-whitespace
35008character on the line, which can be one of the following:
35009
35010@table @code
35011@item %@var{command}
35012Issues a @var{command} to the spec file processor. The commands that can
35013appear here are:
35014
35015@table @code
d77de738 35016@cindex @code{%include}
f33d7a88 35017@item %include <@var{file}>
d77de738
ML
35018Search for @var{file} and insert its text at the current point in the
35019specs file.
35020
d77de738 35021@cindex @code{%include_noerr}
f33d7a88 35022@item %include_noerr <@var{file}>
d77de738
ML
35023Just like @samp{%include}, but do not generate an error message if the include
35024file cannot be found.
35025
d77de738 35026@cindex @code{%rename}
f33d7a88 35027@item %rename @var{old_name} @var{new_name}
d77de738
ML
35028Rename the spec string @var{old_name} to @var{new_name}.
35029
35030@end table
35031
35032@item *[@var{spec_name}]:
35033This tells the compiler to create, override or delete the named spec
35034string. All lines after this directive up to the next directive or
35035blank line are considered to be the text for the spec string. If this
35036results in an empty string then the spec is deleted. (Or, if the
35037spec did not exist, then nothing happens.) Otherwise, if the spec
35038does not currently exist a new spec is created. If the spec does
35039exist then its contents are overridden by the text of this
35040directive, unless the first character of that text is the @samp{+}
35041character, in which case the text is appended to the spec.
35042
35043@item [@var{suffix}]:
35044Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
35045and up to the next directive or blank line are considered to make up the
35046spec string for the indicated suffix. When the compiler encounters an
35047input file with the named suffix, it processes the spec string in
35048order to work out how to compile that file. For example:
35049
35050@smallexample
35051.ZZ:
35052z-compile -input %i
35053@end smallexample
35054
35055This says that any input file whose name ends in @samp{.ZZ} should be
35056passed to the program @samp{z-compile}, which should be invoked with the
35057command-line switch @option{-input} and with the result of performing the
35058@samp{%i} substitution. (See below.)
35059
35060As an alternative to providing a spec string, the text following a
35061suffix directive can be one of the following:
35062
35063@table @code
35064@item @@@var{language}
35065This says that the suffix is an alias for a known @var{language}. This is
35066similar to using the @option{-x} command-line switch to GCC to specify a
35067language explicitly. For example:
35068
35069@smallexample
35070.ZZ:
35071@@c++
35072@end smallexample
35073
35074Says that .ZZ files are, in fact, C++ source files.
35075
35076@item #@var{name}
35077This causes an error messages saying:
35078
35079@smallexample
35080@var{name} compiler not installed on this system.
35081@end smallexample
35082@end table
35083
35084GCC already has an extensive list of suffixes built into it.
35085This directive adds an entry to the end of the list of suffixes, but
35086since the list is searched from the end backwards, it is effectively
35087possible to override earlier entries using this technique.
35088
35089@end table
35090
35091GCC has the following spec strings built into it. Spec files can
35092override these strings or create their own. Note that individual
35093targets can also add their own spec strings to this list.
35094
35095@smallexample
35096asm Options to pass to the assembler
35097asm_final Options to pass to the assembler post-processor
35098cpp Options to pass to the C preprocessor
35099cc1 Options to pass to the C compiler
35100cc1plus Options to pass to the C++ compiler
35101endfile Object files to include at the end of the link
35102link Options to pass to the linker
35103lib Libraries to include on the command line to the linker
35104libgcc Decides which GCC support library to pass to the linker
35105linker Sets the name of the linker
35106predefines Defines to be passed to the C preprocessor
35107signed_char Defines to pass to CPP to say whether @code{char} is signed
35108 by default
35109startfile Object files to include at the start of the link
35110@end smallexample
35111
35112Here is a small example of a spec file:
35113
35114@smallexample
35115%rename lib old_lib
35116
35117*lib:
35118--start-group -lgcc -lc -leval1 --end-group %(old_lib)
35119@end smallexample
35120
35121This example renames the spec called @samp{lib} to @samp{old_lib} and
35122then overrides the previous definition of @samp{lib} with a new one.
35123The new definition adds in some extra command-line options before
35124including the text of the old definition.
35125
35126@dfn{Spec strings} are a list of command-line options to be passed to their
35127corresponding program. In addition, the spec strings can contain
35128@samp{%}-prefixed sequences to substitute variable text or to
35129conditionally insert text into the command line. Using these constructs
35130it is possible to generate quite complex command lines.
35131
35132Here is a table of all defined @samp{%}-sequences for spec
35133strings. Note that spaces are not generated automatically around the
35134results of expanding these sequences. Therefore you can concatenate them
35135together or combine them with constant text in a single argument.
35136
35137@table @code
35138@item %%
35139Substitute one @samp{%} into the program name or argument.
35140
35141@item %"
35142Substitute an empty argument.
35143
35144@item %i
35145Substitute the name of the input file being processed.
35146
35147@item %b
35148Substitute the basename for outputs related with the input file being
35149processed. This is often the substring up to (and not including) the
35150last period and not including the directory but, unless %w is active, it
35151expands to the basename for auxiliary outputs, which may be influenced
35152by an explicit output name, and by various other options that control
35153how auxiliary outputs are named.
35154
35155@item %B
35156This is the same as @samp{%b}, but include the file suffix (text after
35157the last period). Without %w, it expands to the basename for dump
35158outputs.
35159
35160@item %d
35161Marks the argument containing or following the @samp{%d} as a
35162temporary file name, so that that file is deleted if GCC exits
35163successfully. Unlike @samp{%g}, this contributes no text to the
35164argument.
35165
35166@item %g@var{suffix}
35167Substitute a file name that has suffix @var{suffix} and is chosen
35168once per compilation, and mark the argument in the same way as
35169@samp{%d}. To reduce exposure to denial-of-service attacks, the file
35170name is now chosen in a way that is hard to predict even when previously
35171chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
35172might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
35173the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
35174treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
35175was simply substituted with a file name chosen once per compilation,
35176without regard to any appended suffix (which was therefore treated
35177just like ordinary text), making such attacks more likely to succeed.
35178
35179@item %u@var{suffix}
35180Like @samp{%g}, but generates a new temporary file name
35181each time it appears instead of once per compilation.
35182
35183@item %U@var{suffix}
35184Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
35185new one if there is no such last file name. In the absence of any
35186@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
35187the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
35188involves the generation of two distinct file names, one
35189for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
35190simply substituted with a file name chosen for the previous @samp{%u},
35191without regard to any appended suffix.
35192
35193@item %j@var{suffix}
35194Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
35195writable, and if @option{-save-temps} is not used;
35196otherwise, substitute the name
35197of a temporary file, just like @samp{%u}. This temporary file is not
35198meant for communication between processes, but rather as a junk
35199disposal mechanism.
35200
35201@item %|@var{suffix}
35202@itemx %m@var{suffix}
35203Like @samp{%g}, except if @option{-pipe} is in effect. In that case
35204@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
35205all. These are the two most common ways to instruct a program that it
35206should read from standard input or write to standard output. If you
35207need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
35208construct: see for example @file{gcc/fortran/lang-specs.h}.
35209
35210@item %.@var{SUFFIX}
35211Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
35212when it is subsequently output with @samp{%*}. @var{SUFFIX} is
35213terminated by the next space or %.
35214
35215@item %w
35216Marks the argument containing or following the @samp{%w} as the
35217designated output file of this compilation. This puts the argument
35218into the sequence of arguments that @samp{%o} substitutes.
35219
35220@item %V
35221Indicates that this compilation produces no output file.
35222
35223@item %o
35224Substitutes the names of all the output files, with spaces
35225automatically placed around them. You should write spaces
35226around the @samp{%o} as well or the results are undefined.
35227@samp{%o} is for use in the specs for running the linker.
35228Input files whose names have no recognized suffix are not compiled
35229at all, but they are included among the output files, so they are
35230linked.
35231
35232@item %O
35233Substitutes the suffix for object files. Note that this is
35234handled specially when it immediately follows @samp{%g, %u, or %U},
35235because of the need for those to form complete file names. The
35236handling is such that @samp{%O} is treated exactly as if it had already
35237been substituted, except that @samp{%g, %u, and %U} do not currently
35238support additional @var{suffix} characters following @samp{%O} as they do
35239following, for example, @samp{.o}.
35240
35241@item %I
35242Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
35243@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
35244@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
35245and @option{-imultilib} as necessary.
35246
35247@item %s
35248Current argument is the name of a library or startup file of some sort.
35249Search for that file in a standard list of directories and substitute
35250the full name found. The current working directory is included in the
35251list of directories scanned.
35252
35253@item %T
35254Current argument is the name of a linker script. Search for that file
35255in the current list of directories to scan for libraries. If the file
35256is located insert a @option{--script} option into the command line
35257followed by the full path name found. If the file is not found then
35258generate an error message. Note: the current working directory is not
35259searched.
35260
35261@item %e@var{str}
35262Print @var{str} as an error message. @var{str} is terminated by a newline.
35263Use this when inconsistent options are detected.
35264
35265@item %n@var{str}
35266Print @var{str} as a notice. @var{str} is terminated by a newline.
35267
35268@item %(@var{name})
35269Substitute the contents of spec string @var{name} at this point.
35270
35271@item %x@{@var{option}@}
35272Accumulate an option for @samp{%X}.
35273
35274@item %X
35275Output the accumulated linker options specified by a @samp{%x} spec string.
35276
35277@item %Y
35278Output the accumulated assembler options specified by @option{-Wa}.
35279
35280@item %Z
35281Output the accumulated preprocessor options specified by @option{-Wp}.
35282
35283@item %M
35284Output @code{multilib_os_dir}.
35285
35286@item %R
35287Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
35288
35289@item %a
35290Process the @code{asm} spec. This is used to compute the
35291switches to be passed to the assembler.
35292
35293@item %A
35294Process the @code{asm_final} spec. This is a spec string for
35295passing switches to an assembler post-processor, if such a program is
35296needed.
35297
35298@item %l
35299Process the @code{link} spec. This is the spec for computing the
35300command line passed to the linker. Typically it makes use of the
35301@samp{%L %G %S %D and %E} sequences.
35302
35303@item %D
35304Dump out a @option{-L} option for each directory that GCC believes might
35305contain startup files. If the target supports multilibs then the
35306current multilib directory is prepended to each of these paths.
35307
35308@item %L
35309Process the @code{lib} spec. This is a spec string for deciding which
35310libraries are included on the command line to the linker.
35311
35312@item %G
35313Process the @code{libgcc} spec. This is a spec string for deciding
35314which GCC support library is included on the command line to the linker.
35315
35316@item %S
35317Process the @code{startfile} spec. This is a spec for deciding which
35318object files are the first ones passed to the linker. Typically
35319this might be a file named @file{crt0.o}.
35320
35321@item %E
35322Process the @code{endfile} spec. This is a spec string that specifies
35323the last object files that are passed to the linker.
35324
35325@item %C
35326Process the @code{cpp} spec. This is used to construct the arguments
35327to be passed to the C preprocessor.
35328
35329@item %1
35330Process the @code{cc1} spec. This is used to construct the options to be
35331passed to the actual C compiler (@command{cc1}).
35332
35333@item %2
35334Process the @code{cc1plus} spec. This is used to construct the options to be
35335passed to the actual C++ compiler (@command{cc1plus}).
35336
35337@item %*
35338Substitute the variable part of a matched option. See below.
35339Note that each comma in the substituted string is replaced by
35340a single space.
35341
35342@item %<S
35343Remove all occurrences of @code{-S} from the command line. Note---this
35344command is position dependent. @samp{%} commands in the spec string
35345before this one see @code{-S}, @samp{%} commands in the spec string
35346after this one do not.
35347
35348@item %<S*
35349Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
35350
35351@item %>S
35352Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
35353
35354@item %:@var{function}(@var{args})
35355Call the named function @var{function}, passing it @var{args}.
35356@var{args} is first processed as a nested spec string, then split
35357into an argument vector in the usual fashion. The function returns
35358a string which is processed as if it had appeared literally as part
35359of the current spec.
35360
35361The following built-in spec functions are provided:
35362
35363@table @code
35364@item @code{getenv}
35365The @code{getenv} spec function takes two arguments: an environment
35366variable name and a string. If the environment variable is not
35367defined, a fatal error is issued. Otherwise, the return value is the
35368value of the environment variable concatenated with the string. For
35369example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
35370
35371@smallexample
35372%:getenv(TOPDIR /include)
35373@end smallexample
35374
35375expands to @file{/path/to/top/include}.
35376
35377@item @code{if-exists}
35378The @code{if-exists} spec function takes one argument, an absolute
35379pathname to a file. If the file exists, @code{if-exists} returns the
35380pathname. Here is a small example of its usage:
35381
35382@smallexample
35383*startfile:
35384crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
35385@end smallexample
35386
35387@item @code{if-exists-else}
35388The @code{if-exists-else} spec function is similar to the @code{if-exists}
35389spec function, except that it takes two arguments. The first argument is
35390an absolute pathname to a file. If the file exists, @code{if-exists-else}
35391returns the pathname. If it does not exist, it returns the second argument.
35392This way, @code{if-exists-else} can be used to select one file or another,
35393based on the existence of the first. Here is a small example of its usage:
35394
35395@smallexample
35396*startfile:
35397crt0%O%s %:if-exists(crti%O%s) \
35398%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
35399@end smallexample
35400
35401@item @code{if-exists-then-else}
35402The @code{if-exists-then-else} spec function takes at least two arguments
35403and an optional third one. The first argument is an absolute pathname to a
35404file. If the file exists, the function returns the second argument.
35405If the file does not exist, the function returns the third argument if there
35406is one, or NULL otherwise. This can be used to expand one text, or optionally
35407another, based on the existence of a file. Here is a small example of its
35408usage:
35409
35410@smallexample
35411-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
35412@end smallexample
35413
35414@item @code{sanitize}
35415The @code{sanitize} spec function takes no arguments. It returns non-NULL if
35416any address, thread or undefined behavior sanitizers are active.
35417
35418@smallexample
35419%@{%:sanitize(address):-funwind-tables@}
35420@end smallexample
35421
35422@item @code{replace-outfile}
35423The @code{replace-outfile} spec function takes two arguments. It looks for the
35424first argument in the outfiles array and replaces it with the second argument. Here
35425is a small example of its usage:
35426
35427@smallexample
35428%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
35429@end smallexample
35430
35431@item @code{remove-outfile}
35432The @code{remove-outfile} spec function takes one argument. It looks for the
35433first argument in the outfiles array and removes it. Here is a small example
35434its usage:
35435
35436@smallexample
35437%:remove-outfile(-lm)
35438@end smallexample
35439
35440@item @code{version-compare}
35441The @code{version-compare} spec function takes four or five arguments of the following
35442form:
35443
35444@smallexample
35445<comparison-op> <arg1> [<arg2>] <switch> <result>
35446@end smallexample
35447
35448It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
35449The supported @code{comparison-op} values are:
35450
35451@table @code
35452@item >=
35453True if @code{switch} is a later (or same) version than @code{arg1}
35454
35455@item !>
35456Opposite of @code{>=}
35457
35458@item <
35459True if @code{switch} is an earlier version than @code{arg1}
35460
35461@item !<
35462Opposite of @code{<}
35463
35464@item ><
35465True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
35466
35467@item <>
35468True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
35469@end table
35470
35471If the @code{switch} is not present at all, the condition is false unless the first character
35472of the @code{comparison-op} is @code{!}.
35473
35474@smallexample
35475%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
35476@end smallexample
35477
35478The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
35479passed.
35480
35481@item @code{include}
35482The @code{include} spec function behaves much like @code{%include}, with the advantage
35483that it can be nested inside a spec and thus be conditionalized. It takes one argument,
35484the filename, and looks for it in the startfile path. It always returns NULL.
35485
35486@smallexample
35487%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
35488@end smallexample
35489
35490@item @code{pass-through-libs}
35491The @code{pass-through-libs} spec function takes any number of arguments. It
35492finds any @option{-l} options and any non-options ending in @file{.a} (which it
35493assumes are the names of linker input library archive files) and returns a
35494result containing all the found arguments each prepended by
35495@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
35496intended to be passed to the LTO linker plugin.
35497
35498@smallexample
35499%:pass-through-libs(%G %L %G)
35500@end smallexample
35501
35502@item @code{print-asm-header}
35503The @code{print-asm-header} function takes no arguments and simply
35504prints a banner like:
35505
35506@smallexample
35507Assembler options
35508=================
35509
35510Use "-Wa,OPTION" to pass "OPTION" to the assembler.
35511@end smallexample
35512
35513It is used to separate compiler options from assembler options
35514in the @option{--target-help} output.
35515
35516@item @code{gt}
35517The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
35518empty string) if the second-to-last argument is greater than the last argument, and NULL
35519otherwise. The following example inserts the @code{link_gomp} spec if the last
35520@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
35521
35522@smallexample
35523%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
35524@end smallexample
35525
35526@item @code{debug-level-gt}
35527The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
35528empty string) if @code{debug_info_level} is greater than the specified number, and NULL
35529otherwise.
35530
35531@smallexample
35532%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
35533@end smallexample
35534@end table
35535
35536@item %@{S@}
35537Substitutes the @code{-S} switch, if that switch is given to GCC@.
35538If that switch is not specified, this substitutes nothing. Note that
35539the leading dash is omitted when specifying this option, and it is
35540automatically inserted if the substitution is performed. Thus the spec
35541string @samp{%@{foo@}} matches the command-line option @option{-foo}
35542and outputs the command-line option @option{-foo}.
35543
35544@item %W@{S@}
35545Like %@{@code{S}@} but mark last argument supplied within as a file to be
35546deleted on failure.
35547
35548@item %@@@{S@}
35549Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
35550@code{@@FILE} if an @code{@@file} argument has been supplied.
35551
35552@item %@{S*@}
35553Substitutes all the switches specified to GCC whose names start
35554with @code{-S}, but which also take an argument. This is used for
35555switches like @option{-o}, @option{-D}, @option{-I}, etc.
35556GCC considers @option{-o foo} as being
35557one switch whose name starts with @samp{o}. %@{o*@} substitutes this
35558text, including the space. Thus two arguments are generated.
35559
35560@item %@{S*&T*@}
35561Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
35562(the order of @code{S} and @code{T} in the spec is not significant).
35563There can be any number of ampersand-separated variables; for each the
35564wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
35565
35566@item %@{S:X@}
35567Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
35568
35569@item %@{!S:X@}
35570Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
35571
35572@item %@{S*:X@}
35573Substitutes @code{X} if one or more switches whose names start with
35574@code{-S} are specified to GCC@. Normally @code{X} is substituted only
35575once, no matter how many such switches appeared. However, if @code{%*}
35576appears somewhere in @code{X}, then @code{X} is substituted once
35577for each matching switch, with the @code{%*} replaced by the part of
35578that switch matching the @code{*}.
35579
35580If @code{%*} appears as the last part of a spec sequence then a space
35581is added after the end of the last substitution. If there is more
35582text in the sequence, however, then a space is not generated. This
35583allows the @code{%*} substitution to be used as part of a larger
35584string. For example, a spec string like this:
35585
35586@smallexample
35587%@{mcu=*:--script=%*/memory.ld@}
35588@end smallexample
35589
35590@noindent
35591when matching an option like @option{-mcu=newchip} produces:
35592
35593@smallexample
35594--script=newchip/memory.ld
35595@end smallexample
35596
35597@item %@{.S:X@}
35598Substitutes @code{X}, if processing a file with suffix @code{S}.
35599
35600@item %@{!.S:X@}
35601Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35602
35603@item %@{,S:X@}
35604Substitutes @code{X}, if processing a file for language @code{S}.
35605
35606@item %@{!,S:X@}
35607Substitutes @code{X}, if not processing a file for language @code{S}.
35608
35609@item %@{S|P:X@}
35610Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35611GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35612@code{*} sequences as well, although they have a stronger binding than
35613the @samp{|}. If @code{%*} appears in @code{X}, all of the
35614alternatives must be starred, and only the first matching alternative
35615is substituted.
35616
35617For example, a spec string like this:
35618
35619@smallexample
35620%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35621@end smallexample
35622
35623@noindent
35624outputs the following command-line options from the following input
35625command-line options:
35626
35627@smallexample
35628fred.c -foo -baz
35629jim.d -bar -boggle
35630-d fred.c -foo -baz -boggle
35631-d jim.d -bar -baz -boggle
35632@end smallexample
35633
35634@item %@{%:@var{function}(@var{args}):X@}
35635
35636Call function named @var{function} with args @var{args}. If the
35637function returns non-NULL, then @code{X} is substituted, if it returns
35638NULL, it isn't substituted.
35639
35640@item %@{S:X; T:Y; :D@}
35641
35642If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35643given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35644be as many clauses as you need. This may be combined with @code{.},
35645@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35646
35647
35648@end table
35649
35650The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35651or similar construct can use a backslash to ignore the special meaning
35652of the character following it, thus allowing literal matching of a
35653character that is otherwise specially treated. For example,
35654@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35655@option{-std=iso9899:1999} option is given.
35656
35657The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35658construct may contain other nested @samp{%} constructs or spaces, or
35659even newlines. They are processed as usual, as described above.
35660Trailing white space in @code{X} is ignored. White space may also
35661appear anywhere on the left side of the colon in these constructs,
35662except between @code{.} or @code{*} and the corresponding word.
35663
35664The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35665handled specifically in these constructs. If another value of
35666@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35667@option{-W} switch is found later in the command line, the earlier
35668switch value is ignored, except with @{@code{S}*@} where @code{S} is
35669just one letter, which passes all matching options.
35670
35671The character @samp{|} at the beginning of the predicate text is used to
35672indicate that a command should be piped to the following command, but
35673only if @option{-pipe} is specified.
35674
35675It is built into GCC which switches take arguments and which do not.
35676(You might think it would be useful to generalize this to allow each
35677compiler's spec to say which switches take arguments. But this cannot
35678be done in a consistent fashion. GCC cannot even decide which input
35679files have been specified without knowing which switches take arguments,
35680and it must know which input files to compile in order to tell which
35681compilers to run).
35682
35683GCC also knows implicitly that arguments starting in @option{-l} are to be
35684treated as compiler output files, and passed to the linker in their
35685proper position among the other output files.
35686
35687@node Environment Variables
35688@section Environment Variables Affecting GCC
35689@cindex environment variables
35690
35691@c man begin ENVIRONMENT
35692This section describes several environment variables that affect how GCC
35693operates. Some of them work by specifying directories or prefixes to use
35694when searching for various kinds of files. Some are used to specify other
35695aspects of the compilation environment.
35696
35697Note that you can also specify places to search using options such as
35698@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35699take precedence over places specified using environment variables, which
35700in turn take precedence over those specified by the configuration of GCC@.
35701@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35702GNU Compiler Collection (GCC) Internals}.
35703
35704@table @env
f33d7a88
AA
35705@vindex LANG
35706@vindex LC_CTYPE
35707@c @vindex LC_COLLATE
35708@vindex LC_MESSAGES
35709@c @vindex LC_MONETARY
35710@c @vindex LC_NUMERIC
35711@c @vindex LC_TIME
35712@vindex LC_ALL
35713@cindex locale
d77de738
ML
35714@item LANG
35715@itemx LC_CTYPE
35716@c @itemx LC_COLLATE
35717@itemx LC_MESSAGES
35718@c @itemx LC_MONETARY
35719@c @itemx LC_NUMERIC
35720@c @itemx LC_TIME
35721@itemx LC_ALL
d77de738
ML
35722These environment variables control the way that GCC uses
35723localization information which allows GCC to work with different
35724national conventions. GCC inspects the locale categories
35725@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35726so. These locale categories can be set to any value supported by your
35727installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35728Kingdom encoded in UTF-8.
35729
35730The @env{LC_CTYPE} environment variable specifies character
35731classification. GCC uses it to determine the character boundaries in
35732a string; this is needed for some multibyte encodings that contain quote
35733and escape characters that are otherwise interpreted as a string
35734end or escape.
35735
35736The @env{LC_MESSAGES} environment variable specifies the language to
35737use in diagnostic messages.
35738
35739If the @env{LC_ALL} environment variable is set, it overrides the value
35740of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35741and @env{LC_MESSAGES} default to the value of the @env{LANG}
35742environment variable. If none of these variables are set, GCC
35743defaults to traditional C English behavior.
35744
f33d7a88 35745@vindex TMPDIR
d77de738 35746@item TMPDIR
d77de738
ML
35747If @env{TMPDIR} is set, it specifies the directory to use for temporary
35748files. GCC uses temporary files to hold the output of one stage of
35749compilation which is to be used as input to the next stage: for example,
35750the output of the preprocessor, which is the input to the compiler
35751proper.
35752
f33d7a88 35753@vindex GCC_COMPARE_DEBUG
d77de738 35754@item GCC_COMPARE_DEBUG
d77de738
ML
35755Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35756@option{-fcompare-debug} to the compiler driver. See the documentation
35757of this option for more details.
35758
f33d7a88 35759@vindex GCC_EXEC_PREFIX
d77de738 35760@item GCC_EXEC_PREFIX
d77de738
ML
35761If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35762names of the subprograms executed by the compiler. No slash is added
35763when this prefix is combined with the name of a subprogram, but you can
35764specify a prefix that ends with a slash if you wish.
35765
35766If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35767an appropriate prefix to use based on the pathname it is invoked with.
35768
35769If GCC cannot find the subprogram using the specified prefix, it
35770tries looking in the usual places for the subprogram.
35771
35772The default value of @env{GCC_EXEC_PREFIX} is
35773@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35774the installed compiler. In many cases @var{prefix} is the value
35775of @code{prefix} when you ran the @file{configure} script.
35776
35777Other prefixes specified with @option{-B} take precedence over this prefix.
35778
35779This prefix is also used for finding files such as @file{crt0.o} that are
35780used for linking.
35781
35782In addition, the prefix is used in an unusual way in finding the
35783directories to search for header files. For each of the standard
35784directories whose name normally begins with @samp{/usr/local/lib/gcc}
35785(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35786replacing that beginning with the specified prefix to produce an
35787alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35788@file{foo/bar} just before it searches the standard directory
35789@file{/usr/local/lib/bar}.
35790If a standard directory begins with the configured
35791@var{prefix} then the value of @var{prefix} is replaced by
35792@env{GCC_EXEC_PREFIX} when looking for header files.
35793
f33d7a88 35794@vindex COMPILER_PATH
d77de738 35795@item COMPILER_PATH
d77de738
ML
35796The value of @env{COMPILER_PATH} is a colon-separated list of
35797directories, much like @env{PATH}. GCC tries the directories thus
35798specified when searching for subprograms, if it cannot find the
35799subprograms using @env{GCC_EXEC_PREFIX}.
35800
f33d7a88 35801@vindex LIBRARY_PATH
d77de738 35802@item LIBRARY_PATH
d77de738
ML
35803The value of @env{LIBRARY_PATH} is a colon-separated list of
35804directories, much like @env{PATH}. When configured as a native compiler,
35805GCC tries the directories thus specified when searching for special
35806linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35807using GCC also uses these directories when searching for ordinary
35808libraries for the @option{-l} option (but directories specified with
35809@option{-L} come first).
35810
f33d7a88 35811@vindex LANG
d77de738 35812@cindex locale definition
f33d7a88 35813@item LANG
d77de738
ML
35814This variable is used to pass locale information to the compiler. One way in
35815which this information is used is to determine the character set to be used
35816when character literals, string literals and comments are parsed in C and C++.
35817When the compiler is configured to allow multibyte characters,
35818the following values for @env{LANG} are recognized:
35819
35820@table @samp
35821@item C-JIS
35822Recognize JIS characters.
35823@item C-SJIS
35824Recognize SJIS characters.
35825@item C-EUCJP
35826Recognize EUCJP characters.
35827@end table
35828
35829If @env{LANG} is not defined, or if it has some other value, then the
35830compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35831recognize and translate multibyte characters.
35832
f33d7a88 35833@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 35834@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
35835If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35836then additional text will be emitted to stderr when fix-it hints are
35837emitted. @option{-fdiagnostics-parseable-fixits} and
35838@option{-fno-diagnostics-parseable-fixits} take precedence over this
35839environment variable.
35840
35841@table @samp
35842@item fixits-v1
35843Emit parseable fix-it hints, equivalent to
35844@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35845expressed as a count of bytes, starting at byte 1 for the initial column.
35846
35847@item fixits-v2
35848As @code{fixits-v1}, but columns are expressed as display columns,
35849as per @option{-fdiagnostics-column-unit=display}.
35850@end table
35851
35852@end table
35853
35854@noindent
35855Some additional environment variables affect the behavior of the
35856preprocessor.
35857
35858@include cppenv.texi
35859
35860@c man end
35861
35862@node Precompiled Headers
35863@section Using Precompiled Headers
35864@cindex precompiled headers
35865@cindex speed of compilation
35866
35867Often large projects have many header files that are included in every
35868source file. The time the compiler takes to process these header files
35869over and over again can account for nearly all of the time required to
35870build the project. To make builds faster, GCC allows you to
35871@dfn{precompile} a header file.
35872
35873To create a precompiled header file, simply compile it as you would any
35874other file, if necessary using the @option{-x} option to make the driver
35875treat it as a C or C++ header file. You may want to use a
35876tool like @command{make} to keep the precompiled header up-to-date when
35877the headers it contains change.
35878
35879A precompiled header file is searched for when @code{#include} is
35880seen in the compilation. As it searches for the included file
35881(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35882compiler looks for a precompiled header in each directory just before it
35883looks for the include file in that directory. The name searched for is
35884the name specified in the @code{#include} with @samp{.gch} appended. If
35885the precompiled header file cannot be used, it is ignored.
35886
35887For instance, if you have @code{#include "all.h"}, and you have
35888@file{all.h.gch} in the same directory as @file{all.h}, then the
35889precompiled header file is used if possible, and the original
35890header is used otherwise.
35891
35892Alternatively, you might decide to put the precompiled header file in a
35893directory and use @option{-I} to ensure that directory is searched
35894before (or instead of) the directory containing the original header.
35895Then, if you want to check that the precompiled header file is always
35896used, you can put a file of the same name as the original header in this
35897directory containing an @code{#error} command.
35898
35899This also works with @option{-include}. So yet another way to use
35900precompiled headers, good for projects not designed with precompiled
35901header files in mind, is to simply take most of the header files used by
35902a project, include them from another header file, precompile that header
35903file, and @option{-include} the precompiled header. If the header files
35904have guards against multiple inclusion, they are skipped because
35905they've already been included (in the precompiled header).
35906
35907If you need to precompile the same header file for different
35908languages, targets, or compiler options, you can instead make a
35909@emph{directory} named like @file{all.h.gch}, and put each precompiled
35910header in the directory, perhaps using @option{-o}. It doesn't matter
35911what you call the files in the directory; every precompiled header in
35912the directory is considered. The first precompiled header
35913encountered in the directory that is valid for this compilation is
35914used; they're searched in no particular order.
35915
35916There are many other possibilities, limited only by your imagination,
35917good sense, and the constraints of your build system.
35918
35919A precompiled header file can be used only when these conditions apply:
35920
35921@itemize
35922@item
35923Only one precompiled header can be used in a particular compilation.
35924
35925@item
35926A precompiled header cannot be used once the first C token is seen. You
35927can have preprocessor directives before a precompiled header; you cannot
35928include a precompiled header from inside another header.
35929
35930@item
35931The precompiled header file must be produced for the same language as
35932the current compilation. You cannot use a C precompiled header for a C++
35933compilation.
35934
35935@item
35936The precompiled header file must have been produced by the same compiler
35937binary as the current compilation is using.
35938
35939@item
35940Any macros defined before the precompiled header is included must
35941either be defined in the same way as when the precompiled header was
35942generated, or must not affect the precompiled header, which usually
35943means that they don't appear in the precompiled header at all.
35944
35945The @option{-D} option is one way to define a macro before a
35946precompiled header is included; using a @code{#define} can also do it.
35947There are also some options that define macros implicitly, like
35948@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35949defined this way.
35950
35951@item If debugging information is output when using the precompiled
35952header, using @option{-g} or similar, the same kind of debugging information
35953must have been output when building the precompiled header. However,
35954a precompiled header built using @option{-g} can be used in a compilation
35955when no debugging information is being output.
35956
35957@item The same @option{-m} options must generally be used when building
35958and using the precompiled header. @xref{Submodel Options},
35959for any cases where this rule is relaxed.
35960
35961@item Each of the following options must be the same when building and using
35962the precompiled header:
35963
35964@gccoptlist{-fexceptions}
35965
35966@item
35967Some other command-line options starting with @option{-f},
35968@option{-p}, or @option{-O} must be defined in the same way as when
35969the precompiled header was generated. At present, it's not clear
35970which options are safe to change and which are not; the safest choice
35971is to use exactly the same options when generating and using the
35972precompiled header. The following are known to be safe:
35973
43b72ede
AA
35974@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
35975-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
35976-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
35977-pedantic-errors}
35978
35979@item Address space layout randomization (ASLR) can lead to not binary identical
35980PCH files. If you rely on stable PCH file contents disable ASLR when generating
35981PCH files.
35982
35983@end itemize
35984
35985For all of these except the last, the compiler automatically
35986ignores the precompiled header if the conditions aren't met. If you
35987find an option combination that doesn't work and doesn't cause the
35988precompiled header to be ignored, please consider filing a bug report,
35989see @ref{Bugs}.
35990
35991If you do use differing options when generating and using the
35992precompiled header, the actual behavior is a mixture of the
35993behavior for the options. For instance, if you use @option{-g} to
35994generate the precompiled header but not when using it, you may or may
35995not get debugging information for routines in the precompiled header.
35996
35997@node C++ Modules
35998@section C++ Modules
35999@cindex speed of compilation
36000
36001Modules are a C++20 language feature. As the name suggests, they
36002provides a modular compilation system, intending to provide both
36003faster builds and better library isolation. The ``Merging Modules''
36004paper @uref{https://wg21.link/p1103}, provides the easiest to read set
36005of changes to the standard, although it does not capture later
36006changes.
36007
36008@emph{G++'s modules support is not complete.} Other than bugs, the
36009known missing pieces are:
36010
36011@table @emph
36012
36013@item Private Module Fragment
36014The Private Module Fragment is recognized, but an error is emitted.
36015
36016@item Partition definition visibility rules
36017Entities may be defined in implementation partitions, and those
36018definitions are not available outside of the module. This is not
36019implemented, and the definitions are available to extra-module use.
36020
36021@item Textual merging of reachable GM entities
36022Entities may be multiply defined across different header-units.
36023These must be de-duplicated, and this is implemented across imports,
36024or when an import redefines a textually-defined entity. However the
36025reverse is not implemented---textually redefining an entity that has
36026been defined in an imported header-unit. A redefinition error is
36027emitted.
36028
36029@item Translation-Unit local referencing rules
36030Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
36031(@uref{https://wg21.link/p2003}) add limitations on which entities an
36032exported region may reference (for instance, the entities an exported
36033template definition may reference). These are not fully implemented.
36034
36035@item Standard Library Header Units
36036The Standard Library is not provided as importable header units. If
36037you want to import such units, you must explicitly build them first.
36038If you do not do this with care, you may have multiple declarations,
36039which the module machinery must merge---compiler resource usage can be
36040affected by how you partition header files into header units.
36041
36042@end table
36043
36044Modular compilation is @emph{not} enabled with just the
36045@option{-std=c++20} option. You must explicitly enable it with the
36046@option{-fmodules-ts} option. It is independent of the language
36047version selected, although in pre-C++20 versions, it is of course an
36048extension.
36049
36050No new source file suffixes are required or supported. If you wish to
36051use a non-standard suffix (@pxref{Overall Options}), you also need
36052to provide a @option{-x c++} option too.@footnote{Some users like to
36053distinguish module interface files with a new suffix, such as naming
36054the source @code{module.cppm}, which involves
36055teaching all tools about the new suffix. A different scheme, such as
36056naming @code{module-m.cpp} would be less invasive.}
36057
36058Compiling a module interface unit produces an additional output (to
36059the assembly or object file), called a Compiled Module Interface
36060(CMI). This encodes the exported declarations of the module.
36061Importing a module reads in the CMI. The import graph is a Directed
36062Acyclic Graph (DAG). You must build imports before the importer.
36063
36064Header files may themselves be compiled to header units, which are a
36065transitional ability aiming at faster compilation. The
36066@option{-fmodule-header} option is used to enable this, and implies
36067the @option{-fmodules-ts} option. These CMIs are named by the fully
36068resolved underlying header file, and thus may be a complete pathname
36069containing subdirectories. If the header file is found at an absolute
36070pathname, the CMI location is still relative to a CMI root directory.
36071
36072As header files often have no suffix, you commonly have to specify a
36073@option{-x} option to tell the compiler the source is a header file.
36074You may use @option{-x c++-header}, @option{-x c++-user-header} or
36075@option{-x c++-system-header}. When used in conjunction with
36076@option{-fmodules-ts}, these all imply an appropriate
36077@option{-fmodule-header} option. The latter two variants use the
36078user or system include path to search for the file specified. This
36079allows you to, for instance, compile standard library header files as
36080header units, without needing to know exactly where they are
36081installed. Specifying the language as one of these variants also
36082inhibits output of the object file, as header files have no associated
36083object file.
36084
36085The @option{-fmodule-only} option disables generation of the
36086associated object file for compiling a module interface. Only the CMI
36087is generated. This option is implied when using the
36088@option{-fmodule-header} option.
36089
36090The @option{-flang-info-include-translate} and
36091@option{-flang-info-include-translate-not} options notes whether
36092include translation occurs or not. With no argument, the first will
36093note all include translation. The second will note all
36094non-translations of include files not known to intentionally be
36095textual. With an argument, queries about include translation of a
36096header files with that particular trailing pathname are noted. You
36097may repeat this form to cover several different header files. This
36098option may be helpful in determining whether include translation is
36099happening---if it is working correctly, it behaves as if it isn't
36100there at all.
36101
36102The @option{-flang-info-module-cmi} option can be used to determine
36103where the compiler is reading a CMI from. Without the option, the
36104compiler is silent when such a read is successful. This option has an
36105optional argument, which will restrict the notification to just the
36106set of named modules or header units specified.
36107
36108The @option{-Winvalid-imported-macros} option causes all imported macros
36109to be resolved at the end of compilation. Without this, imported
36110macros are only resolved when expanded or (re)defined. This option
36111detects conflicting import definitions for all macros.
36112
36113For details of the @option{-fmodule-mapper} family of options,
36114@pxref{C++ Module Mapper}.
36115
36116@menu
36117* C++ Module Mapper:: Module Mapper
36118* C++ Module Preprocessing:: Module Preprocessing
36119* C++ Compiled Module Interface:: Compiled Module Interface
36120@end menu
36121
36122@node C++ Module Mapper
36123@subsection Module Mapper
36124@cindex C++ Module Mapper
36125
36126A module mapper provides a server or file that the compiler queries to
36127determine the mapping between module names and CMI files. It is also
36128used to build CMIs on demand. @emph{Mapper functionality is in its
36129infancy and is intended for experimentation with build system
36130interactions.}
36131
36132You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
36133option or @env{CXX_MODULE_MAPPER} environment variable. The value may
36134have one of the following forms:
36135
36136@table @gcctabopt
36137
36138@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
36139An optional hostname and a numeric port number to connect to. If the
36140hostname is omitted, the loopback address is used. If the hostname
36141corresponds to multiple IPV6 addresses, these are tried in turn, until
36142one is successful. If your host lacks IPv6, this form is
36143non-functional. If you must use IPv4 use
36144@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
36145
36146@item =@var{socket}@r{[}?@var{ident}@r{]}
36147A local domain socket. If your host lacks local domain sockets, this
36148form is non-functional.
36149
36150@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
36151A program to spawn, and communicate with on its stdin/stdout streams.
36152Your @var{PATH} environment variable is searched for the program.
36153Arguments are separated by space characters, (it is not possible for
36154one of the arguments delivered to the program to contain a space). An
36155exception is if @var{program} begins with @@. In that case
36156@var{program} (sans @@) is looked for in the compiler's internal
36157binary directory. Thus the sample mapper-server can be specified
36158with @code{@@g++-mapper-server}.
36159
36160@item <>@r{[}?@var{ident}@r{]}
36161@item <>@var{inout}@r{[}?@var{ident}@r{]}
36162@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
36163Named pipes or file descriptors to communicate over. The first form,
36164@option{<>}, communicates over stdin and stdout. The other forms
36165allow you to specify a file descriptor or name a pipe. A numeric value
36166is interpreted as a file descriptor, otherwise named pipe is opened.
36167The second form specifies a bidirectional pipe and the last form
36168allows specifying two independent pipes. Using file descriptors
36169directly in this manner is fragile in general, as it can require the
36170cooperation of intermediate processes. In particular using stdin &
36171stdout is fraught with danger as other compiler options might also
36172cause the compiler to read stdin or write stdout, and it can have
36173unfortunate interactions with signal delivery from the terminal.
36174
36175@item @var{file}@r{[}?@var{ident}@r{]}
36176A mapping file consisting of space-separated module-name, filename
36177pairs, one per line. Only the mappings for the direct imports and any
36178module export name need be provided. If other mappings are provided,
36179they override those stored in any imported CMI files. A repository
36180root may be specified in the mapping file by using @samp{$root} as the
36181module name in the first active line. Use of this option will disable
36182any default module->CMI name mapping.
36183
36184@end table
36185
36186As shown, an optional @var{ident} may suffix the first word of the
36187option, indicated by a @samp{?} prefix. The value is used in the
36188initial handshake with the module server, or to specify a prefix on
36189mapping file lines. In the server case, the main source file name is
36190used if no @var{ident} is specified. In the file case, all non-blank
36191lines are significant, unless a value is specified, in which case only
36192lines beginning with @var{ident} are significant. The @var{ident}
36193must be separated by whitespace from the module name. Be aware that
36194@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
36195significant to the shell, and therefore may need quoting.
36196
36197The mapper is connected to or loaded lazily, when the first module
36198mapping is required. The networking protocols are only supported on
36199hosts that provide networking. If no mapper is specified a default is
36200provided.
36201
36202A project-specific mapper is expected to be provided by the build
36203system that invokes the compiler. It is not expected that a
36204general-purpose server is provided for all compilations. As such, the
36205server will know the build configuration, the compiler it invoked, and
36206the environment (such as working directory) in which that is
36207operating. As it may parallelize builds, several compilations may
36208connect to the same socket.
36209
36210The default mapper generates CMI files in a @samp{gcm.cache}
36211directory. CMI files have a @samp{.gcm} suffix. The module unit name
36212is used directly to provide the basename. Header units construct a
36213relative path using the underlying header file name. If the path is
36214already relative, a @samp{,} directory is prepended. Internal
36215@samp{..} components are translated to @samp{,,}. No attempt is made
36216to canonicalize these filenames beyond that done by the preprocessor's
36217include search algorithm, as in general it is ambiguous when symbolic
36218links are present.
36219
36220The mapper protocol was published as ``A Module Mapper''
36221@uref{https://wg21.link/p1184}. The implementation is provided by
36222@command{libcody}, @uref{https://github.com/urnathan/libcody},
36223which specifies the canonical protocol definition. A proof of concept
36224server implementation embedded in @command{make} was described in
36225''Make Me A Module'', @uref{https://wg21.link/p1602}.
36226
36227@node C++ Module Preprocessing
36228@subsection Module Preprocessing
36229@cindex C++ Module Preprocessing
36230
36231Modules affect preprocessing because of header units and include
36232translation. Some uses of the preprocessor as a separate step either
36233do not produce a correct output, or require CMIs to be available.
36234
36235Header units import macros. These macros can affect later conditional
36236inclusion, which therefore can cascade to differing import sets. When
36237preprocessing, it is necessary to load the CMI. If a header unit is
36238unavailable, the preprocessor issues a warning and continue (when
36239not just preprocessing, an error is emitted). Detecting such imports
36240requires preprocessor tokenization of the input stream to phase 4
36241(macro expansion).
36242
36243Include translation converts @code{#include}, @code{#include_next} and
36244@code{#import} directives to internal @code{import} declarations.
36245Whether a particular directive is translated is controlled by the
36246module mapper. Header unit names are canonicalized during
36247preprocessing.
36248
36249Dependency information can be emitted for macro import, extending the
36250functionality of @option{-MD} and @option{-MMD} options. Detection of
36251import declarations also requires phase 4 preprocessing, and thus
36252requires full preprocessing (or compilation).
36253
36254The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
36255preprocessing before phase 4.
36256
36257The @option{-save-temps} option uses @option{-fdirectives-only} for
36258preprocessing, and preserve the macro definitions in the preprocessed
36259output. Usually you also want to use this option when explicitly
36260preprocessing a header-unit, or consuming such preprocessed output:
36261
36262@smallexample
36263g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
36264g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
36265@end smallexample
36266
36267@node C++ Compiled Module Interface
36268@subsection Compiled Module Interface
36269@cindex C++ Compiled Module Interface
36270
36271CMIs are an additional artifact when compiling named module
36272interfaces, partitions or header units. These are read when
36273importing. CMI contents are implementation-specific, and in GCC's
36274case tied to the compiler version. Consider them a rebuildable cache
36275artifact, not a distributable object.
36276
36277When creating an output CMI, any missing directory components are
36278created in a manner that is safe for concurrent builds creating
36279multiple, different, CMIs within a common subdirectory tree.
36280
36281CMI contents are written to a temporary file, which is then atomically
36282renamed. Observers either see old contents (if there is an
36283existing file), or complete new contents. They do not observe the
36284CMI during its creation. This is unlike object file writing, which
36285may be observed by an external process.
36286
36287CMIs are read in lazily, if the host OS provides @code{mmap}
36288functionality. Generally blocks are read when name lookup or template
36289instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
36290option may be used.
36291
36292The @option{--param lazy-modules=@var{n}} parameter controls the limit
36293on the number of concurrently open module files during lazy loading.
36294Should more modules be imported, an LRU algorithm is used to determine
36295which files to close---until that file is needed again. This limit
36296may be exceeded with deep module dependency hierarchies. With large
36297code bases there may be more imports than the process limit of file
36298descriptors. By default, the limit is a few less than the per-process
36299file descriptor hard limit, if that is determinable.@footnote{Where
36300applicable the soft limit is incremented as needed towards the hard limit.}
36301
36302GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
36303You may use @command{readelf} to inspect them, although section
36304contents are largely undecipherable. There is a section named
36305@code{.gnu.c++.README}, which contains human-readable text. Other
36306than the first line, each line consists of @code{@var{tag}: @code{value}}
36307tuples.
36308
36309@smallexample
36310> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
36311
36312String dump of section '.gnu.c++.README':
36313 [ 0] GNU C++ primary module interface
36314 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
36315 [ 6f] version: 2020/11/16-04:54
36316 [ 89] module: foo
36317 [ 95] source: c_b.ii
36318 [ a4] dialect: C++20/coroutines
36319 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
36320 [ ee] repository: gcm.cache
36321 [ 104] buildtime: 2020/11/16 15:03:21 UTC
36322 [ 127] localtime: 2020/11/16 07:03:21 PST
36323 [ 14a] export: foo:part1 foo-part1.gcm
36324@end smallexample
36325
36326Amongst other things, this lists the source that was built, C++
36327dialect used and imports of the module.@footnote{The precise contents
36328of this output may change.} The timestamp is the same value as that
36329provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
36330explicitly specified with the environment variable
36331@code{SOURCE_DATE_EPOCH}. For further details
36332@pxref{Environment Variables}.
36333
36334A set of related CMIs may be copied, provided the relative pathnames
36335are preserved.
36336
36337The @code{.gnu.c++.README} contents do not affect CMI integrity, and
36338it may be removed or altered. The section numbering of the sections
36339whose names do not begin with @code{.gnu.c++.}, or are not the string
36340section is significant and must not be altered.