]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
RISC-V: Implement `riscv_emit_unary' helper
[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
fad61bf7 340-Wc11-c23-compat
43b72ede
AA
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
841008d3 451-fdump-analyzer-infinite-loop
43b72ede
AA
452-fdump-analyzer-json
453-fdump-analyzer-state-purge
454-fdump-analyzer-stderr
455-fdump-analyzer-supergraph
456-fdump-analyzer-untracked
457-Wno-analyzer-double-fclose
458-Wno-analyzer-double-free
459-Wno-analyzer-exposure-through-output-file
460-Wno-analyzer-exposure-through-uninit-copy
461-Wno-analyzer-fd-access-mode-mismatch
462-Wno-analyzer-fd-double-close
463-Wno-analyzer-fd-leak
464-Wno-analyzer-fd-phase-mismatch
465-Wno-analyzer-fd-type-mismatch
466-Wno-analyzer-fd-use-after-close
467-Wno-analyzer-fd-use-without-check
468-Wno-analyzer-file-leak
469-Wno-analyzer-free-of-non-heap
470-Wno-analyzer-imprecise-fp-arithmetic
841008d3 471-Wno-analyzer-infinite-loop
43b72ede
AA
472-Wno-analyzer-infinite-recursion
473-Wno-analyzer-jump-through-null
474-Wno-analyzer-malloc-leak
475-Wno-analyzer-mismatching-deallocation
476-Wno-analyzer-null-argument
477-Wno-analyzer-null-dereference
478-Wno-analyzer-out-of-bounds
034d99e8 479-Wno-analyzer-overlapping-buffers
43b72ede
AA
480-Wno-analyzer-possible-null-argument
481-Wno-analyzer-possible-null-dereference
482-Wno-analyzer-putenv-of-auto-var
483-Wno-analyzer-shift-count-negative
484-Wno-analyzer-shift-count-overflow
485-Wno-analyzer-stale-setjmp-buffer
486-Wno-analyzer-tainted-allocation-size
487-Wno-analyzer-tainted-assertion
488-Wno-analyzer-tainted-array-index
489-Wno-analyzer-tainted-divisor
490-Wno-analyzer-tainted-offset
491-Wno-analyzer-tainted-size
492-Wanalyzer-too-complex
f65f63c4 493-Wno-analyzer-undefined-behavior-strtok
43b72ede
AA
494-Wno-analyzer-unsafe-call-within-signal-handler
495-Wno-analyzer-use-after-free
496-Wno-analyzer-use-of-pointer-in-stale-stack-frame
497-Wno-analyzer-use-of-uninitialized-value
498-Wno-analyzer-va-arg-type-mismatch
499-Wno-analyzer-va-list-exhausted
500-Wno-analyzer-va-list-leak
501-Wno-analyzer-va-list-use-after-va-end
502-Wno-analyzer-write-to-const
503-Wno-analyzer-write-to-string-literal
d77de738
ML
504}
505
506@item C and Objective-C-only Warning Options
43b72ede 507@gccoptlist{-Wbad-function-cast -Wmissing-declarations
ffc74822
HM
508-Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations
509-Wnested-externs -Wold-style-declaration -Wold-style-definition
43b72ede 510-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
d77de738
ML
511-Wdeclaration-after-statement -Wpointer-sign}
512
513@item Debugging Options
514@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
515@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
516-gbtf -gctf -gctf@var{level}
517-ggdb -grecord-gcc-switches -gno-record-gcc-switches
518-gstrict-dwarf -gno-strict-dwarf
519-gas-loc-support -gno-as-loc-support
520-gas-locview-support -gno-as-locview-support
3eeb4801 521-gcodeview
43b72ede
AA
522-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
523-gstatement-frontiers -gno-statement-frontiers
524-gvariable-location-views -gno-variable-location-views
525-ginternal-reset-location-views -gno-internal-reset-location-views
526-ginline-points -gno-inline-points
527-gvms -gz@r{[}=@var{type}@r{]}
528-gsplit-dwarf -gdescribe-dies -gno-describe-dies
529-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
530-fno-eliminate-unused-debug-types
531-femit-struct-debug-baseonly -femit-struct-debug-reduced
532-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
533-fno-eliminate-unused-debug-symbols -femit-class-debug-always
534-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
535-fvar-tracking -fvar-tracking-assignments}
536
537@item Optimization Options
538@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
539@gccoptlist{-faggressive-loop-optimizations
540-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
541-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
542-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
543-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
544-fno-allocation-dce -fallow-store-data-races
545-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
546-fauto-inc-dec -fbranch-probabilities
547-fcaller-saves
548-fcombine-stack-adjustments -fconserve-stack
04c9cf5c 549-ffold-mem-offsets
43b72ede
AA
550-fcompare-elim -fcprop-registers -fcrossjumping
551-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
552-fcx-limited-range
553-fdata-sections -fdce -fdelayed-branch
554-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
555-fdevirtualize-at-ltrans -fdse
556-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
557-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
558-ffinite-loops
559-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
560-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
561-fgcse-sm -fhoist-adjacent-loads -fif-conversion
562-fif-conversion2 -findirect-inlining
563-finline-functions -finline-functions-called-once -finline-limit=@var{n}
564-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
565-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
566-fipa-reference -fipa-reference-addressable
567-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
568-flive-patching=@var{level}
569-fira-region=@var{region} -fira-hoist-pressure
570-fira-loop-pressure -fno-ira-share-save-slots
571-fno-ira-share-spill-slots
572-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
573-fivopts -fkeep-inline-functions -fkeep-static-functions
574-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
575-floop-block -floop-interchange -floop-strip-mine
576-floop-unroll-and-jam -floop-nest-optimize
577-floop-parallelize-all -flra-remat -flto -flto-compression-level
578-flto-partition=@var{alg} -fmerge-all-constants
579-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
580-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
581-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
582-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
583-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
584-fno-sched-spec -fno-signed-zeros
585-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
586-fomit-frame-pointer -foptimize-sibling-calls
587-fpartial-inlining -fpeel-loops -fpredictive-commoning
588-fprefetch-loop-arrays
589-fprofile-correction
590-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
591-fprofile-values -fprofile-reorder-functions
592-freciprocal-math -free -frename-registers -freorder-blocks
593-freorder-blocks-algorithm=@var{algorithm}
594-freorder-blocks-and-partition -freorder-functions
595-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
596-frounding-math -fsave-optimization-record
597-fsched2-use-superblocks -fsched-pressure
598-fsched-spec-load -fsched-spec-load-dangerous
599-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
600-fsched-group-heuristic -fsched-critical-path-heuristic
601-fsched-spec-insn-heuristic -fsched-rank-heuristic
602-fsched-last-insn-heuristic -fsched-dep-count-heuristic
603-fschedule-fusion
604-fschedule-insns -fschedule-insns2 -fsection-anchors
605-fselective-scheduling -fselective-scheduling2
606-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
607-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
608-fsignaling-nans
609-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
610-fsplit-paths
611-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
612-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
613-fthread-jumps -ftracer -ftree-bit-ccp
614-ftree-builtin-call-dce -ftree-ccp -ftree-ch
615-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
616-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
617-ftree-loop-if-convert -ftree-loop-im
618-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
619-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
620-ftree-loop-vectorize
621-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
622-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
623-ftree-switch-conversion -ftree-tail-merge
624-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
625-funconstrained-commons -funit-at-a-time -funroll-all-loops
626-funroll-loops -funsafe-math-optimizations -funswitch-loops
627-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
628-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
629--param @var{name}=@var{value}
630-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
631
632@item Program Instrumentation Options
633@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede
AA
634@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
635-fprofile-abs-path
636-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
637-fprofile-info-section -fprofile-info-section=@var{name}
638-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
639-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
640-fprofile-exclude-files=@var{regex}
641-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
642-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
643-fsanitize-trap -fsanitize-trap=@var{style}
644-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
645-fsanitize-undefined-trap-on-error -fbounds-check
646-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
647-fharden-compares -fharden-conditional-branches
551935d1
AO
648-fharden-control-flow-redundancy -fhardcfr-skip-leaf
649-fhardcfr-check-exceptions -fhardcfr-check-returning-calls
650-fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
43b72ede
AA
651-fstack-protector -fstack-protector-all -fstack-protector-strong
652-fstack-protector-explicit -fstack-check
653-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
654-fno-stack-limit -fsplit-stack
655-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
656-fvtv-counts -fvtv-debug
657-finstrument-functions -finstrument-functions-once
658-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
659-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
b42dd137
M
660-fprofile-prefix-map=@var{old}=@var{new}
661-fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}}
d77de738
ML
662
663@item Preprocessor Options
664@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
665@gccoptlist{-A@var{question}=@var{answer}
666-A-@var{question}@r{[}=@var{answer}@r{]}
667-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
668-dD -dI -dM -dN -dU
669-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
670-fexec-charset=@var{charset} -fextended-identifiers
671-finput-charset=@var{charset} -flarge-source-files
672-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
673-fno-canonical-system-headers -fpch-deps -fpch-preprocess
674-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
675-fwide-exec-charset=@var{charset} -fworking-directory
676-H -imacros @var{file} -include @var{file}
677-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
678-no-integrated-cpp -P -pthread -remap
679-traditional -traditional-cpp -trigraphs
680-U@var{macro} -undef
d77de738
ML
681-Wp,@var{option} -Xpreprocessor @var{option}}
682
683@item Assembler Options
684@xref{Assembler Options,,Passing Options to the Assembler}.
685@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
686
687@item Linker Options
688@xref{Link Options,,Options for Linking}.
43b72ede
AA
689@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
690-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
691-e @var{entry} --entry=@var{entry}
692-pie -pthread -r -rdynamic
693-s -static -static-pie -static-libgcc -static-libstdc++
694-static-libasan -static-libtsan -static-liblsan -static-libubsan
695-shared -shared-libgcc -symbolic
696-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
697-u @var{symbol} -z @var{keyword}}
698
699@item Directory Options
700@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
701@gccoptlist{-B@var{prefix} -I@var{dir} -I-
702-idirafter @var{dir}
703-imacros @var{file} -imultilib @var{dir}
704-iplugindir=@var{dir} -iprefix @var{file}
705-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
706-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
707-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
708-nostdinc -nostdinc++ --sysroot=@var{dir}}
709
710@item Code Generation Options
711@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
712@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
713-ffixed-@var{reg} -fexceptions
714-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
715-fasynchronous-unwind-tables
716-fno-gnu-unique
717-finhibit-size-directive -fcommon -fno-ident
718-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
719-fno-jump-tables -fno-bit-tests
720-frecord-gcc-switches
721-freg-struct-return -fshort-enums -fshort-wchar
722-fverbose-asm -fpack-struct[=@var{n}]
723-fleading-underscore -ftls-model=@var{model}
724-fstack-reuse=@var{reuse_level}
28d8c680
AB
725-ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
726-ftrapv -fwrapv
43b72ede 727-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
728-fstrict-volatile-bitfields -fsync-libcalls}
729
730@item Developer Options
731@xref{Developer Options,,GCC Developer Options}.
43b72ede 732@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 733-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
734-fchecking -fchecking=@var{n}
735-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
736-fdisable-ipa-@var{pass_name}
737-fdisable-rtl-@var{pass_name}
738-fdisable-rtl-@var{pass-name}=@var{range-list}
739-fdisable-tree-@var{pass_name}
740-fdisable-tree-@var{pass-name}=@var{range-list}
741-fdump-debug -fdump-earlydebug
742-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
743-fdump-final-insns@r{[}=@var{file}@r{]}
744-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
745-fdump-lang-all
746-fdump-lang-@var{switch}
747-fdump-lang-@var{switch}-@var{options}
748-fdump-lang-@var{switch}-@var{options}=@var{filename}
749-fdump-passes
750-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
751-fdump-statistics
752-fdump-tree-all
753-fdump-tree-@var{switch}
754-fdump-tree-@var{switch}-@var{options}
755-fdump-tree-@var{switch}-@var{options}=@var{filename}
756-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
757-fenable-@var{kind}-@var{pass}
758-fenable-@var{kind}-@var{pass}=@var{range-list}
759-fira-verbose=@var{n}
760-flto-report -flto-report-wpa -fmem-report-wpa
761-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
762-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
763-fmultiflags -fprofile-report
764-frandom-seed=@var{string} -fsched-verbose=@var{n}
765-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
766-fstats -fstack-usage -ftime-report -ftime-report-details
767-fvar-tracking-assignments-toggle -gtoggle
768-print-file-name=@var{library} -print-libgcc-file-name
769-print-multi-directory -print-multi-lib -print-multi-os-directory
770-print-prog-name=@var{program} -print-search-dirs -Q
771-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
772-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
773
774@item Machine-Dependent Options
775@xref{Submodel Options,,Machine-Dependent Options}.
776@c This list is ordered alphanumerically by subsection name.
777@c Try and put the significant identifier (CPU or system) first,
778@c so users have a clue at guessing where the ones they want will be.
779
780@emph{AArch64 Options}
43b72ede
AA
781@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
782-mgeneral-regs-only
783-mcmodel=tiny -mcmodel=small -mcmodel=large
784-mstrict-align -mno-strict-align
785-momit-leaf-frame-pointer
786-mtls-dialect=desc -mtls-dialect=traditional
787-mtls-size=@var{size}
788-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
789-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
790-mpc-relative-literal-loads
791-msign-return-address=@var{scope}
d77de738 792-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
43b72ede
AA
793+@var{b-key}]|@var{bti}
794-mharden-sls=@var{opts}
795-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
796-moverride=@var{string} -mverbose-cost-dump
797-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
798-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
d77de738
ML
799-moutline-atomics }
800
801@emph{Adapteva Epiphany Options}
43b72ede
AA
802@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
803-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
804-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
805-mround-nearest -mlong-calls -mshort-calls -msmall16
806-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
807-msplit-vecmove-early -m1reg-@var{reg}}
808
809@emph{AMD GCN Options}
810@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
811
812@emph{ARC Options}
43b72ede
AA
813@gccoptlist{-mbarrel-shifter -mjli-always
814-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
815-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
816-mea -mno-mpy -mmul32x16 -mmul64 -matomic
817-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
818-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
819-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
820-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
821-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
822-mvolatile-cache -mtp-regno=@var{regno}
823-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
824-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
825-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
826-mlra-priority-compact -mlra-priority-noncompact -mmillicode
827-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
828-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
829-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
830-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
831
832@emph{ARM Options}
43b72ede
AA
833@gccoptlist{-mapcs-frame -mno-apcs-frame
834-mabi=@var{name}
835-mapcs-stack-check -mno-apcs-stack-check
836-mapcs-reentrant -mno-apcs-reentrant
837-mgeneral-regs-only
838-msched-prolog -mno-sched-prolog
839-mlittle-endian -mbig-endian
840-mbe8 -mbe32
841-mfloat-abi=@var{name}
d77de738 842-mfp16-format=@var{name}
43b72ede
AA
843-mthumb-interwork -mno-thumb-interwork
844-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
845-mtune=@var{name} -mprint-tune-info
846-mstructure-size-boundary=@var{n}
847-mabort-on-noreturn
848-mlong-calls -mno-long-calls
849-msingle-pic-base -mno-single-pic-base
850-mpic-register=@var{reg}
851-mnop-fun-dllimport
852-mpoke-function-name
853-mthumb -marm -mflip-thumb
854-mtpcs-frame -mtpcs-leaf-frame
855-mcaller-super-interworking -mcallee-super-interworking
856-mtp=@var{name} -mtls-dialect=@var{dialect}
857-mword-relocations
858-mfix-cortex-m3-ldrd
859-mfix-cortex-a57-aes-1742098
860-mfix-cortex-a72-aes-1655431
861-munaligned-access
862-mneon-for-64bits
863-mslow-flash-data
864-masm-syntax-unified
865-mrestrict-it
866-mverbose-cost-dump
867-mpure-code
868-mcmse
869-mfix-cmse-cve-2021-35465
870-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
871-mfdpic
14fab5fb
AC
872-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
873[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
874
875@emph{AVR Options}
43b72ede
AA
876@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
877-mbranch-cost=@var{cost}
878-mcall-prologues -mgas-isr-prologues -mint8
879-mdouble=@var{bits} -mlong-double=@var{bits}
880-mn_flash=@var{size} -mno-interrupts
881-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
882-mfract-convert-truncate
883-mshort-calls -nodevicelib -nodevicespecs
d77de738
ML
884-Waddr-space-convert -Wmisspelled-isr}
885
886@emph{Blackfin Options}
43b72ede
AA
887@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
888-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
889-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
890-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
891-mno-id-shared-library -mshared-library-id=@var{n}
892-mleaf-id-shared-library -mno-leaf-id-shared-library
893-msep-data -mno-sep-data -mlong-calls -mno-long-calls
894-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
895-micplb}
896
897@emph{C6X Options}
43b72ede 898@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
899-msim -msdata=@var{sdata-type}}
900
901@emph{CRIS Options}
902@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
903-mtune=@var{cpu} -mmax-stack-frame=@var{n}
904-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
905-mstack-align -mdata-align -mconst-align
906-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
907-melf -maout -sim -sim2
d77de738
ML
908-mmul-bug-workaround -mno-mul-bug-workaround}
909
910@emph{C-SKY Options}
43b72ede
AA
911@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
912-mbig-endian -EB -mlittle-endian -EL
913-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
914-mfloat-abi=@var{name}
915-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
916-mdsp -medsp -mvdsp
917-mdiv -msmart -mhigh-registers -manchor
918-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
919-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
920
921@emph{Darwin Options}
43b72ede
AA
922@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
923-arch_only -bind_at_load -bundle -bundle_loader
924-client_name -compatibility_version -current_version
925-dead_strip
926-dependency-file -dylib_file -dylinker_install_name
927-dynamic -dynamiclib -exported_symbols_list
928-filelist -flat_namespace -force_cpusubtype_ALL
929-force_flat_namespace -headerpad_max_install_names
930-iframework
931-image_base -init -install_name -keep_private_externs
932-multi_module -multiply_defined -multiply_defined_unused
47b634a3 933-noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
43b72ede
AA
934-nofixprebinding -nomultidefs -noprebind -noseglinkedit
935-pagezero_size -prebind -prebind_all_twolevel_modules
936-private_bundle -read_only_relocs -sectalign
937-sectobjectsymbols -whyload -seg1addr
938-sectcreate -sectobjectsymbols -sectorder
939-segaddr -segs_read_only_addr -segs_read_write_addr
940-seg_addr_table -seg_addr_table_filename -seglinkedit
941-segprot -segs_read_only_addr -segs_read_write_addr
942-single_module -static -sub_library -sub_umbrella
943-twolevel_namespace -umbrella -undefined
944-unexported_symbols_list -weak_reference_mismatches
945-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
946-mkernel -mone-byte-bool}
947
948@emph{DEC Alpha Options}
43b72ede
AA
949@gccoptlist{-mno-fp-regs -msoft-float
950-mieee -mieee-with-inexact -mieee-conformant
951-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
952-mtrap-precision=@var{mode} -mbuild-constants
953-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
954-mbwx -mmax -mfix -mcix
955-mfloat-vax -mfloat-ieee
956-mexplicit-relocs -msmall-data -mlarge-data
957-msmall-text -mlarge-text
d77de738
ML
958-mmemory-latency=@var{time}}
959
960@emph{eBPF Options}
9cbf4286 961@gccoptlist{-mbig-endian -mlittle-endian
77d0f9ec 962-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
14dab1a1 963-mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
9cbf4286 964-masm=@var{dialect}}
d77de738
ML
965
966@emph{FR30 Options}
967@gccoptlist{-msmall-model -mno-lsim}
968
969@emph{FT32 Options}
970@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
971
972@emph{FRV Options}
43b72ede
AA
973@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
974-mhard-float -msoft-float
975-malloc-cc -mfixed-cc -mdword -mno-dword
976-mdouble -mno-double
977-mmedia -mno-media -mmuladd -mno-muladd
978-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
979-mlinked-fp -mlong-calls -malign-labels
980-mlibrary-pic -macc-4 -macc-8
981-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
982-moptimize-membar -mno-optimize-membar
983-mscc -mno-scc -mcond-exec -mno-cond-exec
984-mvliw-branch -mno-vliw-branch
985-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
986-mno-nested-cond-exec -mtomcat-stats
987-mTLS -mtls
d77de738
ML
988-mcpu=@var{cpu}}
989
990@emph{GNU/Linux Options}
43b72ede 991@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
992-tno-android-cc -tno-android-ld}
993
994@emph{H8/300 Options}
995@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
996
997@emph{HPPA Options}
43b72ede
AA
998@gccoptlist{-march=@var{architecture-type}
999-matomic-libcalls -mbig-switch
1000-mcaller-copies -mdisable-fpregs -mdisable-indexing
1001-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
1002-mfixed-range=@var{register-range}
1003-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1004-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1005-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1006-mno-jump-in-delay -mno-long-load-store
1007-mno-portable-runtime -mno-soft-float
1008-mno-space-regs -msoft-float -mpa-risc-1-0
1009-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1010-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
1011-munix=@var{unix-std} -nolibdld -static -threads}
1012
1013@emph{IA-64 Options}
43b72ede
AA
1014@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1015-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1016-mconstant-gp -mauto-pic -mfused-madd
1017-minline-float-divide-min-latency
1018-minline-float-divide-max-throughput
1019-mno-inline-float-divide
1020-minline-int-divide-min-latency
1021-minline-int-divide-max-throughput
1022-mno-inline-int-divide
1023-minline-sqrt-min-latency -minline-sqrt-max-throughput
1024-mno-inline-sqrt
1025-mdwarf2-asm -mearly-stop-bits
1026-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1027-mtune=@var{cpu-type} -milp32 -mlp64
1028-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1029-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1030-msched-spec-ldc -msched-spec-control-ldc
1031-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1032-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1033-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1034-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1035
1036@emph{LM32 Options}
43b72ede 1037@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1038-msign-extend-enabled -muser-enabled}
1039
1040@emph{LoongArch Options}
43b72ede 1041@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
bb4a8198
YY
1042-mfpu=@var{fpu-type} -msimd=@var{simd-type}
1043-msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
43b72ede
AA
1044-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1045-mcond-move-int -mno-cond-move-int
1046-mcond-move-float -mno-cond-move-float
1047-memcpy -mno-memcpy -mstrict-align -mno-strict-align
1048-mmax-inline-memcpy-size=@var{n}
e1b1cba1 1049-mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
43b72ede 1050-mdirect-extern-access -mno-direct-extern-access
fe23a2ff 1051-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as}
d77de738
ML
1052
1053@emph{M32R/D Options}
43b72ede
AA
1054@gccoptlist{-m32r2 -m32rx -m32r
1055-mdebug
1056-malign-loops -mno-align-loops
1057-missue-rate=@var{number}
1058-mbranch-cost=@var{number}
1059-mmodel=@var{code-size-model-type}
1060-msdata=@var{sdata-type}
1061-mno-flush-func -mflush-func=@var{name}
1062-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1063-G @var{num}}
1064
1065@emph{M32C Options}
1066@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1067
1068@emph{M680x0 Options}
43b72ede
AA
1069@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1070-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1071-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1072-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1073-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1074-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1075-malign-int -mstrict-align -msep-data -mno-sep-data
1076-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1077-mxgot -mno-xgot -mlong-jump-table-offsets}
1078
1079@emph{MCore Options}
43b72ede
AA
1080@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1081-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1082-m4byte-functions -mno-4byte-functions -mcallgraph-data
1083-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1084-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1085
d77de738 1086@emph{MicroBlaze Options}
43b72ede
AA
1087@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1088-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1089-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1090-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1091-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1092-mpic-data-is-text-relative}
1093
1094@emph{MIPS Options}
43b72ede
AA
1095@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1096-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1097-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1098-mips16 -mno-mips16 -mflip-mips16
1099-minterlink-compressed -mno-interlink-compressed
1100-minterlink-mips16 -mno-interlink-mips16
1101-mabi=@var{abi} -mabicalls -mno-abicalls
1102-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1103-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1104-mno-float -msingle-float -mdouble-float
1105-modd-spreg -mno-odd-spreg
1106-mabs=@var{mode} -mnan=@var{encoding}
1107-mdsp -mno-dsp -mdspr2 -mno-dspr2
1108-mmcu -mmno-mcu
1109-meva -mno-eva
1110-mvirt -mno-virt
1111-mxpa -mno-xpa
1112-mcrc -mno-crc
1113-mginv -mno-ginv
1114-mmicromips -mno-micromips
1115-mmsa -mno-msa
1116-mloongson-mmi -mno-loongson-mmi
1117-mloongson-ext -mno-loongson-ext
1118-mloongson-ext2 -mno-loongson-ext2
1119-mfpu=@var{fpu-type}
1120-msmartmips -mno-smartmips
1121-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1122-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1123-mlong64 -mlong32 -msym32 -mno-sym32
1124-G@var{num} -mlocal-sdata -mno-local-sdata
1125-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1126-membedded-data -mno-embedded-data
1127-muninit-const-in-rodata -mno-uninit-const-in-rodata
1128-mcode-readable=@var{setting}
1129-msplit-addresses -mno-split-addresses
1130-mexplicit-relocs -mno-explicit-relocs
1131-mcheck-zero-division -mno-check-zero-division
1132-mdivide-traps -mdivide-breaks
1133-mload-store-pairs -mno-load-store-pairs
1134-munaligned-access -mno-unaligned-access
1135-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1136-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1137-mfix-24k -mno-fix-24k
1138-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1139-mfix-r5900 -mno-fix-r5900
1140-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1141-mfix-vr4120 -mno-fix-vr4120
1142-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1143-mflush-func=@var{func} -mno-flush-func
1144-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1145-mcompact-branches=@var{policy}
1146-mfp-exceptions -mno-fp-exceptions
1147-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1148-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1149-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1150-mframe-header-opt -mno-frame-header-opt}
1151
1152@emph{MMIX Options}
43b72ede
AA
1153@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1154-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1155-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1156-mno-base-addresses -msingle-exit -mno-single-exit}
1157
1158@emph{MN10300 Options}
43b72ede
AA
1159@gccoptlist{-mmult-bug -mno-mult-bug
1160-mno-am33 -mam33 -mam33-2 -mam34
1161-mtune=@var{cpu-type}
1162-mreturn-pointer-on-d0
d77de738
ML
1163-mno-crt0 -mrelax -mliw -msetlb}
1164
1165@emph{Moxie Options}
1166@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1167
1168@emph{MSP430 Options}
43b72ede
AA
1169@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1170-mwarn-mcu
1171-mcode-region= -mdata-region=
1172-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1173-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1174
1175@emph{NDS32 Options}
43b72ede
AA
1176@gccoptlist{-mbig-endian -mlittle-endian
1177-mreduced-regs -mfull-regs
1178-mcmov -mno-cmov
1179-mext-perf -mno-ext-perf
1180-mext-perf2 -mno-ext-perf2
1181-mext-string -mno-ext-string
1182-mv3push -mno-v3push
1183-m16bit -mno-16bit
1184-misr-vector-size=@var{num}
1185-mcache-block-size=@var{num}
1186-march=@var{arch}
1187-mcmodel=@var{code-model}
d77de738
ML
1188-mctor-dtor -mrelax}
1189
1190@emph{Nios II Options}
43b72ede
AA
1191@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1192-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1193-mel -meb
1194-mno-bypass-cache -mbypass-cache
1195-mno-cache-volatile -mcache-volatile
1196-mno-fast-sw-div -mfast-sw-div
1197-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1198-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1199-mcustom-fpu-cfg=@var{name}
1200-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
d77de738
ML
1201-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1202
1203@emph{Nvidia PTX Options}
1204@gccoptlist{-m64 -mmainkernel -moptimize}
1205
1206@emph{OpenRISC Options}
43b72ede
AA
1207@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1208-msoft-mul -msoft-div
1209-msoft-float -mhard-float -mdouble-float -munordered-float
1210-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1211-mcmodel=@var{code-model}}
1212
1213@emph{PDP-11 Options}
43b72ede
AA
1214@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1215-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1216-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1217
d77de738
ML
1218@emph{PowerPC Options}
1219See RS/6000 and PowerPC Options.
1220
1221@emph{PRU Options}
43b72ede 1222@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1223-mabi=@var{variant}}
d77de738
ML
1224
1225@emph{RISC-V Options}
43b72ede
AA
1226@gccoptlist{-mbranch-cost=@var{N-instruction}
1227-mplt -mno-plt
1228-mabi=@var{ABI-string}
1229-mfdiv -mno-fdiv
1230-mdiv -mno-div
1231-misa-spec=@var{ISA-spec-string}
1232-march=@var{ISA-string}
1233-mtune=@var{processor-string}
1234-mpreferred-stack-boundary=@var{num}
1235-msmall-data-limit=@var{N-bytes}
1236-msave-restore -mno-save-restore
1237-mshorten-memrefs -mno-shorten-memrefs
1238-mstrict-align -mno-strict-align
1239-mcmodel=medlow -mcmodel=medany
1240-mexplicit-relocs -mno-explicit-relocs
1241-mrelax -mno-relax
1242-mriscv-attribute -mno-riscv-attribute
1243-malign-data=@var{type}
1244-mbig-endian -mlittle-endian
1245-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1246-mstack-protector-guard-offset=@var{offset}
f797260a 1247-mcsr-check -mno-csr-check
df48285b 1248-minline-atomics -mno-inline-atomics
949f1ccf
CM
1249-minline-strlen -mno-inline-strlen
1250-minline-strcmp -mno-inline-strcmp
1251-minline-strncmp -mno-inline-strncmp}
d77de738
ML
1252
1253@emph{RL78 Options}
43b72ede
AA
1254@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1255-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1256-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1257
1258@emph{RS/6000 and PowerPC Options}
43b72ede
AA
1259@gccoptlist{-mcpu=@var{cpu-type}
1260-mtune=@var{cpu-type}
1261-mcmodel=@var{code-model}
1262-mpowerpc64
1263-maltivec -mno-altivec
1264-mpowerpc-gpopt -mno-powerpc-gpopt
1265-mpowerpc-gfxopt -mno-powerpc-gfxopt
1266-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1267-mfprnd -mno-fprnd
1268-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1269-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1270-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1271-malign-power -malign-natural
1272-msoft-float -mhard-float -mmultiple -mno-multiple
1273-mupdate -mno-update
1274-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1275-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1276-mstrict-align -mno-strict-align -mrelocatable
1277-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1278-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1279-mdynamic-no-pic -mswdiv -msingle-pic-base
1280-mprioritize-restricted-insns=@var{priority}
1281-msched-costly-dep=@var{dependence_type}
1282-minsert-sched-nops=@var{scheme}
1283-mcall-aixdesc -mcall-eabi -mcall-freebsd
1284-mcall-linux -mcall-netbsd -mcall-openbsd
1285-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1286-mtraceback=@var{traceback_type}
1287-maix-struct-return -msvr4-struct-return
1288-mabi=@var{abi-type} -msecure-plt -mbss-plt
1289-mlongcall -mno-longcall -mpltseq -mno-pltseq
1290-mblock-move-inline-limit=@var{num}
1291-mblock-compare-inline-limit=@var{num}
1292-mblock-compare-inline-loop-limit=@var{num}
1293-mno-block-ops-unaligned-vsx
1294-mstring-compare-inline-limit=@var{num}
1295-misel -mno-isel
1296-mvrsave -mno-vrsave
1297-mmulhw -mno-mulhw
1298-mdlmzb -mno-dlmzb
1299-mprototype -mno-prototype
1300-msim -mmvme -mads -myellowknife -memb -msdata
1301-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1302-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1303-mno-recip-precision
1304-mveclibabi=@var{type} -mfriz -mno-friz
1305-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1306-msave-toc-indirect -mno-save-toc-indirect
1307-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector
1308-mcrypto -mno-crypto -mhtm -mno-htm
1309-mquad-memory -mno-quad-memory
1310-mquad-memory-atomic -mno-quad-memory-atomic
1311-mcompat-align-parm -mno-compat-align-parm
1312-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1313-mgnu-attribute -mno-gnu-attribute
1314-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1315-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1316-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1317-mprivileged -mno-privileged}
1318
1319@emph{RX Options}
43b72ede
AA
1320@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1321-mcpu=
1322-mbig-endian-data -mlittle-endian-data
1323-msmall-data
1324-msim -mno-sim
1325-mas100-syntax -mno-as100-syntax
1326-mrelax
1327-mmax-constant-size=
1328-mint-register=
1329-mpid
1330-mallow-string-insns -mno-allow-string-insns
1331-mjsr
1332-mno-warn-multiple-fast-interrupts
d77de738
ML
1333-msave-acc-in-interrupts}
1334
1335@emph{S/390 and zSeries Options}
43b72ede
AA
1336@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1337-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1338-mlong-double-64 -mlong-double-128
1339-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1340-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1341-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1342-mhtm -mvx -mzvector
1343-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1344-mfused-madd -mno-fused-madd
1345-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1346-mhotpatch=@var{halfwords},@var{halfwords}}
1347
d77de738 1348@emph{SH Options}
43b72ede
AA
1349@gccoptlist{-m1 -m2 -m2e
1350-m2a-nofpu -m2a-single-only -m2a-single -m2a
1351-m3 -m3e
1352-m4-nofpu -m4-single-only -m4-single -m4
1353-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1354-mb -ml -mdalign -mrelax
1355-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1356-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1357-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1358-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1359-maccumulate-outgoing-args
1360-matomic-model=@var{atomic-model}
1361-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1362-mcbranch-force-delay-slot
1363-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1364-mpretend-cmove -mtas}
1365
1366@emph{Solaris 2 Options}
43b72ede 1367@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1368-pthreads}
1369
1370@emph{SPARC Options}
43b72ede
AA
1371@gccoptlist{-mcpu=@var{cpu-type}
1372-mtune=@var{cpu-type}
1373-mcmodel=@var{code-model}
1374-mmemory-model=@var{mem-model}
1375-m32 -m64 -mapp-regs -mno-app-regs
1376-mfaster-structs -mno-faster-structs -mflat -mno-flat
1377-mfpu -mno-fpu -mhard-float -msoft-float
1378-mhard-quad-float -msoft-quad-float
1379-mstack-bias -mno-stack-bias
1380-mstd-struct-return -mno-std-struct-return
1381-munaligned-doubles -mno-unaligned-doubles
1382-muser-mode -mno-user-mode
1383-mv8plus -mno-v8plus -mvis -mno-vis
1384-mvis2 -mno-vis2 -mvis3 -mno-vis3
1385-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1386-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1387-mpopc -mno-popc -msubxc -mno-subxc
1388-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
d77de738
ML
1389-mlra -mno-lra}
1390
1391@emph{System V Options}
1392@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1393
1394@emph{V850 Options}
43b72ede
AA
1395@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1396-mprolog-function -mno-prolog-function -mspace
1397-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1398-mapp-regs -mno-app-regs
1399-mdisable-callt -mno-disable-callt
1400-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1401-mv850e -mv850 -mv850e3v5
1402-mloop
1403-mrelax
1404-mlong-jumps
1405-msoft-float
1406-mhard-float
1407-mgcc-abi
1408-mrh850-abi
d77de738
ML
1409-mbig-switch}
1410
1411@emph{VAX Options}
1412@gccoptlist{-mg -mgnu -munix -mlra}
1413
1414@emph{Visium Options}
43b72ede 1415@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1416-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1417
1418@emph{VMS Options}
43b72ede 1419@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1420-mpointer-size=@var{size}}
1421
1422@emph{VxWorks Options}
b6f4b000 1423@gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
d77de738
ML
1424-Xbind-lazy -Xbind-now}
1425
1426@emph{x86 Options}
43b72ede
AA
1427@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1428-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1429-mfpmath=@var{unit}
1430-masm=@var{dialect} -mno-fancy-math-387
1431-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1432-mno-wide-multiply -mrtd -malign-double
1433-mpreferred-stack-boundary=@var{num}
1434-mincoming-stack-boundary=@var{num}
1435-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1436-mrecip -mrecip=@var{opt}
1437-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
ad5b757d 1438-mpartial-vector-fp-math
43b72ede
AA
1439-mmove-max=@var{bits} -mstore-max=@var{bits}
1440-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1441-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1442-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1443-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1444-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1445-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1446-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1447-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1448-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1449-mavx512vbmi2 -mavx512bf16 -menqcmd
1450-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1451-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1452-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1453-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1454-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
e686416b 1455-mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
2f8f7ee2 1456-musermsr -mavx10.1 -mavx10.1-256 -mavx10.1-512
43b72ede
AA
1457-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1458-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1459-mkl -mwidekl
1460-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1461-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1462-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1463-mregparm=@var{num} -msseregparm
1464-mveclibabi=@var{type} -mvect8-ret-in-mem
1465-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1466-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1467-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1468-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1469-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1470-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1471-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1472-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1473-mstack-protector-guard-reg=@var{reg}
1474-mstack-protector-guard-offset=@var{offset}
1475-mstack-protector-guard-symbol=@var{symbol}
1476-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1477-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1478-mindirect-branch-register -mharden-sls=@var{choice}
1479-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1480-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1481
1482@emph{x86 Windows Options}
453cb585 1483@gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll
43b72ede 1484-mnop-fun-dllimport -mthread
d77de738
ML
1485-municode -mwin32 -mwindows -fno-set-stack-executable}
1486
1487@emph{Xstormy16 Options}
1488@gccoptlist{-msim}
1489
1490@emph{Xtensa Options}
43b72ede
AA
1491@gccoptlist{-mconst16 -mno-const16
1492-mfused-madd -mno-fused-madd
1493-mforce-no-pic
1494-mserialize-volatile -mno-serialize-volatile
1495-mtext-section-literals -mno-text-section-literals
1496-mauto-litpools -mno-auto-litpools
1497-mtarget-align -mno-target-align
1498-mlongcalls -mno-longcalls
1499-mabi=@var{abi-type}
675b390e
MF
1500-mextra-l32r-costs=@var{cycles}
1501-mstrict-align -mno-strict-align}
d77de738
ML
1502
1503@emph{zSeries Options}
1504See S/390 and zSeries Options.
1505@end table
1506
1507
1508@node Overall Options
1509@section Options Controlling the Kind of Output
1510
1511Compilation can involve up to four stages: preprocessing, compilation
1512proper, assembly and linking, always in that order. GCC is capable of
1513preprocessing and compiling several files either into several
1514assembler input files, or into one assembler input file; then each
1515assembler input file produces an object file, and linking combines all
1516the object files (those newly compiled, and those specified as input)
1517into an executable file.
1518
1519@cindex file name suffix
1520For any given input file, the file name suffix determines what kind of
1521compilation is done:
1522
1523@table @gcctabopt
1524@item @var{file}.c
1525C source code that must be preprocessed.
1526
1527@item @var{file}.i
1528C source code that should not be preprocessed.
1529
1530@item @var{file}.ii
1531C++ source code that should not be preprocessed.
1532
1533@item @var{file}.m
1534Objective-C source code. Note that you must link with the @file{libobjc}
1535library to make an Objective-C program work.
1536
1537@item @var{file}.mi
1538Objective-C source code that should not be preprocessed.
1539
1540@item @var{file}.mm
1541@itemx @var{file}.M
1542Objective-C++ source code. Note that you must link with the @file{libobjc}
1543library to make an Objective-C++ program work. Note that @samp{.M} refers
1544to a literal capital M@.
1545
1546@item @var{file}.mii
1547Objective-C++ source code that should not be preprocessed.
1548
1549@item @var{file}.h
1550C, C++, Objective-C or Objective-C++ header file to be turned into a
1551precompiled header (default), or C, C++ header file to be turned into an
1552Ada spec (via the @option{-fdump-ada-spec} switch).
1553
1554@item @var{file}.cc
1555@itemx @var{file}.cp
1556@itemx @var{file}.cxx
1557@itemx @var{file}.cpp
1558@itemx @var{file}.CPP
1559@itemx @var{file}.c++
1560@itemx @var{file}.C
1561C++ source code that must be preprocessed. Note that in @samp{.cxx},
1562the last two letters must both be literally @samp{x}. Likewise,
1563@samp{.C} refers to a literal capital C@.
1564
1565@item @var{file}.mm
1566@itemx @var{file}.M
1567Objective-C++ source code that must be preprocessed.
1568
1569@item @var{file}.mii
1570Objective-C++ source code that should not be preprocessed.
1571
1572@item @var{file}.hh
1573@itemx @var{file}.H
1574@itemx @var{file}.hp
1575@itemx @var{file}.hxx
1576@itemx @var{file}.hpp
1577@itemx @var{file}.HPP
1578@itemx @var{file}.h++
1579@itemx @var{file}.tcc
1580C++ header file to be turned into a precompiled header or Ada spec.
1581
1582@item @var{file}.f
1583@itemx @var{file}.for
1584@itemx @var{file}.ftn
1585Fixed form Fortran source code that should not be preprocessed.
1586
1587@item @var{file}.F
1588@itemx @var{file}.FOR
1589@itemx @var{file}.fpp
1590@itemx @var{file}.FPP
1591@itemx @var{file}.FTN
1592Fixed form Fortran source code that must be preprocessed (with the traditional
1593preprocessor).
1594
1595@item @var{file}.f90
1596@itemx @var{file}.f95
1597@itemx @var{file}.f03
1598@itemx @var{file}.f08
1599Free form Fortran source code that should not be preprocessed.
1600
1601@item @var{file}.F90
1602@itemx @var{file}.F95
1603@itemx @var{file}.F03
1604@itemx @var{file}.F08
1605Free form Fortran source code that must be preprocessed (with the
1606traditional preprocessor).
1607
1608@item @var{file}.go
1609Go source code.
1610
1611@item @var{file}.d
1612D source code.
1613
1614@item @var{file}.di
1615D interface file.
1616
1617@item @var{file}.dd
1618D documentation code (Ddoc).
1619
1620@item @var{file}.ads
1621Ada source code file that contains a library unit declaration (a
1622declaration of a package, subprogram, or generic, or a generic
1623instantiation), or a library unit renaming declaration (a package,
1624generic, or subprogram renaming declaration). Such files are also
1625called @dfn{specs}.
1626
1627@item @var{file}.adb
1628Ada source code file containing a library unit body (a subprogram or
1629package body). Such files are also called @dfn{bodies}.
1630
1631@c GCC also knows about some suffixes for languages not yet included:
1632@c Ratfor:
1633@c @var{file}.r
1634
1635@item @var{file}.s
1636Assembler code.
1637
1638@item @var{file}.S
1639@itemx @var{file}.sx
1640Assembler code that must be preprocessed.
1641
1642@item @var{other}
1643An object file to be fed straight into linking.
1644Any file name with no recognized suffix is treated this way.
1645@end table
1646
1647@opindex x
1648You can specify the input language explicitly with the @option{-x} option:
1649
1650@table @gcctabopt
1651@item -x @var{language}
1652Specify explicitly the @var{language} for the following input files
1653(rather than letting the compiler choose a default based on the file
1654name suffix). This option applies to all following input files until
1655the next @option{-x} option. Possible values for @var{language} are:
1656@smallexample
1657c c-header cpp-output
1658c++ c++-header c++-system-header c++-user-header c++-cpp-output
1659objective-c objective-c-header objective-c-cpp-output
1660objective-c++ objective-c++-header objective-c++-cpp-output
1661assembler assembler-with-cpp
1662ada
1663d
1664f77 f77-cpp-input f95 f95-cpp-input
1665go
1666@end smallexample
1667
1668@item -x none
1669Turn off any specification of a language, so that subsequent files are
1670handled according to their file name suffixes (as they are if @option{-x}
1671has not been used at all).
1672@end table
1673
1674If you only want some of the stages of compilation, you can use
1675@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1676one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1677@command{gcc} is to stop. Note that some combinations (for example,
1678@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1679
1680@table @gcctabopt
d77de738 1681@opindex c
ddf6fe37 1682@item -c
d77de738
ML
1683Compile or assemble the source files, but do not link. The linking
1684stage simply is not done. The ultimate output is in the form of an
1685object file for each source file.
1686
1687By default, the object file name for a source file is made by replacing
1688the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1689
1690Unrecognized input files, not requiring compilation or assembly, are
1691ignored.
1692
d77de738 1693@opindex S
ddf6fe37 1694@item -S
d77de738
ML
1695Stop after the stage of compilation proper; do not assemble. The output
1696is in the form of an assembler code file for each non-assembler input
1697file specified.
1698
1699By default, the assembler file name for a source file is made by
1700replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1701
1702Input files that don't require compilation are ignored.
1703
d77de738 1704@opindex E
ddf6fe37 1705@item -E
d77de738
ML
1706Stop after the preprocessing stage; do not run the compiler proper. The
1707output is in the form of preprocessed source code, which is sent to the
1708standard output.
1709
1710Input files that don't require preprocessing are ignored.
1711
1712@cindex output file option
d77de738 1713@opindex o
ddf6fe37 1714@item -o @var{file}
d77de738
ML
1715Place the primary output in file @var{file}. This applies to whatever
1716sort of output is being produced, whether it be an executable file, an
1717object file, an assembler file or preprocessed C code.
1718
1719If @option{-o} is not specified, the default is to put an executable
1720file in @file{a.out}, the object file for
1721@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1722assembler file in @file{@var{source}.s}, a precompiled header file in
1723@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1724standard output.
1725
1726Though @option{-o} names only the primary output, it also affects the
1727naming of auxiliary and dump outputs. See the examples below. Unless
1728overridden, both auxiliary outputs and dump outputs are placed in the
1729same directory as the primary output. In auxiliary outputs, the suffix
1730of the input file is replaced with that of the auxiliary output file
1731type; in dump outputs, the suffix of the dump file is appended to the
1732input file suffix. In compilation commands, the base name of both
1733auxiliary and dump outputs is that of the primary output; in compile and
1734link commands, the primary output name, minus the executable suffix, is
1735combined with the input file name. If both share the same base name,
1736disregarding the suffix, the result of the combination is that base
1737name, otherwise, they are concatenated, separated by a dash.
1738
1739@smallexample
1740gcc -c foo.c ...
1741@end smallexample
1742
1743will use @file{foo.o} as the primary output, and place aux outputs and
1744dumps next to it, e.g., aux file @file{foo.dwo} for
1745@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1746@option{-fdump-rtl-final}.
1747
1748If a non-linker output file is explicitly specified, aux and dump files
1749by default take the same base name:
1750
1751@smallexample
1752gcc -c foo.c -o dir/foobar.o ...
1753@end smallexample
1754
1755will name aux outputs @file{dir/foobar.*} and dump outputs
1756@file{dir/foobar.c.*}.
1757
1758A linker output will instead prefix aux and dump outputs:
1759
1760@smallexample
1761gcc foo.c bar.c -o dir/foobar ...
1762@end smallexample
1763
1764will generally name aux outputs @file{dir/foobar-foo.*} and
1765@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1766@file{dir/foobar-bar.c.*}.
1767
1768The one exception to the above is when the executable shares the base
1769name with the single input:
1770
1771@smallexample
1772gcc foo.c -o dir/foo ...
1773@end smallexample
1774
1775in which case aux outputs are named @file{dir/foo.*} and dump outputs
1776named @file{dir/foo.c.*}.
1777
1778The location and the names of auxiliary and dump outputs can be adjusted
1779by the options @option{-dumpbase}, @option{-dumpbase-ext},
1780@option{-dumpdir}, @option{-save-temps=cwd}, and
1781@option{-save-temps=obj}.
1782
1783
d77de738 1784@opindex dumpbase
ddf6fe37 1785@item -dumpbase @var{dumpbase}
d77de738
ML
1786This option sets the base name for auxiliary and dump output files. It
1787does not affect the name of the primary output file. Intermediate
1788outputs, when preserved, are not regarded as primary outputs, but as
1789auxiliary outputs:
1790
1791@smallexample
1792gcc -save-temps -S foo.c
1793@end smallexample
1794
1795saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1796then compiles to the (implied) output file @file{foo.s}, whereas:
1797
1798@smallexample
1799gcc -save-temps -dumpbase save-foo -c foo.c
1800@end smallexample
1801
1802preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1803an intermediate, thus auxiliary output), and then assembles to the
1804(implied) output file @file{foo.o}.
1805
1806Absent this option, dump and aux files take their names from the input
1807file, or from the (non-linker) output file, if one is explicitly
1808specified: dump output files (e.g. those requested by @option{-fdump-*}
1809options) with the input name suffix, and aux output files (those
1810requested by other non-dump options, e.g. @code{-save-temps},
1811@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1812
1813Similar suffix differentiation of dump and aux outputs can be attained
1814for explicitly-given @option{-dumpbase basename.suf} by also specifying
1815@option{-dumpbase-ext .suf}.
1816
1817If @var{dumpbase} is explicitly specified with any directory component,
1818any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1819@option{-save-temps=*}) is ignored, and instead of appending to it,
1820@var{dumpbase} fully overrides it:
1821
1822@smallexample
1823gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1824 -dumpdir pfx- -save-temps=cwd ...
1825@end smallexample
1826
1827creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1828@file{dir/} in @option{-o}, the @file{./} prefix implied by
1829@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1830
1831When @option{-dumpbase} is specified in a command that compiles multiple
1832inputs, or that compiles and then links, it may be combined with
1833@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1834file is compiled using the combined @var{dumppfx}, and default values
1835for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1836file:
1837
1838@smallexample
1839gcc foo.c bar.c -c -dumpbase main ...
1840@end smallexample
1841
1842creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1843overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1844as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1845and @file{main-bar.*}.
1846
1847An empty string specified as @var{dumpbase} avoids the influence of the
1848output basename in the naming of auxiliary and dump outputs during
1849compilation, computing default values :
1850
1851@smallexample
1852gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1853@end smallexample
1854
1855will name aux outputs @file{dir/foo.*} and dump outputs
1856@file{dir/foo.c.*}. Note how their basenames are taken from the input
1857name, but the directory still defaults to that of the output.
1858
1859The empty-string dumpbase does not prevent the use of the output
1860basename for outputs during linking:
1861
1862@smallexample
1863gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1864@end smallexample
1865
1866The compilation of the source files will name auxiliary outputs
1867@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1868@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1869linking will use @file{dir/foobar.} as the prefix for dumps and
1870auxiliary files.
1871
1872
d77de738 1873@opindex dumpbase-ext
ddf6fe37 1874@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1875When forming the name of an auxiliary (but not a dump) output file, drop
1876trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1877suffixes. If not specified, this option defaults to the suffix of a
1878default @var{dumpbase}, i.e., the suffix of the input file when
1879@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1880is combined with @var{dumppfx}.
1881
1882@smallexample
1883gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1884@end smallexample
1885
1886creates @file{dir/foo.o} as the main output, and generates auxiliary
1887outputs in @file{dir/x-foo.*}, taking the location of the primary
1888output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1889outputs retain the suffix: @file{dir/x-foo.c.*}.
1890
1891This option is disregarded if it does not match the suffix of a
1892specified @var{dumpbase}, except as an alternative to the executable
1893suffix when appending the linker output base name to @var{dumppfx}, as
1894specified below:
1895
1896@smallexample
1897gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1898@end smallexample
1899
1900creates @file{main.out} as the primary output, and avoids overwriting
1901the auxiliary and dump outputs by using the executable name minus
1902@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1903@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1904@file{main-foo.c.*} and @file{main-bar.c.*}.
1905
1906
d77de738 1907@opindex dumpdir
ddf6fe37 1908@item -dumpdir @var{dumppfx}
d77de738
ML
1909When forming the name of an auxiliary or dump output file, use
1910@var{dumppfx} as a prefix:
1911
1912@smallexample
1913gcc -dumpdir pfx- -c foo.c ...
1914@end smallexample
1915
1916creates @file{foo.o} as the primary output, and auxiliary outputs named
1917@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1918@var{dumpbase} derived from the default primary output, derived in turn
1919from the input name. Dump outputs also take the input name suffix:
1920@file{pfx-foo.c.*}.
1921
1922If @var{dumppfx} is to be used as a directory name, it must end with a
1923directory separator:
1924
1925@smallexample
1926gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1927@end smallexample
1928
1929creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1930named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1931default @var{dumpbase} derived from the primary output name. Dump
1932outputs also take the input name suffix: @file{dir/bar.c.*}.
1933
1934It defaults to the location of the output file, unless the output
1935file is a special file like @code{/dev/null}. Options
1936@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1937default, just like an explicit @option{-dumpdir} option. In case
1938multiple such options are given, the last one prevails:
1939
1940@smallexample
1941gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1942@end smallexample
1943
1944outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1945@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1946@option{-dumpdir} option. It does not matter that @option{=obj} is the
1947default for @option{-save-temps}, nor that the output directory is
1948implicitly the current directory. Dump outputs are named
1949@file{foo.c.*}.
1950
1951When compiling from multiple input files, if @option{-dumpbase} is
1952specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1953are appended to (or override, if containing any directory components) an
1954explicit or defaulted @var{dumppfx}, so that each of the multiple
1955compilations gets differently-named aux and dump outputs.
1956
1957@smallexample
1958gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1959@end smallexample
1960
1961outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1962@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1963Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1964and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1965single-input compilation:
1966
1967@smallexample
1968gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1969@end smallexample
1970
1971that, applying @option{-dumpbase} to a single source, does not compute
1972and append a separate @var{dumpbase} per input file. Its auxiliary and
1973dump outputs go in @file{dir/pfx-main.*}.
1974
1975When compiling and then linking from multiple input files, a defaulted
1976or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1977transformation above (e.g. the compilation of @file{foo.c} and
1978@file{bar.c} above, but without @option{-c}). If neither
1979@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1980base name, minus @var{auxdropsuf}, if specified, or the executable
1981suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1982instead. Note, however, that unlike earlier cases of linking:
1983
1984@smallexample
1985gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1986@end smallexample
1987
1988does not append the output name @file{main} to @var{dumppfx}, because
1989@option{-dumpdir} is explicitly specified. The goal is that the
1990explicitly-specified @var{dumppfx} may contain the specified output name
1991as part of the prefix, if desired; only an explicitly-specified
1992@option{-dumpbase} would be combined with it, in order to avoid simply
1993discarding a meaningful option.
1994
1995When compiling and then linking from a single input file, the linker
1996output base name will only be appended to the default @var{dumppfx} as
1997above if it does not share the base name with the single input file
1998name. This has been covered in single-input linking cases above, but
1999not with an explicit @option{-dumpdir} that inhibits the combination,
2000even if overridden by @option{-save-temps=*}:
2001
2002@smallexample
2003gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2004@end smallexample
2005
2006Auxiliary outputs are named @file{foo.*}, and dump outputs
2007@file{foo.c.*}, in the current working directory as ultimately requested
2008by @option{-save-temps=cwd}.
2009
2010Summing it all up for an intuitive though slightly imprecise data flow:
2011the primary output name is broken into a directory part and a basename
2012part; @var{dumppfx} is set to the former, unless overridden by
2013@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2014to the latter, unless overriden by @option{-dumpbase}. If there are
2015multiple inputs or linking, this @var{dumpbase} may be combined with
2016@var{dumppfx} and taken from each input file. Auxiliary output names
2017for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2018minus suffix, and the auxiliary output suffix; dump output names are
2019only different in that the suffix from @var{dumpbase} is retained.
2020
2021When it comes to auxiliary and dump outputs created during LTO
2022recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2023given or as derived from the linker output name but not from inputs,
2024even in cases in which this combination would not otherwise be used as
2025such, is passed down with a trailing period replacing the compiler-added
2026dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2027being involved in linking, this program does not normally get any
2028@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2029
2030When running sub-compilers, @command{lto-wrapper} appends LTO stage
2031names to the received @var{dumppfx}, ensures it contains a directory
2032component so that it overrides any @option{-dumpdir}, and passes that as
2033@option{-dumpbase} to sub-compilers.
2034
d77de738 2035@opindex v
ddf6fe37 2036@item -v
d77de738
ML
2037Print (on standard error output) the commands executed to run the stages
2038of compilation. Also print the version number of the compiler driver
2039program and of the preprocessor and the compiler proper.
2040
d77de738 2041@opindex ###
ddf6fe37 2042@item -###
d77de738
ML
2043Like @option{-v} except the commands are not executed and arguments
2044are quoted unless they contain only alphanumeric characters or @code{./-_}.
2045This is useful for shell scripts to capture the driver-generated command lines.
2046
d77de738 2047@opindex help
ddf6fe37 2048@item --help
d77de738
ML
2049Print (on the standard output) a description of the command-line options
2050understood by @command{gcc}. If the @option{-v} option is also specified
2051then @option{--help} is also passed on to the various processes
2052invoked by @command{gcc}, so that they can display the command-line options
2053they accept. If the @option{-Wextra} option has also been specified
2054(prior to the @option{--help} option), then command-line options that
2055have no documentation associated with them are also displayed.
2056
d77de738 2057@opindex target-help
ddf6fe37 2058@item --target-help
d77de738
ML
2059Print (on the standard output) a description of target-specific command-line
2060options for each tool. For some targets extra target-specific
2061information may also be printed.
2062
2063@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2064Print (on the standard output) a description of the command-line
2065options understood by the compiler that fit into all specified classes
2066and qualifiers. These are the supported classes:
2067
2068@table @asis
2069@item @samp{optimizers}
2070Display all of the optimization options supported by the
2071compiler.
2072
2073@item @samp{warnings}
2074Display all of the options controlling warning messages
2075produced by the compiler.
2076
2077@item @samp{target}
2078Display target-specific options. Unlike the
2079@option{--target-help} option however, target-specific options of the
2080linker and assembler are not displayed. This is because those
2081tools do not currently support the extended @option{--help=} syntax.
2082
2083@item @samp{params}
2084Display the values recognized by the @option{--param}
2085option.
2086
2087@item @var{language}
2088Display the options supported for @var{language}, where
2089@var{language} is the name of one of the languages supported in this
2090version of GCC@. If an option is supported by all languages, one needs
2091to select @samp{common} class.
2092
2093@item @samp{common}
2094Display the options that are common to all languages.
2095@end table
2096
2097These are the supported qualifiers:
2098
2099@table @asis
2100@item @samp{undocumented}
2101Display only those options that are undocumented.
2102
2103@item @samp{joined}
2104Display options taking an argument that appears after an equal
2105sign in the same continuous piece of text, such as:
2106@samp{--help=target}.
2107
2108@item @samp{separate}
2109Display options taking an argument that appears as a separate word
2110following the original option, such as: @samp{-o output-file}.
2111@end table
2112
2113Thus for example to display all the undocumented target-specific
2114switches supported by the compiler, use:
2115
2116@smallexample
2117--help=target,undocumented
2118@end smallexample
2119
2120The sense of a qualifier can be inverted by prefixing it with the
2121@samp{^} character, so for example to display all binary warning
2122options (i.e., ones that are either on or off and that do not take an
2123argument) that have a description, use:
2124
2125@smallexample
2126--help=warnings,^joined,^undocumented
2127@end smallexample
2128
2129The argument to @option{--help=} should not consist solely of inverted
2130qualifiers.
2131
2132Combining several classes is possible, although this usually
2133restricts the output so much that there is nothing to display. One
2134case where it does work, however, is when one of the classes is
2135@var{target}. For example, to display all the target-specific
2136optimization options, use:
2137
2138@smallexample
2139--help=target,optimizers
2140@end smallexample
2141
2142The @option{--help=} option can be repeated on the command line. Each
2143successive use displays its requested class of options, skipping
2144those that have already been displayed. If @option{--help} is also
2145specified anywhere on the command line then this takes precedence
2146over any @option{--help=} option.
2147
2148If the @option{-Q} option appears on the command line before the
2149@option{--help=} option, then the descriptive text displayed by
2150@option{--help=} is changed. Instead of describing the displayed
2151options, an indication is given as to whether the option is enabled,
2152disabled or set to a specific value (assuming that the compiler
2153knows this at the point where the @option{--help=} option is used).
2154
2155Here is a truncated example from the ARM port of @command{gcc}:
2156
2157@smallexample
2158 % gcc -Q -mabi=2 --help=target -c
2159 The following options are target specific:
2160 -mabi= 2
2161 -mabort-on-noreturn [disabled]
2162 -mapcs [disabled]
2163@end smallexample
2164
2165The output is sensitive to the effects of previous command-line
2166options, so for example it is possible to find out which optimizations
2167are enabled at @option{-O2} by using:
2168
2169@smallexample
2170-Q -O2 --help=optimizers
2171@end smallexample
2172
2173Alternatively you can discover which binary optimizations are enabled
2174by @option{-O3} by using:
2175
2176@smallexample
2177gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2178gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2179diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2180@end smallexample
2181
d77de738 2182@opindex version
ddf6fe37 2183@item --version
d77de738
ML
2184Display the version number and copyrights of the invoked GCC@.
2185
d77de738 2186@opindex pass-exit-codes
ddf6fe37 2187@item -pass-exit-codes
d77de738
ML
2188Normally the @command{gcc} program exits with the code of 1 if any
2189phase of the compiler returns a non-success return code. If you specify
2190@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2191the numerically highest error produced by any phase returning an error
2192indication. The C, C++, and Fortran front ends return 4 if an internal
2193compiler error is encountered.
2194
d77de738 2195@opindex pipe
ddf6fe37 2196@item -pipe
d77de738
ML
2197Use pipes rather than temporary files for communication between the
2198various stages of compilation. This fails to work on some systems where
2199the assembler is unable to read from a pipe; but the GNU assembler has
2200no trouble.
2201
d77de738 2202@opindex specs
ddf6fe37 2203@item -specs=@var{file}
d77de738
ML
2204Process @var{file} after the compiler reads in the standard @file{specs}
2205file, in order to override the defaults which the @command{gcc} driver
2206program uses when determining what switches to pass to @command{cc1},
2207@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2208@option{-specs=@var{file}} can be specified on the command line, and they
2209are processed in order, from left to right. @xref{Spec Files}, for
2210information about the format of the @var{file}.
2211
d77de738 2212@opindex wrapper
ddf6fe37 2213@item -wrapper
d77de738
ML
2214Invoke all subcommands under a wrapper program. The name of the
2215wrapper program and its parameters are passed as a comma separated
2216list.
2217
2218@smallexample
2219gcc -c t.c -wrapper gdb,--args
2220@end smallexample
2221
2222@noindent
2223This invokes all subprograms of @command{gcc} under
2224@samp{gdb --args}, thus the invocation of @command{cc1} is
2225@samp{gdb --args cc1 @dots{}}.
2226
d77de738 2227@opindex ffile-prefix-map
ddf6fe37 2228@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2229When compiling files residing in directory @file{@var{old}}, record
2230any references to them in the result of the compilation as if the
2231files resided in directory @file{@var{new}} instead. Specifying this
2232option is equivalent to specifying all the individual
2233@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2234builds that are location independent. Directories referenced by
2eb0191a
JJ
2235directives are not affected by these options. See also
2236@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2237@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2238
2eb0191a 2239@opindex fcanon-prefix-map
e54b01a1 2240@item -fcanon-prefix-map
2eb0191a
JJ
2241For the @option{-f*-prefix-map} options normally comparison
2242of @file{@var{old}} prefix against the filename that would be normally
2243referenced in the result of the compilation is done using textual
2244comparison of the prefixes, or ignoring character case for case insensitive
2245filesystems and considering slashes and backslashes as equal on DOS based
2246filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2247to be done on canonicalized paths of @file{@var{old}}
2248and the referenced filename.
d77de738 2249
d77de738 2250@opindex fplugin
ddf6fe37 2251@item -fplugin=@var{name}.so
d77de738
ML
2252Load the plugin code in file @var{name}.so, assumed to be a
2253shared object to be dlopen'd by the compiler. The base name of
2254the shared object file is used to identify the plugin for the
2255purposes of argument parsing (See
2256@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2257Each plugin should define the callback functions specified in the
2258Plugins API.
2259
d77de738 2260@opindex fplugin-arg
ddf6fe37 2261@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2262Define an argument called @var{key} with a value of @var{value}
2263for the plugin called @var{name}.
2264
d77de738 2265@opindex fdump-ada-spec
ddf6fe37 2266@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2267For C and C++ source and include files, generate corresponding Ada specs.
2268@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2269GNAT User's Guide}, which provides detailed documentation on this feature.
2270
d77de738 2271@opindex fada-spec-parent
ddf6fe37 2272@item -fada-spec-parent=@var{unit}
d77de738
ML
2273In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2274Ada specs as child units of parent @var{unit}.
2275
d77de738 2276@opindex fdump-go-spec
ddf6fe37 2277@item -fdump-go-spec=@var{file}
d77de738
ML
2278For input files in any language, generate corresponding Go
2279declarations in @var{file}. This generates Go @code{const},
2280@code{type}, @code{var}, and @code{func} declarations which may be a
2281useful way to start writing a Go interface to code written in some
2282other language.
2283
2284@include @value{srcdir}/../libiberty/at-file.texi
2285@end table
2286
2287@node Invoking G++
2288@section Compiling C++ Programs
2289
2290@cindex suffixes for C++ source
2291@cindex C++ source file suffixes
2292C++ source files conventionally use one of the suffixes @samp{.C},
2293@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2294@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2295@samp{.H}, or (for shared template code) @samp{.tcc}; and
2296preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2297files with these names and compiles them as C++ programs even if you
2298call the compiler the same way as for compiling C programs (usually
2299with the name @command{gcc}).
2300
2301@findex g++
2302@findex c++
2303However, the use of @command{gcc} does not add the C++ library.
2304@command{g++} is a program that calls GCC and automatically specifies linking
2305against the C++ library. It treats @samp{.c},
2306@samp{.h} and @samp{.i} files as C++ source files instead of C source
2307files unless @option{-x} is used. This program is also useful when
2308precompiling a C header file with a @samp{.h} extension for use in C++
2309compilations. On many systems, @command{g++} is also installed with
2310the name @command{c++}.
2311
2312@cindex invoking @command{g++}
2313When you compile C++ programs, you may specify many of the same
2314command-line options that you use for compiling programs in any
2315language; or command-line options meaningful for C and related
2316languages; or options that are meaningful only for C++ programs.
2317@xref{C Dialect Options,,Options Controlling C Dialect}, for
2318explanations of options for languages related to C@.
2319@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2320explanations of options that are meaningful only for C++ programs.
2321
2322@node C Dialect Options
2323@section Options Controlling C Dialect
2324@cindex dialect options
2325@cindex language dialect options
2326@cindex options, dialect
2327
2328The following options control the dialect of C (or languages derived
2329from C, such as C++, Objective-C and Objective-C++) that the compiler
2330accepts:
2331
2332@table @gcctabopt
2333@cindex ANSI support
2334@cindex ISO support
d77de738 2335@opindex ansi
ddf6fe37 2336@item -ansi
d77de738
ML
2337In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2338equivalent to @option{-std=c++98}.
2339
2340This turns off certain features of GCC that are incompatible with ISO
2341C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2342such as the @code{asm} and @code{typeof} keywords, and
2343predefined macros such as @code{unix} and @code{vax} that identify the
2344type of system you are using. It also enables the undesirable and
2345rarely used ISO trigraph feature. For the C compiler,
2346it disables recognition of C++ style @samp{//} comments as well as
2347the @code{inline} keyword.
2348
2349The alternate keywords @code{__asm__}, @code{__extension__},
2350@code{__inline__} and @code{__typeof__} continue to work despite
2351@option{-ansi}. You would not want to use them in an ISO C program, of
2352course, but it is useful to put them in header files that might be included
2353in compilations done with @option{-ansi}. Alternate predefined macros
2354such as @code{__unix__} and @code{__vax__} are also available, with or
2355without @option{-ansi}.
2356
2357The @option{-ansi} option does not cause non-ISO programs to be
2358rejected gratuitously. For that, @option{-Wpedantic} is required in
2359addition to @option{-ansi}. @xref{Warning Options}.
2360
2361The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2362option is used. Some header files may notice this macro and refrain
2363from declaring certain functions or defining certain macros that the
2364ISO standard doesn't call for; this is to avoid interfering with any
2365programs that might use these names for other things.
2366
2367Functions that are normally built in but do not have semantics
2368defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2369functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2370built-in functions provided by GCC}, for details of the functions
2371affected.
2372
d77de738 2373@opindex std
ddf6fe37 2374@item -std=
d77de738
ML
2375Determine the language standard. @xref{Standards,,Language Standards
2376Supported by GCC}, for details of these standard versions. This option
2377is currently only supported when compiling C or C++.
2378
2379The compiler can accept several base standards, such as @samp{c90} or
2380@samp{c++98}, and GNU dialects of those standards, such as
2381@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2382compiler accepts all programs following that standard plus those
2383using GNU extensions that do not contradict it. For example,
2384@option{-std=c90} turns off certain features of GCC that are
2385incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2386keywords, but not other GNU extensions that do not have a meaning in
2387ISO C90, such as omitting the middle term of a @code{?:}
2388expression. On the other hand, when a GNU dialect of a standard is
2389specified, all features supported by the compiler are enabled, even when
2390those features change the meaning of the base standard. As a result, some
2391strict-conforming programs may be rejected. The particular standard
2392is used by @option{-Wpedantic} to identify which features are GNU
2393extensions given that version of the standard. For example
2394@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2395comments, while @option{-std=gnu99 -Wpedantic} does not.
2396
2397A value for this option must be provided; possible values are
2398
2399@table @samp
2400@item c90
2401@itemx c89
2402@itemx iso9899:1990
2403Support all ISO C90 programs (certain GNU extensions that conflict
2404with ISO C90 are disabled). Same as @option{-ansi} for C code.
2405
2406@item iso9899:199409
2407ISO C90 as modified in amendment 1.
2408
2409@item c99
2410@itemx c9x
2411@itemx iso9899:1999
2412@itemx iso9899:199x
2413ISO C99. This standard is substantially completely supported, modulo
2414bugs and floating-point issues
2415(mainly but not entirely relating to optional C99 features from
2416Annexes F and G). See
2417@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2418names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2419
2420@item c11
2421@itemx c1x
2422@itemx iso9899:2011
2423ISO C11, the 2011 revision of the ISO C standard. This standard is
2424substantially completely supported, modulo bugs, floating-point issues
2425(mainly but not entirely relating to optional C11 features from
2426Annexes F and G) and the optional Annexes K (Bounds-checking
2427interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2428
2429@item c17
2430@itemx c18
2431@itemx iso9899:2017
2432@itemx iso9899:2018
2433ISO C17, the 2017 revision of the ISO C standard
2434(published in 2018). This standard is
2435same as C11 except for corrections of defects (all of which are also
2436applied with @option{-std=c11}) and a new value of
2437@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2438
fad61bf7
JM
2439@item c23
2440@itemx c2x
2441@itemx iso9899:2024
2442ISO C23, the 2023 revision of the ISO C standard (expected to be
2443published in 2024). The support for this version is experimental and
2444incomplete. The name @samp{c2x} is deprecated.
d77de738
ML
2445
2446@item gnu90
2447@itemx gnu89
2448GNU dialect of ISO C90 (including some C99 features).
2449
2450@item gnu99
2451@itemx gnu9x
2452GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2453
2454@item gnu11
2455@itemx gnu1x
2456GNU dialect of ISO C11.
2457The name @samp{gnu1x} is deprecated.
2458
2459@item gnu17
2460@itemx gnu18
2461GNU dialect of ISO C17. This is the default for C code.
2462
fad61bf7
JM
2463@item gnu23
2464@itemx gnu2x
d77de738
ML
2465The next version of the ISO C standard, still under development, plus
2466GNU extensions. The support for this version is experimental and
fad61bf7 2467incomplete. The name @samp{gnu2x} is deprecated.
d77de738
ML
2468
2469@item c++98
2470@itemx c++03
2471The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2472additional defect reports. Same as @option{-ansi} for C++ code.
2473
2474@item gnu++98
2475@itemx gnu++03
2476GNU dialect of @option{-std=c++98}.
2477
2478@item c++11
2479@itemx c++0x
2480The 2011 ISO C++ standard plus amendments.
2481The name @samp{c++0x} is deprecated.
2482
2483@item gnu++11
2484@itemx gnu++0x
2485GNU dialect of @option{-std=c++11}.
2486The name @samp{gnu++0x} is deprecated.
2487
2488@item c++14
2489@itemx c++1y
2490The 2014 ISO C++ standard plus amendments.
2491The name @samp{c++1y} is deprecated.
2492
2493@item gnu++14
2494@itemx gnu++1y
2495GNU dialect of @option{-std=c++14}.
2496The name @samp{gnu++1y} is deprecated.
2497
2498@item c++17
2499@itemx c++1z
2500The 2017 ISO C++ standard plus amendments.
2501The name @samp{c++1z} is deprecated.
2502
2503@item gnu++17
2504@itemx gnu++1z
2505GNU dialect of @option{-std=c++17}.
2506This is the default for C++ code.
2507The name @samp{gnu++1z} is deprecated.
2508
2509@item c++20
2510@itemx c++2a
2511The 2020 ISO C++ standard plus amendments.
2512Support is experimental, and could change in incompatible ways in
2513future releases.
2514The name @samp{c++2a} is deprecated.
2515
2516@item gnu++20
2517@itemx gnu++2a
2518GNU dialect of @option{-std=c++20}.
2519Support is experimental, and could change in incompatible ways in
2520future releases.
2521The name @samp{gnu++2a} is deprecated.
2522
2523@item c++2b
2524@itemx c++23
2525The next revision of the ISO C++ standard, planned for
25262023. Support is highly experimental, and will almost certainly
2527change in incompatible ways in future releases.
2528
2529@item gnu++2b
2530@itemx gnu++23
2531GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2532and will almost certainly change in incompatible ways in future
2533releases.
5388a43f
MP
2534
2535@item c++2c
2536@itemx c++26
2537The next revision of the ISO C++ standard, planned for
25382026. Support is highly experimental, and will almost certainly
2539change in incompatible ways in future releases.
2540
2541@item gnu++2c
2542@itemx gnu++26
2543GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2544and will almost certainly change in incompatible ways in future
2545releases.
d77de738
ML
2546@end table
2547
d77de738 2548@opindex aux-info
ddf6fe37 2549@item -aux-info @var{filename}
d77de738
ML
2550Output to the given filename prototyped declarations for all functions
2551declared and/or defined in a translation unit, including those in header
2552files. This option is silently ignored in any language other than C@.
2553
2554Besides declarations, the file indicates, in comments, the origin of
2555each declaration (source file and line), whether the declaration was
2556implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2557@samp{O} for old, respectively, in the first character after the line
2558number and the colon), and whether it came from a declaration or a
2559definition (@samp{C} or @samp{F}, respectively, in the following
2560character). In the case of function definitions, a K&R-style list of
2561arguments followed by their declarations is also provided, inside
2562comments, after the declaration.
2563
d77de738
ML
2564@opindex fno-asm
2565@opindex fasm
ddf6fe37 2566@item -fno-asm
d77de738
ML
2567Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2568keyword, so that code can use these words as identifiers. You can use
2569the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2570instead. In C, @option{-ansi} implies @option{-fno-asm}.
2571
2572In C++, @code{inline} is a standard keyword and is not affected by
2573this switch. You may want to use the @option{-fno-gnu-keywords} flag
2574instead, which disables @code{typeof} but not @code{asm} and
2575@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2576this switch only affects the @code{asm} and @code{typeof} keywords,
fad61bf7
JM
2577since @code{inline} is a standard keyword in ISO C99. In C23 mode
2578(@option{-std=c23} or @option{-std=gnu23}), this switch only affects
d77de738 2579the @code{asm} keyword, since @code{typeof} is a standard keyword in
fad61bf7 2580ISO C23.
d77de738 2581
d77de738
ML
2582@opindex fno-builtin
2583@opindex fbuiltin
f33d7a88 2584@cindex built-in functions
ddf6fe37
AA
2585@item -fno-builtin
2586@itemx -fno-builtin-@var{function}
d77de738
ML
2587Don't recognize built-in functions that do not begin with
2588@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2589functions provided by GCC}, for details of the functions affected,
2590including those which are not built-in functions when @option{-ansi} or
2591@option{-std} options for strict ISO C conformance are used because they
2592do not have an ISO standard meaning.
2593
2594GCC normally generates special code to handle certain built-in functions
2595more efficiently; for instance, calls to @code{alloca} may become single
2596instructions which adjust the stack directly, and calls to @code{memcpy}
2597may become inline copy loops. The resulting code is often both smaller
2598and faster, but since the function calls no longer appear as such, you
2599cannot set a breakpoint on those calls, nor can you change the behavior
2600of the functions by linking with a different library. In addition,
2601when a function is recognized as a built-in function, GCC may use
2602information about that function to warn about problems with calls to
2603that function, or to generate more efficient code, even if the
2604resulting code still contains calls to that function. For example,
2605warnings are given with @option{-Wformat} for bad calls to
2606@code{printf} when @code{printf} is built in and @code{strlen} is
2607known not to modify global memory.
2608
2609With the @option{-fno-builtin-@var{function}} option
2610only the built-in function @var{function} is
2611disabled. @var{function} must not begin with @samp{__builtin_}. If a
2612function is named that is not built-in in this version of GCC, this
2613option is ignored. There is no corresponding
2614@option{-fbuiltin-@var{function}} option; if you wish to enable
2615built-in functions selectively when using @option{-fno-builtin} or
2616@option{-ffreestanding}, you may define macros such as:
2617
2618@smallexample
2619#define abs(n) __builtin_abs ((n))
2620#define strcpy(d, s) __builtin_strcpy ((d), (s))
2621@end smallexample
2622
d77de738 2623@opindex fcond-mismatch
ddf6fe37 2624@item -fcond-mismatch
d77de738
ML
2625Allow conditional expressions with mismatched types in the second and
2626third arguments. The value of such an expression is void. This option
2627is not supported for C++.
2628
d77de738
ML
2629@opindex ffreestanding
2630@cindex hosted environment
f33d7a88 2631@item -ffreestanding
d77de738
ML
2632
2633Assert that compilation targets a freestanding environment. This
2634implies @option{-fno-builtin}. A freestanding environment
2635is one in which the standard library may not exist, and program startup may
2636not necessarily be at @code{main}. The most obvious example is an OS kernel.
2637This is equivalent to @option{-fno-hosted}.
2638
2639@xref{Standards,,Language Standards Supported by GCC}, for details of
2640freestanding and hosted environments.
2641
d77de738 2642@opindex fgimple
ddf6fe37 2643@item -fgimple
d77de738
ML
2644
2645Enable parsing of function definitions marked with @code{__GIMPLE}.
2646This is an experimental feature that allows unit testing of GIMPLE
2647passes.
2648
d77de738 2649@opindex fgnu-tm
ddf6fe37 2650@item -fgnu-tm
d77de738
ML
2651When the option @option{-fgnu-tm} is specified, the compiler
2652generates code for the Linux variant of Intel's current Transactional
2653Memory ABI specification document (Revision 1.1, May 6 2009). This is
2654an experimental feature whose interface may change in future versions
2655of GCC, as the official specification changes. Please note that not
2656all architectures are supported for this feature.
2657
2658For more information on GCC's support for transactional memory,
2659@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2660Transactional Memory Library}.
2661
2662Note that the transactional memory feature is not supported with
2663non-call exceptions (@option{-fnon-call-exceptions}).
2664
d77de738 2665@opindex fgnu89-inline
ddf6fe37 2666@item -fgnu89-inline
d77de738
ML
2667The option @option{-fgnu89-inline} tells GCC to use the traditional
2668GNU semantics for @code{inline} functions when in C99 mode.
2669@xref{Inline,,An Inline Function is As Fast As a Macro}.
2670Using this option is roughly equivalent to adding the
2671@code{gnu_inline} function attribute to all inline functions
2672(@pxref{Function Attributes}).
2673
2674The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2675C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2676specifies the default behavior).
2677This option is not supported in @option{-std=c90} or
2678@option{-std=gnu90} mode.
2679
2680The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2681@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2682in effect for @code{inline} functions. @xref{Common Predefined
2683Macros,,,cpp,The C Preprocessor}.
2684
d77de738
ML
2685@opindex fhosted
2686@cindex hosted environment
f33d7a88 2687@item -fhosted
d77de738
ML
2688
2689Assert that compilation targets a hosted environment. This implies
2690@option{-fbuiltin}. A hosted environment is one in which the
2691entire standard library is available, and in which @code{main} has a return
2692type of @code{int}. Examples are nearly everything except a kernel.
2693This is equivalent to @option{-fno-freestanding}.
2694
d77de738 2695@opindex flax-vector-conversions
ddf6fe37 2696@item -flax-vector-conversions
d77de738
ML
2697Allow implicit conversions between vectors with differing numbers of
2698elements and/or incompatible element types. This option should not be
2699used for new code.
2700
d77de738 2701@opindex fms-extensions
ddf6fe37 2702@item -fms-extensions
d77de738
ML
2703Accept some non-standard constructs used in Microsoft header files.
2704
2705In C++ code, this allows member names in structures to be similar
2706to previous types declarations.
2707
2708@smallexample
2709typedef int UOW;
2710struct ABC @{
2711 UOW UOW;
2712@};
2713@end smallexample
2714
2715Some cases of unnamed fields in structures and unions are only
2716accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2717fields within structs/unions}, for details.
2718
2719Note that this option is off for all targets except for x86
2720targets using ms-abi.
2721
ddf6fe37 2722@opindex foffload
d77de738
ML
2723@cindex Offloading targets
2724@cindex OpenACC offloading targets
2725@cindex OpenMP offloading targets
f33d7a88
AA
2726@item -foffload=disable
2727@itemx -foffload=default
2728@itemx -foffload=@var{target-list}
d77de738
ML
2729Specify for which OpenMP and OpenACC offload targets code should be generated.
2730The default behavior, equivalent to @option{-foffload=default}, is to generate
2731code for all supported offload targets. The @option{-foffload=disable} form
2732generates code only for the host fallback, while
2733@option{-foffload=@var{target-list}} generates code only for the specified
2734comma-separated list of offload targets.
2735
2736Offload targets are specified in GCC's internal target-triplet format. You can
2737run the compiler with @option{-v} to show the list of configured offload targets
2738under @code{OFFLOAD_TARGET_NAMES}.
2739
ddf6fe37 2740@opindex foffload-options
d77de738
ML
2741@cindex Offloading options
2742@cindex OpenACC offloading options
2743@cindex OpenMP offloading options
f33d7a88
AA
2744@item -foffload-options=@var{options}
2745@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2746
2747With @option{-foffload-options=@var{options}}, GCC passes the specified
2748@var{options} to the compilers for all enabled offloading targets. You can
2749specify options that apply only to a specific target or targets by using
2750the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2751@var{target-list} is a comma-separated list in the same format as for the
2752@option{-foffload=} option.
2753
2754Typical command lines are
2755
2756@smallexample
4bcb46b3 2757-foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic
e9c1679c 2758-foffload-options=amdgcn-amdhsa=-march=gfx906
d77de738
ML
2759@end smallexample
2760
d77de738
ML
2761@opindex fopenacc
2762@cindex OpenACC accelerator programming
f33d7a88 2763@item -fopenacc
643a5223
TB
2764Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
2765@samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
2766@samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified,
2767the compiler generates accelerated code according to the OpenACC Application
d77de738
ML
2768Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2769implies @option{-pthread}, and thus is only supported on targets that
2770have support for @option{-pthread}.
2771
d77de738
ML
2772@opindex fopenacc-dim
2773@cindex OpenACC accelerator programming
f33d7a88 2774@item -fopenacc-dim=@var{geom}
d77de738
ML
2775Specify default compute dimensions for parallel offload regions that do
2776not explicitly specify. The @var{geom} value is a triple of
2777':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2778can be omitted, to use a target-specific default value.
2779
d77de738
ML
2780@opindex fopenmp
2781@cindex OpenMP parallel
f33d7a88 2782@item -fopenmp
75e5a467 2783Enable handling of OpenMP directives @samp{#pragma omp},
643a5223 2784@samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and
75e5a467 2785@samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It
643a5223
TB
2786additionally enables the conditional compilation sentinel @samp{!$} in
2787Fortran. In fixed source form Fortran, the sentinels can also start with
2788@samp{c} or @samp{*}. When @option{-fopenmp} is specified, the
d77de738
ML
2789compiler generates parallel code according to the OpenMP Application
2790Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2791implies @option{-pthread}, and thus is only supported on targets that
2792have support for @option{-pthread}. @option{-fopenmp} implies
2793@option{-fopenmp-simd}.
2794
d77de738
ML
2795@opindex fopenmp-simd
2796@cindex OpenMP SIMD
2797@cindex SIMD
f33d7a88 2798@item -fopenmp-simd
d77de738 2799Enable handling of OpenMP's @code{simd}, @code{declare simd},
1fab441d
TB
2800@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
2801and @code{loop} directive, and of combined or composite directives with
75e5a467 2802@code{simd} as constituent with @code{#pragma omp},
1fab441d 2803@code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
75e5a467 2804@code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
643a5223
TB
2805additionally enables the conditional compilation sentinel @samp{!$} in
2806Fortran. In fixed source form Fortran, the sentinels can also start with
2807@samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
2808@option{-fopenmp} is additionally specified, the @code{loop} region binds
2809to the current task region, independent of the specified @code{bind} clause.
d77de738 2810
ddf6fe37 2811@opindex fopenmp-target-simd-clone
f33d7a88 2812@cindex OpenMP target SIMD clone
309e2d95
SL
2813@item -fopenmp-target-simd-clone
2814@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2815In addition to generating SIMD clones for functions marked with the
2816@code{declare simd} directive, GCC also generates clones
2817for functions marked with the OpenMP @code{declare target} directive
2818that are suitable for vectorization when this option is in effect. The
2819@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2820and @code{any}, which correspond to keywords for the @code{device_type}
2821clause of the @code{declare target} directive; clones are generated for
2822the intersection of devices specified.
2823@option{-fopenmp-target-simd-clone} is equivalent to
2824@option{-fopenmp-target-simd-clone=any} and
2825@option{-fno-openmp-target-simd-clone} is equivalent to
2826@option{-fopenmp-target-simd-clone=none}.
2827
2828At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2829optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2830it is disabled by default.
2831
d77de738
ML
2832@opindex fpermitted-flt-eval-methods
2833@opindex fpermitted-flt-eval-methods=c11
2834@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2835@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2836ISO/IEC TS 18661-3 defines new permissible values for
2837@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2838a semantic type that is an interchange or extended format should be
2839evaluated to the precision and range of that type. These new values are
2840a superset of those permitted under C99/C11, which does not specify the
2841meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2842conforming to C11 may not have been written expecting the possibility of
2843the new values.
2844
2845@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2846should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2847or the extended set of values specified in ISO/IEC TS 18661-3.
2848
2849@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2850
2851The default when in a standards compliant mode (@option{-std=c11} or similar)
2852is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2853dialect (@option{-std=gnu11} or similar) is
2854@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2855
024f135a
BB
2856@opindex fdeps-
2857The @samp{-fdeps-*} options are used to extract structured dependency
2858information for a source. This involves determining what resources provided by
2859other source files will be required to compile the source as well as what
2860resources are provided by the source. This information can be used to add
2861required dependencies between compilation rules of dependent sources based on
2862their contents rather than requiring such information be reflected within the
2863build tools as well.
2864
2865@opindex fdeps-file
2866@item -fdeps-file=@var{file}
2867Where to write structured dependency information.
2868
2869@opindex fdeps-format
2870@item -fdeps-format=@var{format}
2871The format to use for structured dependency information. @samp{p1689r5} is the
2872only supported format right now. Note that when this argument is specified, the
2873output of @samp{-MF} is stripped of some information (namely C++ modules) so
2874that it does not use extended makefile syntax not understood by most tools.
2875
2876@opindex fdeps-target
2877@item -fdeps-target=@var{file}
2878Analogous to @option{-MT} but for structured dependency information. This
2879indicates the target which will ultimately need any required resources and
2880provide any resources extracted from the source that may be required by other
2881sources.
2882
d77de738 2883@opindex fplan9-extensions
ddf6fe37 2884@item -fplan9-extensions
d77de738
ML
2885Accept some non-standard constructs used in Plan 9 code.
2886
2887This enables @option{-fms-extensions}, permits passing pointers to
2888structures with anonymous fields to functions that expect pointers to
2889elements of the type of the field, and permits referring to anonymous
2890fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2891struct/union fields within structs/unions}, for details. This is only
2892supported for C, not C++.
2893
d77de738
ML
2894@opindex fsigned-bitfields
2895@opindex funsigned-bitfields
2896@opindex fno-signed-bitfields
2897@opindex fno-unsigned-bitfields
ddf6fe37
AA
2898@item -fsigned-bitfields
2899@itemx -funsigned-bitfields
2900@itemx -fno-signed-bitfields
2901@itemx -fno-unsigned-bitfields
d77de738
ML
2902These options control whether a bit-field is signed or unsigned, when the
2903declaration does not use either @code{signed} or @code{unsigned}. By
2904default, such a bit-field is signed, because this is consistent: the
2905basic integer types such as @code{int} are signed types.
2906
d77de738 2907@opindex fsigned-char
ddf6fe37 2908@item -fsigned-char
d77de738
ML
2909Let the type @code{char} be signed, like @code{signed char}.
2910
2911Note that this is equivalent to @option{-fno-unsigned-char}, which is
2912the negative form of @option{-funsigned-char}. Likewise, the option
2913@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2914
d77de738 2915@opindex funsigned-char
ddf6fe37 2916@item -funsigned-char
d77de738
ML
2917Let the type @code{char} be unsigned, like @code{unsigned char}.
2918
2919Each kind of machine has a default for what @code{char} should
2920be. It is either like @code{unsigned char} by default or like
2921@code{signed char} by default.
2922
2923Ideally, a portable program should always use @code{signed char} or
2924@code{unsigned char} when it depends on the signedness of an object.
2925But many programs have been written to use plain @code{char} and
2926expect it to be signed, or expect it to be unsigned, depending on the
2927machines they were written for. This option, and its inverse, let you
2928make such a program work with the opposite default.
2929
2930The type @code{char} is always a distinct type from each of
2931@code{signed char} or @code{unsigned char}, even though its behavior
2932is always just like one of those two.
2933
d77de738
ML
2934@opindex fstrict-flex-arrays
2935@opindex fno-strict-flex-arrays
ddf6fe37 2936@item -fstrict-flex-arrays
d77de738
ML
2937Control when to treat the trailing array of a structure as a flexible array
2938member for the purpose of accessing the elements of such an array.
2939The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2940strictest. A trailing array is treated as a flexible array member only when it
2941is declared as a flexible array member per C99 standard onwards.
2942The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2943least strict. All trailing arrays of structures are treated as flexible array
2944members.
2945
d77de738 2946@opindex fstrict-flex-arrays=@var{level}
ddf6fe37 2947@item -fstrict-flex-arrays=@var{level}
d77de738
ML
2948Control when to treat the trailing array of a structure as a flexible array
2949member for the purpose of accessing the elements of such an array. The value
2950of @var{level} controls the level of strictness.
2951
2952The possible values of @var{level} are the same as for the
2953@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2954
2955You can control this behavior for a specific trailing array field of a
2956structure by using the variable attribute @code{strict_flex_array} attribute
2957(@pxref{Variable Attributes}).
2958
d77de738 2959@opindex fsso-struct
ddf6fe37 2960@item -fsso-struct=@var{endianness}
d77de738
ML
2961Set the default scalar storage order of structures and unions to the
2962specified endianness. The accepted values are @samp{big-endian},
2963@samp{little-endian} and @samp{native} for the native endianness of
2964the target (the default). This option is not supported for C++.
2965
2966@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2967code that is not binary compatible with code generated without it if the
2968specified endianness is not the native endianness of the target.
2969@end table
2970
2971@node C++ Dialect Options
2972@section Options Controlling C++ Dialect
2973
2974@cindex compiler options, C++
2975@cindex C++ options, command-line
2976@cindex options, C++
2977This section describes the command-line options that are only meaningful
2978for C++ programs. You can also use most of the GNU compiler options
2979regardless of what language your program is in. For example, you
2980might compile a file @file{firstClass.C} like this:
2981
2982@smallexample
2983g++ -g -fstrict-enums -O -c firstClass.C
2984@end smallexample
2985
2986@noindent
2987In this example, only @option{-fstrict-enums} is an option meant
2988only for C++ programs; you can use the other options with any
2989language supported by GCC@.
2990
2991Some options for compiling C programs, such as @option{-std}, are also
2992relevant for C++ programs.
2993@xref{C Dialect Options,,Options Controlling C Dialect}.
2994
2995Here is a list of options that are @emph{only} for compiling C++ programs:
2996
2997@table @gcctabopt
2998
d77de738 2999@opindex fabi-version
ddf6fe37 3000@item -fabi-version=@var{n}
d77de738
ML
3001Use version @var{n} of the C++ ABI@. The default is version 0.
3002
3003Version 0 refers to the version conforming most closely to
3004the C++ ABI specification. Therefore, the ABI obtained using version 0
3005will change in different versions of G++ as ABI bugs are fixed.
3006
3007Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
3008
3009Version 2 is the version of the C++ ABI that first appeared in G++
30103.4, and was the default through G++ 4.9.
3011
3012Version 3 corrects an error in mangling a constant address as a
3013template argument.
3014
3015Version 4, which first appeared in G++ 4.5, implements a standard
3016mangling for vector types.
3017
3018Version 5, which first appeared in G++ 4.6, corrects the mangling of
3019attribute const/volatile on function pointer types, decltype of a
3020plain decl, and use of a function parameter in the declaration of
3021another parameter.
3022
3023Version 6, which first appeared in G++ 4.7, corrects the promotion
3024behavior of C++11 scoped enums and the mangling of template argument
3025packs, const/static_cast, prefix ++ and --, and a class scope function
3026used as a template argument.
3027
3028Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
3029builtin type and corrects the mangling of lambdas in default argument
3030scope.
3031
3032Version 8, which first appeared in G++ 4.9, corrects the substitution
3033behavior of function types with function-cv-qualifiers.
3034
3035Version 9, which first appeared in G++ 5.2, corrects the alignment of
3036@code{nullptr_t}.
3037
3038Version 10, which first appeared in G++ 6.1, adds mangling of
3039attributes that affect type identity, such as ia32 calling convention
3040attributes (e.g.@: @samp{stdcall}).
3041
3042Version 11, which first appeared in G++ 7, corrects the mangling of
3043sizeof... expressions and operator names. For multiple entities with
3044the same name within a function, that are declared in different scopes,
3045the mangling now changes starting with the twelfth occurrence. It also
3046implies @option{-fnew-inheriting-ctors}.
3047
3048Version 12, which first appeared in G++ 8, corrects the calling
3049conventions for empty classes on the x86_64 target and for classes
3050with only deleted copy/move constructors. It accidentally changes the
3051calling convention for classes with a deleted copy constructor and a
3052trivial move constructor.
3053
3054Version 13, which first appeared in G++ 8.2, fixes the accidental
3055change in version 12.
3056
3057Version 14, which first appeared in G++ 10, corrects the mangling of
3058the nullptr expression.
3059
3060Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
3061tag regression.
3062
3063Version 16, which first appeared in G++ 11, changes the mangling of
3064@code{__alignof__} to be distinct from that of @code{alignof}, and
3065dependent operator names.
3066
3067Version 17, which first appeared in G++ 12, fixes layout of classes
3068that inherit from aggregate classes with default member initializers
3069in C++14 and up.
3070
3071Version 18, which first appeard in G++ 13, fixes manglings of lambdas
3072that have additional context.
3073
cd37325b
JJ
3074Version 19, which first appeard in G++ 14, fixes manglings of structured
3075bindings to include ABI tags.
3076
d77de738
ML
3077See also @option{-Wabi}.
3078
d77de738 3079@opindex fabi-compat-version
ddf6fe37 3080@item -fabi-compat-version=@var{n}
d77de738
ML
3081On targets that support strong aliases, G++
3082works around mangling changes by creating an alias with the correct
3083mangled name when defining a symbol with an incorrect mangled name.
3084This switch specifies which ABI version to use for the alias.
3085
3086With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3087compatibility). If another ABI version is explicitly selected, this
3088defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3089use @option{-fabi-compat-version=2}.
3090
3091If this option is not provided but @option{-Wabi=@var{n}} is, that
3092version is used for compatibility aliases. If this option is provided
3093along with @option{-Wabi} (without the version), the version from this
3094option is used for the warning.
3095
d77de738
ML
3096@opindex fno-access-control
3097@opindex faccess-control
ddf6fe37 3098@item -fno-access-control
d77de738
ML
3099Turn off all access checking. This switch is mainly useful for working
3100around bugs in the access control code.
3101
d77de738 3102@opindex faligned-new
ddf6fe37 3103@item -faligned-new
d77de738
ML
3104Enable support for C++17 @code{new} of types that require more
3105alignment than @code{void* ::operator new(std::size_t)} provides. A
3106numeric argument such as @code{-faligned-new=32} can be used to
3107specify how much alignment (in bytes) is provided by that function,
3108but few users will need to override the default of
3109@code{alignof(std::max_align_t)}.
3110
3111This flag is enabled by default for @option{-std=c++17}.
3112
d77de738
ML
3113@opindex fchar8_t
3114@opindex fno-char8_t
ddf6fe37
AA
3115@item -fchar8_t
3116@itemx -fno-char8_t
d77de738
ML
3117Enable support for @code{char8_t} as adopted for C++20. This includes
3118the addition of a new @code{char8_t} fundamental type, changes to the
3119types of UTF-8 string and character literals, new signatures for
3120user-defined literals, associated standard library updates, and new
3121@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3122
3123This option enables functions to be overloaded for ordinary and UTF-8
3124strings:
3125
3126@smallexample
3127int f(const char *); // #1
3128int f(const char8_t *); // #2
3129int v1 = f("text"); // Calls #1
3130int v2 = f(u8"text"); // Calls #2
3131@end smallexample
3132
3133@noindent
3134and introduces new signatures for user-defined literals:
3135
3136@smallexample
3137int operator""_udl1(char8_t);
3138int v3 = u8'x'_udl1;
3139int operator""_udl2(const char8_t*, std::size_t);
3140int v4 = u8"text"_udl2;
3141template<typename T, T...> int operator""_udl3();
3142int v5 = u8"text"_udl3;
3143@end smallexample
3144
3145@noindent
3146The change to the types of UTF-8 string and character literals introduces
3147incompatibilities with ISO C++11 and later standards. For example, the
3148following code is well-formed under ISO C++11, but is ill-formed when
3149@option{-fchar8_t} is specified.
3150
3151@smallexample
d77de738
ML
3152const char *cp = u8"xx";// error: invalid conversion from
3153 // `const char8_t*' to `const char*'
3154int f(const char*);
3155auto v = f(u8"xx"); // error: invalid conversion from
3156 // `const char8_t*' to `const char*'
3157std::string s@{u8"xx"@}; // error: no matching function for call to
3158 // `std::basic_string<char>::basic_string()'
3159using namespace std::literals;
3160s = u8"xx"s; // error: conversion from
3161 // `basic_string<char8_t>' to non-scalar
3162 // type `basic_string<char>' requested
3163@end smallexample
3164
d77de738 3165@opindex fcheck-new
ddf6fe37 3166@item -fcheck-new
d77de738
ML
3167Check that the pointer returned by @code{operator new} is non-null
3168before attempting to modify the storage allocated. This check is
3169normally unnecessary because the C++ standard specifies that
3170@code{operator new} only returns @code{0} if it is declared
3171@code{throw()}, in which case the compiler always checks the
3172return value even without this option. In all other cases, when
3173@code{operator new} has a non-empty exception specification, memory
3174exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3175@samp{new (nothrow)}.
3176
d77de738
ML
3177@opindex fconcepts
3178@opindex fconcepts-ts
ddf6fe37
AA
3179@item -fconcepts
3180@itemx -fconcepts-ts
d77de738
ML
3181Enable support for the C++ Concepts feature for constraining template
3182arguments. With @option{-std=c++20} and above, Concepts are part of
3183the language standard, so @option{-fconcepts} defaults to on.
3184
3185Some constructs that were allowed by the earlier C++ Extensions for
3186Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3187into the standard, can additionally be enabled by
3188@option{-fconcepts-ts}.
3189
d77de738 3190@opindex fconstexpr-depth
ddf6fe37 3191@item -fconstexpr-depth=@var{n}
d77de738
ML
3192Set the maximum nested evaluation depth for C++11 constexpr functions
3193to @var{n}. A limit is needed to detect endless recursion during
3194constant expression evaluation. The minimum specified by the standard
3195is 512.
3196
d77de738 3197@opindex fconstexpr-cache-depth
ddf6fe37 3198@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3199Set the maximum level of nested evaluation depth for C++11 constexpr
3200functions that will be cached to @var{n}. This is a heuristic that
3201trades off compilation speed (when the cache avoids repeated
3202calculations) against memory consumption (when the cache grows very
3203large from highly recursive evaluations). The default is 8. Very few
3204users are likely to want to adjust it, but if your code does heavy
3205constexpr calculations you might want to experiment to find which
3206value works best for you.
3207
d77de738 3208@opindex fconstexpr-fp-except
ddf6fe37 3209@item -fconstexpr-fp-except
d77de738
ML
3210Annex F of the C standard specifies that IEC559 floating point
3211exceptions encountered at compile time should not stop compilation.
3212C++ compilers have historically not followed this guidance, instead
3213treating floating point division by zero as non-constant even though
3214it has a well defined value. This flag tells the compiler to give
3215Annex F priority over other rules saying that a particular operation
3216is undefined.
3217
3218@smallexample
3219constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3220@end smallexample
3221
d77de738 3222@opindex fconstexpr-loop-limit
ddf6fe37 3223@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3224Set the maximum number of iterations for a loop in C++14 constexpr functions
3225to @var{n}. A limit is needed to detect infinite loops during
3226constant expression evaluation. The default is 262144 (1<<18).
3227
d77de738 3228@opindex fconstexpr-ops-limit
ddf6fe37 3229@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3230Set the maximum number of operations during a single constexpr evaluation.
3231Even when number of iterations of a single loop is limited with the above limit,
3232if there are several nested loops and each of them has many iterations but still
3233smaller than the above limit, or if in a body of some loop or even outside
3234of a loop too many expressions need to be evaluated, the resulting constexpr
3235evaluation might take too long.
3236The default is 33554432 (1<<25).
3237
2efb237f 3238@opindex fcontracts
ddf6fe37 3239@item -fcontracts
2efb237f
JCI
3240Enable experimental support for the C++ Contracts feature, as briefly
3241added to and then removed from the C++20 working paper (N4820). The
3242implementation also includes proposed enhancements from papers P1290,
3243P1332, and P1429. This functionality is intended mostly for those
3244interested in experimentation towards refining the feature to get it
3245into shape for a future C++ standard.
3246
3247On violation of a checked contract, the violation handler is called.
3248Users can replace the violation handler by defining
3249@smallexample
4ace81b6
SL
3250void
3251handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3252@end smallexample
3253
3254There are different sets of additional flags that can be used together
3255to specify which contracts will be checked and how, for N4820
3256contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3257used together.
3258
3259@table @gcctabopt
2efb237f 3260@opindex fcontract-mode
ddf6fe37 3261@item -fcontract-mode=[on|off]
2efb237f
JCI
3262Control whether any contracts have any semantics at all. Defaults to on.
3263
2efb237f 3264@opindex fcontract-assumption-mode
ddf6fe37 3265@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3266[N4820] Control whether contracts with level @samp{axiom}
3267should have the assume semantic. Defaults to on.
3268
2efb237f 3269@opindex fcontract-build-level
ddf6fe37 3270@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3271[N4820] Specify which level of contracts to generate checks
3272for. Defaults to @samp{default}.
3273
2efb237f 3274@opindex fcontract-continuation-mode
ddf6fe37 3275@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3276[N4820] Control whether to allow the program to continue executing
3277after a contract violation. That is, do checked contracts have the
3278@samp{maybe} semantic described below rather than the @samp{never}
3279semantic. Defaults to off.
3280
2efb237f 3281@opindex fcontract-role
ddf6fe37 3282@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3283[P1332] Specify the concrete semantics for each contract level
3284of a particular contract role.
3285
3286@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3287[P1429] Specify the concrete semantic for a particular
3288contract level.
3289
2efb237f 3290@opindex fcontract-strict-declarations
ddf6fe37 3291@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3292Control whether to reject adding contracts to a function after its
3293first declaration. Defaults to off.
3294@end table
3295
3296The possible concrete semantics for that can be specified with
3297@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3298
3299@table @code
3300@item ignore
3301This contract has no effect.
3302
3303@item assume
3304This contract is treated like C++23 @code{[[assume]]}.
3305
3306@item check_never_continue
3307@itemx never
3308@itemx abort
3309This contract is checked. If it fails, the violation handler is
3310called. If the handler returns, @code{std::terminate} is called.
3311
3312@item check_maybe_continue
3313@itemx maybe
3314This contract is checked. If it fails, the violation handler is
3315called. If the handler returns, execution continues normally.
3316@end table
3317
d77de738 3318@opindex fcoroutines
ddf6fe37 3319@item -fcoroutines
d77de738
ML
3320Enable support for the C++ coroutines extension (experimental).
3321
d77de738
ML
3322@opindex fno-elide-constructors
3323@opindex felide-constructors
ddf6fe37 3324@item -fno-elide-constructors
d77de738
ML
3325The C++ standard allows an implementation to omit creating a temporary
3326that is only used to initialize another object of the same type.
3327Specifying this option disables that optimization, and forces G++ to
3328call the copy constructor in all cases. This option also causes G++
3329to call trivial member functions which otherwise would be expanded inline.
3330
3331In C++17, the compiler is required to omit these temporaries, but this
3332option still affects trivial member functions.
3333
d77de738
ML
3334@opindex fno-enforce-eh-specs
3335@opindex fenforce-eh-specs
ddf6fe37 3336@item -fno-enforce-eh-specs
d77de738
ML
3337Don't generate code to check for violation of exception specifications
3338at run time. This option violates the C++ standard, but may be useful
3339for reducing code size in production builds, much like defining
3340@code{NDEBUG}. This does not give user code permission to throw
3341exceptions in violation of the exception specifications; the compiler
3342still optimizes based on the specifications, so throwing an
3343unexpected exception results in undefined behavior at run time.
3344
d77de738
ML
3345@opindex fextern-tls-init
3346@opindex fno-extern-tls-init
ddf6fe37
AA
3347@item -fextern-tls-init
3348@itemx -fno-extern-tls-init
d77de738
ML
3349The C++11 and OpenMP standards allow @code{thread_local} and
3350@code{threadprivate} variables to have dynamic (runtime)
3351initialization. To support this, any use of such a variable goes
3352through a wrapper function that performs any necessary initialization.
3353When the use and definition of the variable are in the same
3354translation unit, this overhead can be optimized away, but when the
3355use is in a different translation unit there is significant overhead
3356even if the variable doesn't actually need dynamic initialization. If
3357the programmer can be sure that no use of the variable in a
3358non-defining TU needs to trigger dynamic initialization (either
3359because the variable is statically initialized, or a use of the
3360variable in the defining TU will be executed before any uses in
3361another TU), they can avoid this overhead with the
3362@option{-fno-extern-tls-init} option.
3363
3364On targets that support symbol aliases, the default is
3365@option{-fextern-tls-init}. On targets that do not support symbol
3366aliases, the default is @option{-fno-extern-tls-init}.
3367
d77de738
ML
3368@opindex ffold-simple-inlines
3369@opindex fno-fold-simple-inlines
ddf6fe37
AA
3370@item -ffold-simple-inlines
3371@itemx -fno-fold-simple-inlines
d77de738
ML
3372Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3373@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3374means no debug information will be generated for such calls. Since these
3375functions are rarely interesting to debug, this flag is enabled by default
3376unless @option{-fno-inline} is active.
3377
d77de738
ML
3378@opindex fno-gnu-keywords
3379@opindex fgnu-keywords
ddf6fe37 3380@item -fno-gnu-keywords
d77de738
ML
3381Do not recognize @code{typeof} as a keyword, so that code can use this
3382word as an identifier. You can use the keyword @code{__typeof__} instead.
3383This option is implied by the strict ISO C++ dialects: @option{-ansi},
3384@option{-std=c++98}, @option{-std=c++11}, etc.
3385
d77de738 3386@opindex fimplicit-constexpr
ddf6fe37 3387@item -fimplicit-constexpr
d77de738
ML
3388Make inline functions implicitly constexpr, if they satisfy the
3389requirements for a constexpr function. This option can be used in
3390C++14 mode or later. This can result in initialization changing from
3391dynamic to static and other optimizations.
3392
d77de738
ML
3393@opindex fno-implicit-templates
3394@opindex fimplicit-templates
ddf6fe37 3395@item -fno-implicit-templates
d77de738
ML
3396Never emit code for non-inline templates that are instantiated
3397implicitly (i.e.@: by use); only emit code for explicit instantiations.
3398If you use this option, you must take care to structure your code to
3399include all the necessary explicit instantiations to avoid getting
3400undefined symbols at link time.
3401@xref{Template Instantiation}, for more information.
3402
d77de738
ML
3403@opindex fno-implicit-inline-templates
3404@opindex fimplicit-inline-templates
ddf6fe37 3405@item -fno-implicit-inline-templates
d77de738
ML
3406Don't emit code for implicit instantiations of inline templates, either.
3407The default is to handle inlines differently so that compiles with and
3408without optimization need the same set of explicit instantiations.
3409
d77de738
ML
3410@opindex fno-implement-inlines
3411@opindex fimplement-inlines
ddf6fe37 3412@item -fno-implement-inlines
d77de738
ML
3413To save space, do not emit out-of-line copies of inline functions
3414controlled by @code{#pragma implementation}. This causes linker
3415errors if these functions are not inlined everywhere they are called.
3416
d77de738
ML
3417@opindex fmodules-ts
3418@opindex fno-modules-ts
ddf6fe37
AA
3419@item -fmodules-ts
3420@itemx -fno-modules-ts
d77de738
ML
3421Enable support for C++20 modules (@pxref{C++ Modules}). The
3422@option{-fno-modules-ts} is usually not needed, as that is the
3423default. Even though this is a C++20 feature, it is not currently
3424implicitly enabled by selecting that standard version.
3425
ddf6fe37 3426@opindex fmodule-header
d77de738
ML
3427@item -fmodule-header
3428@itemx -fmodule-header=user
3429@itemx -fmodule-header=system
d77de738
ML
3430Compile a header file to create an importable header unit.
3431
d77de738 3432@opindex fmodule-implicit-inline
ddf6fe37 3433@item -fmodule-implicit-inline
d77de738
ML
3434Member functions defined in their class definitions are not implicitly
3435inline for modular code. This is different to traditional C++
3436behavior, for good reasons. However, it may result in a difficulty
3437during code porting. This option makes such function definitions
3438implicitly inline. It does however generate an ABI incompatibility,
3439so you must use it everywhere or nowhere. (Such definitions outside
3440of a named module remain implicitly inline, regardless.)
3441
d77de738
ML
3442@opindex fno-module-lazy
3443@opindex fmodule-lazy
ddf6fe37 3444@item -fno-module-lazy
d77de738
ML
3445Disable lazy module importing and module mapper creation.
3446
f33d7a88
AA
3447@vindex CXX_MODULE_MAPPER @r{environment variable}
3448@opindex fmodule-mapper
d77de738
ML
3449@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3450@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3451@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3452@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3453@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3454@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3455An oracle to query for module name to filename mappings. If
3456unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3457and if that is unset, an in-process default is provided.
3458
d77de738 3459@opindex fmodule-only
ddf6fe37 3460@item -fmodule-only
d77de738
ML
3461Only emit the Compiled Module Interface, inhibiting any object file.
3462
d77de738 3463@opindex fms-extensions
ddf6fe37 3464@item -fms-extensions
d77de738
ML
3465Disable Wpedantic warnings about constructs used in MFC, such as implicit
3466int and getting a pointer to member function via non-standard syntax.
3467
d77de738 3468@opindex fnew-inheriting-ctors
ddf6fe37 3469@item -fnew-inheriting-ctors
d77de738
ML
3470Enable the P0136 adjustment to the semantics of C++11 constructor
3471inheritance. This is part of C++17 but also considered to be a Defect
3472Report against C++11 and C++14. This flag is enabled by default
3473unless @option{-fabi-version=10} or lower is specified.
3474
d77de738 3475@opindex fnew-ttp-matching
ddf6fe37 3476@item -fnew-ttp-matching
d77de738
ML
3477Enable the P0522 resolution to Core issue 150, template template
3478parameters and default arguments: this allows a template with default
3479template arguments as an argument for a template template parameter
3480with fewer template parameters. This flag is enabled by default for
3481@option{-std=c++17}.
3482
d77de738
ML
3483@opindex fno-nonansi-builtins
3484@opindex fnonansi-builtins
ddf6fe37 3485@item -fno-nonansi-builtins
d77de738
ML
3486Disable built-in declarations of functions that are not mandated by
3487ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3488@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3489
d77de738 3490@opindex fnothrow-opt
ddf6fe37 3491@item -fnothrow-opt
d77de738
ML
3492Treat a @code{throw()} exception specification as if it were a
3493@code{noexcept} specification to reduce or eliminate the text size
3494overhead relative to a function with no exception specification. If
3495the function has local variables of types with non-trivial
3496destructors, the exception specification actually makes the
3497function smaller because the EH cleanups for those variables can be
3498optimized away. The semantic effect is that an exception thrown out of
3499a function with such an exception specification results in a call
3500to @code{terminate} rather than @code{unexpected}.
3501
d77de738
ML
3502@opindex fno-operator-names
3503@opindex foperator-names
ddf6fe37 3504@item -fno-operator-names
d77de738
ML
3505Do not treat the operator name keywords @code{and}, @code{bitand},
3506@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3507synonyms as keywords.
3508
d77de738
ML
3509@opindex fno-optional-diags
3510@opindex foptional-diags
ddf6fe37 3511@item -fno-optional-diags
d77de738
ML
3512Disable diagnostics that the standard says a compiler does not need to
3513issue. Currently, the only such diagnostic issued by G++ is the one for
3514a name having multiple meanings within a class.
3515
d77de738
ML
3516@opindex fno-pretty-templates
3517@opindex fpretty-templates
ddf6fe37 3518@item -fno-pretty-templates
d77de738
ML
3519When an error message refers to a specialization of a function
3520template, the compiler normally prints the signature of the
3521template followed by the template arguments and any typedefs or
3522typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3523rather than @code{void f(int)}) so that it's clear which template is
3524involved. When an error message refers to a specialization of a class
3525template, the compiler omits any template arguments that match
3526the default template arguments for that template. If either of these
3527behaviors make it harder to understand the error message rather than
3528easier, you can use @option{-fno-pretty-templates} to disable them.
3529
d77de738
ML
3530@opindex fno-rtti
3531@opindex frtti
ddf6fe37 3532@item -fno-rtti
d77de738
ML
3533Disable generation of information about every class with virtual
3534functions for use by the C++ run-time type identification features
3535(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3536of the language, you can save some space by using this flag. Note that
3537exception handling uses the same information, but G++ generates it as
3538needed. The @code{dynamic_cast} operator can still be used for casts that
3539do not require run-time type information, i.e.@: casts to @code{void *} or to
3540unambiguous base classes.
3541
3542Mixing code compiled with @option{-frtti} with that compiled with
3543@option{-fno-rtti} may not work. For example, programs may
3544fail to link if a class compiled with @option{-fno-rtti} is used as a base
3545for a class compiled with @option{-frtti}.
3546
d77de738 3547@opindex fsized-deallocation
ddf6fe37 3548@item -fsized-deallocation
d77de738
ML
3549Enable the built-in global declarations
3550@smallexample
3551void operator delete (void *, std::size_t) noexcept;
3552void operator delete[] (void *, std::size_t) noexcept;
3553@end smallexample
3554as introduced in C++14. This is useful for user-defined replacement
3555deallocation functions that, for example, use the size of the object
3556to make deallocation faster. Enabled by default under
3557@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3558warns about places that might want to add a definition.
3559
d77de738 3560@opindex fstrict-enums
ddf6fe37 3561@item -fstrict-enums
d77de738
ML
3562Allow the compiler to optimize using the assumption that a value of
3563enumerated type can only be one of the values of the enumeration (as
3564defined in the C++ standard; basically, a value that can be
3565represented in the minimum number of bits needed to represent all the
3566enumerators). This assumption may not be valid if the program uses a
3567cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3568This option has no effect for an enumeration type with a fixed underlying
3569type.
d77de738 3570
d77de738 3571@opindex fstrong-eval-order
ddf6fe37 3572@item -fstrong-eval-order
d77de738
ML
3573Evaluate member access, array subscripting, and shift expressions in
3574left-to-right order, and evaluate assignment in right-to-left order,
3575as adopted for C++17. Enabled by default with @option{-std=c++17}.
3576@option{-fstrong-eval-order=some} enables just the ordering of member
3577access and shift expressions, and is the default without
3578@option{-std=c++17}.
3579
d77de738 3580@opindex ftemplate-backtrace-limit
ddf6fe37 3581@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3582Set the maximum number of template instantiation notes for a single
3583warning or error to @var{n}. The default value is 10.
3584
d77de738 3585@opindex ftemplate-depth
ddf6fe37 3586@item -ftemplate-depth=@var{n}
d77de738
ML
3587Set the maximum instantiation depth for template classes to @var{n}.
3588A limit on the template instantiation depth is needed to detect
3589endless recursions during template class instantiation. ANSI/ISO C++
3590conforming programs must not rely on a maximum depth greater than 17
3591(changed to 1024 in C++11). The default value is 900, as the compiler
3592can run out of stack space before hitting 1024 in some situations.
3593
d77de738
ML
3594@opindex fno-threadsafe-statics
3595@opindex fthreadsafe-statics
ddf6fe37 3596@item -fno-threadsafe-statics
d77de738
ML
3597Do not emit the extra code to use the routines specified in the C++
3598ABI for thread-safe initialization of local statics. You can use this
3599option to reduce code size slightly in code that doesn't need to be
3600thread-safe.
3601
d77de738 3602@opindex fuse-cxa-atexit
ddf6fe37 3603@item -fuse-cxa-atexit
d77de738
ML
3604Register destructors for objects with static storage duration with the
3605@code{__cxa_atexit} function rather than the @code{atexit} function.
3606This option is required for fully standards-compliant handling of static
3607destructors, but only works if your C library supports
3608@code{__cxa_atexit}.
3609
d77de738
ML
3610@opindex fno-use-cxa-get-exception-ptr
3611@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3612@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3613Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3614causes @code{std::uncaught_exception} to be incorrect, but is necessary
3615if the runtime routine is not available.
3616
d77de738 3617@opindex fvisibility-inlines-hidden
ddf6fe37 3618@item -fvisibility-inlines-hidden
d77de738
ML
3619This switch declares that the user does not attempt to compare
3620pointers to inline functions or methods where the addresses of the two functions
3621are taken in different shared objects.
3622
3623The effect of this is that GCC may, effectively, mark inline methods with
3624@code{__attribute__ ((visibility ("hidden")))} so that they do not
3625appear in the export table of a DSO and do not require a PLT indirection
3626when used within the DSO@. Enabling this option can have a dramatic effect
3627on load and link times of a DSO as it massively reduces the size of the
3628dynamic export table when the library makes heavy use of templates.
3629
3630The behavior of this switch is not quite the same as marking the
3631methods as hidden directly, because it does not affect static variables
3632local to the function or cause the compiler to deduce that
3633the function is defined in only one shared object.
3634
3635You may mark a method as having a visibility explicitly to negate the
3636effect of the switch for that method. For example, if you do want to
3637compare pointers to a particular inline method, you might mark it as
3638having default visibility. Marking the enclosing class with explicit
3639visibility has no effect.
3640
3641Explicitly instantiated inline methods are unaffected by this option
3642as their linkage might otherwise cross a shared library boundary.
3643@xref{Template Instantiation}.
3644
d77de738 3645@opindex fvisibility-ms-compat
ddf6fe37 3646@item -fvisibility-ms-compat
d77de738
ML
3647This flag attempts to use visibility settings to make GCC's C++
3648linkage model compatible with that of Microsoft Visual Studio.
3649
3650The flag makes these changes to GCC's linkage model:
3651
3652@enumerate
3653@item
3654It sets the default visibility to @code{hidden}, like
3655@option{-fvisibility=hidden}.
3656
3657@item
3658Types, but not their members, are not hidden by default.
3659
3660@item
3661The One Definition Rule is relaxed for types without explicit
3662visibility specifications that are defined in more than one
3663shared object: those declarations are permitted if they are
3664permitted when this option is not used.
3665@end enumerate
3666
3667In new code it is better to use @option{-fvisibility=hidden} and
3668export those classes that are intended to be externally visible.
3669Unfortunately it is possible for code to rely, perhaps accidentally,
3670on the Visual Studio behavior.
3671
3672Among the consequences of these changes are that static data members
3673of the same type with the same name but defined in different shared
3674objects are different, so changing one does not change the other;
3675and that pointers to function members defined in different shared
3676objects may not compare equal. When this flag is given, it is a
3677violation of the ODR to define types with the same name differently.
3678
d77de738
ML
3679@opindex fno-weak
3680@opindex fweak
ddf6fe37 3681@item -fno-weak
d77de738
ML
3682Do not use weak symbol support, even if it is provided by the linker.
3683By default, G++ uses weak symbols if they are available. This
3684option exists only for testing, and should not be used by end-users;
3685it results in inferior code and has no benefits. This option may
3686be removed in a future release of G++.
3687
d77de738
ML
3688@opindex fext-numeric-literals
3689@opindex fno-ext-numeric-literals
ddf6fe37 3690@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3691Accept imaginary, fixed-point, or machine-defined
3692literal number suffixes as GNU extensions.
3693When this option is turned off these suffixes are treated
3694as C++11 user-defined literal numeric suffixes.
3695This is on by default for all pre-C++11 dialects and all GNU dialects:
3696@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3697@option{-std=gnu++14}.
3698This option is off by default
3699for ISO C++11 onwards (@option{-std=c++11}, ...).
3700
d77de738 3701@opindex nostdinc++
ddf6fe37 3702@item -nostdinc++
d77de738
ML
3703Do not search for header files in the standard directories specific to
3704C++, but do still search the other standard directories. (This option
3705is used when building the C++ library.)
3706
ddf6fe37
AA
3707@opindex flang-info-include-translate
3708@opindex flang-info-include-translate-not
d77de738
ML
3709@item -flang-info-include-translate
3710@itemx -flang-info-include-translate-not
3711@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3712Inform of include translation events. The first will note accepted
3713include translations, the second will note declined include
3714translations. The @var{header} form will inform of include
3715translations relating to that specific header. If @var{header} is of
3716the form @code{"user"} or @code{<system>} it will be resolved to a
3717specific user or system header using the include path.
3718
ddf6fe37 3719@opindex flang-info-module-cmi
d77de738
ML
3720@item -flang-info-module-cmi
3721@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3722Inform of Compiled Module Interface pathnames. The first will note
3723all read CMI pathnames. The @var{module} form will not reading a
3724specific module's CMI. @var{module} may be a named module or a
3725header-unit (the latter indicated by either being a pathname containing
3726directory separators or enclosed in @code{<>} or @code{""}).
3727
d77de738 3728@opindex stdlib
ddf6fe37 3729@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3730When G++ is configured to support this option, it allows specification of
3731alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3732(the default, native C++ runtime for G++) and @var{libc++} which is the
3733C++ runtime installed on some operating systems (e.g. Darwin versions from
3734Darwin11 onwards). The option switches G++ to use the headers from the
3735specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3736when a C++ runtime is required for linking.
3737@end table
3738
3739In addition, these warning options have meanings only for C++ programs:
3740
3741@table @gcctabopt
d77de738 3742@opindex Wabi-tag
ddf6fe37 3743@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3744Warn when a type with an ABI tag is used in a context that does not
3745have that ABI tag. See @ref{C++ Attributes} for more information
3746about ABI tags.
3747
d77de738
ML
3748@opindex Wcomma-subscript
3749@opindex Wno-comma-subscript
ddf6fe37 3750@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3751Warn about uses of a comma expression within a subscripting expression.
3752This usage was deprecated in C++20 and is going to be removed in C++23.
3753However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3754
3755@smallexample
3756@group
3757void f(int *a, int b, int c) @{
3758 a[b,c]; // deprecated in C++20, invalid in C++23
3759 a[(b,c)]; // OK
3760@}
3761@end group
3762@end smallexample
3763
3764In C++23 it is valid to have comma separated expressions in a subscript
3765when an overloaded subscript operator is found and supports the right
3766number and types of arguments. G++ will accept the formerly valid syntax
3767for code that is not valid in C++23 but used to be valid but deprecated
3768in C++20 with a pedantic warning that can be disabled with
3769@option{-Wno-comma-subscript}.
3770
3771Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3772and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3773
5fccebdb
JM
3774This warning is upgraded to an error by @option{-pedantic-errors} in
3775C++23 mode or later.
3776
d77de738
ML
3777@opindex Wctad-maybe-unsupported
3778@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3779@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3780Warn when performing class template argument deduction (CTAD) on a type with
3781no explicitly written deduction guides. This warning will point out cases
3782where CTAD succeeded only because the compiler synthesized the implicit
3783deduction guides, which might not be what the programmer intended. Certain
3784style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3785types that are designed to support CTAD. This warning can be suppressed with
3786the following pattern:
3787
3788@smallexample
3789struct allow_ctad_t; // any name works
3790template <typename T> struct S @{
3791 S(T) @{ @}
3792@};
4ace81b6
SL
3793// Guide with incomplete parameter type will never be considered.
3794S(allow_ctad_t) -> S<void>;
d77de738
ML
3795@end smallexample
3796
d77de738
ML
3797@opindex Wctor-dtor-privacy
3798@opindex Wno-ctor-dtor-privacy
ddf6fe37 3799@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3800Warn when a class seems unusable because all the constructors or
3801destructors in that class are private, and it has neither friends nor
3802public static member functions. Also warn if there are no non-private
3803methods, and there's at least one private member function that isn't
3804a constructor or destructor.
3805
d77de738
ML
3806@opindex Wdangling-reference
3807@opindex Wno-dangling-reference
ddf6fe37 3808@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3809Warn when a reference is bound to a temporary whose lifetime has ended.
3810For example:
3811
3812@smallexample
3813int n = 1;
3814const int& r = std::max(n - 1, n + 1); // r is dangling
3815@end smallexample
3816
3817In the example above, two temporaries are created, one for each
3818argument, and a reference to one of the temporaries is returned.
3819However, both temporaries are destroyed at the end of the full
3820expression, so the reference @code{r} is dangling. This warning
3821also detects dangling references in member initializer lists:
3822
3823@smallexample
3824const int& f(const int& i) @{ return i; @}
3825struct S @{
3826 const int &r; // r is dangling
3827 S() : r(f(10)) @{ @}
3828@};
3829@end smallexample
3830
3831Member functions are checked as well, but only their object argument:
3832
3833@smallexample
3834struct S @{
3835 const S& self () @{ return *this; @}
3836@};
3837const S& s = S().self(); // s is dangling
3838@end smallexample
3839
3840Certain functions are safe in this respect, for example @code{std::use_facet}:
3841they take and return a reference, but they don't return one of its arguments,
3842which can fool the warning. Such functions can be excluded from the warning
3843by wrapping them in a @code{#pragma}:
3844
3845@smallexample
3846#pragma GCC diagnostic push
3847#pragma GCC diagnostic ignored "-Wdangling-reference"
3848const T& foo (const T&) @{ @dots{} @}
3849#pragma GCC diagnostic pop
3850@end smallexample
3851
ce51e843
ML
3852@option{-Wdangling-reference} also warns about code like
3853
3854@smallexample
3855auto p = std::minmax(1, 2);
3856@end smallexample
3857
3858where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3859both references dangle after the end of the full expression that contains
3860the call to @code{std::minmax}.
3861
d77de738
ML
3862This warning is enabled by @option{-Wall}.
3863
d77de738
ML
3864@opindex Wdelete-non-virtual-dtor
3865@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3866@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3867Warn when @code{delete} is used to destroy an instance of a class that
3868has virtual functions and non-virtual destructor. It is unsafe to delete
3869an instance of a derived class through a pointer to a base class if the
3870base class does not have a virtual destructor. This warning is enabled
3871by @option{-Wall}.
3872
d77de738
ML
3873@opindex Wdeprecated-copy
3874@opindex Wno-deprecated-copy
ddf6fe37 3875@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3876Warn that the implicit declaration of a copy constructor or copy
3877assignment operator is deprecated if the class has a user-provided
3878copy constructor or copy assignment operator, in C++11 and up. This
3879warning is enabled by @option{-Wextra}. With
3880@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3881user-provided destructor.
3882
d77de738
ML
3883@opindex Wdeprecated-enum-enum-conversion
3884@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3885@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3886Disable the warning about the case when the usual arithmetic conversions
3887are applied on operands where one is of enumeration type and the other is
3888of a different enumeration type. This conversion was deprecated in C++20.
3889For example:
3890
3891@smallexample
3892enum E1 @{ e @};
3893enum E2 @{ f @};
3894int k = f - e;
3895@end smallexample
3896
3897@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3898@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3899by @option{-Wenum-conversion}.
3900
d77de738
ML
3901@opindex Wdeprecated-enum-float-conversion
3902@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3903@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3904Disable the warning about the case when the usual arithmetic conversions
3905are applied on operands where one is of enumeration type and the other is
3906of a floating-point type. This conversion was deprecated in C++20. For
3907example:
3908
3909@smallexample
3910enum E1 @{ e @};
3911enum E2 @{ f @};
3912bool b = e <= 3.7;
3913@end smallexample
3914
3915@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3916@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3917by @option{-Wenum-conversion}.
3918
b106f11d
AC
3919@opindex Welaborated-enum-base
3920@opindex Wno-elaborated-enum-base
3921@item -Wno-elaborated-enum-base
3922For C++11 and above, warn if an (invalid) additional enum-base is used
3923in an elaborated-type-specifier. That is, if an enum with given
3924underlying type and no enumerator list is used in a declaration other
3925than just a standalone declaration of the enum. Enabled by default. This
3926warning is upgraded to an error with -pedantic-errors.
3927
d77de738
ML
3928@opindex Winit-list-lifetime
3929@opindex Wno-init-list-lifetime
ddf6fe37 3930@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3931Do not warn about uses of @code{std::initializer_list} that are likely
3932to result in dangling pointers. Since the underlying array for an
3933@code{initializer_list} is handled like a normal C++ temporary object,
3934it is easy to inadvertently keep a pointer to the array past the end
3935of the array's lifetime. For example:
3936
3937@itemize @bullet
3938@item
3939If a function returns a temporary @code{initializer_list}, or a local
3940@code{initializer_list} variable, the array's lifetime ends at the end
3941of the return statement, so the value returned has a dangling pointer.
3942
3943@item
3944If a new-expression creates an @code{initializer_list}, the array only
3945lives until the end of the enclosing full-expression, so the
3946@code{initializer_list} in the heap has a dangling pointer.
3947
3948@item
3949When an @code{initializer_list} variable is assigned from a
3950brace-enclosed initializer list, the temporary array created for the
3951right side of the assignment only lives until the end of the
3952full-expression, so at the next statement the @code{initializer_list}
3953variable has a dangling pointer.
3954
3955@smallexample
3956// li's initial underlying array lives as long as li
3957std::initializer_list<int> li = @{ 1,2,3 @};
3958// assignment changes li to point to a temporary array
3959li = @{ 4, 5 @};
3960// now the temporary is gone and li has a dangling pointer
3961int i = li.begin()[0] // undefined behavior
3962@end smallexample
3963
3964@item
3965When a list constructor stores the @code{begin} pointer from the
3966@code{initializer_list} argument, this doesn't extend the lifetime of
3967the array, so if a class variable is constructed from a temporary
3968@code{initializer_list}, the pointer is left dangling by the end of
3969the variable declaration statement.
3970
3971@end itemize
3972
c85f8dbb
MP
3973@opindex Winvalid-constexpr
3974@opindex Wno-invalid-constexpr
ddf6fe37 3975@item -Winvalid-constexpr
c85f8dbb
MP
3976
3977Warn when a function never produces a constant expression. In C++20
3978and earlier, for every @code{constexpr} function and function template,
3979there must be at least one set of function arguments in at least one
3980instantiation such that an invocation of the function or constructor
3981could be an evaluated subexpression of a core constant expression.
3982C++23 removed this restriction, so it's possible to have a function
3983or a function template marked @code{constexpr} for which no invocation
3984satisfies the requirements of a core constant expression.
3985
3986This warning is enabled as a pedantic warning by default in C++20 and
3987earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3988which case it will be an ordinary warning. For example:
3989
3990@smallexample
3991void f (int& i);
3992constexpr void
3993g (int& i)
3994@{
4ace81b6
SL
3995 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3996 f(i);
c85f8dbb
MP
3997@}
3998@end smallexample
3999
d77de738
ML
4000@opindex Winvalid-imported-macros
4001@opindex Wno-invalid-imported-macros
ddf6fe37 4002@item -Winvalid-imported-macros
d77de738
ML
4003Verify all imported macro definitions are valid at the end of
4004compilation. This is not enabled by default, as it requires
4005additional processing to determine. It may be useful when preparing
4006sets of header-units to ensure consistent macros.
4007
d77de738
ML
4008@opindex Wliteral-suffix
4009@opindex Wno-literal-suffix
ddf6fe37 4010@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
4011Do not warn when a string or character literal is followed by a
4012ud-suffix which does not begin with an underscore. As a conforming
4013extension, GCC treats such suffixes as separate preprocessing tokens
4014in order to maintain backwards compatibility with code that uses
4015formatting macros from @code{<inttypes.h>}. For example:
4016
4017@smallexample
4018#define __STDC_FORMAT_MACROS
4019#include <inttypes.h>
4020#include <stdio.h>
4021
4022int main() @{
4023 int64_t i64 = 123;
4024 printf("My int64: %" PRId64"\n", i64);
4025@}
4026@end smallexample
4027
4028In this case, @code{PRId64} is treated as a separate preprocessing token.
4029
4030This option also controls warnings when a user-defined literal
4031operator is declared with a literal suffix identifier that doesn't
4032begin with an underscore. Literal suffix identifiers that don't begin
4033with an underscore are reserved for future standardization.
4034
4035These warnings are enabled by default.
4036
d77de738
ML
4037@opindex Wnarrowing
4038@opindex Wno-narrowing
ddf6fe37 4039@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
4040For C++11 and later standards, narrowing conversions are diagnosed by default,
4041as required by the standard. A narrowing conversion from a constant produces
4042an error, and a narrowing conversion from a non-constant produces a warning,
4043but @option{-Wno-narrowing} suppresses the diagnostic.
4044Note that this does not affect the meaning of well-formed code;
4045narrowing conversions are still considered ill-formed in SFINAE contexts.
4046
4047With @option{-Wnarrowing} in C++98, warn when a narrowing
4048conversion prohibited by C++11 occurs within
4049@samp{@{ @}}, e.g.
4050
4051@smallexample
4052int i = @{ 2.2 @}; // error: narrowing from double to int
4053@end smallexample
4054
4055This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4056
d77de738
ML
4057@opindex Wnoexcept
4058@opindex Wno-noexcept
ddf6fe37 4059@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
4060Warn when a noexcept-expression evaluates to false because of a call
4061to a function that does not have a non-throwing exception
4062specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4063the compiler to never throw an exception.
4064
d77de738
ML
4065@opindex Wnoexcept-type
4066@opindex Wno-noexcept-type
ddf6fe37 4067@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
4068Warn if the C++17 feature making @code{noexcept} part of a function
4069type changes the mangled name of a symbol relative to C++14. Enabled
4070by @option{-Wabi} and @option{-Wc++17-compat}.
4071
4072As an example:
4073
4074@smallexample
4075template <class T> void f(T t) @{ t(); @};
4076void g() noexcept;
4077void h() @{ f(g); @}
4078@end smallexample
4079
4080@noindent
4081In C++14, @code{f} calls @code{f<void(*)()>}, but in
4082C++17 it calls @code{f<void(*)()noexcept>}.
4083
d77de738
ML
4084@opindex Wclass-memaccess
4085@opindex Wno-class-memaccess
ddf6fe37 4086@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4087Warn when the destination of a call to a raw memory function such as
4088@code{memset} or @code{memcpy} is an object of class type, and when writing
4089into such an object might bypass the class non-trivial or deleted constructor
4090or copy assignment, violate const-correctness or encapsulation, or corrupt
4091virtual table pointers. Modifying the representation of such objects may
4092violate invariants maintained by member functions of the class. For example,
4093the call to @code{memset} below is undefined because it modifies a non-trivial
4094class object and is, therefore, diagnosed. The safe way to either initialize
4095or clear the storage of objects of such types is by using the appropriate
4096constructor or assignment operator, if one is available.
4097@smallexample
4098std::string str = "abc";
4099memset (&str, 0, sizeof str);
4100@end smallexample
4101The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4102Explicitly casting the pointer to the class object to @code{void *} or
4103to a type that can be safely accessed by the raw memory function suppresses
4104the warning.
4105
d77de738
ML
4106@opindex Wnon-virtual-dtor
4107@opindex Wno-non-virtual-dtor
ddf6fe37 4108@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4109Warn when a class has virtual functions and an accessible non-virtual
4110destructor itself or in an accessible polymorphic base class, in which
4111case it is possible but unsafe to delete an instance of a derived
4112class through a pointer to the class itself or base class. This
4113warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4114The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4115should be preferred because it warns about the unsafe cases without false
4116positives.
d77de738 4117
d77de738
ML
4118@opindex Wregister
4119@opindex Wno-register
ddf6fe37 4120@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4121Warn on uses of the @code{register} storage class specifier, except
4122when it is part of the GNU @ref{Explicit Register Variables} extension.
4123The use of the @code{register} keyword as storage class specifier has
4124been deprecated in C++11 and removed in C++17.
4125Enabled by default with @option{-std=c++17}.
4126
d77de738
ML
4127@opindex Wreorder
4128@opindex Wno-reorder
4129@cindex reordering, warning
4130@cindex warning for reordering of member initializers
f33d7a88 4131@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4132Warn when the order of member initializers given in the code does not
4133match the order in which they must be executed. For instance:
4134
4135@smallexample
4136struct A @{
4137 int i;
4138 int j;
4139 A(): j (0), i (1) @{ @}
4140@};
4141@end smallexample
4142
4143@noindent
4144The compiler rearranges the member initializers for @code{i}
4145and @code{j} to match the declaration order of the members, emitting
4146a warning to that effect. This warning is enabled by @option{-Wall}.
4147
d77de738
ML
4148@opindex Wpessimizing-move
4149@opindex Wno-pessimizing-move
ddf6fe37 4150@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4151This warning warns when a call to @code{std::move} prevents copy
4152elision. A typical scenario when copy elision can occur is when returning in
4153a function with a class return type, when the expression being returned is the
4154name of a non-volatile automatic object, and is not a function parameter, and
4155has the same type as the function return type.
4156
4157@smallexample
4158struct T @{
4159@dots{}
4160@};
4161T fn()
4162@{
4163 T t;
4164 @dots{}
4165 return std::move (t);
4166@}
4167@end smallexample
4168
4169But in this example, the @code{std::move} call prevents copy elision.
4170
4171This warning is enabled by @option{-Wall}.
4172
d77de738
ML
4173@opindex Wredundant-move
4174@opindex Wno-redundant-move
ddf6fe37 4175@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4176This warning warns about redundant calls to @code{std::move}; that is, when
4177a move operation would have been performed even without the @code{std::move}
4178call. This happens because the compiler is forced to treat the object as if
4179it were an rvalue in certain situations such as returning a local variable,
4180where copy elision isn't applicable. Consider:
4181
4182@smallexample
4183struct T @{
4184@dots{}
4185@};
4186T fn(T t)
4187@{
4188 @dots{}
4189 return std::move (t);
4190@}
4191@end smallexample
4192
4193Here, the @code{std::move} call is redundant. Because G++ implements Core
4194Issue 1579, another example is:
4195
4196@smallexample
4197struct T @{ // convertible to U
4198@dots{}
4199@};
4200struct U @{
4201@dots{}
4202@};
4203U fn()
4204@{
4205 T t;
4206 @dots{}
4207 return std::move (t);
4208@}
4209@end smallexample
4210In this example, copy elision isn't applicable because the type of the
4211expression being returned and the function return type differ, yet G++
4212treats the return value as if it were designated by an rvalue.
4213
4214This warning is enabled by @option{-Wextra}.
4215
d77de738
ML
4216@opindex Wrange-loop-construct
4217@opindex Wno-range-loop-construct
ddf6fe37 4218@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4219This warning warns when a C++ range-based for-loop is creating an unnecessary
4220copy. This can happen when the range declaration is not a reference, but
4221probably should be. For example:
4222
4223@smallexample
4224struct S @{ char arr[128]; @};
4225void fn () @{
4226 S arr[5];
4227 for (const auto x : arr) @{ @dots{} @}
4228@}
4229@end smallexample
4230
4231It does not warn when the type being copied is a trivially-copyable type whose
4232size is less than 64 bytes.
4233
4234This warning also warns when a loop variable in a range-based for-loop is
4235initialized with a value of a different type resulting in a copy. For example:
4236
4237@smallexample
4238void fn() @{
4239 int arr[10];
4240 for (const double &x : arr) @{ @dots{} @}
4241@}
4242@end smallexample
4243
4244In the example above, in every iteration of the loop a temporary value of
4245type @code{double} is created and destroyed, to which the reference
4246@code{const double &} is bound.
4247
4248This warning is enabled by @option{-Wall}.
4249
d77de738
ML
4250@opindex Wredundant-tags
4251@opindex Wno-redundant-tags
ddf6fe37 4252@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4253Warn about redundant class-key and enum-key in references to class types
4254and enumerated types in contexts where the key can be eliminated without
4255causing an ambiguity. For example:
4256
4257@smallexample
4258struct foo;
4259struct foo *p; // warn that keyword struct can be eliminated
4260@end smallexample
4261
4262@noindent
4263On the other hand, in this example there is no warning:
4264
4265@smallexample
4266struct foo;
4267void foo (); // "hides" struct foo
4268void bar (struct foo&); // no warning, keyword struct is necessary
4269@end smallexample
4270
d77de738
ML
4271@opindex Wsubobject-linkage
4272@opindex Wno-subobject-linkage
ddf6fe37 4273@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4274Do not warn
4275if a class type has a base or a field whose type uses the anonymous
4276namespace or depends on a type with no linkage. If a type A depends on
4277a type B with no or internal linkage, defining it in multiple
4278translation units would be an ODR violation because the meaning of B
4279is different in each translation unit. If A only appears in a single
4280translation unit, the best way to silence the warning is to give it
4281internal linkage by putting it in an anonymous namespace as well. The
4282compiler doesn't give this warning for types defined in the main .C
4283file, as those are unlikely to have multiple definitions.
4284@option{-Wsubobject-linkage} is enabled by default.
4285
d77de738
ML
4286@opindex Weffc++
4287@opindex Wno-effc++
ddf6fe37 4288@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4289Warn about violations of the following style guidelines from Scott Meyers'
4290@cite{Effective C++} series of books:
4291
4292@itemize @bullet
4293@item
4294Define a copy constructor and an assignment operator for classes
4295with dynamically-allocated memory.
4296
4297@item
4298Prefer initialization to assignment in constructors.
4299
4300@item
4301Have @code{operator=} return a reference to @code{*this}.
4302
4303@item
4304Don't try to return a reference when you must return an object.
4305
4306@item
4307Distinguish between prefix and postfix forms of increment and
4308decrement operators.
4309
4310@item
4311Never overload @code{&&}, @code{||}, or @code{,}.
4312
4313@end itemize
4314
4315This option also enables @option{-Wnon-virtual-dtor}, which is also
4316one of the effective C++ recommendations. However, the check is
4317extended to warn about the lack of virtual destructor in accessible
4318non-polymorphic bases classes too.
4319
4320When selecting this option, be aware that the standard library
4321headers do not obey all of these guidelines; use @samp{grep -v}
4322to filter out those warnings.
4323
d77de738
ML
4324@opindex Wexceptions
4325@opindex Wno-exceptions
ddf6fe37 4326@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4327Disable the warning about the case when an exception handler is shadowed by
4328another handler, which can point out a wrong ordering of exception handlers.
4329
d77de738
ML
4330@opindex Wstrict-null-sentinel
4331@opindex Wno-strict-null-sentinel
ddf6fe37 4332@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4333Warn about the use of an uncasted @code{NULL} as sentinel. When
4334compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4335to @code{__null}. Although it is a null pointer constant rather than a
4336null pointer, it is guaranteed to be of the same size as a pointer.
4337But this use is not portable across different compilers.
4338
d77de738
ML
4339@opindex Wno-non-template-friend
4340@opindex Wnon-template-friend
ddf6fe37 4341@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4342Disable warnings when non-template friend functions are declared
4343within a template. In very old versions of GCC that predate implementation
4344of the ISO standard, declarations such as
4345@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4346could be interpreted as a particular specialization of a template
4347function; the warning exists to diagnose compatibility problems,
4348and is enabled by default.
4349
d77de738
ML
4350@opindex Wold-style-cast
4351@opindex Wno-old-style-cast
ddf6fe37 4352@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4353Warn if an old-style (C-style) cast to a non-void type is used within
4354a C++ program. The new-style casts (@code{dynamic_cast},
4355@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4356less vulnerable to unintended effects and much easier to search for.
4357
d77de738
ML
4358@opindex Woverloaded-virtual
4359@opindex Wno-overloaded-virtual
4360@cindex overloaded virtual function, warning
4361@cindex warning for overloaded virtual function
f33d7a88
AA
4362@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4363@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4364Warn when a function declaration hides virtual functions from a
4365base class. For example, in:
4366
4367@smallexample
4368struct A @{
4369 virtual void f();
4370@};
4371
4372struct B: public A @{
4373 void f(int); // does not override
4374@};
4375@end smallexample
4376
4377the @code{A} class version of @code{f} is hidden in @code{B}, and code
4378like:
4379
4380@smallexample
4381B* b;
4382b->f();
4383@end smallexample
4384
4385@noindent
4386fails to compile.
4387
d82490d5
JW
4388In cases where the different signatures are not an accident, the
4389simplest solution is to add a using-declaration to the derived class
4390to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4391
d77de738
ML
4392The optional level suffix controls the behavior when all the
4393declarations in the derived class override virtual functions in the
4394base class, even if not all of the base functions are overridden:
4395
4396@smallexample
4397struct C @{
4398 virtual void f();
4399 virtual void f(int);
4400@};
4401
4402struct D: public C @{
4403 void f(int); // does override
4404@}
4405@end smallexample
4406
4407This pattern is less likely to be a mistake; if D is only used
4408virtually, the user might have decided that the base class semantics
4409for some of the overloads are fine.
4410
4411At level 1, this case does not warn; at level 2, it does.
4412@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4413included in @option{-Wall}.
4414
d77de738
ML
4415@opindex Wno-pmf-conversions
4416@opindex Wpmf-conversions
ddf6fe37 4417@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4418Disable the diagnostic for converting a bound pointer to member function
4419to a plain pointer.
4420
d77de738
ML
4421@opindex Wsign-promo
4422@opindex Wno-sign-promo
ddf6fe37 4423@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4424Warn when overload resolution chooses a promotion from unsigned or
4425enumerated type to a signed type, over a conversion to an unsigned type of
4426the same size. Previous versions of G++ tried to preserve
4427unsignedness, but the standard mandates the current behavior.
4428
d77de738
ML
4429@opindex Wtemplates
4430@opindex Wno-templates
ddf6fe37 4431@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4432Warn when a primary template declaration is encountered. Some coding
4433rules disallow templates, and this may be used to enforce that rule.
4434The warning is inactive inside a system header file, such as the STL, so
4435one can still use the STL. One may also instantiate or specialize
4436templates.
4437
d77de738
ML
4438@opindex Wmismatched-new-delete
4439@opindex Wno-mismatched-new-delete
ddf6fe37 4440@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4441Warn for mismatches between calls to @code{operator new} or @code{operator
4442delete} and the corresponding call to the allocation or deallocation function.
4443This includes invocations of C++ @code{operator delete} with pointers
4444returned from either mismatched forms of @code{operator new}, or from other
4445functions that allocate objects for which the @code{operator delete} isn't
4446a suitable deallocator, as well as calls to other deallocation functions
4447with pointers returned from @code{operator new} for which the deallocation
4448function isn't suitable.
4449
4450For example, the @code{delete} expression in the function below is diagnosed
4451because it doesn't match the array form of the @code{new} expression
4452the pointer argument was returned from. Similarly, the call to @code{free}
4453is also diagnosed.
4454
4455@smallexample
4456void f ()
4457@{
4458 int *a = new int[n];
4459 delete a; // warning: mismatch in array forms of expressions
4460
4461 char *p = new char[n];
4462 free (p); // warning: mismatch between new and free
4463@}
4464@end smallexample
4465
4466The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4467involving allocation and deallocation functions other than @code{operator
4468new} and @code{operator delete}.
4469
4470@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4471
d77de738
ML
4472@opindex Wmismatched-tags
4473@opindex Wno-mismatched-tags
ddf6fe37 4474@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4475Warn for declarations of structs, classes, and class templates and their
4476specializations with a class-key that does not match either the definition
4477or the first declaration if no definition is provided.
4478
4479For example, the declaration of @code{struct Object} in the argument list
4480of @code{draw} triggers the warning. To avoid it, either remove the redundant
4481class-key @code{struct} or replace it with @code{class} to match its definition.
4482@smallexample
4483class Object @{
4484public:
4485 virtual ~Object () = 0;
4486@};
4487void draw (struct Object*);
4488@end smallexample
4489
4490It is not wrong to declare a class with the class-key @code{struct} as
4491the example above shows. The @option{-Wmismatched-tags} option is intended
4492to help achieve a consistent style of class declarations. In code that is
4493intended to be portable to Windows-based compilers the warning helps prevent
4494unresolved references due to the difference in the mangling of symbols
4495declared with different class-keys. The option can be used either on its
4496own or in conjunction with @option{-Wredundant-tags}.
4497
d77de738
ML
4498@opindex Wmultiple-inheritance
4499@opindex Wno-multiple-inheritance
ddf6fe37 4500@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4501Warn when a class is defined with multiple direct base classes. Some
4502coding rules disallow multiple inheritance, and this may be used to
4503enforce that rule. The warning is inactive inside a system header file,
4504such as the STL, so one can still use the STL. One may also define
4505classes that indirectly use multiple inheritance.
4506
d77de738
ML
4507@opindex Wvirtual-inheritance
4508@opindex Wno-virtual-inheritance
ddf6fe37 4509@item -Wvirtual-inheritance
d77de738
ML
4510Warn when a class is defined with a virtual direct base class. Some
4511coding rules disallow multiple inheritance, and this may be used to
4512enforce that rule. The warning is inactive inside a system header file,
4513such as the STL, so one can still use the STL. One may also define
4514classes that indirectly use virtual inheritance.
4515
d77de738
ML
4516@opindex Wvirtual-move-assign
4517@opindex Wno-virtual-move-assign
ddf6fe37 4518@item -Wno-virtual-move-assign
d77de738
ML
4519Suppress warnings about inheriting from a virtual base with a
4520non-trivial C++11 move assignment operator. This is dangerous because
4521if the virtual base is reachable along more than one path, it is
4522moved multiple times, which can mean both objects end up in the
4523moved-from state. If the move assignment operator is written to avoid
4524moving from a moved-from object, this warning can be disabled.
4525
d77de738
ML
4526@opindex Wnamespaces
4527@opindex Wno-namespaces
ddf6fe37 4528@item -Wnamespaces
d77de738
ML
4529Warn when a namespace definition is opened. Some coding rules disallow
4530namespaces, and this may be used to enforce that rule. The warning is
4531inactive inside a system header file, such as the STL, so one can still
4532use the STL. One may also use using directives and qualified names.
4533
d77de738
ML
4534@opindex Wterminate
4535@opindex Wno-terminate
ddf6fe37 4536@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4537Disable the warning about a throw-expression that will immediately
4538result in a call to @code{terminate}.
4539
d77de738
ML
4540@opindex Wvexing-parse
4541@opindex Wno-vexing-parse
ddf6fe37 4542@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4543Warn about the most vexing parse syntactic ambiguity. This warns about
4544the cases when a declaration looks like a variable definition, but the
4545C++ language requires it to be interpreted as a function declaration.
4546For instance:
4547
4548@smallexample
4549void f(double a) @{
4550 int i(); // extern int i (void);
4551 int n(int(a)); // extern int n (int);
4552@}
4553@end smallexample
4554
4555Another example:
4556
4557@smallexample
4558struct S @{ S(int); @};
4559void f(double a) @{
4560 S x(int(a)); // extern struct S x (int);
4561 S y(int()); // extern struct S y (int (*) (void));
4562 S z(); // extern struct S z (void);
4563@}
4564@end smallexample
4565
4566The warning will suggest options how to deal with such an ambiguity; e.g.,
4567it can suggest removing the parentheses or using braces instead.
4568
4569This warning is enabled by default.
4570
d77de738
ML
4571@opindex Wno-class-conversion
4572@opindex Wclass-conversion
ddf6fe37 4573@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4574Do not warn when a conversion function converts an
4575object to the same type, to a base class of that type, or to void; such
4576a conversion function will never be called.
4577
d77de738
ML
4578@opindex Wvolatile
4579@opindex Wno-volatile
ddf6fe37 4580@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4581Warn about deprecated uses of the @code{volatile} qualifier. This includes
4582postfix and prefix @code{++} and @code{--} expressions of
4583@code{volatile}-qualified types, using simple assignments where the left
4584operand is a @code{volatile}-qualified non-class type for their value,
4585compound assignments where the left operand is a @code{volatile}-qualified
4586non-class type, @code{volatile}-qualified function return type,
4587@code{volatile}-qualified parameter type, and structured bindings of a
4588@code{volatile}-qualified type. This usage was deprecated in C++20.
4589
4590Enabled by default with @option{-std=c++20}.
4591
d77de738
ML
4592@opindex Wzero-as-null-pointer-constant
4593@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4594@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4595Warn when a literal @samp{0} is used as null pointer constant. This can
4596be useful to facilitate the conversion to @code{nullptr} in C++11.
4597
d77de738
ML
4598@opindex Waligned-new
4599@opindex Wno-aligned-new
ddf6fe37 4600@item -Waligned-new
d77de738
ML
4601Warn about a new-expression of a type that requires greater alignment
4602than the @code{alignof(std::max_align_t)} but uses an allocation
4603function without an explicit alignment parameter. This option is
4604enabled by @option{-Wall}.
4605
4606Normally this only warns about global allocation functions, but
4607@option{-Waligned-new=all} also warns about class member allocation
4608functions.
4609
d77de738
ML
4610@opindex Wplacement-new
4611@opindex Wno-placement-new
ddf6fe37
AA
4612@item -Wno-placement-new
4613@itemx -Wplacement-new=@var{n}
d77de738
ML
4614Warn about placement new expressions with undefined behavior, such as
4615constructing an object in a buffer that is smaller than the type of
4616the object. For example, the placement new expression below is diagnosed
4617because it attempts to construct an array of 64 integers in a buffer only
461864 bytes large.
4619@smallexample
4620char buf [64];
4621new (buf) int[64];
4622@end smallexample
4623This warning is enabled by default.
4624
4625@table @gcctabopt
4626@item -Wplacement-new=1
4627This is the default warning level of @option{-Wplacement-new}. At this
4628level the warning is not issued for some strictly undefined constructs that
4629GCC allows as extensions for compatibility with legacy code. For example,
4630the following @code{new} expression is not diagnosed at this level even
4631though it has undefined behavior according to the C++ standard because
4632it writes past the end of the one-element array.
4633@smallexample
4634struct S @{ int n, a[1]; @};
4635S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4636new (s->a)int [32]();
4637@end smallexample
4638
4639@item -Wplacement-new=2
4640At this level, in addition to diagnosing all the same constructs as at level
46411, a diagnostic is also issued for placement new expressions that construct
4642an object in the last member of structure whose type is an array of a single
4643element and whose size is less than the size of the object being constructed.
4644While the previous example would be diagnosed, the following construct makes
4645use of the flexible member array extension to avoid the warning at level 2.
4646@smallexample
4647struct S @{ int n, a[]; @};
4648S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4649new (s->a)int [32]();
4650@end smallexample
4651
4652@end table
4653
d77de738
ML
4654@opindex Wcatch-value
4655@opindex Wno-catch-value
ddf6fe37
AA
4656@item -Wcatch-value
4657@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4658Warn about catch handlers that do not catch via reference.
4659With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4660warn about polymorphic class types that are caught by value.
4661With @option{-Wcatch-value=2} warn about all class types that are caught
4662by value. With @option{-Wcatch-value=3} warn about all types that are
4663not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4664
d77de738
ML
4665@opindex Wconditionally-supported
4666@opindex Wno-conditionally-supported
ddf6fe37 4667@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4668Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4669
d77de738
ML
4670@opindex Wdelete-incomplete
4671@opindex Wno-delete-incomplete
ddf6fe37 4672@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4673Do not warn when deleting a pointer to incomplete type, which may cause
4674undefined behavior at runtime. This warning is enabled by default.
4675
d77de738
ML
4676@opindex Wextra-semi
4677@opindex Wno-extra-semi
ddf6fe37 4678@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4679Warn about redundant semicolons after in-class function definitions.
4680
d77de738
ML
4681@opindex Winaccessible-base
4682@opindex Wno-inaccessible-base
ddf6fe37 4683@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4684This option controls warnings
4685when a base class is inaccessible in a class derived from it due to
4686ambiguity. The warning is enabled by default.
4687Note that the warning for ambiguous virtual
4688bases is enabled by the @option{-Wextra} option.
4689@smallexample
4690@group
4691struct A @{ int a; @};
4692
4693struct B : A @{ @};
4694
4695struct C : B, A @{ @};
4696@end group
4697@end smallexample
4698
d77de738
ML
4699@opindex Winherited-variadic-ctor
4700@opindex Wno-inherited-variadic-ctor
ddf6fe37 4701@item -Wno-inherited-variadic-ctor
d77de738
ML
4702Suppress warnings about use of C++11 inheriting constructors when the
4703base class inherited from has a C variadic constructor; the warning is
4704on by default because the ellipsis is not inherited.
4705
d77de738
ML
4706@opindex Wno-invalid-offsetof
4707@opindex Winvalid-offsetof
ddf6fe37 4708@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4709Suppress warnings from applying the @code{offsetof} macro to a non-POD
4710type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4711to a non-standard-layout type is undefined. In existing C++ implementations,
4712however, @code{offsetof} typically gives meaningful results.
4713This flag is for users who are aware that they are
4714writing nonportable code and who have deliberately chosen to ignore the
4715warning about it.
4716
4717The restrictions on @code{offsetof} may be relaxed in a future version
4718of the C++ standard.
4719
d77de738
ML
4720@opindex Wsized-deallocation
4721@opindex Wno-sized-deallocation
ddf6fe37 4722@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4723Warn about a definition of an unsized deallocation function
4724@smallexample
4725void operator delete (void *) noexcept;
4726void operator delete[] (void *) noexcept;
4727@end smallexample
4728without a definition of the corresponding sized deallocation function
4729@smallexample
4730void operator delete (void *, std::size_t) noexcept;
4731void operator delete[] (void *, std::size_t) noexcept;
4732@end smallexample
4733or vice versa. Enabled by @option{-Wextra} along with
4734@option{-fsized-deallocation}.
4735
d77de738
ML
4736@opindex Wno-suggest-final-types
4737@opindex Wsuggest-final-types
ddf6fe37 4738@item -Wsuggest-final-types
d77de738
ML
4739Warn about types with virtual methods where code quality would be improved
4740if the type were declared with the C++11 @code{final} specifier,
4741or, if possible,
4742declared in an anonymous namespace. This allows GCC to more aggressively
4743devirtualize the polymorphic calls. This warning is more effective with
4744link-time optimization,
4745where the information about the class hierarchy graph is
4746more complete.
4747
d77de738
ML
4748@opindex Wno-suggest-final-methods
4749@opindex Wsuggest-final-methods
ddf6fe37 4750@item -Wsuggest-final-methods
d77de738
ML
4751Warn about virtual methods where code quality would be improved if the method
4752were declared with the C++11 @code{final} specifier,
4753or, if possible, its type were
4754declared in an anonymous namespace or with the @code{final} specifier.
4755This warning is
4756more effective with link-time optimization, where the information about the
4757class hierarchy graph is more complete. It is recommended to first consider
4758suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4759annotations.
4760
d77de738
ML
4761@opindex Wsuggest-override
4762@opindex Wno-suggest-override
ddf6fe37 4763@item -Wsuggest-override
d77de738
ML
4764Warn about overriding virtual functions that are not marked with the
4765@code{override} keyword.
4766
d77de738
ML
4767@opindex Wuse-after-free
4768@opindex Wno-use-after-free
ddf6fe37
AA
4769@item -Wuse-after-free
4770@itemx -Wuse-after-free=@var{n}
d77de738
ML
4771Warn about uses of pointers to dynamically allocated objects that have
4772been rendered indeterminate by a call to a deallocation function.
4773The warning is enabled at all optimization levels but may yield different
4774results with optimization than without.
4775
4776@table @gcctabopt
4777@item -Wuse-after-free=1
4778At level 1 the warning attempts to diagnose only unconditional uses
4779of pointers made indeterminate by a deallocation call or a successful
4780call to @code{realloc}, regardless of whether or not the call resulted
4781in an actual reallocatio of memory. This includes double-@code{free}
4782calls as well as uses in arithmetic and relational expressions. Although
4783undefined, uses of indeterminate pointers in equality (or inequality)
4784expressions are not diagnosed at this level.
4785@item -Wuse-after-free=2
4786At level 2, in addition to unconditional uses, the warning also diagnoses
4787conditional uses of pointers made indeterminate by a deallocation call.
4788As at level 2, uses in equality (or inequality) expressions are not
4789diagnosed. For example, the second call to @code{free} in the following
4790function is diagnosed at this level:
4791@smallexample
4792struct A @{ int refcount; void *data; @};
4793
4794void release (struct A *p)
4795@{
4796 int refcount = --p->refcount;
4797 free (p);
4798 if (refcount == 0)
4799 free (p->data); // warning: p may be used after free
4800@}
4801@end smallexample
4802@item -Wuse-after-free=3
4803At level 3, the warning also diagnoses uses of indeterminate pointers in
4804equality expressions. All uses of indeterminate pointers are undefined
4805but equality tests sometimes appear after calls to @code{realloc} as
4806an attempt to determine whether the call resulted in relocating the object
4807to a different address. They are diagnosed at a separate level to aid
4808legacy code gradually transition to safe alternatives. For example,
4809the equality test in the function below is diagnosed at this level:
4810@smallexample
4811void adjust_pointers (int**, int);
4812
4813void grow (int **p, int n)
4814@{
4815 int **q = (int**)realloc (p, n *= 2);
4816 if (q == p)
4817 return;
4818 adjust_pointers ((int**)q, n);
4819@}
4820@end smallexample
4821To avoid the warning at this level, store offsets into allocated memory
4822instead of pointers. This approach obviates needing to adjust the stored
4823pointers after reallocation.
4824@end table
4825
4826@option{-Wuse-after-free=2} is included in @option{-Wall}.
4827
d77de738
ML
4828@opindex Wuseless-cast
4829@opindex Wno-useless-cast
68783211 4830@item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
4831Warn when an expression is cast to its own type. This warning does not
4832occur when a class object is converted to a non-reference type as that
4833is a way to create a temporary:
4834
4835@smallexample
4836struct S @{ @};
4837void g (S&&);
4838void f (S&& arg)
4839@{
4840 g (S(arg)); // make arg prvalue so that it can bind to S&&
4841@}
4842@end smallexample
4843
d77de738
ML
4844@opindex Wconversion-null
4845@opindex Wno-conversion-null
ddf6fe37 4846@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4847Do not warn for conversions between @code{NULL} and non-pointer
4848types. @option{-Wconversion-null} is enabled by default.
4849
4850@end table
4851
4852@node Objective-C and Objective-C++ Dialect Options
4853@section Options Controlling Objective-C and Objective-C++ Dialects
4854
4855@cindex compiler options, Objective-C and Objective-C++
4856@cindex Objective-C and Objective-C++ options, command-line
4857@cindex options, Objective-C and Objective-C++
4858(NOTE: This manual does not describe the Objective-C and Objective-C++
4859languages themselves. @xref{Standards,,Language Standards
4860Supported by GCC}, for references.)
4861
4862This section describes the command-line options that are only meaningful
4863for Objective-C and Objective-C++ programs. You can also use most of
4864the language-independent GNU compiler options.
4865For example, you might compile a file @file{some_class.m} like this:
4866
4867@smallexample
4868gcc -g -fgnu-runtime -O -c some_class.m
4869@end smallexample
4870
4871@noindent
4872In this example, @option{-fgnu-runtime} is an option meant only for
4873Objective-C and Objective-C++ programs; you can use the other options with
4874any language supported by GCC@.
4875
4876Note that since Objective-C is an extension of the C language, Objective-C
4877compilations may also use options specific to the C front-end (e.g.,
4878@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4879C++-specific options (e.g., @option{-Wabi}).
4880
4881Here is a list of options that are @emph{only} for compiling Objective-C
4882and Objective-C++ programs:
4883
4884@table @gcctabopt
d77de738 4885@opindex fconstant-string-class
ddf6fe37 4886@item -fconstant-string-class=@var{class-name}
d77de738
ML
4887Use @var{class-name} as the name of the class to instantiate for each
4888literal string specified with the syntax @code{@@"@dots{}"}. The default
4889class name is @code{NXConstantString} if the GNU runtime is being used, and
cdd4b3c0 4890@code{NSConstantString} if the NeXT runtime is being used (see below). On
a335cf24 4891Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
cdd4b3c0
IS
4892also present, overrides the @option{-fconstant-string-class} setting and cause
4893@code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
4894Note that @option{-fconstant-cfstrings} is an alias for the target-specific
4895@option{-mconstant-cfstrings} equivalent.
d77de738 4896
d77de738 4897@opindex fgnu-runtime
ddf6fe37 4898@item -fgnu-runtime
d77de738
ML
4899Generate object code compatible with the standard GNU Objective-C
4900runtime. This is the default for most types of systems.
4901
d77de738 4902@opindex fnext-runtime
ddf6fe37 4903@item -fnext-runtime
d77de738 4904Generate output compatible with the NeXT runtime. This is the default
a335cf24 4905for NeXT-based systems, including Darwin / macOS. The macro
d77de738
ML
4906@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4907used.
4908
d77de738
ML
4909@opindex fno-nil-receivers
4910@opindex fnil-receivers
ddf6fe37 4911@item -fno-nil-receivers
d77de738
ML
4912Assume that all Objective-C message dispatches (@code{[receiver
4913message:arg]}) in this translation unit ensure that the receiver is
4914not @code{nil}. This allows for more efficient entry points in the
4915runtime to be used. This option is only available in conjunction with
4916the NeXT runtime and ABI version 0 or 1.
4917
d77de738 4918@opindex fobjc-abi-version
ddf6fe37 4919@item -fobjc-abi-version=@var{n}
d77de738
ML
4920Use version @var{n} of the Objective-C ABI for the selected runtime.
4921This option is currently supported only for the NeXT runtime. In that
4922case, Version 0 is the traditional (32-bit) ABI without support for
4923properties and other Objective-C 2.0 additions. Version 1 is the
4924traditional (32-bit) ABI with support for properties and other
4925Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4926nothing is specified, the default is Version 0 on 32-bit target
4927machines, and Version 2 on 64-bit target machines.
4928
d77de738 4929@opindex fobjc-call-cxx-cdtors
ddf6fe37 4930@item -fobjc-call-cxx-cdtors
d77de738
ML
4931For each Objective-C class, check if any of its instance variables is a
4932C++ object with a non-trivial default constructor. If so, synthesize a
4933special @code{- (id) .cxx_construct} instance method which runs
4934non-trivial default constructors on any such instance variables, in order,
4935and then return @code{self}. Similarly, check if any instance variable
4936is a C++ object with a non-trivial destructor, and if so, synthesize a
4937special @code{- (void) .cxx_destruct} method which runs
4938all such default destructors, in reverse order.
4939
4940The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4941methods thusly generated only operate on instance variables
4942declared in the current Objective-C class, and not those inherited
4943from superclasses. It is the responsibility of the Objective-C
4944runtime to invoke all such methods in an object's inheritance
4945hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4946by the runtime immediately after a new object instance is allocated;
4947the @code{- (void) .cxx_destruct} methods are invoked immediately
4948before the runtime deallocates an object instance.
4949
4950As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4951support for invoking the @code{- (id) .cxx_construct} and
4952@code{- (void) .cxx_destruct} methods.
4953
d77de738 4954@opindex fobjc-direct-dispatch
ddf6fe37 4955@item -fobjc-direct-dispatch
d77de738
ML
4956Allow fast jumps to the message dispatcher. On Darwin this is
4957accomplished via the comm page.
4958
d77de738 4959@opindex fobjc-exceptions
ddf6fe37 4960@item -fobjc-exceptions
d77de738
ML
4961Enable syntactic support for structured exception handling in
4962Objective-C, similar to what is offered by C++. This option
4963is required to use the Objective-C keywords @code{@@try},
4964@code{@@throw}, @code{@@catch}, @code{@@finally} and
4965@code{@@synchronized}. This option is available with both the GNU
4966runtime and the NeXT runtime (but not available in conjunction with
4967the NeXT runtime on Mac OS X 10.2 and earlier).
4968
d77de738 4969@opindex fobjc-gc
ddf6fe37 4970@item -fobjc-gc
d77de738
ML
4971Enable garbage collection (GC) in Objective-C and Objective-C++
4972programs. This option is only available with the NeXT runtime; the
4973GNU runtime has a different garbage collection implementation that
4974does not require special compiler flags.
4975
d77de738 4976@opindex fobjc-nilcheck
ddf6fe37 4977@item -fobjc-nilcheck
d77de738
ML
4978For the NeXT runtime with version 2 of the ABI, check for a nil
4979receiver in method invocations before doing the actual method call.
4980This is the default and can be disabled using
4981@option{-fno-objc-nilcheck}. Class methods and super calls are never
4982checked for nil in this way no matter what this flag is set to.
4983Currently this flag does nothing when the GNU runtime, or an older
4984version of the NeXT runtime ABI, is used.
4985
d77de738 4986@opindex fobjc-std
ddf6fe37 4987@item -fobjc-std=objc1
d77de738
ML
4988Conform to the language syntax of Objective-C 1.0, the language
4989recognized by GCC 4.0. This only affects the Objective-C additions to
4990the C/C++ language; it does not affect conformance to C/C++ standards,
4991which is controlled by the separate C/C++ dialect option flags. When
4992this option is used with the Objective-C or Objective-C++ compiler,
4993any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4994This is useful if you need to make sure that your Objective-C code can
4995be compiled with older versions of GCC@.
4996
d77de738 4997@opindex freplace-objc-classes
ddf6fe37 4998@item -freplace-objc-classes
d77de738
ML
4999Emit a special marker instructing @command{ld(1)} not to statically link in
5000the resulting object file, and allow @command{dyld(1)} to load it in at
5001run time instead. This is used in conjunction with the Fix-and-Continue
5002debugging mode, where the object file in question may be recompiled and
5003dynamically reloaded in the course of program execution, without the need
5004to restart the program itself. Currently, Fix-and-Continue functionality
5005is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5006and later.
5007
d77de738 5008@opindex fzero-link
ddf6fe37 5009@item -fzero-link
d77de738
ML
5010When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5011to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5012compile time) with static class references that get initialized at load time,
5013which improves run-time performance. Specifying the @option{-fzero-link} flag
5014suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5015to be retained. This is useful in Zero-Link debugging mode, since it allows
5016for individual class implementations to be modified during program execution.
5017The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5018regardless of command-line options.
5019
d77de738
ML
5020@opindex fno-local-ivars
5021@opindex flocal-ivars
ddf6fe37 5022@item -fno-local-ivars
d77de738
ML
5023By default instance variables in Objective-C can be accessed as if
5024they were local variables from within the methods of the class they're
5025declared in. This can lead to shadowing between instance variables
5026and other variables declared either locally inside a class method or
5027globally with the same name. Specifying the @option{-fno-local-ivars}
5028flag disables this behavior thus avoiding variable shadowing issues.
5029
d77de738 5030@opindex fivar-visibility
ddf6fe37 5031@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
5032Set the default instance variable visibility to the specified option
5033so that instance variables declared outside the scope of any access
5034modifier directives default to the specified visibility.
5035
d77de738 5036@opindex gen-decls
ddf6fe37 5037@item -gen-decls
d77de738
ML
5038Dump interface declarations for all classes seen in the source file to a
5039file named @file{@var{sourcename}.decl}.
5040
d77de738
ML
5041@opindex Wassign-intercept
5042@opindex Wno-assign-intercept
ddf6fe37 5043@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5044Warn whenever an Objective-C assignment is being intercepted by the
5045garbage collector.
5046
d77de738
ML
5047@opindex Wproperty-assign-default
5048@opindex Wno-property-assign-default
ddf6fe37 5049@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5050Do not warn if a property for an Objective-C object has no assign
5051semantics specified.
5052
d77de738
ML
5053@opindex Wno-protocol
5054@opindex Wprotocol
ddf6fe37 5055@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5056If a class is declared to implement a protocol, a warning is issued for
5057every method in the protocol that is not implemented by the class. The
5058default behavior is to issue a warning for every method not explicitly
5059implemented in the class, even if a method implementation is inherited
5060from the superclass. If you use the @option{-Wno-protocol} option, then
5061methods inherited from the superclass are considered to be implemented,
5062and no warning is issued for them.
5063
d77de738 5064@opindex Wobjc-root-class
ddf6fe37 5065@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5066Warn if a class interface lacks a superclass. Most classes will inherit
5067from @code{NSObject} (or @code{Object}) for example. When declaring
5068classes intended to be root classes, the warning can be suppressed by
5069marking their interfaces with @code{__attribute__((objc_root_class))}.
5070
d77de738
ML
5071@opindex Wselector
5072@opindex Wno-selector
ddf6fe37 5073@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5074Warn if multiple methods of different types for the same selector are
5075found during compilation. The check is performed on the list of methods
5076in the final stage of compilation. Additionally, a check is performed
5077for each selector appearing in a @code{@@selector(@dots{})}
5078expression, and a corresponding method for that selector has been found
5079during compilation. Because these checks scan the method table only at
5080the end of compilation, these warnings are not produced if the final
5081stage of compilation is not reached, for example because an error is
5082found during compilation, or because the @option{-fsyntax-only} option is
5083being used.
5084
d77de738
ML
5085@opindex Wstrict-selector-match
5086@opindex Wno-strict-selector-match
ddf6fe37 5087@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5088Warn if multiple methods with differing argument and/or return types are
5089found for a given selector when attempting to send a message using this
5090selector to a receiver of type @code{id} or @code{Class}. When this flag
5091is off (which is the default behavior), the compiler omits such warnings
5092if any differences found are confined to types that share the same size
5093and alignment.
5094
d77de738
ML
5095@opindex Wundeclared-selector
5096@opindex Wno-undeclared-selector
ddf6fe37 5097@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5098Warn if a @code{@@selector(@dots{})} expression referring to an
5099undeclared selector is found. A selector is considered undeclared if no
5100method with that name has been declared before the
5101@code{@@selector(@dots{})} expression, either explicitly in an
5102@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5103an @code{@@implementation} section. This option always performs its
5104checks as soon as a @code{@@selector(@dots{})} expression is found,
5105while @option{-Wselector} only performs its checks in the final stage of
5106compilation. This also enforces the coding style convention
5107that methods and selectors must be declared before being used.
5108
d77de738 5109@opindex print-objc-runtime-info
ddf6fe37 5110@item -print-objc-runtime-info
d77de738
ML
5111Generate C header describing the largest structure that is passed by
5112value, if any.
5113
5114@end table
5115
5116@node Diagnostic Message Formatting Options
5117@section Options to Control Diagnostic Messages Formatting
5118@cindex options to control diagnostics formatting
5119@cindex diagnostic messages
5120@cindex message formatting
5121
5122Traditionally, diagnostic messages have been formatted irrespective of
5123the output device's aspect (e.g.@: its width, @dots{}). You can use the
5124options described below
5125to control the formatting algorithm for diagnostic messages,
5126e.g.@: how many characters per line, how often source location
5127information should be reported. Note that some language front ends may not
5128honor these options.
5129
5130@table @gcctabopt
d77de738 5131@opindex fmessage-length
ddf6fe37 5132@item -fmessage-length=@var{n}
d77de738
ML
5133Try to format error messages so that they fit on lines of about
5134@var{n} characters. If @var{n} is zero, then no line-wrapping is
5135done; each error message appears on a single line. This is the
5136default for all front ends.
5137
5138Note - this option also affects the display of the @samp{#error} and
5139@samp{#warning} pre-processor directives, and the @samp{deprecated}
5140function/type/variable attribute. It does not however affect the
5141@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5142
5143@item -fdiagnostics-plain-output
5144This option requests that diagnostic output look as plain as possible, which
5145may be useful when running @command{dejagnu} or other utilities that need to
5146parse diagnostics output and prefer that it remain more stable over time.
5147@option{-fdiagnostics-plain-output} is currently equivalent to the following
5148options:
43b72ede
AA
5149@gccoptlist{-fno-diagnostics-show-caret
5150-fno-diagnostics-show-line-numbers
5151-fdiagnostics-color=never
5152-fdiagnostics-urls=never
4f01ae37
DM
5153-fdiagnostics-path-format=separate-events
5154-fdiagnostics-text-art-charset=none}
d77de738
ML
5155In the future, if GCC changes the default appearance of its diagnostics, the
5156corresponding option to disable the new behavior will be added to this list.
5157
d77de738 5158@opindex fdiagnostics-show-location
ddf6fe37 5159@item -fdiagnostics-show-location=once
d77de738
ML
5160Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5161reporter to emit source location information @emph{once}; that is, in
5162case the message is too long to fit on a single physical line and has to
5163be wrapped, the source location won't be emitted (as prefix) again,
5164over and over, in subsequent continuation lines. This is the default
5165behavior.
5166
5167@item -fdiagnostics-show-location=every-line
5168Only meaningful in line-wrapping mode. Instructs the diagnostic
5169messages reporter to emit the same source location information (as
5170prefix) for physical lines that result from the process of breaking
5171a message which is too long to fit on a single line.
5172
ddf6fe37 5173@opindex fdiagnostics-color
d77de738
ML
5174@cindex highlight, color
5175@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5176@item -fdiagnostics-color[=@var{WHEN}]
5177@itemx -fno-diagnostics-color
d77de738
ML
5178Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5179or @samp{auto}. The default depends on how the compiler has been configured,
5180it can be any of the above @var{WHEN} options or also @samp{never}
5181if @env{GCC_COLORS} environment variable isn't present in the environment,
5182and @samp{auto} otherwise.
5183@samp{auto} makes GCC use color only when the standard error is a terminal,
5184and when not executing in an emacs shell.
5185The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5186aliases for @option{-fdiagnostics-color=always} and
5187@option{-fdiagnostics-color=never}, respectively.
5188
5189The colors are defined by the environment variable @env{GCC_COLORS}.
5190Its value is a colon-separated list of capabilities and Select Graphic
5191Rendition (SGR) substrings. SGR commands are interpreted by the
5192terminal or terminal emulator. (See the section in the documentation
5193of your text terminal for permitted values and their meanings as
5194character attributes.) These substring values are integers in decimal
5195representation and can be concatenated with semicolons.
5196Common values to concatenate include
5197@samp{1} for bold,
5198@samp{4} for underline,
5199@samp{5} for blink,
5200@samp{7} for inverse,
5201@samp{39} for default foreground color,
5202@samp{30} to @samp{37} for foreground colors,
5203@samp{90} to @samp{97} for 16-color mode foreground colors,
5204@samp{38;5;0} to @samp{38;5;255}
5205for 88-color and 256-color modes foreground colors,
5206@samp{49} for default background color,
5207@samp{40} to @samp{47} for background colors,
5208@samp{100} to @samp{107} for 16-color mode background colors,
5209and @samp{48;5;0} to @samp{48;5;255}
5210for 88-color and 256-color modes background colors.
5211
5212The default @env{GCC_COLORS} is
5213@smallexample
5214error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5215quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5216diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5217type-diff=01;32:fnname=01;32:targs=35
5218@end smallexample
5219@noindent
5220where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5221@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5222@samp{01} is bold, and @samp{31} is red.
5223Setting @env{GCC_COLORS} to the empty string disables colors.
5224Supported capabilities are as follows.
5225
5226@table @code
d77de738 5227@vindex error GCC_COLORS @r{capability}
f33d7a88 5228@item error=
d77de738
ML
5229SGR substring for error: markers.
5230
d77de738 5231@vindex warning GCC_COLORS @r{capability}
f33d7a88 5232@item warning=
d77de738
ML
5233SGR substring for warning: markers.
5234
d77de738 5235@vindex note GCC_COLORS @r{capability}
f33d7a88 5236@item note=
d77de738
ML
5237SGR substring for note: markers.
5238
d77de738 5239@vindex path GCC_COLORS @r{capability}
f33d7a88 5240@item path=
d77de738
ML
5241SGR substring for colorizing paths of control-flow events as printed
5242via @option{-fdiagnostics-path-format=}, such as the identifiers of
5243individual events and lines indicating interprocedural calls and returns.
5244
d77de738 5245@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5246@item range1=
d77de738
ML
5247SGR substring for first additional range.
5248
d77de738 5249@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5250@item range2=
d77de738
ML
5251SGR substring for second additional range.
5252
d77de738 5253@vindex locus GCC_COLORS @r{capability}
f33d7a88 5254@item locus=
d77de738
ML
5255SGR substring for location information, @samp{file:line} or
5256@samp{file:line:column} etc.
5257
d77de738 5258@vindex quote GCC_COLORS @r{capability}
f33d7a88 5259@item quote=
d77de738
ML
5260SGR substring for information printed within quotes.
5261
d77de738 5262@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5263@item fnname=
d77de738
ML
5264SGR substring for names of C++ functions.
5265
d77de738 5266@vindex targs GCC_COLORS @r{capability}
f33d7a88 5267@item targs=
d77de738
ML
5268SGR substring for C++ function template parameter bindings.
5269
d77de738 5270@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5271@item fixit-insert=
d77de738
ML
5272SGR substring for fix-it hints suggesting text to
5273be inserted or replaced.
5274
d77de738 5275@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5276@item fixit-delete=
d77de738
ML
5277SGR substring for fix-it hints suggesting text to
5278be deleted.
5279
d77de738 5280@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5281@item diff-filename=
d77de738
ML
5282SGR substring for filename headers within generated patches.
5283
d77de738 5284@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5285@item diff-hunk=
d77de738
ML
5286SGR substring for the starts of hunks within generated patches.
5287
d77de738 5288@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5289@item diff-delete=
d77de738
ML
5290SGR substring for deleted lines within generated patches.
5291
d77de738 5292@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5293@item diff-insert=
d77de738
ML
5294SGR substring for inserted lines within generated patches.
5295
d77de738 5296@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5297@item type-diff=
d77de738
ML
5298SGR substring for highlighting mismatching types within template
5299arguments in the C++ frontend.
5300@end table
5301
d77de738
ML
5302@opindex fdiagnostics-urls
5303@cindex urls
5304@vindex GCC_URLS @r{environment variable}
5305@vindex TERM_URLS @r{environment variable}
f33d7a88 5306@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5307Use escape sequences to embed URLs in diagnostics. For example, when
5308@option{-fdiagnostics-show-option} emits text showing the command-line
5309option controlling a diagnostic, embed a URL for documentation of that
5310option.
5311
5312@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5313@samp{auto} makes GCC use URL escape sequences only when the standard error
5314is a terminal, and when not executing in an emacs shell or any graphical
5315terminal which is known to be incompatible with this feature, see below.
5316
5317The default depends on how the compiler has been configured.
5318It can be any of the above @var{WHEN} options.
5319
5320GCC can also be configured (via the
5321@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5322so that the default is affected by environment variables.
5323Under such a configuration, GCC defaults to using @samp{auto}
5324if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5325present and non-empty in the environment of the compiler, or @samp{never}
5326if neither are.
5327
5328However, even with @option{-fdiagnostics-urls=always} the behavior is
5329dependent on those environment variables:
5330If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5331diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5332If set to @samp{bel}, the default, URLs use BEL escape sequences.
5333Any other non-empty value enables the feature.
5334If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5335Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5336BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5337
5338At this time GCC tries to detect also a few terminals that are known to
5339not implement the URL feature, and have bugs or at least had bugs in
5340some versions that are still in use, where the URL escapes are likely
5341to misbehave, i.e. print garbage on the screen.
5342That list is currently xfce4-terminal, certain known to be buggy
5343gnome-terminal versions, the linux console, and mingw.
5344This check can be skipped with the @option{-fdiagnostics-urls=always}.
5345
d77de738
ML
5346@opindex fno-diagnostics-show-option
5347@opindex fdiagnostics-show-option
ddf6fe37 5348@item -fno-diagnostics-show-option
d77de738
ML
5349By default, each diagnostic emitted includes text indicating the
5350command-line option that directly controls the diagnostic (if such an
5351option is known to the diagnostic machinery). Specifying the
5352@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5353
d77de738
ML
5354@opindex fno-diagnostics-show-caret
5355@opindex fdiagnostics-show-caret
ddf6fe37 5356@item -fno-diagnostics-show-caret
d77de738
ML
5357By default, each diagnostic emitted includes the original source line
5358and a caret @samp{^} indicating the column. This option suppresses this
5359information. The source line is truncated to @var{n} characters, if
5360the @option{-fmessage-length=n} option is given. When the output is done
5361to the terminal, the width is limited to the width given by the
5362@env{COLUMNS} environment variable or, if not set, to the terminal width.
5363
d77de738
ML
5364@opindex fno-diagnostics-show-labels
5365@opindex fdiagnostics-show-labels
ddf6fe37 5366@item -fno-diagnostics-show-labels
d77de738
ML
5367By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5368diagnostics can label ranges of source code with pertinent information, such
5369as the types of expressions:
5370
5371@smallexample
5372 printf ("foo %s bar", long_i + long_j);
5373 ~^ ~~~~~~~~~~~~~~~
5374 | |
5375 char * long int
5376@end smallexample
5377
5378This option suppresses the printing of these labels (in the example above,
5379the vertical bars and the ``char *'' and ``long int'' text).
5380
d77de738
ML
5381@opindex fno-diagnostics-show-cwe
5382@opindex fdiagnostics-show-cwe
ddf6fe37 5383@item -fno-diagnostics-show-cwe
d77de738
ML
5384Diagnostic messages can optionally have an associated
5385@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5386GCC itself only provides such metadata for some of the @option{-fanalyzer}
5387diagnostics. GCC plugins may also provide diagnostics with such metadata.
5388By default, if this information is present, it will be printed with
5389the diagnostic. This option suppresses the printing of this metadata.
5390
d77de738
ML
5391@opindex fno-diagnostics-show-rules
5392@opindex fdiagnostics-show-rules
ddf6fe37 5393@item -fno-diagnostics-show-rules
d77de738
ML
5394Diagnostic messages can optionally have rules associated with them, such
5395as from a coding standard, or a specification.
5396GCC itself does not do this for any of its diagnostics, but plugins may do so.
5397By default, if this information is present, it will be printed with
5398the diagnostic. This option suppresses the printing of this metadata.
5399
d77de738
ML
5400@opindex fno-diagnostics-show-line-numbers
5401@opindex fdiagnostics-show-line-numbers
ddf6fe37 5402@item -fno-diagnostics-show-line-numbers
d77de738
ML
5403By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5404a left margin is printed, showing line numbers. This option suppresses this
5405left margin.
5406
d77de738 5407@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5408@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5409This option controls the minimum width of the left margin printed by
5410@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5411
d77de738 5412@opindex fdiagnostics-parseable-fixits
ddf6fe37 5413@item -fdiagnostics-parseable-fixits
d77de738
ML
5414Emit fix-it hints in a machine-parseable format, suitable for consumption
5415by IDEs. For each fix-it, a line will be printed after the relevant
5416diagnostic, starting with the string ``fix-it:''. For example:
5417
5418@smallexample
5419fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5420@end smallexample
5421
5422The location is expressed as a half-open range, expressed as a count of
5423bytes, starting at byte 1 for the initial column. In the above example,
5424bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5425given string:
5426
5427@smallexample
542800000000011111111112222222222
542912345678901234567890123456789
5430 gtk_widget_showall (dlg);
5431 ^^^^^^^^^^^^^^^^^^
5432 gtk_widget_show_all
5433@end smallexample
5434
5435The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5436newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5437(e.g. vertical tab as ``\013'').
5438
5439An empty replacement string indicates that the given range is to be removed.
5440An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5441be inserted at the given position.
5442
d77de738 5443@opindex fdiagnostics-generate-patch
ddf6fe37 5444@item -fdiagnostics-generate-patch
d77de738
ML
5445Print fix-it hints to stderr in unified diff format, after any diagnostics
5446are printed. For example:
5447
5448@smallexample
5449--- test.c
5450+++ test.c
5451@@ -42,5 +42,5 @@
5452
5453 void show_cb(GtkDialog *dlg)
5454 @{
5455- gtk_widget_showall(dlg);
5456+ gtk_widget_show_all(dlg);
5457 @}
5458
5459@end smallexample
5460
5461The diff may or may not be colorized, following the same rules
5462as for diagnostics (see @option{-fdiagnostics-color}).
5463
d77de738 5464@opindex fdiagnostics-show-template-tree
ddf6fe37 5465@item -fdiagnostics-show-template-tree
d77de738
ML
5466
5467In the C++ frontend, when printing diagnostics showing mismatching
5468template types, such as:
5469
5470@smallexample
5471 could not convert 'std::map<int, std::vector<double> >()'
5472 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5473@end smallexample
5474
5475the @option{-fdiagnostics-show-template-tree} flag enables printing a
5476tree-like structure showing the common and differing parts of the types,
5477such as:
5478
5479@smallexample
5480 map<
5481 [...],
5482 vector<
5483 [double != float]>>
5484@end smallexample
5485
5486The parts that differ are highlighted with color (``double'' and
5487``float'' in this case).
5488
d77de738
ML
5489@opindex fno-elide-type
5490@opindex felide-type
ddf6fe37 5491@item -fno-elide-type
d77de738
ML
5492By default when the C++ frontend prints diagnostics showing mismatching
5493template types, common parts of the types are printed as ``[...]'' to
5494simplify the error message. For example:
5495
5496@smallexample
5497 could not convert 'std::map<int, std::vector<double> >()'
5498 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5499@end smallexample
5500
5501Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5502This flag also affects the output of the
5503@option{-fdiagnostics-show-template-tree} flag.
5504
d77de738 5505@opindex fdiagnostics-path-format
ddf6fe37 5506@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5507Specify how to print paths of control-flow events for diagnostics that
5508have such a path associated with them.
5509
5510@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5511the default.
5512
5513@samp{none} means to not print diagnostic paths.
5514
5515@samp{separate-events} means to print a separate ``note'' diagnostic for
5516each event within the diagnostic. For example:
5517
5518@smallexample
5519test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5520test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5521test.c:27:3: note: (2) when 'i < count'
5522test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5523@end smallexample
5524
5525@samp{inline-events} means to print the events ``inline'' within the source
5526code. This view attempts to consolidate the events into runs of
5527sufficiently-close events, printing them as labelled ranges within the source.
5528
5529For example, the same events as above might be printed as:
5530
5531@smallexample
5532 'test': events 1-3
5533 |
5534 | 25 | list = PyList_New(0);
5535 | | ^~~~~~~~~~~~~
5536 | | |
5537 | | (1) when 'PyList_New' fails, returning NULL
5538 | 26 |
5539 | 27 | for (i = 0; i < count; i++) @{
5540 | | ~~~
5541 | | |
5542 | | (2) when 'i < count'
5543 | 28 | item = PyLong_FromLong(random());
5544 | 29 | PyList_Append(list, item);
5545 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5546 | | |
5547 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5548 |
5549@end smallexample
5550
5551Interprocedural control flow is shown by grouping the events by stack frame,
5552and using indentation to show how stack frames are nested, pushed, and popped.
5553
5554For example:
5555
5556@smallexample
5557 'test': events 1-2
5558 |
5559 | 133 | @{
5560 | | ^
5561 | | |
5562 | | (1) entering 'test'
5563 | 134 | boxed_int *obj = make_boxed_int (i);
5564 | | ~~~~~~~~~~~~~~~~~~
5565 | | |
5566 | | (2) calling 'make_boxed_int'
5567 |
5568 +--> 'make_boxed_int': events 3-4
5569 |
5570 | 120 | @{
5571 | | ^
5572 | | |
5573 | | (3) entering 'make_boxed_int'
5574 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5575 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5576 | | |
5577 | | (4) calling 'wrapped_malloc'
5578 |
5579 +--> 'wrapped_malloc': events 5-6
5580 |
5581 | 7 | @{
5582 | | ^
5583 | | |
5584 | | (5) entering 'wrapped_malloc'
5585 | 8 | return malloc (size);
5586 | | ~~~~~~~~~~~~~
5587 | | |
5588 | | (6) calling 'malloc'
5589 |
5590 <-------------+
5591 |
5592 'test': event 7
5593 |
5594 | 138 | free_boxed_int (obj);
5595 | | ^~~~~~~~~~~~~~~~~~~~
5596 | | |
5597 | | (7) calling 'free_boxed_int'
5598 |
5599(etc)
5600@end smallexample
5601
d77de738 5602@opindex fdiagnostics-show-path-depths
ddf6fe37 5603@item -fdiagnostics-show-path-depths
d77de738
ML
5604This option provides additional information when printing control-flow paths
5605associated with a diagnostic.
5606
5607If this is option is provided then the stack depth will be printed for
5608each run of events within @option{-fdiagnostics-path-format=inline-events}.
5609If provided with @option{-fdiagnostics-path-format=separate-events}, then
5610the stack depth and function declaration will be appended when printing
5611each event.
5612
5613This is intended for use by GCC developers and plugin developers when
5614debugging diagnostics that report interprocedural control flow.
5615
d77de738
ML
5616@opindex fno-show-column
5617@opindex fshow-column
ddf6fe37 5618@item -fno-show-column
d77de738
ML
5619Do not print column numbers in diagnostics. This may be necessary if
5620diagnostics are being scanned by a program that does not understand the
5621column numbers, such as @command{dejagnu}.
5622
d77de738 5623@opindex fdiagnostics-column-unit
ddf6fe37 5624@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5625Select the units for the column number. This affects traditional diagnostics
5626(in the absence of @option{-fno-show-column}), as well as JSON format
5627diagnostics if requested.
5628
5629The default @var{UNIT}, @samp{display}, considers the number of display
5630columns occupied by each character. This may be larger than the number
5631of bytes required to encode the character, in the case of tab
5632characters, or it may be smaller, in the case of multibyte characters.
5633For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5634display column, and its UTF-8 encoding requires two bytes; the character
5635``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5636its UTF-8 encoding requires four bytes.
5637
5638Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5639count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5640
d77de738 5641@opindex fdiagnostics-column-origin
ddf6fe37 5642@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5643Select the origin for column numbers, i.e. the column number assigned to the
5644first column. The default value of 1 corresponds to traditional GCC
5645behavior and to the GNU style guide. Some utilities may perform better with an
5646origin of 0; any non-negative value may be specified.
5647
d77de738 5648@opindex fdiagnostics-escape-format
ddf6fe37 5649@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5650When GCC prints pertinent source lines for a diagnostic it normally attempts
5651to print the source bytes directly. However, some diagnostics relate to encoding
5652issues in the source file, such as malformed UTF-8, or issues with Unicode
5653normalization. These diagnostics are flagged so that GCC will escape bytes
5654that are not printable ASCII when printing their pertinent source lines.
5655
5656This option controls how such bytes should be escaped.
5657
5658The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5659are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5660correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5661displayed as hexadecimal in the form @samp{<XX>}.
5662
5663For example, a source line containing the string @samp{before} followed by the
5664Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
56650xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5666the string @samp{after} will be printed for such a diagnostic as:
5667
5668@smallexample
5669 before<U+03C0><BF>after
5670@end smallexample
5671
5672Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5673in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5674Unicode characters. For the example above, the following will be printed:
5675
5676@smallexample
5677 before<CF><80><BF>after
5678@end smallexample
5679
4f01ae37
DM
5680@opindex fdiagnostics-text-art-charset
5681@item -fdiagnostics-text-art-charset=@var{CHARSET}
5682Some diagnostics can contain ``text art'' diagrams: visualizations created
5683from text, intended to be viewed in a monospaced font.
5684
5685This option selects which characters should be used for printing such
5686diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
5687or @samp{emoji}.
5688
5689The @samp{none} value suppresses the printing of such diagrams.
5690The @samp{ascii} value will ensure that such diagrams are pure ASCII
5691(``ASCII art''). The @samp{unicode} value will allow for conservative use of
5692unicode drawing characters (such as box-drawing characters). The @samp{emoji}
5693value further adds the possibility of emoji in the output (such as emitting
5694U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
5695emoji variant of the character).
5696
04013e44
DM
5697The default is @samp{emoji}, except when the environment variable @env{LANG}
5698is set to @samp{C}, in which case the default is @samp{ascii}.
4f01ae37 5699
d77de738 5700@opindex fdiagnostics-format
ddf6fe37 5701@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5702Select a different format for printing diagnostics.
5703@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5704@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5705
5706The default is @samp{text}.
5707
5708The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5709diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5710named @file{@var{source}.sarif}, respectively.
5711
5712The @samp{json} format is a synonym for @samp{json-stderr}.
5713The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5714where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5715whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5716
5717The emitted JSON consists of a top-level JSON array containing JSON objects
5718representing the diagnostics. The JSON is emitted as one line, without
5719formatting; the examples below have been formatted for clarity.
5720
5721Diagnostics can have child diagnostics. For example, this error and note:
5722
5723@smallexample
5724misleading-indentation.c:15:3: warning: this 'if' clause does not
5725 guard... [-Wmisleading-indentation]
5726 15 | if (flag)
5727 | ^~
5728misleading-indentation.c:17:5: note: ...this statement, but the latter
5729 is misleadingly indented as if it were guarded by the 'if'
5730 17 | y = 2;
5731 | ^
5732@end smallexample
5733
5734@noindent
5735might be printed in JSON form (after formatting) like this:
5736
5737@smallexample
5738[
5739 @{
5740 "kind": "warning",
5741 "locations": [
5742 @{
5743 "caret": @{
5744 "display-column": 3,
5745 "byte-column": 3,
5746 "column": 3,
5747 "file": "misleading-indentation.c",
5748 "line": 15
5749 @},
5750 "finish": @{
5751 "display-column": 4,
5752 "byte-column": 4,
5753 "column": 4,
5754 "file": "misleading-indentation.c",
5755 "line": 15
5756 @}
5757 @}
5758 ],
5759 "message": "this \u2018if\u2019 clause does not guard...",
5760 "option": "-Wmisleading-indentation",
5761 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5762 "children": [
5763 @{
5764 "kind": "note",
5765 "locations": [
5766 @{
5767 "caret": @{
5768 "display-column": 5,
5769 "byte-column": 5,
5770 "column": 5,
5771 "file": "misleading-indentation.c",
5772 "line": 17
5773 @}
5774 @}
5775 ],
5776 "escape-source": false,
5777 "message": "...this statement, but the latter is @dots{}"
5778 @}
5779 ]
5780 "escape-source": false,
5781 "column-origin": 1,
5782 @}
5783]
5784@end smallexample
5785
5786@noindent
5787where the @code{note} is a child of the @code{warning}.
5788
5789A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5790an @code{option} key describing the command-line option controlling the
5791warning.
5792
5793A diagnostic can contain zero or more locations. Each location has an
5794optional @code{label} string and up to three positions within it: a
5795@code{caret} position and optional @code{start} and @code{finish} positions.
5796A position is described by a @code{file} name, a @code{line} number, and
5797three numbers indicating a column position:
5798@itemize @bullet
5799
5800@item
5801@code{display-column} counts display columns, accounting for tabs and
5802multibyte characters.
5803
5804@item
5805@code{byte-column} counts raw bytes.
5806
5807@item
5808@code{column} is equal to one of
5809the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5810option.
5811
5812@end itemize
5813All three columns are relative to the origin specified by
5814@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5815be set, for instance, to 0 for compatibility with other utilities that
5816number columns from 0. The column origin is recorded in the JSON output in
5817the @code{column-origin} tag. In the remaining examples below, the extra
5818column number outputs have been omitted for brevity.
5819
5820For example, this error:
5821
5822@smallexample
5823bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5824 'struct s'@} and 'T' @{aka 'struct t'@})
5825 64 | return callee_4a () + callee_4b ();
5826 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5827 | | |
5828 | | T @{aka struct t@}
5829 | S @{aka struct s@}
5830@end smallexample
5831
5832@noindent
5833has three locations. Its primary location is at the ``+'' token at column
583423. It has two secondary locations, describing the left and right-hand sides
5835of the expression, which have labels. It might be printed in JSON form as:
5836
5837@smallexample
5838 @{
5839 "children": [],
5840 "kind": "error",
5841 "locations": [
5842 @{
5843 "caret": @{
5844 "column": 23, "file": "bad-binary-ops.c", "line": 64
5845 @}
5846 @},
5847 @{
5848 "caret": @{
5849 "column": 10, "file": "bad-binary-ops.c", "line": 64
5850 @},
5851 "finish": @{
5852 "column": 21, "file": "bad-binary-ops.c", "line": 64
5853 @},
5854 "label": "S @{aka struct s@}"
5855 @},
5856 @{
5857 "caret": @{
5858 "column": 25, "file": "bad-binary-ops.c", "line": 64
5859 @},
5860 "finish": @{
5861 "column": 36, "file": "bad-binary-ops.c", "line": 64
5862 @},
5863 "label": "T @{aka struct t@}"
5864 @}
5865 ],
5866 "escape-source": false,
5867 "message": "invalid operands to binary + @dots{}"
5868 @}
5869@end smallexample
5870
5871If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5872consisting of half-open intervals, similar to the output of
5873@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5874with a replacement fix-it hint:
5875
5876@smallexample
5877demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5878 mean 'color'?
5879 8 | return ptr->colour;
5880 | ^~~~~~
5881 | color
5882@end smallexample
5883
5884@noindent
5885might be printed in JSON form as:
5886
5887@smallexample
5888 @{
5889 "children": [],
5890 "fixits": [
5891 @{
5892 "next": @{
5893 "column": 21,
5894 "file": "demo.c",
5895 "line": 8
5896 @},
5897 "start": @{
5898 "column": 15,
5899 "file": "demo.c",
5900 "line": 8
5901 @},
5902 "string": "color"
5903 @}
5904 ],
5905 "kind": "error",
5906 "locations": [
5907 @{
5908 "caret": @{
5909 "column": 15,
5910 "file": "demo.c",
5911 "line": 8
5912 @},
5913 "finish": @{
5914 "column": 20,
5915 "file": "demo.c",
5916 "line": 8
5917 @}
5918 @}
5919 ],
5920 "escape-source": false,
5921 "message": "\u2018struct s\u2019 has no member named @dots{}"
5922 @}
5923@end smallexample
5924
5925@noindent
5926where the fix-it hint suggests replacing the text from @code{start} up
5927to but not including @code{next} with @code{string}'s value. Deletions
5928are expressed via an empty value for @code{string}, insertions by
5929having @code{start} equal @code{next}.
5930
5931If the diagnostic has a path of control-flow events associated with it,
5932it has a @code{path} array of objects representing the events. Each
5933event object has a @code{description} string, a @code{location} object,
5934along with a @code{function} string and a @code{depth} number for
5935representing interprocedural paths. The @code{function} represents the
5936current function at that event, and the @code{depth} represents the
5937stack depth relative to some baseline: the higher, the more frames are
5938within the stack.
5939
5940For example, the intraprocedural example shown for
5941@option{-fdiagnostics-path-format=} might have this JSON for its path:
5942
5943@smallexample
5944 "path": [
5945 @{
5946 "depth": 0,
5947 "description": "when 'PyList_New' fails, returning NULL",
5948 "function": "test",
5949 "location": @{
5950 "column": 10,
5951 "file": "test.c",
5952 "line": 25
5953 @}
5954 @},
5955 @{
5956 "depth": 0,
5957 "description": "when 'i < count'",
5958 "function": "test",
5959 "location": @{
5960 "column": 3,
5961 "file": "test.c",
5962 "line": 27
5963 @}
5964 @},
5965 @{
5966 "depth": 0,
5967 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5968 "function": "test",
5969 "location": @{
5970 "column": 5,
5971 "file": "test.c",
5972 "line": 29
5973 @}
5974 @}
5975 ]
5976@end smallexample
5977
5978Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5979non-ASCII bytes should be escaped when printing the pertinent lines of
5980source code (@code{true} for diagnostics involving source encoding issues).
5981
5982@end table
5983
5984@node Warning Options
5985@section Options to Request or Suppress Warnings
5986@cindex options to control warnings
5987@cindex warning messages
5988@cindex messages, warning
5989@cindex suppressing warnings
5990
5991Warnings are diagnostic messages that report constructions that
5992are not inherently erroneous but that are risky or suggest there
5993may have been an error.
5994
5995The following language-independent options do not enable specific
5996warnings but control the kinds of diagnostics produced by GCC@.
5997
5998@table @gcctabopt
5999@cindex syntax checking
d77de738 6000@opindex fsyntax-only
ddf6fe37 6001@item -fsyntax-only
d77de738
ML
6002Check the code for syntax errors, but don't do anything beyond that.
6003
d77de738 6004@opindex fmax-errors
ddf6fe37 6005@item -fmax-errors=@var{n}
d77de738
ML
6006Limits the maximum number of error messages to @var{n}, at which point
6007GCC bails out rather than attempting to continue processing the source
6008code. If @var{n} is 0 (the default), there is no limit on the number
6009of error messages produced. If @option{-Wfatal-errors} is also
6010specified, then @option{-Wfatal-errors} takes precedence over this
6011option.
6012
d77de738 6013@opindex w
ddf6fe37 6014@item -w
d77de738
ML
6015Inhibit all warning messages.
6016
d77de738
ML
6017@opindex Werror
6018@opindex Wno-error
ddf6fe37 6019@item -Werror
d77de738
ML
6020Make all warnings into errors.
6021
d77de738
ML
6022@opindex Werror=
6023@opindex Wno-error=
ddf6fe37 6024@item -Werror=
d77de738
ML
6025Make the specified warning into an error. The specifier for a warning
6026is appended; for example @option{-Werror=switch} turns the warnings
6027controlled by @option{-Wswitch} into errors. This switch takes a
6028negative form, to be used to negate @option{-Werror} for specific
6029warnings; for example @option{-Wno-error=switch} makes
6030@option{-Wswitch} warnings not be errors, even when @option{-Werror}
6031is in effect.
6032
6033The warning message for each controllable warning includes the
6034option that controls the warning. That option can then be used with
6035@option{-Werror=} and @option{-Wno-error=} as described above.
6036(Printing of the option in the warning message can be disabled using the
6037@option{-fno-diagnostics-show-option} flag.)
6038
6039Note that specifying @option{-Werror=}@var{foo} automatically implies
6040@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6041imply anything.
6042
d77de738
ML
6043@opindex Wfatal-errors
6044@opindex Wno-fatal-errors
ddf6fe37 6045@item -Wfatal-errors
d77de738
ML
6046This option causes the compiler to abort compilation on the first error
6047occurred rather than trying to keep going and printing further error
6048messages.
6049
6050@end table
6051
6052You can request many specific warnings with options beginning with
6053@samp{-W}, for example @option{-Wimplicit} to request warnings on
6054implicit declarations. Each of these specific warning options also
6055has a negative form beginning @samp{-Wno-} to turn off warnings; for
6056example, @option{-Wno-implicit}. This manual lists only one of the
6057two forms, whichever is not the default. For further
6058language-specific options also refer to @ref{C++ Dialect Options} and
6059@ref{Objective-C and Objective-C++ Dialect Options}.
6060Additional warnings can be produced by enabling the static analyzer;
6061@xref{Static Analyzer Options}.
6062
6063Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6064options, such as @option{-Wunused}, which may turn on further options,
6065such as @option{-Wunused-value}. The combined effect of positive and
6066negative forms is that more specific options have priority over less
6067specific ones, independently of their position in the command-line. For
6068options of the same specificity, the last one takes effect. Options
6069enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6070as if they appeared at the end of the command-line.
6071
6072When an unrecognized warning option is requested (e.g.,
6073@option{-Wunknown-warning}), GCC emits a diagnostic stating
6074that the option is not recognized. However, if the @option{-Wno-} form
6075is used, the behavior is slightly different: no diagnostic is
6076produced for @option{-Wno-unknown-warning} unless other diagnostics
6077are being produced. This allows the use of new @option{-Wno-} options
6078with old compilers, but if something goes wrong, the compiler
6079warns that an unrecognized option is present.
6080
6081The effectiveness of some warnings depends on optimizations also being
6082enabled. For example @option{-Wsuggest-final-types} is more effective
6083with link-time optimization and some instances of other warnings may
6084not be issued at all unless optimization is enabled. While optimization
6085in general improves the efficacy of control and data flow sensitive
6086warnings, in some cases it may also cause false positives.
6087
6088@table @gcctabopt
d77de738
ML
6089@opindex pedantic
6090@opindex Wpedantic
6091@opindex Wno-pedantic
ddf6fe37
AA
6092@item -Wpedantic
6093@itemx -pedantic
d77de738 6094Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
6095diagnose all programs that use forbidden extensions, and some other
6096programs that do not follow ISO C and ISO C++. This follows the version
6097of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
6098
6099Valid ISO C and ISO C++ programs should compile properly with or without
6100this option (though a rare few require @option{-ansi} or a
5fccebdb 6101@option{-std} option specifying the version of the standard)@. However,
d77de738 6102without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6103features are supported as well. With this option, they are diagnosed
6104(or rejected with @option{-pedantic-errors}).
d77de738
ML
6105
6106@option{-Wpedantic} does not cause warning messages for use of the
6107alternate keywords whose names begin and end with @samp{__}. This alternate
6108format can also be used to disable warnings for non-ISO @samp{__intN} types,
6109i.e. @samp{__intN__}.
6110Pedantic warnings are also disabled in the expression that follows
6111@code{__extension__}. However, only system header files should use
6112these escape routes; application programs should avoid them.
6113@xref{Alternate Keywords}.
6114
5fccebdb
JM
6115Some warnings about non-conforming programs are controlled by options
6116other than @option{-Wpedantic}; in many cases they are implied by
6117@option{-Wpedantic} but can be disabled separately by their specific
6118option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6119
6120Where the standard specified with @option{-std} represents a GNU
6121extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6122corresponding @dfn{base standard}, the version of ISO C on which the GNU
6123extended dialect is based. Warnings from @option{-Wpedantic} are given
6124where they are required by the base standard. (It does not make sense
6125for such warnings to be given only for features not in the specified GNU
6126C dialect, since by definition the GNU dialects of C include all
6127features the compiler supports with the given option, and there would be
6128nothing to warn about.)
6129
d77de738 6130@opindex pedantic-errors
ddf6fe37 6131@item -pedantic-errors
d77de738
ML
6132Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6133requires a diagnostic, in some cases where there is undefined behavior
6134at compile-time and in some other cases that do not prevent compilation
6135of programs that are valid according to the standard. This is not
5fccebdb
JM
6136equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6137useful, as it only makes errors of the diagnostics that are controlled by
6138@option{-Wpedantic}, whereas this option also affects required diagnostics that
6139are always enabled or controlled by options other than @option{-Wpedantic}.
6140
6141If you want the required diagnostics that are warnings by default to
6142be errors instead, but don't also want to enable the @option{-Wpedantic}
6143diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6144(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6145only as warnings).
6146
6147Some required diagnostics are errors by default, but can be reduced to
6148warnings using @option{-fpermissive} or their specific warning option,
6149e.g. @option{-Wno-error=narrowing}.
6150
6151Some diagnostics for non-ISO practices are controlled by specific
6152warning options other than @option{-Wpedantic}, but are also made
6153errors by @option{-pedantic-errors}. For instance:
6154
6155@gccoptlist{
6156-Wattributes @r{(for standard attributes)}
6157-Wchanges-meaning @r{(C++)}
6158-Wcomma-subscript @r{(C++23 or later)}
6159-Wdeclaration-after-statement @r{(C90 or earlier)}
b106f11d 6160-Welaborated-enum-base @r{(C++11 or later)}
5fccebdb
JM
6161-Wimplicit-int @r{(C99 or later)}
6162-Wimplicit-function-declaration @r{(C99 or later)}
6163-Wincompatible-pointer-types
6164-Wint-conversion
6165-Wlong-long @r{(C90 or earlier)}
6166-Wmain
6167-Wnarrowing @r{(C++11 or later)}
6168-Wpointer-arith
6169-Wpointer-sign
6170-Wincompatible-pointer-types
6171-Wregister @r{(C++17 or later)}
6172-Wvla @r{(C90 or earlier)}
6173-Wwrite-strings @r{(C++11 or later)}
6174}
d77de738 6175
ef10cb86
JM
6176@opindex fpermissive
6177@item -fpermissive
6178Downgrade some required diagnostics about nonconformant code from
6179errors to warnings. Thus, using @option{-fpermissive} allows some
6180nonconforming code to compile. Some C++ diagnostics are controlled
da4315f5
FW
6181only by this flag, but it also downgrades some C and C++ diagnostics
6182that have their own flag:
ef10cb86
JM
6183
6184@gccoptlist{
6185-Wnarrowing @r{(C++)}
6186}
6187
da4315f5
FW
6188The @option{-fpermissive} option is the default for historic C language
6189modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6190@option{-std=gnu90}).
6191
d77de738
ML
6192@opindex Wall
6193@opindex Wno-all
ddf6fe37 6194@item -Wall
d77de738
ML
6195This enables all the warnings about constructions that some users
6196consider questionable, and that are easy to avoid (or modify to
6197prevent the warning), even in conjunction with macros. This also
6198enables some language-specific warnings described in @ref{C++ Dialect
6199Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6200
6201@option{-Wall} turns on the following warning flags:
6202
43b72ede
AA
6203@gccoptlist{-Waddress
6204-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6205-Warray-compare
6206-Warray-parameter=2 @r{(C and Objective-C only)}
6207-Wbool-compare
6208-Wbool-operation
6209-Wc++11-compat -Wc++14-compat
6210-Wcatch-value @r{(C++ and Objective-C++ only)}
6211-Wchar-subscripts
6212-Wcomment
6213-Wdangling-pointer=2
6214-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6215-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6216-Wenum-int-mismatch @r{(C and Objective-C only)}
6217-Wformat
6218-Wformat-overflow
6219-Wformat-truncation
6220-Wint-in-bool-context
6221-Wimplicit @r{(C and Objective-C only)}
6222-Wimplicit-int @r{(C and Objective-C only)}
6223-Wimplicit-function-declaration @r{(C and Objective-C only)}
6224-Winit-self @r{(only for C++)}
6225-Wlogical-not-parentheses
6226-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6227-Wmaybe-uninitialized
6228-Wmemset-elt-size
6229-Wmemset-transposed-args
6230-Wmisleading-indentation @r{(only for C/C++)}
6231-Wmismatched-dealloc
6232-Wmismatched-new-delete @r{(only for C/C++)}
6233-Wmissing-attributes
6234-Wmissing-braces @r{(only for C/ObjC)}
6235-Wmultistatement-macros
6236-Wnarrowing @r{(only for C++)}
6237-Wnonnull
6238-Wnonnull-compare
6239-Wopenmp-simd
6240-Wparentheses
6241-Wpessimizing-move @r{(only for C++)}
6242-Wpointer-sign
6243-Wrange-loop-construct @r{(only for C++)}
6244-Wreorder
6245-Wrestrict
6246-Wreturn-type
6247-Wself-move @r{(only for C++)}
6248-Wsequence-point
6249-Wsign-compare @r{(only in C++)}
6250-Wsizeof-array-div
6251-Wsizeof-pointer-div
6252-Wsizeof-pointer-memaccess
6253-Wstrict-aliasing
6254-Wstrict-overflow=1
6255-Wswitch
6256-Wtautological-compare
6257-Wtrigraphs
6258-Wuninitialized
6259-Wunknown-pragmas
6260-Wunused-function
6261-Wunused-label
6262-Wunused-value
6263-Wunused-variable
6264-Wuse-after-free=2
6265-Wvla-parameter @r{(C and Objective-C only)}
6266-Wvolatile-register-var
d77de738
ML
6267-Wzero-length-bounds}
6268
6269Note that some warning flags are not implied by @option{-Wall}. Some of
6270them warn about constructions that users generally do not consider
6271questionable, but which occasionally you might wish to check for;
6272others warn about constructions that are necessary or hard to avoid in
6273some cases, and there is no simple way to modify the code to suppress
6274the warning. Some of them are enabled by @option{-Wextra} but many of
6275them must be enabled individually.
6276
d77de738
ML
6277@opindex W
6278@opindex Wextra
6279@opindex Wno-extra
ddf6fe37 6280@item -Wextra
d77de738
ML
6281This enables some extra warning flags that are not enabled by
6282@option{-Wall}. (This option used to be called @option{-W}. The older
6283name is still supported, but the newer name is more descriptive.)
6284
43b72ede
AA
6285@gccoptlist{-Wclobbered
6286-Wcast-function-type
6287-Wdeprecated-copy @r{(C++ only)}
6288-Wempty-body
6289-Wenum-conversion @r{(C only)}
6290-Wignored-qualifiers
6291-Wimplicit-fallthrough=3
6292-Wmissing-field-initializers
6293-Wmissing-parameter-type @r{(C only)}
6294-Wold-style-declaration @r{(C only)}
6295-Woverride-init
6296-Wsign-compare @r{(C only)}
6297-Wstring-compare
6298-Wredundant-move @r{(only for C++)}
6299-Wtype-limits
6300-Wuninitialized
6301-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6302-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6303-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6304
6305
6306The option @option{-Wextra} also prints warning messages for the
6307following cases:
6308
6309@itemize @bullet
6310
6311@item
6312A pointer is compared against integer zero with @code{<}, @code{<=},
6313@code{>}, or @code{>=}.
6314
6315@item
6316(C++ only) An enumerator and a non-enumerator both appear in a
6317conditional expression.
6318
6319@item
6320(C++ only) Ambiguous virtual bases.
6321
6322@item
6323(C++ only) Subscripting an array that has been declared @code{register}.
6324
6325@item
6326(C++ only) Taking the address of a variable that has been declared
6327@code{register}.
6328
6329@item
6330(C++ only) A base class is not initialized in the copy constructor
6331of a derived class.
6332
6333@end itemize
6334
d77de738
ML
6335@opindex Wabi
6336@opindex Wno-abi
ddf6fe37 6337@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6338
6339Warn about code affected by ABI changes. This includes code that may
6340not be compatible with the vendor-neutral C++ ABI as well as the psABI
6341for the particular target.
6342
6343Since G++ now defaults to updating the ABI with each major release,
6344normally @option{-Wabi} warns only about C++ ABI compatibility
6345problems if there is a check added later in a release series for an
6346ABI issue discovered since the initial release. @option{-Wabi} warns
6347about more things if an older ABI version is selected (with
6348@option{-fabi-version=@var{n}}).
6349
6350@option{-Wabi} can also be used with an explicit version number to
6351warn about C++ ABI compatibility with a particular @option{-fabi-version}
6352level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6353@option{-fabi-version=2}.
6354
6355If an explicit version number is provided and
6356@option{-fabi-compat-version} is not specified, the version number
6357from this option is used for compatibility aliases. If no explicit
6358version number is provided with this option, but
6359@option{-fabi-compat-version} is specified, that version number is
6360used for C++ ABI warnings.
6361
6362Although an effort has been made to warn about
6363all such cases, there are probably some cases that are not warned about,
6364even though G++ is generating incompatible code. There may also be
6365cases where warnings are emitted even though the code that is generated
6366is compatible.
6367
6368You should rewrite your code to avoid these warnings if you are
6369concerned about the fact that code generated by G++ may not be binary
6370compatible with code generated by other compilers.
6371
6372Known incompatibilities in @option{-fabi-version=2} (which was the
6373default from GCC 3.4 to 4.9) include:
6374
6375@itemize @bullet
6376
6377@item
6378A template with a non-type template parameter of reference type was
6379mangled incorrectly:
6380@smallexample
6381extern int N;
6382template <int &> struct S @{@};
6383void n (S<N>) @{2@}
6384@end smallexample
6385
6386This was fixed in @option{-fabi-version=3}.
6387
6388@item
6389SIMD vector types declared using @code{__attribute ((vector_size))} were
6390mangled in a non-standard way that does not allow for overloading of
6391functions taking vectors of different sizes.
6392
6393The mangling was changed in @option{-fabi-version=4}.
6394
6395@item
6396@code{__attribute ((const))} and @code{noreturn} were mangled as type
6397qualifiers, and @code{decltype} of a plain declaration was folded away.
6398
6399These mangling issues were fixed in @option{-fabi-version=5}.
6400
6401@item
6402Scoped enumerators passed as arguments to a variadic function are
6403promoted like unscoped enumerators, causing @code{va_arg} to complain.
6404On most targets this does not actually affect the parameter passing
6405ABI, as there is no way to pass an argument smaller than @code{int}.
6406
6407Also, the ABI changed the mangling of template argument packs,
6408@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6409a class scope function used as a template argument.
6410
6411These issues were corrected in @option{-fabi-version=6}.
6412
6413@item
6414Lambdas in default argument scope were mangled incorrectly, and the
6415ABI changed the mangling of @code{nullptr_t}.
6416
6417These issues were corrected in @option{-fabi-version=7}.
6418
6419@item
6420When mangling a function type with function-cv-qualifiers, the
6421un-qualified function type was incorrectly treated as a substitution
6422candidate.
6423
6424This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6425
6426@item
6427@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6428unaligned accesses. Note that this did not affect the ABI of a
6429function with a @code{nullptr_t} parameter, as parameters have a
6430minimum alignment.
6431
6432This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6433
6434@item
6435Target-specific attributes that affect the identity of a type, such as
6436ia32 calling conventions on a function type (stdcall, regparm, etc.),
6437did not affect the mangled name, leading to name collisions when
6438function pointers were used as template arguments.
6439
6440This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6441
6442@end itemize
6443
6444This option also enables warnings about psABI-related changes.
6445The known psABI changes at this point include:
6446
6447@itemize @bullet
6448
6449@item
6450For SysV/x86-64, unions with @code{long double} members are
6451passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6452the case. For example:
6453
6454@smallexample
6455union U @{
6456 long double ld;
6457 int i;
6458@};
6459@end smallexample
6460
6461@noindent
6462@code{union U} is now always passed in memory.
6463
6464@end itemize
6465
e2f939d3
JM
6466@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6467C++ requires that unqualified uses of a name within a class have the
6468same meaning in the complete scope of the class, so declaring the name
6469after using it is ill-formed:
6470@smallexample
6471struct A;
6472struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6473struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6474@end smallexample
6475By default, the B1 case is only a warning because the two declarations
6476have the same type, while the B2 case is an error. Both diagnostics
6477can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6478error case can be reduced to a warning with
6479@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6480
6481Both diagnostics are also suppressed by @option{-fms-extensions}.
6482
d77de738
ML
6483@opindex Wchar-subscripts
6484@opindex Wno-char-subscripts
ddf6fe37 6485@item -Wchar-subscripts
d77de738
ML
6486Warn if an array subscript has type @code{char}. This is a common cause
6487of error, as programmers often forget that this type is signed on some
6488machines.
6489This warning is enabled by @option{-Wall}.
6490
d77de738
ML
6491@opindex Wno-coverage-mismatch
6492@opindex Wcoverage-mismatch
ddf6fe37 6493@item -Wno-coverage-mismatch
d77de738
ML
6494Warn if feedback profiles do not match when using the
6495@option{-fprofile-use} option.
6496If a source file is changed between compiling with @option{-fprofile-generate}
6497and with @option{-fprofile-use}, the files with the profile feedback can fail
6498to match the source file and GCC cannot use the profile feedback
6499information. By default, this warning is enabled and is treated as an
6500error. @option{-Wno-coverage-mismatch} can be used to disable the
6501warning or @option{-Wno-error=coverage-mismatch} can be used to
6502disable the error. Disabling the error for this warning can result in
6503poorly optimized code and is useful only in the
6504case of very minor changes such as bug fixes to an existing code-base.
6505Completely disabling the warning is not recommended.
6506
d77de738
ML
6507@opindex Wno-coverage-invalid-line-number
6508@opindex Wcoverage-invalid-line-number
ddf6fe37 6509@item -Wno-coverage-invalid-line-number
d77de738
ML
6510Warn in case a function ends earlier than it begins due
6511to an invalid linenum macros. The warning is emitted only
6512with @option{--coverage} enabled.
6513
6514By default, this warning is enabled and is treated as an
6515error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6516warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6517disable the error.
6518
d77de738
ML
6519@opindex Wno-cpp
6520@opindex Wcpp
ddf6fe37 6521@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6522Suppress warning messages emitted by @code{#warning} directives.
6523
d77de738
ML
6524@opindex Wdouble-promotion
6525@opindex Wno-double-promotion
ddf6fe37 6526@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6527Give a warning when a value of type @code{float} is implicitly
6528promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6529floating-point unit implement @code{float} in hardware, but emulate
6530@code{double} in software. On such a machine, doing computations
6531using @code{double} values is much more expensive because of the
6532overhead required for software emulation.
6533
6534It is easy to accidentally do computations with @code{double} because
6535floating-point literals are implicitly of type @code{double}. For
6536example, in:
6537@smallexample
6538@group
6539float area(float radius)
6540@{
6541 return 3.14159 * radius * radius;
6542@}
6543@end group
6544@end smallexample
6545the compiler performs the entire computation with @code{double}
6546because the floating-point literal is a @code{double}.
6547
d77de738
ML
6548@opindex Wduplicate-decl-specifier
6549@opindex Wno-duplicate-decl-specifier
ddf6fe37 6550@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6551Warn if a declaration has duplicate @code{const}, @code{volatile},
6552@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6553@option{-Wall}.
6554
d77de738
ML
6555@opindex Wformat
6556@opindex Wno-format
6557@opindex ffreestanding
6558@opindex fno-builtin
6559@opindex Wformat=
ddf6fe37
AA
6560@item -Wformat
6561@itemx -Wformat=@var{n}
d77de738
ML
6562Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6563the arguments supplied have types appropriate to the format string
6564specified, and that the conversions specified in the format string make
6565sense. This includes standard functions, and others specified by format
6566attributes (@pxref{Function Attributes}), in the @code{printf},
6567@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6568not in the C standard) families (or other target-specific families).
6569Which functions are checked without format attributes having been
6570specified depends on the standard version selected, and such checks of
6571functions without the attribute specified are disabled by
6572@option{-ffreestanding} or @option{-fno-builtin}.
6573
6574The formats are checked against the format features supported by GNU
6575libc version 2.2. These include all ISO C90 and C99 features, as well
6576as features from the Single Unix Specification and some BSD and GNU
6577extensions. Other library implementations may not support all these
6578features; GCC does not support warning about features that go beyond a
6579particular library's limitations. However, if @option{-Wpedantic} is used
6580with @option{-Wformat}, warnings are given about format features not
6581in the selected standard version (but not for @code{strfmon} formats,
6582since those are not in any version of the C standard). @xref{C Dialect
6583Options,,Options Controlling C Dialect}.
6584
6585@table @gcctabopt
d77de738
ML
6586@opindex Wformat
6587@opindex Wformat=1
ddf6fe37
AA
6588@item -Wformat=1
6589@itemx -Wformat
d77de738
ML
6590Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6591@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6592@option{-Wformat} also checks for null format arguments for several
6593functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6594aspects of this level of format checking can be disabled by the
6595options: @option{-Wno-format-contains-nul},
6596@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6597@option{-Wformat} is enabled by @option{-Wall}.
6598
d77de738 6599@opindex Wformat=2
ddf6fe37 6600@item -Wformat=2
d77de738
ML
6601Enable @option{-Wformat} plus additional format checks. Currently
6602equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6603-Wformat-y2k}.
6604@end table
6605
d77de738
ML
6606@opindex Wno-format-contains-nul
6607@opindex Wformat-contains-nul
ddf6fe37 6608@item -Wno-format-contains-nul
d77de738
ML
6609If @option{-Wformat} is specified, do not warn about format strings that
6610contain NUL bytes.
6611
d77de738
ML
6612@opindex Wno-format-extra-args
6613@opindex Wformat-extra-args
ddf6fe37 6614@item -Wno-format-extra-args
d77de738
ML
6615If @option{-Wformat} is specified, do not warn about excess arguments to a
6616@code{printf} or @code{scanf} format function. The C standard specifies
6617that such arguments are ignored.
6618
6619Where the unused arguments lie between used arguments that are
6620specified with @samp{$} operand number specifications, normally
6621warnings are still given, since the implementation could not know what
6622type to pass to @code{va_arg} to skip the unused arguments. However,
6623in the case of @code{scanf} formats, this option suppresses the
6624warning if the unused arguments are all pointers, since the Single
6625Unix Specification says that such unused arguments are allowed.
6626
d77de738
ML
6627@opindex Wformat-overflow
6628@opindex Wno-format-overflow
ddf6fe37
AA
6629@item -Wformat-overflow
6630@itemx -Wformat-overflow=@var{level}
d77de738
ML
6631Warn about calls to formatted input/output functions such as @code{sprintf}
6632and @code{vsprintf} that might overflow the destination buffer. When the
6633exact number of bytes written by a format directive cannot be determined
6634at compile-time it is estimated based on heuristics that depend on the
6635@var{level} argument and on optimization. While enabling optimization
6636will in most cases improve the accuracy of the warning, it may also
6637result in false positives.
6638
6639@table @gcctabopt
d77de738
ML
6640@opindex Wformat-overflow
6641@opindex Wno-format-overflow
ddf6fe37
AA
6642@item -Wformat-overflow
6643@itemx -Wformat-overflow=1
d77de738
ML
6644Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6645employs a conservative approach that warns only about calls that most
6646likely overflow the buffer. At this level, numeric arguments to format
6647directives with unknown values are assumed to have the value of one, and
6648strings of unknown length to be empty. Numeric arguments that are known
6649to be bounded to a subrange of their type, or string arguments whose output
6650is bounded either by their directive's precision or by a finite set of
6651string literals, are assumed to take on the value within the range that
6652results in the most bytes on output. For example, the call to @code{sprintf}
6653below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6654the terminating NUL character (@code{'\0'}) appended by the function
6655to the destination buffer will be written past its end. Increasing
6656the size of the buffer by a single byte is sufficient to avoid the
6657warning, though it may not be sufficient to avoid the overflow.
6658
6659@smallexample
6660void f (int a, int b)
6661@{
6662 char buf [13];
6663 sprintf (buf, "a = %i, b = %i\n", a, b);
6664@}
6665@end smallexample
6666
6667@item -Wformat-overflow=2
6668Level @var{2} warns also about calls that might overflow the destination
6669buffer given an argument of sufficient length or magnitude. At level
6670@var{2}, unknown numeric arguments are assumed to have the minimum
6671representable value for signed types with a precision greater than 1, and
6672the maximum representable value otherwise. Unknown string arguments whose
6673length cannot be assumed to be bounded either by the directive's precision,
6674or by a finite set of string literals they may evaluate to, or the character
6675array they may point to, are assumed to be 1 character long.
6676
6677At level @var{2}, the call in the example above is again diagnosed, but
6678this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6679@code{%i} directive will write some of its digits beyond the end of
6680the destination buffer. To make the call safe regardless of the values
6681of the two variables, the size of the destination buffer must be increased
6682to at least 34 bytes. GCC includes the minimum size of the buffer in
6683an informational note following the warning.
6684
6685An alternative to increasing the size of the destination buffer is to
6686constrain the range of formatted values. The maximum length of string
6687arguments can be bounded by specifying the precision in the format
6688directive. When numeric arguments of format directives can be assumed
6689to be bounded by less than the precision of their type, choosing
6690an appropriate length modifier to the format specifier will reduce
6691the required buffer size. For example, if @var{a} and @var{b} in the
6692example above can be assumed to be within the precision of
6693the @code{short int} type then using either the @code{%hi} format
6694directive or casting the argument to @code{short} reduces the maximum
6695required size of the buffer to 24 bytes.
6696
6697@smallexample
6698void f (int a, int b)
6699@{
6700 char buf [23];
6701 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6702@}
6703@end smallexample
6704@end table
6705
d77de738
ML
6706@opindex Wno-format-zero-length
6707@opindex Wformat-zero-length
ddf6fe37 6708@item -Wno-format-zero-length
d77de738
ML
6709If @option{-Wformat} is specified, do not warn about zero-length formats.
6710The C standard specifies that zero-length formats are allowed.
6711
d77de738
ML
6712@opindex Wformat-nonliteral
6713@opindex Wno-format-nonliteral
ddf6fe37 6714@item -Wformat-nonliteral
d77de738
ML
6715If @option{-Wformat} is specified, also warn if the format string is not a
6716string literal and so cannot be checked, unless the format function
6717takes its format arguments as a @code{va_list}.
6718
d77de738
ML
6719@opindex Wformat-security
6720@opindex Wno-format-security
ddf6fe37 6721@item -Wformat-security
d77de738
ML
6722If @option{-Wformat} is specified, also warn about uses of format
6723functions that represent possible security problems. At present, this
6724warns about calls to @code{printf} and @code{scanf} functions where the
6725format string is not a string literal and there are no format arguments,
6726as in @code{printf (foo);}. This may be a security hole if the format
6727string came from untrusted input and contains @samp{%n}. (This is
6728currently a subset of what @option{-Wformat-nonliteral} warns about, but
6729in future warnings may be added to @option{-Wformat-security} that are not
6730included in @option{-Wformat-nonliteral}.)
6731
d77de738
ML
6732@opindex Wformat-signedness
6733@opindex Wno-format-signedness
ddf6fe37 6734@item -Wformat-signedness
d77de738
ML
6735If @option{-Wformat} is specified, also warn if the format string
6736requires an unsigned argument and the argument is signed and vice versa.
6737
d77de738
ML
6738@opindex Wformat-truncation
6739@opindex Wno-format-truncation
ddf6fe37
AA
6740@item -Wformat-truncation
6741@itemx -Wformat-truncation=@var{level}
d77de738
ML
6742Warn about calls to formatted input/output functions such as @code{snprintf}
6743and @code{vsnprintf} that might result in output truncation. When the exact
6744number of bytes written by a format directive cannot be determined at
6745compile-time it is estimated based on heuristics that depend on
6746the @var{level} argument and on optimization. While enabling optimization
6747will in most cases improve the accuracy of the warning, it may also result
6748in false positives. Except as noted otherwise, the option uses the same
6749logic @option{-Wformat-overflow}.
6750
6751@table @gcctabopt
d77de738
ML
6752@opindex Wformat-truncation
6753@opindex Wno-format-truncation
ddf6fe37
AA
6754@item -Wformat-truncation
6755@itemx -Wformat-truncation=1
d77de738
ML
6756Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6757employs a conservative approach that warns only about calls to bounded
6758functions whose return value is unused and that will most likely result
6759in output truncation.
6760
6761@item -Wformat-truncation=2
6762Level @var{2} warns also about calls to bounded functions whose return
6763value is used and that might result in truncation given an argument of
6764sufficient length or magnitude.
6765@end table
6766
d77de738
ML
6767@opindex Wformat-y2k
6768@opindex Wno-format-y2k
ddf6fe37 6769@item -Wformat-y2k
d77de738
ML
6770If @option{-Wformat} is specified, also warn about @code{strftime}
6771formats that may yield only a two-digit year.
6772
d77de738
ML
6773@opindex Wnonnull
6774@opindex Wno-nonnull
ddf6fe37 6775@item -Wnonnull
d77de738
ML
6776Warn about passing a null pointer for arguments marked as
6777requiring a non-null value by the @code{nonnull} function attribute.
6778
6779@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6780can be disabled with the @option{-Wno-nonnull} option.
6781
d77de738
ML
6782@opindex Wnonnull-compare
6783@opindex Wno-nonnull-compare
ddf6fe37 6784@item -Wnonnull-compare
d77de738
ML
6785Warn when comparing an argument marked with the @code{nonnull}
6786function attribute against null inside the function.
6787
6788@option{-Wnonnull-compare} is included in @option{-Wall}. It
6789can be disabled with the @option{-Wno-nonnull-compare} option.
6790
d77de738
ML
6791@opindex Wnull-dereference
6792@opindex Wno-null-dereference
ddf6fe37 6793@item -Wnull-dereference
d77de738
ML
6794Warn if the compiler detects paths that trigger erroneous or
6795undefined behavior due to dereferencing a null pointer. This option
6796is only active when @option{-fdelete-null-pointer-checks} is active,
6797which is enabled by optimizations in most targets. The precision of
6798the warnings depends on the optimization options used.
6799
2ae5384d
JM
6800@opindex Wnrvo
6801@opindex Wno-nrvo
6802@item -Wnrvo @r{(C++ and Objective-C++ only)}
6803Warn if the compiler does not elide the copy from a local variable to
6804the return value of a function in a context where it is allowed by
6805[class.copy.elision]. This elision is commonly known as the Named
6806Return Value Optimization. For instance, in the example below the
72cfa0f7 6807compiler cannot elide copies from both v1 and v2, so it elides neither.
2ae5384d
JM
6808
6809@smallexample
6810std::vector<int> f()
6811@{
6812 std::vector<int> v1, v2;
6813 // ...
6814 if (cond) return v1;
6815 else return v2; // warning: not eliding copy
6816@}
6817@end smallexample
6818
d77de738
ML
6819@opindex Winfinite-recursion
6820@opindex Wno-infinite-recursion
ddf6fe37 6821@item -Winfinite-recursion
d77de738
ML
6822Warn about infinitely recursive calls. The warning is effective at all
6823optimization levels but requires optimization in order to detect infinite
6824recursion in calls between two or more functions.
6825@option{-Winfinite-recursion} is included in @option{-Wall}.
6826
ce51e843
ML
6827Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6828similar diagnostic, but is implemented in a different way (as part of
6829@option{-fanalyzer}).
6830
d77de738
ML
6831@opindex Winit-self
6832@opindex Wno-init-self
ddf6fe37 6833@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6834Warn about uninitialized variables that are initialized with themselves.
6835Note this option can only be used with the @option{-Wuninitialized} option.
6836
6837For example, GCC warns about @code{i} being uninitialized in the
6838following snippet only when @option{-Winit-self} has been specified:
6839@smallexample
6840@group
6841int f()
6842@{
6843 int i = i;
6844 return i;
6845@}
6846@end group
6847@end smallexample
6848
6849This warning is enabled by @option{-Wall} in C++.
6850
d77de738
ML
6851@opindex Wimplicit-int
6852@opindex Wno-implicit-int
ddf6fe37 6853@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6854This option controls warnings when a declaration does not specify a type.
6855This warning is enabled by default in C99 and later dialects of C,
6856and also by @option{-Wall}.
6857
5fccebdb
JM
6858This warning is upgraded to an error by @option{-pedantic-errors}.
6859
d77de738
ML
6860@opindex Wimplicit-function-declaration
6861@opindex Wno-implicit-function-declaration
ddf6fe37 6862@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6863This option controls warnings when a function is used before being declared.
6864This warning is enabled by default in C99 and later dialects of C,
6865and also by @option{-Wall}.
5fccebdb
JM
6866
6867This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 6868
d77de738
ML
6869@opindex Wimplicit
6870@opindex Wno-implicit
ddf6fe37 6871@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6872Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6873This warning is enabled by @option{-Wall}.
6874
d77de738
ML
6875@opindex Wimplicit-fallthrough
6876@opindex Wno-implicit-fallthrough
ddf6fe37 6877@item -Wimplicit-fallthrough
d77de738
ML
6878@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6879and @option{-Wno-implicit-fallthrough} is the same as
6880@option{-Wimplicit-fallthrough=0}.
6881
d77de738 6882@opindex Wimplicit-fallthrough=
ddf6fe37 6883@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6884Warn when a switch case falls through. For example:
6885
6886@smallexample
6887@group
6888switch (cond)
6889 @{
6890 case 1:
6891 a = 1;
6892 break;
6893 case 2:
6894 a = 2;
6895 case 3:
6896 a = 3;
6897 break;
6898 @}
6899@end group
6900@end smallexample
6901
6902This warning does not warn when the last statement of a case cannot
6903fall through, e.g. when there is a return statement or a call to function
6904declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6905also takes into account control flow statements, such as ifs, and only
6906warns when appropriate. E.g.@:
6907
6908@smallexample
6909@group
6910switch (cond)
6911 @{
6912 case 1:
6913 if (i > 3) @{
6914 bar (5);
6915 break;
6916 @} else if (i < 1) @{
6917 bar (0);
6918 @} else
6919 return;
6920 default:
6921 @dots{}
6922 @}
6923@end group
6924@end smallexample
6925
6926Since there are occasions where a switch case fall through is desirable,
6927GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6928to be used along with a null statement to suppress this warning that
6929would normally occur:
6930
6931@smallexample
6932@group
6933switch (cond)
6934 @{
6935 case 1:
6936 bar (0);
6937 __attribute__ ((fallthrough));
6938 default:
6939 @dots{}
6940 @}
6941@end group
6942@end smallexample
6943
6944C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6945warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6946or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6947Instead of these attributes, it is also possible to add a fallthrough comment
6948to silence the warning. The whole body of the C or C++ style comment should
6949match the given regular expressions listed below. The option argument @var{n}
6950specifies what kind of comments are accepted:
6951
6952@itemize @bullet
6953
6954@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6955
6956@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6957expression, any comment is used as fallthrough comment.
6958
6959@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6960@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6961
6962@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6963following regular expressions:
6964
6965@itemize @bullet
6966
6967@item @code{-fallthrough}
6968
6969@item @code{@@fallthrough@@}
6970
6971@item @code{lint -fallthrough[ \t]*}
6972
6973@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6974
6975@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6976
6977@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6978
6979@end itemize
6980
6981@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6982following regular expressions:
6983
6984@itemize @bullet
6985
6986@item @code{-fallthrough}
6987
6988@item @code{@@fallthrough@@}
6989
6990@item @code{lint -fallthrough[ \t]*}
6991
6992@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6993
6994@end itemize
6995
6996@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6997fallthrough comments, only attributes disable the warning.
6998
6999@end itemize
7000
7001The comment needs to be followed after optional whitespace and other comments
7002by @code{case} or @code{default} keywords or by a user label that precedes some
7003@code{case} or @code{default} label.
7004
7005@smallexample
7006@group
7007switch (cond)
7008 @{
7009 case 1:
7010 bar (0);
7011 /* FALLTHRU */
7012 default:
7013 @dots{}
7014 @}
7015@end group
7016@end smallexample
7017
7018The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7019
d77de738
ML
7020@opindex Wif-not-aligned
7021@opindex Wno-if-not-aligned
ddf6fe37 7022@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7023Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7024should be issued. These warnings are enabled by default.
7025
d77de738
ML
7026@opindex Wignored-qualifiers
7027@opindex Wno-ignored-qualifiers
ddf6fe37 7028@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
7029Warn if the return type of a function has a type qualifier
7030such as @code{const}. For ISO C such a type qualifier has no effect,
7031since the value returned by a function is not an lvalue.
7032For C++, the warning is only emitted for scalar types or @code{void}.
7033ISO C prohibits qualified @code{void} return types on function
7034definitions, so such return types always receive a warning
7035even without this option.
7036
7037This warning is also enabled by @option{-Wextra}.
7038
d77de738
ML
7039@opindex Wignored-attributes
7040@opindex Wno-ignored-attributes
ddf6fe37 7041@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
7042This option controls warnings when an attribute is ignored.
7043This is different from the
7044@option{-Wattributes} option in that it warns whenever the compiler decides
7045to drop an attribute, not that the attribute is either unknown, used in a
7046wrong place, etc. This warning is enabled by default.
7047
d77de738
ML
7048@opindex Wmain
7049@opindex Wno-main
ddf6fe37 7050@item -Wmain
d77de738
ML
7051Warn if the type of @code{main} is suspicious. @code{main} should be
7052a function with external linkage, returning int, taking either zero
7053arguments, two, or three arguments of appropriate types. This warning
7054is enabled by default in C++ and is enabled by either @option{-Wall}
7055or @option{-Wpedantic}.
7056
5fccebdb
JM
7057This warning is upgraded to an error by @option{-pedantic-errors}.
7058
d77de738
ML
7059@opindex Wmisleading-indentation
7060@opindex Wno-misleading-indentation
ddf6fe37 7061@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
7062Warn when the indentation of the code does not reflect the block structure.
7063Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7064@code{for} clauses with a guarded statement that does not use braces,
7065followed by an unguarded statement with the same indentation.
7066
7067In the following example, the call to ``bar'' is misleadingly indented as
7068if it were guarded by the ``if'' conditional.
7069
7070@smallexample
7071 if (some_condition ())
7072 foo ();
7073 bar (); /* Gotcha: this is not guarded by the "if". */
7074@end smallexample
7075
7076In the case of mixed tabs and spaces, the warning uses the
7077@option{-ftabstop=} option to determine if the statements line up
7078(defaulting to 8).
7079
7080The warning is not issued for code involving multiline preprocessor logic
7081such as the following example.
7082
7083@smallexample
7084 if (flagA)
7085 foo (0);
7086#if SOME_CONDITION_THAT_DOES_NOT_HOLD
7087 if (flagB)
7088#endif
7089 foo (1);
7090@end smallexample
7091
7092The warning is not issued after a @code{#line} directive, since this
7093typically indicates autogenerated code, and no assumptions can be made
7094about the layout of the file that the directive references.
7095
7096This warning is enabled by @option{-Wall} in C and C++.
7097
d77de738
ML
7098@opindex Wmissing-attributes
7099@opindex Wno-missing-attributes
ddf6fe37 7100@item -Wmissing-attributes
d77de738
ML
7101Warn when a declaration of a function is missing one or more attributes
7102that a related function is declared with and whose absence may adversely
7103affect the correctness or efficiency of generated code. For example,
7104the warning is issued for declarations of aliases that use attributes
7105to specify less restrictive requirements than those of their targets.
7106This typically represents a potential optimization opportunity.
7107By contrast, the @option{-Wattribute-alias=2} option controls warnings
7108issued when the alias is more restrictive than the target, which could
7109lead to incorrect code generation.
7110Attributes considered include @code{alloc_align}, @code{alloc_size},
7111@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7112@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7113@code{returns_nonnull}, and @code{returns_twice}.
7114
7115In C++, the warning is issued when an explicit specialization of a primary
7116template declared with attribute @code{alloc_align}, @code{alloc_size},
7117@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7118or @code{nonnull} is declared without it. Attributes @code{deprecated},
7119@code{error}, and @code{warning} suppress the warning.
7120(@pxref{Function Attributes}).
7121
7122You can use the @code{copy} attribute to apply the same
7123set of attributes to a declaration as that on another declaration without
7124explicitly enumerating the attributes. This attribute can be applied
7125to declarations of functions (@pxref{Common Function Attributes}),
7126variables (@pxref{Common Variable Attributes}), or types
7127(@pxref{Common Type Attributes}).
7128
7129@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7130
7131For example, since the declaration of the primary function template
7132below makes use of both attribute @code{malloc} and @code{alloc_size}
7133the declaration of the explicit specialization of the template is
7134diagnosed because it is missing one of the attributes.
7135
7136@smallexample
7137template <class T>
7138T* __attribute__ ((malloc, alloc_size (1)))
7139allocate (size_t);
7140
7141template <>
7142void* __attribute__ ((malloc)) // missing alloc_size
7143allocate<void> (size_t);
7144@end smallexample
7145
d77de738
ML
7146@opindex Wmissing-braces
7147@opindex Wno-missing-braces
ddf6fe37 7148@item -Wmissing-braces
d77de738
ML
7149Warn if an aggregate or union initializer is not fully bracketed. In
7150the following example, the initializer for @code{a} is not fully
7151bracketed, but that for @code{b} is fully bracketed.
7152
7153@smallexample
7154int a[2][2] = @{ 0, 1, 2, 3 @};
7155int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7156@end smallexample
7157
7158This warning is enabled by @option{-Wall}.
7159
d77de738
ML
7160@opindex Wmissing-include-dirs
7161@opindex Wno-missing-include-dirs
ddf6fe37 7162@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
72cfa0f7 7163Warn if a user-supplied include directory does not exist. This option is disabled
d77de738
ML
7164by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7165enabled by default by warning for -I and -J, only.
7166
d77de738
ML
7167@opindex Wmissing-profile
7168@opindex Wno-missing-profile
ddf6fe37 7169@item -Wno-missing-profile
d77de738
ML
7170This option controls warnings if feedback profiles are missing when using the
7171@option{-fprofile-use} option.
7172This option diagnoses those cases where a new function or a new file is added
7173between compiling with @option{-fprofile-generate} and with
7174@option{-fprofile-use}, without regenerating the profiles.
7175In these cases, the profile feedback data files do not contain any
7176profile feedback information for
7177the newly added function or file respectively. Also, in the case when profile
7178count data (.gcda) files are removed, GCC cannot use any profile feedback
7179information. In all these cases, warnings are issued to inform you that a
7180profile generation step is due.
7181Ignoring the warning can result in poorly optimized code.
7182@option{-Wno-missing-profile} can be used to
7183disable the warning, but this is not recommended and should be done only
7184when non-existent profile data is justified.
7185
d77de738
ML
7186@opindex Wmismatched-dealloc
7187@opindex Wno-mismatched-dealloc
ddf6fe37 7188@item -Wmismatched-dealloc
d77de738
ML
7189
7190Warn for calls to deallocation functions with pointer arguments returned
7191from from allocations functions for which the former isn't a suitable
7192deallocator. A pair of functions can be associated as matching allocators
7193and deallocators by use of attribute @code{malloc}. Unless disabled by
7194the @option{-fno-builtin} option the standard functions @code{calloc},
7195@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7196forms of C++ @code{operator new} and @code{operator delete} are implicitly
7197associated as matching allocators and deallocators. In the following
7198example @code{mydealloc} is the deallocator for pointers returned from
7199@code{myalloc}.
7200
7201@smallexample
7202void mydealloc (void*);
7203
7204__attribute__ ((malloc (mydealloc, 1))) void*
7205myalloc (size_t);
7206
7207void f (void)
7208@{
7209 void *p = myalloc (32);
7210 // @dots{}use p@dots{}
7211 free (p); // warning: not a matching deallocator for myalloc
7212 mydealloc (p); // ok
7213@}
7214@end smallexample
7215
7216In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7217mismatches involving either @code{operator new} or @code{operator delete}.
7218
7219Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7220
d77de738
ML
7221@opindex Wmultistatement-macros
7222@opindex Wno-multistatement-macros
ddf6fe37 7223@item -Wmultistatement-macros
d77de738
ML
7224Warn about unsafe multiple statement macros that appear to be guarded
7225by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7226@code{while}, in which only the first statement is actually guarded after
7227the macro is expanded.
7228
7229For example:
7230
7231@smallexample
7232#define DOIT x++; y++
7233if (c)
7234 DOIT;
7235@end smallexample
7236
7237will increment @code{y} unconditionally, not just when @code{c} holds.
7238The can usually be fixed by wrapping the macro in a do-while loop:
7239@smallexample
7240#define DOIT do @{ x++; y++; @} while (0)
7241if (c)
7242 DOIT;
7243@end smallexample
7244
7245This warning is enabled by @option{-Wall} in C and C++.
7246
d77de738
ML
7247@opindex Wparentheses
7248@opindex Wno-parentheses
ddf6fe37 7249@item -Wparentheses
d77de738
ML
7250Warn if parentheses are omitted in certain contexts, such
7251as when there is an assignment in a context where a truth value
7252is expected, or when operators are nested whose precedence people
7253often get confused about.
7254
7255Also warn if a comparison like @code{x<=y<=z} appears; this is
7256equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7257interpretation from that of ordinary mathematical notation.
7258
7259Also warn for dangerous uses of the GNU extension to
7260@code{?:} with omitted middle operand. When the condition
7261in the @code{?}: operator is a boolean expression, the omitted value is
7262always 1. Often programmers expect it to be a value computed
7263inside the conditional expression instead.
7264
7265For C++ this also warns for some cases of unnecessary parentheses in
7266declarations, which can indicate an attempt at a function call instead
7267of a declaration:
7268@smallexample
7269@{
7270 // Declares a local variable called mymutex.
7271 std::unique_lock<std::mutex> (mymutex);
7272 // User meant std::unique_lock<std::mutex> lock (mymutex);
7273@}
7274@end smallexample
7275
7276This warning is enabled by @option{-Wall}.
7277
d77de738
ML
7278@opindex Wself-move
7279@opindex Wno-self-move
ddf6fe37 7280@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7281This warning warns when a value is moved to itself with @code{std::move}.
7282Such a @code{std::move} typically has no effect.
7283
7284@smallexample
7285struct T @{
7286@dots{}
7287@};
7288void fn()
7289@{
7290 T t;
7291 @dots{}
7292 t = std::move (t);
7293@}
7294@end smallexample
7295
7296This warning is enabled by @option{-Wall}.
7297
d77de738
ML
7298@opindex Wsequence-point
7299@opindex Wno-sequence-point
ddf6fe37 7300@item -Wsequence-point
d77de738
ML
7301Warn about code that may have undefined semantics because of violations
7302of sequence point rules in the C and C++ standards.
7303
7304The C and C++ standards define the order in which expressions in a C/C++
7305program are evaluated in terms of @dfn{sequence points}, which represent
7306a partial ordering between the execution of parts of the program: those
7307executed before the sequence point, and those executed after it. These
7308occur after the evaluation of a full expression (one which is not part
7309of a larger expression), after the evaluation of the first operand of a
7310@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7311function is called (but after the evaluation of its arguments and the
7312expression denoting the called function), and in certain other places.
7313Other than as expressed by the sequence point rules, the order of
7314evaluation of subexpressions of an expression is not specified. All
7315these rules describe only a partial order rather than a total order,
7316since, for example, if two functions are called within one expression
7317with no sequence point between them, the order in which the functions
7318are called is not specified. However, the standards committee have
7319ruled that function calls do not overlap.
7320
7321It is not specified when between sequence points modifications to the
7322values of objects take effect. Programs whose behavior depends on this
7323have undefined behavior; the C and C++ standards specify that ``Between
7324the previous and next sequence point an object shall have its stored
7325value modified at most once by the evaluation of an expression.
7326Furthermore, the prior value shall be read only to determine the value
7327to be stored.''. If a program breaks these rules, the results on any
7328particular implementation are entirely unpredictable.
7329
7330Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7331= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7332diagnosed by this option, and it may give an occasional false positive
7333result, but in general it has been found fairly effective at detecting
7334this sort of problem in programs.
7335
7336The C++17 standard will define the order of evaluation of operands in
7337more cases: in particular it requires that the right-hand side of an
7338assignment be evaluated before the left-hand side, so the above
7339examples are no longer undefined. But this option will still warn
7340about them, to help people avoid writing code that is undefined in C
7341and earlier revisions of C++.
7342
7343The standard is worded confusingly, therefore there is some debate
7344over the precise meaning of the sequence point rules in subtle cases.
7345Links to discussions of the problem, including proposed formal
7346definitions, may be found on the GCC readings page, at
7347@uref{https://gcc.gnu.org/@/readings.html}.
7348
7349This warning is enabled by @option{-Wall} for C and C++.
7350
d77de738
ML
7351@opindex Wno-return-local-addr
7352@opindex Wreturn-local-addr
ddf6fe37 7353@item -Wno-return-local-addr
d77de738
ML
7354Do not warn about returning a pointer (or in C++, a reference) to a
7355variable that goes out of scope after the function returns.
7356
6e312b2b
FW
7357@opindex Wreturn-mismatch
7358@opindex Wno-return-mismatch
7359@item -Wreturn-mismatch
7360Warn about return statements without an expressions in functions which
7361do not return @code{void}. Also warn about a @code{return} statement
7362with an expression in a function whose return type is @code{void},
7363unless the expression type is also @code{void}. As a GNU extension, the
7364latter case is accepted without a warning unless @option{-Wpedantic} is
7365used.
7366
7367Attempting to use the return value of a non-@code{void} function other
7368than @code{main} that flows off the end by reaching the closing curly
7369brace that terminates the function is undefined.
7370
7371This warning is specific to C and enabled by default.
7372
d77de738
ML
7373@opindex Wreturn-type
7374@opindex Wno-return-type
ddf6fe37 7375@item -Wreturn-type
6e312b2b
FW
7376Warn whenever a function is defined with a return type that defaults to
7377@code{int} (unless @option{-Wimplicit-int} is active, which takes
7378precedence). Also warn if execution may reach the end of the function
7379body, or if the function does not contain any return statement at all.
7380
7381Attempting to use the return value of a non-@code{void} function other
7382than @code{main} that flows off the end by reaching the closing curly
7383brace that terminates the function is undefined.
d77de738
ML
7384
7385Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7386than @code{main} results in undefined behavior even when the value of
7387the function is not used.
7388
7389This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7390
d77de738
ML
7391@opindex Wshift-count-negative
7392@opindex Wno-shift-count-negative
ddf6fe37 7393@item -Wno-shift-count-negative
d77de738
ML
7394Controls warnings if a shift count is negative.
7395This warning is enabled by default.
7396
d77de738
ML
7397@opindex Wshift-count-overflow
7398@opindex Wno-shift-count-overflow
ddf6fe37 7399@item -Wno-shift-count-overflow
d77de738
ML
7400Controls warnings if a shift count is greater than or equal to the bit width
7401of the type. This warning is enabled by default.
7402
d77de738
ML
7403@opindex Wshift-negative-value
7404@opindex Wno-shift-negative-value
ddf6fe37 7405@item -Wshift-negative-value
d77de738
ML
7406Warn if left shifting a negative value. This warning is enabled by
7407@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7408
d77de738
ML
7409@opindex Wshift-overflow
7410@opindex Wno-shift-overflow
ddf6fe37
AA
7411@item -Wno-shift-overflow
7412@itemx -Wshift-overflow=@var{n}
d77de738
ML
7413These options control warnings about left shift overflows.
7414
7415@table @gcctabopt
7416@item -Wshift-overflow=1
7417This is the warning level of @option{-Wshift-overflow} and is enabled
7418by default in C99 and C++11 modes (and newer). This warning level does
7419not warn about left-shifting 1 into the sign bit. (However, in C, such
7420an overflow is still rejected in contexts where an integer constant expression
7421is required.) No warning is emitted in C++20 mode (and newer), as signed left
7422shifts always wrap.
7423
7424@item -Wshift-overflow=2
7425This warning level also warns about left-shifting 1 into the sign bit,
7426unless C++14 mode (or newer) is active.
7427@end table
7428
d77de738
ML
7429@opindex Wswitch
7430@opindex Wno-switch
ddf6fe37 7431@item -Wswitch
d77de738
ML
7432Warn whenever a @code{switch} statement has an index of enumerated type
7433and lacks a @code{case} for one or more of the named codes of that
7434enumeration. (The presence of a @code{default} label prevents this
7435warning.) @code{case} labels outside the enumeration range also
7436provoke warnings when this option is used (even if there is a
7437@code{default} label).
7438This warning is enabled by @option{-Wall}.
7439
d77de738
ML
7440@opindex Wswitch-default
7441@opindex Wno-switch-default
ddf6fe37 7442@item -Wswitch-default
d77de738
ML
7443Warn whenever a @code{switch} statement does not have a @code{default}
7444case.
7445
d77de738
ML
7446@opindex Wswitch-enum
7447@opindex Wno-switch-enum
ddf6fe37 7448@item -Wswitch-enum
d77de738
ML
7449Warn whenever a @code{switch} statement has an index of enumerated type
7450and lacks a @code{case} for one or more of the named codes of that
7451enumeration. @code{case} labels outside the enumeration range also
7452provoke warnings when this option is used. The only difference
7453between @option{-Wswitch} and this option is that this option gives a
7454warning about an omitted enumeration code even if there is a
7455@code{default} label.
7456
d77de738
ML
7457@opindex Wswitch-bool
7458@opindex Wno-switch-bool
ddf6fe37 7459@item -Wno-switch-bool
d77de738
ML
7460Do not warn when a @code{switch} statement has an index of boolean type
7461and the case values are outside the range of a boolean type.
7462It is possible to suppress this warning by casting the controlling
7463expression to a type other than @code{bool}. For example:
7464@smallexample
7465@group
7466switch ((int) (a == 4))
7467 @{
7468 @dots{}
7469 @}
7470@end group
7471@end smallexample
7472This warning is enabled by default for C and C++ programs.
7473
d77de738
ML
7474@opindex Wswitch-outside-range
7475@opindex Wno-switch-outside-range
ddf6fe37 7476@item -Wno-switch-outside-range
d77de738
ML
7477This option controls warnings when a @code{switch} case has a value
7478that is outside of its
7479respective type range. This warning is enabled by default for
7480C and C++ programs.
7481
d77de738
ML
7482@opindex Wswitch-unreachable
7483@opindex Wno-switch-unreachable
ddf6fe37 7484@item -Wno-switch-unreachable
d77de738
ML
7485Do not warn when a @code{switch} statement contains statements between the
7486controlling expression and the first case label, which will never be
7487executed. For example:
7488@smallexample
7489@group
7490switch (cond)
7491 @{
7492 i = 15;
7493 @dots{}
7494 case 5:
7495 @dots{}
7496 @}
7497@end group
7498@end smallexample
7499@option{-Wswitch-unreachable} does not warn if the statement between the
7500controlling expression and the first case label is just a declaration:
7501@smallexample
7502@group
7503switch (cond)
7504 @{
7505 int i;
7506 @dots{}
7507 case 5:
7508 i = 5;
7509 @dots{}
7510 @}
7511@end group
7512@end smallexample
7513This warning is enabled by default for C and C++ programs.
7514
d77de738
ML
7515@opindex Wsync-nand
7516@opindex Wno-sync-nand
ddf6fe37 7517@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7518Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7519built-in functions are used. These functions changed semantics in GCC 4.4.
7520
d77de738
ML
7521@opindex Wtrivial-auto-var-init
7522@opindex Wno-trivial-auto-var-init
ddf6fe37 7523@item -Wtrivial-auto-var-init
d77de738
ML
7524Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7525variable. A common situation is an automatic variable that is declared
7526between the controlling expression and the first case label of a @code{switch}
7527statement.
7528
d77de738
ML
7529@opindex Wunused-but-set-parameter
7530@opindex Wno-unused-but-set-parameter
ddf6fe37 7531@item -Wunused-but-set-parameter
d77de738
ML
7532Warn whenever a function parameter is assigned to, but otherwise unused
7533(aside from its declaration).
7534
7535To suppress this warning use the @code{unused} attribute
7536(@pxref{Variable Attributes}).
7537
7538This warning is also enabled by @option{-Wunused} together with
7539@option{-Wextra}.
7540
d77de738
ML
7541@opindex Wunused-but-set-variable
7542@opindex Wno-unused-but-set-variable
ddf6fe37 7543@item -Wunused-but-set-variable
d77de738
ML
7544Warn whenever a local variable is assigned to, but otherwise unused
7545(aside from its declaration).
7546This warning is enabled by @option{-Wall}.
7547
7548To suppress this warning use the @code{unused} attribute
7549(@pxref{Variable Attributes}).
7550
7551This warning is also enabled by @option{-Wunused}, which is enabled
7552by @option{-Wall}.
7553
d77de738
ML
7554@opindex Wunused-function
7555@opindex Wno-unused-function
ddf6fe37 7556@item -Wunused-function
d77de738
ML
7557Warn whenever a static function is declared but not defined or a
7558non-inline static function is unused.
7559This warning is enabled by @option{-Wall}.
7560
d77de738
ML
7561@opindex Wunused-label
7562@opindex Wno-unused-label
ddf6fe37 7563@item -Wunused-label
d77de738
ML
7564Warn whenever a label is declared but not used.
7565This warning is enabled by @option{-Wall}.
7566
7567To suppress this warning use the @code{unused} attribute
7568(@pxref{Variable Attributes}).
7569
d77de738
ML
7570@opindex Wunused-local-typedefs
7571@opindex Wno-unused-local-typedefs
ddf6fe37 7572@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7573Warn when a typedef locally defined in a function is not used.
7574This warning is enabled by @option{-Wall}.
7575
d77de738
ML
7576@opindex Wunused-parameter
7577@opindex Wno-unused-parameter
ddf6fe37 7578@item -Wunused-parameter
d77de738
ML
7579Warn whenever a function parameter is unused aside from its declaration.
7580
7581To suppress this warning use the @code{unused} attribute
7582(@pxref{Variable Attributes}).
7583
d77de738
ML
7584@opindex Wunused-result
7585@opindex Wno-unused-result
ddf6fe37 7586@item -Wno-unused-result
d77de738
ML
7587Do not warn if a caller of a function marked with attribute
7588@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7589its return value. The default is @option{-Wunused-result}.
7590
d77de738
ML
7591@opindex Wunused-variable
7592@opindex Wno-unused-variable
ddf6fe37 7593@item -Wunused-variable
d77de738
ML
7594Warn whenever a local or static variable is unused aside from its
7595declaration. This option implies @option{-Wunused-const-variable=1} for C,
7596but not for C++. This warning is enabled by @option{-Wall}.
7597
7598To suppress this warning use the @code{unused} attribute
7599(@pxref{Variable Attributes}).
7600
d77de738
ML
7601@opindex Wunused-const-variable
7602@opindex Wno-unused-const-variable
ddf6fe37
AA
7603@item -Wunused-const-variable
7604@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7605Warn whenever a constant static variable is unused aside from its declaration.
7606@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7607for C, but not for C++. In C this declares variable storage, but in C++ this
7608is not an error since const variables take the place of @code{#define}s.
7609
7610To suppress this warning use the @code{unused} attribute
7611(@pxref{Variable Attributes}).
7612
7613@table @gcctabopt
7614@item -Wunused-const-variable=1
7615This is the warning level that is enabled by @option{-Wunused-variable} for
7616C. It warns only about unused static const variables defined in the main
7617compilation unit, but not about static const variables declared in any
7618header included.
7619
7620@item -Wunused-const-variable=2
7621This warning level also warns for unused constant static variables in
7622headers (excluding system headers). This is the warning level of
7623@option{-Wunused-const-variable} and must be explicitly requested since
7624in C++ this isn't an error and in C it might be harder to clean up all
7625headers included.
7626@end table
7627
d77de738
ML
7628@opindex Wunused-value
7629@opindex Wno-unused-value
ddf6fe37 7630@item -Wunused-value
d77de738
ML
7631Warn whenever a statement computes a result that is explicitly not
7632used. To suppress this warning cast the unused expression to
7633@code{void}. This includes an expression-statement or the left-hand
7634side of a comma expression that contains no side effects. For example,
7635an expression such as @code{x[i,j]} causes a warning, while
7636@code{x[(void)i,j]} does not.
7637
7638This warning is enabled by @option{-Wall}.
7639
d77de738
ML
7640@opindex Wunused
7641@opindex Wno-unused
ddf6fe37 7642@item -Wunused
d77de738
ML
7643All the above @option{-Wunused} options combined.
7644
7645In order to get a warning about an unused function parameter, you must
7646either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7647@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7648
d77de738
ML
7649@opindex Wuninitialized
7650@opindex Wno-uninitialized
ddf6fe37 7651@item -Wuninitialized
d77de738
ML
7652Warn if an object with automatic or allocated storage duration is used
7653without having been initialized. In C++, also warn if a non-static
7654reference or non-static @code{const} member appears in a class without
7655constructors.
7656
7657In addition, passing a pointer (or in C++, a reference) to an uninitialized
7658object to a @code{const}-qualified argument of a built-in function known to
7659read the object is also diagnosed by this warning.
7660(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7661
7662If you want to warn about code that uses the uninitialized value of the
7663variable in its own initializer, use the @option{-Winit-self} option.
7664
7665These warnings occur for individual uninitialized elements of
7666structure, union or array variables as well as for variables that are
7667uninitialized as a whole. They do not occur for variables or elements
7668declared @code{volatile}. Because these warnings depend on
7669optimization, the exact variables or elements for which there are
7670warnings depend on the precise optimization options and version of GCC
7671used.
7672
7673Note that there may be no warning about a variable that is used only
7674to compute a value that itself is never used, because such
7675computations may be deleted by data flow analysis before the warnings
7676are printed.
7677
7678In C++, this warning also warns about using uninitialized objects in
7679member-initializer-lists. For example, GCC warns about @code{b} being
7680uninitialized in the following snippet:
7681
7682@smallexample
7683struct A @{
7684 int a;
7685 int b;
7686 A() : a(b) @{ @}
7687@};
7688@end smallexample
7689
d77de738
ML
7690@opindex Winvalid-memory-model
7691@opindex Wno-invalid-memory-model
ddf6fe37 7692@item -Wno-invalid-memory-model
d77de738
ML
7693This option controls warnings
7694for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7695and the C11 atomic generic functions with a memory consistency argument
7696that is either invalid for the operation or outside the range of values
7697of the @code{memory_order} enumeration. For example, since the
7698@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7699defined for the relaxed, release, and sequentially consistent memory
7700orders the following code is diagnosed:
7701
7702@smallexample
7703void store (int *i)
7704@{
7705 __atomic_store_n (i, 0, memory_order_consume);
7706@}
7707@end smallexample
7708
7709@option{-Winvalid-memory-model} is enabled by default.
7710
d77de738
ML
7711@opindex Wmaybe-uninitialized
7712@opindex Wno-maybe-uninitialized
ddf6fe37 7713@item -Wmaybe-uninitialized
d77de738
ML
7714For an object with automatic or allocated storage duration, if there exists
7715a path from the function entry to a use of the object that is initialized,
7716but there exist some other paths for which the object is not initialized,
7717the compiler emits a warning if it cannot prove the uninitialized paths
7718are not executed at run time.
7719
7720In addition, passing a pointer (or in C++, a reference) to an uninitialized
7721object to a @code{const}-qualified function argument is also diagnosed by
7722this warning. (@option{-Wuninitialized} is issued for built-in functions
7723known to read the object.) Annotating the function with attribute
7724@code{access (none)} indicates that the argument isn't used to access
7725the object and avoids the warning (@pxref{Common Function Attributes}).
7726
7727These warnings are only possible in optimizing compilation, because otherwise
7728GCC does not keep track of the state of variables.
7729
7730These warnings are made optional because GCC may not be able to determine when
7731the code is correct in spite of appearing to have an error. Here is one
7732example of how this can happen:
7733
7734@smallexample
7735@group
7736@{
7737 int x;
7738 switch (y)
7739 @{
7740 case 1: x = 1;
7741 break;
7742 case 2: x = 4;
7743 break;
7744 case 3: x = 5;
7745 @}
7746 foo (x);
7747@}
7748@end group
7749@end smallexample
7750
7751@noindent
7752If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7753always initialized, but GCC doesn't know this. To suppress the
7754warning, you need to provide a default case with assert(0) or
7755similar code.
7756
7757@cindex @code{longjmp} warnings
7758This option also warns when a non-volatile automatic variable might be
7759changed by a call to @code{longjmp}.
7760The compiler sees only the calls to @code{setjmp}. It cannot know
7761where @code{longjmp} will be called; in fact, a signal handler could
7762call it at any point in the code. As a result, you may get a warning
7763even when there is in fact no problem because @code{longjmp} cannot
7764in fact be called at the place that would cause a problem.
7765
7766Some spurious warnings can be avoided if you declare all the functions
7767you use that never return as @code{noreturn}. @xref{Function
7768Attributes}.
7769
7770This warning is enabled by @option{-Wall} or @option{-Wextra}.
7771
d77de738
ML
7772@opindex Wunknown-pragmas
7773@opindex Wno-unknown-pragmas
7774@cindex warning for unknown pragmas
7775@cindex unknown pragmas, warning
7776@cindex pragmas, warning of unknown
f33d7a88 7777@item -Wunknown-pragmas
d77de738
ML
7778Warn when a @code{#pragma} directive is encountered that is not understood by
7779GCC@. If this command-line option is used, warnings are even issued
7780for unknown pragmas in system header files. This is not the case if
7781the warnings are only enabled by the @option{-Wall} command-line option.
7782
d77de738
ML
7783@opindex Wno-pragmas
7784@opindex Wpragmas
ddf6fe37 7785@item -Wno-pragmas
d77de738
ML
7786Do not warn about misuses of pragmas, such as incorrect parameters,
7787invalid syntax, or conflicts between pragmas. See also
7788@option{-Wunknown-pragmas}.
7789
d77de738
ML
7790@opindex Wno-prio-ctor-dtor
7791@opindex Wprio-ctor-dtor
ddf6fe37 7792@item -Wno-prio-ctor-dtor
d77de738
ML
7793Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7794The use of constructor and destructor attributes allow you to assign a
7795priority to the constructor/destructor to control its order of execution
7796before @code{main} is called or after it returns. The priority values must be
7797greater than 100 as the compiler reserves priority values between 0--100 for
7798the implementation.
7799
d77de738
ML
7800@opindex Wstrict-aliasing
7801@opindex Wno-strict-aliasing
ddf6fe37 7802@item -Wstrict-aliasing
d77de738
ML
7803This option is only active when @option{-fstrict-aliasing} is active.
7804It warns about code that might break the strict aliasing rules that the
7805compiler is using for optimization. The warning does not catch all
7806cases, but does attempt to catch the more common pitfalls. It is
7807included in @option{-Wall}.
7808It is equivalent to @option{-Wstrict-aliasing=3}
7809
d77de738 7810@opindex Wstrict-aliasing=n
ddf6fe37 7811@item -Wstrict-aliasing=n
d77de738
ML
7812This option is only active when @option{-fstrict-aliasing} is active.
7813It warns about code that might break the strict aliasing rules that the
7814compiler is using for optimization.
7815Higher levels correspond to higher accuracy (fewer false positives).
7816Higher levels also correspond to more effort, similar to the way @option{-O}
7817works.
7818@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7819
7820Level 1: Most aggressive, quick, least accurate.
7821Possibly useful when higher levels
7822do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7823false negatives. However, it has many false positives.
7824Warns for all pointer conversions between possibly incompatible types,
7825even if never dereferenced. Runs in the front end only.
7826
7827Level 2: Aggressive, quick, not too precise.
7828May still have many false positives (not as many as level 1 though),
7829and few false negatives (but possibly more than level 1).
7830Unlike level 1, it only warns when an address is taken. Warns about
7831incomplete types. Runs in the front end only.
7832
7833Level 3 (default for @option{-Wstrict-aliasing}):
7834Should have very few false positives and few false
7835negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7836Takes care of the common pun+dereference pattern in the front end:
7837@code{*(int*)&some_float}.
7838If optimization is enabled, it also runs in the back end, where it deals
7839with multiple statement cases using flow-sensitive points-to information.
7840Only warns when the converted pointer is dereferenced.
7841Does not warn about incomplete types.
7842
d77de738
ML
7843@opindex Wstrict-overflow
7844@opindex Wno-strict-overflow
ddf6fe37
AA
7845@item -Wstrict-overflow
7846@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7847This option is only active when signed overflow is undefined.
7848It warns about cases where the compiler optimizes based on the
7849assumption that signed overflow does not occur. Note that it does not
7850warn about all cases where the code might overflow: it only warns
7851about cases where the compiler implements some optimization. Thus
7852this warning depends on the optimization level.
7853
7854An optimization that assumes that signed overflow does not occur is
7855perfectly safe if the values of the variables involved are such that
7856overflow never does, in fact, occur. Therefore this warning can
7857easily give a false positive: a warning about code that is not
7858actually a problem. To help focus on important issues, several
7859warning levels are defined. No warnings are issued for the use of
7860undefined signed overflow when estimating how many iterations a loop
7861requires, in particular when determining whether a loop will be
7862executed at all.
7863
7864@table @gcctabopt
7865@item -Wstrict-overflow=1
7866Warn about cases that are both questionable and easy to avoid. For
7867example the compiler simplifies
7868@code{x + 1 > x} to @code{1}. This level of
7869@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7870are not, and must be explicitly requested.
7871
7872@item -Wstrict-overflow=2
7873Also warn about other cases where a comparison is simplified to a
7874constant. For example: @code{abs (x) >= 0}. This can only be
7875simplified when signed integer overflow is undefined, because
7876@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7877zero. @option{-Wstrict-overflow} (with no level) is the same as
7878@option{-Wstrict-overflow=2}.
7879
7880@item -Wstrict-overflow=3
7881Also warn about other cases where a comparison is simplified. For
7882example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7883
7884@item -Wstrict-overflow=4
7885Also warn about other simplifications not covered by the above cases.
7886For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7887
7888@item -Wstrict-overflow=5
7889Also warn about cases where the compiler reduces the magnitude of a
7890constant involved in a comparison. For example: @code{x + 2 > y} is
7891simplified to @code{x + 1 >= y}. This is reported only at the
7892highest warning level because this simplification applies to many
7893comparisons, so this warning level gives a very large number of
7894false positives.
7895@end table
7896
d77de738
ML
7897@opindex Wstring-compare
7898@opindex Wno-string-compare
ddf6fe37 7899@item -Wstring-compare
d77de738
ML
7900Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7901determined to be either zero or non-zero in tests for such equality
7902owing to the length of one argument being greater than the size of
7903the array the other argument is stored in (or the bound in the case
7904of @code{strncmp}). Such calls could be mistakes. For example,
7905the call to @code{strcmp} below is diagnosed because its result is
7906necessarily non-zero irrespective of the contents of the array @code{a}.
7907
7908@smallexample
7909extern char a[4];
7910void f (char *d)
7911@{
7912 strcpy (d, "string");
7913 @dots{}
7914 if (0 == strcmp (a, d)) // cannot be true
7915 puts ("a and d are the same");
7916@}
7917@end smallexample
7918
7919@option{-Wstring-compare} is enabled by @option{-Wextra}.
7920
ddf6fe37
AA
7921@opindex Wstringop-overflow
7922@opindex Wno-stringop-overflow
d77de738
ML
7923@item -Wno-stringop-overflow
7924@item -Wstringop-overflow
7925@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7926Warn for calls to string manipulation functions such as @code{memcpy} and
7927@code{strcpy} that are determined to overflow the destination buffer. The
7928optional argument is one greater than the type of Object Size Checking to
7929perform to determine the size of the destination. @xref{Object Size Checking}.
7930The argument is meaningful only for functions that operate on character arrays
7931but not for raw memory functions like @code{memcpy} which always make use
7932of Object Size type-0. The option also warns for calls that specify a size
7933in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7934The option produces the best results with optimization enabled but can detect
7935a small subset of simple buffer overflows even without optimization in
7936calls to the GCC built-in functions like @code{__builtin_memcpy} that
7937correspond to the standard functions. In any case, the option warns about
7938just a subset of buffer overflows detected by the corresponding overflow
7939checking built-ins. For example, the option issues a warning for
7940the @code{strcpy} call below because it copies at least 5 characters
7941(the string @code{"blue"} including the terminating NUL) into the buffer
7942of size 4.
7943
7944@smallexample
7945enum Color @{ blue, purple, yellow @};
7946const char* f (enum Color clr)
7947@{
7948 static char buf [4];
7949 const char *str;
7950 switch (clr)
7951 @{
7952 case blue: str = "blue"; break;
7953 case purple: str = "purple"; break;
7954 case yellow: str = "yellow"; break;
7955 @}
7956
7957 return strcpy (buf, str); // warning here
7958@}
7959@end smallexample
7960
7961Option @option{-Wstringop-overflow=2} is enabled by default.
7962
7963@table @gcctabopt
d77de738
ML
7964@opindex Wstringop-overflow
7965@opindex Wno-stringop-overflow
ddf6fe37
AA
7966@item -Wstringop-overflow
7967@itemx -Wstringop-overflow=1
d77de738
ML
7968The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7969to determine the sizes of destination objects. At this setting the option
7970does not warn for writes past the end of subobjects of larger objects accessed
7971by pointers unless the size of the largest surrounding object is known. When
7972the destination may be one of several objects it is assumed to be the largest
7973one of them. On Linux systems, when optimization is enabled at this setting
7974the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7975is defined to a non-zero value.
7976
7977@item -Wstringop-overflow=2
7978The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7979to determine the sizes of destination objects. At this setting the option
7980warns about overflows when writing to members of the largest complete
7981objects whose exact size is known. However, it does not warn for excessive
7982writes to the same members of unknown objects referenced by pointers since
7983they may point to arrays containing unknown numbers of elements. This is
7984the default setting of the option.
7985
7986@item -Wstringop-overflow=3
7987The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7988to determine the sizes of destination objects. At this setting the option
7989warns about overflowing the smallest object or data member. This is the
7990most restrictive setting of the option that may result in warnings for safe
7991code.
7992
7993@item -Wstringop-overflow=4
7994The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7995to determine the sizes of destination objects. At this setting the option
7996warns about overflowing any data members, and when the destination is
7997one of several objects it uses the size of the largest of them to decide
7998whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7999setting of the option may result in warnings for benign code.
8000@end table
8001
d77de738
ML
8002@opindex Wstringop-overread
8003@opindex Wno-stringop-overread
ddf6fe37 8004@item -Wno-stringop-overread
d77de738
ML
8005Warn for calls to string manipulation functions such as @code{memchr}, or
8006@code{strcpy} that are determined to read past the end of the source
8007sequence.
8008
8009Option @option{-Wstringop-overread} is enabled by default.
8010
d77de738
ML
8011@opindex Wstringop-truncation
8012@opindex Wno-stringop-truncation
ddf6fe37 8013@item -Wno-stringop-truncation
d77de738
ML
8014Do not warn for calls to bounded string manipulation functions
8015such as @code{strncat},
8016@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8017or leave the destination unchanged.
8018
8019In the following example, the call to @code{strncat} specifies a bound that
8020is less than the length of the source string. As a result, the copy of
8021the source will be truncated and so the call is diagnosed. To avoid the
8022warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8023
8024@smallexample
8025void append (char *buf, size_t bufsize)
8026@{
8027 strncat (buf, ".txt", 3);
8028@}
8029@end smallexample
8030
8031As another example, the following call to @code{strncpy} results in copying
8032to @code{d} just the characters preceding the terminating NUL, without
8033appending the NUL to the end. Assuming the result of @code{strncpy} is
8034necessarily a NUL-terminated string is a common mistake, and so the call
8035is diagnosed. To avoid the warning when the result is not expected to be
8036NUL-terminated, call @code{memcpy} instead.
8037
8038@smallexample
8039void copy (char *d, const char *s)
8040@{
8041 strncpy (d, s, strlen (s));
8042@}
8043@end smallexample
8044
8045In the following example, the call to @code{strncpy} specifies the size
8046of the destination buffer as the bound. If the length of the source
8047string is equal to or greater than this size the result of the copy will
8048not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8049the warning, specify @code{sizeof buf - 1} as the bound and set the last
8050element of the buffer to @code{NUL}.
8051
8052@smallexample
8053void copy (const char *s)
8054@{
8055 char buf[80];
8056 strncpy (buf, s, sizeof buf);
8057 @dots{}
8058@}
8059@end smallexample
8060
8061In situations where a character array is intended to store a sequence
8062of bytes with no terminating @code{NUL} such an array may be annotated
8063with attribute @code{nonstring} to avoid this warning. Such arrays,
8064however, are not suitable arguments to functions that expect
8065@code{NUL}-terminated strings. To help detect accidental misuses of
8066such arrays GCC issues warnings unless it can prove that the use is
8067safe. @xref{Common Variable Attributes}.
8068
2a27ae32
QZ
8069@opindex Wstrict-flex-arrays
8070@opindex Wno-strict-flex-arrays
ddf6fe37 8071@item -Wstrict-flex-arrays
2a27ae32
QZ
8072Warn about inproper usages of flexible array members
8073according to the @var{level} of the @code{strict_flex_array (@var{level})}
8074attribute attached to the trailing array field of a structure if it's
8075available, otherwise according to the @var{level} of the option
8076@option{-fstrict-flex-arrays=@var{level}}.
8077
8078This option is effective only when @var{level} is bigger than 0. Otherwise,
8079it will be ignored with a warning.
8080
8081when @var{level}=1, warnings will be issued for a trailing array reference
8082of a structure that have 2 or more elements if the trailing array is referenced
8083as a flexible array member.
8084
8085when @var{level}=2, in addition to @var{level}=1, additional warnings will be
8086issued for a trailing one-element array reference of a structure
8087if the array is referenced as a flexible array member.
8088
8089when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8090issued for a trailing zero-length array reference of a structure
8091if the array is referenced as a flexible array member.
8092
8093
d77de738
ML
8094@opindex Wsuggest-attribute=
8095@opindex Wno-suggest-attribute=
53ba8d66 8096@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}returns_nonnull@r{|}
d77de738
ML
8097Warn for cases where adding an attribute may be beneficial. The
8098attributes currently supported are listed below.
8099
8100@table @gcctabopt
d77de738
ML
8101@opindex Wsuggest-attribute=pure
8102@opindex Wno-suggest-attribute=pure
8103@opindex Wsuggest-attribute=const
8104@opindex Wno-suggest-attribute=const
8105@opindex Wsuggest-attribute=noreturn
8106@opindex Wno-suggest-attribute=noreturn
8107@opindex Wmissing-noreturn
8108@opindex Wno-missing-noreturn
8109@opindex Wsuggest-attribute=malloc
8110@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
8111@item -Wsuggest-attribute=pure
8112@itemx -Wsuggest-attribute=const
8113@itemx -Wsuggest-attribute=noreturn
8114@itemx -Wmissing-noreturn
8115@itemx -Wsuggest-attribute=malloc
53ba8d66
JH
8116@itemx -Wsuggest-attribute=returns_nonnull
8117@itemx -Wno-suggest-attribute=returns_nonnull
d77de738
ML
8118
8119Warn about functions that might be candidates for attributes
53ba8d66 8120@code{pure}, @code{const}, @code{noreturn}, @code{malloc} or @code{returns_nonnull}. The compiler
d77de738
ML
8121only warns for functions visible in other compilation units or (in the case of
8122@code{pure} and @code{const}) if it cannot prove that the function returns
8123normally. A function returns normally if it doesn't contain an infinite loop or
8124return abnormally by throwing, calling @code{abort} or trapping. This analysis
8125requires option @option{-fipa-pure-const}, which is enabled by default at
8126@option{-O} and higher. Higher optimization levels improve the accuracy
8127of the analysis.
8128
d77de738
ML
8129@opindex Wsuggest-attribute=format
8130@opindex Wmissing-format-attribute
8131@opindex Wno-suggest-attribute=format
8132@opindex Wno-missing-format-attribute
8133@opindex Wformat
8134@opindex Wno-format
ddf6fe37
AA
8135@item -Wsuggest-attribute=format
8136@itemx -Wmissing-format-attribute
d77de738
ML
8137
8138Warn about function pointers that might be candidates for @code{format}
8139attributes. Note these are only possible candidates, not absolute ones.
8140GCC guesses that function pointers with @code{format} attributes that
8141are used in assignment, initialization, parameter passing or return
8142statements should have a corresponding @code{format} attribute in the
8143resulting type. I.e.@: the left-hand side of the assignment or
8144initialization, the type of the parameter variable, or the return type
8145of the containing function respectively should also have a @code{format}
8146attribute to avoid the warning.
8147
8148GCC also warns about function definitions that might be
8149candidates for @code{format} attributes. Again, these are only
8150possible candidates. GCC guesses that @code{format} attributes
8151might be appropriate for any function that calls a function like
8152@code{vprintf} or @code{vscanf}, but this might not always be the
8153case, and some functions for which @code{format} attributes are
8154appropriate may not be detected.
8155
d77de738
ML
8156@opindex Wsuggest-attribute=cold
8157@opindex Wno-suggest-attribute=cold
ddf6fe37 8158@item -Wsuggest-attribute=cold
d77de738
ML
8159
8160Warn about functions that might be candidates for @code{cold} attribute. This
8161is based on static detection and generally only warns about functions which
8162always leads to a call to another @code{cold} function such as wrappers of
8163C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8164@end table
8165
d880e093
MU
8166@opindex Wno-alloc-size
8167@opindex Walloc-size
8168@item -Walloc-size
8169Warn about calls to allocation functions decorated with attribute
8170@code{alloc_size} that specify insufficient size for the target type of
8171the pointer the result is assigned to, including those to the built-in
8172forms of the functions @code{aligned_alloc}, @code{alloca},
8173@code{calloc},
8174@code{malloc}, and @code{realloc}.
8175
d77de738
ML
8176@opindex Wno-alloc-zero
8177@opindex Walloc-zero
ddf6fe37 8178@item -Walloc-zero
d77de738
ML
8179Warn about calls to allocation functions decorated with attribute
8180@code{alloc_size} that specify zero bytes, including those to the built-in
8181forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8182@code{malloc}, and @code{realloc}. Because the behavior of these functions
8183when called with a zero size differs among implementations (and in the case
8184of @code{realloc} has been deprecated) relying on it may result in subtle
8185portability bugs and should be avoided.
8186
d77de738
ML
8187@opindex Walloc-size-larger-than=
8188@opindex Wno-alloc-size-larger-than
ddf6fe37 8189@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8190Warn about calls to functions decorated with attribute @code{alloc_size}
8191that attempt to allocate objects larger than the specified number of bytes,
8192or where the result of the size computation in an integer type with infinite
8193precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8194@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8195Warnings controlled by the option can be disabled either by specifying
8196@var{byte-size} of @samp{SIZE_MAX} or more or by
8197@option{-Wno-alloc-size-larger-than}.
8198@xref{Function Attributes}.
8199
d77de738 8200@opindex Wno-alloc-size-larger-than
ddf6fe37 8201@item -Wno-alloc-size-larger-than
d77de738
ML
8202Disable @option{-Walloc-size-larger-than=} warnings. The option is
8203equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8204larger.
8205
d77de738
ML
8206@opindex Wno-alloca
8207@opindex Walloca
ddf6fe37 8208@item -Walloca
d77de738
ML
8209This option warns on all uses of @code{alloca} in the source.
8210
d77de738
ML
8211@opindex Walloca-larger-than=
8212@opindex Wno-alloca-larger-than
ddf6fe37 8213@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8214This option warns on calls to @code{alloca} with an integer argument whose
8215value is either zero, or that is not bounded by a controlling predicate
8216that limits its value to at most @var{byte-size}. It also warns for calls
8217to @code{alloca} where the bound value is unknown. Arguments of non-integer
8218types are considered unbounded even if they appear to be constrained to
8219the expected range.
8220
8221For example, a bounded case of @code{alloca} could be:
8222
8223@smallexample
8224void func (size_t n)
8225@{
8226 void *p;
8227 if (n <= 1000)
8228 p = alloca (n);
8229 else
8230 p = malloc (n);
8231 f (p);
8232@}
8233@end smallexample
8234
8235In the above example, passing @code{-Walloca-larger-than=1000} would not
8236issue a warning because the call to @code{alloca} is known to be at most
82371000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8238the compiler would emit a warning.
8239
8240Unbounded uses, on the other hand, are uses of @code{alloca} with no
8241controlling predicate constraining its integer argument. For example:
8242
8243@smallexample
8244void func ()
8245@{
8246 void *p = alloca (n);
8247 f (p);
8248@}
8249@end smallexample
8250
8251If @code{-Walloca-larger-than=500} were passed, the above would trigger
8252a warning, but this time because of the lack of bounds checking.
8253
8254Note, that even seemingly correct code involving signed integers could
8255cause a warning:
8256
8257@smallexample
8258void func (signed int n)
8259@{
8260 if (n < 500)
8261 @{
8262 p = alloca (n);
8263 f (p);
8264 @}
8265@}
8266@end smallexample
8267
8268In the above example, @var{n} could be negative, causing a larger than
8269expected argument to be implicitly cast into the @code{alloca} call.
8270
8271This option also warns when @code{alloca} is used in a loop.
8272
8273@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8274but is usually only effective when @option{-ftree-vrp} is active (default
8275for @option{-O2} and above).
8276
8277See also @option{-Wvla-larger-than=}@samp{byte-size}.
8278
d77de738 8279@opindex Wno-alloca-larger-than
ddf6fe37 8280@item -Wno-alloca-larger-than
d77de738
ML
8281Disable @option{-Walloca-larger-than=} warnings. The option is
8282equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8283
d77de738
ML
8284@opindex Warith-conversion
8285@opindex Wno-arith-conversion
ddf6fe37 8286@item -Warith-conversion
d77de738
ML
8287Do warn about implicit conversions from arithmetic operations even
8288when conversion of the operands to the same type cannot change their
8289values. This affects warnings from @option{-Wconversion},
8290@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8291
8292@smallexample
8293@group
8294void f (char c, int i)
8295@{
8296 c = c + i; // warns with @option{-Wconversion}
8297 c = c + 1; // only warns with @option{-Warith-conversion}
8298@}
8299@end group
8300@end smallexample
8301
d77de738
ML
8302@opindex Wno-array-bounds
8303@opindex Warray-bounds
ddf6fe37
AA
8304@item -Warray-bounds
8305@itemx -Warray-bounds=@var{n}
d77de738
ML
8306Warn about out of bounds subscripts or offsets into arrays. This warning
8307is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8308is active (the default for @option{-O2} and above) but a subset of instances
8309are issued even without optimization.
8310
710c9676
QZ
8311By default, the trailing array of a structure will be treated as a flexible
8312array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8313if it is declared as either a flexible array member per C99 standard onwards
8314(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8315array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8316zero-length arrays or one-element arrays are not warned by default.
8317
8318You can add the option @option{-fstrict-flex-arrays} or
8319@option{-fstrict-flex-arrays=@var{level}} to control how this
8320option treat trailing array of a structure as a flexible array member:
8321
8322when @var{level}<=1, no change to the default behavior.
8323
8324when @var{level}=2, additional warnings will be issued for out of bounds
8325subscripts or offsets into one-element arrays;
8326
8327when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8328issued for out of bounds subscripts or offsets into zero-length arrays.
8329
d77de738
ML
8330@table @gcctabopt
8331@item -Warray-bounds=1
8332This is the default warning level of @option{-Warray-bounds} and is enabled
8333by @option{-Wall}; higher levels are not, and must be explicitly requested.
8334
8335@item -Warray-bounds=2
710c9676
QZ
8336This warning level also warns about the intermediate results of pointer
8337arithmetic that may yield out of bounds values. This warning level may
8338give a larger number of false positives and is deactivated by default.
d77de738
ML
8339@end table
8340
d77de738
ML
8341@opindex Warray-compare
8342@opindex Wno-array-compare
ddf6fe37 8343@item -Warray-compare
d77de738
ML
8344Warn about equality and relational comparisons between two operands of array
8345type. This comparison was deprecated in C++20. For example:
8346
8347@smallexample
8348int arr1[5];
8349int arr2[5];
8350bool same = arr1 == arr2;
8351@end smallexample
8352
8353@option{-Warray-compare} is enabled by @option{-Wall}.
8354
ddf6fe37 8355@opindex Wno-array-parameter
d77de738
ML
8356@item -Warray-parameter
8357@itemx -Warray-parameter=@var{n}
d77de738
ML
8358Warn about redeclarations of functions involving arguments of array or
8359pointer types of inconsistent kinds or forms, and enable the detection
8360of out-of-bounds accesses to such parameters by warnings such as
8361@option{-Warray-bounds}.
8362
8363If the first function declaration uses the array form the bound specified
8364in the array is assumed to be the minimum number of elements expected to
8365be provided in calls to the function and the maximum number of elements
8366accessed by it. Failing to provide arguments of sufficient size or accessing
8367more than the maximum number of elements may be diagnosed by warnings such
8368as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8369involving array parameters declared using the @code{T[static N]} form.
8370
8371For example, the warning triggers for the following redeclarations because
8372the first one allows an array of any size to be passed to @code{f} while
8373the second one with the keyword @code{static} specifies that the array
8374argument must have at least four elements.
8375
8376@smallexample
8377void f (int[static 4]);
8378void f (int[]); // warning (inconsistent array form)
8379
8380void g (void)
8381@{
8382 int *p = (int *)malloc (4);
8383 f (p); // warning (array too small)
8384 @dots{}
8385@}
8386@end smallexample
8387
8388At level 2 the warning also triggers for redeclarations involving any other
8389inconsistency in array or pointer argument forms denoting array sizes.
8390Pointers and arrays of unspecified bound are considered equivalent and do
8391not trigger a warning.
8392
8393@smallexample
8394void g (int*);
8395void g (int[]); // no warning
8396void g (int[8]); // warning (inconsistent array bound)
8397@end smallexample
8398
8399@option{-Warray-parameter=2} is included in @option{-Wall}. The
8400@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8401involving Variable Length Array arguments.
8402
d77de738
ML
8403@opindex Wattribute-alias
8404@opindex Wno-attribute-alias
ddf6fe37
AA
8405@item -Wattribute-alias=@var{n}
8406@itemx -Wno-attribute-alias
d77de738
ML
8407Warn about declarations using the @code{alias} and similar attributes whose
8408target is incompatible with the type of the alias.
8409@xref{Function Attributes,,Declaring Attributes of Functions}.
8410
8411@table @gcctabopt
8412@item -Wattribute-alias=1
8413The default warning level of the @option{-Wattribute-alias} option diagnoses
8414incompatibilities between the type of the alias declaration and that of its
8415target. Such incompatibilities are typically indicative of bugs.
8416
8417@item -Wattribute-alias=2
8418
8419At this level @option{-Wattribute-alias} also diagnoses cases where
8420the attributes of the alias declaration are more restrictive than the
8421attributes applied to its target. These mismatches can potentially
8422result in incorrect code generation. In other cases they may be
8423benign and could be resolved simply by adding the missing attribute to
8424the target. For comparison, see the @option{-Wmissing-attributes}
8425option, which controls diagnostics when the alias declaration is less
8426restrictive than the target, rather than more restrictive.
8427
8428Attributes considered include @code{alloc_align}, @code{alloc_size},
8429@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8430@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8431@code{returns_nonnull}, and @code{returns_twice}.
8432@end table
8433
8434@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8435This is the default. You can disable these warnings with either
8436@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8437
d77de738
ML
8438@opindex Wbidi-chars=
8439@opindex Wbidi-chars
8440@opindex Wno-bidi-chars
ddf6fe37 8441@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8442Warn about possibly misleading UTF-8 bidirectional control characters in
8443comments, string literals, character constants, and identifiers. Such
8444characters can change left-to-right writing direction into right-to-left
8445(and vice versa), which can cause confusion between the logical order and
8446visual order. This may be dangerous; for instance, it may seem that a piece
8447of code is not commented out, whereas it in fact is.
8448
8449There are three levels of warning supported by GCC@. The default is
8450@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8451bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8452@option{-Wbidi-chars=any} warns about any use of bidirectional control
8453characters.
8454
8455By default, this warning does not warn about UCNs. It is, however, possible
8456to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8457@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8458and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8459@option{-Wbidi-chars=any} was specified.
8460
d77de738
ML
8461@opindex Wno-bool-compare
8462@opindex Wbool-compare
ddf6fe37 8463@item -Wbool-compare
d77de738
ML
8464Warn about boolean expression compared with an integer value different from
8465@code{true}/@code{false}. For instance, the following comparison is
8466always false:
8467@smallexample
8468int n = 5;
8469@dots{}
8470if ((n > 1) == 2) @{ @dots{} @}
8471@end smallexample
8472This warning is enabled by @option{-Wall}.
8473
d77de738
ML
8474@opindex Wno-bool-operation
8475@opindex Wbool-operation
ddf6fe37 8476@item -Wbool-operation
d77de738
ML
8477Warn about suspicious operations on expressions of a boolean type. For
8478instance, bitwise negation of a boolean is very likely a bug in the program.
8479For C, this warning also warns about incrementing or decrementing a boolean,
8480which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8481Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8482
8483This warning is enabled by @option{-Wall}.
8484
d77de738
ML
8485@opindex Wno-duplicated-branches
8486@opindex Wduplicated-branches
ddf6fe37 8487@item -Wduplicated-branches
d77de738
ML
8488Warn when an if-else has identical branches. This warning detects cases like
8489@smallexample
8490if (p != NULL)
8491 return 0;
8492else
8493 return 0;
8494@end smallexample
8495It doesn't warn when both branches contain just a null statement. This warning
8496also warn for conditional operators:
8497@smallexample
8498 int i = x ? *p : *p;
8499@end smallexample
8500
d77de738
ML
8501@opindex Wno-duplicated-cond
8502@opindex Wduplicated-cond
ddf6fe37 8503@item -Wduplicated-cond
d77de738
ML
8504Warn about duplicated conditions in an if-else-if chain. For instance,
8505warn for the following code:
8506@smallexample
8507if (p->q != NULL) @{ @dots{} @}
8508else if (p->q != NULL) @{ @dots{} @}
8509@end smallexample
8510
d77de738
ML
8511@opindex Wno-frame-address
8512@opindex Wframe-address
ddf6fe37 8513@item -Wframe-address
d77de738
ML
8514Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8515is called with an argument greater than 0. Such calls may return indeterminate
8516values or crash the program. The warning is included in @option{-Wall}.
8517
d77de738
ML
8518@opindex Wno-discarded-qualifiers
8519@opindex Wdiscarded-qualifiers
ddf6fe37 8520@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8521Do not warn if type qualifiers on pointers are being discarded.
8522Typically, the compiler warns if a @code{const char *} variable is
8523passed to a function that takes a @code{char *} parameter. This option
8524can be used to suppress such a warning.
8525
d77de738
ML
8526@opindex Wno-discarded-array-qualifiers
8527@opindex Wdiscarded-array-qualifiers
ddf6fe37 8528@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8529Do not warn if type qualifiers on arrays which are pointer targets
8530are being discarded. Typically, the compiler warns if a
8531@code{const int (*)[]} variable is passed to a function that
8532takes a @code{int (*)[]} parameter. This option can be used to
8533suppress such a warning.
8534
d77de738
ML
8535@opindex Wno-incompatible-pointer-types
8536@opindex Wincompatible-pointer-types
ddf6fe37 8537@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8538Do not warn when there is a conversion between pointers that have incompatible
8539types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8540which warns for pointer argument passing or assignment with different
8541signedness.
8542
5fccebdb
JM
8543This warning is upgraded to an error by @option{-pedantic-errors}.
8544
d77de738
ML
8545@opindex Wno-int-conversion
8546@opindex Wint-conversion
ddf6fe37 8547@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8548Do not warn about incompatible integer to pointer and pointer to integer
8549conversions. This warning is about implicit conversions; for explicit
8550conversions the warnings @option{-Wno-int-to-pointer-cast} and
8551@option{-Wno-pointer-to-int-cast} may be used.
8552
5fccebdb
JM
8553This warning is upgraded to an error by @option{-pedantic-errors}.
8554
d77de738
ML
8555@opindex Wzero-length-bounds
8556@opindex Wzero-length-bounds
ddf6fe37 8557@item -Wzero-length-bounds
d77de738
ML
8558Warn about accesses to elements of zero-length array members that might
8559overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8560arrays is discouraged because accesses to them are undefined.
d77de738
ML
8561@xref{Zero Length}.
8562
8563For example, the first two stores in function @code{bad} are diagnosed
8564because the array elements overlap the subsequent members @code{b} and
8565@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8566because it is beyond the bounds of the enclosing object.
8567
8568@smallexample
8569struct X @{ int a[0]; int b, c; @};
8570struct X x;
8571
8572void bad (void)
8573@{
8574 x.a[0] = 0; // -Wzero-length-bounds
8575 x.a[1] = 1; // -Wzero-length-bounds
8576 x.a[2] = 2; // -Warray-bounds
8577@}
8578@end smallexample
8579
8580Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8581
d77de738
ML
8582@opindex Wno-div-by-zero
8583@opindex Wdiv-by-zero
ddf6fe37 8584@item -Wno-div-by-zero
d77de738
ML
8585Do not warn about compile-time integer division by zero. Floating-point
8586division by zero is not warned about, as it can be a legitimate way of
8587obtaining infinities and NaNs.
8588
d77de738
ML
8589@opindex Wsystem-headers
8590@opindex Wno-system-headers
8591@cindex warnings from system headers
8592@cindex system headers, warnings from
f33d7a88 8593@item -Wsystem-headers
d77de738
ML
8594Print warning messages for constructs found in system header files.
8595Warnings from system headers are normally suppressed, on the assumption
8596that they usually do not indicate real problems and would only make the
8597compiler output harder to read. Using this command-line option tells
8598GCC to emit warnings from system headers as if they occurred in user
8599code. However, note that using @option{-Wall} in conjunction with this
8600option does @emph{not} warn about unknown pragmas in system
8601headers---for that, @option{-Wunknown-pragmas} must also be used.
8602
d77de738
ML
8603@opindex Wtautological-compare
8604@opindex Wno-tautological-compare
ddf6fe37 8605@item -Wtautological-compare
d77de738
ML
8606Warn if a self-comparison always evaluates to true or false. This
8607warning detects various mistakes such as:
8608@smallexample
8609int i = 1;
8610@dots{}
8611if (i > i) @{ @dots{} @}
8612@end smallexample
8613
8614This warning also warns about bitwise comparisons that always evaluate
8615to true or false, for instance:
8616@smallexample
8617if ((a & 16) == 10) @{ @dots{} @}
8618@end smallexample
8619will always be false.
8620
8621This warning is enabled by @option{-Wall}.
8622
d77de738
ML
8623@opindex Wtrampolines
8624@opindex Wno-trampolines
ddf6fe37 8625@item -Wtrampolines
d77de738
ML
8626Warn about trampolines generated for pointers to nested functions.
8627A trampoline is a small piece of data or code that is created at run
8628time on the stack when the address of a nested function is taken, and is
8629used to call the nested function indirectly. For some targets, it is
8630made up of data only and thus requires no special treatment. But, for
8631most targets, it is made up of code and thus requires the stack to be
8632made executable in order for the program to work properly.
8633
d77de738
ML
8634@opindex Wfloat-equal
8635@opindex Wno-float-equal
ddf6fe37 8636@item -Wfloat-equal
d77de738
ML
8637Warn if floating-point values are used in equality comparisons.
8638
8639The idea behind this is that sometimes it is convenient (for the
8640programmer) to consider floating-point values as approximations to
8641infinitely precise real numbers. If you are doing this, then you need
8642to compute (by analyzing the code, or in some other way) the maximum or
8643likely maximum error that the computation introduces, and allow for it
8644when performing comparisons (and when producing output, but that's a
8645different problem). In particular, instead of testing for equality, you
8646should check to see whether the two values have ranges that overlap; and
8647this is done with the relational operators, so equality comparisons are
8648probably mistaken.
8649
d77de738
ML
8650@opindex Wtraditional
8651@opindex Wno-traditional
ddf6fe37 8652@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8653Warn about certain constructs that behave differently in traditional and
8654ISO C@. Also warn about ISO C constructs that have no traditional C
8655equivalent, and/or problematic constructs that should be avoided.
8656
8657@itemize @bullet
8658@item
8659Macro parameters that appear within string literals in the macro body.
8660In traditional C macro replacement takes place within string literals,
8661but in ISO C it does not.
8662
8663@item
8664In traditional C, some preprocessor directives did not exist.
8665Traditional preprocessors only considered a line to be a directive
8666if the @samp{#} appeared in column 1 on the line. Therefore
8667@option{-Wtraditional} warns about directives that traditional C
8668understands but ignores because the @samp{#} does not appear as the
8669first character on the line. It also suggests you hide directives like
8670@code{#pragma} not understood by traditional C by indenting them. Some
8671traditional implementations do not recognize @code{#elif}, so this option
8672suggests avoiding it altogether.
8673
8674@item
8675A function-like macro that appears without arguments.
8676
8677@item
8678The unary plus operator.
8679
8680@item
8681The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8682constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8683constants.) Note, these suffixes appear in macros defined in the system
8684headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8685Use of these macros in user code might normally lead to spurious
8686warnings, however GCC's integrated preprocessor has enough context to
8687avoid warning in these cases.
8688
8689@item
8690A function declared external in one block and then used after the end of
8691the block.
8692
8693@item
8694A @code{switch} statement has an operand of type @code{long}.
8695
8696@item
8697A non-@code{static} function declaration follows a @code{static} one.
8698This construct is not accepted by some traditional C compilers.
8699
8700@item
8701The ISO type of an integer constant has a different width or
8702signedness from its traditional type. This warning is only issued if
8703the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8704typically represent bit patterns, are not warned about.
8705
8706@item
8707Usage of ISO string concatenation is detected.
8708
8709@item
8710Initialization of automatic aggregates.
8711
8712@item
8713Identifier conflicts with labels. Traditional C lacks a separate
8714namespace for labels.
8715
8716@item
8717Initialization of unions. If the initializer is zero, the warning is
8718omitted. This is done under the assumption that the zero initializer in
8719user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8720initializer warnings and relies on default initialization to zero in the
8721traditional C case.
8722
8723@item
8724Conversions by prototypes between fixed/floating-point values and vice
8725versa. The absence of these prototypes when compiling with traditional
8726C causes serious problems. This is a subset of the possible
8727conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8728
8729@item
8730Use of ISO C style function definitions. This warning intentionally is
8731@emph{not} issued for prototype declarations or variadic functions
8732because these ISO C features appear in your code when using
8733libiberty's traditional C compatibility macros, @code{PARAMS} and
8734@code{VPARAMS}. This warning is also bypassed for nested functions
8735because that feature is already a GCC extension and thus not relevant to
8736traditional C compatibility.
8737@end itemize
8738
d77de738
ML
8739@opindex Wtraditional-conversion
8740@opindex Wno-traditional-conversion
ddf6fe37 8741@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8742Warn if a prototype causes a type conversion that is different from what
8743would happen to the same argument in the absence of a prototype. This
8744includes conversions of fixed point to floating and vice versa, and
8745conversions changing the width or signedness of a fixed-point argument
8746except when the same as the default promotion.
8747
d77de738
ML
8748@opindex Wdeclaration-after-statement
8749@opindex Wno-declaration-after-statement
ddf6fe37 8750@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8751Warn when a declaration is found after a statement in a block. This
8752construct, known from C++, was introduced with ISO C99 and is by default
8753allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8754
5fccebdb
JM
8755This warning is upgraded to an error by @option{-pedantic-errors}.
8756
d77de738
ML
8757@opindex Wshadow
8758@opindex Wno-shadow
ddf6fe37 8759@item -Wshadow
d77de738
ML
8760Warn whenever a local variable or type declaration shadows another
8761variable, parameter, type, class member (in C++), or instance variable
8762(in Objective-C) or whenever a built-in function is shadowed. Note
8763that in C++, the compiler warns if a local variable shadows an
8764explicit typedef, but not if it shadows a struct/class/enum.
8765If this warning is enabled, it includes also all instances of
8766local shadowing. This means that @option{-Wno-shadow=local}
8767and @option{-Wno-shadow=compatible-local} are ignored when
8768@option{-Wshadow} is used.
8769Same as @option{-Wshadow=global}.
8770
d77de738
ML
8771@opindex Wno-shadow-ivar
8772@opindex Wshadow-ivar
ddf6fe37 8773@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8774Do not warn whenever a local variable shadows an instance variable in an
8775Objective-C method.
8776
d77de738 8777@opindex Wshadow=global
ddf6fe37 8778@item -Wshadow=global
d77de738
ML
8779Warn for any shadowing.
8780Same as @option{-Wshadow}.
8781
d77de738 8782@opindex Wshadow=local
ddf6fe37 8783@item -Wshadow=local
d77de738
ML
8784Warn when a local variable shadows another local variable or parameter.
8785
d77de738 8786@opindex Wshadow=compatible-local
ddf6fe37 8787@item -Wshadow=compatible-local
d77de738
ML
8788Warn when a local variable shadows another local variable or parameter
8789whose type is compatible with that of the shadowing variable. In C++,
8790type compatibility here means the type of the shadowing variable can be
8791converted to that of the shadowed variable. The creation of this flag
8792(in addition to @option{-Wshadow=local}) is based on the idea that when
8793a local variable shadows another one of incompatible type, it is most
8794likely intentional, not a bug or typo, as shown in the following example:
8795
8796@smallexample
8797@group
8798for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8799@{
8800 for (int i = 0; i < N; ++i)
8801 @{
8802 ...
8803 @}
8804 ...
8805@}
8806@end group
8807@end smallexample
8808
8809Since the two variable @code{i} in the example above have incompatible types,
8810enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8811Because their types are incompatible, if a programmer accidentally uses one
8812in place of the other, type checking is expected to catch that and emit an
8813error or warning. Use of this flag instead of @option{-Wshadow=local} can
8814possibly reduce the number of warnings triggered by intentional shadowing.
8815Note that this also means that shadowing @code{const char *i} by
8816@code{char *i} does not emit a warning.
8817
8818This warning is also enabled by @option{-Wshadow=local}.
8819
d77de738
ML
8820@opindex Wlarger-than=
8821@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8822@item -Wlarger-than=@var{byte-size}
d77de738
ML
8823Warn whenever an object is defined whose size exceeds @var{byte-size}.
8824@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8825Warnings controlled by the option can be disabled either by specifying
8826@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8827
8828Also warn for calls to bounded functions such as @code{memchr} or
8829@code{strnlen} that specify a bound greater than the largest possible
8830object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8831can only be disabled by @option{-Wno-larger-than}.
8832
d77de738 8833@opindex Wno-larger-than
ddf6fe37 8834@item -Wno-larger-than
d77de738
ML
8835Disable @option{-Wlarger-than=} warnings. The option is equivalent
8836to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8837
d77de738
ML
8838@opindex Wframe-larger-than=
8839@opindex Wno-frame-larger-than
ddf6fe37 8840@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8841Warn if the size of a function frame exceeds @var{byte-size}.
8842The computation done to determine the stack frame size is approximate
8843and not conservative.
8844The actual requirements may be somewhat greater than @var{byte-size}
8845even if you do not get a warning. In addition, any space allocated
8846via @code{alloca}, variable-length arrays, or related constructs
8847is not included by the compiler when determining
8848whether or not to issue a warning.
8849@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8850Warnings controlled by the option can be disabled either by specifying
8851@var{byte-size} of @samp{SIZE_MAX} or more or by
8852@option{-Wno-frame-larger-than}.
8853
d77de738 8854@opindex Wno-frame-larger-than
ddf6fe37 8855@item -Wno-frame-larger-than
d77de738
ML
8856Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8857to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8858
d77de738
ML
8859@opindex Wfree-nonheap-object
8860@opindex Wno-free-nonheap-object
ddf6fe37 8861@item -Wfree-nonheap-object
d77de738
ML
8862Warn when attempting to deallocate an object that was either not allocated
8863on the heap, or by using a pointer that was not returned from a prior call
8864to the corresponding allocation function. For example, because the call
8865to @code{stpcpy} returns a pointer to the terminating nul character and
8866not to the beginning of the object, the call to @code{free} below is
8867diagnosed.
8868
8869@smallexample
8870void f (char *p)
8871@{
8872 p = stpcpy (p, "abc");
8873 // ...
8874 free (p); // warning
8875@}
8876@end smallexample
8877
8878@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8879
d77de738
ML
8880@opindex Wstack-usage
8881@opindex Wno-stack-usage
ddf6fe37 8882@item -Wstack-usage=@var{byte-size}
d77de738
ML
8883Warn if the stack usage of a function might exceed @var{byte-size}.
8884The computation done to determine the stack usage is conservative.
8885Any space allocated via @code{alloca}, variable-length arrays, or related
8886constructs is included by the compiler when determining whether or not to
8887issue a warning.
8888
8889The message is in keeping with the output of @option{-fstack-usage}.
8890
8891@itemize
8892@item
8893If the stack usage is fully static but exceeds the specified amount, it's:
8894
8895@smallexample
8896 warning: stack usage is 1120 bytes
8897@end smallexample
8898@item
8899If the stack usage is (partly) dynamic but bounded, it's:
8900
8901@smallexample
8902 warning: stack usage might be 1648 bytes
8903@end smallexample
8904@item
8905If the stack usage is (partly) dynamic and not bounded, it's:
8906
8907@smallexample
8908 warning: stack usage might be unbounded
8909@end smallexample
8910@end itemize
8911
8912@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8913Warnings controlled by the option can be disabled either by specifying
8914@var{byte-size} of @samp{SIZE_MAX} or more or by
8915@option{-Wno-stack-usage}.
8916
d77de738 8917@opindex Wno-stack-usage
ddf6fe37 8918@item -Wno-stack-usage
d77de738
ML
8919Disable @option{-Wstack-usage=} warnings. The option is equivalent
8920to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8921
d77de738
ML
8922@opindex Wunsafe-loop-optimizations
8923@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8924@item -Wunsafe-loop-optimizations
d77de738
ML
8925Warn if the loop cannot be optimized because the compiler cannot
8926assume anything on the bounds of the loop indices. With
8927@option{-funsafe-loop-optimizations} warn if the compiler makes
8928such assumptions.
8929
d77de738
ML
8930@opindex Wno-pedantic-ms-format
8931@opindex Wpedantic-ms-format
ddf6fe37 8932@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8933When used in combination with @option{-Wformat}
8934and @option{-pedantic} without GNU extensions, this option
8935disables the warnings about non-ISO @code{printf} / @code{scanf} format
8936width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8937which depend on the MS runtime.
8938
d77de738
ML
8939@opindex Wpointer-arith
8940@opindex Wno-pointer-arith
ddf6fe37 8941@item -Wpointer-arith
d77de738
ML
8942Warn about anything that depends on the ``size of'' a function type or
8943of @code{void}. GNU C assigns these types a size of 1, for
8944convenience in calculations with @code{void *} pointers and pointers
8945to functions. In C++, warn also when an arithmetic operation involves
8946@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8947
5fccebdb
JM
8948This warning is upgraded to an error by @option{-pedantic-errors}.
8949
d77de738
ML
8950@opindex Wpointer-compare
8951@opindex Wno-pointer-compare
ddf6fe37 8952@item -Wno-pointer-compare
d77de738
ML
8953Do not warn if a pointer is compared with a zero character constant.
8954This usually
8955means that the pointer was meant to be dereferenced. For example:
8956
8957@smallexample
8958const char *p = foo ();
8959if (p == '\0')
8960 return 42;
8961@end smallexample
8962
8963Note that the code above is invalid in C++11.
8964
8965This warning is enabled by default.
8966
d77de738
ML
8967@opindex Wtsan
8968@opindex Wno-tsan
ddf6fe37 8969@item -Wtsan
d77de738
ML
8970Warn about unsupported features in ThreadSanitizer.
8971
8972ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8973can report false positives.
8974
8975This warning is enabled by default.
8976
d77de738
ML
8977@opindex Wtype-limits
8978@opindex Wno-type-limits
ddf6fe37 8979@item -Wtype-limits
d77de738
ML
8980Warn if a comparison is always true or always false due to the limited
8981range of the data type, but do not warn for constant expressions. For
8982example, warn if an unsigned variable is compared against zero with
8983@code{<} or @code{>=}. This warning is also enabled by
8984@option{-Wextra}.
8985
d77de738
ML
8986@opindex Wabsolute-value
8987@opindex Wno-absolute-value
ddf6fe37 8988@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8989Warn for calls to standard functions that compute the absolute value
8990of an argument when a more appropriate standard function is available.
8991For example, calling @code{abs(3.14)} triggers the warning because the
8992appropriate function to call to compute the absolute value of a double
8993argument is @code{fabs}. The option also triggers warnings when the
8994argument in a call to such a function has an unsigned type. This
8995warning can be suppressed with an explicit type cast and it is also
8996enabled by @option{-Wextra}.
8997
8998@include cppwarnopts.texi
8999
d77de738
ML
9000@opindex Wbad-function-cast
9001@opindex Wno-bad-function-cast
ddf6fe37 9002@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
9003Warn when a function call is cast to a non-matching type.
9004For example, warn if a call to a function returning an integer type
9005is cast to a pointer type.
9006
d77de738
ML
9007@opindex Wc90-c99-compat
9008@opindex Wno-c90-c99-compat
ddf6fe37 9009@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
9010Warn about features not present in ISO C90, but present in ISO C99.
9011For instance, warn about use of variable length arrays, @code{long long}
9012type, @code{bool} type, compound literals, designated initializers, and so
9013on. This option is independent of the standards mode. Warnings are disabled
9014in the expression that follows @code{__extension__}.
9015
d77de738
ML
9016@opindex Wc99-c11-compat
9017@opindex Wno-c99-c11-compat
ddf6fe37 9018@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
9019Warn about features not present in ISO C99, but present in ISO C11.
9020For instance, warn about use of anonymous structures and unions,
9021@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9022@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9023and so on. This option is independent of the standards mode. Warnings are
9024disabled in the expression that follows @code{__extension__}.
9025
fad61bf7
JM
9026@opindex Wc11-c23-compat
9027@opindex Wno-c11-c23-compat
9028@item -Wc11-c23-compat @r{(C and Objective-C only)}
9029@itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9030Warn about features not present in ISO C11, but present in ISO C23.
d77de738
ML
9031For instance, warn about omitting the string in @code{_Static_assert},
9032use of @samp{[[]]} syntax for attributes, use of decimal
9033floating-point types, and so on. This option is independent of the
9034standards mode. Warnings are disabled in the expression that follows
fad61bf7
JM
9035@code{__extension__}. The name @option{-Wc11-c2x-compat} is
9036deprecated.
d77de738 9037
fad61bf7 9038When not compiling in C23 mode, these warnings are upgraded to errors
5fccebdb
JM
9039by @option{-pedantic-errors}.
9040
d77de738
ML
9041@opindex Wc++-compat
9042@opindex Wno-c++-compat
ddf6fe37 9043@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
9044Warn about ISO C constructs that are outside of the common subset of
9045ISO C and ISO C++, e.g.@: request for implicit conversion from
9046@code{void *} to a pointer to non-@code{void} type.
9047
d77de738
ML
9048@opindex Wc++11-compat
9049@opindex Wno-c++11-compat
ddf6fe37 9050@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9051Warn about C++ constructs whose meaning differs between ISO C++ 1998
9052and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9053in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9054enabled by @option{-Wall}.
9055
d77de738
ML
9056@opindex Wc++14-compat
9057@opindex Wno-c++14-compat
ddf6fe37 9058@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9059Warn about C++ constructs whose meaning differs between ISO C++ 2011
9060and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9061
d77de738
ML
9062@opindex Wc++17-compat
9063@opindex Wno-c++17-compat
ddf6fe37 9064@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9065Warn about C++ constructs whose meaning differs between ISO C++ 2014
9066and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9067
d77de738
ML
9068@opindex Wc++20-compat
9069@opindex Wno-c++20-compat
ddf6fe37 9070@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9071Warn about C++ constructs whose meaning differs between ISO C++ 2017
9072and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9073
d77de738
ML
9074@opindex Wc++11-extensions
9075@opindex Wno-c++11-extensions
ddf6fe37 9076@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9077Do not warn about C++11 constructs in code being compiled using
9078an older C++ standard. Even without this option, some C++11 constructs
9079will only be diagnosed if @option{-Wpedantic} is used.
9080
d77de738
ML
9081@opindex Wc++14-extensions
9082@opindex Wno-c++14-extensions
ddf6fe37 9083@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9084Do not warn about C++14 constructs in code being compiled using
9085an older C++ standard. Even without this option, some C++14 constructs
9086will only be diagnosed if @option{-Wpedantic} is used.
9087
d77de738
ML
9088@opindex Wc++17-extensions
9089@opindex Wno-c++17-extensions
ddf6fe37 9090@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9091Do not warn about C++17 constructs in code being compiled using
9092an older C++ standard. Even without this option, some C++17 constructs
9093will only be diagnosed if @option{-Wpedantic} is used.
9094
d77de738
ML
9095@opindex Wc++20-extensions
9096@opindex Wno-c++20-extensions
ddf6fe37 9097@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9098Do not warn about C++20 constructs in code being compiled using
9099an older C++ standard. Even without this option, some C++20 constructs
9100will only be diagnosed if @option{-Wpedantic} is used.
9101
d77de738
ML
9102@opindex Wc++23-extensions
9103@opindex Wno-c++23-extensions
ddf6fe37 9104@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9105Do not warn about C++23 constructs in code being compiled using
9106an older C++ standard. Even without this option, some C++23 constructs
9107will only be diagnosed if @option{-Wpedantic} is used.
9108
d77de738
ML
9109@opindex Wcast-qual
9110@opindex Wno-cast-qual
ddf6fe37 9111@item -Wcast-qual
d77de738
ML
9112Warn whenever a pointer is cast so as to remove a type qualifier from
9113the target type. For example, warn if a @code{const char *} is cast
9114to an ordinary @code{char *}.
9115
9116Also warn when making a cast that introduces a type qualifier in an
9117unsafe way. For example, casting @code{char **} to @code{const char **}
9118is unsafe, as in this example:
9119
9120@smallexample
9121 /* p is char ** value. */
9122 const char **q = (const char **) p;
9123 /* Assignment of readonly string to const char * is OK. */
9124 *q = "string";
9125 /* Now char** pointer points to read-only memory. */
9126 **p = 'b';
9127@end smallexample
9128
d77de738
ML
9129@opindex Wcast-align
9130@opindex Wno-cast-align
ddf6fe37 9131@item -Wcast-align
d77de738
ML
9132Warn whenever a pointer is cast such that the required alignment of the
9133target is increased. For example, warn if a @code{char *} is cast to
9134an @code{int *} on machines where integers can only be accessed at
9135two- or four-byte boundaries.
9136
d77de738 9137@opindex Wcast-align=strict
ddf6fe37 9138@item -Wcast-align=strict
d77de738
ML
9139Warn whenever a pointer is cast such that the required alignment of the
9140target is increased. For example, warn if a @code{char *} is cast to
9141an @code{int *} regardless of the target machine.
9142
d77de738
ML
9143@opindex Wcast-function-type
9144@opindex Wno-cast-function-type
ddf6fe37 9145@item -Wcast-function-type
d77de738
ML
9146Warn when a function pointer is cast to an incompatible function pointer.
9147In a cast involving function types with a variable argument list only
9148the types of initial arguments that are provided are considered.
9149Any parameter of pointer-type matches any other pointer-type. Any benign
9150differences in integral types are ignored, like @code{int} vs.@: @code{long}
9151on ILP32 targets. Likewise type qualifiers are ignored. The function
9152type @code{void (*) (void)} is special and matches everything, which can
9153be used to suppress this warning.
9154In a cast involving pointer to member types this warning warns whenever
9155the type cast is changing the pointer to member type.
9156This warning is enabled by @option{-Wextra}.
9157
d77de738
ML
9158@opindex Wwrite-strings
9159@opindex Wno-write-strings
ddf6fe37 9160@item -Wwrite-strings
d77de738
ML
9161When compiling C, give string constants the type @code{const
9162char[@var{length}]} so that copying the address of one into a
9163non-@code{const} @code{char *} pointer produces a warning. These
9164warnings help you find at compile time code that can try to write
9165into a string constant, but only if you have been very careful about
9166using @code{const} in declarations and prototypes. Otherwise, it is
9167just a nuisance. This is why we did not make @option{-Wall} request
9168these warnings.
9169
9170When compiling C++, warn about the deprecated conversion from string
9171literals to @code{char *}. This warning is enabled by default for C++
9172programs.
9173
5fccebdb
JM
9174This warning is upgraded to an error by @option{-pedantic-errors} in
9175C++11 mode or later.
9176
d77de738
ML
9177@opindex Wclobbered
9178@opindex Wno-clobbered
f33d7a88 9179@item -Wclobbered
d77de738
ML
9180Warn for variables that might be changed by @code{longjmp} or
9181@code{vfork}. This warning is also enabled by @option{-Wextra}.
9182
320dc51c
TS
9183@opindex Wcomplain-wrong-lang
9184@opindex Wno-complain-wrong-lang
f33d7a88 9185@item -Wno-complain-wrong-lang
320dc51c
TS
9186By default, language front ends complain when a command-line option is
9187valid, but not applicable to that front end.
9188This may be disabled with @option{-Wno-complain-wrong-lang},
9189which is mostly useful when invoking a single compiler driver for
9190multiple source files written in different languages, for example:
9191
9192@smallexample
9193$ g++ -fno-rtti a.cc b.f90
9194@end smallexample
9195
9196The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9197and the Fortran front end to compile @file{b.f90}.
9198The latter front end diagnoses
9199@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9200which may be disabled with @option{-Wno-complain-wrong-lang}.
9201
e1f45bea
JM
9202@opindex Wcompare-distinct-pointer-types
9203@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9204Warn if pointers of distinct types are compared without a cast. This
9205warning is enabled by default.
9206
d77de738
ML
9207@opindex Wconversion
9208@opindex Wno-conversion
f33d7a88 9209@item -Wconversion
d77de738
ML
9210Warn for implicit conversions that may alter a value. This includes
9211conversions between real and integer, like @code{abs (x)} when
9212@code{x} is @code{double}; conversions between signed and unsigned,
9213like @code{unsigned ui = -1}; and conversions to smaller types, like
9214@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9215((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9216changed by the conversion like in @code{abs (2.0)}. Warnings about
9217conversions between signed and unsigned integers can be disabled by
9218using @option{-Wno-sign-conversion}.
9219
9220For C++, also warn for confusing overload resolution for user-defined
9221conversions; and conversions that never use a type conversion
9222operator: conversions to @code{void}, the same type, a base class or a
9223reference to them. Warnings about conversions between signed and
9224unsigned integers are disabled by default in C++ unless
9225@option{-Wsign-conversion} is explicitly enabled.
9226
9227Warnings about conversion from arithmetic on a small type back to that
9228type are only given with @option{-Warith-conversion}.
9229
d77de738
ML
9230@opindex Wdangling-else
9231@opindex Wno-dangling-else
ddf6fe37 9232@item -Wdangling-else
d77de738
ML
9233Warn about constructions where there may be confusion to which
9234@code{if} statement an @code{else} branch belongs. Here is an example of
9235such a case:
9236
9237@smallexample
9238@group
9239@{
9240 if (a)
9241 if (b)
9242 foo ();
9243 else
9244 bar ();
9245@}
9246@end group
9247@end smallexample
9248
9249In C/C++, every @code{else} branch belongs to the innermost possible
9250@code{if} statement, which in this example is @code{if (b)}. This is
9251often not what the programmer expected, as illustrated in the above
9252example by indentation the programmer chose. When there is the
9253potential for this confusion, GCC issues a warning when this flag
9254is specified. To eliminate the warning, add explicit braces around
9255the innermost @code{if} statement so there is no way the @code{else}
9256can belong to the enclosing @code{if}. The resulting code
9257looks like this:
9258
9259@smallexample
9260@group
9261@{
9262 if (a)
9263 @{
9264 if (b)
9265 foo ();
9266 else
9267 bar ();
9268 @}
9269@}
9270@end group
9271@end smallexample
9272
9273This warning is enabled by @option{-Wparentheses}.
9274
d77de738
ML
9275@opindex Wdangling-pointer
9276@opindex Wno-dangling-pointer
ddf6fe37
AA
9277@item -Wdangling-pointer
9278@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9279Warn about uses of pointers (or C++ references) to objects with automatic
9280storage duration after their lifetime has ended. This includes local
9281variables declared in nested blocks, compound literals and other unnamed
9282temporary objects. In addition, warn about storing the address of such
9283objects in escaped pointers. The warning is enabled at all optimization
9284levels but may yield different results with optimization than without.
9285
9286@table @gcctabopt
9287@item -Wdangling-pointer=1
9288At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9289For example
9290@smallexample
9291int f (int c1, int c2, x)
9292@{
9293 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9294 // warning: dangling pointer to a compound literal
9295 return p ? *p : 'x';
d77de738
ML
9296@}
9297@end smallexample
9298In the following function the store of the address of the local variable
9299@code{x} in the escaped pointer @code{*p} also triggers the warning.
9300@smallexample
9301void g (int **p)
9302@{
9303 int x = 7;
4ace81b6
SL
9304 // warning: storing the address of a local variable in *p
9305 *p = &x;
d77de738
ML
9306@}
9307@end smallexample
9308
9309@item -Wdangling-pointer=2
9310At level 2, in addition to unconditional uses the warning also diagnoses
9311conditional uses of dangling pointers.
9312
9313For example, because the array @var{a} in the following function is out of
9314scope when the pointer @var{s} that was set to point is used, the warning
9315triggers at this level.
9316
9317@smallexample
9318void f (char *s)
9319@{
9320 if (!s)
9321 @{
9322 char a[12] = "tmpname";
9323 s = a;
9324 @}
4ace81b6
SL
9325 // warning: dangling pointer to a may be used
9326 strcat (s, ".tmp");
d77de738
ML
9327 ...
9328@}
9329@end smallexample
9330@end table
9331
9332@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9333
d77de738
ML
9334@opindex Wdate-time
9335@opindex Wno-date-time
ddf6fe37 9336@item -Wdate-time
d77de738
ML
9337Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9338are encountered as they might prevent bit-wise-identical reproducible
9339compilations.
9340
d77de738
ML
9341@opindex Wempty-body
9342@opindex Wno-empty-body
ddf6fe37 9343@item -Wempty-body
d77de738
ML
9344Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9345while} statement. This warning is also enabled by @option{-Wextra}.
9346
d77de738
ML
9347@opindex Wendif-labels
9348@opindex Wno-endif-labels
ddf6fe37 9349@item -Wno-endif-labels
d77de738
ML
9350Do not warn about stray tokens after @code{#else} and @code{#endif}.
9351
d77de738
ML
9352@opindex Wenum-compare
9353@opindex Wno-enum-compare
ddf6fe37 9354@item -Wenum-compare
d77de738
ML
9355Warn about a comparison between values of different enumerated types.
9356In C++ enumerated type mismatches in conditional expressions are also
9357diagnosed and the warning is enabled by default. In C this warning is
9358enabled by @option{-Wall}.
9359
d77de738
ML
9360@opindex Wenum-conversion
9361@opindex Wno-enum-conversion
ddf6fe37 9362@item -Wenum-conversion
d77de738
ML
9363Warn when a value of enumerated type is implicitly converted to a
9364different enumerated type. This warning is enabled by @option{-Wextra}
9365in C@.
9366
d77de738
ML
9367@opindex Wenum-int-mismatch
9368@opindex Wno-enum-int-mismatch
ddf6fe37 9369@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9370Warn about mismatches between an enumerated type and an integer type in
9371declarations. For example:
9372
9373@smallexample
9374enum E @{ l = -1, z = 0, g = 1 @};
9375int foo(void);
9376enum E foo(void);
9377@end smallexample
9378
9379In C, an enumerated type is compatible with @code{char}, a signed
9380integer type, or an unsigned integer type. However, since the choice
9381of the underlying type of an enumerated type is implementation-defined,
9382such mismatches may cause portability issues. In C++, such mismatches
9383are an error. In C, this warning is enabled by @option{-Wall} and
9384@option{-Wc++-compat}.
9385
d77de738
ML
9386@opindex Wjump-misses-init
9387@opindex Wno-jump-misses-init
ddf6fe37 9388@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9389Warn if a @code{goto} statement or a @code{switch} statement jumps
9390forward across the initialization of a variable, or jumps backward to a
9391label after the variable has been initialized. This only warns about
9392variables that are initialized when they are declared. This warning is
9393only supported for C and Objective-C; in C++ this sort of branch is an
9394error in any case.
9395
9396@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9397can be disabled with the @option{-Wno-jump-misses-init} option.
9398
d77de738
ML
9399@opindex Wsign-compare
9400@opindex Wno-sign-compare
9401@cindex warning for comparison of signed and unsigned values
9402@cindex comparison of signed and unsigned values, warning
9403@cindex signed and unsigned values, comparison warning
f33d7a88 9404@item -Wsign-compare
d77de738
ML
9405Warn when a comparison between signed and unsigned values could produce
9406an incorrect result when the signed value is converted to unsigned.
9407In C++, this warning is also enabled by @option{-Wall}. In C, it is
9408also enabled by @option{-Wextra}.
9409
d77de738
ML
9410@opindex Wsign-conversion
9411@opindex Wno-sign-conversion
ddf6fe37 9412@item -Wsign-conversion
d77de738
ML
9413Warn for implicit conversions that may change the sign of an integer
9414value, like assigning a signed integer expression to an unsigned
9415integer variable. An explicit cast silences the warning. In C, this
9416option is enabled also by @option{-Wconversion}.
9417
44e3f39a
QZ
9418@opindex Wflex-array-member-not-at-end
9419@opindex Wno-flex-array-member-not-at-end
9420@item -Wflex-array-member-not-at-end @r{(C and C++ only)}
9421Warn when a structure containing a C99 flexible array member as the last
9422field is not at the end of another structure.
9423This warning warns e.g. about
9424
9425@smallexample
9426struct flex @{ int length; char data[]; @};
9427struct mid_flex @{ int m; struct flex flex_data; int n; @};
9428@end smallexample
9429
d77de738
ML
9430@opindex Wfloat-conversion
9431@opindex Wno-float-conversion
ddf6fe37 9432@item -Wfloat-conversion
d77de738
ML
9433Warn for implicit conversions that reduce the precision of a real value.
9434This includes conversions from real to integer, and from higher precision
9435real to lower precision real values. This option is also enabled by
9436@option{-Wconversion}.
9437
d77de738
ML
9438@opindex Wno-scalar-storage-order
9439@opindex Wscalar-storage-order
ddf6fe37 9440@item -Wno-scalar-storage-order
d77de738
ML
9441Do not warn on suspicious constructs involving reverse scalar storage order.
9442
d77de738
ML
9443@opindex Wsizeof-array-div
9444@opindex Wno-sizeof-array-div
ddf6fe37 9445@item -Wsizeof-array-div
d77de738
ML
9446Warn about divisions of two sizeof operators when the first one is applied
9447to an array and the divisor does not equal the size of the array element.
9448In such a case, the computation will not yield the number of elements in the
9449array, which is likely what the user intended. This warning warns e.g. about
9450@smallexample
9451int fn ()
9452@{
9453 int arr[10];
9454 return sizeof (arr) / sizeof (short);
9455@}
9456@end smallexample
9457
9458This warning is enabled by @option{-Wall}.
9459
d77de738
ML
9460@opindex Wsizeof-pointer-div
9461@opindex Wno-sizeof-pointer-div
ddf6fe37 9462@item -Wsizeof-pointer-div
d77de738
ML
9463Warn for suspicious divisions of two sizeof expressions that divide
9464the pointer size by the element size, which is the usual way to compute
9465the array size but won't work out correctly with pointers. This warning
9466warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9467not an array, but a pointer. This warning is enabled by @option{-Wall}.
9468
d77de738
ML
9469@opindex Wsizeof-pointer-memaccess
9470@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9471@item -Wsizeof-pointer-memaccess
d77de738
ML
9472Warn for suspicious length parameters to certain string and memory built-in
9473functions if the argument uses @code{sizeof}. This warning triggers for
9474example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9475an array, but a pointer, and suggests a possible fix, or about
9476@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9477also warns about calls to bounded string copy functions like @code{strncat}
9478or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9479the source array. For example, in the following function the call to
9480@code{strncat} specifies the size of the source string as the bound. That
9481is almost certainly a mistake and so the call is diagnosed.
9482@smallexample
9483void make_file (const char *name)
9484@{
9485 char path[PATH_MAX];
9486 strncpy (path, name, sizeof path - 1);
9487 strncat (path, ".text", sizeof ".text");
9488 @dots{}
9489@}
9490@end smallexample
9491
9492The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9493
d77de738
ML
9494@opindex Wsizeof-array-argument
9495@opindex Wno-sizeof-array-argument
ddf6fe37 9496@item -Wno-sizeof-array-argument
d77de738
ML
9497Do not warn when the @code{sizeof} operator is applied to a parameter that is
9498declared as an array in a function definition. This warning is enabled by
9499default for C and C++ programs.
9500
d77de738
ML
9501@opindex Wmemset-elt-size
9502@opindex Wno-memset-elt-size
ddf6fe37 9503@item -Wmemset-elt-size
d77de738
ML
9504Warn for suspicious calls to the @code{memset} built-in function, if the
9505first argument references an array, and the third argument is a number
9506equal to the number of elements, but not equal to the size of the array
9507in memory. This indicates that the user has omitted a multiplication by
9508the element size. This warning is enabled by @option{-Wall}.
9509
d77de738
ML
9510@opindex Wmemset-transposed-args
9511@opindex Wno-memset-transposed-args
ddf6fe37 9512@item -Wmemset-transposed-args
d77de738
ML
9513Warn for suspicious calls to the @code{memset} built-in function where
9514the second argument is not zero and the third argument is zero. For
9515example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9516@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9517is only emitted if the third argument is a literal zero. Otherwise, if
9518it is an expression that is folded to zero, or a cast of zero to some
9519type, it is far less likely that the arguments have been mistakenly
9520transposed and no warning is emitted. This warning is enabled
9521by @option{-Wall}.
9522
d77de738
ML
9523@opindex Waddress
9524@opindex Wno-address
ddf6fe37 9525@item -Waddress
d77de738
ML
9526Warn about suspicious uses of address expressions. These include comparing
9527the address of a function or a declared object to the null pointer constant
9528such as in
9529@smallexample
9530void f (void);
9531void g (void)
9532@{
9533 if (!f) // warning: expression evaluates to false
9534 abort ();
9535@}
9536@end smallexample
9537comparisons of a pointer to a string literal, such as in
9538@smallexample
9539void f (const char *x)
9540@{
9541 if (x == "abc") // warning: expression evaluates to false
9542 puts ("equal");
9543@}
9544@end smallexample
9545and tests of the results of pointer addition or subtraction for equality
9546to null, such as in
9547@smallexample
9548void f (const int *p, int i)
9549@{
9550 return p + i == NULL;
9551@}
9552@end smallexample
9553Such uses typically indicate a programmer error: the address of most
9554functions and objects necessarily evaluates to true (the exception are
9555weak symbols), so their use in a conditional might indicate missing
9556parentheses in a function call or a missing dereference in an array
9557expression. The subset of the warning for object pointers can be
9558suppressed by casting the pointer operand to an integer type such
9559as @code{intptr_t} or @code{uintptr_t}.
9560Comparisons against string literals result in unspecified behavior
9561and are not portable, and suggest the intent was to call @code{strcmp}.
9562The warning is suppressed if the suspicious expression is the result
9563of macro expansion.
9564@option{-Waddress} warning is enabled by @option{-Wall}.
9565
d77de738
ML
9566@opindex Waddress-of-packed-member
9567@opindex Wno-address-of-packed-member
ddf6fe37 9568@item -Wno-address-of-packed-member
d77de738
ML
9569Do not warn when the address of packed member of struct or union is taken,
9570which usually results in an unaligned pointer value. This is
9571enabled by default.
9572
d77de738
ML
9573@opindex Wlogical-op
9574@opindex Wno-logical-op
ddf6fe37 9575@item -Wlogical-op
d77de738
ML
9576Warn about suspicious uses of logical operators in expressions.
9577This includes using logical operators in contexts where a
9578bit-wise operator is likely to be expected. Also warns when
9579the operands of a logical operator are the same:
9580@smallexample
9581extern int a;
9582if (a < 0 && a < 0) @{ @dots{} @}
9583@end smallexample
9584
d77de738
ML
9585@opindex Wlogical-not-parentheses
9586@opindex Wno-logical-not-parentheses
ddf6fe37 9587@item -Wlogical-not-parentheses
d77de738
ML
9588Warn about logical not used on the left hand side operand of a comparison.
9589This option does not warn if the right operand is considered to be a boolean
9590expression. Its purpose is to detect suspicious code like the following:
9591@smallexample
9592int a;
9593@dots{}
9594if (!a > 1) @{ @dots{} @}
9595@end smallexample
9596
9597It is possible to suppress the warning by wrapping the LHS into
9598parentheses:
9599@smallexample
9600if ((!a) > 1) @{ @dots{} @}
9601@end smallexample
9602
9603This warning is enabled by @option{-Wall}.
9604
d77de738
ML
9605@opindex Waggregate-return
9606@opindex Wno-aggregate-return
ddf6fe37 9607@item -Waggregate-return
d77de738
ML
9608Warn if any functions that return structures or unions are defined or
9609called. (In languages where you can return an array, this also elicits
9610a warning.)
9611
d77de738
ML
9612@opindex Wno-aggressive-loop-optimizations
9613@opindex Waggressive-loop-optimizations
ddf6fe37 9614@item -Wno-aggressive-loop-optimizations
d77de738
ML
9615Warn if in a loop with constant number of iterations the compiler detects
9616undefined behavior in some statement during one or more of the iterations.
9617
d77de738
ML
9618@opindex Wno-attributes
9619@opindex Wattributes
ddf6fe37 9620@item -Wno-attributes
d77de738
ML
9621Do not warn if an unexpected @code{__attribute__} is used, such as
9622unrecognized attributes, function attributes applied to variables,
9623etc. This does not stop errors for incorrect use of supported
9624attributes.
9625
5fccebdb
JM
9626Warnings about ill-formed uses of standard attributes are upgraded to
9627errors by @option{-pedantic-errors}.
9628
d77de738 9629Additionally, using @option{-Wno-attributes=}, it is possible to suppress
094a609c 9630warnings about unknown scoped attributes (in C++11 and C23). For example,
d77de738
ML
9631@option{-Wno-attributes=vendor::attr} disables warning about the following
9632declaration:
9633
9634@smallexample
9635[[vendor::attr]] void f();
9636@end smallexample
9637
9638It is also possible to disable warning about all attributes in a namespace
9639using @option{-Wno-attributes=vendor::} which prevents warning about both
9640of these declarations:
9641
9642@smallexample
9643[[vendor::safe]] void f();
9644[[vendor::unsafe]] void f2();
9645@end smallexample
9646
9647Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9648
d77de738
ML
9649@opindex Wno-builtin-declaration-mismatch
9650@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9651@item -Wno-builtin-declaration-mismatch
d77de738
ML
9652Warn if a built-in function is declared with an incompatible signature
9653or as a non-function, or when a built-in function declared with a type
9654that does not include a prototype is called with arguments whose promoted
9655types do not match those expected by the function. When @option{-Wextra}
9656is specified, also warn when a built-in function that takes arguments is
9657declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9658warning is enabled by default. To avoid the warning include the appropriate
9659header to bring the prototypes of built-in functions into scope.
9660
9661For example, the call to @code{memset} below is diagnosed by the warning
9662because the function expects a value of type @code{size_t} as its argument
9663but the type of @code{32} is @code{int}. With @option{-Wextra},
9664the declaration of the function is diagnosed as well.
9665@smallexample
9666extern void* memset ();
9667void f (void *d)
9668@{
9669 memset (d, '\0', 32);
9670@}
9671@end smallexample
9672
d77de738
ML
9673@opindex Wno-builtin-macro-redefined
9674@opindex Wbuiltin-macro-redefined
ddf6fe37 9675@item -Wno-builtin-macro-redefined
d77de738
ML
9676Do not warn if certain built-in macros are redefined. This suppresses
9677warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9678@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9679
d77de738
ML
9680@opindex Wstrict-prototypes
9681@opindex Wno-strict-prototypes
ddf6fe37 9682@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9683Warn if a function is declared or defined without specifying the
9684argument types. (An old-style function definition is permitted without
9685a warning if preceded by a declaration that specifies the argument
9686types.)
9687
d77de738
ML
9688@opindex Wold-style-declaration
9689@opindex Wno-old-style-declaration
ddf6fe37 9690@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9691Warn for obsolescent usages, according to the C Standard, in a
9692declaration. For example, warn if storage-class specifiers like
9693@code{static} are not the first things in a declaration. This warning
9694is also enabled by @option{-Wextra}.
9695
d77de738
ML
9696@opindex Wold-style-definition
9697@opindex Wno-old-style-definition
ddf6fe37 9698@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9699Warn if an old-style function definition is used. A warning is given
9700even if there is a previous prototype. A definition using @samp{()}
094a609c 9701is not considered an old-style definition in C23 mode, because it is
d77de738
ML
9702equivalent to @samp{(void)} in that case, but is considered an
9703old-style definition for older standards.
9704
d77de738
ML
9705@opindex Wmissing-parameter-type
9706@opindex Wno-missing-parameter-type
ddf6fe37 9707@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9708A function parameter is declared without a type specifier in K&R-style
9709functions:
9710
9711@smallexample
9712void foo(bar) @{ @}
9713@end smallexample
9714
9715This warning is also enabled by @option{-Wextra}.
9716
d77de738
ML
9717@opindex Wmissing-prototypes
9718@opindex Wno-missing-prototypes
ddf6fe37 9719@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9720Warn if a global function is defined without a previous prototype
9721declaration. This warning is issued even if the definition itself
9722provides a prototype. Use this option to detect global functions
9723that do not have a matching prototype declaration in a header file.
9724This option is not valid for C++ because all function declarations
9725provide prototypes and a non-matching declaration declares an
9726overload rather than conflict with an earlier declaration.
9727Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9728
ffc74822
HM
9729@opindex Wmissing-variable-declarations
9730@opindex Wno-missing-variable-declarations
9731@item -Wmissing-variable-declarations @r{(C and Objective-C only)}
9732Warn if a global variable is defined without a previous declaration.
9733Use this option to detect global variables that do not have a matching
9734extern declaration in a header file.
9735
d77de738
ML
9736@opindex Wmissing-declarations
9737@opindex Wno-missing-declarations
ddf6fe37 9738@item -Wmissing-declarations
d77de738
ML
9739Warn if a global function is defined without a previous declaration.
9740Do so even if the definition itself provides a prototype.
9741Use this option to detect global functions that are not declared in
9742header files. In C, no warnings are issued for functions with previous
9743non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9744missing prototypes. In C++, no warnings are issued for function templates,
9745or for inline functions, or for functions in anonymous namespaces.
9746
d77de738
ML
9747@opindex Wmissing-field-initializers
9748@opindex Wno-missing-field-initializers
9749@opindex W
9750@opindex Wextra
9751@opindex Wno-extra
ddf6fe37 9752@item -Wmissing-field-initializers
d77de738
ML
9753Warn if a structure's initializer has some fields missing. For
9754example, the following code causes such a warning, because
9755@code{x.h} is implicitly zero:
9756
9757@smallexample
9758struct s @{ int f, g, h; @};
9759struct s x = @{ 3, 4 @};
9760@end smallexample
9761
0f8f1dee
MP
9762@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
9763In C this option does not warn about designated initializers, so the
9764following modification does not trigger a warning:
d77de738
ML
9765
9766@smallexample
9767struct s @{ int f, g, h; @};
9768struct s x = @{ .f = 3, .g = 4 @};
9769@end smallexample
9770
9771In C this option does not warn about the universal zero initializer
9772@samp{@{ 0 @}}:
9773
9774@smallexample
9775struct s @{ int f, g, h; @};
9776struct s x = @{ 0 @};
9777@end smallexample
9778
9779Likewise, in C++ this option does not warn about the empty @{ @}
9780initializer, for example:
9781
9782@smallexample
9783struct s @{ int f, g, h; @};
9784s x = @{ @};
9785@end smallexample
9786
9787This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9788warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9789
d77de738
ML
9790@opindex Wmissing-requires
9791@opindex Wno-missing-requires
ddf6fe37 9792@item -Wno-missing-requires
d77de738
ML
9793
9794By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9795
9796@smallexample
9797bool satisfied = requires @{ C<T> @};
9798@end smallexample
9799
9800Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9801expression, which it is for all T. Presumably the user meant to write
9802
9803@smallexample
9804bool satisfied = requires @{ requires C<T> @};
9805@end smallexample
9806
9807so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9808type @samp{T}.
9809
9810This warning can be disabled with @option{-Wno-missing-requires}.
9811
d77de738
ML
9812@opindex Wmissing-template-keyword
9813@opindex Wno-missing-template-keyword
ddf6fe37 9814@item -Wno-missing-template-keyword
d77de738
ML
9815
9816The member access tokens ., -> and :: must be followed by the @code{template}
9817keyword if the parent object is dependent and the member being named is a
9818template.
9819
9820@smallexample
9821template <class X>
9822void DoStuff (X x)
9823@{
9824 x.template DoSomeOtherStuff<X>(); // Good.
9825 x.DoMoreStuff<X>(); // Warning, x is dependent.
9826@}
9827@end smallexample
9828
9829In rare cases it is possible to get false positives. To silence this, wrap
9830the expression in parentheses. For example, the following is treated as a
9831template, even where m and N are integers:
9832
9833@smallexample
9834void NotATemplate (my_class t)
9835@{
9836 int N = 5;
9837
9838 bool test = t.m < N > (0); // Treated as a template.
9839 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9840@}
9841@end smallexample
9842
9843This warning can be disabled with @option{-Wno-missing-template-keyword}.
9844
d77de738
ML
9845@opindex Wno-multichar
9846@opindex Wmultichar
ddf6fe37 9847@item -Wno-multichar
d77de738
ML
9848Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9849Usually they indicate a typo in the user's code, as they have
9850implementation-defined values, and should not be used in portable code.
9851
d77de738
ML
9852@opindex Wnormalized=
9853@opindex Wnormalized
9854@opindex Wno-normalized
9855@cindex NFC
9856@cindex NFKC
9857@cindex character set, input normalization
f33d7a88 9858@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9859In ISO C and ISO C++, two identifiers are different if they are
9860different sequences of characters. However, sometimes when characters
9861outside the basic ASCII character set are used, you can have two
9862different character sequences that look the same. To avoid confusion,
9863the ISO 10646 standard sets out some @dfn{normalization rules} which
9864when applied ensure that two sequences that look the same are turned into
9865the same sequence. GCC can warn you if you are using identifiers that
9866have not been normalized; this option controls that warning.
9867
9868There are four levels of warning supported by GCC@. The default is
9869@option{-Wnormalized=nfc}, which warns about any identifier that is
9870not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9871recommended form for most uses. It is equivalent to
9872@option{-Wnormalized}.
9873
9874Unfortunately, there are some characters allowed in identifiers by
9875ISO C and ISO C++ that, when turned into NFC, are not allowed in
9876identifiers. That is, there's no way to use these symbols in portable
9877ISO C or C++ and have all your identifiers in NFC@.
9878@option{-Wnormalized=id} suppresses the warning for these characters.
9879It is hoped that future versions of the standards involved will correct
9880this, which is why this option is not the default.
9881
9882You can switch the warning off for all characters by writing
9883@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9884only do this if you are using some other normalization scheme (like
9885``D''), because otherwise you can easily create bugs that are
9886literally impossible to see.
9887
9888Some characters in ISO 10646 have distinct meanings but look identical
9889in some fonts or display methodologies, especially once formatting has
9890been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9891LETTER N'', displays just like a regular @code{n} that has been
9892placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9893normalization scheme to convert all these into a standard form as
9894well, and GCC warns if your code is not in NFKC if you use
9895@option{-Wnormalized=nfkc}. This warning is comparable to warning
9896about every identifier that contains the letter O because it might be
9897confused with the digit 0, and so is not the default, but may be
9898useful as a local coding convention if the programming environment
9899cannot be fixed to display these characters distinctly.
9900
d77de738
ML
9901@opindex Wno-attribute-warning
9902@opindex Wattribute-warning
ddf6fe37 9903@item -Wno-attribute-warning
d77de738
ML
9904Do not warn about usage of functions (@pxref{Function Attributes})
9905declared with @code{warning} attribute. By default, this warning is
9906enabled. @option{-Wno-attribute-warning} can be used to disable the
9907warning or @option{-Wno-error=attribute-warning} can be used to
9908disable the error when compiled with @option{-Werror} flag.
9909
d77de738
ML
9910@opindex Wno-deprecated
9911@opindex Wdeprecated
ddf6fe37 9912@item -Wno-deprecated
d77de738
ML
9913Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9914
d77de738
ML
9915@opindex Wno-deprecated-declarations
9916@opindex Wdeprecated-declarations
ddf6fe37 9917@item -Wno-deprecated-declarations
d77de738
ML
9918Do not warn about uses of functions (@pxref{Function Attributes}),
9919variables (@pxref{Variable Attributes}), and types (@pxref{Type
9920Attributes}) marked as deprecated by using the @code{deprecated}
9921attribute.
9922
d77de738
ML
9923@opindex Wno-overflow
9924@opindex Woverflow
ddf6fe37 9925@item -Wno-overflow
d77de738
ML
9926Do not warn about compile-time overflow in constant expressions.
9927
d77de738
ML
9928@opindex Wno-odr
9929@opindex Wodr
ddf6fe37 9930@item -Wno-odr
d77de738
ML
9931Warn about One Definition Rule violations during link-time optimization.
9932Enabled by default.
9933
d77de738
ML
9934@opindex Wopenacc-parallelism
9935@opindex Wno-openacc-parallelism
9936@cindex OpenACC accelerator programming
f33d7a88 9937@item -Wopenacc-parallelism
d77de738
ML
9938Warn about potentially suboptimal choices related to OpenACC parallelism.
9939
d77de738
ML
9940@opindex Wopenmp-simd
9941@opindex Wno-openmp-simd
ddf6fe37 9942@item -Wopenmp-simd
d77de738
ML
9943Warn if the vectorizer cost model overrides the OpenMP
9944simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9945option can be used to relax the cost model.
9946
d77de738
ML
9947@opindex Woverride-init
9948@opindex Wno-override-init
9949@opindex W
9950@opindex Wextra
9951@opindex Wno-extra
ddf6fe37 9952@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9953Warn if an initialized field without side effects is overridden when
9954using designated initializers (@pxref{Designated Inits, , Designated
9955Initializers}).
9956
9957This warning is included in @option{-Wextra}. To get other
9958@option{-Wextra} warnings without this one, use @option{-Wextra
9959-Wno-override-init}.
9960
d77de738
ML
9961@opindex Woverride-init-side-effects
9962@opindex Wno-override-init-side-effects
ddf6fe37 9963@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9964Do not warn if an initialized field with side effects is overridden when
9965using designated initializers (@pxref{Designated Inits, , Designated
9966Initializers}). This warning is enabled by default.
9967
d77de738
ML
9968@opindex Wpacked
9969@opindex Wno-packed
ddf6fe37 9970@item -Wpacked
d77de738
ML
9971Warn if a structure is given the packed attribute, but the packed
9972attribute has no effect on the layout or size of the structure.
9973Such structures may be mis-aligned for little benefit. For
9974instance, in this code, the variable @code{f.x} in @code{struct bar}
9975is misaligned even though @code{struct bar} does not itself
9976have the packed attribute:
9977
9978@smallexample
9979@group
9980struct foo @{
9981 int x;
9982 char a, b, c, d;
9983@} __attribute__((packed));
9984struct bar @{
9985 char z;
9986 struct foo f;
9987@};
9988@end group
9989@end smallexample
9990
d77de738
ML
9991@opindex Wpacked-bitfield-compat
9992@opindex Wno-packed-bitfield-compat
ddf6fe37 9993@item -Wnopacked-bitfield-compat
d77de738
ML
9994The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9995on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9996the change can lead to differences in the structure layout. GCC
9997informs you when the offset of such a field has changed in GCC 4.4.
9998For example there is no longer a 4-bit padding between field @code{a}
9999and @code{b} in this structure:
10000
10001@smallexample
10002struct foo
10003@{
10004 char a:4;
10005 char b:8;
10006@} __attribute__ ((packed));
10007@end smallexample
10008
10009This warning is enabled by default. Use
10010@option{-Wno-packed-bitfield-compat} to disable this warning.
10011
d77de738
ML
10012@opindex Wpacked-not-aligned
10013@opindex Wno-packed-not-aligned
ddf6fe37 10014@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10015Warn if a structure field with explicitly specified alignment in a
10016packed struct or union is misaligned. For example, a warning will
10017be issued on @code{struct S}, like, @code{warning: alignment 1 of
10018'struct S' is less than 8}, in this code:
10019
10020@smallexample
10021@group
10022struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10023struct __attribute__ ((packed)) S @{
10024 struct S8 s8;
10025@};
10026@end group
10027@end smallexample
10028
10029This warning is enabled by @option{-Wall}.
10030
d77de738
ML
10031@opindex Wpadded
10032@opindex Wno-padded
ddf6fe37 10033@item -Wpadded
d77de738
ML
10034Warn if padding is included in a structure, either to align an element
10035of the structure or to align the whole structure. Sometimes when this
10036happens it is possible to rearrange the fields of the structure to
10037reduce the padding and so make the structure smaller.
10038
d77de738
ML
10039@opindex Wredundant-decls
10040@opindex Wno-redundant-decls
ddf6fe37 10041@item -Wredundant-decls
d77de738
ML
10042Warn if anything is declared more than once in the same scope, even in
10043cases where multiple declaration is valid and changes nothing.
10044
d77de738
ML
10045@opindex Wrestrict
10046@opindex Wno-restrict
ddf6fe37 10047@item -Wrestrict
d77de738
ML
10048Warn when an object referenced by a @code{restrict}-qualified parameter
10049(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10050argument, or when copies between such objects overlap. For example,
10051the call to the @code{strcpy} function below attempts to truncate the string
10052by replacing its initial characters with the last four. However, because
10053the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10054the call is diagnosed.
10055
10056@smallexample
10057void foo (void)
10058@{
10059 char a[] = "abcd1234";
10060 strcpy (a, a + 4);
10061 @dots{}
10062@}
10063@end smallexample
10064The @option{-Wrestrict} option detects some instances of simple overlap
10065even without optimization but works best at @option{-O2} and above. It
10066is included in @option{-Wall}.
10067
d77de738
ML
10068@opindex Wnested-externs
10069@opindex Wno-nested-externs
ddf6fe37 10070@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
10071Warn if an @code{extern} declaration is encountered within a function.
10072
d77de738
ML
10073@opindex Winline
10074@opindex Wno-inline
ddf6fe37 10075@item -Winline
d77de738
ML
10076Warn if a function that is declared as inline cannot be inlined.
10077Even with this option, the compiler does not warn about failures to
10078inline functions declared in system headers.
10079
10080The compiler uses a variety of heuristics to determine whether or not
10081to inline a function. For example, the compiler takes into account
10082the size of the function being inlined and the amount of inlining
10083that has already been done in the current function. Therefore,
10084seemingly insignificant changes in the source program can cause the
10085warnings produced by @option{-Winline} to appear or disappear.
10086
d77de738 10087@opindex Winterference-size
ddf6fe37 10088@item -Winterference-size
d77de738
ML
10089Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10090without specifying its value with @option{--param destructive-interference-size}.
10091Also warn about questionable values for that option.
10092
10093This variable is intended to be used for controlling class layout, to
10094avoid false sharing in concurrent code:
10095
10096@smallexample
10097struct independent_fields @{
4ace81b6
SL
10098 alignas(std::hardware_destructive_interference_size)
10099 std::atomic<int> one;
10100 alignas(std::hardware_destructive_interference_size)
10101 std::atomic<int> two;
d77de738
ML
10102@};
10103@end smallexample
10104
10105Here @samp{one} and @samp{two} are intended to be far enough apart
10106that stores to one won't require accesses to the other to reload the
10107cache line.
10108
10109By default, @option{--param destructive-interference-size} and
10110@option{--param constructive-interference-size} are set based on the
10111current @option{-mtune} option, typically to the L1 cache line size
10112for the particular target CPU, sometimes to a range if tuning for a
10113generic target. So all translation units that depend on ABI
10114compatibility for the use of these variables must be compiled with
10115the same @option{-mtune} (or @option{-mcpu}).
10116
10117If ABI stability is important, such as if the use is in a header for a
10118library, you should probably not use the hardware interference size
10119variables at all. Alternatively, you can force a particular value
10120with @option{--param}.
10121
10122If you are confident that your use of the variable does not affect ABI
10123outside a single build of your project, you can turn off the warning
10124with @option{-Wno-interference-size}.
10125
d77de738
ML
10126@opindex Wint-in-bool-context
10127@opindex Wno-int-in-bool-context
ddf6fe37 10128@item -Wint-in-bool-context
d77de738
ML
10129Warn for suspicious use of integer values where boolean values are expected,
10130such as conditional expressions (?:) using non-boolean integer constants in
10131boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10132integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10133for all kinds of multiplications regardless of the data type.
10134This warning is enabled by @option{-Wall}.
10135
d77de738
ML
10136@opindex Wno-int-to-pointer-cast
10137@opindex Wint-to-pointer-cast
ddf6fe37 10138@item -Wno-int-to-pointer-cast
d77de738
ML
10139Suppress warnings from casts to pointer type of an integer of a
10140different size. In C++, casting to a pointer type of smaller size is
10141an error. @option{Wint-to-pointer-cast} is enabled by default.
10142
10143
d77de738
ML
10144@opindex Wno-pointer-to-int-cast
10145@opindex Wpointer-to-int-cast
ddf6fe37 10146@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
10147Suppress warnings from casts from a pointer to an integer type of a
10148different size.
10149
d77de738
ML
10150@opindex Winvalid-pch
10151@opindex Wno-invalid-pch
ddf6fe37 10152@item -Winvalid-pch
d77de738
ML
10153Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10154the search path but cannot be used.
10155
d77de738
ML
10156@opindex Winvalid-utf8
10157@opindex Wno-invalid-utf8
ddf6fe37 10158@item -Winvalid-utf8
d77de738
ML
10159Warn if an invalid UTF-8 character is found.
10160This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10161is used and turned into error with @option{-pedantic-errors}.
10162
d77de738
ML
10163@opindex Wunicode
10164@opindex Wno-unicode
ddf6fe37 10165@item -Wno-unicode
d77de738
ML
10166Don't diagnose invalid forms of delimited or named escape sequences which are
10167treated as separate tokens. @option{Wunicode} is enabled by default.
10168
d77de738
ML
10169@opindex Wlong-long
10170@opindex Wno-long-long
ddf6fe37 10171@item -Wlong-long
d77de738
ML
10172Warn if @code{long long} type is used. This is enabled by either
10173@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10174modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10175
5fccebdb
JM
10176This warning is upgraded to an error by @option{-pedantic-errors}.
10177
d77de738
ML
10178@opindex Wvariadic-macros
10179@opindex Wno-variadic-macros
ddf6fe37 10180@item -Wvariadic-macros
d77de738
ML
10181Warn if variadic macros are used in ISO C90 mode, or if the GNU
10182alternate syntax is used in ISO C99 mode. This is enabled by either
10183@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10184messages, use @option{-Wno-variadic-macros}.
10185
d77de738
ML
10186@opindex Wvarargs
10187@opindex Wno-varargs
ddf6fe37 10188@item -Wno-varargs
d77de738
ML
10189Do not warn upon questionable usage of the macros used to handle variable
10190arguments like @code{va_start}. These warnings are enabled by default.
10191
d77de738
ML
10192@opindex Wvector-operation-performance
10193@opindex Wno-vector-operation-performance
ddf6fe37 10194@item -Wvector-operation-performance
d77de738
ML
10195Warn if vector operation is not implemented via SIMD capabilities of the
10196architecture. Mainly useful for the performance tuning.
10197Vector operation can be implemented @code{piecewise}, which means that the
10198scalar operation is performed on every vector element;
10199@code{in parallel}, which means that the vector operation is implemented
10200using scalars of wider type, which normally is more performance efficient;
10201and @code{as a single scalar}, which means that vector fits into a
10202scalar type.
10203
d77de738
ML
10204@opindex Wvla
10205@opindex Wno-vla
ddf6fe37 10206@item -Wvla
d77de738
ML
10207Warn if a variable-length array is used in the code.
10208@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10209the variable-length array.
10210
5fccebdb
JM
10211This warning is upgraded to an error by @option{-pedantic-errors}.
10212
d77de738
ML
10213@opindex Wvla-larger-than=
10214@opindex Wno-vla-larger-than
ddf6fe37 10215@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10216If this option is used, the compiler warns for declarations of
10217variable-length arrays whose size is either unbounded, or bounded
10218by an argument that allows the array size to exceed @var{byte-size}
10219bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10220works, but with variable-length arrays.
10221
10222Note that GCC may optimize small variable-length arrays of a known
10223value into plain arrays, so this warning may not get triggered for
10224such arrays.
10225
10226@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10227is typically only effective when @option{-ftree-vrp} is active (default
10228for @option{-O2} and above).
10229
10230See also @option{-Walloca-larger-than=@var{byte-size}}.
10231
d77de738 10232@opindex Wno-vla-larger-than
ddf6fe37 10233@item -Wno-vla-larger-than
d77de738
ML
10234Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10235to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10236
d77de738 10237@opindex Wno-vla-parameter
ddf6fe37 10238@item -Wvla-parameter
d77de738
ML
10239Warn about redeclarations of functions involving arguments of Variable
10240Length Array types of inconsistent kinds or forms, and enable the detection
10241of out-of-bounds accesses to such parameters by warnings such as
10242@option{-Warray-bounds}.
10243
10244If the first function declaration uses the VLA form the bound specified
10245in the array is assumed to be the minimum number of elements expected to
10246be provided in calls to the function and the maximum number of elements
10247accessed by it. Failing to provide arguments of sufficient size or
10248accessing more than the maximum number of elements may be diagnosed.
10249
10250For example, the warning triggers for the following redeclarations because
10251the first one allows an array of any size to be passed to @code{f} while
10252the second one specifies that the array argument must have at least @code{n}
10253elements. In addition, calling @code{f} with the associated VLA bound
10254parameter in excess of the actual VLA bound triggers a warning as well.
10255
10256@smallexample
10257void f (int n, int[n]);
4ace81b6
SL
10258// warning: argument 2 previously declared as a VLA
10259void f (int, int[]);
d77de738
ML
10260
10261void g (int n)
10262@{
10263 if (n > 4)
10264 return;
10265 int a[n];
4ace81b6
SL
10266 // warning: access to a by f may be out of bounds
10267 f (sizeof a, a);
d77de738
ML
10268 @dots{}
10269@}
10270
10271@end smallexample
10272
10273@option{-Wvla-parameter} is included in @option{-Wall}. The
10274@option{-Warray-parameter} option triggers warnings for similar problems
10275involving ordinary array arguments.
10276
d77de738
ML
10277@opindex Wvolatile-register-var
10278@opindex Wno-volatile-register-var
ddf6fe37 10279@item -Wvolatile-register-var
d77de738
ML
10280Warn if a register variable is declared volatile. The volatile
10281modifier does not inhibit all optimizations that may eliminate reads
10282and/or writes to register variables. This warning is enabled by
10283@option{-Wall}.
10284
d77de738
ML
10285@opindex Wxor-used-as-pow
10286@opindex Wno-xor-used-as-pow
ddf6fe37 10287@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10288Warn about uses of @code{^}, the exclusive or operator, where it appears
10289the user meant exponentiation. Specifically, the warning occurs when the
10290left-hand side is the decimal constant 2 or 10 and the right-hand side
10291is also a decimal constant.
10292
10293In C and C++, @code{^} means exclusive or, whereas in some other languages
10294(e.g. TeX and some versions of BASIC) it means exponentiation.
10295
10296This warning is enabled by default. It can be silenced by converting one
10297of the operands to hexadecimal.
10298
d77de738
ML
10299@opindex Wdisabled-optimization
10300@opindex Wno-disabled-optimization
ddf6fe37 10301@item -Wdisabled-optimization
d77de738
ML
10302Warn if a requested optimization pass is disabled. This warning does
10303not generally indicate that there is anything wrong with your code; it
10304merely indicates that GCC's optimizers are unable to handle the code
10305effectively. Often, the problem is that your code is too big or too
10306complex; GCC refuses to optimize programs when the optimization
10307itself is likely to take inordinate amounts of time.
10308
d77de738
ML
10309@opindex Wpointer-sign
10310@opindex Wno-pointer-sign
ddf6fe37 10311@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10312Warn for pointer argument passing or assignment with different signedness.
10313This option is only supported for C and Objective-C@. It is implied by
10314@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10315@option{-Wno-pointer-sign}.
10316
5fccebdb
JM
10317This warning is upgraded to an error by @option{-pedantic-errors}.
10318
d77de738
ML
10319@opindex Wstack-protector
10320@opindex Wno-stack-protector
ddf6fe37 10321@item -Wstack-protector
d77de738
ML
10322This option is only active when @option{-fstack-protector} is active. It
10323warns about functions that are not protected against stack smashing.
10324
d77de738
ML
10325@opindex Woverlength-strings
10326@opindex Wno-overlength-strings
ddf6fe37 10327@item -Woverlength-strings
d77de738
ML
10328Warn about string constants that are longer than the ``minimum
10329maximum'' length specified in the C standard. Modern compilers
10330generally allow string constants that are much longer than the
10331standard's minimum limit, but very portable programs should avoid
10332using longer strings.
10333
10334The limit applies @emph{after} string constant concatenation, and does
10335not count the trailing NUL@. In C90, the limit was 509 characters; in
10336C99, it was raised to 4095. C++98 does not specify a normative
10337minimum maximum, so we do not diagnose overlength strings in C++@.
10338
10339This option is implied by @option{-Wpedantic}, and can be disabled with
10340@option{-Wno-overlength-strings}.
10341
d77de738
ML
10342@opindex Wunsuffixed-float-constants
10343@opindex Wno-unsuffixed-float-constants
ddf6fe37 10344@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10345
10346Issue a warning for any floating constant that does not have
10347a suffix. When used together with @option{-Wsystem-headers} it
10348warns about such constants in system header files. This can be useful
10349when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10350from the decimal floating-point extension to C99.
10351
d77de738
ML
10352@opindex Wlto-type-mismatch
10353@opindex Wno-lto-type-mismatch
ddf6fe37 10354@item -Wno-lto-type-mismatch
d77de738
ML
10355
10356During the link-time optimization, do not warn about type mismatches in
10357global declarations from different compilation units.
10358Requires @option{-flto} to be enabled. Enabled by default.
10359
d77de738
ML
10360@opindex Wdesignated-init
10361@opindex Wno-designated-init
ddf6fe37 10362@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10363Suppress warnings when a positional initializer is used to initialize
10364a structure that has been marked with the @code{designated_init}
10365attribute.
10366
10367@end table
10368
10369@node Static Analyzer Options
10370@section Options That Control Static Analysis
10371
10372@table @gcctabopt
d77de738
ML
10373@opindex analyzer
10374@opindex fanalyzer
10375@opindex fno-analyzer
ddf6fe37 10376@item -fanalyzer
d77de738
ML
10377This option enables an static analysis of program flow which looks
10378for ``interesting'' interprocedural paths through the
10379code, and issues warnings for problems found on them.
10380
10381This analysis is much more expensive than other GCC warnings.
10382
a90316c6
DM
10383In technical terms, it performs coverage-guided symbolic execution of
10384the code being compiled. It is neither sound nor complete: it can
10385have false positives and false negatives. It is a bug-finding tool,
10386rather than a tool for proving program correctness.
10387
10388The analyzer is only suitable for use on C code in this release.
10389
d77de738
ML
10390Enabling this option effectively enables the following warnings:
10391
43b72ede
AA
10392@gccoptlist{
10393-Wanalyzer-allocation-size
10394-Wanalyzer-deref-before-check
10395-Wanalyzer-double-fclose
10396-Wanalyzer-double-free
10397-Wanalyzer-exposure-through-output-file
10398-Wanalyzer-exposure-through-uninit-copy
10399-Wanalyzer-fd-access-mode-mismatch
10400-Wanalyzer-fd-double-close
10401-Wanalyzer-fd-leak
10402-Wanalyzer-fd-phase-mismatch
10403-Wanalyzer-fd-type-mismatch
10404-Wanalyzer-fd-use-after-close
10405-Wanalyzer-fd-use-without-check
10406-Wanalyzer-file-leak
10407-Wanalyzer-free-of-non-heap
10408-Wanalyzer-imprecise-fp-arithmetic
841008d3 10409-Wanalyzer-infinite-loop
43b72ede
AA
10410-Wanalyzer-infinite-recursion
10411-Wanalyzer-jump-through-null
10412-Wanalyzer-malloc-leak
10413-Wanalyzer-mismatching-deallocation
10414-Wanalyzer-null-argument
10415-Wanalyzer-null-dereference
10416-Wanalyzer-out-of-bounds
034d99e8 10417-Wanalyzer-overlapping-buffers
43b72ede
AA
10418-Wanalyzer-possible-null-argument
10419-Wanalyzer-possible-null-dereference
10420-Wanalyzer-putenv-of-auto-var
10421-Wanalyzer-shift-count-negative
10422-Wanalyzer-shift-count-overflow
10423-Wanalyzer-stale-setjmp-buffer
cfaaa8b1
DM
10424-Wanalyzer-tainted-allocation-size
10425-Wanalyzer-tainted-array-index
10426-Wanalyzer-tainted-assertion
10427-Wanalyzer-tainted-divisor
10428-Wanalyzer-tainted-offset
10429-Wanalyzer-tainted-size
f65f63c4 10430-Wanalyzer-undefined-behavior-strtok
43b72ede
AA
10431-Wanalyzer-unsafe-call-within-signal-handler
10432-Wanalyzer-use-after-free
10433-Wanalyzer-use-of-pointer-in-stale-stack-frame
10434-Wanalyzer-use-of-uninitialized-value
10435-Wanalyzer-va-arg-type-mismatch
10436-Wanalyzer-va-list-exhausted
10437-Wanalyzer-va-list-leak
10438-Wanalyzer-va-list-use-after-va-end
10439-Wanalyzer-write-to-const
10440-Wanalyzer-write-to-string-literal
d77de738 10441}
d77de738
ML
10442
10443This option is only available if GCC was configured with analyzer
10444support enabled.
10445
d77de738
ML
10446@opindex Wanalyzer-too-complex
10447@opindex Wno-analyzer-too-complex
ddf6fe37 10448@item -Wanalyzer-too-complex
d77de738
ML
10449If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10450to attempt to explore the control flow and data flow in the program,
10451but these can be defeated by sufficiently complicated code.
10452
10453By default, the analysis silently stops if the code is too
10454complicated for the analyzer to fully explore and it reaches an internal
10455limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10456
d77de738
ML
10457@opindex Wanalyzer-allocation-size
10458@opindex Wno-analyzer-allocation-size
ddf6fe37 10459@item -Wno-analyzer-allocation-size
4ace81b6
SL
10460This warning requires @option{-fanalyzer}, which enables it;
10461to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10462
10463This diagnostic warns for paths through the code in which a pointer to
10464a buffer is assigned to point at a buffer with a size that is not a
10465multiple of @code{sizeof (*pointer)}.
10466
10467See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10468
ce51e843
ML
10469@opindex Wanalyzer-deref-before-check
10470@opindex Wno-analyzer-deref-before-check
ddf6fe37 10471@item -Wno-analyzer-deref-before-check
ce51e843
ML
10472This warning requires @option{-fanalyzer}, which enables it; use
10473@option{-Wno-analyzer-deref-before-check}
10474to disable it.
10475
10476This diagnostic warns for paths through the code in which a pointer
10477is checked for @code{NULL} *after* it has already been
10478dereferenced, suggesting that the pointer could have been NULL.
10479Such cases suggest that the check for NULL is either redundant,
10480or that it needs to be moved to before the pointer is dereferenced.
10481
10482This diagnostic also considers values passed to a function argument
10483marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10484value, and thus will complain if such values are checked for @code{NULL}
10485after returning from such a function call.
10486
10487This diagnostic is unlikely to be reported when any level of optimization
10488is enabled, as GCC's optimization logic will typically consider such
10489checks for NULL as being redundant, and optimize them away before the
10490analyzer "sees" them. Hence optimization should be disabled when
10491attempting to trigger this diagnostic.
10492
d77de738
ML
10493@opindex Wanalyzer-double-fclose
10494@opindex Wno-analyzer-double-fclose
ddf6fe37 10495@item -Wno-analyzer-double-fclose
d77de738
ML
10496This warning requires @option{-fanalyzer}, which enables it; use
10497@option{-Wno-analyzer-double-fclose} to disable it.
10498
10499This diagnostic warns for paths through the code in which a @code{FILE *}
10500can have @code{fclose} called on it more than once.
10501
10502See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10503
d77de738
ML
10504@opindex Wanalyzer-double-free
10505@opindex Wno-analyzer-double-free
ddf6fe37 10506@item -Wno-analyzer-double-free
d77de738
ML
10507This warning requires @option{-fanalyzer}, which enables it; use
10508@option{-Wno-analyzer-double-free} to disable it.
10509
10510This diagnostic warns for paths through the code in which a pointer
10511can have a deallocator called on it more than once, either @code{free},
10512or a deallocator referenced by attribute @code{malloc}.
10513
10514See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10515
d77de738
ML
10516@opindex Wanalyzer-exposure-through-output-file
10517@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10518@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10519This warning requires @option{-fanalyzer}, which enables it; use
10520@option{-Wno-analyzer-exposure-through-output-file}
10521to disable it.
10522
10523This diagnostic warns for paths through the code in which a
10524security-sensitive value is written to an output file
10525(such as writing a password to a log file).
10526
10527See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10528
d77de738
ML
10529@opindex Wanalyzer-exposure-through-uninit-copy
10530@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10531@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10532This warning requires both @option{-fanalyzer} and the use of a plugin
10533to specify a function that copies across a ``trust boundary''. Use
10534@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10535
10536This diagnostic warns for ``infoleaks'' - paths through the code in which
10537uninitialized values are copied across a security boundary
10538(such as code within an OS kernel that copies a partially-initialized
10539struct on the stack to user space).
10540
10541See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10542
d77de738
ML
10543@opindex Wanalyzer-fd-access-mode-mismatch
10544@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10545@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10546This warning requires @option{-fanalyzer}, which enables it; use
10547@option{-Wno-analyzer-fd-access-mode-mismatch}
10548to disable it.
10549
10550This diagnostic warns for paths through code in which a
10551@code{read} on a write-only file descriptor is attempted, or vice versa.
10552
10553This diagnostic also warns for code paths in a which a function with attribute
10554@code{fd_arg_read (N)} is called with a file descriptor opened with
10555@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10556@code{fd_arg_write (N)} is called with a file descriptor opened with
10557@code{O_RDONLY} at referenced argument @var{N}.
10558
d77de738
ML
10559@opindex Wanalyzer-fd-double-close
10560@opindex Wno-analyzer-fd-double-close
ddf6fe37 10561@item -Wno-analyzer-fd-double-close
d77de738
ML
10562This warning requires @option{-fanalyzer}, which enables it; use
10563@option{-Wno-analyzer-fd-double-close}
10564to disable it.
10565
10566This diagnostic warns for paths through code in which a
10567file descriptor can be closed more than once.
10568
10569See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10570
d77de738
ML
10571@opindex Wanalyzer-fd-leak
10572@opindex Wno-analyzer-fd-leak
ddf6fe37 10573@item -Wno-analyzer-fd-leak
d77de738
ML
10574This warning requires @option{-fanalyzer}, which enables it; use
10575@option{-Wno-analyzer-fd-leak}
10576to disable it.
10577
10578This diagnostic warns for paths through code in which an
10579open file descriptor is leaked.
10580
10581See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10582
86a90006
DM
10583@opindex Wanalyzer-fd-phase-mismatch
10584@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10585@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10586This warning requires @option{-fanalyzer}, which enables it; use
10587@option{-Wno-analyzer-fd-phase-mismatch}
10588to disable it.
10589
10590This diagnostic warns for paths through code in which an operation is
10591attempted in the wrong phase of a file descriptor's lifetime.
10592For example, it will warn on attempts to call @code{accept} on a stream
10593socket that has not yet had @code{listen} successfully called on it.
10594
10595See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10596
86a90006
DM
10597@opindex Wanalyzer-fd-type-mismatch
10598@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10599@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10600This warning requires @option{-fanalyzer}, which enables it; use
10601@option{-Wno-analyzer-fd-type-mismatch}
10602to disable it.
10603
10604This diagnostic warns for paths through code in which an
10605operation is attempted on the wrong type of file descriptor.
10606For example, it will warn on attempts to use socket operations
10607on a file descriptor obtained via @code{open}, or when attempting
10608to use a stream socket operation on a datagram socket.
10609
d77de738
ML
10610@opindex Wanalyzer-fd-use-after-close
10611@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10612@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10613This warning requires @option{-fanalyzer}, which enables it; use
10614@option{-Wno-analyzer-fd-use-after-close}
10615to disable it.
10616
10617This diagnostic warns for paths through code in which a
10618read or write is called on a closed file descriptor.
10619
10620This diagnostic also warns for paths through code in which
10621a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10622or @code{fd_arg_write (N)} is called with a closed file descriptor at
10623referenced argument @code{N}.
10624
d77de738
ML
10625@opindex Wanalyzer-fd-use-without-check
10626@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10627@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10628This warning requires @option{-fanalyzer}, which enables it; use
10629@option{-Wno-analyzer-fd-use-without-check}
10630to disable it.
10631
10632This diagnostic warns for paths through code in which a
10633file descriptor is used without being checked for validity.
10634
10635This diagnostic also warns for paths through code in which
10636a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10637or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10638argument @code{N}, without being checked for validity.
10639
d77de738
ML
10640@opindex Wanalyzer-file-leak
10641@opindex Wno-analyzer-file-leak
ddf6fe37 10642@item -Wno-analyzer-file-leak
d77de738
ML
10643This warning requires @option{-fanalyzer}, which enables it; use
10644@option{-Wno-analyzer-file-leak}
10645to disable it.
10646
10647This diagnostic warns for paths through the code in which a
10648@code{<stdio.h>} @code{FILE *} stream object is leaked.
10649
10650See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10651
d77de738
ML
10652@opindex Wanalyzer-free-of-non-heap
10653@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10654@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10655This warning requires @option{-fanalyzer}, which enables it; use
10656@option{-Wno-analyzer-free-of-non-heap}
10657to disable it.
10658
10659This diagnostic warns for paths through the code in which @code{free}
10660is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10661
10662See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10663
d77de738
ML
10664@opindex Wanalyzer-imprecise-fp-arithmetic
10665@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10666@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10667This warning requires @option{-fanalyzer}, which enables it; use
10668@option{-Wno-analyzer-imprecise-fp-arithmetic}
10669to disable it.
10670
10671This diagnostic warns for paths through the code in which floating-point
10672arithmetic is used in locations where precise computation is needed. This
10673diagnostic only warns on use of floating-point operands inside the
10674calculation of an allocation size at the moment.
10675
841008d3
DM
10676@opindex Wanalyzer-infinite-loop
10677@opindex Wno-analyzer-infinite-loop
10678@item -Wno-analyzer-infinite-loop
10679This warning requires @option{-fanalyzer}, which enables it; use
10680@option{-Wno-analyzer-infinite-loop} to disable it.
10681
10682This diagnostics warns for paths through the code which appear to
10683lead to an infinite loop.
10684
10685Specifically, the analyzer will issue this warning when it "sees" a loop
10686in which:
10687@itemize @bullet
10688@item
10689no externally-visible work could be being done within the loop
10690@item
10691there is no way to escape from the loop
10692@item
10693the analyzer is sufficiently confident about the program state
10694throughout the loop to know that the above are true
10695@end itemize
10696
10697One way for this warning to be emitted is when there is an execution
10698path through a loop for which taking the path on one iteration implies
10699that the same path will be taken on all subsequent iterations.
10700
10701For example, consider:
10702
10703@smallexample
10704 while (1)
10705 @{
10706 char opcode = *cpu_state.pc;
10707 switch (opcode)
10708 @{
10709 case OPCODE_FOO:
10710 handle_opcode_foo (&cpu_state);
10711 break;
10712 case OPCODE_BAR:
10713 handle_opcode_bar (&cpu_state);
10714 break;
10715 @}
10716 @}
10717@end smallexample
10718
10719The analyzer will complain for the above case because if @code{opcode}
10720ever matches none of the cases, the @code{switch} will follow the
10721implicit @code{default} case, making the body of the loop be a ``no-op''
10722with @code{cpu_state.pc} unchanged, and thus using the same value of
10723@code{opcode} on all subseqent iterations, leading to an infinite loop.
10724
10725See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}.
10726
ce51e843
ML
10727@opindex Wanalyzer-infinite-recursion
10728@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10729@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10730This warning requires @option{-fanalyzer}, which enables it; use
10731@option{-Wno-analyzer-infinite-recursion} to disable it.
10732
10733This diagnostics warns for paths through the code which appear to
10734lead to infinite recursion.
10735
10736Specifically, when the analyzer "sees" a recursive call, it will compare
10737the state of memory at the entry to the new frame with that at the entry
10738to the previous frame of that function on the stack. The warning is
10739issued if nothing in memory appears to be changing; any changes observed
10740to parameters or globals are assumed to lead to termination of the
10741recursion and thus suppress the warning.
10742
10743This diagnostic is likely to miss cases of infinite recursion that
10744are convered to iteration by the optimizer before the analyzer "sees"
10745them. Hence optimization should be disabled when attempting to trigger
10746this diagnostic.
10747
10748Compare with @option{-Winfinite-recursion}, which provides a similar
10749diagnostic, but is implemented in a different way.
10750
841008d3
DM
10751See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}.
10752
d77de738
ML
10753@opindex Wanalyzer-jump-through-null
10754@opindex Wno-analyzer-jump-through-null
ddf6fe37 10755@item -Wno-analyzer-jump-through-null
d77de738
ML
10756This warning requires @option{-fanalyzer}, which enables it; use
10757@option{-Wno-analyzer-jump-through-null}
10758to disable it.
10759
10760This diagnostic warns for paths through the code in which a @code{NULL}
10761function pointer is called.
10762
d77de738
ML
10763@opindex Wanalyzer-malloc-leak
10764@opindex Wno-analyzer-malloc-leak
ddf6fe37 10765@item -Wno-analyzer-malloc-leak
d77de738
ML
10766This warning requires @option{-fanalyzer}, which enables it; use
10767@option{-Wno-analyzer-malloc-leak}
10768to disable it.
10769
10770This diagnostic warns for paths through the code in which a
10771pointer allocated via an allocator is leaked: either @code{malloc},
10772or a function marked with attribute @code{malloc}.
10773
10774See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10775
d77de738
ML
10776@opindex Wanalyzer-mismatching-deallocation
10777@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10778@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10779This warning requires @option{-fanalyzer}, which enables it; use
10780@option{-Wno-analyzer-mismatching-deallocation}
10781to disable it.
10782
10783This diagnostic warns for paths through the code in which the
10784wrong deallocation function is called on a pointer value, based on
10785which function was used to allocate the pointer value. The diagnostic
10786will warn about mismatches between @code{free}, scalar @code{delete}
10787and vector @code{delete[]}, and those marked as allocator/deallocator
10788pairs using attribute @code{malloc}.
10789
10790See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10791
d77de738
ML
10792@opindex Wanalyzer-out-of-bounds
10793@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10794@item -Wno-analyzer-out-of-bounds
4ace81b6 10795This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10796@option{-Wno-analyzer-out-of-bounds} to disable it.
10797
4ace81b6 10798This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10799definitely read or written out-of-bounds. The diagnostic applies for
10800cases where the analyzer is able to determine a constant offset and for
10801accesses past the end of a buffer, also a constant capacity. Further,
10802the diagnostic does limited checking for accesses past the end when the
10803offset as well as the capacity is symbolic.
10804
10805See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10806
0e466e97
DM
10807For cases where the analyzer is able, it will emit a text art diagram
10808visualizing the spatial relationship between the memory region that the
10809analyzer predicts would be accessed, versus the range of memory that is
10810valid to access: whether they overlap, are touching, are close or far
10811apart; which one is before or after in memory, the relative sizes
10812involved, the direction of the access (read vs write), and, in some
10813cases, the values of data involved. This diagram can be suppressed
10814using @option{-fdiagnostics-text-art-charset=none}.
10815
034d99e8
DM
10816@opindex Wanalyzer-overlapping-buffers
10817@opindex Wno-analyzer-overlapping-buffers
10818@item -Wno-analyzer-overlapping-buffers
10819This warning requires @option{-fanalyzer}, which enables it; use
10820@option{-Wno-analyzer-overlapping-buffers} to disable it.
10821
10822This diagnostic warns for paths through the code in which overlapping
10823buffers are passed to an API for which the behavior on such buffers
10824is undefined.
10825
10826Specifically, the diagnostic occurs on calls to the following functions
10827@itemize @bullet
10828@item @code{memcpy}
10829@item @code{strcat}
10830@item @code{strcpy}
10831@end itemize
10832for cases where the buffers are known to overlap.
10833
d77de738
ML
10834@opindex Wanalyzer-possible-null-argument
10835@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10836@item -Wno-analyzer-possible-null-argument
d77de738
ML
10837This warning requires @option{-fanalyzer}, which enables it; use
10838@option{-Wno-analyzer-possible-null-argument} to disable it.
10839
10840This diagnostic warns for paths through the code in which a
10841possibly-NULL value is passed to a function argument marked
10842with @code{__attribute__((nonnull))} as requiring a non-NULL
10843value.
10844
10845See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10846
d77de738
ML
10847@opindex Wanalyzer-possible-null-dereference
10848@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10849@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10850This warning requires @option{-fanalyzer}, which enables it; use
10851@option{-Wno-analyzer-possible-null-dereference} to disable it.
10852
10853This diagnostic warns for paths through the code in which a
10854possibly-NULL value is dereferenced.
10855
10856See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10857
d77de738
ML
10858@opindex Wanalyzer-null-argument
10859@opindex Wno-analyzer-null-argument
ddf6fe37 10860@item -Wno-analyzer-null-argument
d77de738
ML
10861This warning requires @option{-fanalyzer}, which enables it; use
10862@option{-Wno-analyzer-null-argument} to disable it.
10863
10864This diagnostic warns for paths through the code in which a
10865value known to be NULL is passed to a function argument marked
10866with @code{__attribute__((nonnull))} as requiring a non-NULL
10867value.
10868
10869See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10870
d77de738
ML
10871@opindex Wanalyzer-null-dereference
10872@opindex Wno-analyzer-null-dereference
ddf6fe37 10873@item -Wno-analyzer-null-dereference
d77de738
ML
10874This warning requires @option{-fanalyzer}, which enables it; use
10875@option{-Wno-analyzer-null-dereference} to disable it.
10876
10877This diagnostic warns for paths through the code in which a
10878value known to be NULL is dereferenced.
10879
10880See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10881
d77de738
ML
10882@opindex Wanalyzer-putenv-of-auto-var
10883@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10884@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10885This warning requires @option{-fanalyzer}, which enables it; use
10886@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10887
10888This diagnostic warns for paths through the code in which a
10889call to @code{putenv} is passed a pointer to an automatic variable
10890or an on-stack buffer.
10891
10892See @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}.
10893
d77de738
ML
10894@opindex Wanalyzer-shift-count-negative
10895@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10896@item -Wno-analyzer-shift-count-negative
d77de738
ML
10897This warning requires @option{-fanalyzer}, which enables it; use
10898@option{-Wno-analyzer-shift-count-negative} to disable it.
10899
10900This diagnostic warns for paths through the code in which a
10901shift is attempted with a negative count. It is analogous to
10902the @option{-Wshift-count-negative} diagnostic implemented in
10903the C/C++ front ends, but is implemented based on analyzing
10904interprocedural paths, rather than merely parsing the syntax tree.
10905However, the analyzer does not prioritize detection of such paths, so
10906false negatives are more likely relative to other warnings.
10907
d77de738
ML
10908@opindex Wanalyzer-shift-count-overflow
10909@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10910@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10911This warning requires @option{-fanalyzer}, which enables it; use
10912@option{-Wno-analyzer-shift-count-overflow} to disable it.
10913
10914This diagnostic warns for paths through the code in which a
10915shift is attempted with a count greater than or equal to the
10916precision of the operand's type. It is analogous to
10917the @option{-Wshift-count-overflow} diagnostic implemented in
10918the C/C++ front ends, but is implemented based on analyzing
10919interprocedural paths, rather than merely parsing the syntax tree.
10920However, the analyzer does not prioritize detection of such paths, so
10921false negatives are more likely relative to other warnings.
10922
d77de738
ML
10923@opindex Wanalyzer-stale-setjmp-buffer
10924@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10925@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10926This warning requires @option{-fanalyzer}, which enables it; use
10927@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10928
10929This diagnostic warns for paths through the code in which
10930@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10931to a @code{setjmp} call in a function that has returned.
10932
10933When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10934location, it records the stack frame. The stack frame becomes invalid
10935when the function containing the @code{setjmp} call returns. Attempting
10936to rewind to it via @code{longjmp} would reference a stack frame that
10937no longer exists, and likely lead to a crash (or worse).
10938
d77de738
ML
10939@opindex Wanalyzer-tainted-allocation-size
10940@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10941@item -Wno-analyzer-tainted-allocation-size
cfaaa8b1 10942This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
10943use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10944
10945This diagnostic warns for paths through the code in which a value
10946that could be under an attacker's control is used as the size
10947of an allocation without being sanitized, so that an attacker could
10948inject an excessively large allocation and potentially cause a denial
10949of service attack.
10950
10951See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10952
ce51e843
ML
10953@opindex Wanalyzer-tainted-assertion
10954@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10955@item -Wno-analyzer-tainted-assertion
ce51e843 10956
cfaaa8b1 10957This warning requires @option{-fanalyzer} which enables it;
ce51e843
ML
10958use @option{-Wno-analyzer-tainted-assertion} to disable it.
10959
10960This diagnostic warns for paths through the code in which a value
10961that could be under an attacker's control is used as part of a
10962condition without being first sanitized, and that condition guards a
10963call to a function marked with attribute @code{noreturn}
10964(such as the function @code{__builtin_unreachable}). Such functions
10965typically indicate abnormal termination of the program, such as for
10966assertion failure handlers. For example:
10967
10968@smallexample
10969assert (some_tainted_value < SOME_LIMIT);
10970@end smallexample
10971
10972In such cases:
10973
10974@itemize
10975@item
10976when assertion-checking is enabled: an attacker could trigger
10977a denial of service by injecting an assertion failure
10978
10979@item
10980when assertion-checking is disabled, such as by defining @code{NDEBUG},
10981an attacker could inject data that subverts the process, since it
10982presumably violates a precondition that is being assumed by the code.
10983
10984@end itemize
10985
10986Note that when assertion-checking is disabled, the assertions are
10987typically removed by the preprocessor before the analyzer has a chance
10988to "see" them, so this diagnostic can only generate warnings on builds
10989in which assertion-checking is enabled.
10990
10991For the purpose of this warning, any function marked with attribute
10992@code{noreturn} is considered as a possible assertion failure
10993handler, including @code{__builtin_unreachable}. Note that these functions
10994are sometimes removed by the optimizer before the analyzer "sees" them.
10995Hence optimization should be disabled when attempting to trigger this
10996diagnostic.
10997
10998See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10999
11000The warning can also report problematic constructions such as
11001
11002@smallexample
11003switch (some_tainted_value) @{
11004case 0:
11005 /* [...etc; various valid cases omitted...] */
11006 break;
11007
11008default:
11009 __builtin_unreachable (); /* BUG: attacker can trigger this */
11010@}
11011@end smallexample
11012
11013despite the above not being an assertion failure, strictly speaking.
11014
d77de738
ML
11015@opindex Wanalyzer-tainted-array-index
11016@opindex Wno-analyzer-tainted-array-index
ddf6fe37 11017@item -Wno-analyzer-tainted-array-index
cfaaa8b1 11018This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11019use @option{-Wno-analyzer-tainted-array-index} to disable it.
11020
11021This diagnostic warns for paths through the code in which a value
11022that could be under an attacker's control is used as the index
11023of an array access without being sanitized, so that an attacker
11024could inject an out-of-bounds access.
11025
11026See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11027
d77de738
ML
11028@opindex Wanalyzer-tainted-divisor
11029@opindex Wno-analyzer-tainted-divisor
ddf6fe37 11030@item -Wno-analyzer-tainted-divisor
cfaaa8b1 11031This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11032use @option{-Wno-analyzer-tainted-divisor} to disable it.
11033
11034This diagnostic warns for paths through the code in which a value
11035that could be under an attacker's control is used as the divisor
11036in a division or modulus operation without being sanitized, so that
11037an attacker could inject a division-by-zero.
11038
11039See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
11040
d77de738
ML
11041@opindex Wanalyzer-tainted-offset
11042@opindex Wno-analyzer-tainted-offset
ddf6fe37 11043@item -Wno-analyzer-tainted-offset
cfaaa8b1 11044This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11045use @option{-Wno-analyzer-tainted-offset} to disable it.
11046
11047This diagnostic warns for paths through the code in which a value
11048that could be under an attacker's control is used as a pointer offset
11049without being sanitized, so that an attacker could inject an out-of-bounds
11050access.
11051
11052See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
11053
d77de738
ML
11054@opindex Wanalyzer-tainted-size
11055@opindex Wno-analyzer-tainted-size
ddf6fe37 11056@item -Wno-analyzer-tainted-size
cfaaa8b1 11057This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11058use @option{-Wno-analyzer-tainted-size} to disable it.
11059
11060This diagnostic warns for paths through the code in which a value
11061that could be under an attacker's control is used as the size of
11062an operation such as @code{memset} without being sanitized, so that an
11063attacker could inject an out-of-bounds access.
11064
11065See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11066
f65f63c4
DM
11067@opindex Wanalyzer-undefined-behavior-strtok
11068@opindex Wno-analyzer-undefined-behavior-strtok
11069@item -Wno-analyzer-undefined-behavior-strtok
11070This warning requires @option{-fanalyzer}, which enables it; use
11071@option{-Wno-analyzer-undefined-behavior-strtok} to disable it.
11072
11073This diagnostic warns for paths through the code in which a
11074call is made to @code{strtok} with undefined behavior.
11075
11076Specifically, passing NULL as the first parameter for the initial
11077call to @code{strtok} within a process has undefined behavior.
11078
d77de738
ML
11079@opindex Wanalyzer-unsafe-call-within-signal-handler
11080@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 11081@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
11082This warning requires @option{-fanalyzer}, which enables it; use
11083@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11084
11085This diagnostic warns for paths through the code in which a
11086function known to be async-signal-unsafe (such as @code{fprintf}) is
11087called from a signal handler.
11088
11089See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11090
d77de738
ML
11091@opindex Wanalyzer-use-after-free
11092@opindex Wno-analyzer-use-after-free
ddf6fe37 11093@item -Wno-analyzer-use-after-free
d77de738
ML
11094This warning requires @option{-fanalyzer}, which enables it; use
11095@option{-Wno-analyzer-use-after-free} to disable it.
11096
11097This diagnostic warns for paths through the code in which a
11098pointer is used after a deallocator is called on it: either @code{free},
11099or a deallocator referenced by attribute @code{malloc}.
11100
11101See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11102
d77de738
ML
11103@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11104@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 11105@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
11106This warning requires @option{-fanalyzer}, which enables it; use
11107@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11108to disable it.
11109
11110This diagnostic warns for paths through the code in which a pointer
11111is dereferenced that points to a variable in a stale stack frame.
11112
d77de738
ML
11113@opindex Wanalyzer-va-arg-type-mismatch
11114@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 11115@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
11116This warning requires @option{-fanalyzer}, which enables it; use
11117@option{-Wno-analyzer-va-arg-type-mismatch}
11118to disable it.
11119
11120This diagnostic warns for interprocedural paths through the code for which
11121the analyzer detects an attempt to use @code{va_arg} to extract a value
11122passed to a variadic call, but uses a type that does not match that of
11123the expression passed to the call.
11124
11125See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11126
d77de738
ML
11127@opindex Wanalyzer-va-list-exhausted
11128@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 11129@item -Wno-analyzer-va-list-exhausted
d77de738
ML
11130This warning requires @option{-fanalyzer}, which enables it; use
11131@option{-Wno-analyzer-va-list-exhausted}
11132to disable it.
11133
11134This diagnostic warns for interprocedural paths through the code for which
11135the analyzer detects an attempt to use @code{va_arg} to access the next
11136value passed to a variadic call, but all of the values in the
11137@code{va_list} have already been consumed.
11138
11139See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11140
d77de738
ML
11141@opindex Wanalyzer-va-list-leak
11142@opindex Wno-analyzer-va-list-leak
ddf6fe37 11143@item -Wno-analyzer-va-list-leak
d77de738
ML
11144This warning requires @option{-fanalyzer}, which enables it; use
11145@option{-Wno-analyzer-va-list-leak}
11146to disable it.
11147
11148This diagnostic warns for interprocedural paths through the code for which
11149the analyzer detects that @code{va_start} or @code{va_copy} has been called
11150on a @code{va_list} without a corresponding call to @code{va_end}.
11151
d77de738
ML
11152@opindex Wanalyzer-va-list-use-after-va-end
11153@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 11154@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
11155This warning requires @option{-fanalyzer}, which enables it; use
11156@option{-Wno-analyzer-va-list-use-after-va-end}
11157to disable it.
11158
11159This diagnostic warns for interprocedural paths through the code for which
11160the analyzer detects an attempt to use a @code{va_list} after
11161@code{va_end} has been called on it.
11162@code{va_list}.
11163
d77de738
ML
11164@opindex Wanalyzer-write-to-const
11165@opindex Wno-analyzer-write-to-const
ddf6fe37 11166@item -Wno-analyzer-write-to-const
d77de738
ML
11167This warning requires @option{-fanalyzer}, which enables it; use
11168@option{-Wno-analyzer-write-to-const}
11169to disable it.
11170
11171This diagnostic warns for paths through the code in which the analyzer
11172detects an attempt to write through a pointer to a @code{const} object.
11173However, the analyzer does not prioritize detection of such paths, so
11174false negatives are more likely relative to other warnings.
11175
d77de738
ML
11176@opindex Wanalyzer-write-to-string-literal
11177@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 11178@item -Wno-analyzer-write-to-string-literal
d77de738
ML
11179This warning requires @option{-fanalyzer}, which enables it; use
11180@option{-Wno-analyzer-write-to-string-literal}
11181to disable it.
11182
11183This diagnostic warns for paths through the code in which the analyzer
11184detects an attempt to write through a pointer to a string literal.
11185However, the analyzer does not prioritize detection of such paths, so
11186false negatives are more likely relative to other warnings.
11187
d77de738
ML
11188@opindex Wanalyzer-use-of-uninitialized-value
11189@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 11190@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
11191This warning requires @option{-fanalyzer}, which enables it; use
11192@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11193
11194This diagnostic warns for paths through the code in which an uninitialized
11195value is used.
11196
11197See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11198
11199@end table
11200
11201The analyzer has hardcoded knowledge about the behavior of the following
11202memory-management functions:
11203
11204@itemize @bullet
11205@item @code{alloca}
11206@item The built-in functions @code{__builtin_alloc},
11207@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11208@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11209@code{__builtin_memcpy_chk}, @code{__builtin_memset},
11210@code{__builtin_memset_chk}, @code{__builtin_realloc},
11211@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11212@item @code{calloc}
11213@item @code{free}
11214@item @code{malloc}
11215@item @code{memset}
11216@item @code{operator delete}
11217@item @code{operator delete []}
11218@item @code{operator new}
11219@item @code{operator new []}
11220@item @code{realloc}
11221@item @code{strdup}
11222@item @code{strndup}
11223@end itemize
11224
4ace81b6 11225@noindent
d77de738
ML
11226of the following functions for working with file descriptors:
11227
11228@itemize @bullet
11229@item @code{open}
11230@item @code{close}
11231@item @code{creat}
11232@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 11233@item @code{isatty}
d77de738
ML
11234@item @code{pipe}, and @code{pipe2}
11235@item @code{read}
11236@item @code{write}
86a90006 11237@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
11238@end itemize
11239
4ace81b6 11240@noindent
d77de738
ML
11241of the following functions for working with @code{<stdio.h>} streams:
11242@itemize @bullet
11243@item The built-in functions @code{__builtin_fprintf},
11244@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11245@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11246@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11247@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11248@code{__builtin_printf_unlocked}, @code{__builtin_putc},
11249@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11250@code{__builtin_putc_unlocked}, @code{__builtin_puts},
11251@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
11252@code{__builtin_vprintf}
11253@item @code{fopen}
11254@item @code{fclose}
78a17f44 11255@item @code{ferror}
d77de738
ML
11256@item @code{fgets}
11257@item @code{fgets_unlocked}
78a17f44 11258@item @code{fileno}
d77de738 11259@item @code{fread}
78a17f44 11260@item @code{getc}
d77de738
ML
11261@item @code{getchar}
11262@item @code{fprintf}
11263@item @code{printf}
11264@item @code{fwrite}
11265@end itemize
11266
4ace81b6 11267@noindent
d77de738
ML
11268and of the following functions:
11269
11270@itemize @bullet
11271@item The built-in functions @code{__builtin_expect},
11272@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11273@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11274@code{__builtin_strlen}, @code{__builtin_va_copy}, and
11275@code{__builtin_va_start}
11276@item The GNU extensions @code{error} and @code{error_at_line}
11277@item @code{getpass}
11278@item @code{longjmp}
11279@item @code{putenv}
11280@item @code{setjmp}
11281@item @code{siglongjmp}
11282@item @code{signal}
11283@item @code{sigsetjmp}
bbdc0e0d 11284@item @code{strcat}
d77de738
ML
11285@item @code{strchr}
11286@item @code{strlen}
11287@end itemize
11288
11289In addition, various functions with an @code{__analyzer_} prefix have
11290special meaning to the analyzer, described in the GCC Internals manual.
11291
11292Pertinent parameters for controlling the exploration are:
4ace81b6
SL
11293@itemize @bullet
11294@item @option{--param analyzer-bb-explosion-factor=@var{value}}
11295@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11296@item @option{--param analyzer-max-recursion-depth=@var{value}}
11297@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11298@end itemize
d77de738
ML
11299
11300The following options control the analyzer.
11301
11302@table @gcctabopt
11303
d77de738
ML
11304@opindex fanalyzer-call-summaries
11305@opindex fno-analyzer-call-summaries
ddf6fe37 11306@item -fanalyzer-call-summaries
d77de738
ML
11307Simplify interprocedural analysis by computing the effect of certain calls,
11308rather than exploring all paths through the function from callsite to each
11309possible return.
11310
11311If enabled, call summaries are only used for functions with more than one
11312call site, and that are sufficiently complicated (as per
11313@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11314
d77de738 11315@opindex fanalyzer-checker
ddf6fe37 11316@item -fanalyzer-checker=@var{name}
d77de738
ML
11317Restrict the analyzer to run just the named checker, and enable it.
11318
0e466e97
DM
11319@opindex fanalyzer-debug-text-art
11320@opindex fno-analyzer-debug-text-art
11321@item -fanalyzer-debug-text-art-headings
11322This option is intended for analyzer developers. If enabled,
11323the analyzer will add extra annotations to any diagrams it generates.
11324
d77de738
ML
11325@opindex fanalyzer-feasibility
11326@opindex fno-analyzer-feasibility
ddf6fe37 11327@item -fno-analyzer-feasibility
d77de738
ML
11328This option is intended for analyzer developers.
11329
11330By default the analyzer verifies that there is a feasible control flow path
11331for each diagnostic it emits: that the conditions that hold are not mutually
11332exclusive. Diagnostics for which no feasible path can be found are rejected.
11333This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11334debugging issues in this code.
11335
d77de738
ML
11336@opindex fanalyzer-fine-grained
11337@opindex fno-analyzer-fine-grained
ddf6fe37 11338@item -fanalyzer-fine-grained
d77de738
ML
11339This option is intended for analyzer developers.
11340
11341Internally the analyzer builds an ``exploded graph'' that combines
11342control flow graphs with data flow information.
11343
11344By default, an edge in this graph can contain the effects of a run
11345of multiple statements within a basic block. With
11346@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11347
d77de738
ML
11348@opindex fanalyzer-show-duplicate-count
11349@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11350@item -fanalyzer-show-duplicate-count
d77de738
ML
11351This option is intended for analyzer developers: if multiple diagnostics
11352have been detected as being duplicates of each other, it emits a note when
11353reporting the best diagnostic, giving the number of additional diagnostics
11354that were suppressed by the deduplication logic.
11355
ce8cdf5b 11356@opindex fanalyzer-show-events-in-system-headers
11357@opindex fno-analyzer-show-events-in-system-headers
11358@item -fanalyzer-show-events-in-system-headers
11359By default the analyzer emits simplified diagnostics paths by hiding
11360events fully located within a system header.
11361With @option{-fanalyzer-show-events-in-system-headers} such
11362events are no longer suppressed.
11363
d77de738
ML
11364@opindex fanalyzer-state-merge
11365@opindex fno-analyzer-state-merge
ddf6fe37 11366@item -fno-analyzer-state-merge
d77de738
ML
11367This option is intended for analyzer developers.
11368
11369By default the analyzer attempts to simplify analysis by merging
11370sufficiently similar states at each program point as it builds its
11371``exploded graph''. With @option{-fno-analyzer-state-merge} this
11372merging can be suppressed, for debugging state-handling issues.
11373
d77de738
ML
11374@opindex fanalyzer-state-purge
11375@opindex fno-analyzer-state-purge
ddf6fe37 11376@item -fno-analyzer-state-purge
d77de738
ML
11377This option is intended for analyzer developers.
11378
11379By default the analyzer attempts to simplify analysis by purging
11380aspects of state at a program point that appear to no longer be relevant
11381e.g. the values of locals that aren't accessed later in the function
11382and which aren't relevant to leak analysis.
11383
11384With @option{-fno-analyzer-state-purge} this purging of state can
11385be suppressed, for debugging state-handling issues.
11386
8f636915
DM
11387@opindex fanalyzer-suppress-followups
11388@opindex fno-analyzer-suppress-followups
f33d7a88 11389@item -fno-analyzer-suppress-followups
8f636915
DM
11390This option is intended for analyzer developers.
11391
11392By default the analyzer will stop exploring an execution path after
11393encountering certain diagnostics, in order to avoid potentially issuing a
11394cascade of follow-up diagnostics.
11395
11396The diagnostics that terminate analysis along a path are:
11397
11398@itemize
11399@item @option{-Wanalyzer-null-argument}
11400@item @option{-Wanalyzer-null-dereference}
11401@item @option{-Wanalyzer-use-after-free}
11402@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11403@item @option{-Wanalyzer-use-of-uninitialized-value}
11404@end itemize
11405
11406With @option{-fno-analyzer-suppress-followups} the analyzer will
11407continue to explore such paths even after such diagnostics, which may
11408be helpful for debugging issues in the analyzer, or for microbenchmarks
11409for detecting undefined behavior.
11410
d77de738
ML
11411@opindex fanalyzer-transitivity
11412@opindex fno-analyzer-transitivity
ddf6fe37 11413@item -fanalyzer-transitivity
d77de738
ML
11414This option enables transitivity of constraints within the analyzer.
11415
d77de738
ML
11416@opindex fanalyzer-undo-inlining
11417@opindex fno-analyzer-undo-inlining
ddf6fe37 11418@item -fno-analyzer-undo-inlining
d77de738
ML
11419This option is intended for analyzer developers.
11420
11421@option{-fanalyzer} runs relatively late compared to other code analysis
11422tools, and some optimizations have already been applied to the code. In
11423particular function inlining may have occurred, leading to the
11424interprocedural execution paths emitted by the analyzer containing
11425function frames that don't correspond to those in the original source
11426code.
11427
11428By default the analyzer attempts to reconstruct the original function
11429frames, and to emit events showing the inlined calls.
11430
11431With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11432the original frame information can be be disabled, which may be of help
11433when debugging issues in the analyzer.
11434
11435@item -fanalyzer-verbose-edges
11436This option is intended for analyzer developers. It enables more
11437verbose, lower-level detail in the descriptions of control flow
11438within diagnostic paths.
11439
11440@item -fanalyzer-verbose-state-changes
11441This option is intended for analyzer developers. It enables more
11442verbose, lower-level detail in the descriptions of events relating
11443to state machines within diagnostic paths.
11444
11445@item -fanalyzer-verbosity=@var{level}
11446This option controls the complexity of the control flow paths that are
11447emitted for analyzer diagnostics.
11448
11449The @var{level} can be one of:
11450
11451@table @samp
11452@item 0
11453At this level, interprocedural call and return events are displayed,
11454along with the most pertinent state-change events relating to
11455a diagnostic. For example, for a double-@code{free} diagnostic,
11456both calls to @code{free} will be shown.
11457
11458@item 1
11459As per the previous level, but also show events for the entry
11460to each function.
11461
11462@item 2
11463As per the previous level, but also show events relating to
11464control flow that are significant to triggering the issue
11465(e.g. ``true path taken'' at a conditional).
11466
11467This level is the default.
11468
11469@item 3
11470As per the previous level, but show all control flow events, not
11471just significant ones.
11472
11473@item 4
11474This level is intended for analyzer developers; it adds various
11475other events intended for debugging the analyzer.
11476
11477@end table
11478
d77de738 11479@opindex fdump-analyzer
ddf6fe37 11480@item -fdump-analyzer
d77de738
ML
11481Dump internal details about what the analyzer is doing to
11482@file{@var{file}.analyzer.txt}.
4ace81b6 11483@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11484
d77de738 11485@opindex fdump-analyzer-stderr
ddf6fe37 11486@item -fdump-analyzer-stderr
d77de738
ML
11487Dump internal details about what the analyzer is doing to stderr.
11488This option overrides @option{-fdump-analyzer}.
11489
d77de738 11490@opindex fdump-analyzer-callgraph
ddf6fe37 11491@item -fdump-analyzer-callgraph
d77de738
ML
11492Dump a representation of the call graph suitable for viewing with
11493GraphViz to @file{@var{file}.callgraph.dot}.
11494
d77de738 11495@opindex fdump-analyzer-exploded-graph
ddf6fe37 11496@item -fdump-analyzer-exploded-graph
d77de738
ML
11497Dump a representation of the ``exploded graph'' suitable for viewing with
11498GraphViz to @file{@var{file}.eg.dot}.
11499Nodes are color-coded based on state-machine states to emphasize
11500state changes.
11501
d77de738 11502@opindex dump-analyzer-exploded-nodes
ddf6fe37 11503@item -fdump-analyzer-exploded-nodes
d77de738
ML
11504Emit diagnostics showing where nodes in the ``exploded graph'' are
11505in relation to the program source.
11506
d77de738 11507@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11508@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11509Dump a textual representation of the ``exploded graph'' to
11510@file{@var{file}.eg.txt}.
11511
d77de738 11512@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11513@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11514Dump a textual representation of the ``exploded graph'' to
11515one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11516This is typically a large number of dump files.
11517
d77de738 11518@opindex fdump-analyzer-exploded-paths
ddf6fe37 11519@item -fdump-analyzer-exploded-paths
d77de738
ML
11520Dump a textual representation of the ``exploded path'' for each
11521diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11522
d77de738 11523@opindex dump-analyzer-feasibility
ddf6fe37 11524@item -fdump-analyzer-feasibility
d77de738
ML
11525Dump internal details about the analyzer's search for feasible paths.
11526The details are written in a form suitable for viewing with GraphViz
11527to filenames of the form @file{@var{file}.*.fg.dot},
11528@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11529
841008d3
DM
11530@opindex dump-analyzer-infinite-loop
11531@item -fdump-analyzer-infinite-loop
11532Dump internal details about the analyzer's search for infinite loops.
11533The details are written in a form suitable for viewing with GraphViz
11534to filenames of the form @file{@var{file}.*.infinite-loop.dot}.
11535
d77de738 11536@opindex fdump-analyzer-json
ddf6fe37 11537@item -fdump-analyzer-json
d77de738
ML
11538Dump a compressed JSON representation of analyzer internals to
11539@file{@var{file}.analyzer.json.gz}. The precise format is subject
11540to change.
11541
d77de738 11542@opindex fdump-analyzer-state-purge
ddf6fe37 11543@item -fdump-analyzer-state-purge
d77de738
ML
11544As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11545``supergraph'' suitable for viewing with GraphViz, but annotate the
11546graph with information on what state will be purged at each node.
11547The graph is written to @file{@var{file}.state-purge.dot}.
11548
d77de738 11549@opindex fdump-analyzer-supergraph
ddf6fe37 11550@item -fdump-analyzer-supergraph
d77de738
ML
11551Dump representations of the ``supergraph'' suitable for viewing with
11552GraphViz to @file{@var{file}.supergraph.dot} and to
11553@file{@var{file}.supergraph-eg.dot}. These show all of the
11554control flow graphs in the program, with interprocedural edges for
11555calls and returns. The second dump contains annotations showing nodes
11556in the ``exploded graph'' and diagnostics associated with them.
11557
d77de738 11558@opindex fdump-analyzer-untracked
ddf6fe37 11559@item -fdump-analyzer-untracked
d77de738
ML
11560Emit custom warnings with internal details intended for analyzer developers.
11561
11562@end table
11563
11564@node Debugging Options
11565@section Options for Debugging Your Program
11566@cindex options, debugging
11567@cindex debugging information options
11568
11569To tell GCC to emit extra information for use by a debugger, in almost
11570all cases you need only to add @option{-g} to your other options. Some debug
11571formats can co-exist (like DWARF with CTF) when each of them is enabled
11572explicitly by adding the respective command line option to your other options.
11573
11574GCC allows you to use @option{-g} with
11575@option{-O}. The shortcuts taken by optimized code may occasionally
11576be surprising: some variables you declared may not exist
11577at all; flow of control may briefly move where you did not expect it;
11578some statements may not be executed because they compute constant
11579results or their values are already at hand; some statements may
11580execute in different places because they have been moved out of loops.
11581Nevertheless it is possible to debug optimized output. This makes
11582it reasonable to use the optimizer for programs that might have bugs.
11583
11584If you are not using some other optimization option, consider
11585using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11586With no @option{-O} option at all, some compiler passes that collect
11587information useful for debugging do not run at all, so that
11588@option{-Og} may result in a better debugging experience.
11589
11590@table @gcctabopt
d77de738 11591@opindex g
ddf6fe37 11592@item -g
d77de738
ML
11593Produce debugging information in the operating system's native format
11594(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11595information.
11596
11597On most systems that use stabs format, @option{-g} enables use of extra
11598debugging information that only GDB can use; this extra information
11599makes debugging work better in GDB but probably makes other debuggers
11600crash or refuse to read the program. If you want to control for certain whether
11601to generate the extra information, use @option{-gvms} (see below).
11602
d77de738 11603@opindex ggdb
ddf6fe37 11604@item -ggdb
d77de738
ML
11605Produce debugging information for use by GDB@. This means to use the
11606most expressive format available (DWARF, stabs, or the native format
11607if neither of those are supported), including GDB extensions if at all
11608possible.
11609
ddf6fe37 11610@opindex gdwarf
d77de738
ML
11611@item -gdwarf
11612@itemx -gdwarf-@var{version}
d77de738
ML
11613Produce debugging information in DWARF format (if that is supported).
11614The value of @var{version} may be either 2, 3, 4 or 5; the default
11615version for most targets is 5 (with the exception of VxWorks, TPF and
a335cf24 11616Darwin / macOS, which default to version 2, and AIX, which defaults
d77de738
ML
11617to version 4).
11618
11619Note that with DWARF Version 2, some ports require and always
11620use some non-conflicting DWARF 3 extensions in the unwind tables.
11621
11622Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11623for maximum benefit. Version 5 requires GDB 8.0 or higher.
11624
11625GCC no longer supports DWARF Version 1, which is substantially
11626different than Version 2 and later. For historical reasons, some
11627other DWARF-related options such as
11628@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11629in their names, but apply to all currently-supported versions of DWARF.
11630
d77de738 11631@opindex gbtf
ddf6fe37 11632@item -gbtf
d77de738
ML
11633Request BTF debug information. BTF is the default debugging format for the
11634eBPF target. On other targets, like x86, BTF debug information can be
11635generated along with DWARF debug information when both of the debug formats are
11636enabled explicitly via their respective command line options.
11637
ddf6fe37 11638@opindex gctf
d77de738
ML
11639@item -gctf
11640@itemx -gctf@var{level}
d77de738
ML
11641Request CTF debug information and use level to specify how much CTF debug
11642information should be produced. If @option{-gctf} is specified
11643without a value for level, the default level of CTF debug information is 2.
11644
11645CTF debug information can be generated along with DWARF debug information when
11646both of the debug formats are enabled explicitly via their respective command
11647line options.
11648
11649Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11650negates @option{-gctf}.
11651
11652Level 1 produces CTF information for tracebacks only. This includes callsite
11653information, but does not include type information.
11654
11655Level 2 produces type information for entities (functions, data objects etc.)
11656at file-scope or global-scope only.
11657
d77de738 11658@opindex gvms
ddf6fe37 11659@item -gvms
d77de738
ML
11660Produce debugging information in Alpha/VMS debug format (if that is
11661supported). This is the format used by DEBUG on Alpha/VMS systems.
11662
2f7e7bfa
MH
11663@item -gcodeview
11664@opindex gcodeview
11665Produce debugging information in CodeView debug format (if that is
11666supported). This is the format used by Microsoft Visual C++ on
11667Windows.
11668
d77de738
ML
11669@item -g@var{level}
11670@itemx -ggdb@var{level}
11671@itemx -gvms@var{level}
11672Request debugging information and also use @var{level} to specify how
11673much information. The default level is 2.
11674
11675Level 0 produces no debug information at all. Thus, @option{-g0} negates
11676@option{-g}.
11677
11678Level 1 produces minimal information, enough for making backtraces in
11679parts of the program that you don't plan to debug. This includes
11680descriptions of functions and external variables, and line number
11681tables, but no information about local variables.
11682
11683Level 3 includes extra information, such as all the macro definitions
11684present in the program. Some debuggers support macro expansion when
11685you use @option{-g3}.
11686
11687If you use multiple @option{-g} options, with or without level numbers,
11688the last such option is the one that is effective.
11689
11690@option{-gdwarf} does not accept a concatenated debug level, to avoid
11691confusion with @option{-gdwarf-@var{level}}.
11692Instead use an additional @option{-g@var{level}} option to change the
11693debug level for DWARF.
11694
d77de738
ML
11695@opindex feliminate-unused-debug-symbols
11696@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11697@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11698By default, no debug information is produced for symbols that are not actually
11699used. Use this option if you want debug information for all symbols.
11700
d77de738 11701@opindex femit-class-debug-always
ddf6fe37 11702@item -femit-class-debug-always
d77de738
ML
11703Instead of emitting debugging information for a C++ class in only one
11704object file, emit it in all object files using the class. This option
11705should be used only with debuggers that are unable to handle the way GCC
11706normally emits debugging information for classes because using this
11707option increases the size of debugging information by as much as a
11708factor of two.
11709
d77de738
ML
11710@opindex fmerge-debug-strings
11711@opindex fno-merge-debug-strings
ddf6fe37 11712@item -fno-merge-debug-strings
d77de738
ML
11713Direct the linker to not merge together strings in the debugging
11714information that are identical in different object files. Merging is
11715not supported by all assemblers or linkers. Merging decreases the size
11716of the debug information in the output file at the cost of increasing
11717link processing time. Merging is enabled by default.
11718
d77de738 11719@opindex fdebug-prefix-map
ddf6fe37 11720@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11721When compiling files residing in directory @file{@var{old}}, record
11722debugging information describing them as if the files resided in
11723directory @file{@var{new}} instead. This can be used to replace a
11724build-time path with an install-time path in the debug info. It can
11725also be used to change an absolute path to a relative path by using
11726@file{.} for @var{new}. This can give more reproducible builds, which
11727are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11728where to find the source files. See also @option{-ffile-prefix-map}
11729and @option{-fcanon-prefix-map}.
d77de738 11730
d77de738 11731@opindex fvar-tracking
ddf6fe37 11732@item -fvar-tracking
d77de738
ML
11733Run variable tracking pass. It computes where variables are stored at each
11734position in code. Better debugging information is then generated
11735(if the debugging information format supports this information).
11736
11737It is enabled by default when compiling with optimization (@option{-Os},
11738@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11739the debug info format supports it.
11740
d77de738
ML
11741@opindex fvar-tracking-assignments
11742@opindex fno-var-tracking-assignments
ddf6fe37 11743@item -fvar-tracking-assignments
d77de738
ML
11744Annotate assignments to user variables early in the compilation and
11745attempt to carry the annotations over throughout the compilation all the
11746way to the end, in an attempt to improve debug information while
11747optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11748
11749It can be enabled even if var-tracking is disabled, in which case
11750annotations are created and maintained, but discarded at the end.
11751By default, this flag is enabled together with @option{-fvar-tracking},
11752except when selective scheduling is enabled.
11753
d77de738 11754@opindex gsplit-dwarf
ddf6fe37 11755@item -gsplit-dwarf
d77de738
ML
11756If DWARF debugging information is enabled, separate as much debugging
11757information as possible into a separate output file with the extension
11758@file{.dwo}. This option allows the build system to avoid linking files with
11759debug information. To be useful, this option requires a debugger capable of
11760reading @file{.dwo} files.
11761
d77de738
ML
11762@opindex gdwarf32
11763@opindex gdwarf64
ddf6fe37
AA
11764@item -gdwarf32
11765@itemx -gdwarf64
d77de738
ML
11766If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11767the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11768DWARF format. The default is target specific, on most targets it is
11769@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11770can't support more than 2GiB of debug information in any of the DWARF
11771debug information sections. The 64-bit DWARF format allows larger debug
11772information and might not be well supported by all consumers yet.
11773
d77de738 11774@opindex gdescribe-dies
ddf6fe37 11775@item -gdescribe-dies
d77de738
ML
11776Add description attributes to some DWARF DIEs that have no name attribute,
11777such as artificial variables, external references and call site
11778parameter DIEs.
11779
d77de738 11780@opindex gpubnames
ddf6fe37 11781@item -gpubnames
d77de738
ML
11782Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11783
d77de738 11784@opindex ggnu-pubnames
ddf6fe37 11785@item -ggnu-pubnames
d77de738
ML
11786Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11787suitable for conversion into a GDB@ index. This option is only useful
11788with a linker that can produce GDB@ index version 7.
11789
d77de738
ML
11790@opindex fdebug-types-section
11791@opindex fno-debug-types-section
ddf6fe37 11792@item -fdebug-types-section
d77de738
ML
11793When using DWARF Version 4 or higher, type DIEs can be put into
11794their own @code{.debug_types} section instead of making them part of the
11795@code{.debug_info} section. It is more efficient to put them in a separate
11796comdat section since the linker can then remove duplicates.
11797But not all DWARF consumers support @code{.debug_types} sections yet
11798and on some objects @code{.debug_types} produces larger instead of smaller
11799debugging information.
11800
d77de738
ML
11801@opindex grecord-gcc-switches
11802@opindex gno-record-gcc-switches
ddf6fe37
AA
11803@item -grecord-gcc-switches
11804@itemx -gno-record-gcc-switches
d77de738
ML
11805This switch causes the command-line options used to invoke the
11806compiler that may affect code generation to be appended to the
11807DW_AT_producer attribute in DWARF debugging information. The options
11808are concatenated with spaces separating them from each other and from
11809the compiler version.
11810It is enabled by default.
11811See also @option{-frecord-gcc-switches} for another
11812way of storing compiler options into the object file.
11813
d77de738 11814@opindex gstrict-dwarf
ddf6fe37 11815@item -gstrict-dwarf
d77de738
ML
11816Disallow using extensions of later DWARF standard version than selected
11817with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11818DWARF extensions from later standard versions is allowed.
11819
d77de738 11820@opindex gno-strict-dwarf
ddf6fe37 11821@item -gno-strict-dwarf
d77de738
ML
11822Allow using extensions of later DWARF standard version than selected with
11823@option{-gdwarf-@var{version}}.
11824
d77de738 11825@opindex gas-loc-support
ddf6fe37 11826@item -gas-loc-support
d77de738
ML
11827Inform the compiler that the assembler supports @code{.loc} directives.
11828It may then use them for the assembler to generate DWARF2+ line number
11829tables.
11830
11831This is generally desirable, because assembler-generated line-number
11832tables are a lot more compact than those the compiler can generate
11833itself.
11834
11835This option will be enabled by default if, at GCC configure time, the
11836assembler was found to support such directives.
11837
d77de738 11838@opindex gno-as-loc-support
ddf6fe37 11839@item -gno-as-loc-support
d77de738
ML
11840Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11841line number tables are to be generated.
11842
d77de738 11843@opindex gas-locview-support
ddf6fe37 11844@item -gas-locview-support
d77de738
ML
11845Inform the compiler that the assembler supports @code{view} assignment
11846and reset assertion checking in @code{.loc} directives.
11847
11848This option will be enabled by default if, at GCC configure time, the
11849assembler was found to support them.
11850
11851@item -gno-as-locview-support
11852Force GCC to assign view numbers internally, if
11853@option{-gvariable-location-views} are explicitly requested.
11854
d77de738
ML
11855@opindex gcolumn-info
11856@opindex gno-column-info
ddf6fe37
AA
11857@item -gcolumn-info
11858@itemx -gno-column-info
d77de738
ML
11859Emit location column information into DWARF debugging information, rather
11860than just file and line.
11861This option is enabled by default.
11862
d77de738
ML
11863@opindex gstatement-frontiers
11864@opindex gno-statement-frontiers
ddf6fe37
AA
11865@item -gstatement-frontiers
11866@itemx -gno-statement-frontiers
d77de738
ML
11867This option causes GCC to create markers in the internal representation
11868at the beginning of statements, and to keep them roughly in place
11869throughout compilation, using them to guide the output of @code{is_stmt}
11870markers in the line number table. This is enabled by default when
11871compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11872@dots{}), and outputting DWARF 2 debug information at the normal level.
11873
d77de738
ML
11874@opindex gvariable-location-views
11875@opindex gvariable-location-views=incompat5
11876@opindex gno-variable-location-views
ddf6fe37
AA
11877@item -gvariable-location-views
11878@itemx -gvariable-location-views=incompat5
11879@itemx -gno-variable-location-views
d77de738
ML
11880Augment variable location lists with progressive view numbers implied
11881from the line number table. This enables debug information consumers to
11882inspect state at certain points of the program, even if no instructions
11883associated with the corresponding source locations are present at that
11884point. If the assembler lacks support for view numbers in line number
11885tables, this will cause the compiler to emit the line number table,
11886which generally makes them somewhat less compact. The augmented line
11887number tables and location lists are fully backward-compatible, so they
11888can be consumed by debug information consumers that are not aware of
11889these augmentations, but they won't derive any benefit from them either.
11890
11891This is enabled by default when outputting DWARF 2 debug information at
11892the normal level, as long as there is assembler support,
11893@option{-fvar-tracking-assignments} is enabled and
11894@option{-gstrict-dwarf} is not. When assembler support is not
11895available, this may still be enabled, but it will force GCC to output
11896internal line number tables, and if
11897@option{-ginternal-reset-location-views} is not enabled, that will most
11898certainly lead to silently mismatching location views.
11899
11900There is a proposed representation for view numbers that is not backward
11901compatible with the location list format introduced in DWARF 5, that can
11902be enabled with @option{-gvariable-location-views=incompat5}. This
11903option may be removed in the future, is only provided as a reference
11904implementation of the proposed representation. Debug information
11905consumers are not expected to support this extended format, and they
11906would be rendered unable to decode location lists using it.
11907
d77de738
ML
11908@opindex ginternal-reset-location-views
11909@opindex gno-internal-reset-location-views
ddf6fe37
AA
11910@item -ginternal-reset-location-views
11911@itemx -gno-internal-reset-location-views
d77de738
ML
11912Attempt to determine location views that can be omitted from location
11913view lists. This requires the compiler to have very accurate insn
11914length estimates, which isn't always the case, and it may cause
11915incorrect view lists to be generated silently when using an assembler
11916that does not support location view lists. The GNU assembler will flag
11917any such error as a @code{view number mismatch}. This is only enabled
11918on ports that define a reliable estimation function.
11919
d77de738
ML
11920@opindex ginline-points
11921@opindex gno-inline-points
ddf6fe37
AA
11922@item -ginline-points
11923@itemx -gno-inline-points
d77de738
ML
11924Generate extended debug information for inlined functions. Location
11925view tracking markers are inserted at inlined entry points, so that
11926address and view numbers can be computed and output in debug
11927information. This can be enabled independently of location views, in
11928which case the view numbers won't be output, but it can only be enabled
11929along with statement frontiers, and it is only enabled by default if
11930location views are enabled.
11931
d77de738 11932@opindex gz
ddf6fe37 11933@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11934Produce compressed debug sections in DWARF format, if that is supported.
11935If @var{type} is not given, the default type depends on the capabilities
11936of the assembler and linker used. @var{type} may be one of
11937@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11938compression in ELF gABI format). If the linker doesn't support writing
11939compressed debug sections, the option is rejected. Otherwise, if the
11940assembler does not support them, @option{-gz} is silently ignored when
11941producing object files.
11942
d77de738 11943@opindex femit-struct-debug-baseonly
ddf6fe37 11944@item -femit-struct-debug-baseonly
d77de738
ML
11945Emit debug information for struct-like types
11946only when the base name of the compilation source file
11947matches the base name of file in which the struct is defined.
11948
11949This option substantially reduces the size of debugging information,
11950but at significant potential loss in type information to the debugger.
11951See @option{-femit-struct-debug-reduced} for a less aggressive option.
11952See @option{-femit-struct-debug-detailed} for more detailed control.
11953
11954This option works only with DWARF debug output.
11955
d77de738 11956@opindex femit-struct-debug-reduced
ddf6fe37 11957@item -femit-struct-debug-reduced
d77de738
ML
11958Emit debug information for struct-like types
11959only when the base name of the compilation source file
11960matches the base name of file in which the type is defined,
11961unless the struct is a template or defined in a system header.
11962
11963This option significantly reduces the size of debugging information,
11964with some potential loss in type information to the debugger.
11965See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11966See @option{-femit-struct-debug-detailed} for more detailed control.
11967
11968This option works only with DWARF debug output.
11969
d77de738 11970@opindex femit-struct-debug-detailed
ddf6fe37 11971@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11972Specify the struct-like types
11973for which the compiler generates debug information.
11974The intent is to reduce duplicate struct debug information
11975between different object files within the same program.
11976
11977This option is a detailed version of
11978@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11979which serves for most needs.
11980
11981A specification has the syntax@*
11982[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11983
11984The optional first word limits the specification to
11985structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11986A struct type is used directly when it is the type of a variable, member.
11987Indirect uses arise through pointers to structs.
11988That is, when use of an incomplete struct is valid, the use is indirect.
11989An example is
11990@samp{struct one direct; struct two * indirect;}.
11991
11992The optional second word limits the specification to
11993ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11994Generic structs are a bit complicated to explain.
11995For C++, these are non-explicit specializations of template classes,
11996or non-template classes within the above.
11997Other programming languages have generics,
11998but @option{-femit-struct-debug-detailed} does not yet implement them.
11999
12000The third word specifies the source files for those
12001structs for which the compiler should emit debug information.
12002The values @samp{none} and @samp{any} have the normal meaning.
12003The value @samp{base} means that
12004the base of name of the file in which the type declaration appears
12005must match the base of the name of the main compilation file.
12006In practice, this means that when compiling @file{foo.c}, debug information
12007is generated for types declared in that file and @file{foo.h},
12008but not other header files.
12009The value @samp{sys} means those types satisfying @samp{base}
12010or declared in system or compiler headers.
12011
12012You may need to experiment to determine the best settings for your application.
12013
12014The default is @option{-femit-struct-debug-detailed=all}.
12015
12016This option works only with DWARF debug output.
12017
d77de738
ML
12018@opindex fdwarf2-cfi-asm
12019@opindex fno-dwarf2-cfi-asm
ddf6fe37 12020@item -fno-dwarf2-cfi-asm
d77de738
ML
12021Emit DWARF unwind info as compiler generated @code{.eh_frame} section
12022instead of using GAS @code{.cfi_*} directives.
12023
d77de738
ML
12024@opindex feliminate-unused-debug-types
12025@opindex fno-eliminate-unused-debug-types
ddf6fe37 12026@item -fno-eliminate-unused-debug-types
d77de738
ML
12027Normally, when producing DWARF output, GCC avoids producing debug symbol
12028output for types that are nowhere used in the source file being compiled.
12029Sometimes it is useful to have GCC emit debugging
12030information for all types declared in a compilation
12031unit, regardless of whether or not they are actually used
12032in that compilation unit, for example
12033if, in the debugger, you want to cast a value to a type that is
12034not actually used in your program (but is declared). More often,
12035however, this results in a significant amount of wasted space.
12036@end table
12037
12038@node Optimize Options
12039@section Options That Control Optimization
12040@cindex optimize options
12041@cindex options, optimization
12042
12043These options control various sorts of optimizations.
12044
12045Without any optimization option, the compiler's goal is to reduce the
12046cost of compilation and to make debugging produce the expected
12047results. Statements are independent: if you stop the program with a
12048breakpoint between statements, you can then assign a new value to any
12049variable or change the program counter to any other statement in the
12050function and get exactly the results you expect from the source
12051code.
12052
12053Turning on optimization flags makes the compiler attempt to improve
12054the performance and/or code size at the expense of compilation time
12055and possibly the ability to debug the program.
12056
12057The compiler performs optimization based on the knowledge it has of the
12058program. Compiling multiple files at once to a single output file mode allows
12059the compiler to use information gained from all of the files when compiling
12060each of them.
12061
12062Not all optimizations are controlled directly by a flag. Only
12063optimizations that have a flag are listed in this section.
12064
12065Most optimizations are completely disabled at @option{-O0} or if an
12066@option{-O} level is not set on the command line, even if individual
12067optimization flags are specified. Similarly, @option{-Og} suppresses
12068many optimization passes.
12069
12070Depending on the target and how GCC was configured, a slightly different
12071set of optimizations may be enabled at each @option{-O} level than
12072those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12073to find out the exact set of optimizations that are enabled at each level.
12074@xref{Overall Options}, for examples.
12075
12076@table @gcctabopt
d77de738
ML
12077@opindex O
12078@opindex O1
ddf6fe37
AA
12079@item -O
12080@itemx -O1
d77de738
ML
12081Optimize. Optimizing compilation takes somewhat more time, and a lot
12082more memory for a large function.
12083
12084With @option{-O}, the compiler tries to reduce code size and execution
12085time, without performing any optimizations that take a great deal of
12086compilation time.
12087
12088@c Note that in addition to the default_options_table list in opts.cc,
12089@c several optimization flags default to true but control optimization
12090@c passes that are explicitly disabled at -O0.
12091
12092@option{-O} turns on the following optimization flags:
12093
12094@c Please keep the following list alphabetized.
43b72ede
AA
12095@gccoptlist{-fauto-inc-dec
12096-fbranch-count-reg
12097-fcombine-stack-adjustments
12098-fcompare-elim
12099-fcprop-registers
12100-fdce
12101-fdefer-pop
12102-fdelayed-branch
12103-fdse
12104-fforward-propagate
12105-fguess-branch-probability
12106-fif-conversion
12107-fif-conversion2
12108-finline-functions-called-once
12109-fipa-modref
12110-fipa-profile
12111-fipa-pure-const
12112-fipa-reference
12113-fipa-reference-addressable
12114-fmerge-constants
12115-fmove-loop-invariants
12116-fmove-loop-stores
12117-fomit-frame-pointer
12118-freorder-blocks
12119-fshrink-wrap
12120-fshrink-wrap-separate
12121-fsplit-wide-types
12122-fssa-backprop
12123-fssa-phiopt
12124-ftree-bit-ccp
12125-ftree-ccp
12126-ftree-ch
12127-ftree-coalesce-vars
12128-ftree-copy-prop
12129-ftree-dce
12130-ftree-dominator-opts
12131-ftree-dse
12132-ftree-forwprop
12133-ftree-fre
12134-ftree-phiprop
12135-ftree-pta
12136-ftree-scev-cprop
12137-ftree-sink
12138-ftree-slsr
12139-ftree-sra
12140-ftree-ter
d77de738
ML
12141-funit-at-a-time}
12142
d77de738 12143@opindex O2
ddf6fe37 12144@item -O2
d77de738
ML
12145Optimize even more. GCC performs nearly all supported optimizations
12146that do not involve a space-speed tradeoff.
12147As compared to @option{-O}, this option increases both compilation time
12148and the performance of the generated code.
12149
12150@option{-O2} turns on all optimization flags specified by @option{-O1}. It
12151also turns on the following optimization flags:
12152
12153@c Please keep the following list alphabetized!
43b72ede
AA
12154@gccoptlist{-falign-functions -falign-jumps
12155-falign-labels -falign-loops
12156-fcaller-saves
12157-fcode-hoisting
12158-fcrossjumping
12159-fcse-follow-jumps -fcse-skip-blocks
12160-fdelete-null-pointer-checks
12161-fdevirtualize -fdevirtualize-speculatively
12162-fexpensive-optimizations
12163-ffinite-loops
12164-fgcse -fgcse-lm
12165-fhoist-adjacent-loads
12166-finline-functions
12167-finline-small-functions
12168-findirect-inlining
12169-fipa-bit-cp -fipa-cp -fipa-icf
12170-fipa-ra -fipa-sra -fipa-vrp
12171-fisolate-erroneous-paths-dereference
12172-flra-remat
12173-foptimize-sibling-calls
12174-foptimize-strlen
12175-fpartial-inlining
12176-fpeephole2
12177-freorder-blocks-algorithm=stc
12178-freorder-blocks-and-partition -freorder-functions
12179-frerun-cse-after-loop
12180-fschedule-insns -fschedule-insns2
12181-fsched-interblock -fsched-spec
12182-fstore-merging
12183-fstrict-aliasing
12184-fthread-jumps
12185-ftree-builtin-call-dce
12186-ftree-loop-vectorize
12187-ftree-pre
12188-ftree-slp-vectorize
12189-ftree-switch-conversion -ftree-tail-merge
12190-ftree-vrp
d77de738
ML
12191-fvect-cost-model=very-cheap}
12192
12193Please note the warning under @option{-fgcse} about
12194invoking @option{-O2} on programs that use computed gotos.
12195
d77de738 12196@opindex O3
ddf6fe37 12197@item -O3
d77de738
ML
12198Optimize yet more. @option{-O3} turns on all optimizations specified
12199by @option{-O2} and also turns on the following optimization flags:
12200
12201@c Please keep the following list alphabetized!
43b72ede 12202@gccoptlist{-fgcse-after-reload
d77de738 12203-fipa-cp-clone
43b72ede
AA
12204-floop-interchange
12205-floop-unroll-and-jam
12206-fpeel-loops
12207-fpredictive-commoning
12208-fsplit-loops
12209-fsplit-paths
12210-ftree-loop-distribution
12211-ftree-partial-pre
12212-funswitch-loops
12213-fvect-cost-model=dynamic
d77de738
ML
12214-fversion-loops-for-strides}
12215
d77de738 12216@opindex O0
ddf6fe37 12217@item -O0
d77de738
ML
12218Reduce compilation time and make debugging produce the expected
12219results. This is the default.
12220
d77de738 12221@opindex Os
ddf6fe37 12222@item -Os
d77de738
ML
12223Optimize for size. @option{-Os} enables all @option{-O2} optimizations
12224except those that often increase code size:
12225
43b72ede
AA
12226@gccoptlist{-falign-functions -falign-jumps
12227-falign-labels -falign-loops
d77de738
ML
12228-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
12229
12230It also enables @option{-finline-functions}, causes the compiler to tune for
12231code size rather than execution speed, and performs further optimizations
12232designed to reduce code size.
12233
d77de738 12234@opindex Ofast
ddf6fe37 12235@item -Ofast
d77de738
ML
12236Disregard strict standards compliance. @option{-Ofast} enables all
12237@option{-O3} optimizations. It also enables optimizations that are not
12238valid for all standard-compliant programs.
12239It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
12240and the Fortran-specific @option{-fstack-arrays}, unless
12241@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
12242It turns off @option{-fsemantic-interposition}.
12243
d77de738 12244@opindex Og
ddf6fe37 12245@item -Og
d77de738
ML
12246Optimize debugging experience. @option{-Og} should be the optimization
12247level of choice for the standard edit-compile-debug cycle, offering
12248a reasonable level of optimization while maintaining fast compilation
12249and a good debugging experience. It is a better choice than @option{-O0}
12250for producing debuggable code because some compiler passes
12251that collect debug information are disabled at @option{-O0}.
12252
12253Like @option{-O0}, @option{-Og} completely disables a number of
12254optimization passes so that individual options controlling them have
12255no effect. Otherwise @option{-Og} enables all @option{-O1}
12256optimization flags except for those that may interfere with debugging:
12257
43b72ede
AA
12258@gccoptlist{-fbranch-count-reg -fdelayed-branch
12259-fdse -fif-conversion -fif-conversion2
12260-finline-functions-called-once
12261-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
12262-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12263
d77de738 12264@opindex Oz
ddf6fe37 12265@item -Oz
d77de738
ML
12266Optimize aggressively for size rather than speed. This may increase
12267the number of instructions executed if those instructions require
12268fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12269including enabling most @option{-O2} optimizations.
12270
12271@end table
12272
12273If you use multiple @option{-O} options, with or without level numbers,
12274the last such option is the one that is effective.
12275
12276Options of the form @option{-f@var{flag}} specify machine-independent
12277flags. Most flags have both positive and negative forms; the negative
12278form of @option{-ffoo} is @option{-fno-foo}. In the table
12279below, only one of the forms is listed---the one you typically
12280use. You can figure out the other form by either removing @samp{no-}
12281or adding it.
12282
12283The following options control specific optimizations. They are either
12284activated by @option{-O} options or are related to ones that are. You
12285can use the following flags in the rare cases when ``fine-tuning'' of
12286optimizations to be performed is desired.
12287
12288@table @gcctabopt
d77de738
ML
12289@opindex fno-defer-pop
12290@opindex fdefer-pop
ddf6fe37 12291@item -fno-defer-pop
d77de738
ML
12292For machines that must pop arguments after a function call, always pop
12293the arguments as soon as each function returns.
12294At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12295this allows the compiler to let arguments accumulate on the stack for several
12296function calls and pop them all at once.
12297
d77de738 12298@opindex fforward-propagate
ddf6fe37 12299@item -fforward-propagate
d77de738
ML
12300Perform a forward propagation pass on RTL@. The pass tries to combine two
12301instructions and checks if the result can be simplified. If loop unrolling
12302is active, two passes are performed and the second is scheduled after
12303loop unrolling.
12304
12305This option is enabled by default at optimization levels @option{-O1},
12306@option{-O2}, @option{-O3}, @option{-Os}.
12307
d77de738 12308@opindex ffp-contract
ddf6fe37 12309@item -ffp-contract=@var{style}
d77de738
ML
12310@option{-ffp-contract=off} disables floating-point expression contraction.
12311@option{-ffp-contract=fast} enables floating-point expression contraction
12312such as forming of fused multiply-add operations if the target has
12313native support for them.
12314@option{-ffp-contract=on} enables floating-point expression contraction
1c1dd396
AM
12315if allowed by the language standard. This is implemented for C and C++,
12316where it enables contraction within one expression, but not across
12317different statements.
d77de738 12318
1c1dd396
AM
12319The default is @option{-ffp-contract=off} for C in a standards compliant mode
12320(@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
d77de738 12321
d77de738 12322@opindex fomit-frame-pointer
ddf6fe37 12323@item -fomit-frame-pointer
d77de738
ML
12324Omit the frame pointer in functions that don't need one. This avoids the
12325instructions to save, set up and restore the frame pointer; on many targets
12326it also makes an extra register available.
12327
12328On some targets this flag has no effect because the standard calling sequence
12329always uses a frame pointer, so it cannot be omitted.
12330
12331Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12332is used in all functions. Several targets always omit the frame pointer in
12333leaf functions.
12334
12335Enabled by default at @option{-O1} and higher.
12336
d77de738 12337@opindex foptimize-sibling-calls
ddf6fe37 12338@item -foptimize-sibling-calls
d77de738
ML
12339Optimize sibling and tail recursive calls.
12340
12341Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12342
d77de738 12343@opindex foptimize-strlen
ddf6fe37 12344@item -foptimize-strlen
d77de738
ML
12345Optimize various standard C string functions (e.g.@: @code{strlen},
12346@code{strchr} or @code{strcpy}) and
12347their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12348
12349Enabled at levels @option{-O2}, @option{-O3}.
12350
d77de738
ML
12351@opindex fno-inline
12352@opindex finline
ddf6fe37 12353@item -fno-inline
d77de738
ML
12354Do not expand any functions inline apart from those marked with
12355the @code{always_inline} attribute. This is the default when not
12356optimizing.
12357
12358Single functions can be exempted from inlining by marking them
12359with the @code{noinline} attribute.
12360
d77de738 12361@opindex finline-small-functions
ddf6fe37 12362@item -finline-small-functions
d77de738
ML
12363Integrate functions into their callers when their body is smaller than expected
12364function call code (so overall size of program gets smaller). The compiler
12365heuristically decides which functions are simple enough to be worth integrating
12366in this way. This inlining applies to all functions, even those not declared
12367inline.
12368
12369Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12370
d77de738 12371@opindex findirect-inlining
ddf6fe37 12372@item -findirect-inlining
d77de738
ML
12373Inline also indirect calls that are discovered to be known at compile
12374time thanks to previous inlining. This option has any effect only
12375when inlining itself is turned on by the @option{-finline-functions}
12376or @option{-finline-small-functions} options.
12377
12378Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12379
d77de738 12380@opindex finline-functions
ddf6fe37 12381@item -finline-functions
d77de738
ML
12382Consider all functions for inlining, even if they are not declared inline.
12383The compiler heuristically decides which functions are worth integrating
12384in this way.
12385
12386If all calls to a given function are integrated, and the function is
12387declared @code{static}, then the function is normally not output as
12388assembler code in its own right.
12389
12390Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12391by @option{-fprofile-use} and @option{-fauto-profile}.
12392
d77de738 12393@opindex finline-functions-called-once
ddf6fe37 12394@item -finline-functions-called-once
d77de738
ML
12395Consider all @code{static} functions called once for inlining into their
12396caller even if they are not marked @code{inline}. If a call to a given
12397function is integrated, then the function is not output as assembler code
12398in its own right.
12399
12400Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12401but not @option{-Og}.
12402
d77de738 12403@opindex fearly-inlining
ddf6fe37 12404@item -fearly-inlining
d77de738
ML
12405Inline functions marked by @code{always_inline} and functions whose body seems
12406smaller than the function call overhead early before doing
12407@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12408makes profiling significantly cheaper and usually inlining faster on programs
12409having large chains of nested wrapper functions.
12410
12411Enabled by default.
12412
d77de738 12413@opindex fipa-sra
ddf6fe37 12414@item -fipa-sra
d77de738
ML
12415Perform interprocedural scalar replacement of aggregates, removal of
12416unused parameters and replacement of parameters passed by reference
12417by parameters passed by value.
12418
12419Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12420
d77de738 12421@opindex finline-limit
ddf6fe37 12422@item -finline-limit=@var{n}
d77de738
ML
12423By default, GCC limits the size of functions that can be inlined. This flag
12424allows coarse control of this limit. @var{n} is the size of functions that
12425can be inlined in number of pseudo instructions.
12426
12427Inlining is actually controlled by a number of parameters, which may be
12428specified individually by using @option{--param @var{name}=@var{value}}.
12429The @option{-finline-limit=@var{n}} option sets some of these parameters
12430as follows:
12431
12432@table @gcctabopt
12433@item max-inline-insns-single
12434is set to @var{n}/2.
12435@item max-inline-insns-auto
12436is set to @var{n}/2.
12437@end table
12438
12439See below for a documentation of the individual
12440parameters controlling inlining and for the defaults of these parameters.
12441
12442@emph{Note:} there may be no value to @option{-finline-limit} that results
12443in default behavior.
12444
12445@emph{Note:} pseudo instruction represents, in this particular context, an
12446abstract measurement of function's size. In no way does it represent a count
12447of assembly instructions and as such its exact meaning might change from one
12448release to an another.
12449
d77de738
ML
12450@opindex fno-keep-inline-dllexport
12451@opindex fkeep-inline-dllexport
ddf6fe37 12452@item -fno-keep-inline-dllexport
d77de738
ML
12453This is a more fine-grained version of @option{-fkeep-inline-functions},
12454which applies only to functions that are declared using the @code{dllexport}
12455attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12456Functions}.
12457
d77de738 12458@opindex fkeep-inline-functions
ddf6fe37 12459@item -fkeep-inline-functions
d77de738
ML
12460In C, emit @code{static} functions that are declared @code{inline}
12461into the object file, even if the function has been inlined into all
12462of its callers. This switch does not affect functions using the
12463@code{extern inline} extension in GNU C90@. In C++, emit any and all
12464inline functions into the object file.
12465
d77de738 12466@opindex fkeep-static-functions
ddf6fe37 12467@item -fkeep-static-functions
d77de738
ML
12468Emit @code{static} functions into the object file, even if the function
12469is never used.
12470
d77de738 12471@opindex fkeep-static-consts
ddf6fe37 12472@item -fkeep-static-consts
d77de738
ML
12473Emit variables declared @code{static const} when optimization isn't turned
12474on, even if the variables aren't referenced.
12475
12476GCC enables this option by default. If you want to force the compiler to
12477check if a variable is referenced, regardless of whether or not
12478optimization is turned on, use the @option{-fno-keep-static-consts} option.
12479
d77de738 12480@opindex fmerge-constants
ddf6fe37 12481@item -fmerge-constants
d77de738
ML
12482Attempt to merge identical constants (string constants and floating-point
12483constants) across compilation units.
12484
12485This option is the default for optimized compilation if the assembler and
12486linker support it. Use @option{-fno-merge-constants} to inhibit this
12487behavior.
12488
12489Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12490
d77de738 12491@opindex fmerge-all-constants
ddf6fe37 12492@item -fmerge-all-constants
d77de738
ML
12493Attempt to merge identical constants and identical variables.
12494
12495This option implies @option{-fmerge-constants}. In addition to
12496@option{-fmerge-constants} this considers e.g.@: even constant initialized
12497arrays or initialized constant variables with integral or floating-point
12498types. Languages like C or C++ require each variable, including multiple
12499instances of the same variable in recursive calls, to have distinct locations,
12500so using this option results in non-conforming
12501behavior.
12502
d77de738 12503@opindex fmodulo-sched
ddf6fe37 12504@item -fmodulo-sched
d77de738
ML
12505Perform swing modulo scheduling immediately before the first scheduling
12506pass. This pass looks at innermost loops and reorders their
12507instructions by overlapping different iterations.
12508
d77de738 12509@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12510@item -fmodulo-sched-allow-regmoves
d77de738
ML
12511Perform more aggressive SMS-based modulo scheduling with register moves
12512allowed. By setting this flag certain anti-dependences edges are
12513deleted, which triggers the generation of reg-moves based on the
12514life-range analysis. This option is effective only with
12515@option{-fmodulo-sched} enabled.
12516
d77de738
ML
12517@opindex fno-branch-count-reg
12518@opindex fbranch-count-reg
ddf6fe37 12519@item -fno-branch-count-reg
d77de738
ML
12520Disable the optimization pass that scans for opportunities to use
12521``decrement and branch'' instructions on a count register instead of
12522instruction sequences that decrement a register, compare it against zero, and
12523then branch based upon the result. This option is only meaningful on
12524architectures that support such instructions, which include x86, PowerPC,
12525IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12526doesn't remove the decrement and branch instructions from the generated
12527instruction stream introduced by other optimization passes.
12528
12529The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12530except for @option{-Og}.
12531
d77de738
ML
12532@opindex fno-function-cse
12533@opindex ffunction-cse
ddf6fe37 12534@item -fno-function-cse
d77de738
ML
12535Do not put function addresses in registers; make each instruction that
12536calls a constant function contain the function's address explicitly.
12537
12538This option results in less efficient code, but some strange hacks
12539that alter the assembler output may be confused by the optimizations
12540performed when this option is not used.
12541
12542The default is @option{-ffunction-cse}
12543
d77de738
ML
12544@opindex fno-zero-initialized-in-bss
12545@opindex fzero-initialized-in-bss
ddf6fe37 12546@item -fno-zero-initialized-in-bss
d77de738
ML
12547If the target supports a BSS section, GCC by default puts variables that
12548are initialized to zero into BSS@. This can save space in the resulting
12549code.
12550
12551This option turns off this behavior because some programs explicitly
12552rely on variables going to the data section---e.g., so that the
12553resulting executable can find the beginning of that section and/or make
12554assumptions based on that.
12555
12556The default is @option{-fzero-initialized-in-bss}.
12557
d77de738 12558@opindex fthread-jumps
ddf6fe37 12559@item -fthread-jumps
d77de738
ML
12560Perform optimizations that check to see if a jump branches to a
12561location where another comparison subsumed by the first is found. If
12562so, the first branch is redirected to either the destination of the
12563second branch or a point immediately following it, depending on whether
12564the condition is known to be true or false.
12565
12566Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12567
d77de738 12568@opindex fsplit-wide-types
ddf6fe37 12569@item -fsplit-wide-types
d77de738
ML
12570When using a type that occupies multiple registers, such as @code{long
12571long} on a 32-bit system, split the registers apart and allocate them
12572independently. This normally generates better code for those types,
12573but may make debugging more difficult.
12574
12575Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12576@option{-Os}.
12577
d77de738 12578@opindex fsplit-wide-types-early
ddf6fe37 12579@item -fsplit-wide-types-early
d77de738
ML
12580Fully split wide types early, instead of very late.
12581This option has no effect unless @option{-fsplit-wide-types} is turned on.
12582
12583This is the default on some targets.
12584
d77de738 12585@opindex fcse-follow-jumps
ddf6fe37 12586@item -fcse-follow-jumps
d77de738
ML
12587In common subexpression elimination (CSE), scan through jump instructions
12588when the target of the jump is not reached by any other path. For
12589example, when CSE encounters an @code{if} statement with an
12590@code{else} clause, CSE follows the jump when the condition
12591tested is false.
12592
12593Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12594
d77de738 12595@opindex fcse-skip-blocks
ddf6fe37 12596@item -fcse-skip-blocks
d77de738
ML
12597This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12598follow jumps that conditionally skip over blocks. When CSE
12599encounters a simple @code{if} statement with no else clause,
12600@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12601body of the @code{if}.
12602
12603Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12604
d77de738 12605@opindex frerun-cse-after-loop
ddf6fe37 12606@item -frerun-cse-after-loop
d77de738
ML
12607Re-run common subexpression elimination after loop optimizations are
12608performed.
12609
12610Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12611
d77de738 12612@opindex fgcse
ddf6fe37 12613@item -fgcse
d77de738
ML
12614Perform a global common subexpression elimination pass.
12615This pass also performs global constant and copy propagation.
12616
12617@emph{Note:} When compiling a program using computed gotos, a GCC
12618extension, you may get better run-time performance if you disable
12619the global common subexpression elimination pass by adding
12620@option{-fno-gcse} to the command line.
12621
12622Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12623
d77de738 12624@opindex fgcse-lm
ddf6fe37 12625@item -fgcse-lm
d77de738
ML
12626When @option{-fgcse-lm} is enabled, global common subexpression elimination
12627attempts to move loads that are only killed by stores into themselves. This
12628allows a loop containing a load/store sequence to be changed to a load outside
12629the loop, and a copy/store within the loop.
12630
12631Enabled by default when @option{-fgcse} is enabled.
12632
d77de738 12633@opindex fgcse-sm
ddf6fe37 12634@item -fgcse-sm
d77de738
ML
12635When @option{-fgcse-sm} is enabled, a store motion pass is run after
12636global common subexpression elimination. This pass attempts to move
12637stores out of loops. When used in conjunction with @option{-fgcse-lm},
12638loops containing a load/store sequence can be changed to a load before
12639the loop and a store after the loop.
12640
12641Not enabled at any optimization level.
12642
d77de738 12643@opindex fgcse-las
ddf6fe37 12644@item -fgcse-las
d77de738
ML
12645When @option{-fgcse-las} is enabled, the global common subexpression
12646elimination pass eliminates redundant loads that come after stores to the
12647same memory location (both partial and full redundancies).
12648
12649Not enabled at any optimization level.
12650
d77de738 12651@opindex fgcse-after-reload
ddf6fe37 12652@item -fgcse-after-reload
d77de738
ML
12653When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12654pass is performed after reload. The purpose of this pass is to clean up
12655redundant spilling.
12656
12657Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12658
d77de738 12659@opindex faggressive-loop-optimizations
ddf6fe37 12660@item -faggressive-loop-optimizations
d77de738
ML
12661This option tells the loop optimizer to use language constraints to
12662derive bounds for the number of iterations of a loop. This assumes that
12663loop code does not invoke undefined behavior by for example causing signed
12664integer overflows or out-of-bound array accesses. The bounds for the
12665number of iterations of a loop are used to guide loop unrolling and peeling
12666and loop exit test optimizations.
12667This option is enabled by default.
12668
d77de738 12669@opindex funconstrained-commons
ddf6fe37 12670@item -funconstrained-commons
d77de738
ML
12671This option tells the compiler that variables declared in common blocks
12672(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12673prevents certain optimizations that depend on knowing the array bounds.
12674
d77de738 12675@opindex fcrossjumping
ddf6fe37 12676@item -fcrossjumping
d77de738
ML
12677Perform cross-jumping transformation.
12678This transformation unifies equivalent code and saves code size. The
12679resulting code may or may not perform better than without cross-jumping.
12680
12681Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12682
d77de738 12683@opindex fauto-inc-dec
ddf6fe37 12684@item -fauto-inc-dec
d77de738
ML
12685Combine increments or decrements of addresses with memory accesses.
12686This pass is always skipped on architectures that do not have
12687instructions to support this. Enabled by default at @option{-O1} and
12688higher on architectures that support this.
12689
d77de738 12690@opindex fdce
ddf6fe37 12691@item -fdce
d77de738
ML
12692Perform dead code elimination (DCE) on RTL@.
12693Enabled by default at @option{-O1} and higher.
12694
d77de738 12695@opindex fdse
ddf6fe37 12696@item -fdse
d77de738
ML
12697Perform dead store elimination (DSE) on RTL@.
12698Enabled by default at @option{-O1} and higher.
12699
d77de738 12700@opindex fif-conversion
ddf6fe37 12701@item -fif-conversion
d77de738
ML
12702Attempt to transform conditional jumps into branch-less equivalents. This
12703includes use of conditional moves, min, max, set flags and abs instructions, and
12704some tricks doable by standard arithmetics. The use of conditional execution
12705on chips where it is available is controlled by @option{-fif-conversion2}.
12706
12707Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12708not with @option{-Og}.
12709
d77de738 12710@opindex fif-conversion2
ddf6fe37 12711@item -fif-conversion2
d77de738
ML
12712Use conditional execution (where available) to transform conditional jumps into
12713branch-less equivalents.
12714
12715Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12716not with @option{-Og}.
12717
d77de738 12718@opindex fdeclone-ctor-dtor
ddf6fe37 12719@item -fdeclone-ctor-dtor
d77de738
ML
12720The C++ ABI requires multiple entry points for constructors and
12721destructors: one for a base subobject, one for a complete object, and
12722one for a virtual destructor that calls operator delete afterwards.
12723For a hierarchy with virtual bases, the base and complete variants are
12724clones, which means two copies of the function. With this option, the
12725base and complete variants are changed to be thunks that call a common
12726implementation.
12727
12728Enabled by @option{-Os}.
12729
d77de738 12730@opindex fdelete-null-pointer-checks
ddf6fe37 12731@item -fdelete-null-pointer-checks
d77de738
ML
12732Assume that programs cannot safely dereference null pointers, and that
12733no code or data element resides at address zero.
12734This option enables simple constant
12735folding optimizations at all optimization levels. In addition, other
12736optimization passes in GCC use this flag to control global dataflow
12737analyses that eliminate useless checks for null pointers; these assume
12738that a memory access to address zero always results in a trap, so
12739that if a pointer is checked after it has already been dereferenced,
12740it cannot be null.
12741
12742Note however that in some environments this assumption is not true.
12743Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12744for programs that depend on that behavior.
12745
12746This option is enabled by default on most targets. On Nios II ELF, it
12747defaults to off. On AVR and MSP430, this option is completely disabled.
12748
12749Passes that use the dataflow information
12750are enabled independently at different optimization levels.
12751
d77de738 12752@opindex fdevirtualize
ddf6fe37 12753@item -fdevirtualize
d77de738
ML
12754Attempt to convert calls to virtual functions to direct calls. This
12755is done both within a procedure and interprocedurally as part of
12756indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12757propagation (@option{-fipa-cp}).
12758Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12759
d77de738 12760@opindex fdevirtualize-speculatively
ddf6fe37 12761@item -fdevirtualize-speculatively
d77de738
ML
12762Attempt to convert calls to virtual functions to speculative direct calls.
12763Based on the analysis of the type inheritance graph, determine for a given call
12764the set of likely targets. If the set is small, preferably of size 1, change
12765the call into a conditional deciding between direct and indirect calls. The
12766speculative calls enable more optimizations, such as inlining. When they seem
12767useless after further optimization, they are converted back into original form.
12768
d77de738 12769@opindex fdevirtualize-at-ltrans
ddf6fe37 12770@item -fdevirtualize-at-ltrans
d77de738
ML
12771Stream extra information needed for aggressive devirtualization when running
12772the link-time optimizer in local transformation mode.
12773This option enables more devirtualization but
12774significantly increases the size of streamed data. For this reason it is
12775disabled by default.
12776
d77de738 12777@opindex fexpensive-optimizations
ddf6fe37 12778@item -fexpensive-optimizations
d77de738
ML
12779Perform a number of minor optimizations that are relatively expensive.
12780
12781Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12782
d77de738 12783@opindex free
ddf6fe37 12784@item -free
d77de738
ML
12785Attempt to remove redundant extension instructions. This is especially
12786helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12787registers after writing to their lower 32-bit half.
12788
88ae53a3
LC
12789Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
12790levels @option{-O2}, @option{-O3}, @option{-Os}.
d77de738 12791
d77de738
ML
12792@opindex fno-lifetime-dse
12793@opindex flifetime-dse
ddf6fe37 12794@item -fno-lifetime-dse
d77de738
ML
12795In C++ the value of an object is only affected by changes within its
12796lifetime: when the constructor begins, the object has an indeterminate
12797value, and any changes during the lifetime of the object are dead when
12798the object is destroyed. Normally dead store elimination will take
12799advantage of this; if your code relies on the value of the object
12800storage persisting beyond the lifetime of the object, you can use this
12801flag to disable this optimization. To preserve stores before the
12802constructor starts (e.g.@: because your operator new clears the object
12803storage) but still treat the object as dead after the destructor, you
12804can use @option{-flifetime-dse=1}. The default behavior can be
12805explicitly selected with @option{-flifetime-dse=2}.
12806@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12807
d77de738 12808@opindex flive-range-shrinkage
ddf6fe37 12809@item -flive-range-shrinkage
d77de738
ML
12810Attempt to decrease register pressure through register live range
12811shrinkage. This is helpful for fast processors with small or moderate
12812size register sets.
12813
d77de738 12814@opindex fira-algorithm
ddf6fe37 12815@item -fira-algorithm=@var{algorithm}
d77de738
ML
12816Use the specified coloring algorithm for the integrated register
12817allocator. The @var{algorithm} argument can be @samp{priority}, which
12818specifies Chow's priority coloring, or @samp{CB}, which specifies
12819Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12820for all architectures, but for those targets that do support it, it is
12821the default because it generates better code.
12822
d77de738 12823@opindex fira-region
ddf6fe37 12824@item -fira-region=@var{region}
d77de738
ML
12825Use specified regions for the integrated register allocator. The
12826@var{region} argument should be one of the following:
12827
12828@table @samp
12829
12830@item all
12831Use all loops as register allocation regions.
12832This can give the best results for machines with a small and/or
12833irregular register set.
12834
12835@item mixed
12836Use all loops except for loops with small register pressure
12837as the regions. This value usually gives
12838the best results in most cases and for most architectures,
12839and is enabled by default when compiling with optimization for speed
12840(@option{-O}, @option{-O2}, @dots{}).
12841
12842@item one
12843Use all functions as a single region.
12844This typically results in the smallest code size, and is enabled by default for
12845@option{-Os} or @option{-O0}.
12846
12847@end table
12848
d77de738 12849@opindex fira-hoist-pressure
ddf6fe37 12850@item -fira-hoist-pressure
d77de738
ML
12851Use IRA to evaluate register pressure in the code hoisting pass for
12852decisions to hoist expressions. This option usually results in smaller
12853code, but it can slow the compiler down.
12854
12855This option is enabled at level @option{-Os} for all targets.
12856
d77de738 12857@opindex fira-loop-pressure
ddf6fe37 12858@item -fira-loop-pressure
d77de738
ML
12859Use IRA to evaluate register pressure in loops for decisions to move
12860loop invariants. This option usually results in generation
12861of faster and smaller code on machines with large register files (>= 32
12862registers), but it can slow the compiler down.
12863
12864This option is enabled at level @option{-O3} for some targets.
12865
d77de738
ML
12866@opindex fno-ira-share-save-slots
12867@opindex fira-share-save-slots
ddf6fe37 12868@item -fno-ira-share-save-slots
d77de738
ML
12869Disable sharing of stack slots used for saving call-used hard
12870registers living through a call. Each hard register gets a
12871separate stack slot, and as a result function stack frames are
12872larger.
12873
d77de738
ML
12874@opindex fno-ira-share-spill-slots
12875@opindex fira-share-spill-slots
ddf6fe37 12876@item -fno-ira-share-spill-slots
d77de738
ML
12877Disable sharing of stack slots allocated for pseudo-registers. Each
12878pseudo-register that does not get a hard register gets a separate
12879stack slot, and as a result function stack frames are larger.
12880
d77de738 12881@opindex flra-remat
ddf6fe37 12882@item -flra-remat
d77de738
ML
12883Enable CFG-sensitive rematerialization in LRA. Instead of loading
12884values of spilled pseudos, LRA tries to rematerialize (recalculate)
12885values if it is profitable.
12886
12887Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12888
d77de738 12889@opindex fdelayed-branch
ddf6fe37 12890@item -fdelayed-branch
d77de738
ML
12891If supported for the target machine, attempt to reorder instructions
12892to exploit instruction slots available after delayed branch
12893instructions.
12894
12895Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12896but not at @option{-Og}.
12897
d77de738 12898@opindex fschedule-insns
ddf6fe37 12899@item -fschedule-insns
d77de738
ML
12900If supported for the target machine, attempt to reorder instructions to
12901eliminate execution stalls due to required data being unavailable. This
12902helps machines that have slow floating point or memory load instructions
12903by allowing other instructions to be issued until the result of the load
12904or floating-point instruction is required.
12905
12906Enabled at levels @option{-O2}, @option{-O3}.
12907
d77de738 12908@opindex fschedule-insns2
ddf6fe37 12909@item -fschedule-insns2
d77de738
ML
12910Similar to @option{-fschedule-insns}, but requests an additional pass of
12911instruction scheduling after register allocation has been done. This is
12912especially useful on machines with a relatively small number of
12913registers and where memory load instructions take more than one cycle.
12914
12915Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12916
d77de738
ML
12917@opindex fno-sched-interblock
12918@opindex fsched-interblock
ddf6fe37 12919@item -fno-sched-interblock
d77de738
ML
12920Disable instruction scheduling across basic blocks, which
12921is normally enabled when scheduling before register allocation, i.e.@:
12922with @option{-fschedule-insns} or at @option{-O2} or higher.
12923
d77de738
ML
12924@opindex fno-sched-spec
12925@opindex fsched-spec
ddf6fe37 12926@item -fno-sched-spec
d77de738
ML
12927Disable speculative motion of non-load instructions, which
12928is normally enabled when scheduling before register allocation, i.e.@:
12929with @option{-fschedule-insns} or at @option{-O2} or higher.
12930
d77de738 12931@opindex fsched-pressure
ddf6fe37 12932@item -fsched-pressure
d77de738
ML
12933Enable register pressure sensitive insn scheduling before register
12934allocation. This only makes sense when scheduling before register
12935allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12936@option{-O2} or higher. Usage of this option can improve the
12937generated code and decrease its size by preventing register pressure
12938increase above the number of available hard registers and subsequent
12939spills in register allocation.
12940
d77de738 12941@opindex fsched-spec-load
ddf6fe37 12942@item -fsched-spec-load
d77de738
ML
12943Allow speculative motion of some load instructions. This only makes
12944sense when scheduling before register allocation, i.e.@: with
12945@option{-fschedule-insns} or at @option{-O2} or higher.
12946
d77de738 12947@opindex fsched-spec-load-dangerous
ddf6fe37 12948@item -fsched-spec-load-dangerous
d77de738
ML
12949Allow speculative motion of more load instructions. This only makes
12950sense when scheduling before register allocation, i.e.@: with
12951@option{-fschedule-insns} or at @option{-O2} or higher.
12952
ddf6fe37 12953@opindex fsched-stalled-insns
d77de738
ML
12954@item -fsched-stalled-insns
12955@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12956Define how many insns (if any) can be moved prematurely from the queue
12957of stalled insns into the ready list during the second scheduling pass.
12958@option{-fno-sched-stalled-insns} means that no insns are moved
12959prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12960on how many queued insns can be moved prematurely.
12961@option{-fsched-stalled-insns} without a value is equivalent to
12962@option{-fsched-stalled-insns=1}.
12963
ddf6fe37 12964@opindex fsched-stalled-insns-dep
d77de738
ML
12965@item -fsched-stalled-insns-dep
12966@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12967Define how many insn groups (cycles) are examined for a dependency
12968on a stalled insn that is a candidate for premature removal from the queue
12969of stalled insns. This has an effect only during the second scheduling pass,
12970and only if @option{-fsched-stalled-insns} is used.
12971@option{-fno-sched-stalled-insns-dep} is equivalent to
12972@option{-fsched-stalled-insns-dep=0}.
12973@option{-fsched-stalled-insns-dep} without a value is equivalent to
12974@option{-fsched-stalled-insns-dep=1}.
12975
d77de738 12976@opindex fsched2-use-superblocks
ddf6fe37 12977@item -fsched2-use-superblocks
d77de738
ML
12978When scheduling after register allocation, use superblock scheduling.
12979This allows motion across basic block boundaries,
12980resulting in faster schedules. This option is experimental, as not all machine
12981descriptions used by GCC model the CPU closely enough to avoid unreliable
12982results from the algorithm.
12983
12984This only makes sense when scheduling after register allocation, i.e.@: with
12985@option{-fschedule-insns2} or at @option{-O2} or higher.
12986
d77de738 12987@opindex fsched-group-heuristic
ddf6fe37 12988@item -fsched-group-heuristic
d77de738
ML
12989Enable the group heuristic in the scheduler. This heuristic favors
12990the instruction that belongs to a schedule group. This is enabled
12991by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12992or @option{-fschedule-insns2} or at @option{-O2} or higher.
12993
d77de738 12994@opindex fsched-critical-path-heuristic
ddf6fe37 12995@item -fsched-critical-path-heuristic
d77de738
ML
12996Enable the critical-path heuristic in the scheduler. This heuristic favors
12997instructions on the critical path. This is enabled by default when
12998scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12999or @option{-fschedule-insns2} or at @option{-O2} or higher.
13000
d77de738 13001@opindex fsched-spec-insn-heuristic
ddf6fe37 13002@item -fsched-spec-insn-heuristic
d77de738
ML
13003Enable the speculative instruction heuristic in the scheduler. This
13004heuristic favors speculative instructions with greater dependency weakness.
13005This is enabled by default when scheduling is enabled, i.e.@:
13006with @option{-fschedule-insns} or @option{-fschedule-insns2}
13007or at @option{-O2} or higher.
13008
d77de738 13009@opindex fsched-rank-heuristic
ddf6fe37 13010@item -fsched-rank-heuristic
d77de738
ML
13011Enable the rank heuristic in the scheduler. This heuristic favors
13012the instruction belonging to a basic block with greater size or frequency.
13013This is enabled by default when scheduling is enabled, i.e.@:
13014with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13015at @option{-O2} or higher.
13016
d77de738 13017@opindex fsched-last-insn-heuristic
ddf6fe37 13018@item -fsched-last-insn-heuristic
d77de738
ML
13019Enable the last-instruction heuristic in the scheduler. This heuristic
13020favors the instruction that is less dependent on the last instruction
13021scheduled. This is enabled by default when scheduling is enabled,
13022i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13023at @option{-O2} or higher.
13024
d77de738 13025@opindex fsched-dep-count-heuristic
ddf6fe37 13026@item -fsched-dep-count-heuristic
d77de738
ML
13027Enable the dependent-count heuristic in the scheduler. This heuristic
13028favors the instruction that has more instructions depending on it.
13029This is enabled by default when scheduling is enabled, i.e.@:
13030with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13031at @option{-O2} or higher.
13032
d77de738 13033@opindex freschedule-modulo-scheduled-loops
ddf6fe37 13034@item -freschedule-modulo-scheduled-loops
d77de738
ML
13035Modulo scheduling is performed before traditional scheduling. If a loop
13036is modulo scheduled, later scheduling passes may change its schedule.
13037Use this option to control that behavior.
13038
d77de738 13039@opindex fselective-scheduling
ddf6fe37 13040@item -fselective-scheduling
d77de738
ML
13041Schedule instructions using selective scheduling algorithm. Selective
13042scheduling runs instead of the first scheduler pass.
13043
d77de738 13044@opindex fselective-scheduling2
ddf6fe37 13045@item -fselective-scheduling2
d77de738
ML
13046Schedule instructions using selective scheduling algorithm. Selective
13047scheduling runs instead of the second scheduler pass.
13048
d77de738 13049@opindex fsel-sched-pipelining
ddf6fe37 13050@item -fsel-sched-pipelining
d77de738
ML
13051Enable software pipelining of innermost loops during selective scheduling.
13052This option has no effect unless one of @option{-fselective-scheduling} or
13053@option{-fselective-scheduling2} is turned on.
13054
d77de738 13055@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 13056@item -fsel-sched-pipelining-outer-loops
d77de738
ML
13057When pipelining loops during selective scheduling, also pipeline outer loops.
13058This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13059
d77de738 13060@opindex fsemantic-interposition
ddf6fe37 13061@item -fsemantic-interposition
d77de738
ML
13062Some object formats, like ELF, allow interposing of symbols by the
13063dynamic linker.
13064This means that for symbols exported from the DSO, the compiler cannot perform
13065interprocedural propagation, inlining and other optimizations in anticipation
13066that the function or variable in question may change. While this feature is
13067useful, for example, to rewrite memory allocation functions by a debugging
13068implementation, it is expensive in the terms of code quality.
13069With @option{-fno-semantic-interposition} the compiler assumes that
13070if interposition happens for functions the overwriting function will have
13071precisely the same semantics (and side effects).
13072Similarly if interposition happens
13073for variables, the constructor of the variable will be the same. The flag
13074has no effect for functions explicitly declared inline
13075(where it is never allowed for interposition to change semantics)
13076and for symbols explicitly declared weak.
13077
d77de738 13078@opindex fshrink-wrap
ddf6fe37 13079@item -fshrink-wrap
d77de738
ML
13080Emit function prologues only before parts of the function that need it,
13081rather than at the top of the function. This flag is enabled by default at
13082@option{-O} and higher.
13083
d77de738 13084@opindex fshrink-wrap-separate
ddf6fe37 13085@item -fshrink-wrap-separate
d77de738
ML
13086Shrink-wrap separate parts of the prologue and epilogue separately, so that
13087those parts are only executed when needed.
13088This option is on by default, but has no effect unless @option{-fshrink-wrap}
13089is also turned on and the target supports this.
13090
d77de738 13091@opindex fcaller-saves
ddf6fe37 13092@item -fcaller-saves
d77de738
ML
13093Enable allocation of values to registers that are clobbered by
13094function calls, by emitting extra instructions to save and restore the
13095registers around such calls. Such allocation is done only when it
13096seems to result in better code.
13097
13098This option is always enabled by default on certain machines, usually
13099those which have no call-preserved registers to use instead.
13100
13101Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13102
d77de738 13103@opindex fcombine-stack-adjustments
ddf6fe37 13104@item -fcombine-stack-adjustments
d77de738
ML
13105Tracks stack adjustments (pushes and pops) and stack memory references
13106and then tries to find ways to combine them.
13107
13108Enabled by default at @option{-O1} and higher.
13109
d77de738 13110@opindex fipa-ra
ddf6fe37 13111@item -fipa-ra
d77de738
ML
13112Use caller save registers for allocation if those registers are not used by
13113any called function. In that case it is not necessary to save and restore
13114them around calls. This is only possible if called functions are part of
13115same compilation unit as current function and they are compiled before it.
13116
13117Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13118is disabled if generated code will be instrumented for profiling
13119(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13120exactly (this happens on targets that do not expose prologues
13121and epilogues in RTL).
13122
d77de738 13123@opindex fconserve-stack
ddf6fe37 13124@item -fconserve-stack
d77de738
ML
13125Attempt to minimize stack usage. The compiler attempts to use less
13126stack space, even if that makes the program slower. This option
13127implies setting the @option{large-stack-frame} parameter to 100
13128and the @option{large-stack-frame-growth} parameter to 400.
13129
d77de738 13130@opindex ftree-reassoc
ddf6fe37 13131@item -ftree-reassoc
d77de738
ML
13132Perform reassociation on trees. This flag is enabled by default
13133at @option{-O1} and higher.
13134
d77de738 13135@opindex fcode-hoisting
ddf6fe37 13136@item -fcode-hoisting
d77de738
ML
13137Perform code hoisting. Code hoisting tries to move the
13138evaluation of expressions executed on all paths to the function exit
13139as early as possible. This is especially useful as a code size
13140optimization, but it often helps for code speed as well.
13141This flag is enabled by default at @option{-O2} and higher.
13142
d77de738 13143@opindex ftree-pre
ddf6fe37 13144@item -ftree-pre
d77de738
ML
13145Perform partial redundancy elimination (PRE) on trees. This flag is
13146enabled by default at @option{-O2} and @option{-O3}.
13147
d77de738 13148@opindex ftree-partial-pre
ddf6fe37 13149@item -ftree-partial-pre
d77de738
ML
13150Make partial redundancy elimination (PRE) more aggressive. This flag is
13151enabled by default at @option{-O3}.
13152
d77de738 13153@opindex ftree-forwprop
ddf6fe37 13154@item -ftree-forwprop
d77de738
ML
13155Perform forward propagation on trees. This flag is enabled by default
13156at @option{-O1} and higher.
13157
d77de738 13158@opindex ftree-fre
ddf6fe37 13159@item -ftree-fre
d77de738
ML
13160Perform full redundancy elimination (FRE) on trees. The difference
13161between FRE and PRE is that FRE only considers expressions
13162that are computed on all paths leading to the redundant computation.
13163This analysis is faster than PRE, though it exposes fewer redundancies.
13164This flag is enabled by default at @option{-O1} and higher.
13165
d77de738 13166@opindex ftree-phiprop
ddf6fe37 13167@item -ftree-phiprop
d77de738
ML
13168Perform hoisting of loads from conditional pointers on trees. This
13169pass is enabled by default at @option{-O1} and higher.
13170
d77de738 13171@opindex fhoist-adjacent-loads
ddf6fe37 13172@item -fhoist-adjacent-loads
d77de738
ML
13173Speculatively hoist loads from both branches of an if-then-else if the
13174loads are from adjacent locations in the same structure and the target
13175architecture has a conditional move instruction. This flag is enabled
13176by default at @option{-O2} and higher.
13177
d77de738 13178@opindex ftree-copy-prop
ddf6fe37 13179@item -ftree-copy-prop
d77de738
ML
13180Perform copy propagation on trees. This pass eliminates unnecessary
13181copy operations. This flag is enabled by default at @option{-O1} and
13182higher.
13183
d77de738 13184@opindex fipa-pure-const
ddf6fe37 13185@item -fipa-pure-const
d77de738
ML
13186Discover which functions are pure or constant.
13187Enabled by default at @option{-O1} and higher.
13188
d77de738 13189@opindex fipa-reference
ddf6fe37 13190@item -fipa-reference
d77de738
ML
13191Discover which static variables do not escape the
13192compilation unit.
13193Enabled by default at @option{-O1} and higher.
13194
d77de738 13195@opindex fipa-reference-addressable
ddf6fe37 13196@item -fipa-reference-addressable
d77de738
ML
13197Discover read-only, write-only and non-addressable static variables.
13198Enabled by default at @option{-O1} and higher.
13199
d77de738 13200@opindex fipa-stack-alignment
ddf6fe37 13201@item -fipa-stack-alignment
d77de738
ML
13202Reduce stack alignment on call sites if possible.
13203Enabled by default.
13204
d77de738 13205@opindex fipa-pta
ddf6fe37 13206@item -fipa-pta
d77de738
ML
13207Perform interprocedural pointer analysis and interprocedural modification
13208and reference analysis. This option can cause excessive memory and
13209compile-time usage on large compilation units. It is not enabled by
13210default at any optimization level.
13211
d77de738 13212@opindex fipa-profile
ddf6fe37 13213@item -fipa-profile
d77de738
ML
13214Perform interprocedural profile propagation. The functions called only from
13215cold functions are marked as cold. Also functions executed once (such as
13216@code{cold}, @code{noreturn}, static constructors or destructors) are
13217identified. Cold functions and loop less parts of functions executed once are
13218then optimized for size.
13219Enabled by default at @option{-O1} and higher.
13220
d77de738 13221@opindex fipa-modref
ddf6fe37 13222@item -fipa-modref
d77de738
ML
13223Perform interprocedural mod/ref analysis. This optimization analyzes the side
13224effects of functions (memory locations that are modified or referenced) and
13225enables better optimization across the function call boundary. This flag is
13226enabled by default at @option{-O1} and higher.
13227
d77de738 13228@opindex fipa-cp
ddf6fe37 13229@item -fipa-cp
d77de738
ML
13230Perform interprocedural constant propagation.
13231This optimization analyzes the program to determine when values passed
13232to functions are constants and then optimizes accordingly.
13233This optimization can substantially increase performance
13234if the application has constants passed to functions.
13235This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
13236It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13237
d77de738 13238@opindex fipa-cp-clone
ddf6fe37 13239@item -fipa-cp-clone
d77de738
ML
13240Perform function cloning to make interprocedural constant propagation stronger.
13241When enabled, interprocedural constant propagation performs function cloning
13242when externally visible function can be called with constant arguments.
13243Because this optimization can create multiple copies of functions,
13244it may significantly increase code size
13245(see @option{--param ipa-cp-unit-growth=@var{value}}).
13246This flag is enabled by default at @option{-O3}.
13247It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13248
d77de738 13249@opindex fipa-bit-cp
ddf6fe37 13250@item -fipa-bit-cp
d77de738
ML
13251When enabled, perform interprocedural bitwise constant
13252propagation. This flag is enabled by default at @option{-O2} and
13253by @option{-fprofile-use} and @option{-fauto-profile}.
13254It requires that @option{-fipa-cp} is enabled.
13255
d77de738 13256@opindex fipa-vrp
ddf6fe37 13257@item -fipa-vrp
d77de738
ML
13258When enabled, perform interprocedural propagation of value
13259ranges. This flag is enabled by default at @option{-O2}. It requires
13260that @option{-fipa-cp} is enabled.
13261
d77de738 13262@opindex fipa-icf
ddf6fe37 13263@item -fipa-icf
d77de738
ML
13264Perform Identical Code Folding for functions and read-only variables.
13265The optimization reduces code size and may disturb unwind stacks by replacing
13266a function by equivalent one with a different name. The optimization works
13267more effectively with link-time optimization enabled.
13268
13269Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13270works on different levels and thus the optimizations are not same - there are
13271equivalences that are found only by GCC and equivalences found only by Gold.
13272
13273This flag is enabled by default at @option{-O2} and @option{-Os}.
13274
d77de738 13275@opindex flive-patching
ddf6fe37 13276@item -flive-patching=@var{level}
d77de738
ML
13277Control GCC's optimizations to produce output suitable for live-patching.
13278
13279If the compiler's optimization uses a function's body or information extracted
13280from its body to optimize/change another function, the latter is called an
13281impacted function of the former. If a function is patched, its impacted
13282functions should be patched too.
13283
13284The impacted functions are determined by the compiler's interprocedural
13285optimizations. For example, a caller is impacted when inlining a function
13286into its caller,
13287cloning a function and changing its caller to call this new clone,
13288or extracting a function's pureness/constness information to optimize
13289its direct or indirect callers, etc.
13290
13291Usually, the more IPA optimizations enabled, the larger the number of
13292impacted functions for each function. In order to control the number of
13293impacted functions and more easily compute the list of impacted function,
13294IPA optimizations can be partially enabled at two different levels.
13295
13296The @var{level} argument should be one of the following:
13297
13298@table @samp
13299
13300@item inline-clone
13301
13302Only enable inlining and cloning optimizations, which includes inlining,
13303cloning, interprocedural scalar replacement of aggregates and partial inlining.
13304As a result, when patching a function, all its callers and its clones'
13305callers are impacted, therefore need to be patched as well.
13306
13307@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
13308@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13309-fipa-icf -fipa-icf-functions -fipa-icf-variables
13310-fipa-bit-cp -fipa-vrp -fipa-pure-const
13311-fipa-reference-addressable
d77de738
ML
13312-fipa-stack-alignment -fipa-modref}
13313
13314@item inline-only-static
13315
13316Only enable inlining of static functions.
13317As a result, when patching a static function, all its callers are impacted
13318and so need to be patched as well.
13319
13320In addition to all the flags that @option{-flive-patching=inline-clone}
13321disables,
13322@option{-flive-patching=inline-only-static} disables the following additional
13323optimization flags:
13324@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13325
13326@end table
13327
13328When @option{-flive-patching} is specified without any value, the default value
13329is @var{inline-clone}.
13330
13331This flag is disabled by default.
13332
13333Note that @option{-flive-patching} is not supported with link-time optimization
13334(@option{-flto}).
13335
d77de738 13336@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13337@item -fisolate-erroneous-paths-dereference
d77de738
ML
13338Detect paths that trigger erroneous or undefined behavior due to
13339dereferencing a null pointer. Isolate those paths from the main control
13340flow and turn the statement with erroneous or undefined behavior into a trap.
13341This flag is enabled by default at @option{-O2} and higher and depends on
13342@option{-fdelete-null-pointer-checks} also being enabled.
13343
d77de738 13344@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13345@item -fisolate-erroneous-paths-attribute
d77de738
ML
13346Detect paths that trigger erroneous or undefined behavior due to a null value
13347being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13348attribute. Isolate those paths from the main control flow and turn the
13349statement with erroneous or undefined behavior into a trap. This is not
13350currently enabled, but may be enabled by @option{-O2} in the future.
13351
d77de738 13352@opindex ftree-sink
ddf6fe37 13353@item -ftree-sink
d77de738
ML
13354Perform forward store motion on trees. This flag is
13355enabled by default at @option{-O1} and higher.
13356
d77de738 13357@opindex ftree-bit-ccp
ddf6fe37 13358@item -ftree-bit-ccp
d77de738
ML
13359Perform sparse conditional bit constant propagation on trees and propagate
13360pointer alignment information.
13361This pass only operates on local scalar variables and is enabled by default
13362at @option{-O1} and higher, except for @option{-Og}.
13363It requires that @option{-ftree-ccp} is enabled.
13364
d77de738 13365@opindex ftree-ccp
ddf6fe37 13366@item -ftree-ccp
d77de738
ML
13367Perform sparse conditional constant propagation (CCP) on trees. This
13368pass only operates on local scalar variables and is enabled by default
13369at @option{-O1} and higher.
13370
d77de738 13371@opindex fssa-backprop
ddf6fe37 13372@item -fssa-backprop
d77de738
ML
13373Propagate information about uses of a value up the definition chain
13374in order to simplify the definitions. For example, this pass strips
13375sign operations if the sign of a value never matters. The flag is
13376enabled by default at @option{-O1} and higher.
13377
d77de738 13378@opindex fssa-phiopt
ddf6fe37 13379@item -fssa-phiopt
d77de738
ML
13380Perform pattern matching on SSA PHI nodes to optimize conditional
13381code. This pass is enabled by default at @option{-O1} and higher,
13382except for @option{-Og}.
13383
d77de738 13384@opindex ftree-switch-conversion
ddf6fe37 13385@item -ftree-switch-conversion
d77de738
ML
13386Perform conversion of simple initializations in a switch to
13387initializations from a scalar array. This flag is enabled by default
13388at @option{-O2} and higher.
13389
d77de738 13390@opindex ftree-tail-merge
ddf6fe37 13391@item -ftree-tail-merge
d77de738
ML
13392Look for identical code sequences. When found, replace one with a jump to the
13393other. This optimization is known as tail merging or cross jumping. This flag
13394is enabled by default at @option{-O2} and higher. The compilation time
13395in this pass can
13396be limited using @option{max-tail-merge-comparisons} parameter and
13397@option{max-tail-merge-iterations} parameter.
13398
d77de738 13399@opindex ftree-dce
ddf6fe37 13400@item -ftree-dce
d77de738
ML
13401Perform dead code elimination (DCE) on trees. This flag is enabled by
13402default at @option{-O1} and higher.
13403
d77de738 13404@opindex ftree-builtin-call-dce
ddf6fe37 13405@item -ftree-builtin-call-dce
d77de738
ML
13406Perform conditional dead code elimination (DCE) for calls to built-in functions
13407that may set @code{errno} but are otherwise free of side effects. This flag is
13408enabled by default at @option{-O2} and higher if @option{-Os} is not also
13409specified.
13410
d77de738
ML
13411@opindex ffinite-loops
13412@opindex fno-finite-loops
ddf6fe37 13413@item -ffinite-loops
d77de738
ML
13414Assume that a loop with an exit will eventually take the exit and not loop
13415indefinitely. This allows the compiler to remove loops that otherwise have
13416no side-effects, not considering eventual endless looping as such.
13417
13418This option is enabled by default at @option{-O2} for C++ with -std=c++11
13419or higher.
13420
d77de738 13421@opindex ftree-dominator-opts
ddf6fe37 13422@item -ftree-dominator-opts
d77de738
ML
13423Perform a variety of simple scalar cleanups (constant/copy
13424propagation, redundancy elimination, range propagation and expression
13425simplification) based on a dominator tree traversal. This also
13426performs jump threading (to reduce jumps to jumps). This flag is
13427enabled by default at @option{-O1} and higher.
13428
d77de738 13429@opindex ftree-dse
ddf6fe37 13430@item -ftree-dse
d77de738
ML
13431Perform dead store elimination (DSE) on trees. A dead store is a store into
13432a memory location that is later overwritten by another store without
13433any intervening loads. In this case the earlier store can be deleted. This
13434flag is enabled by default at @option{-O1} and higher.
13435
d77de738 13436@opindex ftree-ch
ddf6fe37 13437@item -ftree-ch
d77de738
ML
13438Perform loop header copying on trees. This is beneficial since it increases
13439effectiveness of code motion optimizations. It also saves one jump. This flag
13440is enabled by default at @option{-O1} and higher. It is not enabled
13441for @option{-Os}, since it usually increases code size.
13442
d77de738 13443@opindex ftree-loop-optimize
ddf6fe37 13444@item -ftree-loop-optimize
d77de738
ML
13445Perform loop optimizations on trees. This flag is enabled by default
13446at @option{-O1} and higher.
13447
d77de738
ML
13448@opindex ftree-loop-linear
13449@opindex floop-strip-mine
13450@opindex floop-block
ddf6fe37
AA
13451@item -ftree-loop-linear
13452@itemx -floop-strip-mine
13453@itemx -floop-block
d77de738
ML
13454Perform loop nest optimizations. Same as
13455@option{-floop-nest-optimize}. To use this code transformation, GCC has
13456to be configured with @option{--with-isl} to enable the Graphite loop
13457transformation infrastructure.
13458
d77de738 13459@opindex fgraphite-identity
ddf6fe37 13460@item -fgraphite-identity
d77de738
ML
13461Enable the identity transformation for graphite. For every SCoP we generate
13462the polyhedral representation and transform it back to gimple. Using
13463@option{-fgraphite-identity} we can check the costs or benefits of the
13464GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13465are also performed by the code generator isl, like index splitting and
13466dead code elimination in loops.
13467
d77de738 13468@opindex floop-nest-optimize
ddf6fe37 13469@item -floop-nest-optimize
d77de738
ML
13470Enable the isl based loop nest optimizer. This is a generic loop nest
13471optimizer based on the Pluto optimization algorithms. It calculates a loop
13472structure optimized for data-locality and parallelism. This option
13473is experimental.
13474
d77de738 13475@opindex floop-parallelize-all
ddf6fe37 13476@item -floop-parallelize-all
d77de738
ML
13477Use the Graphite data dependence analysis to identify loops that can
13478be parallelized. Parallelize all the loops that can be analyzed to
13479not contain loop carried dependences without checking that it is
13480profitable to parallelize the loops.
13481
d77de738 13482@opindex ftree-coalesce-vars
ddf6fe37 13483@item -ftree-coalesce-vars
d77de738
ML
13484While transforming the program out of the SSA representation, attempt to
13485reduce copying by coalescing versions of different user-defined
13486variables, instead of just compiler temporaries. This may severely
13487limit the ability to debug an optimized program compiled with
13488@option{-fno-var-tracking-assignments}. In the negated form, this flag
13489prevents SSA coalescing of user variables. This option is enabled by
13490default if optimization is enabled, and it does very little otherwise.
13491
d77de738 13492@opindex ftree-loop-if-convert
ddf6fe37 13493@item -ftree-loop-if-convert
d77de738
ML
13494Attempt to transform conditional jumps in the innermost loops to
13495branch-less equivalents. The intent is to remove control-flow from
13496the innermost loops in order to improve the ability of the
13497vectorization pass to handle these loops. This is enabled by default
13498if vectorization is enabled.
13499
d77de738 13500@opindex ftree-loop-distribution
ddf6fe37 13501@item -ftree-loop-distribution
d77de738
ML
13502Perform loop distribution. This flag can improve cache performance on
13503big loop bodies and allow further loop optimizations, like
13504parallelization or vectorization, to take place. For example, the loop
13505@smallexample
13506DO I = 1, N
13507 A(I) = B(I) + C
13508 D(I) = E(I) * F
13509ENDDO
13510@end smallexample
13511is transformed to
13512@smallexample
13513DO I = 1, N
13514 A(I) = B(I) + C
13515ENDDO
13516DO I = 1, N
13517 D(I) = E(I) * F
13518ENDDO
13519@end smallexample
13520This flag is enabled by default at @option{-O3}.
13521It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13522
d77de738 13523@opindex ftree-loop-distribute-patterns
ddf6fe37 13524@item -ftree-loop-distribute-patterns
d77de738
ML
13525Perform loop distribution of patterns that can be code generated with
13526calls to a library. This flag is enabled by default at @option{-O2} and
13527higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13528
13529This pass distributes the initialization loops and generates a call to
13530memset zero. For example, the loop
13531@smallexample
13532DO I = 1, N
13533 A(I) = 0
13534 B(I) = A(I) + I
13535ENDDO
13536@end smallexample
13537is transformed to
13538@smallexample
13539DO I = 1, N
13540 A(I) = 0
13541ENDDO
13542DO I = 1, N
13543 B(I) = A(I) + I
13544ENDDO
13545@end smallexample
13546and the initialization loop is transformed into a call to memset zero.
13547This flag is enabled by default at @option{-O3}.
13548It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13549
d77de738 13550@opindex floop-interchange
ddf6fe37 13551@item -floop-interchange
d77de738
ML
13552Perform loop interchange outside of graphite. This flag can improve cache
13553performance on loop nest and allow further loop optimizations, like
13554vectorization, to take place. For example, the loop
13555@smallexample
13556for (int i = 0; i < N; i++)
13557 for (int j = 0; j < N; j++)
13558 for (int k = 0; k < N; k++)
13559 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13560@end smallexample
13561is transformed to
13562@smallexample
13563for (int i = 0; i < N; i++)
13564 for (int k = 0; k < N; k++)
13565 for (int j = 0; j < N; j++)
13566 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13567@end smallexample
13568This flag is enabled by default at @option{-O3}.
13569It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13570
d77de738 13571@opindex floop-unroll-and-jam
ddf6fe37 13572@item -floop-unroll-and-jam
d77de738
ML
13573Apply unroll and jam transformations on feasible loops. In a loop
13574nest this unrolls the outer loop by some factor and fuses the resulting
13575multiple inner loops. This flag is enabled by default at @option{-O3}.
13576It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13577
d77de738 13578@opindex ftree-loop-im
ddf6fe37 13579@item -ftree-loop-im
d77de738
ML
13580Perform loop invariant motion on trees. This pass moves only invariants that
13581are hard to handle at RTL level (function calls, operations that expand to
13582nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13583operands of conditions that are invariant out of the loop, so that we can use
13584just trivial invariantness analysis in loop unswitching. The pass also includes
13585store motion.
13586
d77de738 13587@opindex ftree-loop-ivcanon
ddf6fe37 13588@item -ftree-loop-ivcanon
d77de738
ML
13589Create a canonical counter for number of iterations in loops for which
13590determining number of iterations requires complicated analysis. Later
13591optimizations then may determine the number easily. Useful especially
13592in connection with unrolling.
13593
d77de738 13594@opindex ftree-scev-cprop
ddf6fe37 13595@item -ftree-scev-cprop
d77de738
ML
13596Perform final value replacement. If a variable is modified in a loop
13597in such a way that its value when exiting the loop can be determined using
13598only its initial value and the number of loop iterations, replace uses of
13599the final value by such a computation, provided it is sufficiently cheap.
13600This reduces data dependencies and may allow further simplifications.
13601Enabled by default at @option{-O1} and higher.
13602
d77de738 13603@opindex fivopts
ddf6fe37 13604@item -fivopts
d77de738
ML
13605Perform induction variable optimizations (strength reduction, induction
13606variable merging and induction variable elimination) on trees.
13607
d77de738 13608@opindex ftree-parallelize-loops
ddf6fe37 13609@item -ftree-parallelize-loops=n
d77de738
ML
13610Parallelize loops, i.e., split their iteration space to run in n threads.
13611This is only possible for loops whose iterations are independent
13612and can be arbitrarily reordered. The optimization is only
13613profitable on multiprocessor machines, for loops that are CPU-intensive,
13614rather than constrained e.g.@: by memory bandwidth. This option
13615implies @option{-pthread}, and thus is only supported on targets
13616that have support for @option{-pthread}.
13617
d77de738 13618@opindex ftree-pta
ddf6fe37 13619@item -ftree-pta
d77de738
ML
13620Perform function-local points-to analysis on trees. This flag is
13621enabled by default at @option{-O1} and higher, except for @option{-Og}.
13622
d77de738 13623@opindex ftree-sra
ddf6fe37 13624@item -ftree-sra
d77de738
ML
13625Perform scalar replacement of aggregates. This pass replaces structure
13626references with scalars to prevent committing structures to memory too
13627early. This flag is enabled by default at @option{-O1} and higher,
13628except for @option{-Og}.
13629
d77de738 13630@opindex fstore-merging
ddf6fe37 13631@item -fstore-merging
d77de738
ML
13632Perform merging of narrow stores to consecutive memory addresses. This pass
13633merges contiguous stores of immediate values narrower than a word into fewer
13634wider stores to reduce the number of instructions. This is enabled by default
13635at @option{-O2} and higher as well as @option{-Os}.
13636
d77de738 13637@opindex ftree-ter
ddf6fe37 13638@item -ftree-ter
d77de738
ML
13639Perform temporary expression replacement during the SSA->normal phase. Single
13640use/single def temporaries are replaced at their use location with their
13641defining expression. This results in non-GIMPLE code, but gives the expanders
13642much more complex trees to work on resulting in better RTL generation. This is
13643enabled by default at @option{-O1} and higher.
13644
d77de738 13645@opindex ftree-slsr
ddf6fe37 13646@item -ftree-slsr
d77de738
ML
13647Perform straight-line strength reduction on trees. This recognizes related
13648expressions involving multiplications and replaces them by less expensive
13649calculations when possible. This is enabled by default at @option{-O1} and
13650higher.
13651
d77de738 13652@opindex ftree-vectorize
ddf6fe37 13653@item -ftree-vectorize
d77de738
ML
13654Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13655and @option{-ftree-slp-vectorize} if not explicitly specified.
13656
d77de738 13657@opindex ftree-loop-vectorize
ddf6fe37 13658@item -ftree-loop-vectorize
d77de738
ML
13659Perform loop vectorization on trees. This flag is enabled by default at
13660@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13661and @option{-fauto-profile}.
13662
d77de738 13663@opindex ftree-slp-vectorize
ddf6fe37 13664@item -ftree-slp-vectorize
d77de738
ML
13665Perform basic block vectorization on trees. This flag is enabled by default at
13666@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13667and @option{-fauto-profile}.
13668
d77de738 13669@opindex ftrivial-auto-var-init
ddf6fe37 13670@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13671Initialize automatic variables with either a pattern or with zeroes to increase
13672the security and predictability of a program by preventing uninitialized memory
13673disclosure and use.
13674GCC still considers an automatic variable that doesn't have an explicit
13675initializer as uninitialized, @option{-Wuninitialized} and
13676@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13677warning messages on such automatic variables and the compiler will
13678perform optimization as if the variable were uninitialized.
d77de738
ML
13679With this option, GCC will also initialize any padding of automatic variables
13680that have structure or union types to zeroes.
13681However, the current implementation cannot initialize automatic variables that
13682are declared between the controlling expression and the first case of a
13683@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13684such cases.
13685
13686The three values of @var{choice} are:
13687
13688@itemize @bullet
13689@item
13690@samp{uninitialized} doesn't initialize any automatic variables.
13691This is C and C++'s default.
13692
13693@item
13694@samp{pattern} Initialize automatic variables with values which will likely
13695transform logic bugs into crashes down the line, are easily recognized in a
13696crash dump and without being values that programmers can rely on for useful
13697program semantics.
13698The current value is byte-repeatable pattern with byte "0xFE".
13699The values used for pattern initialization might be changed in the future.
13700
13701@item
13702@samp{zero} Initialize automatic variables with zeroes.
13703@end itemize
13704
13705The default is @samp{uninitialized}.
13706
13707You can control this behavior for a specific variable by using the variable
13708attribute @code{uninitialized} (@pxref{Variable Attributes}).
13709
d77de738 13710@opindex fvect-cost-model
ddf6fe37 13711@item -fvect-cost-model=@var{model}
d77de738
ML
13712Alter the cost model used for vectorization. The @var{model} argument
13713should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13714@samp{very-cheap}.
13715With the @samp{unlimited} model the vectorized code-path is assumed
13716to be profitable while with the @samp{dynamic} model a runtime check
13717guards the vectorized code-path to enable it only for iteration
13718counts that will likely execute faster than when executing the original
13719scalar loop. The @samp{cheap} model disables vectorization of
13720loops where doing so would be cost prohibitive for example due to
13721required runtime checks for data dependence or alignment but otherwise
13722is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13723allows vectorization if the vector code would entirely replace the
13724scalar code that is being vectorized. For example, if each iteration
13725of a vectorized loop would only be able to handle exactly four iterations
13726of the scalar loop, the @samp{very-cheap} model would only allow
13727vectorization if the scalar iteration count is known to be a multiple
13728of four.
13729
13730The default cost model depends on other optimization flags and is
13731either @samp{dynamic} or @samp{cheap}.
13732
d77de738 13733@opindex fsimd-cost-model
ddf6fe37 13734@item -fsimd-cost-model=@var{model}
d77de738
ML
13735Alter the cost model used for vectorization of loops marked with the OpenMP
13736simd directive. The @var{model} argument should be one of
13737@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13738have the same meaning as described in @option{-fvect-cost-model} and by
13739default a cost model defined with @option{-fvect-cost-model} is used.
13740
d77de738 13741@opindex ftree-vrp
ddf6fe37 13742@item -ftree-vrp
d77de738
ML
13743Perform Value Range Propagation on trees. This is similar to the
13744constant propagation pass, but instead of values, ranges of values are
13745propagated. This allows the optimizers to remove unnecessary range
13746checks like array bound checks and null pointer checks. This is
13747enabled by default at @option{-O2} and higher. Null pointer check
13748elimination is only done if @option{-fdelete-null-pointer-checks} is
13749enabled.
13750
d77de738 13751@opindex fsplit-paths
ddf6fe37 13752@item -fsplit-paths
d77de738
ML
13753Split paths leading to loop backedges. This can improve dead code
13754elimination and common subexpression elimination. This is enabled by
13755default at @option{-O3} and above.
13756
d77de738 13757@opindex fsplit-ivs-in-unroller
ddf6fe37 13758@item -fsplit-ivs-in-unroller
d77de738
ML
13759Enables expression of values of induction variables in later iterations
13760of the unrolled loop using the value in the first iteration. This breaks
13761long dependency chains, thus improving efficiency of the scheduling passes.
13762
13763A combination of @option{-fweb} and CSE is often sufficient to obtain the
13764same effect. However, that is not reliable in cases where the loop body
13765is more complicated than a single basic block. It also does not work at all
13766on some architectures due to restrictions in the CSE pass.
13767
13768This optimization is enabled by default.
13769
d77de738 13770@opindex fvariable-expansion-in-unroller
ddf6fe37 13771@item -fvariable-expansion-in-unroller
d77de738
ML
13772With this option, the compiler creates multiple copies of some
13773local variables when unrolling a loop, which can result in superior code.
13774
13775This optimization is enabled by default for PowerPC targets, but disabled
13776by default otherwise.
13777
d77de738 13778@opindex fpartial-inlining
ddf6fe37 13779@item -fpartial-inlining
d77de738
ML
13780Inline parts of functions. This option has any effect only
13781when inlining itself is turned on by the @option{-finline-functions}
13782or @option{-finline-small-functions} options.
13783
13784Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13785
d77de738 13786@opindex fpredictive-commoning
ddf6fe37 13787@item -fpredictive-commoning
d77de738
ML
13788Perform predictive commoning optimization, i.e., reusing computations
13789(especially memory loads and stores) performed in previous
13790iterations of loops.
13791
13792This option is enabled at level @option{-O3}.
13793It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13794
d77de738 13795@opindex fprefetch-loop-arrays
ddf6fe37 13796@item -fprefetch-loop-arrays
d77de738
ML
13797If supported by the target machine, generate instructions to prefetch
13798memory to improve the performance of loops that access large arrays.
13799
13800This option may generate better or worse code; results are highly
13801dependent on the structure of loops within the source code.
13802
13803Disabled at level @option{-Os}.
13804
d77de738
ML
13805@opindex fno-printf-return-value
13806@opindex fprintf-return-value
ddf6fe37 13807@item -fno-printf-return-value
d77de738
ML
13808Do not substitute constants for known return value of formatted output
13809functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13810@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13811transformation allows GCC to optimize or even eliminate branches based
13812on the known return value of these functions called with arguments that
13813are either constant, or whose values are known to be in a range that
13814makes determining the exact return value possible. For example, when
13815@option{-fprintf-return-value} is in effect, both the branch and the
13816body of the @code{if} statement (but not the call to @code{snprint})
13817can be optimized away when @code{i} is a 32-bit or smaller integer
13818because the return value is guaranteed to be at most 8.
13819
13820@smallexample
13821char buf[9];
13822if (snprintf (buf, "%08x", i) >= sizeof buf)
13823 @dots{}
13824@end smallexample
13825
13826The @option{-fprintf-return-value} option relies on other optimizations
13827and yields best results with @option{-O2} and above. It works in tandem
13828with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13829options. The @option{-fprintf-return-value} option is enabled by default.
13830
d77de738
ML
13831@opindex fno-peephole
13832@opindex fpeephole
13833@opindex fno-peephole2
13834@opindex fpeephole2
ddf6fe37
AA
13835@item -fno-peephole
13836@itemx -fno-peephole2
d77de738
ML
13837Disable any machine-specific peephole optimizations. The difference
13838between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13839are implemented in the compiler; some targets use one, some use the
13840other, a few use both.
13841
13842@option{-fpeephole} is enabled by default.
13843@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13844
d77de738
ML
13845@opindex fno-guess-branch-probability
13846@opindex fguess-branch-probability
ddf6fe37 13847@item -fno-guess-branch-probability
d77de738
ML
13848Do not guess branch probabilities using heuristics.
13849
13850GCC uses heuristics to guess branch probabilities if they are
13851not provided by profiling feedback (@option{-fprofile-arcs}). These
13852heuristics are based on the control flow graph. If some branch probabilities
13853are specified by @code{__builtin_expect}, then the heuristics are
13854used to guess branch probabilities for the rest of the control flow graph,
13855taking the @code{__builtin_expect} info into account. The interactions
13856between the heuristics and @code{__builtin_expect} can be complex, and in
13857some cases, it may be useful to disable the heuristics so that the effects
13858of @code{__builtin_expect} are easier to understand.
13859
13860It is also possible to specify expected probability of the expression
13861with @code{__builtin_expect_with_probability} built-in function.
13862
13863The default is @option{-fguess-branch-probability} at levels
13864@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13865
d77de738 13866@opindex freorder-blocks
ddf6fe37 13867@item -freorder-blocks
d77de738
ML
13868Reorder basic blocks in the compiled function in order to reduce number of
13869taken branches and improve code locality.
13870
13871Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13872
d77de738 13873@opindex freorder-blocks-algorithm
ddf6fe37 13874@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13875Use the specified algorithm for basic block reordering. The
13876@var{algorithm} argument can be @samp{simple}, which does not increase
13877code size (except sometimes due to secondary effects like alignment),
13878or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13879put all often executed code together, minimizing the number of branches
13880executed by making extra copies of code.
13881
13882The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13883@samp{stc} at levels @option{-O2}, @option{-O3}.
13884
d77de738 13885@opindex freorder-blocks-and-partition
ddf6fe37 13886@item -freorder-blocks-and-partition
d77de738
ML
13887In addition to reordering basic blocks in the compiled function, in order
13888to reduce number of taken branches, partitions hot and cold basic blocks
13889into separate sections of the assembly and @file{.o} files, to improve
13890paging and cache locality performance.
13891
13892This optimization is automatically turned off in the presence of
13893exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13894section attribute and on any architecture that does not support named
13895sections. When @option{-fsplit-stack} is used this option is not
13896enabled by default (to avoid linker errors), but may be enabled
13897explicitly (if using a working linker).
13898
13899Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13900
d77de738 13901@opindex freorder-functions
ddf6fe37 13902@item -freorder-functions
d77de738
ML
13903Reorder functions in the object file in order to
13904improve code locality. This is implemented by using special
13905subsections @code{.text.hot} for most frequently executed functions and
13906@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13907the linker so object file format must support named sections and linker must
13908place them in a reasonable way.
13909
13910This option isn't effective unless you either provide profile feedback
13911(see @option{-fprofile-arcs} for details) or manually annotate functions with
13912@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13913
13914Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13915
d77de738 13916@opindex fstrict-aliasing
ddf6fe37 13917@item -fstrict-aliasing
d77de738
ML
13918Allow the compiler to assume the strictest aliasing rules applicable to
13919the language being compiled. For C (and C++), this activates
13920optimizations based on the type of expressions. In particular, an
13921object of one type is assumed never to reside at the same address as an
13922object of a different type, unless the types are almost the same. For
13923example, an @code{unsigned int} can alias an @code{int}, but not a
13924@code{void*} or a @code{double}. A character type may alias any other
13925type.
13926
13927@anchor{Type-punning}Pay special attention to code like this:
13928@smallexample
13929union a_union @{
13930 int i;
13931 double d;
13932@};
13933
13934int f() @{
13935 union a_union t;
13936 t.d = 3.0;
13937 return t.i;
13938@}
13939@end smallexample
13940The practice of reading from a different union member than the one most
13941recently written to (called ``type-punning'') is common. Even with
13942@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13943is accessed through the union type. So, the code above works as
13944expected. @xref{Structures unions enumerations and bit-fields
13945implementation}. However, this code might not:
13946@smallexample
13947int f() @{
13948 union a_union t;
13949 int* ip;
13950 t.d = 3.0;
13951 ip = &t.i;
13952 return *ip;
13953@}
13954@end smallexample
13955
13956Similarly, access by taking the address, casting the resulting pointer
13957and dereferencing the result has undefined behavior, even if the cast
13958uses a union type, e.g.:
13959@smallexample
13960int f() @{
13961 double d = 3.0;
13962 return ((union a_union *) &d)->i;
13963@}
13964@end smallexample
13965
13966The @option{-fstrict-aliasing} option is enabled at levels
13967@option{-O2}, @option{-O3}, @option{-Os}.
13968
d77de738 13969@opindex fipa-strict-aliasing
ddf6fe37 13970@item -fipa-strict-aliasing
d77de738
ML
13971Controls whether rules of @option{-fstrict-aliasing} are applied across
13972function boundaries. Note that if multiple functions gets inlined into a
13973single function the memory accesses are no longer considered to be crossing a
13974function boundary.
13975
13976The @option{-fipa-strict-aliasing} option is enabled by default and is
13977effective only in combination with @option{-fstrict-aliasing}.
13978
ddf6fe37 13979@opindex falign-functions
d77de738
ML
13980@item -falign-functions
13981@itemx -falign-functions=@var{n}
13982@itemx -falign-functions=@var{n}:@var{m}
13983@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13984@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13985Align the start of functions to the next power-of-two greater than or
13986equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13987least the first @var{m} bytes of the function can be fetched by the CPU
13988without crossing an @var{n}-byte alignment boundary.
13989
13990If @var{m} is not specified, it defaults to @var{n}.
13991
13992Examples: @option{-falign-functions=32} aligns functions to the next
1399332-byte boundary, @option{-falign-functions=24} aligns to the next
1399432-byte boundary only if this can be done by skipping 23 bytes or less,
13995@option{-falign-functions=32:7} aligns to the next
1399632-byte boundary only if this can be done by skipping 6 bytes or less.
13997
13998The second pair of @var{n2}:@var{m2} values allows you to specify
13999a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
14000the next 64-byte boundary if this can be done by skipping 6 bytes or less,
14001otherwise aligns to the next 32-byte boundary if this can be done
14002by skipping 2 bytes or less.
14003If @var{m2} is not specified, it defaults to @var{n2}.
14004
14005Some assemblers only support this flag when @var{n} is a power of two;
14006in that case, it is rounded up.
14007
14008@option{-fno-align-functions} and @option{-falign-functions=1} are
14009equivalent and mean that functions are not aligned.
14010
14011If @var{n} is not specified or is zero, use a machine-dependent default.
14012The maximum allowed @var{n} option value is 65536.
14013
14014Enabled at levels @option{-O2}, @option{-O3}.
14015
14016@item -flimit-function-alignment
14017If this option is enabled, the compiler tries to avoid unnecessarily
14018overaligning functions. It attempts to instruct the assembler to align
14019by the amount specified by @option{-falign-functions}, but not to
14020skip more bytes than the size of the function.
14021
ddf6fe37 14022@opindex falign-labels
d77de738
ML
14023@item -falign-labels
14024@itemx -falign-labels=@var{n}
14025@itemx -falign-labels=@var{n}:@var{m}
14026@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
14027@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14028Align all branch targets to a power-of-two boundary.
14029
14030Parameters of this option are analogous to the @option{-falign-functions} option.
14031@option{-fno-align-labels} and @option{-falign-labels=1} are
14032equivalent and mean that labels are not aligned.
14033
14034If @option{-falign-loops} or @option{-falign-jumps} are applicable and
14035are greater than this value, then their values are used instead.
14036
14037If @var{n} is not specified or is zero, use a machine-dependent default
14038which is very likely to be @samp{1}, meaning no alignment.
14039The maximum allowed @var{n} option value is 65536.
14040
14041Enabled at levels @option{-O2}, @option{-O3}.
14042
ddf6fe37 14043@opindex falign-loops
d77de738
ML
14044@item -falign-loops
14045@itemx -falign-loops=@var{n}
14046@itemx -falign-loops=@var{n}:@var{m}
14047@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
14048@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14049Align loops to a power-of-two boundary. If the loops are executed
14050many times, this makes up for any execution of the dummy padding
14051instructions.
14052
14053If @option{-falign-labels} is greater than this value, then its value
14054is used instead.
14055
14056Parameters of this option are analogous to the @option{-falign-functions} option.
14057@option{-fno-align-loops} and @option{-falign-loops=1} are
14058equivalent and mean that loops are not aligned.
14059The maximum allowed @var{n} option value is 65536.
14060
14061If @var{n} is not specified or is zero, use a machine-dependent default.
14062
14063Enabled at levels @option{-O2}, @option{-O3}.
14064
ddf6fe37 14065@opindex falign-jumps
d77de738
ML
14066@item -falign-jumps
14067@itemx -falign-jumps=@var{n}
14068@itemx -falign-jumps=@var{n}:@var{m}
14069@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14070@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14071Align branch targets to a power-of-two boundary, for branch targets
14072where the targets can only be reached by jumping. In this case,
14073no dummy operations need be executed.
14074
14075If @option{-falign-labels} is greater than this value, then its value
14076is used instead.
14077
14078Parameters of this option are analogous to the @option{-falign-functions} option.
14079@option{-fno-align-jumps} and @option{-falign-jumps=1} are
14080equivalent and mean that loops are not aligned.
14081
14082If @var{n} is not specified or is zero, use a machine-dependent default.
14083The maximum allowed @var{n} option value is 65536.
14084
14085Enabled at levels @option{-O2}, @option{-O3}.
14086
d77de738 14087@opindex fno-allocation-dce
ddf6fe37 14088@item -fno-allocation-dce
d77de738
ML
14089Do not remove unused C++ allocations in dead code elimination.
14090
d77de738 14091@opindex fallow-store-data-races
ddf6fe37 14092@item -fallow-store-data-races
d77de738
ML
14093Allow the compiler to perform optimizations that may introduce new data races
14094on stores, without proving that the variable cannot be concurrently accessed
14095by other threads. Does not affect optimization of local data. It is safe to
14096use this option if it is known that global data will not be accessed by
14097multiple threads.
14098
14099Examples of optimizations enabled by @option{-fallow-store-data-races} include
14100hoisting or if-conversions that may cause a value that was already in memory
14101to be re-written with that same value. Such re-writing is safe in a single
14102threaded context but may be unsafe in a multi-threaded context. Note that on
14103some processors, if-conversions may be required in order to enable
14104vectorization.
14105
14106Enabled at level @option{-Ofast}.
14107
d77de738 14108@opindex funit-at-a-time
ddf6fe37 14109@item -funit-at-a-time
d77de738
ML
14110This option is left for compatibility reasons. @option{-funit-at-a-time}
14111has no effect, while @option{-fno-unit-at-a-time} implies
14112@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
14113
14114Enabled by default.
14115
d77de738
ML
14116@opindex fno-toplevel-reorder
14117@opindex ftoplevel-reorder
ddf6fe37 14118@item -fno-toplevel-reorder
d77de738
ML
14119Do not reorder top-level functions, variables, and @code{asm}
14120statements. Output them in the same order that they appear in the
14121input file. When this option is used, unreferenced static variables
14122are not removed. This option is intended to support existing code
14123that relies on a particular ordering. For new code, it is better to
14124use attributes when possible.
14125
14126@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
14127also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
14128Additionally @option{-fno-toplevel-reorder} implies
14129@option{-fno-section-anchors}.
14130
d77de738 14131@opindex funreachable-traps
ddf6fe37 14132@item -funreachable-traps
d77de738
ML
14133With this option, the compiler turns calls to
14134@code{__builtin_unreachable} into traps, instead of using them for
14135optimization. This also affects any such calls implicitly generated
14136by the compiler.
14137
14138This option has the same effect as @option{-fsanitize=unreachable
14139-fsanitize-trap=unreachable}, but does not affect the values of those
14140options. If @option{-fsanitize=unreachable} is enabled, that option
14141takes priority over this one.
14142
14143This option is enabled by default at @option{-O0} and @option{-Og}.
14144
d77de738 14145@opindex fweb
ddf6fe37 14146@item -fweb
d77de738
ML
14147Constructs webs as commonly used for register allocation purposes and assign
14148each web individual pseudo register. This allows the register allocation pass
14149to operate on pseudos directly, but also strengthens several other optimization
14150passes, such as CSE, loop optimizer and trivial dead code remover. It can,
14151however, make debugging impossible, since variables no longer stay in a
14152``home register''.
14153
14154Enabled by default with @option{-funroll-loops}.
14155
d77de738 14156@opindex fwhole-program
ddf6fe37 14157@item -fwhole-program
d77de738
ML
14158Assume that the current compilation unit represents the whole program being
14159compiled. All public functions and variables with the exception of @code{main}
14160and those merged by attribute @code{externally_visible} become static functions
14161and in effect are optimized more aggressively by interprocedural optimizers.
14162
39ebd3a9
JH
14163With @option{-flto} this option has a limited use. In most cases the
14164precise list of symbols used or exported from the binary is known the
14165resolution info passed to the link-time optimizer by the linker plugin. It is
14166still useful if no linker plugin is used or during incremental link step when
14167final code is produced (with @option{-flto}
14168@option{-flinker-output=nolto-rel}).
d77de738 14169
d77de738 14170@opindex flto
ddf6fe37 14171@item -flto[=@var{n}]
d77de738
ML
14172This option runs the standard link-time optimizer. When invoked
14173with source code, it generates GIMPLE (one of GCC's internal
14174representations) and writes it to special ELF sections in the object
14175file. When the object files are linked together, all the function
14176bodies are read from these ELF sections and instantiated as if they
14177had been part of the same translation unit.
14178
14179To use the link-time optimizer, @option{-flto} and optimization
14180options should be specified at compile time and during the final link.
14181It is recommended that you compile all the files participating in the
14182same link with the same options and also specify those options at
14183link time.
14184For example:
14185
14186@smallexample
14187gcc -c -O2 -flto foo.c
14188gcc -c -O2 -flto bar.c
14189gcc -o myprog -flto -O2 foo.o bar.o
14190@end smallexample
14191
14192The first two invocations to GCC save a bytecode representation
14193of GIMPLE into special ELF sections inside @file{foo.o} and
14194@file{bar.o}. The final invocation reads the GIMPLE bytecode from
14195@file{foo.o} and @file{bar.o}, merges the two files into a single
14196internal image, and compiles the result as usual. Since both
14197@file{foo.o} and @file{bar.o} are merged into a single image, this
14198causes all the interprocedural analyses and optimizations in GCC to
14199work across the two files as if they were a single one. This means,
14200for example, that the inliner is able to inline functions in
14201@file{bar.o} into functions in @file{foo.o} and vice-versa.
14202
14203Another (simpler) way to enable link-time optimization is:
14204
14205@smallexample
14206gcc -o myprog -flto -O2 foo.c bar.c
14207@end smallexample
14208
14209The above generates bytecode for @file{foo.c} and @file{bar.c},
14210merges them together into a single GIMPLE representation and optimizes
14211them as usual to produce @file{myprog}.
14212
14213The important thing to keep in mind is that to enable link-time
14214optimizations you need to use the GCC driver to perform the link step.
14215GCC automatically performs link-time optimization if any of the
14216objects involved were compiled with the @option{-flto} command-line option.
14217You can always override
14218the automatic decision to do link-time optimization
14219by passing @option{-fno-lto} to the link command.
14220
14221To make whole program optimization effective, it is necessary to make
14222certain whole program assumptions. The compiler needs to know
14223what functions and variables can be accessed by libraries and runtime
14224outside of the link-time optimized unit. When supported by the linker,
14225the linker plugin (see @option{-fuse-linker-plugin}) passes information
14226to the compiler about used and externally visible symbols. When
14227the linker plugin is not available, @option{-fwhole-program} should be
14228used to allow the compiler to make these assumptions, which leads
14229to more aggressive optimization decisions.
14230
14231When a file is compiled with @option{-flto} without
14232@option{-fuse-linker-plugin}, the generated object file is larger than
14233a regular object file because it contains GIMPLE bytecodes and the usual
14234final code (see @option{-ffat-lto-objects}). This means that
14235object files with LTO information can be linked as normal object
14236files; if @option{-fno-lto} is passed to the linker, no
14237interprocedural optimizations are applied. Note that when
14238@option{-fno-fat-lto-objects} is enabled the compile stage is faster
14239but you cannot perform a regular, non-LTO link on them.
14240
14241When producing the final binary, GCC only
14242applies link-time optimizations to those files that contain bytecode.
14243Therefore, you can mix and match object files and libraries with
14244GIMPLE bytecodes and final object code. GCC automatically selects
14245which files to optimize in LTO mode and which files to link without
14246further processing.
14247
14248Generally, options specified at link time override those
14249specified at compile time, although in some cases GCC attempts to infer
14250link-time options from the settings used to compile the input files.
14251
14252If you do not specify an optimization level option @option{-O} at
14253link time, then GCC uses the highest optimization level
14254used when compiling the object files. Note that it is generally
14255ineffective to specify an optimization level option only at link time and
14256not at compile time, for two reasons. First, compiling without
14257optimization suppresses compiler passes that gather information
14258needed for effective optimization at link time. Second, some early
14259optimization passes can be performed only at compile time and
14260not at link time.
14261
14262There are some code generation flags preserved by GCC when
14263generating bytecodes, as they need to be used during the final link.
14264Currently, the following options and their settings are taken from
14265the first object file that explicitly specifies them:
14266@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14267@option{-fgnu-tm} and all the @option{-m} target flags.
14268
14269The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14270@option{-fPIE} are combined based on the following scheme:
14271
14272@smallexample
14273@option{-fPIC} + @option{-fpic} = @option{-fpic}
14274@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14275@option{-fpic/-fPIC} + (no option) = (no option)
14276@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14277@option{-fpic} + @option{-fPIE} = @option{-fpie}
14278@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14279@end smallexample
14280
14281Certain ABI-changing flags are required to match in all compilation units,
14282and trying to override this at link time with a conflicting value
14283is ignored. This includes options such as @option{-freg-struct-return}
14284and @option{-fpcc-struct-return}.
14285
14286Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14287@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14288are passed through to the link stage and merged conservatively for
14289conflicting translation units. Specifically
14290@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14291precedence; and for example @option{-ffp-contract=off} takes precedence
14292over @option{-ffp-contract=fast}. You can override them at link time.
14293
14294Diagnostic options such as @option{-Wstringop-overflow} are passed
14295through to the link stage and their setting matches that of the
14296compile-step at function granularity. Note that this matters only
14297for diagnostics emitted during optimization. Note that code
14298transforms such as inlining can lead to warnings being enabled
14299or disabled for regions if code not consistent with the setting
14300at compile time.
14301
14302When you need to pass options to the assembler via @option{-Wa} or
14303@option{-Xassembler} make sure to either compile such translation
14304units with @option{-fno-lto} or consistently use the same assembler
14305options on all translation units. You can alternatively also
14306specify assembler options at LTO link time.
14307
14308To enable debug info generation you need to supply @option{-g} at
14309compile time. If any of the input files at link time were built
14310with debug info generation enabled the link will enable debug info
14311generation as well. Any elaborate debug info settings
14312like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14313at the linker command line and mixing different settings in different
14314translation units is discouraged.
14315
14316If LTO encounters objects with C linkage declared with incompatible
14317types in separate translation units to be linked together (undefined
14318behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14319issued. The behavior is still undefined at run time. Similar
14320diagnostics may be raised for other languages.
14321
14322Another feature of LTO is that it is possible to apply interprocedural
14323optimizations on files written in different languages:
14324
14325@smallexample
14326gcc -c -flto foo.c
14327g++ -c -flto bar.cc
14328gfortran -c -flto baz.f90
14329g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14330@end smallexample
14331
14332Notice that the final link is done with @command{g++} to get the C++
14333runtime libraries and @option{-lgfortran} is added to get the Fortran
14334runtime libraries. In general, when mixing languages in LTO mode, you
14335should use the same link command options as when mixing languages in a
14336regular (non-LTO) compilation.
14337
14338If object files containing GIMPLE bytecode are stored in a library archive, say
14339@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14340are using a linker with plugin support. To create static libraries suitable
14341for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14342and @command{ranlib};
14343to show the symbols of object files with GIMPLE bytecode, use
14344@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14345and @command{nm} have been compiled with plugin support. At link time, use the
14346flag @option{-fuse-linker-plugin} to ensure that the library participates in
14347the LTO optimization process:
14348
14349@smallexample
14350gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14351@end smallexample
14352
14353With the linker plugin enabled, the linker extracts the needed
14354GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14355to make them part of the aggregated GIMPLE image to be optimized.
14356
14357If you are not using a linker with plugin support and/or do not
14358enable the linker plugin, then the objects inside @file{libfoo.a}
14359are extracted and linked as usual, but they do not participate
14360in the LTO optimization process. In order to make a static library suitable
14361for both LTO optimization and usual linkage, compile its object files with
14362@option{-flto} @option{-ffat-lto-objects}.
14363
14364Link-time optimizations do not require the presence of the whole program to
14365operate. If the program does not require any symbols to be exported, it is
14366possible to combine @option{-flto} and @option{-fwhole-program} to allow
14367the interprocedural optimizers to use more aggressive assumptions which may
14368lead to improved optimization opportunities.
14369Use of @option{-fwhole-program} is not needed when linker plugin is
14370active (see @option{-fuse-linker-plugin}).
14371
14372The current implementation of LTO makes no
14373attempt to generate bytecode that is portable between different
14374types of hosts. The bytecode files are versioned and there is a
14375strict version check, so bytecode files generated in one version of
14376GCC do not work with an older or newer version of GCC.
14377
14378Link-time optimization does not work well with generation of debugging
14379information on systems other than those using a combination of ELF and
14380DWARF.
14381
14382If you specify the optional @var{n}, the optimization and code
14383generation done at link time is executed in parallel using @var{n}
14384parallel jobs by utilizing an installed @command{make} program. The
14385environment variable @env{MAKE} may be used to override the program
14386used.
14387
14388You can also specify @option{-flto=jobserver} to use GNU make's
14389job server mode to determine the number of parallel jobs. This
14390is useful when the Makefile calling GCC is already executing in parallel.
14391You must prepend a @samp{+} to the command recipe in the parent Makefile
14392for this to work. This option likely only works if @env{MAKE} is
14393GNU make. Even without the option value, GCC tries to automatically
14394detect a running GNU make's job server.
14395
14396Use @option{-flto=auto} to use GNU make's job server, if available,
14397or otherwise fall back to autodetection of the number of CPU threads
14398present in your system.
14399
d77de738 14400@opindex flto-partition
ddf6fe37 14401@item -flto-partition=@var{alg}
d77de738
ML
14402Specify the partitioning algorithm used by the link-time optimizer.
14403The value is either @samp{1to1} to specify a partitioning mirroring
14404the original source files or @samp{balanced} to specify partitioning
14405into equally sized chunks (whenever possible) or @samp{max} to create
14406new partition for every symbol where possible. Specifying @samp{none}
14407as an algorithm disables partitioning and streaming completely.
14408The default value is @samp{balanced}. While @samp{1to1} can be used
14409as an workaround for various code ordering issues, the @samp{max}
14410partitioning is intended for internal testing only.
14411The value @samp{one} specifies that exactly one partition should be
14412used while the value @samp{none} bypasses partitioning and executes
14413the link-time optimization step directly from the WPA phase.
14414
d77de738 14415@opindex flto-compression-level
ddf6fe37 14416@item -flto-compression-level=@var{n}
d77de738
ML
14417This option specifies the level of compression used for intermediate
14418language written to LTO object files, and is only meaningful in
14419conjunction with LTO mode (@option{-flto}). GCC currently supports two
14420LTO compression algorithms. For zstd, valid values are 0 (no compression)
14421to 19 (maximum compression), while zlib supports values from 0 to 9.
14422Values outside this range are clamped to either minimum or maximum
14423of the supported values. If the option is not given,
14424a default balanced compression setting is used.
14425
d77de738 14426@opindex fuse-linker-plugin
ddf6fe37 14427@item -fuse-linker-plugin
d77de738
ML
14428Enables the use of a linker plugin during link-time optimization. This
14429option relies on plugin support in the linker, which is available in gold
14430or in GNU ld 2.21 or newer.
14431
14432This option enables the extraction of object files with GIMPLE bytecode out
14433of library archives. This improves the quality of optimization by exposing
14434more code to the link-time optimizer. This information specifies what
14435symbols can be accessed externally (by non-LTO object or during dynamic
14436linking). Resulting code quality improvements on binaries (and shared
14437libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14438See @option{-flto} for a description of the effect of this flag and how to
14439use it.
14440
14441This option is enabled by default when LTO support in GCC is enabled
14442and GCC was configured for use with
14443a linker supporting plugins (GNU ld 2.21 or newer or gold).
14444
d77de738 14445@opindex ffat-lto-objects
ddf6fe37 14446@item -ffat-lto-objects
d77de738
ML
14447Fat LTO objects are object files that contain both the intermediate language
14448and the object code. This makes them usable for both LTO linking and normal
14449linking. This option is effective only when compiling with @option{-flto}
14450and is ignored at link time.
14451
14452@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14453requires the complete toolchain to be aware of LTO. It requires a linker with
14454linker plugin support for basic functionality. Additionally,
14455@command{nm}, @command{ar} and @command{ranlib}
14456need to support linker plugins to allow a full-featured build environment
14457(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14458@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14459to these tools. With non fat LTO makefiles need to be modified to use them.
14460
14461Note that modern binutils provide plugin auto-load mechanism.
14462Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14463effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14464@command{gcc-ranlib}).
14465
14466The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14467support.
14468
d77de738 14469@opindex fcompare-elim
ddf6fe37 14470@item -fcompare-elim
d77de738
ML
14471After register allocation and post-register allocation instruction splitting,
14472identify arithmetic instructions that compute processor flags similar to a
14473comparison operation based on that arithmetic. If possible, eliminate the
14474explicit comparison operation.
14475
14476This pass only applies to certain targets that cannot explicitly represent
14477the comparison operation before register allocation is complete.
14478
14479Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14480
04c9cf5c
MT
14481@opindex ffold-mem-offsets
14482@item -ffold-mem-offsets
14483@itemx -fno-fold-mem-offsets
14484Try to eliminate add instructions by folding them in memory loads/stores.
14485
14486Enabled at levels @option{-O2}, @option{-O3}.
14487
d77de738 14488@opindex fcprop-registers
ddf6fe37 14489@item -fcprop-registers
d77de738
ML
14490After register allocation and post-register allocation instruction splitting,
14491perform a copy-propagation pass to try to reduce scheduling dependencies
14492and occasionally eliminate the copy.
14493
14494Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14495
d77de738 14496@opindex fprofile-correction
ddf6fe37 14497@item -fprofile-correction
d77de738
ML
14498Profiles collected using an instrumented binary for multi-threaded programs may
14499be inconsistent due to missed counter updates. When this option is specified,
14500GCC uses heuristics to correct or smooth out such inconsistencies. By
14501default, GCC emits an error message when an inconsistent profile is detected.
14502
14503This option is enabled by @option{-fauto-profile}.
14504
d77de738 14505@opindex fprofile-partial-training
ddf6fe37 14506@item -fprofile-partial-training
d77de738
ML
14507With @code{-fprofile-use} all portions of programs not executed during train
14508run are optimized agressively for size rather than speed. In some cases it is
14509not practical to train all possible hot paths in the program. (For
14510example, program may contain functions specific for a given hardware and
14511trianing may not cover all hardware configurations program is run on.) With
14512@code{-fprofile-partial-training} profile feedback will be ignored for all
14513functions not executed during the train run leading them to be optimized as if
14514they were compiled without profile feedback. This leads to better performance
14515when train run is not representative but also leads to significantly bigger
14516code.
14517
ddf6fe37 14518@opindex fprofile-use
d77de738
ML
14519@item -fprofile-use
14520@itemx -fprofile-use=@var{path}
d77de738
ML
14521Enable profile feedback-directed optimizations,
14522and the following optimizations, many of which
14523are generally profitable only with profile feedback available:
14524
43b72ede
AA
14525@gccoptlist{-fbranch-probabilities -fprofile-values
14526-funroll-loops -fpeel-loops -ftracer -fvpt
14527-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14528-fpredictive-commoning -fsplit-loops -funswitch-loops
14529-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14530-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14531-fprofile-reorder-functions}
14532
14533Before you can use this option, you must first generate profiling information.
14534@xref{Instrumentation Options}, for information about the
14535@option{-fprofile-generate} option.
14536
14537By default, GCC emits an error message if the feedback profiles do not
14538match the source code. This error can be turned into a warning by using
14539@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14540optimized code. Additionally, by default, GCC also emits a warning message if
14541the feedback profiles do not exist (see @option{-Wmissing-profile}).
14542
14543If @var{path} is specified, GCC looks at the @var{path} to find
14544the profile feedback data files. See @option{-fprofile-dir}.
14545
ddf6fe37 14546@opindex fauto-profile
d77de738
ML
14547@item -fauto-profile
14548@itemx -fauto-profile=@var{path}
d77de738
ML
14549Enable sampling-based feedback-directed optimizations,
14550and the following optimizations,
14551many of which are generally profitable only with profile feedback available:
14552
43b72ede
AA
14553@gccoptlist{-fbranch-probabilities -fprofile-values
14554-funroll-loops -fpeel-loops -ftracer -fvpt
14555-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14556-fpredictive-commoning -fsplit-loops -funswitch-loops
14557-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14558-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14559-fprofile-correction}
14560
14561@var{path} is the name of a file containing AutoFDO profile information.
14562If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14563
14564Producing an AutoFDO profile data file requires running your program
14565with the @command{perf} utility on a supported GNU/Linux target system.
14566For more information, see @uref{https://perf.wiki.kernel.org/}.
14567
14568E.g.
14569@smallexample
14570perf record -e br_inst_retired:near_taken -b -o perf.data \
14571 -- your_program
14572@end smallexample
14573
14574Then use the @command{create_gcov} tool to convert the raw profile data
14575to a format that can be used by GCC.@ You must also supply the
14576unstripped binary for your program to this tool.
14577See @uref{https://github.com/google/autofdo}.
14578
14579E.g.
14580@smallexample
14581create_gcov --binary=your_program.unstripped --profile=perf.data \
14582 --gcov=profile.afdo
14583@end smallexample
14584@end table
14585
14586The following options control compiler behavior regarding floating-point
14587arithmetic. These options trade off between speed and
14588correctness. All must be specifically enabled.
14589
14590@table @gcctabopt
d77de738 14591@opindex ffloat-store
ddf6fe37 14592@item -ffloat-store
d77de738
ML
14593Do not store floating-point variables in registers, and inhibit other
14594options that might change whether a floating-point value is taken from a
14595register or memory.
14596
14597@cindex floating-point precision
14598This option prevents undesirable excess precision on machines such as
14599the 68000 where the floating registers (of the 68881) keep more
14600precision than a @code{double} is supposed to have. Similarly for the
14601x86 architecture. For most programs, the excess precision does only
14602good, but a few programs rely on the precise definition of IEEE floating
14603point. Use @option{-ffloat-store} for such programs, after modifying
14604them to store all pertinent intermediate computations into variables.
14605
d77de738 14606@opindex fexcess-precision
ddf6fe37 14607@item -fexcess-precision=@var{style}
d77de738
ML
14608This option allows further control over excess precision on machines
14609where floating-point operations occur in a format with more precision or
14610range than the IEEE standard and interchange floating-point types. By
14611default, @option{-fexcess-precision=fast} is in effect; this means that
14612operations may be carried out in a wider precision than the types specified
14613in the source if that would result in faster code, and it is unpredictable
14614when rounding to the types specified in the source code takes place.
14615When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14616then excess precision follows the rules specified in ISO C99 or C++; in particular,
14617both casts and assignments cause values to be rounded to their
14618semantic types (whereas @option{-ffloat-store} only affects
14619assignments). This option is enabled by default for C or C++ if a strict
14620conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14621@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14622regardless of whether a strict conformance option is used.
14623
14624@opindex mfpmath
14625@option{-fexcess-precision=standard} is not implemented for languages
14626other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14627or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14628semantics apply without excess precision, and in the latter, rounding
14629is unpredictable.
14630
d77de738 14631@opindex ffast-math
ddf6fe37 14632@item -ffast-math
d77de738
ML
14633Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14634@option{-ffinite-math-only}, @option{-fno-rounding-math},
14635@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14636@option{-fexcess-precision=fast}.
14637
14638This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14639
14640This option is not turned on by any @option{-O} option besides
14641@option{-Ofast} since it can result in incorrect output for programs
14642that depend on an exact implementation of IEEE or ISO rules/specifications
14643for math functions. It may, however, yield faster code for programs
14644that do not require the guarantees of these specifications.
14645
d77de738
ML
14646@opindex fno-math-errno
14647@opindex fmath-errno
ddf6fe37 14648@item -fno-math-errno
d77de738
ML
14649Do not set @code{errno} after calling math functions that are executed
14650with a single instruction, e.g., @code{sqrt}. A program that relies on
14651IEEE exceptions for math error handling may want to use this flag
14652for speed while maintaining IEEE arithmetic compatibility.
14653
14654This option is not turned on by any @option{-O} option since
14655it can result in incorrect output for programs that depend on
14656an exact implementation of IEEE or ISO rules/specifications for
14657math functions. It may, however, yield faster code for programs
14658that do not require the guarantees of these specifications.
14659
14660The default is @option{-fmath-errno}.
14661
14662On Darwin systems, the math library never sets @code{errno}. There is
14663therefore no reason for the compiler to consider the possibility that
14664it might, and @option{-fno-math-errno} is the default.
14665
d77de738 14666@opindex funsafe-math-optimizations
ddf6fe37 14667@item -funsafe-math-optimizations
d77de738
ML
14668
14669Allow optimizations for floating-point arithmetic that (a) assume
14670that arguments and results are valid and (b) may violate IEEE or
14671ANSI standards. When used at link time, it may include libraries
14672or startup files that change the default FPU control word or other
14673similar optimizations.
14674
14675This option is not turned on by any @option{-O} option since
14676it can result in incorrect output for programs that depend on
14677an exact implementation of IEEE or ISO rules/specifications for
14678math functions. It may, however, yield faster code for programs
14679that do not require the guarantees of these specifications.
14680Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14681@option{-fassociative-math} and @option{-freciprocal-math}.
14682
14683The default is @option{-fno-unsafe-math-optimizations}.
14684
d77de738 14685@opindex fassociative-math
ddf6fe37 14686@item -fassociative-math
d77de738
ML
14687
14688Allow re-association of operands in series of floating-point operations.
14689This violates the ISO C and C++ language standard by possibly changing
14690computation result. NOTE: re-ordering may change the sign of zero as
14691well as ignore NaNs and inhibit or create underflow or overflow (and
14692thus cannot be used on code that relies on rounding behavior like
14693@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14694and thus may not be used when ordered comparisons are required.
14695This option requires that both @option{-fno-signed-zeros} and
14696@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14697much sense with @option{-frounding-math}. For Fortran the option
14698is automatically enabled when both @option{-fno-signed-zeros} and
14699@option{-fno-trapping-math} are in effect.
14700
14701The default is @option{-fno-associative-math}.
14702
d77de738 14703@opindex freciprocal-math
ddf6fe37 14704@item -freciprocal-math
d77de738
ML
14705
14706Allow the reciprocal of a value to be used instead of dividing by
14707the value if this enables optimizations. For example @code{x / y}
14708can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14709is subject to common subexpression elimination. Note that this loses
14710precision and increases the number of flops operating on the value.
14711
14712The default is @option{-fno-reciprocal-math}.
14713
d77de738 14714@opindex ffinite-math-only
ddf6fe37 14715@item -ffinite-math-only
d77de738
ML
14716Allow optimizations for floating-point arithmetic that assume
14717that arguments and results are not NaNs or +-Infs.
14718
14719This option is not turned on by any @option{-O} option since
14720it can result in incorrect output for programs that depend on
14721an exact implementation of IEEE or ISO rules/specifications for
14722math functions. It may, however, yield faster code for programs
14723that do not require the guarantees of these specifications.
14724
14725The default is @option{-fno-finite-math-only}.
14726
d77de738
ML
14727@opindex fno-signed-zeros
14728@opindex fsigned-zeros
ddf6fe37 14729@item -fno-signed-zeros
d77de738
ML
14730Allow optimizations for floating-point arithmetic that ignore the
14731signedness of zero. IEEE arithmetic specifies the behavior of
14732distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14733of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14734This option implies that the sign of a zero result isn't significant.
14735
14736The default is @option{-fsigned-zeros}.
14737
d77de738
ML
14738@opindex fno-trapping-math
14739@opindex ftrapping-math
ddf6fe37 14740@item -fno-trapping-math
d77de738
ML
14741Compile code assuming that floating-point operations cannot generate
14742user-visible traps. These traps include division by zero, overflow,
14743underflow, inexact result and invalid operation. This option requires
14744that @option{-fno-signaling-nans} be in effect. Setting this option may
14745allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14746
14747This option should never be turned on by any @option{-O} option since
14748it can result in incorrect output for programs that depend on
14749an exact implementation of IEEE or ISO rules/specifications for
14750math functions.
14751
14752The default is @option{-ftrapping-math}.
14753
14754Future versions of GCC may provide finer control of this setting
14755using C99's @code{FENV_ACCESS} pragma. This command-line option
14756will be used along with @option{-frounding-math} to specify the
14757default state for @code{FENV_ACCESS}.
14758
d77de738 14759@opindex frounding-math
ddf6fe37 14760@item -frounding-math
d77de738
ML
14761Disable transformations and optimizations that assume default floating-point
14762rounding behavior. This is round-to-zero for all floating point
14763to integer conversions, and round-to-nearest for all other arithmetic
14764truncations. This option should be specified for programs that change
14765the FP rounding mode dynamically, or that may be executed with a
14766non-default rounding mode. This option disables constant folding of
14767floating-point expressions at compile time (which may be affected by
14768rounding mode) and arithmetic transformations that are unsafe in the
14769presence of sign-dependent rounding modes.
14770
14771The default is @option{-fno-rounding-math}.
14772
14773This option is experimental and does not currently guarantee to
14774disable all GCC optimizations that are affected by rounding mode.
14775Future versions of GCC may provide finer control of this setting
14776using C99's @code{FENV_ACCESS} pragma. This command-line option
14777will be used along with @option{-ftrapping-math} to specify the
14778default state for @code{FENV_ACCESS}.
14779
d77de738 14780@opindex fsignaling-nans
ddf6fe37 14781@item -fsignaling-nans
d77de738
ML
14782Compile code assuming that IEEE signaling NaNs may generate user-visible
14783traps during floating-point operations. Setting this option disables
14784optimizations that may change the number of exceptions visible with
14785signaling NaNs. This option implies @option{-ftrapping-math}.
14786
14787This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14788be defined.
14789
14790The default is @option{-fno-signaling-nans}.
14791
14792This option is experimental and does not currently guarantee to
14793disable all GCC optimizations that affect signaling NaN behavior.
14794
d77de738
ML
14795@opindex fno-fp-int-builtin-inexact
14796@opindex ffp-int-builtin-inexact
ddf6fe37 14797@item -fno-fp-int-builtin-inexact
d77de738
ML
14798Do not allow the built-in functions @code{ceil}, @code{floor},
14799@code{round} and @code{trunc}, and their @code{float} and @code{long
14800double} variants, to generate code that raises the ``inexact''
14801floating-point exception for noninteger arguments. ISO C99 and C11
14802allow these functions to raise the ``inexact'' exception, but ISO/IEC
14803TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
094a609c 14804ISO C23, does not allow these functions to do so.
d77de738
ML
14805
14806The default is @option{-ffp-int-builtin-inexact}, allowing the
094a609c 14807exception to be raised, unless C23 or a later C standard is selected.
d77de738
ML
14808This option does nothing unless @option{-ftrapping-math} is in effect.
14809
14810Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14811generate a call to a library function then the ``inexact'' exception
14812may be raised if the library implementation does not follow TS 18661.
14813
d77de738 14814@opindex fsingle-precision-constant
ddf6fe37 14815@item -fsingle-precision-constant
d77de738
ML
14816Treat floating-point constants as single precision instead of
14817implicitly converting them to double-precision constants.
14818
d77de738 14819@opindex fcx-limited-range
ddf6fe37 14820@item -fcx-limited-range
d77de738
ML
14821When enabled, this option states that a range reduction step is not
14822needed when performing complex division. Also, there is no checking
14823whether the result of a complex multiplication or division is @code{NaN
14824+ I*NaN}, with an attempt to rescue the situation in that case. The
14825default is @option{-fno-cx-limited-range}, but is enabled by
14826@option{-ffast-math}.
14827
14828This option controls the default setting of the ISO C99
14829@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14830all languages.
14831
d77de738 14832@opindex fcx-fortran-rules
ddf6fe37 14833@item -fcx-fortran-rules
d77de738
ML
14834Complex multiplication and division follow Fortran rules. Range
14835reduction is done as part of complex division, but there is no checking
14836whether the result of a complex multiplication or division is @code{NaN
14837+ I*NaN}, with an attempt to rescue the situation in that case.
14838
14839The default is @option{-fno-cx-fortran-rules}.
14840
14841@end table
14842
14843The following options control optimizations that may improve
14844performance, but are not enabled by any @option{-O} options. This
14845section includes experimental options that may produce broken code.
14846
14847@table @gcctabopt
d77de738 14848@opindex fbranch-probabilities
ddf6fe37 14849@item -fbranch-probabilities
d77de738
ML
14850After running a program compiled with @option{-fprofile-arcs}
14851(@pxref{Instrumentation Options}),
14852you can compile it a second time using
14853@option{-fbranch-probabilities}, to improve optimizations based on
14854the number of times each branch was taken. When a program
14855compiled with @option{-fprofile-arcs} exits, it saves arc execution
14856counts to a file called @file{@var{sourcename}.gcda} for each source
14857file. The information in this data file is very dependent on the
14858structure of the generated code, so you must use the same source code
14859and the same optimization options for both compilations.
14860See details about the file naming in @option{-fprofile-arcs}.
14861
14862With @option{-fbranch-probabilities}, GCC puts a
14863@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14864These can be used to improve optimization. Currently, they are only
14865used in one place: in @file{reorg.cc}, instead of guessing which path a
14866branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14867exactly determine which path is taken more often.
14868
14869Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14870
d77de738 14871@opindex fprofile-values
ddf6fe37 14872@item -fprofile-values
d77de738
ML
14873If combined with @option{-fprofile-arcs}, it adds code so that some
14874data about values of expressions in the program is gathered.
14875
14876With @option{-fbranch-probabilities}, it reads back the data gathered
14877from profiling values of expressions for usage in optimizations.
14878
14879Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14880@option{-fauto-profile}.
14881
d77de738 14882@opindex fprofile-reorder-functions
ddf6fe37 14883@item -fprofile-reorder-functions
d77de738
ML
14884Function reordering based on profile instrumentation collects
14885first time of execution of a function and orders these functions
14886in ascending order.
14887
14888Enabled with @option{-fprofile-use}.
14889
d77de738 14890@opindex fvpt
ddf6fe37 14891@item -fvpt
d77de738
ML
14892If combined with @option{-fprofile-arcs}, this option instructs the compiler
14893to add code to gather information about values of expressions.
14894
14895With @option{-fbranch-probabilities}, it reads back the data gathered
14896and actually performs the optimizations based on them.
14897Currently the optimizations include specialization of division operations
14898using the knowledge about the value of the denominator.
14899
14900Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14901
d77de738 14902@opindex frename-registers
ddf6fe37 14903@item -frename-registers
d77de738
ML
14904Attempt to avoid false dependencies in scheduled code by making use
14905of registers left over after register allocation. This optimization
14906most benefits processors with lots of registers. Depending on the
14907debug information format adopted by the target, however, it can
14908make debugging impossible, since variables no longer stay in
14909a ``home register''.
14910
14911Enabled by default with @option{-funroll-loops}.
14912
d77de738 14913@opindex fschedule-fusion
ddf6fe37 14914@item -fschedule-fusion
d77de738
ML
14915Performs a target dependent pass over the instruction stream to schedule
14916instructions of same type together because target machine can execute them
14917more efficiently if they are adjacent to each other in the instruction flow.
14918
14919Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14920
d77de738 14921@opindex ftracer
ddf6fe37 14922@item -ftracer
d77de738
ML
14923Perform tail duplication to enlarge superblock size. This transformation
14924simplifies the control flow of the function allowing other optimizations to do
14925a better job.
14926
14927Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14928
d77de738 14929@opindex funroll-loops
ddf6fe37 14930@item -funroll-loops
d77de738
ML
14931Unroll loops whose number of iterations can be determined at compile time or
14932upon entry to the loop. @option{-funroll-loops} implies
14933@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14934It also turns on complete loop peeling (i.e.@: complete removal of loops with
14935a small constant number of iterations). This option makes code larger, and may
14936or may not make it run faster.
14937
14938Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14939
d77de738 14940@opindex funroll-all-loops
ddf6fe37 14941@item -funroll-all-loops
d77de738
ML
14942Unroll all loops, even if their number of iterations is uncertain when
14943the loop is entered. This usually makes programs run more slowly.
14944@option{-funroll-all-loops} implies the same options as
14945@option{-funroll-loops}.
14946
d77de738 14947@opindex fpeel-loops
ddf6fe37 14948@item -fpeel-loops
d77de738
ML
14949Peels loops for which there is enough information that they do not
14950roll much (from profile feedback or static analysis). It also turns on
14951complete loop peeling (i.e.@: complete removal of loops with small constant
14952number of iterations).
14953
14954Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14955
d77de738 14956@opindex fmove-loop-invariants
ddf6fe37 14957@item -fmove-loop-invariants
d77de738
ML
14958Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14959at level @option{-O1} and higher, except for @option{-Og}.
14960
d77de738 14961@opindex fmove-loop-stores
ddf6fe37 14962@item -fmove-loop-stores
d77de738
ML
14963Enables the loop store motion pass in the GIMPLE loop optimizer. This
14964moves invariant stores to after the end of the loop in exchange for
14965carrying the stored value in a register across the iteration.
14966Note for this option to have an effect @option{-ftree-loop-im} has to
14967be enabled as well. Enabled at level @option{-O1} and higher, except
14968for @option{-Og}.
14969
d77de738 14970@opindex fsplit-loops
ddf6fe37 14971@item -fsplit-loops
d77de738
ML
14972Split a loop into two if it contains a condition that's always true
14973for one side of the iteration space and false for the other.
14974
14975Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14976
d77de738 14977@opindex funswitch-loops
ddf6fe37 14978@item -funswitch-loops
d77de738
ML
14979Move branches with loop invariant conditions out of the loop, with duplicates
14980of the loop on both branches (modified according to result of the condition).
14981
14982Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14983
d77de738 14984@opindex fversion-loops-for-strides
ddf6fe37 14985@item -fversion-loops-for-strides
d77de738
ML
14986If a loop iterates over an array with a variable stride, create another
14987version of the loop that assumes the stride is always one. For example:
14988
14989@smallexample
14990for (int i = 0; i < n; ++i)
14991 x[i * stride] = @dots{};
14992@end smallexample
14993
14994becomes:
14995
14996@smallexample
14997if (stride == 1)
14998 for (int i = 0; i < n; ++i)
14999 x[i] = @dots{};
15000else
15001 for (int i = 0; i < n; ++i)
15002 x[i * stride] = @dots{};
15003@end smallexample
15004
15005This is particularly useful for assumed-shape arrays in Fortran where
15006(for example) it allows better vectorization assuming contiguous accesses.
15007This flag is enabled by default at @option{-O3}.
15008It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15009
d77de738
ML
15010@opindex ffunction-sections
15011@opindex fdata-sections
ddf6fe37
AA
15012@item -ffunction-sections
15013@itemx -fdata-sections
d77de738
ML
15014Place each function or data item into its own section in the output
15015file if the target supports arbitrary sections. The name of the
15016function or the name of the data item determines the section's name
15017in the output file.
15018
15019Use these options on systems where the linker can perform optimizations to
15020improve locality of reference in the instruction space. Most systems using the
15021ELF object format have linkers with such optimizations. On AIX, the linker
15022rearranges sections (CSECTs) based on the call graph. The performance impact
15023varies.
15024
15025Together with a linker garbage collection (linker @option{--gc-sections}
15026option) these options may lead to smaller statically-linked executables (after
15027stripping).
15028
15029On ELF/DWARF systems these options do not degenerate the quality of the debug
15030information. There could be issues with other object files/debug info formats.
15031
15032Only use these options when there are significant benefits from doing so. When
15033you specify these options, the assembler and linker create larger object and
15034executable files and are also slower. These options affect code generation.
15035They prevent optimizations by the compiler and assembler using relative
15036locations inside a translation unit since the locations are unknown until
15037link time. An example of such an optimization is relaxing calls to short call
15038instructions.
15039
d77de738 15040@opindex fstdarg-opt
ddf6fe37 15041@item -fstdarg-opt
d77de738
ML
15042Optimize the prologue of variadic argument functions with respect to usage of
15043those arguments.
15044
d77de738 15045@opindex fsection-anchors
ddf6fe37 15046@item -fsection-anchors
d77de738
ML
15047Try to reduce the number of symbolic address calculations by using
15048shared ``anchor'' symbols to address nearby objects. This transformation
15049can help to reduce the number of GOT entries and GOT accesses on some
15050targets.
15051
15052For example, the implementation of the following function @code{foo}:
15053
15054@smallexample
15055static int a, b, c;
15056int foo (void) @{ return a + b + c; @}
15057@end smallexample
15058
15059@noindent
15060usually calculates the addresses of all three variables, but if you
15061compile it with @option{-fsection-anchors}, it accesses the variables
15062from a common anchor point instead. The effect is similar to the
15063following pseudocode (which isn't valid C):
15064
15065@smallexample
15066int foo (void)
15067@{
15068 register int *xr = &x;
15069 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
15070@}
15071@end smallexample
15072
15073Not all targets support this option.
15074
d77de738 15075@opindex fzero-call-used-regs
ddf6fe37 15076@item -fzero-call-used-regs=@var{choice}
d77de738
ML
15077Zero call-used registers at function return to increase program
15078security by either mitigating Return-Oriented Programming (ROP)
15079attacks or preventing information leakage through registers.
15080
15081The possible values of @var{choice} are the same as for the
15082@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
15083The default is @samp{skip}.
15084
15085You can control this behavior for a specific function by using the function
15086attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
15087
d77de738 15088@opindex param
ddf6fe37 15089@item --param @var{name}=@var{value}
d77de738
ML
15090In some places, GCC uses various constants to control the amount of
15091optimization that is done. For example, GCC does not inline functions
15092that contain more than a certain number of instructions. You can
15093control some of these constants on the command line using the
15094@option{--param} option.
15095
15096The names of specific parameters, and the meaning of the values, are
15097tied to the internals of the compiler, and are subject to change
15098without notice in future releases.
15099
c381327d
GP
15100In order to get the minimal, maximal and default values of a parameter,
15101use the @option{--help=param -Q} options.
d77de738
ML
15102
15103In each case, the @var{value} is an integer. The following choices
15104of @var{name} are recognized for all targets:
15105
15106@table @gcctabopt
15107@item predictable-branch-outcome
15108When branch is predicted to be taken with probability lower than this threshold
15109(in percent), then it is considered well predictable.
15110
15111@item max-rtl-if-conversion-insns
15112RTL if-conversion tries to remove conditional branches around a block and
15113replace them with conditionally executed instructions. This parameter
15114gives the maximum number of instructions in a block which should be
15115considered for if-conversion. The compiler will
15116also use other heuristics to decide whether if-conversion is likely to be
15117profitable.
15118
15119@item max-rtl-if-conversion-predictable-cost
15120RTL if-conversion will try to remove conditional branches around a block
15121and replace them with conditionally executed instructions. These parameters
15122give the maximum permissible cost for the sequence that would be generated
15123by if-conversion depending on whether the branch is statically determined
15124to be predictable or not. The units for this parameter are the same as
15125those for the GCC internal seq_cost metric. The compiler will try to
15126provide a reasonable default for this parameter using the BRANCH_COST
15127target macro.
15128
15129@item max-crossjump-edges
15130The maximum number of incoming edges to consider for cross-jumping.
15131The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
15132the number of edges incoming to each block. Increasing values mean
15133more aggressive optimization, making the compilation time increase with
15134probably small improvement in executable size.
15135
15136@item min-crossjump-insns
15137The minimum number of instructions that must be matched at the end
15138of two blocks before cross-jumping is performed on them. This
15139value is ignored in the case where all instructions in the block being
15140cross-jumped from are matched.
15141
15142@item max-grow-copy-bb-insns
15143The maximum code size expansion factor when copying basic blocks
15144instead of jumping. The expansion is relative to a jump instruction.
15145
15146@item max-goto-duplication-insns
15147The maximum number of instructions to duplicate to a block that jumps
15148to a computed goto. To avoid @math{O(N^2)} behavior in a number of
15149passes, GCC factors computed gotos early in the compilation process,
15150and unfactors them as late as possible. Only computed jumps at the
15151end of a basic blocks with no more than max-goto-duplication-insns are
15152unfactored.
15153
15154@item max-delay-slot-insn-search
15155The maximum number of instructions to consider when looking for an
15156instruction to fill a delay slot. If more than this arbitrary number of
15157instructions are searched, the time savings from filling the delay slot
15158are minimal, so stop searching. Increasing values mean more
15159aggressive optimization, making the compilation time increase with probably
15160small improvement in execution time.
15161
15162@item max-delay-slot-live-search
15163When trying to fill delay slots, the maximum number of instructions to
15164consider when searching for a block with valid live register
15165information. Increasing this arbitrarily chosen value means more
15166aggressive optimization, increasing the compilation time. This parameter
15167should be removed when the delay slot code is rewritten to maintain the
15168control-flow graph.
15169
15170@item max-gcse-memory
15171The approximate maximum amount of memory in @code{kB} that can be allocated in
15172order to perform the global common subexpression elimination
15173optimization. If more memory than specified is required, the
15174optimization is not done.
15175
15176@item max-gcse-insertion-ratio
15177If the ratio of expression insertions to deletions is larger than this value
15178for any expression, then RTL PRE inserts or removes the expression and thus
15179leaves partially redundant computations in the instruction stream.
15180
15181@item max-pending-list-length
15182The maximum number of pending dependencies scheduling allows
15183before flushing the current state and starting over. Large functions
15184with few branches or calls can create excessively large lists which
15185needlessly consume memory and resources.
15186
15187@item max-modulo-backtrack-attempts
15188The maximum number of backtrack attempts the scheduler should make
15189when modulo scheduling a loop. Larger values can exponentially increase
15190compilation time.
15191
15192@item max-inline-functions-called-once-loop-depth
15193Maximal loop depth of a call considered by inline heuristics that tries to
15194inline all functions called once.
15195
15196@item max-inline-functions-called-once-insns
15197Maximal estimated size of functions produced while inlining functions called
15198once.
15199
15200@item max-inline-insns-single
15201Several parameters control the tree inliner used in GCC@. This number sets the
15202maximum number of instructions (counted in GCC's internal representation) in a
15203single function that the tree inliner considers for inlining. This only
15204affects functions declared inline and methods implemented in a class
15205declaration (C++).
15206
15207
15208@item max-inline-insns-auto
15209When you use @option{-finline-functions} (included in @option{-O3}),
15210a lot of functions that would otherwise not be considered for inlining
15211by the compiler are investigated. To those functions, a different
15212(more restrictive) limit compared to functions declared inline can
15213be applied (@option{--param max-inline-insns-auto}).
15214
15215@item max-inline-insns-small
15216This is bound applied to calls which are considered relevant with
15217@option{-finline-small-functions}.
15218
15219@item max-inline-insns-size
15220This is bound applied to calls which are optimized for size. Small growth
15221may be desirable to anticipate optimization oppurtunities exposed by inlining.
15222
15223@item uninlined-function-insns
15224Number of instructions accounted by inliner for function overhead such as
15225function prologue and epilogue.
15226
15227@item uninlined-function-time
15228Extra time accounted by inliner for function overhead such as time needed to
15229execute function prologue and epilogue.
15230
15231@item inline-heuristics-hint-percent
15232The scale (in percents) applied to @option{inline-insns-single},
15233@option{inline-insns-single-O2}, @option{inline-insns-auto}
15234when inline heuristics hints that inlining is
15235very profitable (will enable later optimizations).
15236
15237@item uninlined-thunk-insns
15238@item uninlined-thunk-time
15239Same as @option{--param uninlined-function-insns} and
15240@option{--param uninlined-function-time} but applied to function thunks.
15241
15242@item inline-min-speedup
15243When estimated performance improvement of caller + callee runtime exceeds this
15244threshold (in percent), the function can be inlined regardless of the limit on
15245@option{--param max-inline-insns-single} and @option{--param
15246max-inline-insns-auto}.
15247
15248@item large-function-insns
15249The limit specifying really large functions. For functions larger than this
15250limit after inlining, inlining is constrained by
15251@option{--param large-function-growth}. This parameter is useful primarily
15252to avoid extreme compilation time caused by non-linear algorithms used by the
15253back end.
15254
15255@item large-function-growth
15256Specifies maximal growth of large function caused by inlining in percents.
15257For example, parameter value 100 limits large function growth to 2.0 times
15258the original size.
15259
15260@item large-unit-insns
15261The limit specifying large translation unit. Growth caused by inlining of
15262units larger than this limit is limited by @option{--param inline-unit-growth}.
15263For small units this might be too tight.
15264For example, consider a unit consisting of function A
15265that is inline and B that just calls A three times. If B is small relative to
15266A, the growth of unit is 300\% and yet such inlining is very sane. For very
15267large units consisting of small inlineable functions, however, the overall unit
15268growth limit is needed to avoid exponential explosion of code size. Thus for
15269smaller units, the size is increased to @option{--param large-unit-insns}
15270before applying @option{--param inline-unit-growth}.
15271
15272@item lazy-modules
15273Maximum number of concurrently open C++ module files when lazy loading.
15274
15275@item inline-unit-growth
15276Specifies maximal overall growth of the compilation unit caused by inlining.
15277For example, parameter value 20 limits unit growth to 1.2 times the original
15278size. Cold functions (either marked cold via an attribute or by profile
15279feedback) are not accounted into the unit size.
15280
15281@item ipa-cp-unit-growth
15282Specifies maximal overall growth of the compilation unit caused by
15283interprocedural constant propagation. For example, parameter value 10 limits
15284unit growth to 1.1 times the original size.
15285
15286@item ipa-cp-large-unit-insns
15287The size of translation unit that IPA-CP pass considers large.
15288
15289@item large-stack-frame
15290The limit specifying large stack frames. While inlining the algorithm is trying
15291to not grow past this limit too much.
15292
15293@item large-stack-frame-growth
15294Specifies maximal growth of large stack frames caused by inlining in percents.
15295For example, parameter value 1000 limits large stack frame growth to 11 times
15296the original size.
15297
15298@item max-inline-insns-recursive
15299@itemx max-inline-insns-recursive-auto
15300Specifies the maximum number of instructions an out-of-line copy of a
15301self-recursive inline
15302function can grow into by performing recursive inlining.
15303
15304@option{--param max-inline-insns-recursive} applies to functions
15305declared inline.
15306For functions not declared inline, recursive inlining
15307happens only when @option{-finline-functions} (included in @option{-O3}) is
15308enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15309
15310@item max-inline-recursive-depth
15311@itemx max-inline-recursive-depth-auto
15312Specifies the maximum recursion depth used for recursive inlining.
15313
15314@option{--param max-inline-recursive-depth} applies to functions
15315declared inline. For functions not declared inline, recursive inlining
15316happens only when @option{-finline-functions} (included in @option{-O3}) is
15317enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15318
15319@item min-inline-recursive-probability
15320Recursive inlining is profitable only for function having deep recursion
15321in average and can hurt for function having little recursion depth by
15322increasing the prologue size or complexity of function body to other
15323optimizers.
15324
15325When profile feedback is available (see @option{-fprofile-generate}) the actual
15326recursion depth can be guessed from the probability that function recurses
15327via a given call expression. This parameter limits inlining only to call
15328expressions whose probability exceeds the given threshold (in percents).
15329
15330@item early-inlining-insns
15331Specify growth that the early inliner can make. In effect it increases
15332the amount of inlining for code having a large abstraction penalty.
15333
15334@item max-early-inliner-iterations
15335Limit of iterations of the early inliner. This basically bounds
15336the number of nested indirect calls the early inliner can resolve.
15337Deeper chains are still handled by late inlining.
15338
15339@item comdat-sharing-probability
15340Probability (in percent) that C++ inline function with comdat visibility
15341are shared across multiple compilation units.
15342
15343@item modref-max-bases
15344@item modref-max-refs
15345@item modref-max-accesses
15346Specifies the maximal number of base pointers, references and accesses stored
15347for a single function by mod/ref analysis.
15348
15349@item modref-max-tests
15350Specifies the maxmal number of tests alias oracle can perform to disambiguate
15351memory locations using the mod/ref information. This parameter ought to be
15352bigger than @option{--param modref-max-bases} and @option{--param
15353modref-max-refs}.
15354
15355@item modref-max-depth
15356Specifies the maximum depth of DFS walk used by modref escape analysis.
15357Setting to 0 disables the analysis completely.
15358
15359@item modref-max-escape-points
15360Specifies the maximum number of escape points tracked by modref per SSA-name.
15361
15362@item modref-max-adjustments
15363Specifies the maximum number the access range is enlarged during modref dataflow
15364analysis.
15365
15366@item profile-func-internal-id
15367A parameter to control whether to use function internal id in profile
15368database lookup. If the value is 0, the compiler uses an id that
15369is based on function assembler name and filename, which makes old profile
15370data more tolerant to source changes such as function reordering etc.
15371
15372@item min-vect-loop-bound
15373The minimum number of iterations under which loops are not vectorized
15374when @option{-ftree-vectorize} is used. The number of iterations after
15375vectorization needs to be greater than the value specified by this option
15376to allow vectorization.
15377
15378@item gcse-cost-distance-ratio
15379Scaling factor in calculation of maximum distance an expression
15380can be moved by GCSE optimizations. This is currently supported only in the
15381code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15382is with simple expressions, i.e., the expressions that have cost
15383less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15384hoisting of simple expressions.
15385
15386@item gcse-unrestricted-cost
15387Cost, roughly measured as the cost of a single typical machine
15388instruction, at which GCSE optimizations do not constrain
15389the distance an expression can travel. This is currently
15390supported only in the code hoisting pass. The lesser the cost,
15391the more aggressive code hoisting is. Specifying 0
15392allows all expressions to travel unrestricted distances.
15393
15394@item max-hoist-depth
15395The depth of search in the dominator tree for expressions to hoist.
15396This is used to avoid quadratic behavior in hoisting algorithm.
15397The value of 0 does not limit on the search, but may slow down compilation
15398of huge functions.
15399
15400@item max-tail-merge-comparisons
15401The maximum amount of similar bbs to compare a bb with. This is used to
15402avoid quadratic behavior in tree tail merging.
15403
15404@item max-tail-merge-iterations
15405The maximum amount of iterations of the pass over the function. This is used to
15406limit compilation time in tree tail merging.
15407
15408@item store-merging-allow-unaligned
15409Allow the store merging pass to introduce unaligned stores if it is legal to
15410do so.
15411
15412@item max-stores-to-merge
15413The maximum number of stores to attempt to merge into wider stores in the store
15414merging pass.
15415
15416@item max-store-chains-to-track
15417The maximum number of store chains to track at the same time in the attempt
15418to merge them into wider stores in the store merging pass.
15419
15420@item max-stores-to-track
15421The maximum number of stores to track at the same time in the attemt to
15422to merge them into wider stores in the store merging pass.
15423
15424@item max-unrolled-insns
15425The maximum number of instructions that a loop may have to be unrolled.
15426If a loop is unrolled, this parameter also determines how many times
15427the loop code is unrolled.
15428
15429@item max-average-unrolled-insns
15430The maximum number of instructions biased by probabilities of their execution
15431that a loop may have to be unrolled. If a loop is unrolled,
15432this parameter also determines how many times the loop code is unrolled.
15433
15434@item max-unroll-times
15435The maximum number of unrollings of a single loop.
15436
15437@item max-peeled-insns
15438The maximum number of instructions that a loop may have to be peeled.
15439If a loop is peeled, this parameter also determines how many times
15440the loop code is peeled.
15441
15442@item max-peel-times
15443The maximum number of peelings of a single loop.
15444
15445@item max-peel-branches
15446The maximum number of branches on the hot path through the peeled sequence.
15447
15448@item max-completely-peeled-insns
15449The maximum number of insns of a completely peeled loop.
15450
15451@item max-completely-peel-times
15452The maximum number of iterations of a loop to be suitable for complete peeling.
15453
15454@item max-completely-peel-loop-nest-depth
15455The maximum depth of a loop nest suitable for complete peeling.
15456
15457@item max-unswitch-insns
15458The maximum number of insns of an unswitched loop.
15459
5b50850c
RB
15460@item max-unswitch-depth
15461The maximum depth of a loop nest to be unswitched.
15462
d77de738
ML
15463@item lim-expensive
15464The minimum cost of an expensive expression in the loop invariant motion.
15465
15466@item min-loop-cond-split-prob
15467When FDO profile information is available, @option{min-loop-cond-split-prob}
15468specifies minimum threshold for probability of semi-invariant condition
15469statement to trigger loop split.
15470
15471@item iv-consider-all-candidates-bound
15472Bound on number of candidates for induction variables, below which
15473all candidates are considered for each use in induction variable
15474optimizations. If there are more candidates than this,
15475only the most relevant ones are considered to avoid quadratic time complexity.
15476
15477@item iv-max-considered-uses
15478The induction variable optimizations give up on loops that contain more
15479induction variable uses.
15480
15481@item iv-always-prune-cand-set-bound
15482If the number of candidates in the set is smaller than this value,
15483always try to remove unnecessary ivs from the set
15484when adding a new one.
15485
15486@item avg-loop-niter
15487Average number of iterations of a loop.
15488
15489@item dse-max-object-size
15490Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15491Larger values may result in larger compilation times.
15492
15493@item dse-max-alias-queries-per-store
15494Maximum number of queries into the alias oracle per store.
15495Larger values result in larger compilation times and may result in more
15496removed dead stores.
15497
15498@item scev-max-expr-size
15499Bound on size of expressions used in the scalar evolutions analyzer.
15500Large expressions slow the analyzer.
15501
15502@item scev-max-expr-complexity
15503Bound on the complexity of the expressions in the scalar evolutions analyzer.
15504Complex expressions slow the analyzer.
15505
15506@item max-tree-if-conversion-phi-args
15507Maximum number of arguments in a PHI supported by TREE if conversion
15508unless the loop is marked with simd pragma.
15509
15510@item vect-max-layout-candidates
15511The maximum number of possible vector layouts (such as permutations)
15512to consider when optimizing to-be-vectorized code.
15513
15514@item vect-max-version-for-alignment-checks
15515The maximum number of run-time checks that can be performed when
15516doing loop versioning for alignment in the vectorizer.
15517
15518@item vect-max-version-for-alias-checks
15519The maximum number of run-time checks that can be performed when
15520doing loop versioning for alias in the vectorizer.
15521
15522@item vect-max-peeling-for-alignment
15523The maximum number of loop peels to enhance access alignment
15524for vectorizer. Value -1 means no limit.
15525
15526@item max-iterations-to-track
15527The maximum number of iterations of a loop the brute-force algorithm
15528for analysis of the number of iterations of the loop tries to evaluate.
15529
15530@item hot-bb-count-fraction
15531The denominator n of fraction 1/n of the maximal execution count of a
15532basic block in the entire program that a basic block needs to at least
15533have in order to be considered hot. The default is 10000, which means
15534that a basic block is considered hot if its execution count is greater
15535than 1/10000 of the maximal execution count. 0 means that it is never
15536considered hot. Used in non-LTO mode.
15537
15538@item hot-bb-count-ws-permille
15539The number of most executed permilles, ranging from 0 to 1000, of the
15540profiled execution of the entire program to which the execution count
15541of a basic block must be part of in order to be considered hot. The
15542default is 990, which means that a basic block is considered hot if
15543its execution count contributes to the upper 990 permilles, or 99.0%,
15544of the profiled execution of the entire program. 0 means that it is
15545never considered hot. Used in LTO mode.
15546
15547@item hot-bb-frequency-fraction
15548The denominator n of fraction 1/n of the execution frequency of the
15549entry block of a function that a basic block of this function needs
15550to at least have in order to be considered hot. The default is 1000,
15551which means that a basic block is considered hot in a function if it
15552is executed more frequently than 1/1000 of the frequency of the entry
15553block of the function. 0 means that it is never considered hot.
15554
15555@item unlikely-bb-count-fraction
15556The denominator n of fraction 1/n of the number of profiled runs of
15557the entire program below which the execution count of a basic block
15558must be in order for the basic block to be considered unlikely executed.
15559The default is 20, which means that a basic block is considered unlikely
15560executed if it is executed in fewer than 1/20, or 5%, of the runs of
15561the program. 0 means that it is always considered unlikely executed.
15562
15563@item max-predicted-iterations
15564The maximum number of loop iterations we predict statically. This is useful
15565in cases where a function contains a single loop with known bound and
15566another loop with unknown bound.
15567The known number of iterations is predicted correctly, while
15568the unknown number of iterations average to roughly 10. This means that the
15569loop without bounds appears artificially cold relative to the other one.
15570
15571@item builtin-expect-probability
15572Control the probability of the expression having the specified value. This
15573parameter takes a percentage (i.e.@: 0 ... 100) as input.
15574
15575@item builtin-string-cmp-inline-length
15576The maximum length of a constant string for a builtin string cmp call
15577eligible for inlining.
15578
15579@item align-threshold
15580
15581Select fraction of the maximal frequency of executions of a basic block in
15582a function to align the basic block.
15583
15584@item align-loop-iterations
15585
15586A loop expected to iterate at least the selected number of iterations is
15587aligned.
15588
15589@item tracer-dynamic-coverage
15590@itemx tracer-dynamic-coverage-feedback
15591
15592This value is used to limit superblock formation once the given percentage of
15593executed instructions is covered. This limits unnecessary code size
15594expansion.
15595
15596The @option{tracer-dynamic-coverage-feedback} parameter
15597is used only when profile
15598feedback is available. The real profiles (as opposed to statically estimated
15599ones) are much less balanced allowing the threshold to be larger value.
15600
15601@item tracer-max-code-growth
15602Stop tail duplication once code growth has reached given percentage. This is
15603a rather artificial limit, as most of the duplicates are eliminated later in
15604cross jumping, so it may be set to much higher values than is the desired code
15605growth.
15606
15607@item tracer-min-branch-ratio
15608
15609Stop reverse growth when the reverse probability of best edge is less than this
15610threshold (in percent).
15611
15612@item tracer-min-branch-probability
15613@itemx tracer-min-branch-probability-feedback
15614
15615Stop forward growth if the best edge has probability lower than this
15616threshold.
15617
15618Similarly to @option{tracer-dynamic-coverage} two parameters are
15619provided. @option{tracer-min-branch-probability-feedback} is used for
15620compilation with profile feedback and @option{tracer-min-branch-probability}
15621compilation without. The value for compilation with profile feedback
15622needs to be more conservative (higher) in order to make tracer
15623effective.
15624
15625@item stack-clash-protection-guard-size
15626Specify the size of the operating system provided stack guard as
156272 raised to @var{num} bytes. Higher values may reduce the
15628number of explicit probes, but a value larger than the operating system
15629provided guard will leave code vulnerable to stack clash style attacks.
15630
15631@item stack-clash-protection-probe-interval
15632Stack clash protection involves probing stack space as it is allocated. This
15633param controls the maximum distance between probes into the stack as 2 raised
15634to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15635larger than the operating system provided guard will leave code vulnerable to
15636stack clash style attacks.
15637
15638@item max-cse-path-length
15639
15640The maximum number of basic blocks on path that CSE considers.
15641
15642@item max-cse-insns
15643The maximum number of instructions CSE processes before flushing.
15644
15645@item ggc-min-expand
15646
15647GCC uses a garbage collector to manage its own memory allocation. This
15648parameter specifies the minimum percentage by which the garbage
15649collector's heap should be allowed to expand between collections.
15650Tuning this may improve compilation speed; it has no effect on code
15651generation.
15652
15653The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15654RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15655the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15656GCC is not able to calculate RAM on a particular platform, the lower
15657bound of 30% is used. Setting this parameter and
15658@option{ggc-min-heapsize} to zero causes a full collection to occur at
15659every opportunity. This is extremely slow, but can be useful for
15660debugging.
15661
15662@item ggc-min-heapsize
15663
15664Minimum size of the garbage collector's heap before it begins bothering
15665to collect garbage. The first collection occurs after the heap expands
15666by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15667tuning this may improve compilation speed, and has no effect on code
15668generation.
15669
15670The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15671tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15672with a lower bound of 4096 (four megabytes) and an upper bound of
15673131072 (128 megabytes). If GCC is not able to calculate RAM on a
15674particular platform, the lower bound is used. Setting this parameter
15675very large effectively disables garbage collection. Setting this
15676parameter and @option{ggc-min-expand} to zero causes a full collection
15677to occur at every opportunity.
15678
15679@item max-reload-search-insns
15680The maximum number of instruction reload should look backward for equivalent
15681register. Increasing values mean more aggressive optimization, making the
15682compilation time increase with probably slightly better performance.
15683
15684@item max-cselib-memory-locations
15685The maximum number of memory locations cselib should take into account.
15686Increasing values mean more aggressive optimization, making the compilation time
15687increase with probably slightly better performance.
15688
15689@item max-sched-ready-insns
15690The maximum number of instructions ready to be issued the scheduler should
15691consider at any given time during the first scheduling pass. Increasing
15692values mean more thorough searches, making the compilation time increase
15693with probably little benefit.
15694
15695@item max-sched-region-blocks
15696The maximum number of blocks in a region to be considered for
15697interblock scheduling.
15698
15699@item max-pipeline-region-blocks
15700The maximum number of blocks in a region to be considered for
15701pipelining in the selective scheduler.
15702
15703@item max-sched-region-insns
15704The maximum number of insns in a region to be considered for
15705interblock scheduling.
15706
15707@item max-pipeline-region-insns
15708The maximum number of insns in a region to be considered for
15709pipelining in the selective scheduler.
15710
15711@item min-spec-prob
15712The minimum probability (in percents) of reaching a source block
15713for interblock speculative scheduling.
15714
15715@item max-sched-extend-regions-iters
15716The maximum number of iterations through CFG to extend regions.
15717A value of 0 disables region extensions.
15718
15719@item max-sched-insn-conflict-delay
15720The maximum conflict delay for an insn to be considered for speculative motion.
15721
15722@item sched-spec-prob-cutoff
15723The minimal probability of speculation success (in percents), so that
15724speculative insns are scheduled.
15725
15726@item sched-state-edge-prob-cutoff
15727The minimum probability an edge must have for the scheduler to save its
15728state across it.
15729
15730@item sched-mem-true-dep-cost
15731Minimal distance (in CPU cycles) between store and load targeting same
15732memory locations.
15733
15734@item selsched-max-lookahead
15735The maximum size of the lookahead window of selective scheduling. It is a
15736depth of search for available instructions.
15737
15738@item selsched-max-sched-times
15739The maximum number of times that an instruction is scheduled during
15740selective scheduling. This is the limit on the number of iterations
15741through which the instruction may be pipelined.
15742
15743@item selsched-insns-to-rename
15744The maximum number of best instructions in the ready list that are considered
15745for renaming in the selective scheduler.
15746
15747@item sms-min-sc
15748The minimum value of stage count that swing modulo scheduler
15749generates.
15750
15751@item max-last-value-rtl
15752The maximum size measured as number of RTLs that can be recorded in an expression
15753in combiner for a pseudo register as last known value of that register.
15754
15755@item max-combine-insns
15756The maximum number of instructions the RTL combiner tries to combine.
15757
15758@item integer-share-limit
15759Small integer constants can use a shared data structure, reducing the
15760compiler's memory usage and increasing its speed. This sets the maximum
15761value of a shared integer constant.
15762
15763@item ssp-buffer-size
15764The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15765protection when @option{-fstack-protector} is used.
15766
15767@item min-size-for-stack-sharing
15768The minimum size of variables taking part in stack slot sharing when not
15769optimizing.
15770
15771@item max-jump-thread-duplication-stmts
15772Maximum number of statements allowed in a block that needs to be
15773duplicated when threading jumps.
15774
15775@item max-jump-thread-paths
15776The maximum number of paths to consider when searching for jump threading
15777opportunities. When arriving at a block, incoming edges are only considered
15778if the number of paths to be searched so far multiplied by the number of
15779incoming edges does not exhaust the specified maximum number of paths to
15780consider.
15781
15782@item max-fields-for-field-sensitive
15783Maximum number of fields in a structure treated in
15784a field sensitive manner during pointer analysis.
15785
15786@item prefetch-latency
15787Estimate on average number of instructions that are executed before
15788prefetch finishes. The distance prefetched ahead is proportional
15789to this constant. Increasing this number may also lead to less
15790streams being prefetched (see @option{simultaneous-prefetches}).
15791
15792@item simultaneous-prefetches
15793Maximum number of prefetches that can run at the same time.
15794
15795@item l1-cache-line-size
15796The size of cache line in L1 data cache, in bytes.
15797
15798@item l1-cache-size
15799The size of L1 data cache, in kilobytes.
15800
15801@item l2-cache-size
15802The size of L2 data cache, in kilobytes.
15803
15804@item prefetch-dynamic-strides
15805Whether the loop array prefetch pass should issue software prefetch hints
15806for strides that are non-constant. In some cases this may be
15807beneficial, though the fact the stride is non-constant may make it
15808hard to predict when there is clear benefit to issuing these hints.
15809
15810Set to 1 if the prefetch hints should be issued for non-constant
15811strides. Set to 0 if prefetch hints should be issued only for strides that
15812are known to be constant and below @option{prefetch-minimum-stride}.
15813
15814@item prefetch-minimum-stride
15815Minimum constant stride, in bytes, to start using prefetch hints for. If
15816the stride is less than this threshold, prefetch hints will not be issued.
15817
15818This setting is useful for processors that have hardware prefetchers, in
15819which case there may be conflicts between the hardware prefetchers and
15820the software prefetchers. If the hardware prefetchers have a maximum
15821stride they can handle, it should be used here to improve the use of
15822software prefetchers.
15823
15824A value of -1 means we don't have a threshold and therefore
15825prefetch hints can be issued for any constant stride.
15826
15827This setting is only useful for strides that are known and constant.
15828
15829@item destructive-interference-size
15830@item constructive-interference-size
15831The values for the C++17 variables
15832@code{std::hardware_destructive_interference_size} and
15833@code{std::hardware_constructive_interference_size}. The destructive
15834interference size is the minimum recommended offset between two
15835independent concurrently-accessed objects; the constructive
15836interference size is the maximum recommended size of contiguous memory
15837accessed together. Typically both will be the size of an L1 cache
15838line for the target, in bytes. For a generic target covering a range of L1
15839cache line sizes, typically the constructive interference size will be
15840the small end of the range and the destructive size will be the large
15841end.
15842
15843The destructive interference size is intended to be used for layout,
15844and thus has ABI impact. The default value is not expected to be
15845stable, and on some targets varies with @option{-mtune}, so use of
15846this variable in a context where ABI stability is important, such as
15847the public interface of a library, is strongly discouraged; if it is
15848used in that context, users can stabilize the value using this
15849option.
15850
15851The constructive interference size is less sensitive, as it is
15852typically only used in a @samp{static_assert} to make sure that a type
15853fits within a cache line.
15854
15855See also @option{-Winterference-size}.
15856
15857@item loop-interchange-max-num-stmts
15858The maximum number of stmts in a loop to be interchanged.
15859
15860@item loop-interchange-stride-ratio
15861The minimum ratio between stride of two loops for interchange to be profitable.
15862
15863@item min-insn-to-prefetch-ratio
15864The minimum ratio between the number of instructions and the
15865number of prefetches to enable prefetching in a loop.
15866
15867@item prefetch-min-insn-to-mem-ratio
15868The minimum ratio between the number of instructions and the
15869number of memory references to enable prefetching in a loop.
15870
15871@item use-canonical-types
15872Whether the compiler should use the ``canonical'' type system.
15873Should always be 1, which uses a more efficient internal
15874mechanism for comparing types in C++ and Objective-C++. However, if
15875bugs in the canonical type system are causing compilation failures,
15876set this value to 0 to disable canonical types.
15877
15878@item switch-conversion-max-branch-ratio
15879Switch initialization conversion refuses to create arrays that are
15880bigger than @option{switch-conversion-max-branch-ratio} times the number of
15881branches in the switch.
15882
15883@item max-partial-antic-length
15884Maximum length of the partial antic set computed during the tree
15885partial redundancy elimination optimization (@option{-ftree-pre}) when
15886optimizing at @option{-O3} and above. For some sorts of source code
15887the enhanced partial redundancy elimination optimization can run away,
15888consuming all of the memory available on the host machine. This
15889parameter sets a limit on the length of the sets that are computed,
15890which prevents the runaway behavior. Setting a value of 0 for
15891this parameter allows an unlimited set length.
15892
15893@item rpo-vn-max-loop-depth
15894Maximum loop depth that is value-numbered optimistically.
15895When the limit hits the innermost
15896@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15897loop nest are value-numbered optimistically and the remaining ones not.
15898
15899@item sccvn-max-alias-queries-per-access
15900Maximum number of alias-oracle queries we perform when looking for
15901redundancies for loads and stores. If this limit is hit the search
15902is aborted and the load or store is not considered redundant. The
15903number of queries is algorithmically limited to the number of
15904stores on all paths from the load to the function entry.
15905
15906@item ira-max-loops-num
15907IRA uses regional register allocation by default. If a function
15908contains more loops than the number given by this parameter, only at most
15909the given number of the most frequently-executed loops form regions
15910for regional register allocation.
15911
15912@item ira-max-conflict-table-size
15913Although IRA uses a sophisticated algorithm to compress the conflict
15914table, the table can still require excessive amounts of memory for
15915huge functions. If the conflict table for a function could be more
15916than the size in MB given by this parameter, the register allocator
15917instead uses a faster, simpler, and lower-quality
15918algorithm that does not require building a pseudo-register conflict table.
15919
15920@item ira-loop-reserved-regs
15921IRA can be used to evaluate more accurate register pressure in loops
15922for decisions to move loop invariants (see @option{-O3}). The number
15923of available registers reserved for some other purposes is given
15924by this parameter. Default of the parameter
15925is the best found from numerous experiments.
15926
15927@item ira-consider-dup-in-all-alts
15928Make IRA to consider matching constraint (duplicated operand number)
15929heavily in all available alternatives for preferred register class.
15930If it is set as zero, it means IRA only respects the matching
15931constraint when it's in the only available alternative with an
15932appropriate register class. Otherwise, it means IRA will check all
15933available alternatives for preferred register class even if it has
15934found some choice with an appropriate register class and respect the
15935found qualified matching constraint.
15936
9847c753
ML
15937@item ira-simple-lra-insn-threshold
15938Approximate function insn number in 1K units triggering simple local RA.
15939
d77de738
ML
15940@item lra-inheritance-ebb-probability-cutoff
15941LRA tries to reuse values reloaded in registers in subsequent insns.
15942This optimization is called inheritance. EBB is used as a region to
15943do this optimization. The parameter defines a minimal fall-through
15944edge probability in percentage used to add BB to inheritance EBB in
15945LRA. The default value was chosen
15946from numerous runs of SPEC2000 on x86-64.
15947
15948@item loop-invariant-max-bbs-in-loop
15949Loop invariant motion can be very expensive, both in compilation time and
15950in amount of needed compile-time memory, with very large loops. Loops
15951with more basic blocks than this parameter won't have loop invariant
15952motion optimization performed on them.
15953
15954@item loop-max-datarefs-for-datadeps
15955Building data dependencies is expensive for very large loops. This
15956parameter limits the number of data references in loops that are
15957considered for data dependence analysis. These large loops are no
15958handled by the optimizations using loop data dependencies.
15959
15960@item max-vartrack-size
15961Sets a maximum number of hash table slots to use during variable
15962tracking dataflow analysis of any function. If this limit is exceeded
15963with variable tracking at assignments enabled, analysis for that
15964function is retried without it, after removing all debug insns from
15965the function. If the limit is exceeded even without debug insns, var
15966tracking analysis is completely disabled for the function. Setting
15967the parameter to zero makes it unlimited.
15968
15969@item max-vartrack-expr-depth
15970Sets a maximum number of recursion levels when attempting to map
15971variable names or debug temporaries to value expressions. This trades
15972compilation time for more complete debug information. If this is set too
15973low, value expressions that are available and could be represented in
15974debug information may end up not being used; setting this higher may
15975enable the compiler to find more complex debug expressions, but compile
15976time and memory use may grow.
15977
15978@item max-debug-marker-count
15979Sets a threshold on the number of debug markers (e.g.@: begin stmt
15980markers) to avoid complexity explosion at inlining or expanding to RTL.
15981If a function has more such gimple stmts than the set limit, such stmts
15982will be dropped from the inlined copy of a function, and from its RTL
15983expansion.
15984
15985@item min-nondebug-insn-uid
15986Use uids starting at this parameter for nondebug insns. The range below
15987the parameter is reserved exclusively for debug insns created by
15988@option{-fvar-tracking-assignments}, but debug insns may get
15989(non-overlapping) uids above it if the reserved range is exhausted.
15990
10478270
MJ
15991@item ipa-sra-deref-prob-threshold
15992IPA-SRA replaces a pointer which is known not be NULL with one or more
15993new parameters only when the probability (in percent, relative to
15994function entry) of it being dereferenced is higher than this parameter.
15995
d77de738
ML
15996@item ipa-sra-ptr-growth-factor
15997IPA-SRA replaces a pointer to an aggregate with one or more new
15998parameters only when their cumulative size is less or equal to
15999@option{ipa-sra-ptr-growth-factor} times the size of the original
16000pointer parameter.
16001
69363825
ML
16002@item ipa-sra-ptrwrap-growth-factor
16003Additional maximum allowed growth of total size of new parameters
16004that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
16005if it points to a local variable that the caller only writes to and
16006passes it as an argument to other functions.
69363825 16007
d77de738
ML
16008@item ipa-sra-max-replacements
16009Maximum pieces of an aggregate that IPA-SRA tracks. As a
16010consequence, it is also the maximum number of replacements of a formal
16011parameter.
16012
16013@item sra-max-scalarization-size-Ospeed
16014@itemx sra-max-scalarization-size-Osize
16015The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
16016replace scalar parts of aggregates with uses of independent scalar
16017variables. These parameters control the maximum size, in storage units,
16018of aggregate which is considered for replacement when compiling for
16019speed
16020(@option{sra-max-scalarization-size-Ospeed}) or size
16021(@option{sra-max-scalarization-size-Osize}) respectively.
16022
16023@item sra-max-propagations
16024The maximum number of artificial accesses that Scalar Replacement of
16025Aggregates (SRA) will track, per one local variable, in order to
16026facilitate copy propagation.
16027
16028@item tm-max-aggregate-size
16029When making copies of thread-local variables in a transaction, this
16030parameter specifies the size in bytes after which variables are
16031saved with the logging functions as opposed to save/restore code
16032sequence pairs. This option only applies when using
16033@option{-fgnu-tm}.
16034
16035@item graphite-max-nb-scop-params
16036To avoid exponential effects in the Graphite loop transforms, the
16037number of parameters in a Static Control Part (SCoP) is bounded.
16038A value of zero can be used to lift
16039the bound. A variable whose value is unknown at compilation time and
16040defined outside a SCoP is a parameter of the SCoP.
16041
551935d1
AO
16042@item hardcfr-max-blocks
16043Disable @option{-fharden-control-flow-redundancy} for functions with a
16044larger number of blocks than the specified value. Zero removes any
16045limit.
16046
16047@item hardcfr-max-inline-blocks
16048Force @option{-fharden-control-flow-redundancy} to use out-of-line
16049checking for functions with a larger number of basic blocks than the
16050specified value.
16051
d77de738
ML
16052@item loop-block-tile-size
16053Loop blocking or strip mining transforms, enabled with
16054@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
16055loop in the loop nest by a given number of iterations. The strip
16056length can be changed using the @option{loop-block-tile-size}
16057parameter.
16058
16059@item ipa-jump-function-lookups
16060Specifies number of statements visited during jump function offset discovery.
16061
16062@item ipa-cp-value-list-size
16063IPA-CP attempts to track all possible values and types passed to a function's
16064parameter in order to propagate them and perform devirtualization.
16065@option{ipa-cp-value-list-size} is the maximum number of values and types it
16066stores per one formal parameter of a function.
16067
16068@item ipa-cp-eval-threshold
16069IPA-CP calculates its own score of cloning profitability heuristics
16070and performs those cloning opportunities with scores that exceed
16071@option{ipa-cp-eval-threshold}.
16072
16073@item ipa-cp-max-recursive-depth
16074Maximum depth of recursive cloning for self-recursive function.
16075
16076@item ipa-cp-min-recursive-probability
16077Recursive cloning only when the probability of call being executed exceeds
16078the parameter.
16079
16080@item ipa-cp-profile-count-base
16081When using @option{-fprofile-use} option, IPA-CP will consider the measured
16082execution count of a call graph edge at this percentage position in their
16083histogram as the basis for its heuristics calculation.
16084
16085@item ipa-cp-recursive-freq-factor
16086The number of times interprocedural copy propagation expects recursive
16087functions to call themselves.
16088
16089@item ipa-cp-recursion-penalty
16090Percentage penalty the recursive functions will receive when they
16091are evaluated for cloning.
16092
16093@item ipa-cp-single-call-penalty
16094Percentage penalty functions containing a single call to another
16095function will receive when they are evaluated for cloning.
16096
16097@item ipa-max-agg-items
16098IPA-CP is also capable to propagate a number of scalar values passed
16099in an aggregate. @option{ipa-max-agg-items} controls the maximum
16100number of such values per one parameter.
16101
16102@item ipa-cp-loop-hint-bonus
16103When IPA-CP determines that a cloning candidate would make the number
16104of iterations of a loop known, it adds a bonus of
16105@option{ipa-cp-loop-hint-bonus} to the profitability score of
16106the candidate.
16107
16108@item ipa-max-loop-predicates
16109The maximum number of different predicates IPA will use to describe when
16110loops in a function have known properties.
16111
16112@item ipa-max-aa-steps
16113During its analysis of function bodies, IPA-CP employs alias analysis
16114in order to track values pointed to by function parameters. In order
16115not spend too much time analyzing huge functions, it gives up and
16116consider all memory clobbered after examining
16117@option{ipa-max-aa-steps} statements modifying memory.
16118
16119@item ipa-max-switch-predicate-bounds
16120Maximal number of boundary endpoints of case ranges of switch statement.
16121For switch exceeding this limit, IPA-CP will not construct cloning cost
16122predicate, which is used to estimate cloning benefit, for default case
16123of the switch statement.
16124
16125@item ipa-max-param-expr-ops
16126IPA-CP will analyze conditional statement that references some function
16127parameter to estimate benefit for cloning upon certain constant value.
16128But if number of operations in a parameter expression exceeds
16129@option{ipa-max-param-expr-ops}, the expression is treated as complicated
16130one, and is not handled by IPA analysis.
16131
16132@item lto-partitions
16133Specify desired number of partitions produced during WHOPR compilation.
16134The number of partitions should exceed the number of CPUs used for compilation.
16135
16136@item lto-min-partition
16137Size of minimal partition for WHOPR (in estimated instructions).
16138This prevents expenses of splitting very small programs into too many
16139partitions.
16140
16141@item lto-max-partition
16142Size of max partition for WHOPR (in estimated instructions).
16143to provide an upper bound for individual size of partition.
16144Meant to be used only with balanced partitioning.
16145
16146@item lto-max-streaming-parallelism
16147Maximal number of parallel processes used for LTO streaming.
16148
16149@item cxx-max-namespaces-for-diagnostic-help
16150The maximum number of namespaces to consult for suggestions when C++
16151name lookup fails for an identifier.
16152
16153@item sink-frequency-threshold
16154The maximum relative execution frequency (in percents) of the target block
16155relative to a statement's original block to allow statement sinking of a
16156statement. Larger numbers result in more aggressive statement sinking.
16157A small positive adjustment is applied for
16158statements with memory operands as those are even more profitable so sink.
16159
16160@item max-stores-to-sink
16161The maximum number of conditional store pairs that can be sunk. Set to 0
16162if either vectorization (@option{-ftree-vectorize}) or if-conversion
16163(@option{-ftree-loop-if-convert}) is disabled.
16164
16165@item case-values-threshold
16166The smallest number of different values for which it is best to use a
16167jump-table instead of a tree of conditional branches. If the value is
161680, use the default for the machine.
16169
16170@item jump-table-max-growth-ratio-for-size
16171The maximum code size growth ratio when expanding
16172into a jump table (in percent). The parameter is used when
16173optimizing for size.
16174
16175@item jump-table-max-growth-ratio-for-speed
16176The maximum code size growth ratio when expanding
16177into a jump table (in percent). The parameter is used when
16178optimizing for speed.
16179
16180@item tree-reassoc-width
16181Set the maximum number of instructions executed in parallel in
16182reassociated tree. This parameter overrides target dependent
16183heuristics used by default if has non zero value.
16184
16185@item sched-pressure-algorithm
16186Choose between the two available implementations of
16187@option{-fsched-pressure}. Algorithm 1 is the original implementation
16188and is the more likely to prevent instructions from being reordered.
16189Algorithm 2 was designed to be a compromise between the relatively
16190conservative approach taken by algorithm 1 and the rather aggressive
16191approach taken by the default scheduler. It relies more heavily on
16192having a regular register file and accurate register pressure classes.
16193See @file{haifa-sched.cc} in the GCC sources for more details.
16194
16195The default choice depends on the target.
16196
16197@item max-slsr-cand-scan
16198Set the maximum number of existing candidates that are considered when
16199seeking a basis for a new straight-line strength reduction candidate.
16200
16201@item asan-globals
16202Enable buffer overflow detection for global objects. This kind
16203of protection is enabled by default if you are using
16204@option{-fsanitize=address} option.
16205To disable global objects protection use @option{--param asan-globals=0}.
16206
16207@item asan-stack
16208Enable buffer overflow detection for stack objects. This kind of
16209protection is enabled by default when using @option{-fsanitize=address}.
16210To disable stack protection use @option{--param asan-stack=0} option.
16211
16212@item asan-instrument-reads
16213Enable buffer overflow detection for memory reads. This kind of
16214protection is enabled by default when using @option{-fsanitize=address}.
16215To disable memory reads protection use
16216@option{--param asan-instrument-reads=0}.
16217
16218@item asan-instrument-writes
16219Enable buffer overflow detection for memory writes. This kind of
16220protection is enabled by default when using @option{-fsanitize=address}.
16221To disable memory writes protection use
16222@option{--param asan-instrument-writes=0} option.
16223
16224@item asan-memintrin
16225Enable detection for built-in functions. This kind of protection
16226is enabled by default when using @option{-fsanitize=address}.
16227To disable built-in functions protection use
16228@option{--param asan-memintrin=0}.
16229
16230@item asan-use-after-return
16231Enable detection of use-after-return. This kind of protection
16232is enabled by default when using the @option{-fsanitize=address} option.
16233To disable it use @option{--param asan-use-after-return=0}.
16234
16235Note: By default the check is disabled at run time. To enable it,
16236add @code{detect_stack_use_after_return=1} to the environment variable
16237@env{ASAN_OPTIONS}.
16238
16239@item asan-instrumentation-with-call-threshold
16240If number of memory accesses in function being instrumented
16241is greater or equal to this number, use callbacks instead of inline checks.
16242E.g. to disable inline code use
16243@option{--param asan-instrumentation-with-call-threshold=0}.
16244
545c9f8b 16245@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
16246If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
16247with @samp{__asan_} or @samp{__hwasan_}
16248for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
16249respectively.
545c9f8b 16250
d77de738
ML
16251@item hwasan-instrument-stack
16252Enable hwasan instrumentation of statically sized stack-allocated variables.
16253This kind of instrumentation is enabled by default when using
16254@option{-fsanitize=hwaddress} and disabled by default when using
16255@option{-fsanitize=kernel-hwaddress}.
16256To disable stack instrumentation use
16257@option{--param hwasan-instrument-stack=0}, and to enable it use
16258@option{--param hwasan-instrument-stack=1}.
16259
16260@item hwasan-random-frame-tag
16261When using stack instrumentation, decide tags for stack variables using a
16262deterministic sequence beginning at a random tag for each frame. With this
16263parameter unset tags are chosen using the same sequence but beginning from 1.
16264This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16265for @option{-fsanitize=kernel-hwaddress}.
16266To disable it use @option{--param hwasan-random-frame-tag=0}.
16267
16268@item hwasan-instrument-allocas
16269Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16270This kind of instrumentation is enabled by default when using
16271@option{-fsanitize=hwaddress} and disabled by default when using
16272@option{-fsanitize=kernel-hwaddress}.
16273To disable instrumentation of such variables use
16274@option{--param hwasan-instrument-allocas=0}, and to enable it use
16275@option{--param hwasan-instrument-allocas=1}.
16276
16277@item hwasan-instrument-reads
16278Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16279default for both @option{-fsanitize=hwaddress} and
16280@option{-fsanitize=kernel-hwaddress}.
16281To disable checking memory reads use
16282@option{--param hwasan-instrument-reads=0}.
16283
16284@item hwasan-instrument-writes
16285Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16286default for both @option{-fsanitize=hwaddress} and
16287@option{-fsanitize=kernel-hwaddress}.
16288To disable checking memory writes use
16289@option{--param hwasan-instrument-writes=0}.
16290
16291@item hwasan-instrument-mem-intrinsics
16292Enable hwasan instrumentation of builtin functions. Instrumentation of these
16293builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16294and @option{-fsanitize=kernel-hwaddress}.
16295To disable instrumentation of builtin functions use
16296@option{--param hwasan-instrument-mem-intrinsics=0}.
16297
16298@item use-after-scope-direct-emission-threshold
16299If the size of a local variable in bytes is smaller or equal to this
16300number, directly poison (or unpoison) shadow memory instead of using
16301run-time callbacks.
16302
16303@item tsan-distinguish-volatile
16304Emit special instrumentation for accesses to volatiles.
16305
16306@item tsan-instrument-func-entry-exit
16307Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16308
16309@item max-fsm-thread-path-insns
16310Maximum number of instructions to copy when duplicating blocks on a
16311finite state automaton jump thread path.
16312
16313@item threader-debug
16314threader-debug=[none|all] Enables verbose dumping of the threader solver.
16315
16316@item parloops-chunk-size
16317Chunk size of omp schedule for loops parallelized by parloops.
16318
16319@item parloops-schedule
16320Schedule type of omp schedule for loops parallelized by parloops (static,
16321dynamic, guided, auto, runtime).
16322
16323@item parloops-min-per-thread
16324The minimum number of iterations per thread of an innermost parallelized
16325loop for which the parallelized variant is preferred over the single threaded
16326one. Note that for a parallelized loop nest the
16327minimum number of iterations of the outermost loop per thread is two.
16328
16329@item max-ssa-name-query-depth
16330Maximum depth of recursion when querying properties of SSA names in things
16331like fold routines. One level of recursion corresponds to following a
16332use-def chain.
16333
16334@item max-speculative-devirt-maydefs
16335The maximum number of may-defs we analyze when looking for a must-def
16336specifying the dynamic type of an object that invokes a virtual call
16337we may be able to devirtualize speculatively.
16338
d77de738
ML
16339@item ranger-debug
16340Specifies the type of debug output to be issued for ranges.
16341
d77de738
ML
16342@item unroll-jam-min-percent
16343The minimum percentage of memory references that must be optimized
16344away for the unroll-and-jam transformation to be considered profitable.
16345
16346@item unroll-jam-max-unroll
16347The maximum number of times the outer loop should be unrolled by
16348the unroll-and-jam transformation.
16349
16350@item max-rtl-if-conversion-unpredictable-cost
16351Maximum permissible cost for the sequence that would be generated
16352by the RTL if-conversion pass for a branch that is considered unpredictable.
16353
16354@item max-variable-expansions-in-unroller
16355If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16356of times that an individual variable will be expanded during loop unrolling.
16357
16358@item partial-inlining-entry-probability
16359Maximum probability of the entry BB of split region
16360(in percent relative to entry BB of the function)
16361to make partial inlining happen.
16362
16363@item max-tracked-strlens
16364Maximum number of strings for which strlen optimization pass will
16365track string lengths.
16366
16367@item gcse-after-reload-partial-fraction
16368The threshold ratio for performing partial redundancy
16369elimination after reload.
16370
16371@item gcse-after-reload-critical-fraction
16372The threshold ratio of critical edges execution count that
16373permit performing redundancy elimination after reload.
16374
16375@item max-loop-header-insns
16376The maximum number of insns in loop header duplicated
16377by the copy loop headers pass.
16378
16379@item vect-epilogues-nomask
16380Enable loop epilogue vectorization using smaller vector size.
16381
16382@item vect-partial-vector-usage
16383Controls when the loop vectorizer considers using partial vector loads
16384and stores as an alternative to falling back to scalar code. 0 stops
16385the vectorizer from ever using partial vector loads and stores. 1 allows
16386partial vector loads and stores if vectorization removes the need for the
16387code to iterate. 2 allows partial vector loads and stores in all loops.
16388The parameter only has an effect on targets that support partial
16389vector loads and stores.
16390
16391@item vect-inner-loop-cost-factor
16392The maximum factor which the loop vectorizer applies to the cost of statements
16393in an inner loop relative to the loop being vectorized. The factor applied
16394is the maximum of the estimated number of iterations of the inner loop and
16395this parameter. The default value of this parameter is 50.
16396
16397@item vect-induction-float
16398Enable loop vectorization of floating point inductions.
16399
cbe32d38
ML
16400@item vrp-sparse-threshold
16401Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16402
16403@item vrp-switch-limit
16404Maximum number of outgoing edges in a switch before VRP will not process it.
16405
16406@item vrp-vector-threshold
16407Maximum number of basic blocks for VRP to use a basic cache vector.
16408
d77de738
ML
16409@item avoid-fma-max-bits
16410Maximum number of bits for which we avoid creating FMAs.
16411
16412@item sms-loop-average-count-threshold
16413A threshold on the average loop count considered by the swing modulo scheduler.
16414
16415@item sms-dfa-history
16416The number of cycles the swing modulo scheduler considers when checking
16417conflicts using DFA.
16418
16419@item graphite-allow-codegen-errors
16420Whether codegen errors should be ICEs when @option{-fchecking}.
16421
16422@item sms-max-ii-factor
16423A factor for tuning the upper bound that swing modulo scheduler
16424uses for scheduling a loop.
16425
16426@item lra-max-considered-reload-pseudos
16427The max number of reload pseudos which are considered during
16428spilling a non-reload pseudo.
16429
16430@item max-pow-sqrt-depth
16431Maximum depth of sqrt chains to use when synthesizing exponentiation
16432by a real constant.
16433
16434@item max-dse-active-local-stores
16435Maximum number of active local stores in RTL dead store elimination.
16436
16437@item asan-instrument-allocas
16438Enable asan allocas/VLAs protection.
16439
16440@item max-iterations-computation-cost
16441Bound on the cost of an expression to compute the number of iterations.
16442
16443@item max-isl-operations
16444Maximum number of isl operations, 0 means unlimited.
16445
16446@item graphite-max-arrays-per-scop
16447Maximum number of arrays per scop.
16448
16449@item max-vartrack-reverse-op-size
16450Max. size of loc list for which reverse ops should be added.
16451
16452@item fsm-scale-path-stmts
16453Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16454crossing a loop backedge when comparing to
16455@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16456
16457@item uninit-control-dep-attempts
16458Maximum number of nested calls to search for control dependencies
16459during uninitialized variable analysis.
16460
b8a2a124
RB
16461@item uninit-max-chain-len
16462Maximum number of predicates anded for each predicate ored in the normalized
16463predicate chain.
16464
16465@item uninit-max-num-chains
16466Maximum number of predicates ored in the normalized predicate chain.
16467
d77de738
ML
16468@item sched-autopref-queue-depth
16469Hardware autoprefetcher scheduler model control flag.
16470Number of lookahead cycles the model looks into; at '
16471' only enable instruction sorting heuristic.
16472
16473@item loop-versioning-max-inner-insns
16474The maximum number of instructions that an inner loop can have
16475before the loop versioning pass considers it too big to copy.
16476
16477@item loop-versioning-max-outer-insns
16478The maximum number of instructions that an outer loop can have
16479before the loop versioning pass considers it too big to copy,
16480discounting any instructions in inner loops that directly benefit
16481from versioning.
16482
16483@item ssa-name-def-chain-limit
16484The maximum number of SSA_NAME assignments to follow in determining
16485a property of a variable such as its value. This limits the number
16486of iterations or recursive calls GCC performs when optimizing certain
16487statements or when determining their validity prior to issuing
16488diagnostics.
16489
16490@item store-merging-max-size
16491Maximum size of a single store merging region in bytes.
16492
16493@item hash-table-verification-limit
16494The number of elements for which hash table verification is done
16495for each searched element.
16496
16497@item max-find-base-term-values
16498Maximum number of VALUEs handled during a single find_base_term call.
16499
16500@item analyzer-max-enodes-per-program-point
16501The maximum number of exploded nodes per program point within
16502the analyzer, before terminating analysis of that point.
16503
16504@item analyzer-max-constraints
16505The maximum number of constraints per state.
16506
16507@item analyzer-min-snodes-for-call-summary
16508The minimum number of supernodes within a function for the
16509analyzer to consider summarizing its effects at call sites.
16510
16511@item analyzer-max-enodes-for-full-dump
16512The maximum depth of exploded nodes that should appear in a dot dump
16513before switching to a less verbose format.
16514
16515@item analyzer-max-recursion-depth
16516The maximum number of times a callsite can appear in a call stack
16517within the analyzer, before terminating analysis of a call that would
16518recurse deeper.
16519
16520@item analyzer-max-svalue-depth
16521The maximum depth of a symbolic value, before approximating
16522the value as unknown.
16523
16524@item analyzer-max-infeasible-edges
16525The maximum number of infeasible edges to reject before declaring
16526a diagnostic as infeasible.
16527
16528@item gimple-fe-computed-hot-bb-threshold
16529The number of executions of a basic block which is considered hot.
16530The parameter is used only in GIMPLE FE.
16531
16532@item analyzer-bb-explosion-factor
16533The maximum number of 'after supernode' exploded nodes within the analyzer
16534per supernode, before terminating analysis.
16535
c0c5a57b
MJ
16536@item analyzer-text-art-string-ellipsis-threshold
16537The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
16538
16539@item analyzer-text-art-ideal-canvas-width
16540The ideal width in characters of text art diagrams generated by the analyzer.
16541
16542@item analyzer-text-art-string-ellipsis-head-len
16543The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
16544
16545@item analyzer-text-art-string-ellipsis-tail-len
16546The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
16547
d77de738
ML
16548@item ranger-logical-depth
16549Maximum depth of logical expression evaluation ranger will look through
16550when evaluating outgoing edge ranges.
16551
9fd6d83a
ML
16552@item ranger-recompute-depth
16553Maximum depth of instruction chains to consider for recomputation
16554in the outgoing range calculator.
16555
d77de738
ML
16556@item relation-block-limit
16557Maximum number of relations the oracle will register in a basic block.
16558
16559@item min-pagesize
16560Minimum page size for warning purposes.
16561
16562@item openacc-kernels
16563Specify mode of OpenACC `kernels' constructs handling.
16564With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16565constructs are decomposed into parts, a sequence of compute
16566constructs, each then handled individually.
16567This is work in progress.
16568With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16569constructs are handled by the @samp{parloops} pass, en bloc.
16570This is the current default.
16571
16572@item openacc-privatization
4ace81b6
SL
16573Control whether the @option{-fopt-info-omp-note} and applicable
16574@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16575With @option{--param=openacc-privatization=quiet}, don't diagnose.
16576This is the current default.
16577With @option{--param=openacc-privatization=noisy}, do diagnose.
16578
16579@end table
16580
16581The following choices of @var{name} are available on AArch64 targets:
16582
16583@table @gcctabopt
16584@item aarch64-sve-compare-costs
16585When vectorizing for SVE, consider using ``unpacked'' vectors for
16586smaller elements and use the cost model to pick the cheapest approach.
16587Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16588
16589Using unpacked vectors includes storing smaller elements in larger
16590containers and accessing elements with extending loads and truncating
16591stores.
16592
16593@item aarch64-float-recp-precision
16594The number of Newton iterations for calculating the reciprocal for float type.
16595The precision of division is proportional to this param when division
16596approximation is enabled. The default value is 1.
16597
16598@item aarch64-double-recp-precision
16599The number of Newton iterations for calculating the reciprocal for double type.
16600The precision of division is propotional to this param when division
16601approximation is enabled. The default value is 2.
16602
16603@item aarch64-autovec-preference
16604Force an ISA selection strategy for auto-vectorization. Accepts values from
166050 to 4, inclusive.
16606@table @samp
16607@item 0
16608Use the default heuristics.
16609@item 1
16610Use only Advanced SIMD for auto-vectorization.
16611@item 2
16612Use only SVE for auto-vectorization.
16613@item 3
16614Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16615deemed equal.
16616@item 4
16617Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16618@end table
16619The default value is 0.
16620
834fc2bf
MA
16621@item aarch64-ldp-policy
16622Fine-grained policy for load pairs.
16623With @option{--param=aarch64-ldp-policy=default}, use the policy of the
16624tuning structure. This is the current default.
16625With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
16626of alignment.
16627With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
16628With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
16629source pointer is aligned to at least double the alignment of the type.
16630
16631@item aarch64-stp-policy
16632Fine-grained policy for store pairs.
16633With @option{--param=aarch64-stp-policy=default}, use the policy of the
16634tuning structure. This is the current default.
16635With @option{--param=aarch64-stp-policy=always}, emit stp regardless
16636of alignment.
16637With @option{--param=aarch64-stp-policy=never}, do not emit stp.
16638With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
16639source pointer is aligned to at least double the alignment of the type.
16640
d77de738
ML
16641@item aarch64-loop-vect-issue-rate-niters
16642The tuning for some AArch64 CPUs tries to take both latencies and issue
16643rates into account when deciding whether a loop should be vectorized
16644using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16645If this parameter is set to @var{n}, GCC will not use this heuristic
16646for loops that are known to execute in fewer than @var{n} Advanced
16647SIMD iterations.
16648
16649@item aarch64-vect-unroll-limit
16650The vectorizer will use available tuning information to determine whether it
16651would be beneficial to unroll the main vectorized loop and by how much. This
16652parameter set's the upper bound of how much the vectorizer will unroll the main
16653loop. The default value is four.
16654
16655@end table
16656
16657The following choices of @var{name} are available on i386 and x86_64 targets:
16658
16659@table @gcctabopt
16660@item x86-stlf-window-ninsns
16661Instructions number above which STFL stall penalty can be compensated.
16662
60101899
RB
16663@item x86-stv-max-visits
16664The maximum number of use and def visits when discovering a STV chain before
16665the discovery is aborted.
16666
d77de738
ML
16667@end table
16668
16669@end table
16670
16671@node Instrumentation Options
16672@section Program Instrumentation Options
16673@cindex instrumentation options
16674@cindex program instrumentation options
16675@cindex run-time error checking options
16676@cindex profiling options
16677@cindex options, program instrumentation
16678@cindex options, run-time error checking
16679@cindex options, profiling
16680
16681GCC supports a number of command-line options that control adding
16682run-time instrumentation to the code it normally generates.
16683For example, one purpose of instrumentation is collect profiling
16684statistics for use in finding program hot spots, code coverage
16685analysis, or profile-guided optimizations.
16686Another class of program instrumentation is adding run-time checking
16687to detect programming errors like invalid pointer
16688dereferences or out-of-bounds array accesses, as well as deliberately
16689hostile attacks such as stack smashing or C++ vtable hijacking.
16690There is also a general hook which can be used to implement other
16691forms of tracing or function-level instrumentation for debug or
16692program analysis purposes.
16693
16694@table @gcctabopt
16695@cindex @command{prof}
16696@cindex @command{gprof}
d77de738
ML
16697@opindex p
16698@opindex pg
ddf6fe37
AA
16699@item -p
16700@itemx -pg
d77de738
ML
16701Generate extra code to write profile information suitable for the
16702analysis program @command{prof} (for @option{-p}) or @command{gprof}
16703(for @option{-pg}). You must use this option when compiling
16704the source files you want data about, and you must also use it when
16705linking.
16706
16707You can use the function attribute @code{no_instrument_function} to
16708suppress profiling of individual functions when compiling with these options.
16709@xref{Common Function Attributes}.
16710
d77de738 16711@opindex fprofile-arcs
ddf6fe37 16712@item -fprofile-arcs
d77de738
ML
16713Add code so that program flow @dfn{arcs} are instrumented. During
16714execution the program records how many times each branch and call is
16715executed and how many times it is taken or returns. On targets that support
16716constructors with priority support, profiling properly handles constructors,
16717destructors and C++ constructors (and destructors) of classes which are used
16718as a type of a global variable.
16719
16720When the compiled
16721program exits it saves this data to a file called
16722@file{@var{auxname}.gcda} for each source file. The data may be used for
16723profile-directed optimizations (@option{-fbranch-probabilities}), or for
16724test coverage analysis (@option{-ftest-coverage}). Each object file's
16725@var{auxname} is generated from the name of the output file, if
16726explicitly specified and it is not the final executable, otherwise it is
16727the basename of the source file. In both cases any suffix is removed
16728(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16729@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16730
16731Note that if a command line directly links source files, the corresponding
16732@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16733E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16734@file{binary-b.gcda} files.
16735
16736@xref{Cross-profiling}.
16737
16738@cindex @command{gcov}
d77de738 16739@opindex coverage
ddf6fe37 16740@item --coverage
d77de738
ML
16741
16742This option is used to compile and link code instrumented for coverage
16743analysis. The option is a synonym for @option{-fprofile-arcs}
16744@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16745linking). See the documentation for those options for more details.
16746
16747@itemize
16748
16749@item
16750Compile the source files with @option{-fprofile-arcs} plus optimization
16751and code generation options. For test coverage analysis, use the
16752additional @option{-ftest-coverage} option. You do not need to profile
16753every source file in a program.
16754
16755@item
16756Compile the source files additionally with @option{-fprofile-abs-path}
16757to create absolute path names in the @file{.gcno} files. This allows
16758@command{gcov} to find the correct sources in projects where compilations
16759occur with different working directories.
16760
16761@item
16762Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16763(the latter implies the former).
16764
16765@item
16766Run the program on a representative workload to generate the arc profile
16767information. This may be repeated any number of times. You can run
16768concurrent instances of your program, and provided that the file system
16769supports locking, the data files will be correctly updated. Unless
16770a strict ISO C dialect option is in effect, @code{fork} calls are
16771detected and correctly handled without double counting.
16772
16773Moreover, an object file can be recompiled multiple times
16774and the corresponding @file{.gcda} file merges as long as
16775the source file and the compiler options are unchanged.
16776
16777@item
16778For profile-directed optimizations, compile the source files again with
16779the same optimization and code generation options plus
16780@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16781Control Optimization}).
16782
16783@item
16784For test coverage analysis, use @command{gcov} to produce human readable
16785information from the @file{.gcno} and @file{.gcda} files. Refer to the
16786@command{gcov} documentation for further information.
16787
16788@end itemize
16789
16790With @option{-fprofile-arcs}, for each function of your program GCC
16791creates a program flow graph, then finds a spanning tree for the graph.
16792Only arcs that are not on the spanning tree have to be instrumented: the
16793compiler adds code to count the number of times that these arcs are
16794executed. When an arc is the only exit or only entrance to a block, the
16795instrumentation code can be added to the block; otherwise, a new basic
16796block must be created to hold the instrumentation code.
16797
16798@need 2000
d77de738 16799@opindex ftest-coverage
ddf6fe37 16800@item -ftest-coverage
d77de738
ML
16801Produce a notes file that the @command{gcov} code-coverage utility
16802(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16803show program coverage. Each source file's note file is called
16804@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16805above for a description of @var{auxname} and instructions on how to
16806generate test coverage data. Coverage data matches the source files
16807more closely if you do not optimize.
16808
d77de738 16809@opindex fprofile-abs-path
ddf6fe37 16810@item -fprofile-abs-path
d77de738
ML
16811Automatically convert relative source file names to absolute path names
16812in the @file{.gcno} files. This allows @command{gcov} to find the correct
16813sources in projects where compilations occur with different working
16814directories.
16815
d77de738 16816@opindex fprofile-dir
ddf6fe37 16817@item -fprofile-dir=@var{path}
d77de738
ML
16818
16819Set the directory to search for the profile data files in to @var{path}.
16820This option affects only the profile data generated by
16821@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16822and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16823and its related options. Both absolute and relative paths can be used.
16824By default, GCC uses the current directory as @var{path}, thus the
16825profile data file appears in the same directory as the object file.
16826In order to prevent the file name clashing, if the object file name is
16827not an absolute path, we mangle the absolute path of the
16828@file{@var{sourcename}.gcda} file and use it as the file name of a
16829@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16830See similar option @option{-fprofile-note}.
16831
16832When an executable is run in a massive parallel environment, it is recommended
16833to save profile to different folders. That can be done with variables
16834in @var{path} that are exported during run-time:
16835
16836@table @gcctabopt
16837
16838@item %p
16839process ID.
16840
16841@item %q@{VAR@}
16842value of environment variable @var{VAR}
16843
16844@end table
16845
ddf6fe37 16846@opindex fprofile-generate
d77de738
ML
16847@item -fprofile-generate
16848@itemx -fprofile-generate=@var{path}
d77de738
ML
16849
16850Enable options usually used for instrumenting application to produce
16851profile useful for later recompilation with profile feedback based
16852optimization. You must use @option{-fprofile-generate} both when
16853compiling and when linking your program.
16854
16855The following options are enabled:
16856@option{-fprofile-arcs}, @option{-fprofile-values},
16857@option{-finline-functions}, and @option{-fipa-bit-cp}.
16858
16859If @var{path} is specified, GCC looks at the @var{path} to find
16860the profile feedback data files. See @option{-fprofile-dir}.
16861
16862To optimize the program based on the collected profile information, use
16863@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16864
ddf6fe37 16865@opindex fprofile-info-section
d77de738
ML
16866@item -fprofile-info-section
16867@itemx -fprofile-info-section=@var{name}
d77de738
ML
16868
16869Register the profile information in the specified section instead of using a
16870constructor/destructor. The section name is @var{name} if it is specified,
16871otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16872profile information generated by @option{-fprofile-arcs} is placed in the
16873specified section for each translation unit. This option disables the profile
16874information registration through a constructor and it disables the profile
16875information processing through a destructor. This option is not intended to be
16876used in hosted environments such as GNU/Linux. It targets freestanding
16877environments (for example embedded systems) with limited resources which do not
16878support constructors/destructors or the C library file I/O.
16879
16880The linker could collect the input sections in a continuous memory block and
16881define start and end symbols. A GNU linker script example which defines a
16882linker output section follows:
16883
16884@smallexample
16885 .gcov_info :
16886 @{
16887 PROVIDE (__gcov_info_start = .);
16888 KEEP (*(.gcov_info))
16889 PROVIDE (__gcov_info_end = .);
16890 @}
16891@end smallexample
16892
16893The program could dump the profiling information registered in this linker set
16894for example like this:
16895
16896@smallexample
16897#include <gcov.h>
16898#include <stdio.h>
16899#include <stdlib.h>
16900
16901extern const struct gcov_info *const __gcov_info_start[];
16902extern const struct gcov_info *const __gcov_info_end[];
16903
16904static void
16905dump (const void *d, unsigned n, void *arg)
16906@{
16907 const unsigned char *c = d;
16908
16909 for (unsigned i = 0; i < n; ++i)
16910 printf ("%02x", c[i]);
16911@}
16912
16913static void
16914filename (const char *f, void *arg)
16915@{
16916 __gcov_filename_to_gcfn (f, dump, arg );
16917@}
16918
16919static void *
16920allocate (unsigned length, void *arg)
16921@{
16922 return malloc (length);
16923@}
16924
16925static void
16926dump_gcov_info (void)
16927@{
16928 const struct gcov_info *const *info = __gcov_info_start;
16929 const struct gcov_info *const *end = __gcov_info_end;
16930
16931 /* Obfuscate variable to prevent compiler optimizations. */
16932 __asm__ ("" : "+r" (info));
16933
16934 while (info != end)
16935 @{
16936 void *arg = NULL;
16937 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16938 putchar ('\n');
16939 ++info;
16940 @}
16941@}
16942
16943int
16944main (void)
16945@{
16946 dump_gcov_info ();
16947 return 0;
16948@}
16949@end smallexample
16950
16951The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16952deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16953@code{__gcov_info_to_gcda} functions and merge the profile information into
16954@file{.gcda} files on the host filesystem.
16955
d77de738 16956@opindex fprofile-note
ddf6fe37 16957@item -fprofile-note=@var{path}
d77de738
ML
16958
16959If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16960location. If you combine the option with multiple source files,
16961the @file{.gcno} file will be overwritten.
16962
d77de738 16963@opindex fprofile-prefix-path
ddf6fe37 16964@item -fprofile-prefix-path=@var{path}
d77de738
ML
16965
16966This option can be used in combination with
16967@option{profile-generate=}@var{profile_dir} and
16968@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16969directory of built source tree. By default @var{profile_dir} will contain
16970files with mangled absolute paths of all object files in the built project.
16971This is not desirable when directory used to build the instrumented binary
16972differs from the directory used to build the binary optimized with profile
16973feedback because the profile data will not be found during the optimized build.
16974In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16975pointing to the base directory of the build can be used to strip the irrelevant
16976part of the path and keep all file names relative to the main build directory.
16977
d77de738 16978@opindex fprofile-prefix-map
ddf6fe37 16979@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16980When compiling files residing in directory @file{@var{old}}, record
16981profiling information (with @option{--coverage})
16982describing them as if the files resided in
16983directory @file{@var{new}} instead.
2eb0191a 16984See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16985
d77de738 16986@opindex fprofile-update
ddf6fe37 16987@item -fprofile-update=@var{method}
d77de738
ML
16988
16989Alter the update method for an application instrumented for profile
16990feedback based optimization. The @var{method} argument should be one of
16991@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16992The first one is useful for single-threaded applications,
16993while the second one prevents profile corruption by emitting thread-safe code.
16994
16995@strong{Warning:} When an application does not properly join all threads
16996(or creates an detached thread), a profile file can be still corrupted.
16997
16998Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16999when supported by a target, or to @samp{single} otherwise. The GCC driver
17000automatically selects @samp{prefer-atomic} when @option{-pthread}
20a3c74c
SH
17001is present in the command line, otherwise the default method is @samp{single}.
17002
17003If @samp{atomic} is selected, then the profile information is updated using
17004atomic operations on a best-effort basis. Ideally, the profile information is
17005updated through atomic operations in hardware. If the target platform does not
17006support the required atomic operations in hardware, however, @file{libatomic}
17007is available, then the profile information is updated through calls to
17008@file{libatomic}. If the target platform neither supports the required atomic
17009operations in hardware nor @file{libatomic}, then the profile information is
17010not atomically updated and a warning is issued. In this case, the obtained
17011profiling information may be corrupt for multi-threaded applications.
17012
17013For performance reasons, if 64-bit counters are used for the profiling
17014information and the target platform only supports 32-bit atomic operations in
17015hardware, then the performance critical profiling updates are done using two
1701632-bit atomic operations for each counter update. If a signal interrupts these
17017two operations updating a counter, then the profiling information may be in an
17018inconsistent state.
d77de738 17019
d77de738 17020@opindex fprofile-filter-files
ddf6fe37 17021@item -fprofile-filter-files=@var{regex}
d77de738
ML
17022
17023Instrument only functions from files whose name matches
17024any of the regular expressions (separated by semi-colons).
17025
17026For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
17027only @file{main.c} and all C files starting with 'module'.
17028
d77de738 17029@opindex fprofile-exclude-files
ddf6fe37 17030@item -fprofile-exclude-files=@var{regex}
d77de738
ML
17031
17032Instrument only functions from files whose name does not match
17033any of the regular expressions (separated by semi-colons).
17034
17035For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
17036of all files that are located in the @file{/usr/} folder.
17037
d77de738 17038@opindex fprofile-reproducible
ddf6fe37 17039@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
17040Control level of reproducibility of profile gathered by
17041@code{-fprofile-generate}. This makes it possible to rebuild program
17042with same outcome which is useful, for example, for distribution
17043packages.
17044
17045With @option{-fprofile-reproducible=serial} the profile gathered by
17046@option{-fprofile-generate} is reproducible provided the trained program
17047behaves the same at each invocation of the train run, it is not
17048multi-threaded and profile data streaming is always done in the same
17049order. Note that profile streaming happens at the end of program run but
17050also before @code{fork} function is invoked.
17051
17052Note that it is quite common that execution counts of some part of
17053programs depends, for example, on length of temporary file names or
17054memory space randomization (that may affect hash-table collision rate).
17055Such non-reproducible part of programs may be annotated by
17056@code{no_instrument_function} function attribute. @command{gcov-dump} with
17057@option{-l} can be used to dump gathered data and verify that they are
17058indeed reproducible.
17059
17060With @option{-fprofile-reproducible=parallel-runs} collected profile
17061stays reproducible regardless the order of streaming of the data into
17062gcda files. This setting makes it possible to run multiple instances of
17063instrumented program in parallel (such as with @code{make -j}). This
17064reduces quality of gathered data, in particular of indirect call
17065profiling.
17066
d77de738 17067@opindex fsanitize=address
ddf6fe37 17068@item -fsanitize=address
d77de738
ML
17069Enable AddressSanitizer, a fast memory error detector.
17070Memory access instructions are instrumented to detect
17071out-of-bounds and use-after-free bugs.
17072The option enables @option{-fsanitize-address-use-after-scope}.
17073See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
17074more details. The run-time behavior can be influenced using the
17075@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
17076the available options are shown at startup of the instrumented program. See
17077@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
17078for a list of supported options.
17079The option cannot be combined with @option{-fsanitize=thread} or
17080@option{-fsanitize=hwaddress}. Note that the only target
17081@option{-fsanitize=hwaddress} is currently supported on is AArch64.
17082
6a07798c
MP
17083To get more accurate stack traces, it is possible to use options such as
17084@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
17085most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
17086optimizing sibling and tail recursive calls; this option is implicit for
17087@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
17088disables Identical Code Folding for functions). Since multiple runs of the
17089program may yield backtraces with different addresses due to ASLR (Address
17090Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
17091this can be achieved with @samp{setarch `uname -m` -R ./prog}.
17092
d77de738 17093@opindex fsanitize=kernel-address
f33d7a88 17094@item -fsanitize=kernel-address
d77de738 17095Enable AddressSanitizer for Linux kernel.
a0bf71be 17096See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 17097
d77de738 17098@opindex fsanitize=hwaddress
f33d7a88 17099@item -fsanitize=hwaddress
d77de738
ML
17100Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
17101ignore the top byte of a pointer to allow the detection of memory errors with
17102a low memory overhead.
17103Memory access instructions are instrumented to detect out-of-bounds and
17104use-after-free bugs.
17105The option enables @option{-fsanitize-address-use-after-scope}.
17106See
17107@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
17108for more details. The run-time behavior can be influenced using the
17109@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
17110the available options are shown at startup of the instrumented program.
17111The option cannot be combined with @option{-fsanitize=thread} or
17112@option{-fsanitize=address}, and is currently only available on AArch64.
17113
d77de738 17114@opindex fsanitize=kernel-hwaddress
ddf6fe37 17115@item -fsanitize=kernel-hwaddress
d77de738
ML
17116Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
17117Similar to @option{-fsanitize=kernel-address} but using an alternate
17118instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
17119instrumentation differences necessary for compiling the Linux kernel.
17120These differences are to avoid hwasan library initialization calls and to
17121account for the stack pointer having a different value in its top byte.
17122
17123@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
17124Instrumenting the stack and alloca calls are not on by default but are still
17125possible by specifying the command-line options
17126@option{--param hwasan-instrument-stack=1} and
17127@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
17128tag is not implemented for kernel instrumentation.
17129
d77de738 17130@opindex fsanitize=pointer-compare
ddf6fe37 17131@item -fsanitize=pointer-compare
d77de738
ML
17132Instrument comparison operation (<, <=, >, >=) with pointer operands.
17133The option must be combined with either @option{-fsanitize=kernel-address} or
17134@option{-fsanitize=address}
17135The option cannot be combined with @option{-fsanitize=thread}.
17136Note: By default the check is disabled at run time. To enable it,
17137add @code{detect_invalid_pointer_pairs=2} to the environment variable
17138@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17139invalid operation only when both pointers are non-null.
17140
d77de738 17141@opindex fsanitize=pointer-subtract
ddf6fe37 17142@item -fsanitize=pointer-subtract
d77de738
ML
17143Instrument subtraction with pointer operands.
17144The option must be combined with either @option{-fsanitize=kernel-address} or
17145@option{-fsanitize=address}
17146The option cannot be combined with @option{-fsanitize=thread}.
17147Note: By default the check is disabled at run time. To enable it,
17148add @code{detect_invalid_pointer_pairs=2} to the environment variable
17149@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17150invalid operation only when both pointers are non-null.
17151
d77de738 17152@opindex fsanitize=shadow-call-stack
ddf6fe37 17153@item -fsanitize=shadow-call-stack
d77de738
ML
17154Enable ShadowCallStack, a security enhancement mechanism used to protect
17155programs against return address overwrites (e.g. stack buffer overflows.)
17156It works by saving a function's return address to a separately allocated
17157shadow call stack in the function prologue and restoring the return address
17158from the shadow call stack in the function epilogue. Instrumentation only
17159occurs in functions that need to save the return address to the stack.
17160
17161Currently it only supports the aarch64 platform. It is specifically
17162designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
17163For the user space programs, runtime support is not currently provided
17164in libc and libgcc. Users who want to use this feature in user space need
17165to provide their own support for the runtime. It should be noted that
17166this may cause the ABI rules to be broken.
17167
17168On aarch64, the instrumentation makes use of the platform register @code{x18}.
17169This generally means that any code that may run on the same thread as code
17170compiled with ShadowCallStack must be compiled with the flag
17171@option{-ffixed-x18}, otherwise functions compiled without
17172@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
17173stack pointer.
17174
17175Also, because there is no userspace runtime support, code compiled with
17176ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
17177to turn off exceptions.
17178
17179See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
17180details.
17181
d77de738 17182@opindex fsanitize=thread
ddf6fe37 17183@item -fsanitize=thread
d77de738
ML
17184Enable ThreadSanitizer, a fast data race detector.
17185Memory access instructions are instrumented to detect
17186data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
17187details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
17188environment variable; see
17189@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
17190supported options.
17191The option cannot be combined with @option{-fsanitize=address},
17192@option{-fsanitize=leak}.
17193
17194Note that sanitized atomic builtins cannot throw exceptions when
17195operating on invalid memory addresses with non-call exceptions
17196(@option{-fnon-call-exceptions}).
17197
d77de738 17198@opindex fsanitize=leak
ddf6fe37 17199@item -fsanitize=leak
d77de738 17200Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
17201This option only matters for linking of executables.
17202The executable is linked against a library that overrides @code{malloc}
d77de738
ML
17203and other allocator functions. See
17204@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
17205details. The run-time behavior can be influenced using the
17206@env{LSAN_OPTIONS} environment variable.
17207The option cannot be combined with @option{-fsanitize=thread}.
17208
d77de738 17209@opindex fsanitize=undefined
ddf6fe37 17210@item -fsanitize=undefined
d77de738
ML
17211Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
17212Various computations are instrumented to detect undefined behavior
17213at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
17214@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
17215
17216@table @gcctabopt
17217
d77de738 17218@opindex fsanitize=shift
ddf6fe37 17219@item -fsanitize=shift
d77de738
ML
17220This option enables checking that the result of a shift operation is
17221not undefined. Note that what exactly is considered undefined differs
17222slightly between C and C++, as well as between ISO C90 and C99, etc.
17223This option has two suboptions, @option{-fsanitize=shift-base} and
17224@option{-fsanitize=shift-exponent}.
17225
d77de738 17226@opindex fsanitize=shift-exponent
ddf6fe37 17227@item -fsanitize=shift-exponent
d77de738
ML
17228This option enables checking that the second argument of a shift operation
17229is not negative and is smaller than the precision of the promoted first
17230argument.
17231
d77de738 17232@opindex fsanitize=shift-base
ddf6fe37 17233@item -fsanitize=shift-base
d77de738
ML
17234If the second argument of a shift operation is within range, check that the
17235result of a shift operation is not undefined. Note that what exactly is
17236considered undefined differs slightly between C and C++, as well as between
17237ISO C90 and C99, etc.
17238
d77de738 17239@opindex fsanitize=integer-divide-by-zero
ddf6fe37 17240@item -fsanitize=integer-divide-by-zero
d77de738
ML
17241Detect integer division by zero.
17242
d77de738 17243@opindex fsanitize=unreachable
ddf6fe37 17244@item -fsanitize=unreachable
d77de738
ML
17245With this option, the compiler turns the @code{__builtin_unreachable}
17246call into a diagnostics message call instead. When reaching the
17247@code{__builtin_unreachable} call, the behavior is undefined.
17248
d77de738 17249@opindex fsanitize=vla-bound
ddf6fe37 17250@item -fsanitize=vla-bound
d77de738
ML
17251This option instructs the compiler to check that the size of a variable
17252length array is positive.
17253
d77de738 17254@opindex fsanitize=null
ddf6fe37 17255@item -fsanitize=null
d77de738
ML
17256This option enables pointer checking. Particularly, the application
17257built with this option turned on will issue an error message when it
17258tries to dereference a NULL pointer, or if a reference (possibly an
17259rvalue reference) is bound to a NULL pointer, or if a method is invoked
17260on an object pointed by a NULL pointer.
17261
d77de738 17262@opindex fsanitize=return
ddf6fe37 17263@item -fsanitize=return
d77de738
ML
17264This option enables return statement checking. Programs
17265built with this option turned on will issue an error message
17266when the end of a non-void function is reached without actually
17267returning a value. This option works in C++ only.
17268
d77de738 17269@opindex fsanitize=signed-integer-overflow
ddf6fe37 17270@item -fsanitize=signed-integer-overflow
d77de738
ML
17271This option enables signed integer overflow checking. We check that
17272the result of @code{+}, @code{*}, and both unary and binary @code{-}
17273does not overflow in the signed arithmetics. This also detects
17274@code{INT_MIN / -1} signed division. Note, integer promotion
17275rules must be taken into account. That is, the following is not an
17276overflow:
17277@smallexample
17278signed char a = SCHAR_MAX;
17279a++;
17280@end smallexample
17281
d77de738 17282@opindex fsanitize=bounds
ddf6fe37 17283@item -fsanitize=bounds
d77de738
ML
17284This option enables instrumentation of array bounds. Various out of bounds
17285accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
17286arrays, and initializers of variables with static storage are not
17287instrumented, with the exception of flexible array member-like arrays
17288for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
17289options or @code{strict_flex_array} attributes say they shouldn't be treated
17290like flexible array member-like arrays.
d77de738 17291
d77de738 17292@opindex fsanitize=bounds-strict
ddf6fe37 17293@item -fsanitize=bounds-strict
d77de738 17294This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
17295accesses are detected, including flexible array member-like arrays.
17296Initializers of variables with static storage are not instrumented.
d77de738 17297
d77de738 17298@opindex fsanitize=alignment
ddf6fe37 17299@item -fsanitize=alignment
d77de738
ML
17300
17301This option enables checking of alignment of pointers when they are
17302dereferenced, or when a reference is bound to insufficiently aligned target,
17303or when a method or constructor is invoked on insufficiently aligned object.
17304
d77de738 17305@opindex fsanitize=object-size
ddf6fe37 17306@item -fsanitize=object-size
d77de738 17307This option enables instrumentation of memory references using the
7283380a
SP
17308@code{__builtin_dynamic_object_size} function. Various out of bounds
17309pointer accesses are detected.
d77de738 17310
d77de738 17311@opindex fsanitize=float-divide-by-zero
ddf6fe37 17312@item -fsanitize=float-divide-by-zero
d77de738
ML
17313Detect floating-point division by zero. Unlike other similar options,
17314@option{-fsanitize=float-divide-by-zero} is not enabled by
17315@option{-fsanitize=undefined}, since floating-point division by zero can
17316be a legitimate way of obtaining infinities and NaNs.
17317
d77de738 17318@opindex fsanitize=float-cast-overflow
ddf6fe37 17319@item -fsanitize=float-cast-overflow
d77de738
ML
17320This option enables floating-point type to integer conversion checking.
17321We check that the result of the conversion does not overflow.
17322Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17323not enabled by @option{-fsanitize=undefined}.
17324This option does not work well with @code{FE_INVALID} exceptions enabled.
17325
d77de738 17326@opindex fsanitize=nonnull-attribute
ddf6fe37 17327@item -fsanitize=nonnull-attribute
d77de738
ML
17328
17329This option enables instrumentation of calls, checking whether null values
17330are not passed to arguments marked as requiring a non-null value by the
17331@code{nonnull} function attribute.
17332
d77de738 17333@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 17334@item -fsanitize=returns-nonnull-attribute
d77de738
ML
17335
17336This option enables instrumentation of return statements in functions
17337marked with @code{returns_nonnull} function attribute, to detect returning
17338of null values from such functions.
17339
d77de738 17340@opindex fsanitize=bool
ddf6fe37 17341@item -fsanitize=bool
d77de738
ML
17342
17343This option enables instrumentation of loads from bool. If a value other
17344than 0/1 is loaded, a run-time error is issued.
17345
d77de738 17346@opindex fsanitize=enum
ddf6fe37 17347@item -fsanitize=enum
d77de738
ML
17348
17349This option enables instrumentation of loads from an enum type. If
17350a value outside the range of values for the enum type is loaded,
17351a run-time error is issued.
17352
d77de738 17353@opindex fsanitize=vptr
ddf6fe37 17354@item -fsanitize=vptr
d77de738
ML
17355
17356This option enables instrumentation of C++ member function calls, member
17357accesses and some conversions between pointers to base and derived classes,
17358to verify the referenced object has the correct dynamic type.
17359
d77de738 17360@opindex fsanitize=pointer-overflow
ddf6fe37 17361@item -fsanitize=pointer-overflow
d77de738
ML
17362
17363This option enables instrumentation of pointer arithmetics. If the pointer
17364arithmetics overflows, a run-time error is issued.
17365
d77de738 17366@opindex fsanitize=builtin
ddf6fe37 17367@item -fsanitize=builtin
d77de738
ML
17368
17369This option enables instrumentation of arguments to selected builtin
17370functions. If an invalid value is passed to such arguments, a run-time
17371error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17372or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17373by this option.
17374
17375@end table
17376
17377Note that sanitizers tend to increase the rate of false positive
17378warnings, most notably those around @option{-Wmaybe-uninitialized}.
17379We recommend against combining @option{-Werror} and [the use of]
17380sanitizers.
17381
17382While @option{-ftrapv} causes traps for signed overflows to be emitted,
17383@option{-fsanitize=undefined} gives a diagnostic message.
17384This currently works only for the C family of languages.
17385
d77de738 17386@opindex fno-sanitize=all
ddf6fe37 17387@item -fno-sanitize=all
d77de738
ML
17388
17389This option disables all previously enabled sanitizers.
17390@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17391together.
17392
d77de738 17393@opindex fasan-shadow-offset
ddf6fe37 17394@item -fasan-shadow-offset=@var{number}
d77de738
ML
17395This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17396It is useful for experimenting with different shadow memory layouts in
17397Kernel AddressSanitizer.
17398
d77de738 17399@opindex fsanitize-sections
ddf6fe37 17400@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
17401Sanitize global variables in selected user-defined sections. @var{si} may
17402contain wildcards.
17403
d77de738
ML
17404@opindex fsanitize-recover
17405@opindex fno-sanitize-recover
ddf6fe37 17406@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17407@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17408mentioned in comma-separated list of @var{opts}. Enabling this option
17409for a sanitizer component causes it to attempt to continue
17410running the program as if no error happened. This means multiple
17411runtime errors can be reported in a single program run, and the exit
17412code of the program may indicate success even when errors
17413have been reported. The @option{-fno-sanitize-recover=} option
17414can be used to alter
17415this behavior: only the first detected error is reported
17416and program then exits with a non-zero exit code.
17417
17418Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17419except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17420@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17421@option{-fsanitize=bounds-strict},
17422@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17423For these sanitizers error recovery is turned on by default,
17424except @option{-fsanitize=address}, for which this feature is experimental.
17425@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17426accepted, the former enables recovery for all sanitizers that support it,
17427the latter disables recovery for all sanitizers that support it.
17428
17429Even if a recovery mode is turned on the compiler side, it needs to be also
17430enabled on the runtime library side, otherwise the failures are still fatal.
17431The runtime library defaults to @code{halt_on_error=0} for
17432ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17433AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17434setting the @code{halt_on_error} flag in the corresponding environment variable.
17435
17436Syntax without an explicit @var{opts} parameter is deprecated. It is
17437equivalent to specifying an @var{opts} list of:
17438
17439@smallexample
17440undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17441@end smallexample
17442
d77de738 17443@opindex fsanitize-address-use-after-scope
ddf6fe37 17444@item -fsanitize-address-use-after-scope
d77de738
ML
17445Enable sanitization of local variables to detect use-after-scope bugs.
17446The option sets @option{-fstack-reuse} to @samp{none}.
17447
d77de738
ML
17448@opindex fsanitize-trap
17449@opindex fno-sanitize-trap
ddf6fe37 17450@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17451The @option{-fsanitize-trap=} option instructs the compiler to
17452report for sanitizers mentioned in comma-separated list of @var{opts}
17453undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17454library routine. If this option is enabled for certain sanitizer,
17455it takes precedence over the @option{-fsanitizer-recover=} for that
17456sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17457of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17458
17459The advantage of this is that the @code{libubsan} library is not needed
17460and is not linked in, so this is usable even in freestanding environments.
17461
17462Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17463except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17464@option{-fsanitize=float-divide-by-zero} and
17465@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17466specified, which enables it for @code{undefined} suboptions,
17467@option{-fsanitize=float-cast-overflow},
17468@option{-fsanitize=float-divide-by-zero} and
17469@option{-fsanitize=bounds-strict}.
17470If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17471and @code{-fsanitize=vptr} is enabled on the command line, the
17472instrumentation is silently ignored as the instrumentation always needs
17473@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17474
d77de738 17475@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17476@item -fsanitize-undefined-trap-on-error
d77de738
ML
17477The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17478equivalent of @option{-fsanitize-trap=all}.
17479
d77de738 17480@opindex fsanitize-coverage=trace-pc
ddf6fe37 17481@item -fsanitize-coverage=trace-pc
d77de738
ML
17482Enable coverage-guided fuzzing code instrumentation.
17483Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17484
d77de738 17485@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17486@item -fsanitize-coverage=trace-cmp
d77de738
ML
17487Enable dataflow guided fuzzing code instrumentation.
17488Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17489@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17490@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17491variable or @code{__sanitizer_cov_trace_const_cmp1},
17492@code{__sanitizer_cov_trace_const_cmp2},
17493@code{__sanitizer_cov_trace_const_cmp4} or
17494@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17495operand constant, @code{__sanitizer_cov_trace_cmpf} or
17496@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17497@code{__sanitizer_cov_trace_switch} for switch statements.
17498
d77de738 17499@opindex fcf-protection
ddf6fe37 17500@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17501Enable code instrumentation of control-flow transfers to increase
17502program security by checking that target addresses of control-flow
17503transfer instructions (such as indirect function call, function return,
17504indirect jump) are valid. This prevents diverting the flow of control
17505to an unexpected target. This is intended to protect against such
17506threats as Return-oriented Programming (ROP), and similarly
17507call/jmp-oriented programming (COP/JOP).
17508
17509The value @code{branch} tells the compiler to implement checking of
17510validity of control-flow transfer at the point of indirect branch
17511instructions, i.e.@: call/jmp instructions. The value @code{return}
17512implements checking of validity at the point of returning from a
17513function. The value @code{full} is an alias for specifying both
17514@code{branch} and @code{return}. The value @code{none} turns off
17515instrumentation.
17516
17517The value @code{check} is used for the final link with link-time
17518optimization (LTO). An error is issued if LTO object files are
17519compiled with different @option{-fcf-protection} values. The
17520value @code{check} is ignored at the compile time.
17521
17522The macro @code{__CET__} is defined when @option{-fcf-protection} is
17523used. The first bit of @code{__CET__} is set to 1 for the value
17524@code{branch} and the second bit of @code{__CET__} is set to 1 for
17525the @code{return}.
17526
17527You can also use the @code{nocf_check} attribute to identify
17528which functions and calls should be skipped from instrumentation
17529(@pxref{Function Attributes}).
17530
17531Currently the x86 GNU/Linux target provides an implementation based
17532on Intel Control-flow Enforcement Technology (CET) which works for
17533i686 processor or newer.
17534
d77de738 17535@opindex fharden-compares
ddf6fe37 17536@item -fharden-compares
d77de738
ML
17537For every logical test that survives gimple optimizations and is
17538@emph{not} the condition in a conditional branch (for example,
17539conditions tested for conditional moves, or to store in boolean
17540variables), emit extra code to compute and verify the reversed
17541condition, and to call @code{__builtin_trap} if the results do not
17542match. Use with @samp{-fharden-conditional-branches} to cover all
17543conditionals.
17544
d77de738 17545@opindex fharden-conditional-branches
ddf6fe37 17546@item -fharden-conditional-branches
d77de738
ML
17547For every non-vectorized conditional branch that survives gimple
17548optimizations, emit extra code to compute and verify the reversed
17549condition, and to call @code{__builtin_trap} if the result is
17550unexpected. Use with @samp{-fharden-compares} to cover all
17551conditionals.
17552
551935d1
AO
17553@opindex fharden-control-flow-redundancy
17554@item -fharden-control-flow-redundancy
17555Emit extra code to set booleans when entering basic blocks, and to
17556verify and trap, at function exits, when the booleans do not form an
17557execution path that is compatible with the control flow graph.
17558
17559Verification takes place before returns, before mandatory tail calls
17560(see below) and, optionally, before escaping exceptions with
17561@option{-fhardcfr-check-exceptions}, before returning calls with
17562@option{-fhardcfr-check-returning-calls}, and before noreturn calls with
17563@option{-fhardcfr-check-noreturn-calls}). Tuning options
17564@option{--param hardcfr-max-blocks} and @option{--param
17565hardcfr-max-inline-blocks} are available.
17566
17567Tail call optimization takes place too late to affect control flow
17568redundancy, but calls annotated as mandatory tail calls by language
17569front-ends, and any calls marked early enough as potential tail calls
17570would also have verification issued before the call, but these
17571possibilities are merely theoretical, as these conditions can only be
17572met when using custom compiler plugins.
17573
17574@opindex fhardcfr-skip-leaf
17575@item -fhardcfr-skip-leaf
17576Disable @option{-fharden-control-flow-redundancy} in leaf functions.
17577
17578@opindex fhardcfr-check-exceptions
17579@opindex fno-hardcfr-check-exceptions
17580@item -fhardcfr-check-exceptions
17581When @option{-fharden-control-flow-redundancy} is active, check the
17582recorded execution path against the control flow graph at exception
17583escape points, as if the function body was wrapped with a cleanup
17584handler that performed the check and reraised. This option is enabled
17585by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
17586
17587@opindex fhardcfr-check-returning-calls
17588@opindex fno-hardcfr-check-returning-calls
17589@item -fhardcfr-check-returning-calls
17590When @option{-fharden-control-flow-redundancy} is active, check the
17591recorded execution path against the control flow graph before any
17592function call immediately followed by a return of its result, if any, so
17593as to not prevent tail-call optimization, whether or not it is
17594ultimately optimized to a tail call.
17595
17596This option is enabled by default whenever sibling call optimizations
17597are enabled (see @option{-foptimize-sibling-calls}), but it can be
17598enabled (or disabled, using its negated form) explicitly, regardless of
17599the optimizations.
17600
17601@opindex fhardcfr-check-noreturn-calls
17602@item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
17603When @option{-fharden-control-flow-redundancy} is active, check the
17604recorded execution path against the control flow graph before
17605@code{noreturn} calls, either all of them (@option{always}), those that
17606aren't expected to return control to the caller through an exception
17607(@option{no-xthrow}, the default), those that may not return control to
17608the caller through an exception either (@option{nothrow}), or none of
17609them (@option{never}).
17610
17611Checking before a @code{noreturn} function that may return control to
17612the caller through an exception may cause checking to be performed more
17613than once, if the exception is caught in the caller, whether by a
17614handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
17615enabled, the compiler will avoid associating a @code{noreturn} call with
17616the implicitly-added cleanup handler, since it would be redundant with
17617the check performed before the call, but other handlers or cleanups in
17618the function, if activated, will modify the recorded execution path and
17619check it again when another checkpoint is hit. The checkpoint may even
17620be another @code{noreturn} call, so checking may end up performed
17621multiple times.
17622
17623Various optimizers may cause calls to be marked as @code{noreturn}
17624and/or @code{nothrow}, even in the absence of the corresponding
17625attributes, which may affect the placement of checks before calls, as
17626well as the addition of implicit cleanup handlers for them. This
17627unpredictability, and the fact that raising and reraising exceptions
17628frequently amounts to implicitly calling @code{noreturn} functions, have
17629made @option{no-xthrow} the default setting for this option: it excludes
17630from the @code{noreturn} treatment only internal functions used to
17631(re)raise exceptions, that are not affected by these optimizations.
17632
d77de738 17633@opindex fstack-protector
ddf6fe37 17634@item -fstack-protector
d77de738
ML
17635Emit extra code to check for buffer overflows, such as stack smashing
17636attacks. This is done by adding a guard variable to functions with
17637vulnerable objects. This includes functions that call @code{alloca}, and
17638functions with buffers larger than or equal to 8 bytes. The guards are
17639initialized when a function is entered and then checked when the function
17640exits. If a guard check fails, an error message is printed and the program
17641exits. Only variables that are actually allocated on the stack are
17642considered, optimized away variables or variables allocated in registers
17643don't count.
17644
d77de738 17645@opindex fstack-protector-all
ddf6fe37 17646@item -fstack-protector-all
d77de738
ML
17647Like @option{-fstack-protector} except that all functions are protected.
17648
d77de738 17649@opindex fstack-protector-strong
ddf6fe37 17650@item -fstack-protector-strong
d77de738
ML
17651Like @option{-fstack-protector} but includes additional functions to
17652be protected --- those that have local array definitions, or have
17653references to local frame addresses. Only variables that are actually
17654allocated on the stack are considered, optimized away variables or variables
17655allocated in registers don't count.
17656
d77de738 17657@opindex fstack-protector-explicit
ddf6fe37 17658@item -fstack-protector-explicit
d77de738
ML
17659Like @option{-fstack-protector} but only protects those functions which
17660have the @code{stack_protect} attribute.
17661
d77de738 17662@opindex fstack-check
ddf6fe37 17663@item -fstack-check
d77de738
ML
17664Generate code to verify that you do not go beyond the boundary of the
17665stack. You should specify this flag if you are running in an
17666environment with multiple threads, but you only rarely need to specify it in
17667a single-threaded environment since stack overflow is automatically
17668detected on nearly all systems if there is only one stack.
17669
17670Note that this switch does not actually cause checking to be done; the
17671operating system or the language runtime must do that. The switch causes
17672generation of code to ensure that they see the stack being extended.
17673
17674You can additionally specify a string parameter: @samp{no} means no
17675checking, @samp{generic} means force the use of old-style checking,
17676@samp{specific} means use the best checking method and is equivalent
17677to bare @option{-fstack-check}.
17678
17679Old-style checking is a generic mechanism that requires no specific
17680target support in the compiler but comes with the following drawbacks:
17681
17682@enumerate
17683@item
17684Modified allocation strategy for large objects: they are always
17685allocated dynamically if their size exceeds a fixed threshold. Note this
17686may change the semantics of some code.
17687
17688@item
17689Fixed limit on the size of the static frame of functions: when it is
17690topped by a particular function, stack checking is not reliable and
17691a warning is issued by the compiler.
17692
17693@item
17694Inefficiency: because of both the modified allocation strategy and the
17695generic implementation, code performance is hampered.
17696@end enumerate
17697
17698Note that old-style stack checking is also the fallback method for
17699@samp{specific} if no target support has been added in the compiler.
17700
17701@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17702and stack overflows. @samp{specific} is an excellent choice when compiling
17703Ada code. It is not generally sufficient to protect against stack-clash
17704attacks. To protect against those you want @samp{-fstack-clash-protection}.
17705
d77de738 17706@opindex fstack-clash-protection
ddf6fe37 17707@item -fstack-clash-protection
d77de738
ML
17708Generate code to prevent stack clash style attacks. When this option is
17709enabled, the compiler will only allocate one page of stack space at a time
17710and each page is accessed immediately after allocation. Thus, it prevents
17711allocations from jumping over any stack guard page provided by the
17712operating system.
17713
17714Most targets do not fully support stack clash protection. However, on
17715those targets @option{-fstack-clash-protection} will protect dynamic stack
17716allocations. @option{-fstack-clash-protection} may also provide limited
17717protection for static stack allocations if the target supports
17718@option{-fstack-check=specific}.
17719
d77de738
ML
17720@opindex fstack-limit-register
17721@opindex fstack-limit-symbol
17722@opindex fno-stack-limit
ddf6fe37
AA
17723@item -fstack-limit-register=@var{reg}
17724@itemx -fstack-limit-symbol=@var{sym}
17725@itemx -fno-stack-limit
d77de738
ML
17726Generate code to ensure that the stack does not grow beyond a certain value,
17727either the value of a register or the address of a symbol. If a larger
17728stack is required, a signal is raised at run time. For most targets,
17729the signal is raised before the stack overruns the boundary, so
17730it is possible to catch the signal without taking special precautions.
17731
17732For instance, if the stack starts at absolute address @samp{0x80000000}
17733and grows downwards, you can use the flags
17734@option{-fstack-limit-symbol=__stack_limit} and
17735@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17736of 128KB@. Note that this may only work with the GNU linker.
17737
17738You can locally override stack limit checking by using the
17739@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17740
d77de738 17741@opindex fsplit-stack
ddf6fe37 17742@item -fsplit-stack
d77de738
ML
17743Generate code to automatically split the stack before it overflows.
17744The resulting program has a discontiguous stack which can only
17745overflow if the program is unable to allocate any more memory. This
17746is most useful when running threaded programs, as it is no longer
17747necessary to calculate a good stack size to use for each thread. This
17748is currently only implemented for the x86 targets running
17749GNU/Linux.
17750
17751When code compiled with @option{-fsplit-stack} calls code compiled
17752without @option{-fsplit-stack}, there may not be much stack space
17753available for the latter code to run. If compiling all code,
17754including library code, with @option{-fsplit-stack} is not an option,
17755then the linker can fix up these calls so that the code compiled
17756without @option{-fsplit-stack} always has a large stack. Support for
17757this is implemented in the gold linker in GNU binutils release 2.21
17758and later.
17759
d77de738 17760@opindex fvtable-verify
ddf6fe37 17761@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17762This option is only available when compiling C++ code.
17763It turns on (or off, if using @option{-fvtable-verify=none}) the security
17764feature that verifies at run time, for every virtual call, that
17765the vtable pointer through which the call is made is valid for the type of
17766the object, and has not been corrupted or overwritten. If an invalid vtable
17767pointer is detected at run time, an error is reported and execution of the
17768program is immediately halted.
17769
17770This option causes run-time data structures to be built at program startup,
17771which are used for verifying the vtable pointers.
17772The options @samp{std} and @samp{preinit}
17773control the timing of when these data structures are built. In both cases the
17774data structures are built before execution reaches @code{main}. Using
17775@option{-fvtable-verify=std} causes the data structures to be built after
17776shared libraries have been loaded and initialized.
17777@option{-fvtable-verify=preinit} causes them to be built before shared
17778libraries have been loaded and initialized.
17779
17780If this option appears multiple times in the command line with different
17781values specified, @samp{none} takes highest priority over both @samp{std} and
17782@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17783
d77de738 17784@opindex fvtv-debug
ddf6fe37 17785@item -fvtv-debug
d77de738
ML
17786When used in conjunction with @option{-fvtable-verify=std} or
17787@option{-fvtable-verify=preinit}, causes debug versions of the
17788runtime functions for the vtable verification feature to be called.
17789This flag also causes the compiler to log information about which
17790vtable pointers it finds for each class.
17791This information is written to a file named @file{vtv_set_ptr_data.log}
17792in the directory named by the environment variable @env{VTV_LOGS_DIR}
17793if that is defined or the current working directory otherwise.
17794
17795Note: This feature @emph{appends} data to the log file. If you want a fresh log
17796file, be sure to delete any existing one.
17797
d77de738 17798@opindex fvtv-counts
ddf6fe37 17799@item -fvtv-counts
d77de738
ML
17800This is a debugging flag. When used in conjunction with
17801@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17802causes the compiler to keep track of the total number of virtual calls
17803it encounters and the number of verifications it inserts. It also
17804counts the number of calls to certain run-time library functions
17805that it inserts and logs this information for each compilation unit.
17806The compiler writes this information to a file named
17807@file{vtv_count_data.log} in the directory named by the environment
17808variable @env{VTV_LOGS_DIR} if that is defined or the current working
17809directory otherwise. It also counts the size of the vtable pointer sets
17810for each class, and writes this information to @file{vtv_class_set_sizes.log}
17811in the same directory.
17812
17813Note: This feature @emph{appends} data to the log files. To get fresh log
17814files, be sure to delete any existing ones.
17815
d77de738 17816@opindex finstrument-functions
ddf6fe37 17817@item -finstrument-functions
d77de738
ML
17818Generate instrumentation calls for entry and exit to functions. Just
17819after function entry and just before function exit, the following
17820profiling functions are called with the address of the current
17821function and its call site. (On some platforms,
17822@code{__builtin_return_address} does not work beyond the current
17823function, so the call site information may not be available to the
17824profiling functions otherwise.)
17825
17826@smallexample
17827void __cyg_profile_func_enter (void *this_fn,
17828 void *call_site);
17829void __cyg_profile_func_exit (void *this_fn,
17830 void *call_site);
17831@end smallexample
17832
17833The first argument is the address of the start of the current function,
17834which may be looked up exactly in the symbol table.
17835
17836This instrumentation is also done for functions expanded inline in other
17837functions. The profiling calls indicate where, conceptually, the
17838inline function is entered and exited. This means that addressable
17839versions of such functions must be available. If all your uses of a
17840function are expanded inline, this may mean an additional expansion of
17841code size. If you use @code{extern inline} in your C code, an
17842addressable version of such functions must be provided. (This is
17843normally the case anyway, but if you get lucky and the optimizer always
17844expands the functions inline, you might have gotten away without
17845providing static copies.)
17846
17847A function may be given the attribute @code{no_instrument_function}, in
17848which case this instrumentation is not done. This can be used, for
17849example, for the profiling functions listed above, high-priority
17850interrupt routines, and any functions from which the profiling functions
17851cannot safely be called (perhaps signal handlers, if the profiling
17852routines generate output or allocate memory).
17853@xref{Common Function Attributes}.
17854
9c19597c 17855@opindex finstrument-functions-once
ddf6fe37 17856@item -finstrument-functions-once
d77de738
ML
17857This is similar to @option{-finstrument-functions}, but the profiling
17858functions are called only once per instrumented function, i.e. the first
17859profiling function is called after the first entry into the instrumented
17860function and the second profiling function is called before the exit
17861corresponding to this first entry.
17862
17863The definition of @code{once} for the purpose of this option is a little
17864vague because the implementation is not protected against data races.
17865As a result, the implementation only guarantees that the profiling
17866functions are called at @emph{least} once per process and at @emph{most}
17867once per thread, but the calls are always paired, that is to say, if a
17868thread calls the first function, then it will call the second function,
17869unless it never reaches the exit of the instrumented function.
17870
d77de738 17871@opindex finstrument-functions-exclude-file-list
ddf6fe37 17872@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17873
17874Set the list of functions that are excluded from instrumentation (see
17875the description of @option{-finstrument-functions}). If the file that
17876contains a function definition matches with one of @var{file}, then
17877that function is not instrumented. The match is done on substrings:
17878if the @var{file} parameter is a substring of the file name, it is
17879considered to be a match.
17880
17881For example:
17882
17883@smallexample
17884-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17885@end smallexample
17886
17887@noindent
17888excludes any inline function defined in files whose pathnames
17889contain @file{/bits/stl} or @file{include/sys}.
17890
17891If, for some reason, you want to include letter @samp{,} in one of
17892@var{sym}, write @samp{\,}. For example,
17893@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17894(note the single quote surrounding the option).
17895
d77de738 17896@opindex finstrument-functions-exclude-function-list
ddf6fe37 17897@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17898
17899This is similar to @option{-finstrument-functions-exclude-file-list},
17900but this option sets the list of function names to be excluded from
17901instrumentation. The function name to be matched is its user-visible
17902name, such as @code{vector<int> blah(const vector<int> &)}, not the
17903internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17904match is done on substrings: if the @var{sym} parameter is a substring
17905of the function name, it is considered to be a match. For C99 and C++
17906extended identifiers, the function name must be given in UTF-8, not
17907using universal character names.
17908
d77de738 17909@opindex fpatchable-function-entry
ddf6fe37 17910@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17911Generate @var{N} NOPs right at the beginning
17912of each function, with the function entry point before the @var{M}th NOP.
17913If @var{M} is omitted, it defaults to @code{0} so the
17914function entry points to the address just at the first NOP.
17915The NOP instructions reserve extra space which can be used to patch in
17916any desired instrumentation at run time, provided that the code segment
17917is writable. The amount of space is controllable indirectly via
17918the number of NOPs; the NOP instruction used corresponds to the instruction
17919emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17920is target-specific and may also depend on the architecture variant and/or
17921other compilation options.
17922
17923For run-time identification, the starting addresses of these areas,
17924which correspond to their respective function entries minus @var{M},
17925are additionally collected in the @code{__patchable_function_entries}
17926section of the resulting binary.
17927
17928Note that the value of @code{__attribute__ ((patchable_function_entry
17929(N,M)))} takes precedence over command-line option
17930@option{-fpatchable-function-entry=N,M}. This can be used to increase
17931the area size or to remove it completely on a single function.
17932If @code{N=0}, no pad location is recorded.
17933
17934The NOP instructions are inserted at---and maybe before, depending on
17935@var{M}---the function entry address, even before the prologue. On
17936PowerPC with the ELFv2 ABI, for a function with dual entry points,
17937the local entry point is this function entry address.
17938
17939The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17940ELFv2 ABI, for a function with dual entry points, the supported values
17941for @var{M} are 0, 2, 6 and 14.
17942@end table
17943
17944
17945@node Preprocessor Options
17946@section Options Controlling the Preprocessor
17947@cindex preprocessor options
17948@cindex options, preprocessor
17949
17950These options control the C preprocessor, which is run on each C source
17951file before actual compilation.
17952
17953If you use the @option{-E} option, nothing is done except preprocessing.
17954Some of these options make sense only together with @option{-E} because
17955they cause the preprocessor output to be unsuitable for actual
17956compilation.
17957
17958In addition to the options listed here, there are a number of options
17959to control search paths for include files documented in
17960@ref{Directory Options}.
17961Options to control preprocessor diagnostics are listed in
17962@ref{Warning Options}.
17963
17964@table @gcctabopt
17965@include cppopts.texi
17966
d77de738 17967@opindex Wp
ddf6fe37 17968@item -Wp,@var{option}
d77de738
ML
17969You can use @option{-Wp,@var{option}} to bypass the compiler driver
17970and pass @var{option} directly through to the preprocessor. If
17971@var{option} contains commas, it is split into multiple options at the
17972commas. However, many options are modified, translated or interpreted
17973by the compiler driver before being passed to the preprocessor, and
17974@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17975interface is undocumented and subject to change, so whenever possible
17976you should avoid using @option{-Wp} and let the driver handle the
17977options instead.
17978
d77de738 17979@opindex Xpreprocessor
ddf6fe37 17980@item -Xpreprocessor @var{option}
d77de738
ML
17981Pass @var{option} as an option to the preprocessor. You can use this to
17982supply system-specific preprocessor options that GCC does not
17983recognize.
17984
17985If you want to pass an option that takes an argument, you must use
17986@option{-Xpreprocessor} twice, once for the option and once for the argument.
17987
d77de738 17988@opindex no-integrated-cpp
ddf6fe37 17989@item -no-integrated-cpp
d77de738
ML
17990Perform preprocessing as a separate pass before compilation.
17991By default, GCC performs preprocessing as an integrated part of
17992input tokenization and parsing.
17993If this option is provided, the appropriate language front end
17994(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17995and Objective-C, respectively) is instead invoked twice,
17996once for preprocessing only and once for actual compilation
17997of the preprocessed input.
17998This option may be useful in conjunction with the @option{-B} or
17999@option{-wrapper} options to specify an alternate preprocessor or
18000perform additional processing of the program source between
18001normal preprocessing and compilation.
18002
d77de738 18003@opindex flarge-source-files
ddf6fe37 18004@item -flarge-source-files
d77de738
ML
18005Adjust GCC to expect large source files, at the expense of slower
18006compilation and higher memory usage.
18007
18008Specifically, GCC normally tracks both column numbers and line numbers
18009within source files and it normally prints both of these numbers in
18010diagnostics. However, once it has processed a certain number of source
18011lines, it stops tracking column numbers and only tracks line numbers.
18012This means that diagnostics for later lines do not include column numbers.
18013It also means that options like @option{-Wmisleading-indentation} cease to work
18014at that point, although the compiler prints a note if this happens.
18015Passing @option{-flarge-source-files} significantly increases the number
18016of source lines that GCC can process before it stops tracking columns.
18017
18018@end table
18019
18020@node Assembler Options
18021@section Passing Options to the Assembler
18022
18023@c prevent bad page break with this line
18024You can pass options to the assembler.
18025
18026@table @gcctabopt
d77de738 18027@opindex Wa
ddf6fe37 18028@item -Wa,@var{option}
d77de738
ML
18029Pass @var{option} as an option to the assembler. If @var{option}
18030contains commas, it is split into multiple options at the commas.
18031
d77de738 18032@opindex Xassembler
ddf6fe37 18033@item -Xassembler @var{option}
d77de738
ML
18034Pass @var{option} as an option to the assembler. You can use this to
18035supply system-specific assembler options that GCC does not
18036recognize.
18037
18038If you want to pass an option that takes an argument, you must use
18039@option{-Xassembler} twice, once for the option and once for the argument.
18040
18041@end table
18042
18043@node Link Options
18044@section Options for Linking
18045@cindex link options
18046@cindex options, linking
18047
18048These options come into play when the compiler links object files into
18049an executable output file. They are meaningless if the compiler is
18050not doing a link step.
18051
18052@table @gcctabopt
18053@cindex file names
18054@item @var{object-file-name}
18055A file name that does not end in a special recognized suffix is
18056considered to name an object file or library. (Object files are
18057distinguished from libraries by the linker according to the file
18058contents.) If linking is done, these object files are used as input
18059to the linker.
18060
d77de738
ML
18061@opindex c
18062@opindex S
18063@opindex E
ddf6fe37
AA
18064@item -c
18065@itemx -S
18066@itemx -E
d77de738
ML
18067If any of these options is used, then the linker is not run, and
18068object file names should not be used as arguments. @xref{Overall
18069Options}.
18070
d77de738 18071@opindex flinker-output
ddf6fe37 18072@item -flinker-output=@var{type}
d77de738
ML
18073This option controls code generation of the link-time optimizer. By
18074default the linker output is automatically determined by the linker
18075plugin. For debugging the compiler and if incremental linking with a
18076non-LTO object file is desired, it may be useful to control the type
18077manually.
18078
18079If @var{type} is @samp{exec}, code generation produces a static
18080binary. In this case @option{-fpic} and @option{-fpie} are both
18081disabled.
18082
18083If @var{type} is @samp{dyn}, code generation produces a shared
18084library. In this case @option{-fpic} or @option{-fPIC} is preserved,
18085but not enabled automatically. This allows to build shared libraries
18086without position-independent code on architectures where this is
18087possible, i.e.@: on x86.
18088
18089If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
18090executable. This results in similar optimizations as @samp{exec}
18091except that @option{-fpie} is not disabled if specified at compilation
18092time.
18093
18094If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
18095done. The sections containing intermediate code for link-time optimization are
18096merged, pre-optimized, and output to the resulting object file. In addition, if
18097@option{-ffat-lto-objects} is specified, binary code is produced for future
18098non-LTO linking. The object file produced by incremental linking is smaller
18099than a static library produced from the same object files. At link time the
18100result of incremental linking also loads faster than a static
18101library assuming that the majority of objects in the library are used.
18102
18103Finally @samp{nolto-rel} configures the compiler for incremental linking where
18104code generation is forced, a final binary is produced, and the intermediate
18105code for later link-time optimization is stripped. When multiple object files
18106are linked together the resulting code is better optimized than with
18107link-time optimizations disabled (for example, cross-module inlining
18108happens), but most of benefits of whole program optimizations are lost.
18109
18110During the incremental link (by @option{-r}) the linker plugin defaults to
18111@option{rel}. With current interfaces to GNU Binutils it is however not
18112possible to incrementally link LTO objects and non-LTO objects into a single
18113mixed object file. If any of object files in incremental link cannot
18114be used for link-time optimization, the linker plugin issues a warning and
18115uses @samp{nolto-rel}. To maintain whole program optimization, it is
18116recommended to link such objects into static library instead. Alternatively it
18117is possible to use H.J. Lu's binutils with support for mixed objects.
18118
d77de738 18119@opindex fuse-ld=bfd
ddf6fe37 18120@item -fuse-ld=bfd
d77de738
ML
18121Use the @command{bfd} linker instead of the default linker.
18122
d77de738 18123@opindex fuse-ld=gold
ddf6fe37 18124@item -fuse-ld=gold
d77de738
ML
18125Use the @command{gold} linker instead of the default linker.
18126
d77de738 18127@opindex fuse-ld=lld
ddf6fe37 18128@item -fuse-ld=lld
d77de738
ML
18129Use the LLVM @command{lld} linker instead of the default linker.
18130
d77de738 18131@opindex fuse-ld=mold
ddf6fe37 18132@item -fuse-ld=mold
d77de738
ML
18133Use the Modern Linker (@command{mold}) instead of the default linker.
18134
18135@cindex Libraries
ddf6fe37 18136@opindex l
d77de738
ML
18137@item -l@var{library}
18138@itemx -l @var{library}
d77de738
ML
18139Search the library named @var{library} when linking. (The second
18140alternative with the library as a separate argument is only for
18141POSIX compliance and is not recommended.)
18142
18143The @option{-l} option is passed directly to the linker by GCC. Refer
18144to your linker documentation for exact details. The general
18145description below applies to the GNU linker.
18146
18147The linker searches a standard list of directories for the library.
18148The directories searched include several standard system directories
18149plus any that you specify with @option{-L}.
18150
18151Static libraries are archives of object files, and have file names
18152like @file{lib@var{library}.a}. Some targets also support shared
18153libraries, which typically have names like @file{lib@var{library}.so}.
18154If both static and shared libraries are found, the linker gives
18155preference to linking with the shared library unless the
18156@option{-static} option is used.
18157
18158It makes a difference where in the command you write this option; the
18159linker searches and processes libraries and object files in the order they
18160are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
18161after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
18162to functions in @samp{z}, those functions may not be loaded.
18163
d77de738 18164@opindex lobjc
ddf6fe37 18165@item -lobjc
d77de738
ML
18166You need this special case of the @option{-l} option in order to
18167link an Objective-C or Objective-C++ program.
18168
d77de738 18169@opindex nostartfiles
ddf6fe37 18170@item -nostartfiles
d77de738
ML
18171Do not use the standard system startup files when linking.
18172The standard system libraries are used normally, unless @option{-nostdlib},
18173@option{-nolibc}, or @option{-nodefaultlibs} is used.
18174
d77de738 18175@opindex nodefaultlibs
ddf6fe37 18176@item -nodefaultlibs
d77de738
ML
18177Do not use the standard system libraries when linking.
18178Only the libraries you specify are passed to the linker, and options
18179specifying linkage of the system libraries, such as @option{-static-libgcc}
18180or @option{-shared-libgcc}, are ignored.
18181The standard startup files are used normally, unless @option{-nostartfiles}
18182is used.
18183
18184The compiler may generate calls to @code{memcmp},
18185@code{memset}, @code{memcpy} and @code{memmove}.
18186These entries are usually resolved by entries in
18187libc. These entry points should be supplied through some other
18188mechanism when this option is specified.
18189
d77de738 18190@opindex nolibc
ddf6fe37 18191@item -nolibc
d77de738
ML
18192Do not use the C library or system libraries tightly coupled with it when
18193linking. Still link with the startup files, @file{libgcc} or toolchain
18194provided language support libraries such as @file{libgnat}, @file{libgfortran}
18195or @file{libstdc++} unless options preventing their inclusion are used as
18196well. This typically removes @option{-lc} from the link command line, as well
18197as system libraries that normally go with it and become meaningless when
18198absence of a C library is assumed, for example @option{-lpthread} or
18199@option{-lm} in some configurations. This is intended for bare-board
18200targets when there is indeed no C library available.
18201
d77de738 18202@opindex nostdlib
ddf6fe37 18203@item -nostdlib
d77de738
ML
18204Do not use the standard system startup files or libraries when linking.
18205No startup files and only the libraries you specify are passed to
18206the linker, and options specifying linkage of the system libraries, such as
18207@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
18208
18209The compiler may generate calls to @code{memcmp}, @code{memset},
18210@code{memcpy} and @code{memmove}.
18211These entries are usually resolved by entries in
18212libc. These entry points should be supplied through some other
18213mechanism when this option is specified.
18214
18215@cindex @option{-lgcc}, use with @option{-nostdlib}
18216@cindex @option{-nostdlib} and unresolved references
18217@cindex unresolved references and @option{-nostdlib}
18218@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
18219@cindex @option{-nodefaultlibs} and unresolved references
18220@cindex unresolved references and @option{-nodefaultlibs}
18221One of the standard libraries bypassed by @option{-nostdlib} and
18222@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
18223which GCC uses to overcome shortcomings of particular machines, or special
18224needs for some languages.
18225(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
18226Collection (GCC) Internals},
18227for more discussion of @file{libgcc.a}.)
18228In most cases, you need @file{libgcc.a} even when you want to avoid
18229other standard libraries. In other words, when you specify @option{-nostdlib}
18230or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
18231This ensures that you have no unresolved references to internal GCC
18232library subroutines.
18233(An example of such an internal subroutine is @code{__main}, used to ensure C++
18234constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
18235GNU Compiler Collection (GCC) Internals}.)
18236
d77de738 18237@opindex nostdlib++
ddf6fe37 18238@item -nostdlib++
d77de738
ML
18239Do not implicitly link with standard C++ libraries.
18240
d77de738
ML
18241@opindex e
18242@opindex entry
ddf6fe37
AA
18243@item -e @var{entry}
18244@itemx --entry=@var{entry}
d77de738
ML
18245
18246Specify that the program entry point is @var{entry}. The argument is
18247interpreted by the linker; the GNU linker accepts either a symbol name
18248or an address.
18249
d77de738 18250@opindex pie
ddf6fe37 18251@item -pie
d77de738
ML
18252Produce a dynamically linked position independent executable on targets
18253that support it. For predictable results, you must also specify the same
18254set of options used for compilation (@option{-fpie}, @option{-fPIE},
18255or model suboptions) when you specify this linker option.
18256
d77de738 18257@opindex no-pie
ddf6fe37 18258@item -no-pie
d77de738
ML
18259Don't produce a dynamically linked position independent executable.
18260
d77de738 18261@opindex static-pie
ddf6fe37 18262@item -static-pie
d77de738
ML
18263Produce a static position independent executable on targets that support
18264it. A static position independent executable is similar to a static
18265executable, but can be loaded at any address without a dynamic linker.
18266For predictable results, you must also specify the same set of options
18267used for compilation (@option{-fpie}, @option{-fPIE}, or model
18268suboptions) when you specify this linker option.
18269
d77de738 18270@opindex pthread
ddf6fe37 18271@item -pthread
d77de738
ML
18272Link with the POSIX threads library. This option is supported on
18273GNU/Linux targets, most other Unix derivatives, and also on
18274x86 Cygwin and MinGW targets. On some targets this option also sets
18275flags for the preprocessor, so it should be used consistently for both
18276compilation and linking.
18277
d77de738 18278@opindex r
ddf6fe37 18279@item -r
d77de738
ML
18280Produce a relocatable object as output. This is also known as partial
18281linking.
18282
d77de738 18283@opindex rdynamic
ddf6fe37 18284@item -rdynamic
d77de738
ML
18285Pass the flag @option{-export-dynamic} to the ELF linker, on targets
18286that support it. This instructs the linker to add all symbols, not
18287only used ones, to the dynamic symbol table. This option is needed
18288for some uses of @code{dlopen} or to allow obtaining backtraces
18289from within a program.
18290
d77de738 18291@opindex s
ddf6fe37 18292@item -s
d77de738
ML
18293Remove all symbol table and relocation information from the executable.
18294
d77de738 18295@opindex static
ddf6fe37 18296@item -static
d77de738
ML
18297On systems that support dynamic linking, this overrides @option{-pie}
18298and prevents linking with the shared libraries. On other systems, this
18299option has no effect.
18300
d77de738 18301@opindex shared
ddf6fe37 18302@item -shared
d77de738
ML
18303Produce a shared object which can then be linked with other objects to
18304form an executable. Not all systems support this option. For predictable
18305results, you must also specify the same set of options used for compilation
18306(@option{-fpic}, @option{-fPIC}, or model suboptions) when
18307you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
18308needs to build supplementary stub code for constructors to work. On
18309multi-libbed systems, @samp{gcc -shared} must select the correct support
18310libraries to link against. Failing to supply the correct flags may lead
18311to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
18312is innocuous. @option{-shared} suppresses the addition of startup code
18313to alter the floating-point environment as done with @option{-ffast-math},
18314@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 18315
d77de738
ML
18316@opindex shared-libgcc
18317@opindex static-libgcc
ddf6fe37
AA
18318@item -shared-libgcc
18319@itemx -static-libgcc
d77de738
ML
18320On systems that provide @file{libgcc} as a shared library, these options
18321force the use of either the shared or static version, respectively.
18322If no shared version of @file{libgcc} was built when the compiler was
18323configured, these options have no effect.
18324
18325There are several situations in which an application should use the
18326shared @file{libgcc} instead of the static version. The most common
18327of these is when the application wishes to throw and catch exceptions
18328across different shared libraries. In that case, each of the libraries
18329as well as the application itself should use the shared @file{libgcc}.
18330
18331Therefore, the G++ driver automatically adds @option{-shared-libgcc}
18332whenever you build a shared library or a main executable, because C++
18333programs typically use exceptions, so this is the right thing to do.
18334
18335If, instead, you use the GCC driver to create shared libraries, you may
18336find that they are not always linked with the shared @file{libgcc}.
18337If GCC finds, at its configuration time, that you have a non-GNU linker
18338or a GNU linker that does not support option @option{--eh-frame-hdr},
18339it links the shared version of @file{libgcc} into shared libraries
18340by default. Otherwise, it takes advantage of the linker and optimizes
18341away the linking with the shared version of @file{libgcc}, linking with
18342the static version of libgcc by default. This allows exceptions to
18343propagate through such shared libraries, without incurring relocation
18344costs at library load time.
18345
18346However, if a library or main executable is supposed to throw or catch
18347exceptions, you must link it using the G++ driver, or using the option
18348@option{-shared-libgcc}, such that it is linked with the shared
18349@file{libgcc}.
18350
d77de738 18351@opindex static-libasan
ddf6fe37 18352@item -static-libasan
d77de738
ML
18353When the @option{-fsanitize=address} option is used to link a program,
18354the GCC driver automatically links against @option{libasan}. If
18355@file{libasan} is available as a shared library, and the @option{-static}
18356option is not used, then this links against the shared version of
18357@file{libasan}. The @option{-static-libasan} option directs the GCC
18358driver to link @file{libasan} statically, without necessarily linking
18359other libraries statically.
18360
d77de738 18361@opindex static-libtsan
ddf6fe37 18362@item -static-libtsan
d77de738
ML
18363When the @option{-fsanitize=thread} option is used to link a program,
18364the GCC driver automatically links against @option{libtsan}. If
18365@file{libtsan} is available as a shared library, and the @option{-static}
18366option is not used, then this links against the shared version of
18367@file{libtsan}. The @option{-static-libtsan} option directs the GCC
18368driver to link @file{libtsan} statically, without necessarily linking
18369other libraries statically.
18370
d77de738 18371@opindex static-liblsan
ddf6fe37 18372@item -static-liblsan
d77de738
ML
18373When the @option{-fsanitize=leak} option is used to link a program,
18374the GCC driver automatically links against @option{liblsan}. If
18375@file{liblsan} is available as a shared library, and the @option{-static}
18376option is not used, then this links against the shared version of
18377@file{liblsan}. The @option{-static-liblsan} option directs the GCC
18378driver to link @file{liblsan} statically, without necessarily linking
18379other libraries statically.
18380
d77de738 18381@opindex static-libubsan
ddf6fe37 18382@item -static-libubsan
d77de738
ML
18383When the @option{-fsanitize=undefined} option is used to link a program,
18384the GCC driver automatically links against @option{libubsan}. If
18385@file{libubsan} is available as a shared library, and the @option{-static}
18386option is not used, then this links against the shared version of
18387@file{libubsan}. The @option{-static-libubsan} option directs the GCC
18388driver to link @file{libubsan} statically, without necessarily linking
18389other libraries statically.
18390
d77de738 18391@opindex static-libstdc++
ddf6fe37 18392@item -static-libstdc++
d77de738
ML
18393When the @command{g++} program is used to link a C++ program, it
18394normally automatically links against @option{libstdc++}. If
18395@file{libstdc++} is available as a shared library, and the
18396@option{-static} option is not used, then this links against the
18397shared version of @file{libstdc++}. That is normally fine. However, it
18398is sometimes useful to freeze the version of @file{libstdc++} used by
18399the program without going all the way to a fully static link. The
18400@option{-static-libstdc++} option directs the @command{g++} driver to
18401link @file{libstdc++} statically, without necessarily linking other
18402libraries statically.
18403
d77de738 18404@opindex symbolic
ddf6fe37 18405@item -symbolic
d77de738
ML
18406Bind references to global symbols when building a shared object. Warn
18407about any unresolved references (unless overridden by the link editor
18408option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18409this option.
18410
d77de738
ML
18411@opindex T
18412@cindex linker script
f33d7a88 18413@item -T @var{script}
d77de738
ML
18414Use @var{script} as the linker script. This option is supported by most
18415systems using the GNU linker. On some targets, such as bare-board
18416targets without an operating system, the @option{-T} option may be required
18417when linking to avoid references to undefined symbols.
18418
d77de738 18419@opindex Xlinker
ddf6fe37 18420@item -Xlinker @var{option}
d77de738
ML
18421Pass @var{option} as an option to the linker. You can use this to
18422supply system-specific linker options that GCC does not recognize.
18423
18424If you want to pass an option that takes a separate argument, you must use
18425@option{-Xlinker} twice, once for the option and once for the argument.
18426For example, to pass @option{-assert definitions}, you must write
18427@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18428@option{-Xlinker "-assert definitions"}, because this passes the entire
18429string as a single argument, which is not what the linker expects.
18430
18431When using the GNU linker, it is usually more convenient to pass
18432arguments to linker options using the @option{@var{option}=@var{value}}
18433syntax than as separate arguments. For example, you can specify
18434@option{-Xlinker -Map=output.map} rather than
18435@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18436this syntax for command-line options.
18437
d77de738 18438@opindex Wl
ddf6fe37 18439@item -Wl,@var{option}
d77de738
ML
18440Pass @var{option} as an option to the linker. If @var{option} contains
18441commas, it is split into multiple options at the commas. You can use this
18442syntax to pass an argument to the option.
18443For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18444linker. When using the GNU linker, you can also get the same effect with
18445@option{-Wl,-Map=output.map}.
18446
d77de738 18447@opindex u
ddf6fe37 18448@item -u @var{symbol}
d77de738
ML
18449Pretend the symbol @var{symbol} is undefined, to force linking of
18450library modules to define it. You can use @option{-u} multiple times with
18451different symbols to force loading of additional library modules.
18452
d77de738 18453@opindex z
ddf6fe37 18454@item -z @var{keyword}
d77de738
ML
18455@option{-z} is passed directly on to the linker along with the keyword
18456@var{keyword}. See the section in the documentation of your linker for
18457permitted values and their meanings.
18458@end table
18459
18460@node Directory Options
18461@section Options for Directory Search
18462@cindex directory options
18463@cindex options, directory search
18464@cindex search path
18465
18466These options specify directories to search for header files, for
18467libraries and for parts of the compiler:
18468
18469@table @gcctabopt
18470@include cppdiropts.texi
18471
d77de738 18472@opindex iplugindir=
ddf6fe37 18473@item -iplugindir=@var{dir}
d77de738
ML
18474Set the directory to search for plugins that are passed
18475by @option{-fplugin=@var{name}} instead of
18476@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18477to be used by the user, but only passed by the driver.
18478
d77de738 18479@opindex L
ddf6fe37 18480@item -L@var{dir}
d77de738
ML
18481Add directory @var{dir} to the list of directories to be searched
18482for @option{-l}.
18483
d77de738 18484@opindex B
ddf6fe37 18485@item -B@var{prefix}
d77de738
ML
18486This option specifies where to find the executables, libraries,
18487include files, and data files of the compiler itself.
18488
18489The compiler driver program runs one or more of the subprograms
18490@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18491@var{prefix} as a prefix for each program it tries to run, both with and
18492without @samp{@var{machine}/@var{version}/} for the corresponding target
18493machine and compiler version.
18494
18495For each subprogram to be run, the compiler driver first tries the
18496@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18497is not specified, the driver tries two standard prefixes,
18498@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18499those results in a file name that is found, the unmodified program
18500name is searched for using the directories specified in your
18501@env{PATH} environment variable.
18502
18503The compiler checks to see if the path provided by @option{-B}
18504refers to a directory, and if necessary it adds a directory
18505separator character at the end of the path.
18506
18507@option{-B} prefixes that effectively specify directory names also apply
18508to libraries in the linker, because the compiler translates these
18509options into @option{-L} options for the linker. They also apply to
18510include files in the preprocessor, because the compiler translates these
18511options into @option{-isystem} options for the preprocessor. In this case,
18512the compiler appends @samp{include} to the prefix.
18513
18514The runtime support file @file{libgcc.a} can also be searched for using
18515the @option{-B} prefix, if needed. If it is not found there, the two
18516standard prefixes above are tried, and that is all. The file is left
18517out of the link if it is not found by those means.
18518
18519Another way to specify a prefix much like the @option{-B} prefix is to use
18520the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18521Variables}.
18522
18523As a special kludge, if the path provided by @option{-B} is
18524@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
185259, then it is replaced by @file{[dir/]include}. This is to help
18526with boot-strapping the compiler.
18527
d77de738 18528@opindex no-canonical-prefixes
ddf6fe37 18529@item -no-canonical-prefixes
d77de738
ML
18530Do not expand any symbolic links, resolve references to @samp{/../}
18531or @samp{/./}, or make the path absolute when generating a relative
18532prefix.
18533
d77de738 18534@opindex sysroot
ddf6fe37 18535@item --sysroot=@var{dir}
d77de738
ML
18536Use @var{dir} as the logical root directory for headers and libraries.
18537For example, if the compiler normally searches for headers in
18538@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18539searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18540
18541If you use both this option and the @option{-isysroot} option, then
18542the @option{--sysroot} option applies to libraries, but the
18543@option{-isysroot} option applies to header files.
18544
18545The GNU linker (beginning with version 2.16) has the necessary support
18546for this option. If your linker does not support this option, the
18547header file aspect of @option{--sysroot} still works, but the
18548library aspect does not.
18549
d77de738 18550@opindex no-sysroot-suffix
ddf6fe37 18551@item --no-sysroot-suffix
d77de738
ML
18552For some targets, a suffix is added to the root directory specified
18553with @option{--sysroot}, depending on the other options used, so that
18554headers may for example be found in
18555@file{@var{dir}/@var{suffix}/usr/include} instead of
18556@file{@var{dir}/usr/include}. This option disables the addition of
18557such a suffix.
18558
18559@end table
18560
18561@node Code Gen Options
18562@section Options for Code Generation Conventions
18563@cindex code generation conventions
18564@cindex options, code generation
18565@cindex run-time options
18566
18567These machine-independent options control the interface conventions
18568used in code generation.
18569
18570Most of them have both positive and negative forms; the negative form
18571of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18572one of the forms is listed---the one that is not the default. You
18573can figure out the other form by either removing @samp{no-} or adding
18574it.
18575
18576@table @gcctabopt
d77de738 18577@opindex fstack_reuse
ddf6fe37 18578@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18579This option controls stack space reuse for user declared local/auto variables
18580and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18581@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18582local variables and temporaries, @samp{named_vars} enables the reuse only for
18583user defined local variables with names, and @samp{none} disables stack reuse
18584completely. The default value is @samp{all}. The option is needed when the
18585program extends the lifetime of a scoped local variable or a compiler generated
18586temporary beyond the end point defined by the language. When a lifetime of
18587a variable ends, and if the variable lives in memory, the optimizing compiler
18588has the freedom to reuse its stack space with other temporaries or scoped
18589local variables whose live range does not overlap with it. Legacy code extending
18590local lifetime is likely to break with the stack reuse optimization.
18591
18592For example,
18593
18594@smallexample
18595 int *p;
18596 @{
18597 int local1;
18598
18599 p = &local1;
18600 local1 = 10;
18601 ....
18602 @}
18603 @{
18604 int local2;
18605 local2 = 20;
18606 ...
18607 @}
18608
18609 if (*p == 10) // out of scope use of local1
18610 @{
18611
18612 @}
18613@end smallexample
18614
18615Another example:
18616@smallexample
18617
18618 struct A
18619 @{
18620 A(int k) : i(k), j(k) @{ @}
18621 int i;
18622 int j;
18623 @};
18624
18625 A *ap;
18626
18627 void foo(const A& ar)
18628 @{
18629 ap = &ar;
18630 @}
18631
18632 void bar()
18633 @{
18634 foo(A(10)); // temp object's lifetime ends when foo returns
18635
18636 @{
18637 A a(20);
18638 ....
18639 @}
18640 ap->i+= 10; // ap references out of scope temp whose space
18641 // is reused with a. What is the value of ap->i?
18642 @}
18643
18644@end smallexample
18645
18646The lifetime of a compiler generated temporary is well defined by the C++
18647standard. When a lifetime of a temporary ends, and if the temporary lives
18648in memory, the optimizing compiler has the freedom to reuse its stack
18649space with other temporaries or scoped local variables whose live range
18650does not overlap with it. However some of the legacy code relies on
18651the behavior of older compilers in which temporaries' stack space is
18652not reused, the aggressive stack reuse can lead to runtime errors. This
18653option is used to control the temporary stack reuse optimization.
18654
d77de738 18655@opindex ftrapv
ddf6fe37 18656@item -ftrapv
d77de738
ML
18657This option generates traps for signed overflow on addition, subtraction,
18658multiplication operations.
18659The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18660@option{-ftrapv} @option{-fwrapv} on the command-line results in
18661@option{-fwrapv} being effective. Note that only active options override, so
18662using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18663results in @option{-ftrapv} being effective.
18664
d77de738 18665@opindex fwrapv
ddf6fe37 18666@item -fwrapv
d77de738
ML
18667This option instructs the compiler to assume that signed arithmetic
18668overflow of addition, subtraction and multiplication wraps around
18669using twos-complement representation. This flag enables some optimizations
18670and disables others.
18671The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18672@option{-ftrapv} @option{-fwrapv} on the command-line results in
18673@option{-fwrapv} being effective. Note that only active options override, so
18674using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18675results in @option{-ftrapv} being effective.
18676
d77de738 18677@opindex fwrapv-pointer
ddf6fe37 18678@item -fwrapv-pointer
d77de738
ML
18679This option instructs the compiler to assume that pointer arithmetic
18680overflow on addition and subtraction wraps around using twos-complement
18681representation. This flag disables some optimizations which assume
18682pointer overflow is invalid.
18683
d77de738 18684@opindex fstrict-overflow
ddf6fe37 18685@item -fstrict-overflow
d77de738
ML
18686This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18687negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18688
d77de738 18689@opindex fexceptions
ddf6fe37 18690@item -fexceptions
d77de738
ML
18691Enable exception handling. Generates extra code needed to propagate
18692exceptions. For some targets, this implies GCC generates frame
18693unwind information for all functions, which can produce significant data
18694size overhead, although it does not affect execution. If you do not
18695specify this option, GCC enables it by default for languages like
18696C++ that normally require exception handling, and disables it for
18697languages like C that do not normally require it. However, you may need
18698to enable this option when compiling C code that needs to interoperate
18699properly with exception handlers written in C++. You may also wish to
18700disable this option if you are compiling older C++ programs that don't
18701use exception handling.
18702
d77de738 18703@opindex fnon-call-exceptions
ddf6fe37 18704@item -fnon-call-exceptions
d77de738
ML
18705Generate code that allows trapping instructions to throw exceptions.
18706Note that this requires platform-specific runtime support that does
18707not exist everywhere. Moreover, it only allows @emph{trapping}
18708instructions to throw exceptions, i.e.@: memory references or floating-point
18709instructions. It does not allow exceptions to be thrown from
18710arbitrary signal handlers such as @code{SIGALRM}. This enables
18711@option{-fexceptions}.
18712
d77de738 18713@opindex fdelete-dead-exceptions
ddf6fe37 18714@item -fdelete-dead-exceptions
d77de738
ML
18715Consider that instructions that may throw exceptions but don't otherwise
18716contribute to the execution of the program can be optimized away.
18717This does not affect calls to functions except those with the
18718@code{pure} or @code{const} attributes.
18719This option is enabled by default for the Ada and C++ compilers, as permitted by
18720the language specifications.
18721Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18722
d77de738 18723@opindex funwind-tables
ddf6fe37 18724@item -funwind-tables
d77de738
ML
18725Similar to @option{-fexceptions}, except that it just generates any needed
18726static data, but does not affect the generated code in any other way.
18727You normally do not need to enable this option; instead, a language processor
18728that needs this handling enables it on your behalf.
18729
d77de738 18730@opindex fasynchronous-unwind-tables
ddf6fe37 18731@item -fasynchronous-unwind-tables
d77de738
ML
18732Generate unwind table in DWARF format, if supported by target machine. The
18733table is exact at each instruction boundary, so it can be used for stack
18734unwinding from asynchronous events (such as debugger or garbage collector).
18735
d77de738
ML
18736@opindex fno-gnu-unique
18737@opindex fgnu-unique
ddf6fe37 18738@item -fno-gnu-unique
d77de738
ML
18739On systems with recent GNU assembler and C library, the C++ compiler
18740uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18741of template static data members and static local variables in inline
18742functions are unique even in the presence of @code{RTLD_LOCAL}; this
18743is necessary to avoid problems with a library used by two different
18744@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18745therefore disagreeing with the other one about the binding of the
18746symbol. But this causes @code{dlclose} to be ignored for affected
18747DSOs; if your program relies on reinitialization of a DSO via
18748@code{dlclose} and @code{dlopen}, you can use
18749@option{-fno-gnu-unique}.
18750
d77de738 18751@opindex fpcc-struct-return
ddf6fe37 18752@item -fpcc-struct-return
d77de738
ML
18753Return ``short'' @code{struct} and @code{union} values in memory like
18754longer ones, rather than in registers. This convention is less
18755efficient, but it has the advantage of allowing intercallability between
18756GCC-compiled files and files compiled with other compilers, particularly
18757the Portable C Compiler (pcc).
18758
18759The precise convention for returning structures in memory depends
18760on the target configuration macros.
18761
18762Short structures and unions are those whose size and alignment match
18763that of some integer type.
18764
18765@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18766switch is not binary compatible with code compiled with the
18767@option{-freg-struct-return} switch.
18768Use it to conform to a non-default application binary interface.
18769
d77de738 18770@opindex freg-struct-return
ddf6fe37 18771@item -freg-struct-return
d77de738
ML
18772Return @code{struct} and @code{union} values in registers when possible.
18773This is more efficient for small structures than
18774@option{-fpcc-struct-return}.
18775
18776If you specify neither @option{-fpcc-struct-return} nor
18777@option{-freg-struct-return}, GCC defaults to whichever convention is
18778standard for the target. If there is no standard convention, GCC
18779defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18780the principal compiler. In those cases, we can choose the standard, and
18781we chose the more efficient register return alternative.
18782
18783@strong{Warning:} code compiled with the @option{-freg-struct-return}
18784switch is not binary compatible with code compiled with the
18785@option{-fpcc-struct-return} switch.
18786Use it to conform to a non-default application binary interface.
18787
d77de738 18788@opindex fshort-enums
ddf6fe37 18789@item -fshort-enums
d77de738
ML
18790Allocate to an @code{enum} type only as many bytes as it needs for the
18791declared range of possible values. Specifically, the @code{enum} type
18792is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
18793This option has no effect for an enumeration type with a fixed underlying
18794type.
d77de738
ML
18795
18796@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18797code that is not binary compatible with code generated without that switch.
18798Use it to conform to a non-default application binary interface.
18799
d77de738 18800@opindex fshort-wchar
ddf6fe37 18801@item -fshort-wchar
d77de738
ML
18802Override the underlying type for @code{wchar_t} to be @code{short
18803unsigned int} instead of the default for the target. This option is
18804useful for building programs to run under WINE@.
18805
18806@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18807code that is not binary compatible with code generated without that switch.
18808Use it to conform to a non-default application binary interface.
18809
d77de738
ML
18810@opindex fcommon
18811@opindex fno-common
18812@cindex tentative definitions
f33d7a88 18813@item -fcommon
d77de738
ML
18814In C code, this option controls the placement of global variables
18815defined without an initializer, known as @dfn{tentative definitions}
18816in the C standard. Tentative definitions are distinct from declarations
18817of a variable with the @code{extern} keyword, which do not allocate storage.
18818
18819The default is @option{-fno-common}, which specifies that the compiler places
18820uninitialized global variables in the BSS section of the object file.
18821This inhibits the merging of tentative definitions by the linker so you get a
18822multiple-definition error if the same variable is accidentally defined in more
18823than one compilation unit.
18824
18825The @option{-fcommon} places uninitialized global variables in a common block.
18826This allows the linker to resolve all tentative definitions of the same variable
18827in different compilation units to the same object, or to a non-tentative
18828definition. This behavior is inconsistent with C++, and on many targets implies
18829a speed and code size penalty on global variable references. It is mainly
18830useful to enable legacy code to link without errors.
18831
d77de738
ML
18832@opindex fno-ident
18833@opindex fident
ddf6fe37 18834@item -fno-ident
d77de738
ML
18835Ignore the @code{#ident} directive.
18836
d77de738 18837@opindex finhibit-size-directive
ddf6fe37 18838@item -finhibit-size-directive
d77de738
ML
18839Don't output a @code{.size} assembler directive, or anything else that
18840would cause trouble if the function is split in the middle, and the
18841two halves are placed at locations far apart in memory. This option is
18842used when compiling @file{crtstuff.c}; you should not need to use it
18843for anything else.
18844
d77de738 18845@opindex fverbose-asm
ddf6fe37 18846@item -fverbose-asm
d77de738
ML
18847Put extra commentary information in the generated assembly code to
18848make it more readable. This option is generally only of use to those
18849who actually need to read the generated assembly code (perhaps while
18850debugging the compiler itself).
18851
18852@option{-fno-verbose-asm}, the default, causes the
18853extra information to be omitted and is useful when comparing two assembler
18854files.
18855
18856The added comments include:
18857
18858@itemize @bullet
18859
18860@item
18861information on the compiler version and command-line options,
18862
18863@item
18864the source code lines associated with the assembly instructions,
18865in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18866
18867@item
18868hints on which high-level expressions correspond to
18869the various assembly instruction operands.
18870
18871@end itemize
18872
18873For example, given this C source file:
18874
18875@smallexample
18876int test (int n)
18877@{
18878 int i;
18879 int total = 0;
18880
18881 for (i = 0; i < n; i++)
18882 total += i * i;
18883
18884 return total;
18885@}
18886@end smallexample
18887
18888compiling to (x86_64) assembly via @option{-S} and emitting the result
18889direct to stdout via @option{-o} @option{-}
18890
18891@smallexample
18892gcc -S test.c -fverbose-asm -Os -o -
18893@end smallexample
18894
18895gives output similar to this:
18896
18897@smallexample
18898 .file "test.c"
18899# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18900 [...snip...]
18901# options passed:
18902 [...snip...]
18903
18904 .text
18905 .globl test
18906 .type test, @@function
18907test:
18908.LFB0:
18909 .cfi_startproc
18910# test.c:4: int total = 0;
18911 xorl %eax, %eax # <retval>
18912# test.c:6: for (i = 0; i < n; i++)
18913 xorl %edx, %edx # i
18914.L2:
18915# test.c:6: for (i = 0; i < n; i++)
18916 cmpl %edi, %edx # n, i
18917 jge .L5 #,
18918# test.c:7: total += i * i;
18919 movl %edx, %ecx # i, tmp92
18920 imull %edx, %ecx # i, tmp92
18921# test.c:6: for (i = 0; i < n; i++)
18922 incl %edx # i
18923# test.c:7: total += i * i;
18924 addl %ecx, %eax # tmp92, <retval>
18925 jmp .L2 #
18926.L5:
18927# test.c:10: @}
18928 ret
18929 .cfi_endproc
18930.LFE0:
18931 .size test, .-test
18932 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18933 .section .note.GNU-stack,"",@@progbits
18934@end smallexample
18935
18936The comments are intended for humans rather than machines and hence the
18937precise format of the comments is subject to change.
18938
d77de738 18939@opindex frecord-gcc-switches
ddf6fe37 18940@item -frecord-gcc-switches
d77de738
ML
18941This switch causes the command line used to invoke the
18942compiler to be recorded into the object file that is being created.
18943This switch is only implemented on some targets and the exact format
18944of the recording is target and binary file format dependent, but it
18945usually takes the form of a section containing ASCII text. This
18946switch is related to the @option{-fverbose-asm} switch, but that
18947switch only records information in the assembler output file as
18948comments, so it never reaches the object file.
18949See also @option{-grecord-gcc-switches} for another
18950way of storing compiler options into the object file.
18951
d77de738
ML
18952@opindex fpic
18953@cindex global offset table
18954@cindex PIC
f33d7a88 18955@item -fpic
d77de738
ML
18956Generate position-independent code (PIC) suitable for use in a shared
18957library, if supported for the target machine. Such code accesses all
18958constant addresses through a global offset table (GOT)@. The dynamic
18959loader resolves the GOT entries when the program starts (the dynamic
18960loader is not part of GCC; it is part of the operating system). If
18961the GOT size for the linked executable exceeds a machine-specific
18962maximum size, you get an error message from the linker indicating that
18963@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18964instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18965on the m68k and RS/6000. The x86 has no such limit.)
18966
18967Position-independent code requires special support, and therefore works
18968only on certain machines. For the x86, GCC supports PIC for System V
18969but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18970position-independent.
18971
18972When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18973are defined to 1.
18974
d77de738 18975@opindex fPIC
ddf6fe37 18976@item -fPIC
d77de738
ML
18977If supported for the target machine, emit position-independent code,
18978suitable for dynamic linking and avoiding any limit on the size of the
18979global offset table. This option makes a difference on AArch64, m68k,
18980PowerPC and SPARC@.
18981
18982Position-independent code requires special support, and therefore works
18983only on certain machines.
18984
18985When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18986are defined to 2.
18987
d77de738
ML
18988@opindex fpie
18989@opindex fPIE
ddf6fe37
AA
18990@item -fpie
18991@itemx -fPIE
d77de738
ML
18992These options are similar to @option{-fpic} and @option{-fPIC}, but the
18993generated position-independent code can be only linked into executables.
18994Usually these options are used to compile code that will be linked using
18995the @option{-pie} GCC option.
18996
18997@option{-fpie} and @option{-fPIE} both define the macros
18998@code{__pie__} and @code{__PIE__}. The macros have the value 1
18999for @option{-fpie} and 2 for @option{-fPIE}.
19000
d77de738
ML
19001@opindex fno-plt
19002@opindex fplt
ddf6fe37 19003@item -fno-plt
d77de738
ML
19004Do not use the PLT for external function calls in position-independent code.
19005Instead, load the callee address at call sites from the GOT and branch to it.
19006This leads to more efficient code by eliminating PLT stubs and exposing
19007GOT loads to optimizations. On architectures such as 32-bit x86 where
19008PLT stubs expect the GOT pointer in a specific register, this gives more
19009register allocation freedom to the compiler.
19010Lazy binding requires use of the PLT;
19011with @option{-fno-plt} all external symbols are resolved at load time.
19012
19013Alternatively, the function attribute @code{noplt} can be used to avoid calls
19014through the PLT for specific external functions.
19015
19016In position-dependent code, a few targets also convert calls to
19017functions that are marked to not use the PLT to use the GOT instead.
19018
d77de738
ML
19019@opindex fno-jump-tables
19020@opindex fjump-tables
ddf6fe37 19021@item -fno-jump-tables
d77de738
ML
19022Do not use jump tables for switch statements even where it would be
19023more efficient than other code generation strategies. This option is
19024of use in conjunction with @option{-fpic} or @option{-fPIC} for
19025building code that forms part of a dynamic linker and cannot
19026reference the address of a jump table. On some targets, jump tables
19027do not require a GOT and this option is not needed.
19028
d77de738
ML
19029@opindex fno-bit-tests
19030@opindex fbit-tests
ddf6fe37 19031@item -fno-bit-tests
d77de738
ML
19032Do not use bit tests for switch statements even where it would be
19033more efficient than other code generation strategies.
19034
d77de738 19035@opindex ffixed
ddf6fe37 19036@item -ffixed-@var{reg}
d77de738
ML
19037Treat the register named @var{reg} as a fixed register; generated code
19038should never refer to it (except perhaps as a stack pointer, frame
19039pointer or in some other fixed role).
19040
19041@var{reg} must be the name of a register. The register names accepted
19042are machine-specific and are defined in the @code{REGISTER_NAMES}
19043macro in the machine description macro file.
19044
19045This flag does not have a negative form, because it specifies a
19046three-way choice.
19047
d77de738 19048@opindex fcall-used
ddf6fe37 19049@item -fcall-used-@var{reg}
d77de738
ML
19050Treat the register named @var{reg} as an allocable register that is
19051clobbered by function calls. It may be allocated for temporaries or
19052variables that do not live across a call. Functions compiled this way
19053do not save and restore the register @var{reg}.
19054
19055It is an error to use this flag with the frame pointer or stack pointer.
19056Use of this flag for other registers that have fixed pervasive roles in
19057the machine's execution model produces disastrous results.
19058
19059This flag does not have a negative form, because it specifies a
19060three-way choice.
19061
d77de738 19062@opindex fcall-saved
ddf6fe37 19063@item -fcall-saved-@var{reg}
d77de738
ML
19064Treat the register named @var{reg} as an allocable register saved by
19065functions. It may be allocated even for temporaries or variables that
19066live across a call. Functions compiled this way save and restore
19067the register @var{reg} if they use it.
19068
19069It is an error to use this flag with the frame pointer or stack pointer.
19070Use of this flag for other registers that have fixed pervasive roles in
19071the machine's execution model produces disastrous results.
19072
19073A different sort of disaster results from the use of this flag for
19074a register in which function values may be returned.
19075
19076This flag does not have a negative form, because it specifies a
19077three-way choice.
19078
d77de738 19079@opindex fpack-struct
ddf6fe37 19080@item -fpack-struct[=@var{n}]
d77de738
ML
19081Without a value specified, pack all structure members together without
19082holes. When a value is specified (which must be a small power of two), pack
19083structure members according to this value, representing the maximum
19084alignment (that is, objects with default alignment requirements larger than
19085this are output potentially unaligned at the next fitting location.
19086
19087@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
19088code that is not binary compatible with code generated without that switch.
19089Additionally, it makes the code suboptimal.
19090Use it to conform to a non-default application binary interface.
19091
d77de738 19092@opindex fleading-underscore
ddf6fe37 19093@item -fleading-underscore
d77de738
ML
19094This option and its counterpart, @option{-fno-leading-underscore}, forcibly
19095change the way C symbols are represented in the object file. One use
19096is to help link with legacy assembly code.
19097
19098@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
19099generate code that is not binary compatible with code generated without that
19100switch. Use it to conform to a non-default application binary interface.
19101Not all targets provide complete support for this switch.
19102
d77de738 19103@opindex ftls-model
ddf6fe37 19104@item -ftls-model=@var{model}
d77de738
ML
19105Alter the thread-local storage model to be used (@pxref{Thread-Local}).
19106The @var{model} argument should be one of @samp{global-dynamic},
19107@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
19108Note that the choice is subject to optimization: the compiler may use
19109a more efficient model for symbols not visible outside of the translation
19110unit, or if @option{-fpic} is not given on the command line.
19111
19112The default without @option{-fpic} is @samp{initial-exec}; with
19113@option{-fpic} the default is @samp{global-dynamic}.
19114
d77de738 19115@opindex ftrampolines
ddf6fe37 19116@item -ftrampolines
d77de738
ML
19117For targets that normally need trampolines for nested functions, always
19118generate them instead of using descriptors. Otherwise, for targets that
19119do not need them, like for example HP-PA or IA-64, do nothing.
19120
19121A trampoline is a small piece of code that is created at run time on the
19122stack when the address of a nested function is taken, and is used to call
19123the nested function indirectly. Therefore, it requires the stack to be
19124made executable in order for the program to work properly.
19125
19126@option{-fno-trampolines} is enabled by default on a language by language
19127basis to let the compiler avoid generating them, if it computes that this
19128is safe, and replace them with descriptors. Descriptors are made up of data
19129only, but the generated code must be prepared to deal with them. As of this
19130writing, @option{-fno-trampolines} is enabled by default only for Ada.
19131
19132Moreover, code compiled with @option{-ftrampolines} and code compiled with
19133@option{-fno-trampolines} are not binary compatible if nested functions are
19134present. This option must therefore be used on a program-wide basis and be
19135manipulated with extreme care.
19136
19137For languages other than Ada, the @code{-ftrampolines} and
19138@code{-fno-trampolines} options currently have no effect, and
19139trampolines are always generated on platforms that need them
19140for nested functions.
19141
28d8c680
AB
19142@opindex ftrampoline-impl
19143@item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
19144By default, trampolines are generated on stack. However, certain platforms
19145(such as the Apple M1) do not permit an executable stack. Compiling with
19146@option{-ftrampoline-impl=heap} generate calls to
19147@code{__builtin_nested_func_ptr_created} and
19148@code{__builtin_nested_func_ptr_deleted} in order to allocate and
19149deallocate trampoline space on the executable heap. These functions are
19150implemented in libgcc, and will only be provided on specific targets:
19151x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
19152trampolines are @emph{not} guaranteed to be correctly deallocated if you
19153@code{setjmp}, instantiate nested functions, and then @code{longjmp} back
19154to a state prior to having allocated those nested functions.
19155
d77de738 19156@opindex fvisibility
ddf6fe37 19157@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
19158Set the default ELF image symbol visibility to the specified option---all
19159symbols are marked with this unless overridden within the code.
19160Using this feature can very substantially improve linking and
19161load times of shared object libraries, produce more optimized
19162code, provide near-perfect API export and prevent symbol clashes.
19163It is @strong{strongly} recommended that you use this in any shared objects
19164you distribute.
19165
19166Despite the nomenclature, @samp{default} always means public; i.e.,
19167available to be linked against from outside the shared object.
19168@samp{protected} and @samp{internal} are pretty useless in real-world
19169usage so the only other commonly used option is @samp{hidden}.
19170The default if @option{-fvisibility} isn't specified is
19171@samp{default}, i.e., make every symbol public.
19172
19173A good explanation of the benefits offered by ensuring ELF
19174symbols have the correct visibility is given by ``How To Write
19175Shared Libraries'' by Ulrich Drepper (which can be found at
19176@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
19177solution made possible by this option to marking things hidden when
19178the default is public is to make the default hidden and mark things
19179public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
19180and @code{__attribute__ ((visibility("default")))} instead of
19181@code{__declspec(dllexport)} you get almost identical semantics with
19182identical syntax. This is a great boon to those working with
19183cross-platform projects.
19184
19185For those adding visibility support to existing code, you may find
19186@code{#pragma GCC visibility} of use. This works by you enclosing
19187the declarations you wish to set visibility for with (for example)
19188@code{#pragma GCC visibility push(hidden)} and
19189@code{#pragma GCC visibility pop}.
19190Bear in mind that symbol visibility should be viewed @strong{as
19191part of the API interface contract} and thus all new code should
19192always specify visibility when it is not the default; i.e., declarations
19193only for use within the local DSO should @strong{always} be marked explicitly
19194as hidden as so to avoid PLT indirection overheads---making this
19195abundantly clear also aids readability and self-documentation of the code.
19196Note that due to ISO C++ specification requirements, @code{operator new} and
19197@code{operator delete} must always be of default visibility.
19198
19199Be aware that headers from outside your project, in particular system
19200headers and headers from any other library you use, may not be
19201expecting to be compiled with visibility other than the default. You
19202may need to explicitly say @code{#pragma GCC visibility push(default)}
19203before including any such headers.
19204
19205@code{extern} declarations are not affected by @option{-fvisibility}, so
19206a lot of code can be recompiled with @option{-fvisibility=hidden} with
19207no modifications. However, this means that calls to @code{extern}
19208functions with no explicit visibility use the PLT, so it is more
19209effective to use @code{__attribute ((visibility))} and/or
19210@code{#pragma GCC visibility} to tell the compiler which @code{extern}
19211declarations should be treated as hidden.
19212
19213Note that @option{-fvisibility} does affect C++ vague linkage
19214entities. This means that, for instance, an exception class that is
19215be thrown between DSOs must be explicitly marked with default
19216visibility so that the @samp{type_info} nodes are unified between
19217the DSOs.
19218
19219An overview of these techniques, their benefits and how to use them
19220is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
19221
d77de738 19222@opindex fstrict-volatile-bitfields
ddf6fe37 19223@item -fstrict-volatile-bitfields
d77de738
ML
19224This option should be used if accesses to volatile bit-fields (or other
19225structure fields, although the compiler usually honors those types
19226anyway) should use a single access of the width of the
19227field's type, aligned to a natural alignment if possible. For
19228example, targets with memory-mapped peripheral registers might require
19229all such accesses to be 16 bits wide; with this flag you can
19230declare all peripheral bit-fields as @code{unsigned short} (assuming short
19231is 16 bits on these targets) to force GCC to use 16-bit accesses
19232instead of, perhaps, a more efficient 32-bit access.
19233
19234If this option is disabled, the compiler uses the most efficient
19235instruction. In the previous example, that might be a 32-bit load
19236instruction, even though that accesses bytes that do not contain
19237any portion of the bit-field, or memory-mapped registers unrelated to
19238the one being updated.
19239
19240In some cases, such as when the @code{packed} attribute is applied to a
19241structure field, it may not be possible to access the field with a single
19242read or write that is correctly aligned for the target machine. In this
19243case GCC falls back to generating multiple accesses rather than code that
19244will fault or truncate the result at run time.
19245
19246Note: Due to restrictions of the C/C++11 memory model, write accesses are
19247not allowed to touch non bit-field members. It is therefore recommended
19248to define all bits of the field's type as bit-field members.
19249
19250The default value of this option is determined by the application binary
19251interface for the target processor.
19252
d77de738 19253@opindex fsync-libcalls
ddf6fe37 19254@item -fsync-libcalls
d77de738
ML
19255This option controls whether any out-of-line instance of the @code{__sync}
19256family of functions may be used to implement the C++11 @code{__atomic}
19257family of functions.
19258
19259The default value of this option is enabled, thus the only useful form
19260of the option is @option{-fno-sync-libcalls}. This option is used in
19261the implementation of the @file{libatomic} runtime library.
19262
19263@end table
19264
19265@node Developer Options
19266@section GCC Developer Options
19267@cindex developer options
19268@cindex debugging GCC
19269@cindex debug dump options
19270@cindex dump options
19271@cindex compilation statistics
19272
19273This section describes command-line options that are primarily of
19274interest to GCC developers, including options to support compiler
19275testing and investigation of compiler bugs and compile-time
19276performance problems. This includes options that produce debug dumps
19277at various points in the compilation; that print statistics such as
19278memory use and execution time; and that print information about GCC's
19279configuration, such as where it searches for libraries. You should
19280rarely need to use any of these options for ordinary compilation and
19281linking tasks.
19282
19283Many developer options that cause GCC to dump output to a file take an
19284optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
19285or @samp{-} to dump to standard output, and @samp{stderr} for standard
19286error.
19287
19288If @samp{=@var{filename}} is omitted, a default dump file name is
19289constructed by concatenating the base dump file name, a pass number,
19290phase letter, and pass name. The base dump file name is the name of
19291output file produced by the compiler if explicitly specified and not
19292an executable; otherwise it is the source file name.
19293The pass number is determined by the order passes are registered with
19294the compiler's pass manager.
19295This is generally the same as the order of execution, but passes
19296registered by plugins, target-specific passes, or passes that are
19297otherwise registered late are numbered higher than the pass named
19298@samp{final}, even if they are executed earlier. The phase letter is
19299one of @samp{i} (inter-procedural analysis), @samp{l}
19300(language-specific), @samp{r} (RTL), or @samp{t} (tree).
19301The files are created in the directory of the output file.
19302
19303@table @gcctabopt
19304
ddf6fe37 19305@opindex fcallgraph-info
d77de738
ML
19306@item -fcallgraph-info
19307@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
19308Makes the compiler output callgraph information for the program, on a
19309per-object-file basis. The information is generated in the common VCG
19310format. It can be decorated with additional, per-node and/or per-edge
19311information, if a list of comma-separated markers is additionally
19312specified. When the @code{su} marker is specified, the callgraph is
19313decorated with stack usage information; it is equivalent to
19314@option{-fstack-usage}. When the @code{da} marker is specified, the
19315callgraph is decorated with information about dynamically allocated
19316objects.
19317
19318When compiling with @option{-flto}, no callgraph information is output
19319along with the object file. At LTO link time, @option{-fcallgraph-info}
19320may generate multiple callgraph information files next to intermediate
19321LTO output files.
19322
ddf6fe37
AA
19323@opindex d
19324@opindex fdump-rtl-@var{pass}
d77de738
ML
19325@item -d@var{letters}
19326@itemx -fdump-rtl-@var{pass}
19327@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
19328Says to make debugging dumps during compilation at times specified by
19329@var{letters}. This is used for debugging the RTL-based passes of the
19330compiler.
19331
19332Some @option{-d@var{letters}} switches have different meaning when
19333@option{-E} is used for preprocessing. @xref{Preprocessor Options},
19334for information about preprocessor-specific dump options.
19335
19336Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
19337@option{-d} option @var{letters}. Here are the possible
19338letters for use in @var{pass} and @var{letters}, and their meanings:
19339
19340@table @gcctabopt
19341
d77de738 19342@opindex fdump-rtl-alignments
ddf6fe37 19343@item -fdump-rtl-alignments
d77de738
ML
19344Dump after branch alignments have been computed.
19345
d77de738 19346@opindex fdump-rtl-asmcons
ddf6fe37 19347@item -fdump-rtl-asmcons
d77de738
ML
19348Dump after fixing rtl statements that have unsatisfied in/out constraints.
19349
d77de738 19350@opindex fdump-rtl-auto_inc_dec
ddf6fe37 19351@item -fdump-rtl-auto_inc_dec
d77de738
ML
19352Dump after auto-inc-dec discovery. This pass is only run on
19353architectures that have auto inc or auto dec instructions.
19354
d77de738 19355@opindex fdump-rtl-barriers
ddf6fe37 19356@item -fdump-rtl-barriers
d77de738
ML
19357Dump after cleaning up the barrier instructions.
19358
d77de738 19359@opindex fdump-rtl-bbpart
ddf6fe37 19360@item -fdump-rtl-bbpart
d77de738
ML
19361Dump after partitioning hot and cold basic blocks.
19362
d77de738 19363@opindex fdump-rtl-bbro
ddf6fe37 19364@item -fdump-rtl-bbro
d77de738
ML
19365Dump after block reordering.
19366
d77de738
ML
19367@opindex fdump-rtl-btl2
19368@opindex fdump-rtl-btl2
ddf6fe37
AA
19369@item -fdump-rtl-btl1
19370@itemx -fdump-rtl-btl2
d77de738
ML
19371@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
19372after the two branch
19373target load optimization passes.
19374
d77de738 19375@opindex fdump-rtl-bypass
ddf6fe37 19376@item -fdump-rtl-bypass
d77de738
ML
19377Dump after jump bypassing and control flow optimizations.
19378
d77de738 19379@opindex fdump-rtl-combine
ddf6fe37 19380@item -fdump-rtl-combine
d77de738
ML
19381Dump after the RTL instruction combination pass.
19382
d77de738 19383@opindex fdump-rtl-compgotos
ddf6fe37 19384@item -fdump-rtl-compgotos
d77de738
ML
19385Dump after duplicating the computed gotos.
19386
d77de738
ML
19387@opindex fdump-rtl-ce1
19388@opindex fdump-rtl-ce2
19389@opindex fdump-rtl-ce3
ddf6fe37
AA
19390@item -fdump-rtl-ce1
19391@itemx -fdump-rtl-ce2
19392@itemx -fdump-rtl-ce3
d77de738
ML
19393@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
19394@option{-fdump-rtl-ce3} enable dumping after the three
19395if conversion passes.
19396
d77de738 19397@opindex fdump-rtl-cprop_hardreg
ddf6fe37 19398@item -fdump-rtl-cprop_hardreg
d77de738
ML
19399Dump after hard register copy propagation.
19400
d77de738 19401@opindex fdump-rtl-csa
ddf6fe37 19402@item -fdump-rtl-csa
d77de738
ML
19403Dump after combining stack adjustments.
19404
d77de738
ML
19405@opindex fdump-rtl-cse1
19406@opindex fdump-rtl-cse2
ddf6fe37
AA
19407@item -fdump-rtl-cse1
19408@itemx -fdump-rtl-cse2
d77de738
ML
19409@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
19410the two common subexpression elimination passes.
19411
d77de738 19412@opindex fdump-rtl-dce
ddf6fe37 19413@item -fdump-rtl-dce
d77de738
ML
19414Dump after the standalone dead code elimination passes.
19415
d77de738 19416@opindex fdump-rtl-dbr
ddf6fe37 19417@item -fdump-rtl-dbr
d77de738
ML
19418Dump after delayed branch scheduling.
19419
d77de738
ML
19420@opindex fdump-rtl-dce1
19421@opindex fdump-rtl-dce2
ddf6fe37
AA
19422@item -fdump-rtl-dce1
19423@itemx -fdump-rtl-dce2
d77de738
ML
19424@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19425the two dead store elimination passes.
19426
d77de738 19427@opindex fdump-rtl-eh
ddf6fe37 19428@item -fdump-rtl-eh
d77de738
ML
19429Dump after finalization of EH handling code.
19430
d77de738 19431@opindex fdump-rtl-eh_ranges
ddf6fe37 19432@item -fdump-rtl-eh_ranges
d77de738
ML
19433Dump after conversion of EH handling range regions.
19434
d77de738 19435@opindex fdump-rtl-expand
ddf6fe37 19436@item -fdump-rtl-expand
d77de738
ML
19437Dump after RTL generation.
19438
d77de738
ML
19439@opindex fdump-rtl-fwprop1
19440@opindex fdump-rtl-fwprop2
ddf6fe37
AA
19441@item -fdump-rtl-fwprop1
19442@itemx -fdump-rtl-fwprop2
d77de738
ML
19443@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19444dumping after the two forward propagation passes.
19445
d77de738
ML
19446@opindex fdump-rtl-gcse1
19447@opindex fdump-rtl-gcse2
ddf6fe37
AA
19448@item -fdump-rtl-gcse1
19449@itemx -fdump-rtl-gcse2
d77de738
ML
19450@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19451after global common subexpression elimination.
19452
d77de738 19453@opindex fdump-rtl-init-regs
ddf6fe37 19454@item -fdump-rtl-init-regs
d77de738
ML
19455Dump after the initialization of the registers.
19456
d77de738 19457@opindex fdump-rtl-initvals
ddf6fe37 19458@item -fdump-rtl-initvals
d77de738
ML
19459Dump after the computation of the initial value sets.
19460
d77de738 19461@opindex fdump-rtl-into_cfglayout
ddf6fe37 19462@item -fdump-rtl-into_cfglayout
d77de738
ML
19463Dump after converting to cfglayout mode.
19464
d77de738 19465@opindex fdump-rtl-ira
ddf6fe37 19466@item -fdump-rtl-ira
d77de738
ML
19467Dump after iterated register allocation.
19468
d77de738 19469@opindex fdump-rtl-jump
ddf6fe37 19470@item -fdump-rtl-jump
d77de738
ML
19471Dump after the second jump optimization.
19472
d77de738 19473@opindex fdump-rtl-loop2
ddf6fe37 19474@item -fdump-rtl-loop2
d77de738
ML
19475@option{-fdump-rtl-loop2} enables dumping after the rtl
19476loop optimization passes.
19477
d77de738 19478@opindex fdump-rtl-mach
ddf6fe37 19479@item -fdump-rtl-mach
d77de738
ML
19480Dump after performing the machine dependent reorganization pass, if that
19481pass exists.
19482
d77de738 19483@opindex fdump-rtl-mode_sw
ddf6fe37 19484@item -fdump-rtl-mode_sw
d77de738
ML
19485Dump after removing redundant mode switches.
19486
d77de738 19487@opindex fdump-rtl-rnreg
ddf6fe37 19488@item -fdump-rtl-rnreg
d77de738
ML
19489Dump after register renumbering.
19490
d77de738 19491@opindex fdump-rtl-outof_cfglayout
ddf6fe37 19492@item -fdump-rtl-outof_cfglayout
d77de738
ML
19493Dump after converting from cfglayout mode.
19494
d77de738 19495@opindex fdump-rtl-peephole2
ddf6fe37 19496@item -fdump-rtl-peephole2
d77de738
ML
19497Dump after the peephole pass.
19498
d77de738 19499@opindex fdump-rtl-postreload
ddf6fe37 19500@item -fdump-rtl-postreload
d77de738
ML
19501Dump after post-reload optimizations.
19502
d77de738 19503@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19504@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19505Dump after generating the function prologues and epilogues.
19506
d77de738
ML
19507@opindex fdump-rtl-sched1
19508@opindex fdump-rtl-sched2
ddf6fe37
AA
19509@item -fdump-rtl-sched1
19510@itemx -fdump-rtl-sched2
d77de738
ML
19511@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19512after the basic block scheduling passes.
19513
d77de738 19514@opindex fdump-rtl-ree
ddf6fe37 19515@item -fdump-rtl-ree
d77de738
ML
19516Dump after sign/zero extension elimination.
19517
d77de738 19518@opindex fdump-rtl-seqabstr
ddf6fe37 19519@item -fdump-rtl-seqabstr
d77de738
ML
19520Dump after common sequence discovery.
19521
d77de738 19522@opindex fdump-rtl-shorten
ddf6fe37 19523@item -fdump-rtl-shorten
d77de738
ML
19524Dump after shortening branches.
19525
d77de738 19526@opindex fdump-rtl-sibling
ddf6fe37 19527@item -fdump-rtl-sibling
d77de738
ML
19528Dump after sibling call optimizations.
19529
d77de738
ML
19530@opindex fdump-rtl-split1
19531@opindex fdump-rtl-split2
19532@opindex fdump-rtl-split3
19533@opindex fdump-rtl-split4
19534@opindex fdump-rtl-split5
ddf6fe37
AA
19535@item -fdump-rtl-split1
19536@itemx -fdump-rtl-split2
19537@itemx -fdump-rtl-split3
19538@itemx -fdump-rtl-split4
19539@itemx -fdump-rtl-split5
d77de738
ML
19540These options enable dumping after five rounds of
19541instruction splitting.
19542
d77de738 19543@opindex fdump-rtl-sms
ddf6fe37 19544@item -fdump-rtl-sms
d77de738
ML
19545Dump after modulo scheduling. This pass is only run on some
19546architectures.
19547
d77de738 19548@opindex fdump-rtl-stack
ddf6fe37 19549@item -fdump-rtl-stack
d77de738
ML
19550Dump after conversion from GCC's ``flat register file'' registers to the
19551x87's stack-like registers. This pass is only run on x86 variants.
19552
d77de738
ML
19553@opindex fdump-rtl-subreg1
19554@opindex fdump-rtl-subreg2
ddf6fe37
AA
19555@item -fdump-rtl-subreg1
19556@itemx -fdump-rtl-subreg2
d77de738
ML
19557@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19558the two subreg expansion passes.
19559
d77de738 19560@opindex fdump-rtl-unshare
ddf6fe37 19561@item -fdump-rtl-unshare
d77de738
ML
19562Dump after all rtl has been unshared.
19563
d77de738 19564@opindex fdump-rtl-vartrack
ddf6fe37 19565@item -fdump-rtl-vartrack
d77de738
ML
19566Dump after variable tracking.
19567
d77de738 19568@opindex fdump-rtl-vregs
ddf6fe37 19569@item -fdump-rtl-vregs
d77de738
ML
19570Dump after converting virtual registers to hard registers.
19571
d77de738 19572@opindex fdump-rtl-web
ddf6fe37 19573@item -fdump-rtl-web
d77de738
ML
19574Dump after live range splitting.
19575
d77de738
ML
19576@opindex fdump-rtl-regclass
19577@opindex fdump-rtl-subregs_of_mode_init
19578@opindex fdump-rtl-subregs_of_mode_finish
19579@opindex fdump-rtl-dfinit
19580@opindex fdump-rtl-dfinish
ddf6fe37
AA
19581@item -fdump-rtl-regclass
19582@itemx -fdump-rtl-subregs_of_mode_init
19583@itemx -fdump-rtl-subregs_of_mode_finish
19584@itemx -fdump-rtl-dfinit
19585@itemx -fdump-rtl-dfinish
d77de738
ML
19586These dumps are defined but always produce empty files.
19587
d77de738
ML
19588@opindex da
19589@opindex fdump-rtl-all
ddf6fe37
AA
19590@item -da
19591@itemx -fdump-rtl-all
d77de738
ML
19592Produce all the dumps listed above.
19593
d77de738 19594@opindex dA
ddf6fe37 19595@item -dA
d77de738
ML
19596Annotate the assembler output with miscellaneous debugging information.
19597
d77de738 19598@opindex dD
ddf6fe37 19599@item -dD
d77de738
ML
19600Dump all macro definitions, at the end of preprocessing, in addition to
19601normal output.
19602
d77de738 19603@opindex dH
ddf6fe37 19604@item -dH
d77de738
ML
19605Produce a core dump whenever an error occurs.
19606
d77de738 19607@opindex dp
ddf6fe37 19608@item -dp
d77de738
ML
19609Annotate the assembler output with a comment indicating which
19610pattern and alternative is used. The length and cost of each instruction are
19611also printed.
19612
d77de738 19613@opindex dP
ddf6fe37 19614@item -dP
d77de738
ML
19615Dump the RTL in the assembler output as a comment before each instruction.
19616Also turns on @option{-dp} annotation.
19617
d77de738 19618@opindex dx
ddf6fe37 19619@item -dx
d77de738
ML
19620Just generate RTL for a function instead of compiling it. Usually used
19621with @option{-fdump-rtl-expand}.
19622@end table
19623
d77de738 19624@opindex fdump-debug
ddf6fe37 19625@item -fdump-debug
d77de738
ML
19626Dump debugging information generated during the debug
19627generation phase.
19628
d77de738 19629@opindex fdump-earlydebug
ddf6fe37 19630@item -fdump-earlydebug
d77de738
ML
19631Dump debugging information generated during the early debug
19632generation phase.
19633
d77de738 19634@opindex fdump-noaddr
ddf6fe37 19635@item -fdump-noaddr
d77de738
ML
19636When doing debugging dumps, suppress address output. This makes it more
19637feasible to use diff on debugging dumps for compiler invocations with
19638different compiler binaries and/or different
19639text / bss / data / heap / stack / dso start locations.
19640
d77de738 19641@opindex freport-bug
ddf6fe37 19642@item -freport-bug
d77de738
ML
19643Collect and dump debug information into a temporary file if an
19644internal compiler error (ICE) occurs.
19645
d77de738 19646@opindex fdump-unnumbered
ddf6fe37 19647@item -fdump-unnumbered
d77de738
ML
19648When doing debugging dumps, suppress instruction numbers and address output.
19649This makes it more feasible to use diff on debugging dumps for compiler
19650invocations with different options, in particular with and without
19651@option{-g}.
19652
d77de738 19653@opindex fdump-unnumbered-links
ddf6fe37 19654@item -fdump-unnumbered-links
d77de738
ML
19655When doing debugging dumps (see @option{-d} option above), suppress
19656instruction numbers for the links to the previous and next instructions
19657in a sequence.
19658
ddf6fe37 19659@opindex fdump-ipa
d77de738
ML
19660@item -fdump-ipa-@var{switch}
19661@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19662Control the dumping at various stages of inter-procedural analysis
19663language tree to a file. The file name is generated by appending a
19664switch specific suffix to the source file name, and the file is created
19665in the same directory as the output file. The following dumps are
19666possible:
19667
19668@table @samp
19669@item all
19670Enables all inter-procedural analysis dumps.
19671
19672@item cgraph
19673Dumps information about call-graph optimization, unused function removal,
19674and inlining decisions.
19675
19676@item inline
19677Dump after function inlining.
19678
19679@end table
19680
19681Additionally, the options @option{-optimized}, @option{-missed},
19682@option{-note}, and @option{-all} can be provided, with the same meaning
19683as for @option{-fopt-info}, defaulting to @option{-optimized}.
19684
19685For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19686information on callsites that were inlined, along with callsites
19687that were not inlined.
19688
19689By default, the dump will contain messages about successful
19690optimizations (equivalent to @option{-optimized}) together with
19691low-level details about the analysis.
19692
d77de738 19693@opindex fdump-lang
ddf6fe37 19694@item -fdump-lang
d77de738
ML
19695Dump language-specific information. The file name is made by appending
19696@file{.lang} to the source file name.
19697
ddf6fe37
AA
19698@opindex fdump-lang-all
19699@opindex fdump-lang
d77de738
ML
19700@item -fdump-lang-all
19701@itemx -fdump-lang-@var{switch}
19702@itemx -fdump-lang-@var{switch}-@var{options}
19703@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19704Control the dumping of language-specific information. The @var{options}
19705and @var{filename} portions behave as described in the
19706@option{-fdump-tree} option. The following @var{switch} values are
19707accepted:
19708
19709@table @samp
19710@item all
19711
19712Enable all language-specific dumps.
19713
19714@item class
19715Dump class hierarchy information. Virtual table information is emitted
19716unless '@option{slim}' is specified. This option is applicable to C++ only.
19717
19718@item module
19719Dump module information. Options @option{lineno} (locations),
19720@option{graph} (reachability), @option{blocks} (clusters),
19721@option{uid} (serialization), @option{alias} (mergeable),
19722@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19723(macros) may provide additional information. This option is
19724applicable to C++ only.
19725
19726@item raw
19727Dump the raw internal tree data. This option is applicable to C++ only.
19728
19729@end table
19730
d77de738 19731@opindex fdump-passes
ddf6fe37 19732@item -fdump-passes
d77de738
ML
19733Print on @file{stderr} the list of optimization passes that are turned
19734on and off by the current command-line options.
19735
d77de738 19736@opindex fdump-statistics
ddf6fe37 19737@item -fdump-statistics-@var{option}
d77de738
ML
19738Enable and control dumping of pass statistics in a separate file. The
19739file name is generated by appending a suffix ending in
19740@samp{.statistics} to the source file name, and the file is created in
19741the same directory as the output file. If the @samp{-@var{option}}
19742form is used, @samp{-stats} causes counters to be summed over the
19743whole compilation unit while @samp{-details} dumps every event as
19744the passes generate them. The default with no option is to sum
19745counters for each function compiled.
19746
ddf6fe37
AA
19747@opindex fdump-tree-all
19748@opindex fdump-tree
d77de738
ML
19749@item -fdump-tree-all
19750@itemx -fdump-tree-@var{switch}
19751@itemx -fdump-tree-@var{switch}-@var{options}
19752@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19753Control the dumping at various stages of processing the intermediate
19754language tree to a file. If the @samp{-@var{options}}
19755form is used, @var{options} is a list of @samp{-} separated options
19756which control the details of the dump. Not all options are applicable
19757to all dumps; those that are not meaningful are ignored. The
19758following options are available
19759
19760@table @samp
19761@item address
19762Print the address of each node. Usually this is not meaningful as it
19763changes according to the environment and source file. Its primary use
19764is for tying up a dump file with a debug environment.
19765@item asmname
19766If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19767in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19768use working backward from mangled names in the assembly file.
19769@item slim
19770When dumping front-end intermediate representations, inhibit dumping
19771of members of a scope or body of a function merely because that scope
19772has been reached. Only dump such items when they are directly reachable
19773by some other path.
19774
19775When dumping pretty-printed trees, this option inhibits dumping the
19776bodies of control structures.
19777
19778When dumping RTL, print the RTL in slim (condensed) form instead of
19779the default LISP-like representation.
19780@item raw
19781Print a raw representation of the tree. By default, trees are
19782pretty-printed into a C-like representation.
19783@item details
19784Enable more detailed dumps (not honored by every dump option). Also
19785include information from the optimization passes.
19786@item stats
19787Enable dumping various statistics about the pass (not honored by every dump
19788option).
19789@item blocks
19790Enable showing basic block boundaries (disabled in raw dumps).
19791@item graph
19792For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19793dump a representation of the control flow graph suitable for viewing with
19794GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19795the file is pretty-printed as a subgraph, so that GraphViz can render them
19796all in a single plot.
19797
19798This option currently only works for RTL dumps, and the RTL is always
19799dumped in slim form.
19800@item vops
19801Enable showing virtual operands for every statement.
19802@item lineno
19803Enable showing line numbers for statements.
19804@item uid
19805Enable showing the unique ID (@code{DECL_UID}) for each variable.
19806@item verbose
19807Enable showing the tree dump for each statement.
19808@item eh
19809Enable showing the EH region number holding each statement.
19810@item scev
19811Enable showing scalar evolution analysis details.
19812@item optimized
19813Enable showing optimization information (only available in certain
19814passes).
19815@item missed
19816Enable showing missed optimization information (only available in certain
19817passes).
19818@item note
19819Enable other detailed optimization information (only available in
19820certain passes).
19821@item all
19822Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19823and @option{lineno}.
19824@item optall
19825Turn on all optimization options, i.e., @option{optimized},
19826@option{missed}, and @option{note}.
19827@end table
19828
19829To determine what tree dumps are available or find the dump for a pass
19830of interest follow the steps below.
19831
19832@enumerate
19833@item
19834Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19835look for a code that corresponds to the pass you are interested in.
19836For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19837@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19838The number at the end distinguishes distinct invocations of the same pass.
19839@item
19840To enable the creation of the dump file, append the pass code to
19841the @option{-fdump-} option prefix and invoke GCC with it. For example,
19842to enable the dump from the Early Value Range Propagation pass, invoke
19843GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19844specify the name of the dump file. If you don't specify one, GCC
19845creates as described below.
19846@item
19847Find the pass dump in a file whose name is composed of three components
19848separated by a period: the name of the source file GCC was invoked to
19849compile, a numeric suffix indicating the pass number followed by the
19850letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19851and finally the pass code. For example, the Early VRP pass dump might
19852be in a file named @file{myfile.c.038t.evrp} in the current working
19853directory. Note that the numeric codes are not stable and may change
19854from one version of GCC to another.
19855@end enumerate
19856
ddf6fe37 19857@opindex fopt-info
d77de738
ML
19858@item -fopt-info
19859@itemx -fopt-info-@var{options}
19860@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19861Controls optimization dumps from various optimization passes. If the
19862@samp{-@var{options}} form is used, @var{options} is a list of
19863@samp{-} separated option keywords to select the dump details and
19864optimizations.
19865
19866The @var{options} can be divided into three groups:
19867@enumerate
19868@item
19869options describing what kinds of messages should be emitted,
19870@item
19871options describing the verbosity of the dump, and
19872@item
19873options describing which optimizations should be included.
19874@end enumerate
19875The options from each group can be freely mixed as they are
19876non-overlapping. However, in case of any conflicts,
19877the later options override the earlier options on the command
19878line.
19879
19880The following options control which kinds of messages should be emitted:
19881
19882@table @samp
19883@item optimized
19884Print information when an optimization is successfully applied. It is
19885up to a pass to decide which information is relevant. For example, the
19886vectorizer passes print the source location of loops which are
19887successfully vectorized.
19888@item missed
19889Print information about missed optimizations. Individual passes
19890control which information to include in the output.
19891@item note
19892Print verbose information about optimizations, such as certain
19893transformations, more detailed messages about decisions etc.
19894@item all
19895Print detailed optimization information. This includes
19896@samp{optimized}, @samp{missed}, and @samp{note}.
19897@end table
19898
19899The following option controls the dump verbosity:
19900
19901@table @samp
19902@item internals
19903By default, only ``high-level'' messages are emitted. This option enables
19904additional, more detailed, messages, which are likely to only be of interest
19905to GCC developers.
19906@end table
19907
19908One or more of the following option keywords can be used to describe a
19909group of optimizations:
19910
19911@table @samp
19912@item ipa
19913Enable dumps from all interprocedural optimizations.
19914@item loop
19915Enable dumps from all loop optimizations.
19916@item inline
19917Enable dumps from all inlining optimizations.
19918@item omp
19919Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19920@item vec
19921Enable dumps from all vectorization optimizations.
19922@item optall
19923Enable dumps from all optimizations. This is a superset of
19924the optimization groups listed above.
19925@end table
19926
19927If @var{options} is
19928omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19929about successful optimizations from all the passes, omitting messages
19930that are treated as ``internals''.
19931
19932If the @var{filename} is provided, then the dumps from all the
19933applicable optimizations are concatenated into the @var{filename}.
19934Otherwise the dump is output onto @file{stderr}. Though multiple
19935@option{-fopt-info} options are accepted, only one of them can include
19936a @var{filename}. If other filenames are provided then all but the
19937first such option are ignored.
19938
19939Note that the output @var{filename} is overwritten
19940in case of multiple translation units. If a combined output from
19941multiple translation units is desired, @file{stderr} should be used
19942instead.
19943
19944In the following example, the optimization info is output to
19945@file{stderr}:
19946
19947@smallexample
19948gcc -O3 -fopt-info
19949@end smallexample
19950
19951This example:
19952@smallexample
19953gcc -O3 -fopt-info-missed=missed.all
19954@end smallexample
19955
19956@noindent
19957outputs missed optimization report from all the passes into
19958@file{missed.all}, and this one:
19959
19960@smallexample
19961gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19962@end smallexample
19963
19964@noindent
19965prints information about missed optimization opportunities from
19966vectorization passes on @file{stderr}.
19967Note that @option{-fopt-info-vec-missed} is equivalent to
19968@option{-fopt-info-missed-vec}. The order of the optimization group
19969names and message types listed after @option{-fopt-info} does not matter.
19970
19971As another example,
19972@smallexample
19973gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19974@end smallexample
19975
19976@noindent
19977outputs information about missed optimizations as well as
19978optimized locations from all the inlining passes into
19979@file{inline.txt}.
19980
19981Finally, consider:
19982
19983@smallexample
19984gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19985@end smallexample
19986
19987@noindent
19988Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19989in conflict since only one output file is allowed. In this case, only
19990the first option takes effect and the subsequent options are
19991ignored. Thus only @file{vec.miss} is produced which contains
19992dumps from the vectorizer about missed opportunities.
19993
d77de738 19994@opindex fsave-optimization-record
ddf6fe37 19995@item -fsave-optimization-record
d77de738
ML
19996Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19997were performed, for those optimizations that support @option{-fopt-info}.
19998
19999This option is experimental and the format of the data within the
20000compressed JSON file is subject to change.
20001
20002It is roughly equivalent to a machine-readable version of
20003@option{-fopt-info-all}, as a collection of messages with source file,
20004line number and column number, with the following additional data for
20005each message:
20006
20007@itemize @bullet
20008
20009@item
20010the execution count of the code being optimized, along with metadata about
20011whether this was from actual profile data, or just an estimate, allowing
20012consumers to prioritize messages by code hotness,
20013
20014@item
20015the function name of the code being optimized, where applicable,
20016
20017@item
20018the ``inlining chain'' for the code being optimized, so that when
20019a function is inlined into several different places (which might
20020themselves be inlined), the reader can distinguish between the copies,
20021
20022@item
20023objects identifying those parts of the message that refer to expressions,
20024statements or symbol-table nodes, which of these categories they are, and,
20025when available, their source code location,
20026
20027@item
20028the GCC pass that emitted the message, and
20029
20030@item
20031the location in GCC's own code from which the message was emitted
20032
20033@end itemize
20034
20035Additionally, some messages are logically nested within other
20036messages, reflecting implementation details of the optimization
20037passes.
20038
d77de738 20039@opindex fsched-verbose
ddf6fe37 20040@item -fsched-verbose=@var{n}
d77de738
ML
20041On targets that use instruction scheduling, this option controls the
20042amount of debugging output the scheduler prints to the dump files.
20043
20044For @var{n} greater than zero, @option{-fsched-verbose} outputs the
20045same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
20046For @var{n} greater than one, it also output basic block probabilities,
20047detailed ready list information and unit/insn info. For @var{n} greater
20048than two, it includes RTL at abort point, control-flow and regions info.
20049And for @var{n} over four, @option{-fsched-verbose} also includes
20050dependence info.
20051
20052
20053
d77de738
ML
20054@opindex fdisable-
20055@opindex fenable-
ddf6fe37
AA
20056@item -fenable-@var{kind}-@var{pass}
20057@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
20058
20059This is a set of options that are used to explicitly disable/enable
20060optimization passes. These options are intended for use for debugging GCC.
20061Compiler users should use regular options for enabling/disabling
20062passes instead.
20063
20064@table @gcctabopt
20065
20066@item -fdisable-ipa-@var{pass}
20067Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20068statically invoked in the compiler multiple times, the pass name should be
20069appended with a sequential number starting from 1.
20070
20071@item -fdisable-rtl-@var{pass}
20072@itemx -fdisable-rtl-@var{pass}=@var{range-list}
20073Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
20074statically invoked in the compiler multiple times, the pass name should be
20075appended with a sequential number starting from 1. @var{range-list} is a
20076comma-separated list of function ranges or assembler names. Each range is a number
20077pair separated by a colon. The range is inclusive in both ends. If the range
20078is trivial, the number pair can be simplified as a single number. If the
20079function's call graph node's @var{uid} falls within one of the specified ranges,
20080the @var{pass} is disabled for that function. The @var{uid} is shown in the
20081function header of a dump file, and the pass names can be dumped by using
20082option @option{-fdump-passes}.
20083
20084@item -fdisable-tree-@var{pass}
20085@itemx -fdisable-tree-@var{pass}=@var{range-list}
20086Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
20087option arguments.
20088
20089@item -fenable-ipa-@var{pass}
20090Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20091statically invoked in the compiler multiple times, the pass name should be
20092appended with a sequential number starting from 1.
20093
20094@item -fenable-rtl-@var{pass}
20095@itemx -fenable-rtl-@var{pass}=@var{range-list}
20096Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
20097description and examples.
20098
20099@item -fenable-tree-@var{pass}
20100@itemx -fenable-tree-@var{pass}=@var{range-list}
20101Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
20102of option arguments.
20103
20104@end table
20105
20106Here are some examples showing uses of these options.
20107
20108@smallexample
20109
20110# disable ccp1 for all functions
20111 -fdisable-tree-ccp1
20112# disable complete unroll for function whose cgraph node uid is 1
20113 -fenable-tree-cunroll=1
20114# disable gcse2 for functions at the following ranges [1,1],
20115# [300,400], and [400,1000]
20116# disable gcse2 for functions foo and foo2
20117 -fdisable-rtl-gcse2=foo,foo2
20118# disable early inlining
20119 -fdisable-tree-einline
20120# disable ipa inlining
20121 -fdisable-ipa-inline
20122# enable tree full unroll
20123 -fenable-tree-unroll
20124
20125@end smallexample
20126
d77de738
ML
20127@opindex fchecking
20128@opindex fno-checking
ddf6fe37
AA
20129@item -fchecking
20130@itemx -fchecking=@var{n}
d77de738
ML
20131Enable internal consistency checking. The default depends on
20132the compiler configuration. @option{-fchecking=2} enables further
20133internal consistency checking that might affect code generation.
20134
d77de738 20135@opindex frandom-seed
ddf6fe37 20136@item -frandom-seed=@var{string}
d77de738
ML
20137This option provides a seed that GCC uses in place of
20138random numbers in generating certain symbol names
20139that have to be different in every compiled file. It is also used to
20140place unique stamps in coverage data files and the object files that
20141produce them. You can use the @option{-frandom-seed} option to produce
20142reproducibly identical object files.
20143
20144The @var{string} can either be a number (decimal, octal or hex) or an
20145arbitrary string (in which case it's converted to a number by
20146computing CRC32).
20147
20148The @var{string} should be different for every file you compile.
20149
d77de738 20150@opindex save-temps
ddf6fe37 20151@item -save-temps
d77de738
ML
20152Store the usual ``temporary'' intermediate files permanently; name them
20153as auxiliary output files, as specified described under
20154@option{-dumpbase} and @option{-dumpdir}.
20155
20156When used in combination with the @option{-x} command-line option,
20157@option{-save-temps} is sensible enough to avoid overwriting an
20158input source file with the same extension as an intermediate file.
20159The corresponding intermediate file may be obtained by renaming the
20160source file before using @option{-save-temps}.
20161
d77de738 20162@opindex save-temps=cwd
ddf6fe37 20163@item -save-temps=cwd
d77de738
ML
20164Equivalent to @option{-save-temps -dumpdir ./}.
20165
d77de738 20166@opindex save-temps=obj
ddf6fe37 20167@item -save-temps=obj
d77de738
ML
20168Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
20169@file{outdir/} is the directory of the output file specified after the
20170@option{-o} option, including any directory separators. If the
20171@option{-o} option is not used, the @option{-save-temps=obj} switch
20172behaves like @option{-save-temps=cwd}.
20173
d77de738 20174@opindex time
ddf6fe37 20175@item -time@r{[}=@var{file}@r{]}
d77de738
ML
20176Report the CPU time taken by each subprocess in the compilation
20177sequence. For C source files, this is the compiler proper and assembler
20178(plus the linker if linking is done).
20179
20180Without the specification of an output file, the output looks like this:
20181
20182@smallexample
20183# cc1 0.12 0.01
20184# as 0.00 0.01
20185@end smallexample
20186
20187The first number on each line is the ``user time'', that is time spent
20188executing the program itself. The second number is ``system time'',
20189time spent executing operating system routines on behalf of the program.
20190Both numbers are in seconds.
20191
20192With the specification of an output file, the output is appended to the
20193named file, and it looks like this:
20194
20195@smallexample
201960.12 0.01 cc1 @var{options}
201970.00 0.01 as @var{options}
20198@end smallexample
20199
20200The ``user time'' and the ``system time'' are moved before the program
20201name, and the options passed to the program are displayed, so that one
20202can later tell what file was being compiled, and with which options.
20203
d77de738 20204@opindex fdump-final-insns
ddf6fe37 20205@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
20206Dump the final internal representation (RTL) to @var{file}. If the
20207optional argument is omitted (or if @var{file} is @code{.}), the name
20208of the dump file is determined by appending @code{.gkd} to the
20209dump base name, see @option{-dumpbase}.
20210
d77de738
ML
20211@opindex fcompare-debug
20212@opindex fno-compare-debug
ddf6fe37 20213@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
20214If no error occurs during compilation, run the compiler a second time,
20215adding @var{opts} and @option{-fcompare-debug-second} to the arguments
20216passed to the second compilation. Dump the final internal
20217representation in both compilations, and print an error if they differ.
20218
20219If the equal sign is omitted, the default @option{-gtoggle} is used.
20220
20221The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
20222and nonzero, implicitly enables @option{-fcompare-debug}. If
20223@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
20224then it is used for @var{opts}, otherwise the default @option{-gtoggle}
20225is used.
20226
20227@option{-fcompare-debug=}, with the equal sign but without @var{opts},
20228is equivalent to @option{-fno-compare-debug}, which disables the dumping
20229of the final representation and the second compilation, preventing even
20230@env{GCC_COMPARE_DEBUG} from taking effect.
20231
20232To verify full coverage during @option{-fcompare-debug} testing, set
20233@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
20234which GCC rejects as an invalid option in any actual compilation
20235(rather than preprocessing, assembly or linking). To get just a
20236warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
20237not overridden} will do.
20238
d77de738 20239@opindex fcompare-debug-second
ddf6fe37 20240@item -fcompare-debug-second
d77de738
ML
20241This option is implicitly passed to the compiler for the second
20242compilation requested by @option{-fcompare-debug}, along with options to
20243silence warnings, and omitting other options that would cause the compiler
20244to produce output to files or to standard output as a side effect. Dump
20245files and preserved temporary files are renamed so as to contain the
20246@code{.gk} additional extension during the second compilation, to avoid
20247overwriting those generated by the first.
20248
20249When this option is passed to the compiler driver, it causes the
20250@emph{first} compilation to be skipped, which makes it useful for little
20251other than debugging the compiler proper.
20252
d77de738 20253@opindex gtoggle
ddf6fe37 20254@item -gtoggle
d77de738
ML
20255Turn off generation of debug info, if leaving out this option
20256generates it, or turn it on at level 2 otherwise. The position of this
20257argument in the command line does not matter; it takes effect after all
20258other options are processed, and it does so only once, no matter how
20259many times it is given. This is mainly intended to be used with
20260@option{-fcompare-debug}.
20261
d77de738
ML
20262@opindex fvar-tracking-assignments-toggle
20263@opindex fno-var-tracking-assignments-toggle
ddf6fe37 20264@item -fvar-tracking-assignments-toggle
d77de738
ML
20265Toggle @option{-fvar-tracking-assignments}, in the same way that
20266@option{-gtoggle} toggles @option{-g}.
20267
d77de738 20268@opindex Q
ddf6fe37 20269@item -Q
d77de738
ML
20270Makes the compiler print out each function name as it is compiled, and
20271print some statistics about each pass when it finishes.
20272
d77de738 20273@opindex ftime-report
ddf6fe37 20274@item -ftime-report
75d62394
DM
20275Makes the compiler print some statistics to stderr about the time consumed
20276by each pass when it finishes.
20277
20278If SARIF output of diagnostics was requested via
20279@option{-fdiagnostics-format=sarif-file} or
20280@option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
20281information is instead emitted in JSON form as part of SARIF output. The
20282precise format of this JSON data is subject to change, and the values may
20283not exactly match those emitted to stderr due to being written out at a
20284slightly different place within the compiler.
d77de738 20285
d77de738 20286@opindex ftime-report-details
ddf6fe37 20287@item -ftime-report-details
d77de738
ML
20288Record the time consumed by infrastructure parts separately for each pass.
20289
d77de738 20290@opindex fira-verbose
ddf6fe37 20291@item -fira-verbose=@var{n}
d77de738
ML
20292Control the verbosity of the dump file for the integrated register allocator.
20293The default value is 5. If the value @var{n} is greater or equal to 10,
20294the dump output is sent to stderr using the same format as @var{n} minus 10.
20295
d77de738 20296@opindex flto-report
ddf6fe37 20297@item -flto-report
d77de738
ML
20298Prints a report with internal details on the workings of the link-time
20299optimizer. The contents of this report vary from version to version.
20300It is meant to be useful to GCC developers when processing object
20301files in LTO mode (via @option{-flto}).
20302
20303Disabled by default.
20304
d77de738 20305@opindex flto-report-wpa
ddf6fe37 20306@item -flto-report-wpa
d77de738
ML
20307Like @option{-flto-report}, but only print for the WPA phase of link-time
20308optimization.
20309
d77de738 20310@opindex fmem-report
ddf6fe37 20311@item -fmem-report
d77de738
ML
20312Makes the compiler print some statistics about permanent memory
20313allocation when it finishes.
20314
d77de738 20315@opindex fmem-report-wpa
ddf6fe37 20316@item -fmem-report-wpa
d77de738
ML
20317Makes the compiler print some statistics about permanent memory
20318allocation for the WPA phase only.
20319
d77de738 20320@opindex fpre-ipa-mem-report
d77de738 20321@opindex fpost-ipa-mem-report
ddf6fe37
AA
20322@item -fpre-ipa-mem-report
20323@item -fpost-ipa-mem-report
d77de738
ML
20324Makes the compiler print some statistics about permanent memory
20325allocation before or after interprocedural optimization.
20326
d77de738 20327@opindex fmultiflags
ddf6fe37 20328@item -fmultiflags
d77de738
ML
20329This option enables multilib-aware @code{TFLAGS} to be used to build
20330target libraries with options different from those the compiler is
20331configured to use by default, through the use of specs (@xref{Spec
20332Files}) set up by compiler internals, by the target, or by builders at
20333configure time.
20334
20335Like @code{TFLAGS}, this allows the target libraries to be built for
20336portable baseline environments, while the compiler defaults to more
20337demanding ones. That's useful because users can easily override the
20338defaults the compiler is configured to use to build their own programs,
20339if the defaults are not ideal for their target environment, whereas
20340rebuilding the runtime libraries is usually not as easy or desirable.
20341
20342Unlike @code{TFLAGS}, the use of specs enables different flags to be
20343selected for different multilibs. The way to accomplish that is to
20344build with @samp{make TFLAGS=-fmultiflags}, after configuring
20345@samp{--with-specs=%@{fmultiflags:...@}}.
20346
20347This option is discarded by the driver once it's done processing driver
20348self spec.
20349
20350It is also useful to check that @code{TFLAGS} are being used to build
20351all target libraries, by configuring a non-bootstrap compiler
20352@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
20353the compiler and target libraries.
20354
d77de738 20355@opindex fprofile-report
ddf6fe37 20356@item -fprofile-report
d77de738
ML
20357Makes the compiler print some statistics about consistency of the
20358(estimated) profile and effect of individual passes.
20359
d77de738 20360@opindex fstack-usage
ddf6fe37 20361@item -fstack-usage
d77de738
ML
20362Makes the compiler output stack usage information for the program, on a
20363per-function basis. The filename for the dump is made by appending
20364@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
20365the output file, if explicitly specified and it is not an executable,
20366otherwise it is the basename of the source file. An entry is made up
20367of three fields:
20368
20369@itemize
20370@item
20371The name of the function.
20372@item
20373A number of bytes.
20374@item
20375One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
20376@end itemize
20377
20378The qualifier @code{static} means that the function manipulates the stack
20379statically: a fixed number of bytes are allocated for the frame on function
20380entry and released on function exit; no stack adjustments are otherwise made
20381in the function. The second field is this fixed number of bytes.
20382
20383The qualifier @code{dynamic} means that the function manipulates the stack
20384dynamically: in addition to the static allocation described above, stack
20385adjustments are made in the body of the function, for example to push/pop
20386arguments around function calls. If the qualifier @code{bounded} is also
20387present, the amount of these adjustments is bounded at compile time and
20388the second field is an upper bound of the total amount of stack used by
20389the function. If it is not present, the amount of these adjustments is
20390not bounded at compile time and the second field only represents the
20391bounded part.
20392
d77de738 20393@opindex fstats
ddf6fe37 20394@item -fstats
d77de738
ML
20395Emit statistics about front-end processing at the end of the compilation.
20396This option is supported only by the C++ front end, and
20397the information is generally only useful to the G++ development team.
20398
d77de738 20399@opindex fdbg-cnt-list
ddf6fe37 20400@item -fdbg-cnt-list
d77de738
ML
20401Print the name and the counter upper bound for all debug counters.
20402
20403
d77de738 20404@opindex fdbg-cnt
ddf6fe37 20405@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
20406Set the internal debug counter lower and upper bound. @var{counter-value-list}
20407is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
20408[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
20409the name of the counter and list of closed intervals.
20410The @var{lower_bound} is optional and is zero
20411initialized if not set.
20412For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
20413@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
20414eleventh invocation.
20415For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
20416
d77de738 20417@opindex print-file-name
ddf6fe37 20418@item -print-file-name=@var{library}
d77de738
ML
20419Print the full absolute name of the library file @var{library} that
20420would be used when linking---and don't do anything else. With this
20421option, GCC does not compile or link anything; it just prints the
20422file name.
20423
d77de738 20424@opindex print-multi-directory
ddf6fe37 20425@item -print-multi-directory
d77de738
ML
20426Print the directory name corresponding to the multilib selected by any
20427other switches present in the command line. This directory is supposed
20428to exist in @env{GCC_EXEC_PREFIX}.
20429
d77de738 20430@opindex print-multi-lib
ddf6fe37 20431@item -print-multi-lib
d77de738
ML
20432Print the mapping from multilib directory names to compiler switches
20433that enable them. The directory name is separated from the switches by
20434@samp{;}, and each switch starts with an @samp{@@} instead of the
20435@samp{-}, without spaces between multiple switches. This is supposed to
20436ease shell processing.
20437
d77de738 20438@opindex print-multi-os-directory
ddf6fe37 20439@item -print-multi-os-directory
d77de738
ML
20440Print the path to OS libraries for the selected
20441multilib, relative to some @file{lib} subdirectory. If OS libraries are
20442present in the @file{lib} subdirectory and no multilibs are used, this is
20443usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20444sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20445@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20446subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20447
d77de738 20448@opindex print-multiarch
ddf6fe37 20449@item -print-multiarch
d77de738
ML
20450Print the path to OS libraries for the selected multiarch,
20451relative to some @file{lib} subdirectory.
20452
d77de738 20453@opindex print-prog-name
ddf6fe37 20454@item -print-prog-name=@var{program}
d77de738
ML
20455Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20456
d77de738 20457@opindex print-libgcc-file-name
ddf6fe37 20458@item -print-libgcc-file-name
d77de738
ML
20459Same as @option{-print-file-name=libgcc.a}.
20460
20461This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20462but you do want to link with @file{libgcc.a}. You can do:
20463
20464@smallexample
20465gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20466@end smallexample
20467
d77de738 20468@opindex print-search-dirs
ddf6fe37 20469@item -print-search-dirs
d77de738
ML
20470Print the name of the configured installation directory and a list of
20471program and library directories @command{gcc} searches---and don't do anything else.
20472
20473This is useful when @command{gcc} prints the error message
20474@samp{installation problem, cannot exec cpp0: No such file or directory}.
20475To resolve this you either need to put @file{cpp0} and the other compiler
20476components where @command{gcc} expects to find them, or you can set the environment
20477variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20478Don't forget the trailing @samp{/}.
20479@xref{Environment Variables}.
20480
d77de738 20481@opindex print-sysroot
ddf6fe37 20482@item -print-sysroot
d77de738
ML
20483Print the target sysroot directory that is used during
20484compilation. This is the target sysroot specified either at configure
20485time or using the @option{--sysroot} option, possibly with an extra
20486suffix that depends on compilation options. If no target sysroot is
20487specified, the option prints nothing.
20488
d77de738 20489@opindex print-sysroot-headers-suffix
ddf6fe37 20490@item -print-sysroot-headers-suffix
d77de738
ML
20491Print the suffix added to the target sysroot when searching for
20492headers, or give an error if the compiler is not configured with such
20493a suffix---and don't do anything else.
20494
d77de738 20495@opindex dumpmachine
ddf6fe37 20496@item -dumpmachine
d77de738
ML
20497Print the compiler's target machine (for example,
20498@samp{i686-pc-linux-gnu})---and don't do anything else.
20499
d77de738 20500@opindex dumpversion
ddf6fe37 20501@item -dumpversion
d77de738
ML
20502Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20503anything else. This is the compiler version used in filesystem paths and
20504specs. Depending on how the compiler has been configured it can be just
20505a single number (major version), two numbers separated by a dot (major and
20506minor version) or three numbers separated by dots (major, minor and patchlevel
20507version).
20508
d77de738 20509@opindex dumpfullversion
ddf6fe37 20510@item -dumpfullversion
d77de738
ML
20511Print the full compiler version---and don't do anything else. The output is
20512always three numbers separated by dots, major, minor and patchlevel version.
20513
d77de738 20514@opindex dumpspecs
ddf6fe37 20515@item -dumpspecs
d77de738
ML
20516Print the compiler's built-in specs---and don't do anything else. (This
20517is used when GCC itself is being built.) @xref{Spec Files}.
20518@end table
20519
20520@node Submodel Options
20521@section Machine-Dependent Options
20522@cindex submodel options
20523@cindex specifying hardware config
20524@cindex hardware models and configurations, specifying
20525@cindex target-dependent options
20526@cindex machine-dependent options
20527
20528Each target machine supported by GCC can have its own options---for
20529example, to allow you to compile for a particular processor variant or
20530ABI, or to control optimizations specific to that machine. By
20531convention, the names of machine-specific options start with
20532@samp{-m}.
20533
20534Some configurations of the compiler also support additional target-specific
20535options, usually for compatibility with other compilers on the same
20536platform.
20537
20538@c This list is ordered alphanumerically by subsection name.
20539@c It should be the same order and spelling as these options are listed
20540@c in Machine Dependent Options
20541
20542@menu
20543* AArch64 Options::
20544* Adapteva Epiphany Options::
20545* AMD GCN Options::
20546* ARC Options::
20547* ARM Options::
20548* AVR Options::
20549* Blackfin Options::
20550* C6X Options::
20551* CRIS Options::
20552* C-SKY Options::
20553* Darwin Options::
20554* DEC Alpha Options::
20555* eBPF Options::
20556* FR30 Options::
20557* FT32 Options::
20558* FRV Options::
20559* GNU/Linux Options::
20560* H8/300 Options::
20561* HPPA Options::
20562* IA-64 Options::
20563* LM32 Options::
20564* LoongArch Options::
20565* M32C Options::
20566* M32R/D Options::
20567* M680x0 Options::
20568* MCore Options::
d77de738
ML
20569* MicroBlaze Options::
20570* MIPS Options::
20571* MMIX Options::
20572* MN10300 Options::
20573* Moxie Options::
20574* MSP430 Options::
20575* NDS32 Options::
20576* Nios II Options::
20577* Nvidia PTX Options::
20578* OpenRISC Options::
20579* PDP-11 Options::
d77de738
ML
20580* PowerPC Options::
20581* PRU Options::
20582* RISC-V Options::
20583* RL78 Options::
20584* RS/6000 and PowerPC Options::
20585* RX Options::
20586* S/390 and zSeries Options::
d77de738
ML
20587* SH Options::
20588* Solaris 2 Options::
20589* SPARC Options::
20590* System V Options::
20591* V850 Options::
20592* VAX Options::
20593* Visium Options::
20594* VMS Options::
20595* VxWorks Options::
20596* x86 Options::
20597* x86 Windows Options::
20598* Xstormy16 Options::
20599* Xtensa Options::
20600* zSeries Options::
20601@end menu
20602
20603@node AArch64 Options
20604@subsection AArch64 Options
20605@cindex AArch64 Options
20606
20607These options are defined for AArch64 implementations:
20608
20609@table @gcctabopt
20610
d77de738 20611@opindex mabi
ddf6fe37 20612@item -mabi=@var{name}
d77de738
ML
20613Generate code for the specified data model. Permissible values
20614are @samp{ilp32} for SysV-like data model where int, long int and pointers
20615are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20616but long int and pointers are 64 bits.
20617
20618The default depends on the specific target configuration. Note that
20619the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20620entire program with the same ABI, and link with a compatible set of libraries.
20621
d77de738 20622@opindex mbig-endian
ddf6fe37 20623@item -mbig-endian
d77de738
ML
20624Generate big-endian code. This is the default when GCC is configured for an
20625@samp{aarch64_be-*-*} target.
20626
d77de738 20627@opindex mgeneral-regs-only
ddf6fe37 20628@item -mgeneral-regs-only
d77de738
ML
20629Generate code which uses only the general-purpose registers. This will prevent
20630the compiler from using floating-point and Advanced SIMD registers but will not
20631impose any restrictions on the assembler.
20632
d77de738 20633@opindex mlittle-endian
ddf6fe37 20634@item -mlittle-endian
d77de738
ML
20635Generate little-endian code. This is the default when GCC is configured for an
20636@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20637
d77de738 20638@opindex mcmodel=tiny
ddf6fe37 20639@item -mcmodel=tiny
d77de738
ML
20640Generate code for the tiny code model. The program and its statically defined
20641symbols must be within 1MB of each other. Programs can be statically or
20642dynamically linked.
20643
d77de738 20644@opindex mcmodel=small
ddf6fe37 20645@item -mcmodel=small
d77de738
ML
20646Generate code for the small code model. The program and its statically defined
20647symbols must be within 4GB of each other. Programs can be statically or
20648dynamically linked. This is the default code model.
20649
d77de738 20650@opindex mcmodel=large
ddf6fe37 20651@item -mcmodel=large
d77de738
ML
20652Generate code for the large code model. This makes no assumptions about
20653addresses and sizes of sections. Programs can be statically linked only. The
20654@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20655@option{-fpic} and @option{-fPIC}.
20656
573624ec
KT
20657@item -mtp=@var{name}
20658@opindex mtp
20659Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
20660are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
20661@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
20662@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
20663The default setting is @samp{tpidr_el0}. It is recommended to compile all
20664code intended to interoperate with the same value of this option to avoid
20665accessing a different thread pointer from the wrong exception level.
573624ec 20666
d77de738
ML
20667@opindex mstrict-align
20668@opindex mno-strict-align
ddf6fe37
AA
20669@item -mstrict-align
20670@itemx -mno-strict-align
d77de738
ML
20671Avoid or allow generating memory accesses that may not be aligned on a natural
20672object boundary as described in the architecture specification.
20673
d77de738
ML
20674@opindex momit-leaf-frame-pointer
20675@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20676@item -momit-leaf-frame-pointer
20677@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20678Omit or keep the frame pointer in leaf functions. The former behavior is the
20679default.
20680
d77de738
ML
20681@opindex mstack-protector-guard
20682@opindex mstack-protector-guard-reg
20683@opindex mstack-protector-guard-offset
ddf6fe37
AA
20684@item -mstack-protector-guard=@var{guard}
20685@itemx -mstack-protector-guard-reg=@var{reg}
20686@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20687Generate stack protection code using canary at @var{guard}. Supported
20688locations are @samp{global} for a global canary or @samp{sysreg} for a
20689canary in an appropriate system register.
20690
20691With the latter choice the options
20692@option{-mstack-protector-guard-reg=@var{reg}} and
20693@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20694which system register to use as base register for reading the canary,
20695and from what offset from that base register. There is no default
20696register or offset as this is entirely for use within the Linux
20697kernel.
20698
d77de738 20699@opindex mtls-dialect=desc
ddf6fe37 20700@item -mtls-dialect=desc
d77de738
ML
20701Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20702of TLS variables. This is the default.
20703
d77de738 20704@opindex mtls-dialect=traditional
ddf6fe37 20705@item -mtls-dialect=traditional
d77de738
ML
20706Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20707of TLS variables.
20708
d77de738 20709@opindex mtls-size
ddf6fe37 20710@item -mtls-size=@var{size}
d77de738
ML
20711Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20712This option requires binutils 2.26 or newer.
20713
d77de738
ML
20714@opindex mfix-cortex-a53-835769
20715@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20716@item -mfix-cortex-a53-835769
20717@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20718Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20719This involves inserting a NOP instruction between memory instructions and
2072064-bit integer multiply-accumulate instructions.
20721
d77de738
ML
20722@opindex mfix-cortex-a53-843419
20723@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20724@item -mfix-cortex-a53-843419
20725@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20726Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20727This erratum workaround is made at link time and this will only pass the
20728corresponding flag to the linker.
20729
d77de738
ML
20730@opindex mlow-precision-recip-sqrt
20731@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20732@item -mlow-precision-recip-sqrt
20733@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20734Enable or disable the reciprocal square root approximation.
20735This option only has an effect if @option{-ffast-math} or
20736@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20737precision of reciprocal square root results to about 16 bits for
20738single precision and to 32 bits for double precision.
20739
d77de738
ML
20740@opindex mlow-precision-sqrt
20741@opindex mno-low-precision-sqrt
ddf6fe37
AA
20742@item -mlow-precision-sqrt
20743@itemx -mno-low-precision-sqrt
d77de738
ML
20744Enable or disable the square root approximation.
20745This option only has an effect if @option{-ffast-math} or
20746@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20747precision of square root results to about 16 bits for
20748single precision and to 32 bits for double precision.
20749If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20750
d77de738
ML
20751@opindex mlow-precision-div
20752@opindex mno-low-precision-div
ddf6fe37
AA
20753@item -mlow-precision-div
20754@itemx -mno-low-precision-div
d77de738
ML
20755Enable or disable the division approximation.
20756This option only has an effect if @option{-ffast-math} or
20757@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20758precision of division results to about 16 bits for
20759single precision and to 32 bits for double precision.
20760
20761@item -mtrack-speculation
20762@itemx -mno-track-speculation
20763Enable or disable generation of additional code to track speculative
20764execution through conditional branches. The tracking state can then
20765be used by the compiler when expanding calls to
20766@code{__builtin_speculation_safe_copy} to permit a more efficient code
20767sequence to be generated.
20768
20769@item -moutline-atomics
20770@itemx -mno-outline-atomics
20771Enable or disable calls to out-of-line helpers to implement atomic operations.
20772These helpers will, at runtime, determine if the LSE instructions from
20773ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20774instructions that are present in the base ARMv8.0 ISA.
20775
20776This option is only applicable when compiling for the base ARMv8.0
20777instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20778or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20779used directly. The same applies when using @option{-mcpu=} when the
20780selected cpu supports the @samp{lse} feature.
20781This option is on by default.
20782
d77de738 20783@opindex march
ddf6fe37 20784@item -march=@var{name}
d77de738
ML
20785Specify the name of the target architecture and, optionally, one or
20786more feature modifiers. This option has the form
20787@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20788
20789The table below summarizes the permissible values for @var{arch}
20790and the features that they enable by default:
20791
20792@multitable @columnfractions 0.20 0.20 0.60
20793@headitem @var{arch} value @tab Architecture @tab Includes by default
20794@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20795@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20796@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20797@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20798@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20799@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20800@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20801@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20802@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20803@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20804@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20805@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20806@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20807@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20808@end multitable
20809
20810The value @samp{native} is available on native AArch64 GNU/Linux and
20811causes the compiler to pick the architecture of the host system. This
20812option has no effect if the compiler is unable to recognize the
20813architecture of the host system,
20814
20815The permissible values for @var{feature} are listed in the sub-section
20816on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20817Feature Modifiers}. Where conflicting feature modifiers are
20818specified, the right-most feature is used.
20819
20820GCC uses @var{name} to determine what kind of instructions it can emit
20821when generating assembly code. If @option{-march} is specified
20822without either of @option{-mtune} or @option{-mcpu} also being
20823specified, the code is tuned to perform well across a range of target
20824processors implementing the target architecture.
20825
d77de738 20826@opindex mtune
ddf6fe37 20827@item -mtune=@var{name}
d77de738
ML
20828Specify the name of the target processor for which GCC should tune the
20829performance of the code. Permissible values for this option are:
20830@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20831@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20832@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20833@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20834@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20835@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20836@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20837@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20838@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20839@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20840@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20841@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20842@samp{octeontx2f95mm},
20843@samp{a64fx},
20844@samp{thunderx}, @samp{thunderxt88},
20845@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20846@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20847@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20848@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20849@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20850@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
3bfde22c
SJ
20851@samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520},
20852@samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1},
20853@samp{ampere1a}, and @samp{native}.
d77de738
ML
20854
20855The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20856@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20857@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20858should tune for a big.LITTLE system.
20859
20860The value @samp{neoverse-512tvb} specifies that GCC should tune
20861for Neoverse cores that (a) implement SVE and (b) have a total vector
20862bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20863tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20864instructions a cycle and that can execute an equivalent number of SVE
20865arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20866This is more general than tuning for a specific core like Neoverse V1
20867but is more specific than the default tuning described below.
20868
20869Additionally on native AArch64 GNU/Linux systems the value
20870@samp{native} tunes performance to the host system. This option has no effect
20871if the compiler is unable to recognize the processor of the host system.
20872
20873Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20874are specified, the code is tuned to perform well across a range
20875of target processors.
20876
20877This option cannot be suffixed by feature modifiers.
20878
d77de738 20879@opindex mcpu
ddf6fe37 20880@item -mcpu=@var{name}
d77de738
ML
20881Specify the name of the target processor, optionally suffixed by one
20882or more feature modifiers. This option has the form
20883@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20884the permissible values for @var{cpu} are the same as those available
20885for @option{-mtune}. The permissible values for @var{feature} are
20886documented in the sub-section on
20887@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20888Feature Modifiers}. Where conflicting feature modifiers are
20889specified, the right-most feature is used.
20890
20891GCC uses @var{name} to determine what kind of instructions it can emit when
20892generating assembly code (as if by @option{-march}) and to determine
20893the target processor for which to tune for performance (as if
20894by @option{-mtune}). Where this option is used in conjunction
20895with @option{-march} or @option{-mtune}, those options take precedence
20896over the appropriate part of this option.
20897
20898@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20899to a specific core, but instead refers to all Neoverse cores that
20900(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20901a cycle. Unless overridden by @option{-march},
20902@option{-mcpu=neoverse-512tvb} generates code that can run on a
20903Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20904these properties. Unless overridden by @option{-mtune},
20905@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20906@option{-mtune=neoverse-512tvb}.
20907
d77de738 20908@opindex moverride
ddf6fe37 20909@item -moverride=@var{string}
d77de738
ML
20910Override tuning decisions made by the back-end in response to a
20911@option{-mtune=} switch. The syntax, semantics, and accepted values
20912for @var{string} in this option are not guaranteed to be consistent
20913across releases.
20914
20915This option is only intended to be useful when developing GCC.
20916
d77de738 20917@opindex mverbose-cost-dump
ddf6fe37 20918@item -mverbose-cost-dump
d77de738
ML
20919Enable verbose cost model dumping in the debug dump files. This option is
20920provided for use in debugging the compiler.
20921
d77de738
ML
20922@opindex mpc-relative-literal-loads
20923@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20924@item -mpc-relative-literal-loads
20925@itemx -mno-pc-relative-literal-loads
d77de738
ML
20926Enable or disable PC-relative literal loads. With this option literal pools are
20927accessed using a single instruction and emitted after each function. This
20928limits the maximum size of functions to 1MB. This is enabled by default for
20929@option{-mcmodel=tiny}.
20930
d77de738 20931@opindex msign-return-address
ddf6fe37 20932@item -msign-return-address=@var{scope}
d77de738
ML
20933Select the function scope on which return address signing will be applied.
20934Permissible values are @samp{none}, which disables return address signing,
20935@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20936functions, and @samp{all}, which enables pointer signing for all functions. The
20937default value is @samp{none}. This option has been deprecated by
20938-mbranch-protection.
20939
d77de738 20940@opindex mbranch-protection
ddf6fe37 20941@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20942Select the branch protection features to use.
20943@samp{none} is the default and turns off all types of branch protection.
20944@samp{standard} turns on all types of branch protection features. If a feature
20945has additional tuning options, then @samp{standard} sets it to its standard
20946level.
20947@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20948level: signing functions that save the return address to memory (non-leaf
20949functions will practically always do this) using the a-key. The optional
20950argument @samp{leaf} can be used to extend the signing to include leaf
20951functions. The optional argument @samp{b-key} can be used to sign the functions
20952with the B-key instead of the A-key.
20953@samp{bti} turns on branch target identification mechanism.
20954
d77de738 20955@opindex mharden-sls
ddf6fe37 20956@item -mharden-sls=@var{opts}
d77de738
ML
20957Enable compiler hardening against straight line speculation (SLS).
20958@var{opts} is a comma-separated list of the following options:
20959@table @samp
20960@item retbr
20961@item blr
20962@end table
20963In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20964@samp{-mharden-sls=none} disables all SLS hardening.
20965
d77de738 20966@opindex msve-vector-bits
ddf6fe37 20967@item -msve-vector-bits=@var{bits}
d77de738
ML
20968Specify the number of bits in an SVE vector register. This option only has
20969an effect when SVE is enabled.
20970
20971GCC supports two forms of SVE code generation: ``vector-length
20972agnostic'' output that works with any size of vector register and
20973``vector-length specific'' output that allows GCC to make assumptions
20974about the vector length when it is useful for optimization reasons.
20975The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20976@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20977Specifying @samp{scalable} selects vector-length agnostic
20978output. At present @samp{-msve-vector-bits=128} also generates vector-length
20979agnostic output for big-endian targets. All other values generate
20980vector-length specific code. The behavior of these values may change
20981in future releases and no value except @samp{scalable} should be
20982relied on for producing code that is portable across different
20983hardware SVE vector lengths.
20984
20985The default is @samp{-msve-vector-bits=scalable}, which produces
20986vector-length agnostic code.
20987@end table
20988
20989@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20990@anchor{aarch64-feature-modifiers}
20991@cindex @option{-march} feature modifiers
20992@cindex @option{-mcpu} feature modifiers
20993Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20994the following and their inverses @option{no@var{feature}}:
20995
20996@table @samp
20997@item crc
20998Enable CRC extension. This is on by default for
20999@option{-march=armv8.1-a}.
21000@item crypto
21001Enable Crypto extension. This also enables Advanced SIMD and floating-point
21002instructions.
21003@item fp
21004Enable floating-point instructions. This is on by default for all possible
21005values for options @option{-march} and @option{-mcpu}.
21006@item simd
21007Enable Advanced SIMD instructions. This also enables floating-point
21008instructions. This is on by default for all possible values for options
21009@option{-march} and @option{-mcpu}.
21010@item sve
21011Enable Scalable Vector Extension instructions. This also enables Advanced
21012SIMD and floating-point instructions.
21013@item lse
21014Enable Large System Extension instructions. This is on by default for
21015@option{-march=armv8.1-a}.
21016@item rdma
21017Enable Round Double Multiply Accumulate instructions. This is on by default
21018for @option{-march=armv8.1-a}.
21019@item fp16
21020Enable FP16 extension. This also enables floating-point instructions.
21021@item fp16fml
21022Enable FP16 fmla extension. This also enables FP16 extensions and
21023floating-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.
21024
21025@item rcpc
0431e8ae
AV
21026Enable the RCpc extension. This enables the use of the LDAPR instructions for
21027load-acquire atomic semantics, and passes it on to the assembler, enabling
21028inline asm statements to use instructions from the RCpc extension.
d77de738
ML
21029@item dotprod
21030Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21031@item aes
21032Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
21033SIMD instructions.
21034@item sha2
21035Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
21036@item sha3
21037Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
21038instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
21039@item sm4
21040Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
21041Use of this option with architectures prior to Armv8.2-A is not supported.
21042@item profile
21043Enable the Statistical Profiling extension. This option is only to enable the
21044extension at the assembler level and does not affect code generation.
21045@item rng
21046Enable the Armv8.5-a Random Number instructions. This option is only to
21047enable the extension at the assembler level and does not affect code
21048generation.
21049@item memtag
21050Enable the Armv8.5-a Memory Tagging Extensions.
21051Use of this option with architectures prior to Armv8.5-A is not supported.
21052@item sb
21053Enable the Armv8-a Speculation Barrier instruction. This option is only to
21054enable the extension at the assembler level and does not affect code
21055generation. This option is enabled by default for @option{-march=armv8.5-a}.
21056@item ssbs
21057Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
21058is only to enable the extension at the assembler level and does not affect code
21059generation. This option is enabled by default for @option{-march=armv8.5-a}.
21060@item predres
21061Enable the Armv8-a Execution and Data Prediction Restriction instructions.
21062This option is only to enable the extension at the assembler level and does
21063not affect code generation. This option is enabled by default for
21064@option{-march=armv8.5-a}.
21065@item sve2
21066Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
21067instructions.
21068@item sve2-bitperm
21069Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
21070@item sve2-sm4
21071Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
21072@item sve2-aes
21073Enable SVE2 aes instructions. This also enables SVE2 instructions.
21074@item sve2-sha3
21075Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
21076@item tme
21077Enable the Transactional Memory Extension.
21078@item i8mm
21079Enable 8-bit Integer Matrix Multiply instructions. This also enables
21080Advanced SIMD and floating-point instructions. This option is enabled by
21081default for @option{-march=armv8.6-a}. Use of this option with architectures
21082prior to Armv8.2-A is not supported.
21083@item f32mm
21084Enable 32-bit Floating point Matrix Multiply instructions. This also enables
21085SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21086not supported.
21087@item f64mm
21088Enable 64-bit Floating point Matrix Multiply instructions. This also enables
21089SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21090not supported.
21091@item bf16
21092Enable brain half-precision floating-point instructions. This also enables
21093Advanced SIMD and floating-point instructions. This option is enabled by
21094default for @option{-march=armv8.6-a}. Use of this option with architectures
21095prior to Armv8.2-A is not supported.
21096@item ls64
21097Enable the 64-byte atomic load and store instructions for accelerators.
21098This option is enabled by default for @option{-march=armv8.7-a}.
21099@item mops
21100Enable the instructions to accelerate memory operations like @code{memcpy},
21101@code{memmove}, @code{memset}. This option is enabled by default for
21102@option{-march=armv8.8-a}
21103@item flagm
21104Enable the Flag Manipulation instructions Extension.
21105@item pauth
21106Enable the Pointer Authentication Extension.
d758d190
KT
21107@item cssc
21108Enable the Common Short Sequence Compression instructions.
d77de738
ML
21109
21110@end table
21111
21112Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
21113which implies @option{fp}.
21114Conversely, @option{nofp} implies @option{nosimd}, which implies
21115@option{nocrypto}, @option{noaes} and @option{nosha2}.
21116
21117@node Adapteva Epiphany Options
21118@subsection Adapteva Epiphany Options
21119
21120These @samp{-m} options are defined for Adapteva Epiphany:
21121
21122@table @gcctabopt
d77de738 21123@opindex mhalf-reg-file
ddf6fe37 21124@item -mhalf-reg-file
d77de738
ML
21125Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
21126That allows code to run on hardware variants that lack these registers.
21127
d77de738 21128@opindex mprefer-short-insn-regs
ddf6fe37 21129@item -mprefer-short-insn-regs
d77de738
ML
21130Preferentially allocate registers that allow short instruction generation.
21131This can result in increased instruction count, so this may either reduce or
21132increase overall code size.
21133
d77de738 21134@opindex mbranch-cost
ddf6fe37 21135@item -mbranch-cost=@var{num}
d77de738
ML
21136Set the cost of branches to roughly @var{num} ``simple'' instructions.
21137This cost is only a heuristic and is not guaranteed to produce
21138consistent results across releases.
21139
d77de738 21140@opindex mcmove
ddf6fe37 21141@item -mcmove
d77de738
ML
21142Enable the generation of conditional moves.
21143
d77de738 21144@opindex mnops
ddf6fe37 21145@item -mnops=@var{num}
d77de738
ML
21146Emit @var{num} NOPs before every other generated instruction.
21147
d77de738
ML
21148@opindex mno-soft-cmpsf
21149@opindex msoft-cmpsf
ddf6fe37 21150@item -mno-soft-cmpsf
d77de738
ML
21151For single-precision floating-point comparisons, emit an @code{fsub} instruction
21152and test the flags. This is faster than a software comparison, but can
21153get incorrect results in the presence of NaNs, or when two different small
21154numbers are compared such that their difference is calculated as zero.
21155The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
21156software comparisons.
21157
d77de738 21158@opindex mstack-offset
ddf6fe37 21159@item -mstack-offset=@var{num}
d77de738
ML
21160Set the offset between the top of the stack and the stack pointer.
21161E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
21162can be used by leaf functions without stack allocation.
21163Values other than @samp{8} or @samp{16} are untested and unlikely to work.
21164Note also that this option changes the ABI; compiling a program with a
21165different stack offset than the libraries have been compiled with
21166generally does not work.
21167This option can be useful if you want to evaluate if a different stack
21168offset would give you better code, but to actually use a different stack
21169offset to build working programs, it is recommended to configure the
21170toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
21171
d77de738
ML
21172@opindex mno-round-nearest
21173@opindex mround-nearest
ddf6fe37 21174@item -mno-round-nearest
d77de738
ML
21175Make the scheduler assume that the rounding mode has been set to
21176truncating. The default is @option{-mround-nearest}.
21177
d77de738 21178@opindex mlong-calls
ddf6fe37 21179@item -mlong-calls
d77de738
ML
21180If not otherwise specified by an attribute, assume all calls might be beyond
21181the offset range of the @code{b} / @code{bl} instructions, and therefore load the
21182function address into a register before performing a (otherwise direct) call.
21183This is the default.
21184
d77de738 21185@opindex short-calls
ddf6fe37 21186@item -mshort-calls
d77de738
ML
21187If not otherwise specified by an attribute, assume all direct calls are
21188in the range of the @code{b} / @code{bl} instructions, so use these instructions
21189for direct calls. The default is @option{-mlong-calls}.
21190
d77de738 21191@opindex msmall16
ddf6fe37 21192@item -msmall16
d77de738
ML
21193Assume addresses can be loaded as 16-bit unsigned values. This does not
21194apply to function addresses for which @option{-mlong-calls} semantics
21195are in effect.
21196
d77de738 21197@opindex mfp-mode
ddf6fe37 21198@item -mfp-mode=@var{mode}
d77de738
ML
21199Set the prevailing mode of the floating-point unit.
21200This determines the floating-point mode that is provided and expected
21201at function call and return time. Making this mode match the mode you
21202predominantly need at function start can make your programs smaller and
21203faster by avoiding unnecessary mode switches.
21204
21205@var{mode} can be set to one the following values:
21206
21207@table @samp
21208@item caller
21209Any mode at function entry is valid, and retained or restored when
21210the function returns, and when it calls other functions.
21211This mode is useful for compiling libraries or other compilation units
21212you might want to incorporate into different programs with different
21213prevailing FPU modes, and the convenience of being able to use a single
21214object file outweighs the size and speed overhead for any extra
21215mode switching that might be needed, compared with what would be needed
21216with a more specific choice of prevailing FPU mode.
21217
21218@item truncate
21219This is the mode used for floating-point calculations with
21220truncating (i.e.@: round towards zero) rounding mode. That includes
21221conversion from floating point to integer.
21222
21223@item round-nearest
21224This is the mode used for floating-point calculations with
21225round-to-nearest-or-even rounding mode.
21226
21227@item int
21228This is the mode used to perform integer calculations in the FPU, e.g.@:
21229integer multiply, or integer multiply-and-accumulate.
21230@end table
21231
21232The default is @option{-mfp-mode=caller}
21233
d77de738
ML
21234@opindex mno-split-lohi
21235@opindex msplit-lohi
21236@opindex mno-postinc
21237@opindex mpostinc
21238@opindex mno-postmodify
21239@opindex mpostmodify
ddf6fe37
AA
21240@item -mno-split-lohi
21241@itemx -mno-postinc
21242@itemx -mno-postmodify
d77de738
ML
21243Code generation tweaks that disable, respectively, splitting of 32-bit
21244loads, generation of post-increment addresses, and generation of
21245post-modify addresses. The defaults are @option{msplit-lohi},
21246@option{-mpost-inc}, and @option{-mpost-modify}.
21247
d77de738
ML
21248@opindex mno-vect-double
21249@opindex mvect-double
ddf6fe37 21250@item -mnovect-double
d77de738
ML
21251Change the preferred SIMD mode to SImode. The default is
21252@option{-mvect-double}, which uses DImode as preferred SIMD mode.
21253
d77de738 21254@opindex max-vect-align
ddf6fe37 21255@item -max-vect-align=@var{num}
d77de738
ML
21256The maximum alignment for SIMD vector mode types.
21257@var{num} may be 4 or 8. The default is 8.
21258Note that this is an ABI change, even though many library function
21259interfaces are unaffected if they don't use SIMD vector modes
21260in places that affect size and/or alignment of relevant types.
21261
d77de738 21262@opindex msplit-vecmove-early
ddf6fe37 21263@item -msplit-vecmove-early
d77de738
ML
21264Split vector moves into single word moves before reload. In theory this
21265can give better register allocation, but so far the reverse seems to be
21266generally the case.
21267
d77de738 21268@opindex m1reg-
ddf6fe37 21269@item -m1reg-@var{reg}
d77de738
ML
21270Specify a register to hold the constant @minus{}1, which makes loading small negative
21271constants and certain bitmasks faster.
21272Allowable values for @var{reg} are @samp{r43} and @samp{r63},
21273which specify use of that register as a fixed register,
21274and @samp{none}, which means that no register is used for this
21275purpose. The default is @option{-m1reg-none}.
21276
21277@end table
21278
21279@node AMD GCN Options
21280@subsection AMD GCN Options
21281@cindex AMD GCN Options
21282
21283These options are defined specifically for the AMD GCN port.
21284
21285@table @gcctabopt
21286
d77de738 21287@opindex march
d77de738 21288@opindex mtune
ddf6fe37
AA
21289@item -march=@var{gpu}
21290@itemx -mtune=@var{gpu}
d77de738
ML
21291Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
21292are
21293
21294@table @samp
21295@item fiji
56ed1055
AS
21296Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility
21297depends on how GCC has been configured, see @option{--with-arch} and
21298@option{--with-multilib-list}.
d77de738
ML
21299
21300@item gfx900
21301Compile for GCN5 Vega 10 devices (gfx900).
21302
21303@item gfx906
21304Compile for GCN5 Vega 20 devices (gfx906).
21305
21306@item gfx908
21307Compile for CDNA1 Instinct MI100 series devices (gfx908).
21308
21309@item gfx90a
21310Compile for CDNA2 Instinct MI200 series devices (gfx90a).
21311
21312@end table
21313
ddf6fe37 21314@opindex msram-ecc
d77de738
ML
21315@item -msram-ecc=on
21316@itemx -msram-ecc=off
21317@itemx -msram-ecc=any
d77de738
ML
21318Compile binaries suitable for devices with the SRAM-ECC feature enabled,
21319disabled, or either mode. This feature can be enabled per-process on some
21320devices. The compiled code must match the device mode. The default is
21321@samp{any}, for devices that support it.
21322
d77de738 21323@opindex mstack-size
ddf6fe37 21324@item -mstack-size=@var{bytes}
d77de738
ML
21325Specify how many @var{bytes} of stack space will be requested for each GPU
21326thread (wave-front). Beware that there may be many threads and limited memory
21327available. The size of the stack allocation may also have an impact on
21328run-time performance. The default is 32KB when using OpenACC or OpenMP, and
213291MB otherwise.
21330
d77de738 21331@opindex mxnack
366e3d30
TB
21332@item -mxnack=on
21333@itemx -mxnack=off
21334@itemx -mxnack=any
21335Compile binaries suitable for devices with the XNACK feature enabled, disabled,
21336or either mode. Some devices always require XNACK and some allow the user to
21337configure XNACK. The compiled code must match the device mode.
21338@c The default is @samp{-mxnack=any}.
21339At present this option is a placeholder for support that is not yet implemented.
d77de738
ML
21340
21341@end table
21342
21343@node ARC Options
21344@subsection ARC Options
21345@cindex ARC options
21346
21347The following options control the architecture variant for which code
21348is being compiled:
21349
21350@c architecture variants
21351@table @gcctabopt
21352
d77de738 21353@opindex mbarrel-shifter
ddf6fe37 21354@item -mbarrel-shifter
d77de738
ML
21355Generate instructions supported by barrel shifter. This is the default
21356unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
21357
d77de738 21358@opindex mjli-always
ddf6fe37 21359@item -mjli-always
d77de738
ML
21360Force to call a function using jli_s instruction. This option is
21361valid only for ARCv2 architecture.
21362
d77de738 21363@opindex mcpu
ddf6fe37 21364@item -mcpu=@var{cpu}
d77de738
ML
21365Set architecture type, register usage, and instruction scheduling
21366parameters for @var{cpu}. There are also shortcut alias options
21367available for backward compatibility and convenience. Supported
21368values for @var{cpu} are
21369
21370@table @samp
21371@opindex mA6
21372@opindex mARC600
21373@item arc600
21374Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
21375
d77de738 21376@opindex mARC601
ddf6fe37 21377@item arc601
d77de738
ML
21378Compile for ARC601. Alias: @option{-mARC601}.
21379
d77de738
ML
21380@opindex mA7
21381@opindex mARC700
ddf6fe37 21382@item arc700
d77de738
ML
21383Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
21384This is the default when configured with @option{--with-cpu=arc700}@.
21385
21386@item arcem
21387Compile for ARC EM.
21388
21389@item archs
21390Compile for ARC HS.
21391
21392@item em
21393Compile for ARC EM CPU with no hardware extensions.
21394
21395@item em4
21396Compile for ARC EM4 CPU.
21397
21398@item em4_dmips
21399Compile for ARC EM4 DMIPS CPU.
21400
21401@item em4_fpus
21402Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
21403extension.
21404
21405@item em4_fpuda
21406Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
21407double assist instructions.
21408
21409@item hs
21410Compile for ARC HS CPU with no hardware extensions except the atomic
21411instructions.
21412
21413@item hs34
21414Compile for ARC HS34 CPU.
21415
21416@item hs38
21417Compile for ARC HS38 CPU.
21418
21419@item hs38_linux
21420Compile for ARC HS38 CPU with all hardware extensions on.
21421
21422@item hs4x
21423Compile for ARC HS4x CPU.
21424
21425@item hs4xd
21426Compile for ARC HS4xD CPU.
21427
21428@item hs4x_rel31
21429Compile for ARC HS4x CPU release 3.10a.
21430
21431@item arc600_norm
21432Compile for ARC 600 CPU with @code{norm} instructions enabled.
21433
21434@item arc600_mul32x16
21435Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21436instructions enabled.
21437
21438@item arc600_mul64
21439Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21440instructions enabled.
21441
21442@item arc601_norm
21443Compile for ARC 601 CPU with @code{norm} instructions enabled.
21444
21445@item arc601_mul32x16
21446Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21447instructions enabled.
21448
21449@item arc601_mul64
21450Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21451instructions enabled.
21452
21453@item nps400
21454Compile for ARC 700 on NPS400 chip.
21455
21456@item em_mini
21457Compile for ARC EM minimalist configuration featuring reduced register
21458set.
21459
21460@end table
21461
d77de738 21462@opindex mdpfp
d77de738 21463@opindex mdpfp-compact
ddf6fe37
AA
21464@item -mdpfp
21465@itemx -mdpfp-compact
d77de738
ML
21466Generate double-precision FPX instructions, tuned for the compact
21467implementation.
21468
d77de738 21469@opindex mdpfp-fast
ddf6fe37 21470@item -mdpfp-fast
d77de738
ML
21471Generate double-precision FPX instructions, tuned for the fast
21472implementation.
21473
d77de738 21474@opindex mno-dpfp-lrsr
ddf6fe37 21475@item -mno-dpfp-lrsr
d77de738
ML
21476Disable @code{lr} and @code{sr} instructions from using FPX extension
21477aux registers.
21478
d77de738 21479@opindex mea
ddf6fe37 21480@item -mea
d77de738
ML
21481Generate extended arithmetic instructions. Currently only
21482@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21483supported. Only valid for @option{-mcpu=ARC700}.
21484
d77de738
ML
21485@opindex mno-mpy
21486@opindex mmpy
ddf6fe37 21487@item -mno-mpy
d77de738
ML
21488Do not generate @code{mpy}-family instructions for ARC700. This option is
21489deprecated.
21490
d77de738 21491@opindex mmul32x16
ddf6fe37 21492@item -mmul32x16
d77de738
ML
21493Generate 32x16-bit multiply and multiply-accumulate instructions.
21494
d77de738 21495@opindex mmul64
ddf6fe37 21496@item -mmul64
d77de738
ML
21497Generate @code{mul64} and @code{mulu64} instructions.
21498Only valid for @option{-mcpu=ARC600}.
21499
d77de738 21500@opindex mnorm
ddf6fe37 21501@item -mnorm
d77de738
ML
21502Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21503is in effect.
21504
d77de738 21505@opindex mspfp
d77de738 21506@opindex mspfp-compact
ddf6fe37
AA
21507@item -mspfp
21508@itemx -mspfp-compact
d77de738
ML
21509Generate single-precision FPX instructions, tuned for the compact
21510implementation.
21511
d77de738 21512@opindex mspfp-fast
ddf6fe37 21513@item -mspfp-fast
d77de738
ML
21514Generate single-precision FPX instructions, tuned for the fast
21515implementation.
21516
d77de738 21517@opindex msimd
ddf6fe37 21518@item -msimd
d77de738
ML
21519Enable generation of ARC SIMD instructions via target-specific
21520builtins. Only valid for @option{-mcpu=ARC700}.
21521
d77de738 21522@opindex msoft-float
ddf6fe37 21523@item -msoft-float
d77de738
ML
21524This option ignored; it is provided for compatibility purposes only.
21525Software floating-point code is emitted by default, and this default
21526can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
21527@option{-mspfp-fast} for single precision, and @option{-mdpfp},
21528@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
21529
d77de738 21530@opindex mswap
ddf6fe37 21531@item -mswap
d77de738
ML
21532Generate @code{swap} instructions.
21533
d77de738 21534@opindex matomic
ddf6fe37 21535@item -matomic
d77de738
ML
21536This enables use of the locked load/store conditional extension to implement
21537atomic memory built-in functions. Not available for ARC 6xx or ARC
21538EM cores.
21539
d77de738 21540@opindex mdiv-rem
ddf6fe37 21541@item -mdiv-rem
d77de738
ML
21542Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21543
d77de738 21544@opindex mcode-density
ddf6fe37 21545@item -mcode-density
d77de738
ML
21546Enable code density instructions for ARC EM.
21547This option is on by default for ARC HS.
21548
d77de738 21549@opindex mll64
ddf6fe37 21550@item -mll64
d77de738
ML
21551Enable double load/store operations for ARC HS cores.
21552
d77de738 21553@opindex mtp-regno
ddf6fe37 21554@item -mtp-regno=@var{regno}
d77de738
ML
21555Specify thread pointer register number.
21556
d77de738 21557@opindex mmpy-option
ddf6fe37 21558@item -mmpy-option=@var{multo}
d77de738
ML
21559Compile ARCv2 code with a multiplier design option. You can specify
21560the option using either a string or numeric value for @var{multo}.
21561@samp{wlh1} is the default value. The recognized values are:
21562
21563@table @samp
21564@item 0
21565@itemx none
21566No multiplier available.
21567
21568@item 1
21569@itemx w
2157016x16 multiplier, fully pipelined.
21571The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21572
21573@item 2
21574@itemx wlh1
2157532x32 multiplier, fully
21576pipelined (1 stage). The following instructions are additionally
21577enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21578
21579@item 3
21580@itemx wlh2
2158132x32 multiplier, fully pipelined
21582(2 stages). The following instructions are additionally enabled: @code{mpy},
21583@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21584
21585@item 4
21586@itemx wlh3
21587Two 16x16 multipliers, blocking,
21588sequential. The following instructions are additionally enabled: @code{mpy},
21589@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21590
21591@item 5
21592@itemx wlh4
21593One 16x16 multiplier, blocking,
21594sequential. The following instructions are additionally enabled: @code{mpy},
21595@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21596
21597@item 6
21598@itemx wlh5
21599One 32x4 multiplier, blocking,
21600sequential. The following instructions are additionally enabled: @code{mpy},
21601@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21602
21603@item 7
21604@itemx plus_dmpy
21605ARC HS SIMD support.
21606
21607@item 8
21608@itemx plus_macd
21609ARC HS SIMD support.
21610
21611@item 9
21612@itemx plus_qmacw
21613ARC HS SIMD support.
21614
21615@end table
21616
21617This option is only available for ARCv2 cores@.
21618
d77de738 21619@opindex mfpu
ddf6fe37 21620@item -mfpu=@var{fpu}
d77de738
ML
21621Enables support for specific floating-point hardware extensions for ARCv2
21622cores. Supported values for @var{fpu} are:
21623
21624@table @samp
21625
21626@item fpus
21627Enables support for single-precision floating-point hardware
21628extensions@.
21629
21630@item fpud
21631Enables support for double-precision floating-point hardware
21632extensions. The single-precision floating-point extension is also
21633enabled. Not available for ARC EM@.
21634
21635@item fpuda
21636Enables support for double-precision floating-point hardware
21637extensions using double-precision assist instructions. The single-precision
21638floating-point extension is also enabled. This option is
21639only available for ARC EM@.
21640
21641@item fpuda_div
21642Enables support for double-precision floating-point hardware
21643extensions using double-precision assist instructions.
21644The single-precision floating-point, square-root, and divide
21645extensions are also enabled. This option is
21646only available for ARC EM@.
21647
21648@item fpuda_fma
21649Enables support for double-precision floating-point hardware
21650extensions using double-precision assist instructions.
21651The single-precision floating-point and fused multiply and add
21652hardware extensions are also enabled. This option is
21653only available for ARC EM@.
21654
21655@item fpuda_all
21656Enables support for double-precision floating-point hardware
21657extensions using double-precision assist instructions.
21658All single-precision floating-point hardware extensions are also
21659enabled. This option is only available for ARC EM@.
21660
21661@item fpus_div
21662Enables support for single-precision floating-point, square-root and divide
21663hardware extensions@.
21664
21665@item fpud_div
21666Enables support for double-precision floating-point, square-root and divide
21667hardware extensions. This option
21668includes option @samp{fpus_div}. Not available for ARC EM@.
21669
21670@item fpus_fma
21671Enables support for single-precision floating-point and
21672fused multiply and add hardware extensions@.
21673
21674@item fpud_fma
21675Enables support for double-precision floating-point and
21676fused multiply and add hardware extensions. This option
21677includes option @samp{fpus_fma}. Not available for ARC EM@.
21678
21679@item fpus_all
21680Enables support for all single-precision floating-point hardware
21681extensions@.
21682
21683@item fpud_all
21684Enables support for all single- and double-precision floating-point
21685hardware extensions. Not available for ARC EM@.
21686
21687@end table
21688
d77de738 21689@opindex mirq-ctrl-saved
ddf6fe37 21690@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21691Specifies general-purposes registers that the processor automatically
21692saves/restores on interrupt entry and exit. @var{register-range} is
21693specified as two registers separated by a dash. The register range
21694always starts with @code{r0}, the upper limit is @code{fp} register.
21695@var{blink} and @var{lp_count} are optional. This option is only
21696valid for ARC EM and ARC HS cores.
21697
d77de738 21698@opindex mrgf-banked-regs
ddf6fe37 21699@item -mrgf-banked-regs=@var{number}
d77de738
ML
21700Specifies the number of registers replicated in second register bank
21701on entry to fast interrupt. Fast interrupts are interrupts with the
21702highest priority level P0. These interrupts save only PC and STATUS32
21703registers to avoid memory transactions during interrupt entry and exit
21704sequences. Use this option when you are using fast interrupts in an
21705ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21706
d77de738 21707@opindex mlpc-width
ddf6fe37 21708@item -mlpc-width=@var{width}
d77de738
ML
21709Specify the width of the @code{lp_count} register. Valid values for
21710@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21711fixed to 32 bits. If the width is less than 32, the compiler does not
21712attempt to transform loops in your program to use the zero-delay loop
21713mechanism unless it is known that the @code{lp_count} register can
21714hold the required loop-counter value. Depending on the width
21715specified, the compiler and run-time library might continue to use the
21716loop mechanism for various needs. This option defines macro
21717@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21718
d77de738 21719@opindex mrf16
ddf6fe37 21720@item -mrf16
d77de738
ML
21721This option instructs the compiler to generate code for a 16-entry
21722register file. This option defines the @code{__ARC_RF16__}
21723preprocessor macro.
21724
d77de738 21725@opindex mbranch-index
ddf6fe37 21726@item -mbranch-index
d77de738
ML
21727Enable use of @code{bi} or @code{bih} instructions to implement jump
21728tables.
21729
21730@end table
21731
21732The following options are passed through to the assembler, and also
21733define preprocessor macro symbols.
21734
21735@c Flags used by the assembler, but for which we define preprocessor
21736@c macro symbols as well.
21737@table @gcctabopt
d77de738 21738@opindex mdsp-packa
ddf6fe37 21739@item -mdsp-packa
d77de738
ML
21740Passed down to the assembler to enable the DSP Pack A extensions.
21741Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21742deprecated.
21743
d77de738 21744@opindex mdvbf
ddf6fe37 21745@item -mdvbf
d77de738
ML
21746Passed down to the assembler to enable the dual Viterbi butterfly
21747extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21748option is deprecated.
21749
21750@c ARC700 4.10 extension instruction
d77de738 21751@opindex mlock
ddf6fe37 21752@item -mlock
d77de738
ML
21753Passed down to the assembler to enable the locked load/store
21754conditional extension. Also sets the preprocessor symbol
21755@code{__Xlock}.
21756
d77de738 21757@opindex mmac-d16
ddf6fe37 21758@item -mmac-d16
d77de738
ML
21759Passed down to the assembler. Also sets the preprocessor symbol
21760@code{__Xxmac_d16}. This option is deprecated.
21761
d77de738 21762@opindex mmac-24
ddf6fe37 21763@item -mmac-24
d77de738
ML
21764Passed down to the assembler. Also sets the preprocessor symbol
21765@code{__Xxmac_24}. This option is deprecated.
21766
21767@c ARC700 4.10 extension instruction
d77de738 21768@opindex mrtsc
ddf6fe37 21769@item -mrtsc
d77de738
ML
21770Passed down to the assembler to enable the 64-bit time-stamp counter
21771extension instruction. Also sets the preprocessor symbol
21772@code{__Xrtsc}. This option is deprecated.
21773
21774@c ARC700 4.10 extension instruction
d77de738 21775@opindex mswape
ddf6fe37 21776@item -mswape
d77de738
ML
21777Passed down to the assembler to enable the swap byte ordering
21778extension instruction. Also sets the preprocessor symbol
21779@code{__Xswape}.
21780
d77de738 21781@opindex mtelephony
ddf6fe37 21782@item -mtelephony
d77de738
ML
21783Passed down to the assembler to enable dual- and single-operand
21784instructions for telephony. Also sets the preprocessor symbol
21785@code{__Xtelephony}. This option is deprecated.
21786
d77de738 21787@opindex mxy
ddf6fe37 21788@item -mxy
d77de738
ML
21789Passed down to the assembler to enable the XY memory extension. Also
21790sets the preprocessor symbol @code{__Xxy}.
21791
21792@end table
21793
21794The following options control how the assembly code is annotated:
21795
21796@c Assembly annotation options
21797@table @gcctabopt
d77de738 21798@opindex misize
ddf6fe37 21799@item -misize
d77de738
ML
21800Annotate assembler instructions with estimated addresses.
21801
d77de738 21802@opindex mannotate-align
ddf6fe37 21803@item -mannotate-align
e4b19406 21804Does nothing. Preserved for backward compatibility.
d77de738
ML
21805
21806@end table
21807
21808The following options are passed through to the linker:
21809
21810@c options passed through to the linker
21811@table @gcctabopt
d77de738 21812@opindex marclinux
ddf6fe37 21813@item -marclinux
d77de738
ML
21814Passed through to the linker, to specify use of the @code{arclinux} emulation.
21815This option is enabled by default in tool chains built for
21816@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21817when profiling is not requested.
21818
d77de738 21819@opindex marclinux_prof
ddf6fe37 21820@item -marclinux_prof
d77de738
ML
21821Passed through to the linker, to specify use of the
21822@code{arclinux_prof} emulation. This option is enabled by default in
21823tool chains built for @w{@code{arc-linux-uclibc}} and
21824@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21825
21826@end table
21827
21828The following options control the semantics of generated code:
21829
21830@c semantically relevant code generation options
21831@table @gcctabopt
d77de738 21832@opindex mlong-calls
ddf6fe37 21833@item -mlong-calls
d77de738
ML
21834Generate calls as register indirect calls, thus providing access
21835to the full 32-bit address range.
21836
d77de738 21837@opindex mmedium-calls
ddf6fe37 21838@item -mmedium-calls
d77de738
ML
21839Don't use less than 25-bit addressing range for calls, which is the
21840offset available for an unconditional branch-and-link
21841instruction. Conditional execution of function calls is suppressed, to
21842allow use of the 25-bit range, rather than the 21-bit range with
21843conditional branch-and-link. This is the default for tool chains built
21844for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21845
d77de738 21846@opindex G
ddf6fe37 21847@item -G @var{num}
d77de738
ML
21848Put definitions of externally-visible data in a small data section if
21849that data is no bigger than @var{num} bytes. The default value of
21850@var{num} is 4 for any ARC configuration, or 8 when we have double
21851load/store operations.
21852
d77de738
ML
21853@opindex mno-sdata
21854@opindex msdata
ddf6fe37 21855@item -mno-sdata
d77de738
ML
21856Do not generate sdata references. This is the default for tool chains
21857built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21858targets.
21859
d77de738 21860@opindex mvolatile-cache
ddf6fe37 21861@item -mvolatile-cache
d77de738
ML
21862Use ordinarily cached memory accesses for volatile references. This is the
21863default.
21864
d77de738
ML
21865@opindex mno-volatile-cache
21866@opindex mvolatile-cache
ddf6fe37 21867@item -mno-volatile-cache
d77de738
ML
21868Enable cache bypass for volatile references.
21869
21870@end table
21871
21872The following options fine tune code generation:
21873@c code generation tuning options
21874@table @gcctabopt
d77de738 21875@opindex malign-call
ddf6fe37 21876@item -malign-call
d77de738
ML
21877Does nothing. Preserved for backward compatibility.
21878
d77de738 21879@opindex mauto-modify-reg
ddf6fe37 21880@item -mauto-modify-reg
d77de738
ML
21881Enable the use of pre/post modify with register displacement.
21882
d77de738 21883@opindex mbbit-peephole
ddf6fe37 21884@item -mbbit-peephole
07f7615c 21885Does nothing. Preserved for backward compatibility.
d77de738 21886
d77de738 21887@opindex mno-brcc
ddf6fe37 21888@item -mno-brcc
d77de738
ML
21889This option disables a target-specific pass in @file{arc_reorg} to
21890generate compare-and-branch (@code{br@var{cc}}) instructions.
21891It has no effect on
21892generation of these instructions driven by the combiner pass.
21893
d77de738 21894@opindex mcase-vector-pcrel
ddf6fe37 21895@item -mcase-vector-pcrel
d77de738
ML
21896Use PC-relative switch case tables to enable case table shortening.
21897This is the default for @option{-Os}.
21898
d77de738 21899@opindex mcompact-casesi
ddf6fe37 21900@item -mcompact-casesi
d77de738
ML
21901Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21902and only available for ARCv1 cores. This option is deprecated.
21903
d77de738 21904@opindex mno-cond-exec
ddf6fe37 21905@item -mno-cond-exec
d77de738
ML
21906Disable the ARCompact-specific pass to generate conditional
21907execution instructions.
21908
21909Due to delay slot scheduling and interactions between operand numbers,
21910literal sizes, instruction lengths, and the support for conditional execution,
21911the target-independent pass to generate conditional execution is often lacking,
21912so the ARC port has kept a special pass around that tries to find more
21913conditional execution generation opportunities after register allocation,
21914branch shortening, and delay slot scheduling have been done. This pass
21915generally, but not always, improves performance and code size, at the cost of
21916extra compilation time, which is why there is an option to switch it off.
21917If you have a problem with call instructions exceeding their allowable
21918offset range because they are conditionalized, you should consider using
21919@option{-mmedium-calls} instead.
21920
d77de738 21921@opindex mearly-cbranchsi
ddf6fe37 21922@item -mearly-cbranchsi
d77de738
ML
21923Enable pre-reload use of the @code{cbranchsi} pattern.
21924
d77de738 21925@opindex mexpand-adddi
ddf6fe37 21926@item -mexpand-adddi
d77de738
ML
21927Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21928@code{add.f}, @code{adc} etc. This option is deprecated.
21929
d77de738 21930@opindex mindexed-loads
ddf6fe37 21931@item -mindexed-loads
d77de738
ML
21932Enable the use of indexed loads. This can be problematic because some
21933optimizers then assume that indexed stores exist, which is not
21934the case.
21935
d77de738 21936@opindex mlra
ddf6fe37 21937@item -mlra
d77de738
ML
21938Enable Local Register Allocation. This is still experimental for ARC,
21939so by default the compiler uses standard reload
21940(i.e.@: @option{-mno-lra}).
21941
d77de738 21942@opindex mlra-priority-none
ddf6fe37 21943@item -mlra-priority-none
d77de738
ML
21944Don't indicate any priority for target registers.
21945
d77de738 21946@opindex mlra-priority-compact
ddf6fe37 21947@item -mlra-priority-compact
d77de738
ML
21948Indicate target register priority for r0..r3 / r12..r15.
21949
d77de738 21950@opindex mlra-priority-noncompact
ddf6fe37 21951@item -mlra-priority-noncompact
d77de738
ML
21952Reduce target register priority for r0..r3 / r12..r15.
21953
d77de738 21954@opindex mmillicode
ddf6fe37 21955@item -mmillicode
d77de738
ML
21956When optimizing for size (using @option{-Os}), prologues and epilogues
21957that have to save or restore a large number of registers are often
21958shortened by using call to a special function in libgcc; this is
21959referred to as a @emph{millicode} call. As these calls can pose
21960performance issues, and/or cause linking issues when linking in a
21961nonstandard way, this option is provided to turn on or off millicode
21962call generation.
21963
d77de738 21964@opindex mcode-density-frame
ddf6fe37 21965@item -mcode-density-frame
d77de738
ML
21966This option enable the compiler to emit @code{enter} and @code{leave}
21967instructions. These instructions are only valid for CPUs with
21968code-density feature.
21969
d77de738 21970@opindex mmixed-code
ddf6fe37 21971@item -mmixed-code
d77de738
ML
21972Does nothing. Preserved for backward compatibility.
21973
d77de738 21974@opindex mq-class
ddf6fe37 21975@item -mq-class
d77de738
ML
21976Ths option is deprecated. Enable @samp{q} instruction alternatives.
21977This is the default for @option{-Os}.
21978
d77de738 21979@opindex mRcq
ddf6fe37 21980@item -mRcq
d77de738
ML
21981Does nothing. Preserved for backward compatibility.
21982
d77de738 21983@opindex mRcw
ddf6fe37 21984@item -mRcw
d77de738
ML
21985Does nothing. Preserved for backward compatibility.
21986
d77de738 21987@opindex msize-level
ddf6fe37 21988@item -msize-level=@var{level}
d77de738
ML
21989Fine-tune size optimization with regards to instruction lengths and alignment.
21990The recognized values for @var{level} are:
21991@table @samp
21992@item 0
21993No size optimization. This level is deprecated and treated like @samp{1}.
21994
21995@item 1
21996Short instructions are used opportunistically.
21997
21998@item 2
21999In addition, alignment of loops and of code after barriers are dropped.
22000
22001@item 3
22002In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
22003
22004@end table
22005
22006This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
22007the behavior when this is not set is equivalent to level @samp{1}.
22008
d77de738 22009@opindex mtune
ddf6fe37 22010@item -mtune=@var{cpu}
d77de738
ML
22011Set instruction scheduling parameters for @var{cpu}, overriding any implied
22012by @option{-mcpu=}.
22013
22014Supported values for @var{cpu} are
22015
22016@table @samp
22017@item ARC600
22018Tune for ARC600 CPU.
22019
22020@item ARC601
22021Tune for ARC601 CPU.
22022
22023@item ARC700
22024Tune for ARC700 CPU with standard multiplier block.
22025
22026@item ARC700-xmac
22027Tune for ARC700 CPU with XMAC block.
22028
22029@item ARC725D
22030Tune for ARC725D CPU.
22031
22032@item ARC750D
22033Tune for ARC750D CPU.
22034
22035@item core3
22036Tune for ARCv2 core3 type CPU. This option enable usage of
22037@code{dbnz} instruction.
22038
22039@item release31a
22040Tune for ARC4x release 3.10a.
22041
22042@end table
22043
d77de738 22044@opindex mmultcost
ddf6fe37 22045@item -mmultcost=@var{num}
d77de738
ML
22046Cost to assume for a multiply instruction, with @samp{4} being equal to a
22047normal instruction.
22048
d77de738 22049@opindex munalign-prob-threshold
ddf6fe37 22050@item -munalign-prob-threshold=@var{probability}
d77de738
ML
22051Does nothing. Preserved for backward compatibility.
22052
22053@end table
22054
22055The following options are maintained for backward compatibility, but
22056are now deprecated and will be removed in a future release:
22057
22058@c Deprecated options
22059@table @gcctabopt
22060
d77de738 22061@opindex margonaut
ddf6fe37 22062@item -margonaut
d77de738
ML
22063Obsolete FPX.
22064
d77de738 22065@opindex mbig-endian
d77de738 22066@opindex EB
ddf6fe37
AA
22067@item -mbig-endian
22068@itemx -EB
d77de738
ML
22069Compile code for big-endian targets. Use of these options is now
22070deprecated. Big-endian code is supported by configuring GCC to build
22071@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
22072for which big endian is the default.
22073
d77de738 22074@opindex mlittle-endian
d77de738 22075@opindex EL
ddf6fe37
AA
22076@item -mlittle-endian
22077@itemx -EL
d77de738
ML
22078Compile code for little-endian targets. Use of these options is now
22079deprecated. Little-endian code is supported by configuring GCC to build
22080@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
22081for which little endian is the default.
22082
d77de738 22083@opindex mbarrel_shifter
ddf6fe37 22084@item -mbarrel_shifter
d77de738
ML
22085Replaced by @option{-mbarrel-shifter}.
22086
d77de738 22087@opindex mdpfp_compact
ddf6fe37 22088@item -mdpfp_compact
d77de738
ML
22089Replaced by @option{-mdpfp-compact}.
22090
d77de738 22091@opindex mdpfp_fast
ddf6fe37 22092@item -mdpfp_fast
d77de738
ML
22093Replaced by @option{-mdpfp-fast}.
22094
d77de738 22095@opindex mdsp_packa
ddf6fe37 22096@item -mdsp_packa
d77de738
ML
22097Replaced by @option{-mdsp-packa}.
22098
d77de738 22099@opindex mEA
ddf6fe37 22100@item -mEA
d77de738
ML
22101Replaced by @option{-mea}.
22102
d77de738 22103@opindex mmac_24
ddf6fe37 22104@item -mmac_24
d77de738
ML
22105Replaced by @option{-mmac-24}.
22106
d77de738 22107@opindex mmac_d16
ddf6fe37 22108@item -mmac_d16
d77de738
ML
22109Replaced by @option{-mmac-d16}.
22110
d77de738 22111@opindex mspfp_compact
ddf6fe37 22112@item -mspfp_compact
d77de738
ML
22113Replaced by @option{-mspfp-compact}.
22114
d77de738 22115@opindex mspfp_fast
ddf6fe37 22116@item -mspfp_fast
d77de738
ML
22117Replaced by @option{-mspfp-fast}.
22118
d77de738 22119@opindex mtune
ddf6fe37 22120@item -mtune=@var{cpu}
d77de738
ML
22121Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
22122@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
22123@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
22124
d77de738 22125@opindex multcost
ddf6fe37 22126@item -multcost=@var{num}
d77de738
ML
22127Replaced by @option{-mmultcost}.
22128
22129@end table
22130
22131@node ARM Options
22132@subsection ARM Options
22133@cindex ARM options
22134
22135These @samp{-m} options are defined for the ARM port:
22136
22137@table @gcctabopt
d77de738 22138@opindex mabi
ddf6fe37 22139@item -mabi=@var{name}
d77de738
ML
22140Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
22141@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
22142
d77de738 22143@opindex mapcs-frame
ddf6fe37 22144@item -mapcs-frame
d77de738
ML
22145Generate a stack frame that is compliant with the ARM Procedure Call
22146Standard for all functions, even if this is not strictly necessary for
22147correct execution of the code. Specifying @option{-fomit-frame-pointer}
22148with this option causes the stack frames not to be generated for
22149leaf functions. The default is @option{-mno-apcs-frame}.
22150This option is deprecated.
22151
d77de738 22152@opindex mapcs
ddf6fe37 22153@item -mapcs
d77de738
ML
22154This is a synonym for @option{-mapcs-frame} and is deprecated.
22155
22156@ignore
22157@c not currently implemented
d77de738 22158@opindex mapcs-stack-check
ddf6fe37 22159@item -mapcs-stack-check
d77de738
ML
22160Generate code to check the amount of stack space available upon entry to
22161every function (that actually uses some stack space). If there is
22162insufficient space available then either the function
22163@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
22164called, depending upon the amount of stack space required. The runtime
22165system is required to provide these functions. The default is
22166@option{-mno-apcs-stack-check}, since this produces smaller code.
22167
22168@c not currently implemented
d77de738 22169@opindex mapcs-reentrant
ddf6fe37 22170@item -mapcs-reentrant
d77de738
ML
22171Generate reentrant, position-independent code. The default is
22172@option{-mno-apcs-reentrant}.
22173@end ignore
22174
d77de738 22175@opindex mthumb-interwork
ddf6fe37 22176@item -mthumb-interwork
d77de738
ML
22177Generate code that supports calling between the ARM and Thumb
22178instruction sets. Without this option, on pre-v5 architectures, the
22179two instruction sets cannot be reliably used inside one program. The
22180default is @option{-mno-thumb-interwork}, since slightly larger code
22181is generated when @option{-mthumb-interwork} is specified. In AAPCS
22182configurations this option is meaningless.
22183
d77de738
ML
22184@opindex mno-sched-prolog
22185@opindex msched-prolog
ddf6fe37 22186@item -mno-sched-prolog
d77de738
ML
22187Prevent the reordering of instructions in the function prologue, or the
22188merging of those instruction with the instructions in the function's
22189body. This means that all functions start with a recognizable set
22190of instructions (or in fact one of a choice from a small set of
22191different function prologues), and this information can be used to
22192locate the start of functions inside an executable piece of code. The
22193default is @option{-msched-prolog}.
22194
d77de738 22195@opindex mfloat-abi
ddf6fe37 22196@item -mfloat-abi=@var{name}
d77de738
ML
22197Specifies which floating-point ABI to use. Permissible values
22198are: @samp{soft}, @samp{softfp} and @samp{hard}.
22199
22200Specifying @samp{soft} causes GCC to generate output containing
22201library calls for floating-point operations.
22202@samp{softfp} allows the generation of code using hardware floating-point
22203instructions, but still uses the soft-float calling conventions.
22204@samp{hard} allows generation of floating-point instructions
22205and uses FPU-specific calling conventions.
22206
22207The default depends on the specific target configuration. Note that
22208the hard-float and soft-float ABIs are not link-compatible; you must
22209compile your entire program with the same ABI, and link with a
22210compatible set of libraries.
22211
d77de738 22212@opindex mgeneral-regs-only
ddf6fe37 22213@item -mgeneral-regs-only
d77de738
ML
22214Generate code which uses only the general-purpose registers. This will prevent
22215the compiler from using floating-point and Advanced SIMD registers but will not
22216impose any restrictions on the assembler.
22217
d77de738 22218@opindex mlittle-endian
ddf6fe37 22219@item -mlittle-endian
d77de738
ML
22220Generate code for a processor running in little-endian mode. This is
22221the default for all standard configurations.
22222
d77de738 22223@opindex mbig-endian
ddf6fe37 22224@item -mbig-endian
d77de738
ML
22225Generate code for a processor running in big-endian mode; the default is
22226to compile code for a little-endian processor.
22227
ddf6fe37 22228@opindex mbe8
d77de738
ML
22229@item -mbe8
22230@itemx -mbe32
d77de738
ML
22231When linking a big-endian image select between BE8 and BE32 formats.
22232The option has no effect for little-endian images and is ignored. The
22233default is dependent on the selected target architecture. For ARMv6
22234and later architectures the default is BE8, for older architectures
22235the default is BE32. BE32 format has been deprecated by ARM.
22236
d77de738 22237@opindex march
ddf6fe37 22238@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22239This specifies the name of the target ARM architecture. GCC uses this
22240name to determine what kind of instructions it can emit when generating
22241assembly code. This option can be used in conjunction with or instead
22242of the @option{-mcpu=} option.
22243
22244Permissible names are:
22245@samp{armv4t},
22246@samp{armv5t}, @samp{armv5te},
22247@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
22248@samp{armv6z}, @samp{armv6zk},
22249@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
22250@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
22251@samp{armv8.4-a},
22252@samp{armv8.5-a},
22253@samp{armv8.6-a},
22254@samp{armv9-a},
22255@samp{armv7-r},
22256@samp{armv8-r},
22257@samp{armv6-m}, @samp{armv6s-m},
22258@samp{armv7-m}, @samp{armv7e-m},
22259@samp{armv8-m.base}, @samp{armv8-m.main},
22260@samp{armv8.1-m.main},
22261@samp{armv9-a},
22262@samp{iwmmxt} and @samp{iwmmxt2}.
22263
22264Additionally, the following architectures, which lack support for the
22265Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
22266
22267Many of the architectures support extensions. These can be added by
22268appending @samp{+@var{extension}} to the architecture name. Extension
22269options are processed in order and capabilities accumulate. An extension
22270will also enable any necessary base extensions
22271upon which it depends. For example, the @samp{+crypto} extension
22272will always enable the @samp{+simd} extension. The exception to the
22273additive construction is for extensions that are prefixed with
22274@samp{+no@dots{}}: these extensions disable the specified option and
22275any other extensions that may depend on the presence of that
22276extension.
22277
22278For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
22279writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
22280entirely disabled by the @samp{+nofp} option that follows it.
22281
22282Most extension names are generically named, but have an effect that is
22283dependent upon the architecture to which it is applied. For example,
22284the @samp{+simd} option can be applied to both @samp{armv7-a} and
22285@samp{armv8-a} architectures, but will enable the original ARMv7-A
22286Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
22287variant for @samp{armv8-a}.
22288
22289The table below lists the supported extensions for each architecture.
22290Architectures not mentioned do not support any extensions.
22291
22292@table @samp
22293@item armv5te
22294@itemx armv6
22295@itemx armv6j
22296@itemx armv6k
22297@itemx armv6kz
22298@itemx armv6t2
22299@itemx armv6z
22300@itemx armv6zk
22301@table @samp
22302@item +fp
22303The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
22304used as an alias for this extension.
22305
22306@item +nofp
22307Disable the floating-point instructions.
22308@end table
22309
22310@item armv7
22311The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
22312@table @samp
22313@item +fp
22314The VFPv3 floating-point instructions, with 16 double-precision
22315registers. The extension @samp{+vfpv3-d16} can be used as an alias
22316for this extension. Note that floating-point is not supported by the
22317base ARMv7-M architecture, but is compatible with both the ARMv7-A and
22318ARMv7-R architectures.
22319
22320@item +nofp
22321Disable the floating-point instructions.
22322@end table
22323
22324@item armv7-a
22325@table @samp
22326@item +mp
22327The multiprocessing extension.
22328
22329@item +sec
22330The security extension.
22331
22332@item +fp
22333The VFPv3 floating-point instructions, with 16 double-precision
22334registers. The extension @samp{+vfpv3-d16} can be used as an alias
22335for this extension.
22336
22337@item +simd
22338The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22339The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
22340for this extension.
22341
22342@item +vfpv3
22343The VFPv3 floating-point instructions, with 32 double-precision
22344registers.
22345
22346@item +vfpv3-d16-fp16
22347The VFPv3 floating-point instructions, with 16 double-precision
22348registers and the half-precision floating-point conversion operations.
22349
22350@item +vfpv3-fp16
22351The VFPv3 floating-point instructions, with 32 double-precision
22352registers and the half-precision floating-point conversion operations.
22353
22354@item +vfpv4-d16
22355The VFPv4 floating-point instructions, with 16 double-precision
22356registers.
22357
22358@item +vfpv4
22359The VFPv4 floating-point instructions, with 32 double-precision
22360registers.
22361
22362@item +neon-fp16
22363The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22364the half-precision floating-point conversion operations.
22365
22366@item +neon-vfpv4
22367The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
22368
22369@item +nosimd
22370Disable the Advanced SIMD instructions (does not disable floating point).
22371
22372@item +nofp
22373Disable the floating-point and Advanced SIMD instructions.
22374@end table
22375
22376@item armv7ve
22377The extended version of the ARMv7-A architecture with support for
22378virtualization.
22379@table @samp
22380@item +fp
22381The VFPv4 floating-point instructions, with 16 double-precision registers.
22382The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
22383
22384@item +simd
22385The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
22386extension @samp{+neon-vfpv4} can be used as an alias for this extension.
22387
22388@item +vfpv3-d16
22389The VFPv3 floating-point instructions, with 16 double-precision
22390registers.
22391
22392@item +vfpv3
22393The VFPv3 floating-point instructions, with 32 double-precision
22394registers.
22395
22396@item +vfpv3-d16-fp16
22397The VFPv3 floating-point instructions, with 16 double-precision
22398registers and the half-precision floating-point conversion operations.
22399
22400@item +vfpv3-fp16
22401The VFPv3 floating-point instructions, with 32 double-precision
22402registers and the half-precision floating-point conversion operations.
22403
22404@item +vfpv4-d16
22405The VFPv4 floating-point instructions, with 16 double-precision
22406registers.
22407
22408@item +vfpv4
22409The VFPv4 floating-point instructions, with 32 double-precision
22410registers.
22411
22412@item +neon
22413The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22414The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
22415
22416@item +neon-fp16
22417The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22418the half-precision floating-point conversion operations.
22419
22420@item +nosimd
22421Disable the Advanced SIMD instructions (does not disable floating point).
22422
22423@item +nofp
22424Disable the floating-point and Advanced SIMD instructions.
22425@end table
22426
22427@item armv8-a
22428@table @samp
22429@item +crc
22430The Cyclic Redundancy Check (CRC) instructions.
22431@item +simd
22432The ARMv8-A Advanced SIMD and floating-point instructions.
22433@item +crypto
22434The cryptographic instructions.
22435@item +nocrypto
22436Disable the cryptographic instructions.
22437@item +nofp
22438Disable the floating-point, Advanced SIMD and cryptographic instructions.
22439@item +sb
22440Speculation Barrier Instruction.
22441@item +predres
22442Execution and Data Prediction Restriction Instructions.
22443@end table
22444
22445@item armv8.1-a
22446@table @samp
22447@item +simd
22448The ARMv8.1-A Advanced SIMD and floating-point instructions.
22449
22450@item +crypto
22451The cryptographic instructions. This also enables the Advanced SIMD and
22452floating-point instructions.
22453
22454@item +nocrypto
22455Disable the cryptographic instructions.
22456
22457@item +nofp
22458Disable the floating-point, Advanced SIMD and cryptographic instructions.
22459
22460@item +sb
22461Speculation Barrier Instruction.
22462
22463@item +predres
22464Execution and Data Prediction Restriction Instructions.
22465@end table
22466
22467@item armv8.2-a
22468@itemx armv8.3-a
22469@table @samp
22470@item +fp16
22471The half-precision floating-point data processing instructions.
22472This also enables the Advanced SIMD and floating-point instructions.
22473
22474@item +fp16fml
22475The half-precision floating-point fmla extension. This also enables
22476the half-precision floating-point extension and Advanced SIMD and
22477floating-point instructions.
22478
22479@item +simd
22480The ARMv8.1-A Advanced SIMD and floating-point instructions.
22481
22482@item +crypto
22483The cryptographic instructions. This also enables the Advanced SIMD and
22484floating-point instructions.
22485
22486@item +dotprod
22487Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22488
22489@item +nocrypto
22490Disable the cryptographic extension.
22491
22492@item +nofp
22493Disable the floating-point, Advanced SIMD and cryptographic instructions.
22494
22495@item +sb
22496Speculation Barrier Instruction.
22497
22498@item +predres
22499Execution and Data Prediction Restriction Instructions.
22500
22501@item +i8mm
225028-bit Integer Matrix Multiply instructions.
22503This also enables Advanced SIMD and floating-point instructions.
22504
22505@item +bf16
22506Brain half-precision floating-point instructions.
22507This also enables Advanced SIMD and floating-point instructions.
22508@end table
22509
22510@item armv8.4-a
22511@table @samp
22512@item +fp16
22513The half-precision floating-point data processing instructions.
22514This also enables the Advanced SIMD and floating-point instructions as well
22515as the Dot Product extension and the half-precision floating-point fmla
22516extension.
22517
22518@item +simd
22519The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22520Dot Product extension.
22521
22522@item +crypto
22523The cryptographic instructions. This also enables the Advanced SIMD and
22524floating-point instructions as well as the Dot Product extension.
22525
22526@item +nocrypto
22527Disable the cryptographic extension.
22528
22529@item +nofp
22530Disable the floating-point, Advanced SIMD and cryptographic instructions.
22531
22532@item +sb
22533Speculation Barrier Instruction.
22534
22535@item +predres
22536Execution and Data Prediction Restriction Instructions.
22537
22538@item +i8mm
225398-bit Integer Matrix Multiply instructions.
22540This also enables Advanced SIMD and floating-point instructions.
22541
22542@item +bf16
22543Brain half-precision floating-point instructions.
22544This also enables Advanced SIMD and floating-point instructions.
22545@end table
22546
22547@item armv8.5-a
22548@table @samp
22549@item +fp16
22550The half-precision floating-point data processing instructions.
22551This also enables the Advanced SIMD and floating-point instructions as well
22552as the Dot Product extension and the half-precision floating-point fmla
22553extension.
22554
22555@item +simd
22556The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22557Dot Product extension.
22558
22559@item +crypto
22560The cryptographic instructions. This also enables the Advanced SIMD and
22561floating-point instructions as well as the Dot Product extension.
22562
22563@item +nocrypto
22564Disable the cryptographic extension.
22565
22566@item +nofp
22567Disable the floating-point, Advanced SIMD and cryptographic instructions.
22568
22569@item +i8mm
225708-bit Integer Matrix Multiply instructions.
22571This also enables Advanced SIMD and floating-point instructions.
22572
22573@item +bf16
22574Brain half-precision floating-point instructions.
22575This also enables Advanced SIMD and floating-point instructions.
22576@end table
22577
22578@item armv8.6-a
22579@table @samp
22580@item +fp16
22581The half-precision floating-point data processing instructions.
22582This also enables the Advanced SIMD and floating-point instructions as well
22583as the Dot Product extension and the half-precision floating-point fmla
22584extension.
22585
22586@item +simd
22587The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22588Dot Product extension.
22589
22590@item +crypto
22591The cryptographic instructions. This also enables the Advanced SIMD and
22592floating-point instructions as well as the Dot Product extension.
22593
22594@item +nocrypto
22595Disable the cryptographic extension.
22596
22597@item +nofp
22598Disable the floating-point, Advanced SIMD and cryptographic instructions.
22599
22600@item +i8mm
226018-bit Integer Matrix Multiply instructions.
22602This also enables Advanced SIMD and floating-point instructions.
22603
22604@item +bf16
22605Brain half-precision floating-point instructions.
22606This also enables Advanced SIMD and floating-point instructions.
22607@end table
22608
22609@item armv7-r
22610@table @samp
22611@item +fp.sp
22612The single-precision VFPv3 floating-point instructions. The extension
22613@samp{+vfpv3xd} can be used as an alias for this extension.
22614
22615@item +fp
22616The VFPv3 floating-point instructions with 16 double-precision registers.
22617The extension +vfpv3-d16 can be used as an alias for this extension.
22618
22619@item +vfpv3xd-d16-fp16
22620The single-precision VFPv3 floating-point instructions with 16 double-precision
22621registers and the half-precision floating-point conversion operations.
22622
22623@item +vfpv3-d16-fp16
22624The VFPv3 floating-point instructions with 16 double-precision
22625registers and the half-precision floating-point conversion operations.
22626
22627@item +nofp
22628Disable the floating-point extension.
22629
22630@item +idiv
22631The ARM-state integer division instructions.
22632
22633@item +noidiv
22634Disable the ARM-state integer division extension.
22635@end table
22636
22637@item armv7e-m
22638@table @samp
22639@item +fp
22640The single-precision VFPv4 floating-point instructions.
22641
22642@item +fpv5
22643The single-precision FPv5 floating-point instructions.
22644
22645@item +fp.dp
22646The single- and double-precision FPv5 floating-point instructions.
22647
22648@item +nofp
22649Disable the floating-point extensions.
22650@end table
22651
22652@item armv8.1-m.main
22653@table @samp
22654
22655@item +dsp
22656The DSP instructions.
22657
22658@item +mve
22659The M-Profile Vector Extension (MVE) integer instructions.
22660
22661@item +mve.fp
22662The M-Profile Vector Extension (MVE) integer and single precision
22663floating-point instructions.
22664
22665@item +fp
22666The single-precision floating-point instructions.
22667
22668@item +fp.dp
22669The single- and double-precision floating-point instructions.
22670
22671@item +nofp
22672Disable the floating-point extension.
22673
22674@item +cdecp0, +cdecp1, ... , +cdecp7
22675Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22676to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22677
22678@item +pacbti
22679Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22680@end table
22681
22682@item armv8-m.main
22683@table @samp
22684@item +dsp
22685The DSP instructions.
22686
22687@item +nodsp
22688Disable the DSP extension.
22689
22690@item +fp
22691The single-precision floating-point instructions.
22692
22693@item +fp.dp
22694The single- and double-precision floating-point instructions.
22695
22696@item +nofp
22697Disable the floating-point extension.
22698
22699@item +cdecp0, +cdecp1, ... , +cdecp7
22700Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22701to the numbers given in the options in the range 0 to 7.
22702@end table
22703
22704@item armv8-r
22705@table @samp
22706@item +crc
22707The Cyclic Redundancy Check (CRC) instructions.
22708@item +fp.sp
22709The single-precision FPv5 floating-point instructions.
22710@item +simd
22711The ARMv8-A Advanced SIMD and floating-point instructions.
22712@item +crypto
22713The cryptographic instructions.
22714@item +nocrypto
22715Disable the cryptographic instructions.
22716@item +nofp
22717Disable the floating-point, Advanced SIMD and cryptographic instructions.
22718@end table
22719
22720@end table
22721
22722@option{-march=native} causes the compiler to auto-detect the architecture
22723of the build computer. At present, this feature is only supported on
22724GNU/Linux, and not all architectures are recognized. If the auto-detect
22725is unsuccessful the option has no effect.
22726
d77de738 22727@opindex mtune
ddf6fe37 22728@item -mtune=@var{name}
d77de738
ML
22729This option specifies the name of the target ARM processor for
22730which GCC should tune the performance of the code.
22731For some ARM implementations better performance can be obtained by using
22732this option.
22733Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22734@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22735@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22736@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22737@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22738@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22739@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22740@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22741@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22742@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22743@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22744@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22745@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22746@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22747@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22748@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22749@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22750@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22751@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22752@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22753@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22754@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22755@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22756@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22757@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22758@samp{xgene1}.
22759
22760Additionally, this option can specify that GCC should tune the performance
22761of the code for a big.LITTLE system. Permissible names are:
22762@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22763@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22764@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22765@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22766
22767@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22768performance for a blend of processors within architecture @var{arch}.
22769The aim is to generate code that run well on the current most popular
22770processors, balancing between optimizations that benefit some CPUs in the
22771range, and avoiding performance pitfalls of other CPUs. The effects of
22772this option may change in future GCC versions as CPU models come and go.
22773
22774@option{-mtune} permits the same extension options as @option{-mcpu}, but
22775the extension options do not affect the tuning of the generated code.
22776
22777@option{-mtune=native} causes the compiler to auto-detect the CPU
22778of the build computer. At present, this feature is only supported on
22779GNU/Linux, and not all architectures are recognized. If the auto-detect is
22780unsuccessful the option has no effect.
22781
d77de738 22782@opindex mcpu
ddf6fe37 22783@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22784This specifies the name of the target ARM processor. GCC uses this name
22785to derive the name of the target ARM architecture (as if specified
22786by @option{-march}) and the ARM processor type for which to tune for
22787performance (as if specified by @option{-mtune}). Where this option
22788is used in conjunction with @option{-march} or @option{-mtune},
22789those options take precedence over the appropriate part of this option.
22790
22791Many of the supported CPUs implement optional architectural
22792extensions. Where this is so the architectural extensions are
22793normally enabled by default. If implementations that lack the
22794extension exist, then the extension syntax can be used to disable
22795those extensions that have been omitted. For floating-point and
22796Advanced SIMD (Neon) instructions, the settings of the options
22797@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22798floating-point and Advanced SIMD instructions will only be used if
22799@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22800@option{-mfpu} other than @samp{auto} will override the available
22801floating-point and SIMD extension instructions.
22802
22803For example, @samp{cortex-a9} can be found in three major
22804configurations: integer only, with just a floating-point unit or with
22805floating-point and Advanced SIMD. The default is to enable all the
22806instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22807be used to disable just the SIMD or both the SIMD and floating-point
22808instructions respectively.
22809
22810Permissible names for this option are the same as those for
22811@option{-mtune}.
22812
22813The following extension options are common to the listed CPUs:
22814
22815@table @samp
22816@item +nodsp
ccfd1e7f
SP
22817Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22818@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22819Extension (MVE) integer and single precision floating-point instructions on
22820@samp{cortex-m55} and @samp{cortex-m85}.
22821
22822@item +nopacbti
22823Disable the Pointer Authentication and Branch Target Identification Extension
22824on @samp{cortex-m85}.
d77de738
ML
22825
22826@item +nomve
22827Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22828floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22829
22830@item +nomve.fp
22831Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22832instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22833
798a0d05
SP
22834@item +cdecp0, +cdecp1, ... , +cdecp7
22835Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22836to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22837
d77de738
ML
22838@item +nofp
22839Disables the floating-point instructions on @samp{arm9e},
22840@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22841@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22842@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22843@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22844@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22845@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22846Disables the floating-point and SIMD instructions on
22847@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22848@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22849@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22850@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22851@samp{cortex-a53} and @samp{cortex-a55}.
22852
22853@item +nofp.dp
22854Disables the double-precision component of the floating-point instructions
22855on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22856@samp{cortex-r52plus} and @samp{cortex-m7}.
22857
22858@item +nosimd
22859Disables the SIMD (but not floating-point) instructions on
22860@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22861and @samp{cortex-a9}.
22862
22863@item +crypto
22864Enables the cryptographic instructions on @samp{cortex-a32},
22865@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22866@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22867@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22868@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22869@samp{cortex-a75.cortex-a55}.
22870@end table
22871
22872Additionally the @samp{generic-armv7-a} pseudo target defaults to
22873VFPv3 with 16 double-precision registers. It supports the following
22874extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22875@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22876@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22877@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22878the extensions to @option{-march=armv7-a}.
22879
22880@option{-mcpu=generic-@var{arch}} is also permissible, and is
22881equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22882See @option{-mtune} for more information.
22883
22884@option{-mcpu=native} causes the compiler to auto-detect the CPU
22885of the build computer. At present, this feature is only supported on
22886GNU/Linux, and not all architectures are recognized. If the auto-detect
22887is unsuccessful the option has no effect.
22888
d77de738 22889@opindex mfpu
ddf6fe37 22890@item -mfpu=@var{name}
d77de738
ML
22891This specifies what floating-point hardware (or hardware emulation) is
22892available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22893@samp{vfpv3},
22894@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22895@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22896@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22897@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22898@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22899Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22900is an alias for @samp{vfpv2}.
22901
22902The setting @samp{auto} is the default and is special. It causes the
22903compiler to select the floating-point and Advanced SIMD instructions
22904based on the settings of @option{-mcpu} and @option{-march}.
22905
22906If the selected floating-point hardware includes the NEON extension
22907(e.g.@: @option{-mfpu=neon}), note that floating-point
22908operations are not generated by GCC's auto-vectorization pass unless
22909@option{-funsafe-math-optimizations} is also specified. This is
22910because NEON hardware does not fully implement the IEEE 754 standard for
22911floating-point arithmetic (in particular denormal values are treated as
22912zero), so the use of NEON instructions may lead to a loss of precision.
22913
22914You 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}).
22915
d77de738 22916@opindex mfp16-format
ddf6fe37 22917@item -mfp16-format=@var{name}
d77de738
ML
22918Specify the format of the @code{__fp16} half-precision floating-point type.
22919Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22920the default is @samp{none}, in which case the @code{__fp16} type is not
22921defined. @xref{Half-Precision}, for more information.
22922
d77de738 22923@opindex mstructure-size-boundary
ddf6fe37 22924@item -mstructure-size-boundary=@var{n}
d77de738
ML
22925The sizes of all structures and unions are rounded up to a multiple
22926of the number of bits set by this option. Permissible values are 8, 32
22927and 64. The default value varies for different toolchains. For the COFF
22928targeted toolchain the default value is 8. A value of 64 is only allowed
22929if the underlying ABI supports it.
22930
22931Specifying a larger number can produce faster, more efficient code, but
22932can also increase the size of the program. Different values are potentially
22933incompatible. Code compiled with one value cannot necessarily expect to
22934work with code or libraries compiled with another value, if they exchange
22935information using structures or unions.
22936
22937This option is deprecated.
22938
d77de738 22939@opindex mabort-on-noreturn
ddf6fe37 22940@item -mabort-on-noreturn
d77de738
ML
22941Generate a call to the function @code{abort} at the end of a
22942@code{noreturn} function. It is executed if the function tries to
22943return.
22944
d77de738
ML
22945@opindex mlong-calls
22946@opindex mno-long-calls
ddf6fe37
AA
22947@item -mlong-calls
22948@itemx -mno-long-calls
d77de738
ML
22949Tells the compiler to perform function calls by first loading the
22950address of the function into a register and then performing a subroutine
22951call on this register. This switch is needed if the target function
22952lies outside of the 64-megabyte addressing range of the offset-based
22953version of subroutine call instruction.
22954
22955Even if this switch is enabled, not all function calls are turned
22956into long calls. The heuristic is that static functions, functions
22957that have the @code{short_call} attribute, functions that are inside
22958the scope of a @code{#pragma no_long_calls} directive, and functions whose
22959definitions have already been compiled within the current compilation
22960unit are not turned into long calls. The exceptions to this rule are
22961that weak function definitions, functions with the @code{long_call}
22962attribute or the @code{section} attribute, and functions that are within
22963the scope of a @code{#pragma long_calls} directive are always
22964turned into long calls.
22965
22966This feature is not enabled by default. Specifying
22967@option{-mno-long-calls} restores the default behavior, as does
22968placing the function calls within the scope of a @code{#pragma
22969long_calls_off} directive. Note these switches have no effect on how
22970the compiler generates code to handle function calls via function
22971pointers.
22972
d77de738 22973@opindex msingle-pic-base
ddf6fe37 22974@item -msingle-pic-base
d77de738
ML
22975Treat the register used for PIC addressing as read-only, rather than
22976loading it in the prologue for each function. The runtime system is
22977responsible for initializing this register with an appropriate value
22978before execution begins.
22979
d77de738 22980@opindex mpic-register
ddf6fe37 22981@item -mpic-register=@var{reg}
d77de738
ML
22982Specify the register to be used for PIC addressing.
22983For standard PIC base case, the default is any suitable register
22984determined by compiler. For single PIC base case, the default is
22985@samp{R9} if target is EABI based or stack-checking is enabled,
22986otherwise the default is @samp{R10}.
22987
d77de738 22988@opindex mpic-data-is-text-relative
ddf6fe37 22989@item -mpic-data-is-text-relative
d77de738
ML
22990Assume that the displacement between the text and data segments is fixed
22991at static link time. This permits using PC-relative addressing
22992operations to access data known to be in the data segment. For
22993non-VxWorks RTP targets, this option is enabled by default. When
22994disabled on such targets, it will enable @option{-msingle-pic-base} by
22995default.
22996
d77de738 22997@opindex mpoke-function-name
ddf6fe37 22998@item -mpoke-function-name
d77de738
ML
22999Write the name of each function into the text section, directly
23000preceding the function prologue. The generated code is similar to this:
23001
23002@smallexample
23003 t0
23004 .ascii "arm_poke_function_name", 0
23005 .align
23006 t1
23007 .word 0xff000000 + (t1 - t0)
23008 arm_poke_function_name
23009 mov ip, sp
23010 stmfd sp!, @{fp, ip, lr, pc@}
23011 sub fp, ip, #4
23012@end smallexample
23013
23014When performing a stack backtrace, code can inspect the value of
23015@code{pc} stored at @code{fp + 0}. If the trace function then looks at
23016location @code{pc - 12} and the top 8 bits are set, then we know that
23017there is a function name embedded immediately preceding this location
23018and has length @code{((pc[-3]) & 0xff000000)}.
23019
d77de738
ML
23020@opindex marm
23021@opindex mthumb
ddf6fe37
AA
23022@item -mthumb
23023@itemx -marm
d77de738
ML
23024
23025Select between generating code that executes in ARM and Thumb
23026states. The default for most configurations is to generate code
23027that executes in ARM state, but the default can be changed by
23028configuring GCC with the @option{--with-mode=}@var{state}
23029configure option.
23030
23031You can also override the ARM and Thumb mode for each function
23032by using the @code{target("thumb")} and @code{target("arm")} function attributes
23033(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
23034
d77de738 23035@opindex mflip-thumb
ddf6fe37 23036@item -mflip-thumb
d77de738
ML
23037Switch ARM/Thumb modes on alternating functions.
23038This option is provided for regression testing of mixed Thumb/ARM code
23039generation, and is not intended for ordinary use in compiling code.
23040
d77de738 23041@opindex mtpcs-frame
ddf6fe37 23042@item -mtpcs-frame
d77de738
ML
23043Generate a stack frame that is compliant with the Thumb Procedure Call
23044Standard for all non-leaf functions. (A leaf function is one that does
23045not call any other functions.) The default is @option{-mno-tpcs-frame}.
23046
d77de738 23047@opindex mtpcs-leaf-frame
ddf6fe37 23048@item -mtpcs-leaf-frame
d77de738
ML
23049Generate a stack frame that is compliant with the Thumb Procedure Call
23050Standard for all leaf functions. (A leaf function is one that does
23051not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
23052
d77de738 23053@opindex mcallee-super-interworking
ddf6fe37 23054@item -mcallee-super-interworking
d77de738
ML
23055Gives all externally visible functions in the file being compiled an ARM
23056instruction set header which switches to Thumb mode before executing the
23057rest of the function. This allows these functions to be called from
23058non-interworking code. This option is not valid in AAPCS configurations
23059because interworking is enabled by default.
23060
d77de738 23061@opindex mcaller-super-interworking
ddf6fe37 23062@item -mcaller-super-interworking
d77de738
ML
23063Allows calls via function pointers (including virtual functions) to
23064execute correctly regardless of whether the target code has been
23065compiled for interworking or not. There is a small overhead in the cost
23066of executing a function pointer if this option is enabled. This option
23067is not valid in AAPCS configurations because interworking is enabled
23068by default.
23069
d77de738 23070@opindex mtp
ddf6fe37 23071@item -mtp=@var{name}
cca8d9e5
KT
23072Specify the access model for the thread local storage pointer. The model
23073@samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
23074models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
23075the thread pointer from the corresponding system register directly
23076(supported from the arm6k architecture and later). These system registers
23077are accessed through the CP15 co-processor interface and the argument
23078@samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
23079The argument @samp{auto} uses the best available method for the selected
23080processor. The default setting is @samp{auto}.
d77de738 23081
d77de738 23082@opindex mtls-dialect
ddf6fe37 23083@item -mtls-dialect=@var{dialect}
d77de738
ML
23084Specify the dialect to use for accessing thread local storage. Two
23085@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
23086@samp{gnu} dialect selects the original GNU scheme for supporting
23087local and global dynamic TLS models. The @samp{gnu2} dialect
23088selects the GNU descriptor scheme, which provides better performance
23089for shared libraries. The GNU descriptor scheme is compatible with
23090the original scheme, but does require new assembler, linker and
23091library support. Initial and local exec TLS models are unaffected by
23092this option and always use the original scheme.
23093
d77de738 23094@opindex mword-relocations
ddf6fe37 23095@item -mword-relocations
d77de738
ML
23096Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
23097This is enabled by default on targets (uClinux, SymbianOS) where the runtime
23098loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
23099is specified. This option conflicts with @option{-mslow-flash-data}.
23100
d77de738 23101@opindex mfix-cortex-m3-ldrd
ddf6fe37 23102@item -mfix-cortex-m3-ldrd
d77de738
ML
23103Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
23104with overlapping destination and base registers are used. This option avoids
23105generating these instructions. This option is enabled by default when
23106@option{-mcpu=cortex-m3} is specified.
23107
23108@item -mfix-cortex-a57-aes-1742098
23109@itemx -mno-fix-cortex-a57-aes-1742098
23110@itemx -mfix-cortex-a72-aes-1655431
23111@itemx -mno-fix-cortex-a72-aes-1655431
23112Enable (disable) mitigation for an erratum on Cortex-A57 and
23113Cortex-A72 that affects the AES cryptographic instructions. This
23114option is enabled by default when either @option{-mcpu=cortex-a57} or
23115@option{-mcpu=cortex-a72} is specified.
23116
d77de738
ML
23117@opindex munaligned-access
23118@opindex mno-unaligned-access
ddf6fe37
AA
23119@item -munaligned-access
23120@itemx -mno-unaligned-access
d77de738
ML
23121Enables (or disables) reading and writing of 16- and 32- bit values
23122from addresses that are not 16- or 32- bit aligned. By default
23123unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
23124ARMv8-M Baseline architectures, and enabled for all other
23125architectures. If unaligned access is not enabled then words in packed
23126data structures are accessed a byte at a time.
23127
23128The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
23129generated object file to either true or false, depending upon the
23130setting of this option. If unaligned access is enabled then the
23131preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
23132defined.
23133
d77de738 23134@opindex mneon-for-64bits
ddf6fe37 23135@item -mneon-for-64bits
d77de738
ML
23136This option is deprecated and has no effect.
23137
d77de738 23138@opindex mslow-flash-data
ddf6fe37 23139@item -mslow-flash-data
d77de738
ML
23140Assume loading data from flash is slower than fetching instruction.
23141Therefore literal load is minimized for better performance.
23142This option is only supported when compiling for ARMv7 M-profile and
23143off by default. It conflicts with @option{-mword-relocations}.
23144
d77de738 23145@opindex masm-syntax-unified
ddf6fe37 23146@item -masm-syntax-unified
d77de738
ML
23147Assume inline assembler is using unified asm syntax. The default is
23148currently off which implies divided syntax. This option has no impact
23149on Thumb2. However, this may change in future releases of GCC.
23150Divided syntax should be considered deprecated.
23151
d77de738 23152@opindex mrestrict-it
ddf6fe37 23153@item -mrestrict-it
d77de738
ML
23154Restricts generation of IT blocks to conform to the rules of ARMv8-A.
23155IT blocks can only contain a single 16-bit instruction from a select
23156set of instructions. This option is on by default for ARMv8-A Thumb mode.
23157
d77de738 23158@opindex mprint-tune-info
ddf6fe37 23159@item -mprint-tune-info
d77de738
ML
23160Print CPU tuning information as comment in assembler file. This is
23161an option used only for regression testing of the compiler and not
23162intended for ordinary use in compiling code. This option is disabled
23163by default.
23164
d77de738 23165@opindex mverbose-cost-dump
ddf6fe37 23166@item -mverbose-cost-dump
d77de738
ML
23167Enable verbose cost model dumping in the debug dump files. This option is
23168provided for use in debugging the compiler.
23169
d77de738 23170@opindex mpure-code
ddf6fe37 23171@item -mpure-code
d77de738
ML
23172Do not allow constant data to be placed in code sections.
23173Additionally, when compiling for ELF object format give all text sections the
23174ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
23175is only available when generating non-pic code for M-profile targets.
23176
d77de738 23177@opindex mcmse
ddf6fe37 23178@item -mcmse
d77de738
ML
23179Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
23180Development Tools Engineering Specification", which can be found on
23181@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
23182
d77de738 23183@opindex mfix-cmse-cve-2021-35465
ddf6fe37 23184@item -mfix-cmse-cve-2021-35465
d77de738
ML
23185Mitigate against a potential security issue with the @code{VLLDM} instruction
23186in some M-profile devices when using CMSE (CVE-2021-365465). This option is
23187enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
23188@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
23189or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
23190to disable the mitigation.
d77de738 23191
d77de738
ML
23192@opindex mstack-protector-guard
23193@opindex mstack-protector-guard-offset
ddf6fe37
AA
23194@item -mstack-protector-guard=@var{guard}
23195@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
23196Generate stack protection code using canary at @var{guard}. Supported
23197locations are @samp{global} for a global canary or @samp{tls} for a
23198canary accessible via the TLS register. The option
23199@option{-mstack-protector-guard-offset=} is for use with
23200@option{-fstack-protector-guard=tls} and not for use in user-land code.
23201
d77de738
ML
23202@opindex mfdpic
23203@opindex mno-fdpic
ddf6fe37
AA
23204@item -mfdpic
23205@itemx -mno-fdpic
d77de738
ML
23206Select the FDPIC ABI, which uses 64-bit function descriptors to
23207represent pointers to functions. When the compiler is configured for
23208@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
23209and implies @option{-fPIE} if none of the PIC/PIE-related options is
23210provided. On other targets, it only enables the FDPIC-specific code
23211generation features, and the user should explicitly provide the
23212PIC/PIE-related options as needed.
23213
23214Note that static linking is not supported because it would still
23215involve the dynamic linker when the program self-relocates. If such
23216behavior is acceptable, use -static and -Wl,-dynamic-linker options.
23217
23218The opposite @option{-mno-fdpic} option is useful (and required) to
23219build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
23220toolchain as the one used to build the userland programs.
23221
14fab5fb 23222@opindex mbranch-protection
ddf6fe37 23223@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
23224Enable branch protection features (armv8.1-m.main only).
23225@samp{none} generate code without branch protection or return address
23226signing.
23227@samp{standard[+@var{leaf}]} generate code with all branch protection
23228features enabled at their standard level.
23229@samp{pac-ret[+@var{leaf}]} generate code with return address signing
23230set to its standard level, which is to sign all functions that save
23231the return address to memory.
23232@samp{leaf} When return address signing is enabled, also sign leaf
23233functions even if they do not write the return address to memory.
23234+@samp{bti} Add landing-pad instructions at the permitted targets of
23235indirect branch instructions.
23236
23237If the @samp{+pacbti} architecture extension is not enabled, then all
23238branch protection and return address signing operations are
23239constrained to use only the instructions defined in the
23240architectural-NOP space. The generated code will remain
23241backwards-compatible with earlier versions of the architecture, but
23242the additional security can be enabled at run time on processors that
23243support the @samp{PACBTI} extension.
23244
23245Branch target enforcement using BTI can only be enabled at runtime if
23246all code in the application has been compiled with at least
23247@samp{-mbranch-protection=bti}.
23248
23249Any setting other than @samp{none} is supported only on armv8-m.main
23250or later.
23251
23252The default is to generate code without branch protection or return
23253address signing.
23254
d77de738
ML
23255@end table
23256
23257@node AVR Options
23258@subsection AVR Options
23259@cindex AVR Options
23260
23261These options are defined for AVR implementations:
23262
23263@table @gcctabopt
d77de738 23264@opindex mmcu
ddf6fe37 23265@item -mmcu=@var{mcu}
d77de738
ML
23266Specify Atmel AVR instruction set architectures (ISA) or MCU type.
23267
23268The default for this option is@tie{}@samp{avr2}.
23269
23270GCC supports the following AVR devices and ISAs:
23271
23272@include avr-mmcu.texi
23273
d77de738 23274@opindex mabsdata
ddf6fe37 23275@item -mabsdata
d77de738
ML
23276
23277Assume that all data in static storage can be accessed by LDS / STS
23278instructions. This option has only an effect on reduced Tiny devices like
23279ATtiny40. See also the @code{absdata}
23280@ref{AVR Variable Attributes,variable attribute}.
23281
d77de738 23282@opindex maccumulate-args
ddf6fe37 23283@item -maccumulate-args
d77de738
ML
23284Accumulate outgoing function arguments and acquire/release the needed
23285stack space for outgoing function arguments once in function
23286prologue/epilogue. Without this option, outgoing arguments are pushed
23287before calling a function and popped afterwards.
23288
23289Popping the arguments after the function call can be expensive on
23290AVR so that accumulating the stack space might lead to smaller
23291executables because arguments need not be removed from the
23292stack after such a function call.
23293
23294This option can lead to reduced code size for functions that perform
23295several calls to functions that get their arguments on the stack like
23296calls to printf-like functions.
23297
d77de738 23298@opindex mbranch-cost
ddf6fe37 23299@item -mbranch-cost=@var{cost}
d77de738
ML
23300Set the branch costs for conditional branch instructions to
23301@var{cost}. Reasonable values for @var{cost} are small, non-negative
23302integers. The default branch cost is 0.
23303
d77de738 23304@opindex mcall-prologues
ddf6fe37 23305@item -mcall-prologues
d77de738
ML
23306Functions prologues/epilogues are expanded as calls to appropriate
23307subroutines. Code size is smaller.
23308
d77de738
ML
23309@opindex mdouble
23310@opindex mlong-double
ddf6fe37
AA
23311@item -mdouble=@var{bits}
23312@itemx -mlong-double=@var{bits}
d77de738
ML
23313Set the size (in bits) of the @code{double} or @code{long double} type,
23314respectively. Possible values for @var{bits} are 32 and 64.
23315Whether or not a specific value for @var{bits} is allowed depends on
23316the @code{--with-double=} and @code{--with-long-double=}
23317@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
23318and the same applies for the default values of the options.
23319
d77de738 23320@opindex mgas-isr-prologues
ddf6fe37 23321@item -mgas-isr-prologues
d77de738
ML
23322Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
23323instruction supported by GNU Binutils.
23324If this option is on, the feature can still be disabled for individual
23325ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
23326function attribute. This feature is activated per default
23327if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
23328and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
23329
d77de738 23330@opindex mint8
ddf6fe37 23331@item -mint8
d77de738
ML
23332Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
23333@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
23334and @code{long long} is 4 bytes. Please note that this option does not
23335conform to the C standards, but it results in smaller code
23336size.
23337
d77de738 23338@opindex mmain-is-OS_task
ddf6fe37 23339@item -mmain-is-OS_task
d77de738
ML
23340Do not save registers in @code{main}. The effect is the same like
23341attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
23342to @code{main}. It is activated per default if optimization is on.
23343
d77de738 23344@opindex mn-flash
ddf6fe37 23345@item -mn-flash=@var{num}
d77de738
ML
23346Assume that the flash memory has a size of
23347@var{num} times 64@tie{}KiB.
23348
d77de738 23349@opindex mno-interrupts
ddf6fe37 23350@item -mno-interrupts
d77de738
ML
23351Generated code is not compatible with hardware interrupts.
23352Code size is smaller.
23353
d77de738 23354@opindex mrelax
ddf6fe37 23355@item -mrelax
d77de738
ML
23356Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
23357@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
23358Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
23359the assembler's command line and the @option{--relax} option to the
23360linker's command line.
23361
23362Jump relaxing is performed by the linker because jump offsets are not
23363known before code is located. Therefore, the assembler code generated by the
23364compiler is the same, but the instructions in the executable may
23365differ from instructions in the assembler code.
23366
23367Relaxing must be turned on if linker stubs are needed, see the
23368section on @code{EIND} and linker stubs below.
23369
d77de738 23370@opindex mrmw
ddf6fe37 23371@item -mrmw
d77de738
ML
23372Assume that the device supports the Read-Modify-Write
23373instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
23374
d77de738 23375@opindex mshort-calls
ddf6fe37 23376@item -mshort-calls
d77de738
ML
23377
23378Assume that @code{RJMP} and @code{RCALL} can target the whole
23379program memory.
23380
23381This option is used internally for multilib selection. It is
23382not an optimization option, and you don't need to set it by hand.
23383
d77de738 23384@opindex msp8
ddf6fe37 23385@item -msp8
d77de738
ML
23386Treat the stack pointer register as an 8-bit register,
23387i.e.@: assume the high byte of the stack pointer is zero.
23388In general, you don't need to set this option by hand.
23389
23390This option is used internally by the compiler to select and
23391build multilibs for architectures @code{avr2} and @code{avr25}.
23392These architectures mix devices with and without @code{SPH}.
23393For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
23394the compiler driver adds or removes this option from the compiler
23395proper's command line, because the compiler then knows if the device
23396or architecture has an 8-bit stack pointer and thus no @code{SPH}
23397register or not.
23398
d77de738 23399@opindex mstrict-X
ddf6fe37 23400@item -mstrict-X
d77de738
ML
23401Use address register @code{X} in a way proposed by the hardware. This means
23402that @code{X} is only used in indirect, post-increment or
23403pre-decrement addressing.
23404
23405Without this option, the @code{X} register may be used in the same way
23406as @code{Y} or @code{Z} which then is emulated by additional
23407instructions.
23408For example, loading a value with @code{X+const} addressing with a
23409small non-negative @code{const < 64} to a register @var{Rn} is
23410performed as
23411
23412@example
23413adiw r26, const ; X += const
23414ld @var{Rn}, X ; @var{Rn} = *X
23415sbiw r26, const ; X -= const
23416@end example
23417
d77de738 23418@opindex mtiny-stack
ddf6fe37 23419@item -mtiny-stack
d77de738
ML
23420Only change the lower 8@tie{}bits of the stack pointer.
23421
d77de738 23422@opindex mfract-convert-truncate
ddf6fe37 23423@item -mfract-convert-truncate
d77de738
ML
23424Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
23425
d77de738 23426@opindex nodevicelib
ddf6fe37 23427@item -nodevicelib
d77de738
ML
23428Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23429
d77de738 23430@opindex nodevicespecs
ddf6fe37 23431@item -nodevicespecs
d77de738
ML
23432Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23433command line. The user takes responsibility for supplying the sub-processes
23434like compiler proper, assembler and linker with appropriate command line
23435options. This means that the user has to supply her private device specs
23436file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23437more need for option @option{-mmcu=@var{mcu}}.
23438
23439This option can also serve as a replacement for the older way of
23440specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23441which contains a folder named @code{device-specs} which contains a specs file named
23442@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23443
d77de738
ML
23444@opindex Waddr-space-convert
23445@opindex Wno-addr-space-convert
ddf6fe37 23446@item -Waddr-space-convert
d77de738
ML
23447Warn about conversions between address spaces in the case where the
23448resulting address space is not contained in the incoming address space.
23449
d77de738
ML
23450@opindex Wmisspelled-isr
23451@opindex Wno-misspelled-isr
ddf6fe37 23452@item -Wmisspelled-isr
d77de738
ML
23453Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23454Enabled by default.
23455@end table
23456
23457@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23458@cindex @code{EIND}
23459Pointers in the implementation are 16@tie{}bits wide.
23460The address of a function or label is represented as word address so
23461that indirect jumps and calls can target any code address in the
23462range of 64@tie{}Ki words.
23463
23464In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23465bytes of program memory space, there is a special function register called
23466@code{EIND} that serves as most significant part of the target address
23467when @code{EICALL} or @code{EIJMP} instructions are used.
23468
23469Indirect jumps and calls on these devices are handled as follows by
23470the compiler and are subject to some limitations:
23471
23472@itemize @bullet
23473
23474@item
23475The compiler never sets @code{EIND}.
23476
23477@item
23478The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23479instructions or might read @code{EIND} directly in order to emulate an
23480indirect call/jump by means of a @code{RET} instruction.
23481
23482@item
23483The compiler assumes that @code{EIND} never changes during the startup
23484code or during the application. In particular, @code{EIND} is not
23485saved/restored in function or interrupt service routine
23486prologue/epilogue.
23487
23488@item
23489For indirect calls to functions and computed goto, the linker
23490generates @emph{stubs}. Stubs are jump pads sometimes also called
23491@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23492The stub contains a direct jump to the desired address.
23493
23494@item
23495Linker relaxation must be turned on so that the linker generates
23496the stubs correctly in all situations. See the compiler option
23497@option{-mrelax} and the linker option @option{--relax}.
23498There are corner cases where the linker is supposed to generate stubs
23499but aborts without relaxation and without a helpful error message.
23500
23501@item
23502The default linker script is arranged for code with @code{EIND = 0}.
23503If code is supposed to work for a setup with @code{EIND != 0}, a custom
23504linker script has to be used in order to place the sections whose
23505name start with @code{.trampolines} into the segment where @code{EIND}
23506points to.
23507
23508@item
23509The startup code from libgcc never sets @code{EIND}.
23510Notice that startup code is a blend of code from libgcc and AVR-LibC.
23511For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23512@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23513
23514@item
23515It is legitimate for user-specific startup code to set up @code{EIND}
23516early, for example by means of initialization code located in
23517section @code{.init3}. Such code runs prior to general startup code
23518that initializes RAM and calls constructors, but after the bit
23519of startup code from AVR-LibC that sets @code{EIND} to the segment
23520where the vector table is located.
23521@example
23522#include <avr/io.h>
23523
23524static void
23525__attribute__((section(".init3"),naked,used,no_instrument_function))
23526init3_set_eind (void)
23527@{
23528 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
23529 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
23530@}
23531@end example
23532
23533@noindent
23534The @code{__trampolines_start} symbol is defined in the linker script.
23535
23536@item
23537Stubs are generated automatically by the linker if
23538the following two conditions are met:
23539@itemize @minus
23540
23541@item The address of a label is taken by means of the @code{gs} modifier
23542(short for @emph{generate stubs}) like so:
23543@example
23544LDI r24, lo8(gs(@var{func}))
23545LDI r25, hi8(gs(@var{func}))
23546@end example
23547@item The final location of that label is in a code segment
23548@emph{outside} the segment where the stubs are located.
23549@end itemize
23550
23551@item
23552The compiler emits such @code{gs} modifiers for code labels in the
23553following situations:
23554@itemize @minus
23555@item Taking address of a function or code label.
23556@item Computed goto.
23557@item If prologue-save function is used, see @option{-mcall-prologues}
23558command-line option.
23559@item Switch/case dispatch tables. If you do not want such dispatch
23560tables you can specify the @option{-fno-jump-tables} command-line option.
23561@item C and C++ constructors/destructors called during startup/shutdown.
23562@item If the tools hit a @code{gs()} modifier explained above.
23563@end itemize
23564
23565@item
23566Jumping to non-symbolic addresses like so is @emph{not} supported:
23567
23568@example
23569int main (void)
23570@{
23571 /* Call function at word address 0x2 */
23572 return ((int(*)(void)) 0x2)();
23573@}
23574@end example
23575
23576Instead, a stub has to be set up, i.e.@: the function has to be called
23577through a symbol (@code{func_4} in the example):
23578
23579@example
23580int main (void)
23581@{
23582 extern int func_4 (void);
23583
23584 /* Call function at byte address 0x4 */
23585 return func_4();
23586@}
23587@end example
23588
23589and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23590Alternatively, @code{func_4} can be defined in the linker script.
23591@end itemize
23592
23593@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23594@cindex @code{RAMPD}
23595@cindex @code{RAMPX}
23596@cindex @code{RAMPY}
23597@cindex @code{RAMPZ}
23598Some AVR devices support memories larger than the 64@tie{}KiB range
23599that can be accessed with 16-bit pointers. To access memory locations
23600outside this 64@tie{}KiB range, the content of a @code{RAMP}
23601register is used as high part of the address:
23602The @code{X}, @code{Y}, @code{Z} address register is concatenated
23603with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23604register, respectively, to get a wide address. Similarly,
23605@code{RAMPD} is used together with direct addressing.
23606
23607@itemize
23608@item
23609The startup code initializes the @code{RAMP} special function
23610registers with zero.
23611
23612@item
23613If a @ref{AVR Named Address Spaces,named address space} other than
23614generic or @code{__flash} is used, then @code{RAMPZ} is set
23615as needed before the operation.
23616
23617@item
23618If the device supports RAM larger than 64@tie{}KiB and the compiler
23619needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23620is reset to zero after the operation.
23621
23622@item
23623If the device comes with a specific @code{RAMP} register, the ISR
23624prologue/epilogue saves/restores that SFR and initializes it with
23625zero in case the ISR code might (implicitly) use it.
23626
23627@item
23628RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23629If you use inline assembler to read from locations outside the
2363016-bit address range and change one of the @code{RAMP} registers,
23631you must reset it to zero after the access.
23632
23633@end itemize
23634
23635@subsubsection AVR Built-in Macros
23636
23637GCC defines several built-in macros so that the user code can test
23638for the presence or absence of features. Almost any of the following
23639built-in macros are deduced from device capabilities and thus
23640triggered by the @option{-mmcu=} command-line option.
23641
23642For even more AVR-specific built-in macros see
23643@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23644
23645@table @code
23646
23647@item __AVR_ARCH__
23648Build-in macro that resolves to a decimal number that identifies the
23649architecture and depends on the @option{-mmcu=@var{mcu}} option.
23650Possible values are:
23651
23652@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23653@code{4}, @code{5}, @code{51}, @code{6}
23654
23655for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23656@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23657
23658respectively and
23659
23660@code{100},
23661@code{102}, @code{103}, @code{104},
23662@code{105}, @code{106}, @code{107}
23663
23664for @var{mcu}=@code{avrtiny},
23665@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23666@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23667If @var{mcu} specifies a device, this built-in macro is set
23668accordingly. For example, with @option{-mmcu=atmega8} the macro is
23669defined to @code{4}.
23670
23671@item __AVR_@var{Device}__
23672Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23673the device's name. For example, @option{-mmcu=atmega8} defines the
23674built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23675@code{__AVR_ATtiny261A__}, etc.
23676
23677The built-in macros' names follow
23678the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23679the device name as from the AVR user manual. The difference between
23680@var{Device} in the built-in macro and @var{device} in
23681@option{-mmcu=@var{device}} is that the latter is always lowercase.
23682
23683If @var{device} is not a device but only a core architecture like
23684@samp{avr51}, this macro is not defined.
23685
23686@item __AVR_DEVICE_NAME__
23687Setting @option{-mmcu=@var{device}} defines this built-in macro to
23688the device's name. For example, with @option{-mmcu=atmega8} the macro
23689is defined to @code{atmega8}.
23690
23691If @var{device} is not a device but only a core architecture like
23692@samp{avr51}, this macro is not defined.
23693
23694@item __AVR_XMEGA__
23695The device / architecture belongs to the XMEGA family of devices.
23696
23697@item __AVR_HAVE_ELPM__
23698The device has the @code{ELPM} instruction.
23699
23700@item __AVR_HAVE_ELPMX__
23701The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23702R@var{n},Z+} instructions.
23703
23704@item __AVR_HAVE_MOVW__
23705The device has the @code{MOVW} instruction to perform 16-bit
23706register-register moves.
23707
23708@item __AVR_HAVE_LPMX__
23709The device has the @code{LPM R@var{n},Z} and
23710@code{LPM R@var{n},Z+} instructions.
23711
23712@item __AVR_HAVE_MUL__
23713The device has a hardware multiplier.
23714
23715@item __AVR_HAVE_JMP_CALL__
23716The device has the @code{JMP} and @code{CALL} instructions.
23717This is the case for devices with more than 8@tie{}KiB of program
23718memory.
23719
23720@item __AVR_HAVE_EIJMP_EICALL__
23721@itemx __AVR_3_BYTE_PC__
23722The device has the @code{EIJMP} and @code{EICALL} instructions.
23723This is the case for devices with more than 128@tie{}KiB of program memory.
23724This also means that the program counter
23725(PC) is 3@tie{}bytes wide.
23726
23727@item __AVR_2_BYTE_PC__
23728The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23729with up to 128@tie{}KiB of program memory.
23730
23731@item __AVR_HAVE_8BIT_SP__
23732@itemx __AVR_HAVE_16BIT_SP__
23733The stack pointer (SP) register is treated as 8-bit respectively
2373416-bit register by the compiler.
23735The definition of these macros is affected by @option{-mtiny-stack}.
23736
23737@item __AVR_HAVE_SPH__
23738@itemx __AVR_SP8__
23739The device has the SPH (high part of stack pointer) special function
23740register or has an 8-bit stack pointer, respectively.
23741The definition of these macros is affected by @option{-mmcu=} and
23742in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23743by @option{-msp8}.
23744
23745@item __AVR_HAVE_RAMPD__
23746@itemx __AVR_HAVE_RAMPX__
23747@itemx __AVR_HAVE_RAMPY__
23748@itemx __AVR_HAVE_RAMPZ__
23749The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23750@code{RAMPZ} special function register, respectively.
23751
23752@item __NO_INTERRUPTS__
23753This macro reflects the @option{-mno-interrupts} command-line option.
23754
23755@item __AVR_ERRATA_SKIP__
23756@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23757Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23758instructions because of a hardware erratum. Skip instructions are
23759@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23760The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23761set.
23762
23763@item __AVR_ISA_RMW__
23764The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23765
23766@item __AVR_SFR_OFFSET__=@var{offset}
23767Instructions that can address I/O special function registers directly
23768like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23769address as if addressed by an instruction to access RAM like @code{LD}
23770or @code{STS}. This offset depends on the device architecture and has
23771to be subtracted from the RAM address in order to get the
23772respective I/O@tie{}address.
23773
23774@item __AVR_SHORT_CALLS__
23775The @option{-mshort-calls} command line option is set.
23776
23777@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23778Some devices support reading from flash memory by means of @code{LD*}
23779instructions. The flash memory is seen in the data address space
23780at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23781is not defined, this feature is not available. If defined,
23782the address space is linear and there is no need to put
23783@code{.rodata} into RAM. This is handled by the default linker
23784description file, and is currently available for
23785@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23786there is no need to use address spaces like @code{__flash} or
23787features like attribute @code{progmem} and @code{pgm_read_*}.
23788
23789@item __WITH_AVRLIBC__
23790The compiler is configured to be used together with AVR-Libc.
23791See the @option{--with-avrlibc} configure option.
23792
23793@item __HAVE_DOUBLE_MULTILIB__
23794Defined if @option{-mdouble=} acts as a multilib option.
23795
23796@item __HAVE_DOUBLE32__
23797@itemx __HAVE_DOUBLE64__
23798Defined if the compiler supports 32-bit double resp. 64-bit double.
23799The actual layout is specified by option @option{-mdouble=}.
23800
23801@item __DEFAULT_DOUBLE__
23802The size in bits of @code{double} if @option{-mdouble=} is not set.
23803To test the layout of @code{double} in a program, use the built-in
23804macro @code{__SIZEOF_DOUBLE__}.
23805
23806@item __HAVE_LONG_DOUBLE32__
23807@itemx __HAVE_LONG_DOUBLE64__
23808@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23809@itemx __DEFAULT_LONG_DOUBLE__
23810Same as above, but for @code{long double} instead of @code{double}.
23811
23812@item __WITH_DOUBLE_COMPARISON__
23813Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23814@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23815and is defined to @code{2} or @code{3}.
23816
23817@item __WITH_LIBF7_LIBGCC__
23818@itemx __WITH_LIBF7_MATH__
23819@itemx __WITH_LIBF7_MATH_SYMBOLS__
23820Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23821@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23822
23823@end table
23824
23825@node Blackfin Options
23826@subsection Blackfin Options
23827@cindex Blackfin Options
23828
23829@table @gcctabopt
d77de738 23830@opindex mcpu=
ddf6fe37 23831@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23832Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23833can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23834@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23835@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23836@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23837@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23838@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23839@samp{bf561}, @samp{bf592}.
23840
23841The optional @var{sirevision} specifies the silicon revision of the target
23842Blackfin processor. Any workarounds available for the targeted silicon revision
23843are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23844If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23845are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23846hexadecimal digits representing the major and minor numbers in the silicon
23847revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23848is not defined. If @var{sirevision} is @samp{any}, the
23849@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23850If this optional @var{sirevision} is not used, GCC assumes the latest known
23851silicon revision of the targeted Blackfin processor.
23852
23853GCC defines a preprocessor macro for the specified @var{cpu}.
23854For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23855provided by libgloss to be linked in if @option{-msim} is not given.
23856
23857Without this option, @samp{bf532} is used as the processor by default.
23858
23859Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23860only the preprocessor macro is defined.
23861
d77de738 23862@opindex msim
ddf6fe37 23863@item -msim
d77de738
ML
23864Specifies that the program will be run on the simulator. This causes
23865the simulator BSP provided by libgloss to be linked in. This option
23866has effect only for @samp{bfin-elf} toolchain.
23867Certain other options, such as @option{-mid-shared-library} and
23868@option{-mfdpic}, imply @option{-msim}.
23869
d77de738 23870@opindex momit-leaf-frame-pointer
ddf6fe37 23871@item -momit-leaf-frame-pointer
d77de738
ML
23872Don't keep the frame pointer in a register for leaf functions. This
23873avoids the instructions to save, set up and restore frame pointers and
23874makes an extra register available in leaf functions.
23875
d77de738 23876@opindex mspecld-anomaly
ddf6fe37 23877@item -mspecld-anomaly
d77de738
ML
23878When enabled, the compiler ensures that the generated code does not
23879contain speculative loads after jump instructions. If this option is used,
23880@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23881
d77de738
ML
23882@opindex mno-specld-anomaly
23883@opindex mspecld-anomaly
ddf6fe37 23884@item -mno-specld-anomaly
d77de738
ML
23885Don't generate extra code to prevent speculative loads from occurring.
23886
d77de738 23887@opindex mcsync-anomaly
ddf6fe37 23888@item -mcsync-anomaly
d77de738
ML
23889When enabled, the compiler ensures that the generated code does not
23890contain CSYNC or SSYNC instructions too soon after conditional branches.
23891If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23892
d77de738
ML
23893@opindex mno-csync-anomaly
23894@opindex mcsync-anomaly
ddf6fe37 23895@item -mno-csync-anomaly
d77de738
ML
23896Don't generate extra code to prevent CSYNC or SSYNC instructions from
23897occurring too soon after a conditional branch.
23898
d77de738 23899@opindex mlow64k
ddf6fe37 23900@item -mlow64k
d77de738
ML
23901When enabled, the compiler is free to take advantage of the knowledge that
23902the entire program fits into the low 64k of memory.
23903
d77de738 23904@opindex mno-low64k
ddf6fe37 23905@item -mno-low64k
d77de738
ML
23906Assume that the program is arbitrarily large. This is the default.
23907
d77de738 23908@opindex mstack-check-l1
ddf6fe37 23909@item -mstack-check-l1
d77de738
ML
23910Do stack checking using information placed into L1 scratchpad memory by the
23911uClinux kernel.
23912
d77de738 23913@opindex mid-shared-library
ddf6fe37 23914@item -mid-shared-library
d77de738
ML
23915Generate code that supports shared libraries via the library ID method.
23916This allows for execute in place and shared libraries in an environment
23917without virtual memory management. This option implies @option{-fPIC}.
23918With a @samp{bfin-elf} target, this option implies @option{-msim}.
23919
d77de738
ML
23920@opindex mno-id-shared-library
23921@opindex mid-shared-library
ddf6fe37 23922@item -mno-id-shared-library
d77de738
ML
23923Generate code that doesn't assume ID-based shared libraries are being used.
23924This is the default.
23925
d77de738 23926@opindex mleaf-id-shared-library
ddf6fe37 23927@item -mleaf-id-shared-library
d77de738
ML
23928Generate code that supports shared libraries via the library ID method,
23929but assumes that this library or executable won't link against any other
23930ID shared libraries. That allows the compiler to use faster code for jumps
23931and calls.
23932
d77de738
ML
23933@opindex mno-leaf-id-shared-library
23934@opindex mleaf-id-shared-library
ddf6fe37 23935@item -mno-leaf-id-shared-library
d77de738
ML
23936Do not assume that the code being compiled won't link against any ID shared
23937libraries. Slower code is generated for jump and call insns.
23938
d77de738 23939@opindex mshared-library-id
ddf6fe37 23940@item -mshared-library-id=n
d77de738
ML
23941Specifies the identification number of the ID-based shared library being
23942compiled. Specifying a value of 0 generates more compact code; specifying
23943other values forces the allocation of that number to the current
23944library but is no more space- or time-efficient than omitting this option.
23945
d77de738 23946@opindex msep-data
ddf6fe37 23947@item -msep-data
d77de738
ML
23948Generate code that allows the data segment to be located in a different
23949area of memory from the text segment. This allows for execute in place in
23950an environment without virtual memory management by eliminating relocations
23951against the text section.
23952
d77de738
ML
23953@opindex mno-sep-data
23954@opindex msep-data
ddf6fe37 23955@item -mno-sep-data
d77de738
ML
23956Generate code that assumes that the data segment follows the text segment.
23957This is the default.
23958
d77de738
ML
23959@opindex mlong-calls
23960@opindex mno-long-calls
ddf6fe37
AA
23961@item -mlong-calls
23962@itemx -mno-long-calls
d77de738
ML
23963Tells the compiler to perform function calls by first loading the
23964address of the function into a register and then performing a subroutine
23965call on this register. This switch is needed if the target function
23966lies outside of the 24-bit addressing range of the offset-based
23967version of subroutine call instruction.
23968
23969This feature is not enabled by default. Specifying
23970@option{-mno-long-calls} restores the default behavior. Note these
23971switches have no effect on how the compiler generates code to handle
23972function calls via function pointers.
23973
d77de738 23974@opindex mfast-fp
ddf6fe37 23975@item -mfast-fp
d77de738
ML
23976Link with the fast floating-point library. This library relaxes some of
23977the IEEE floating-point standard's rules for checking inputs against
23978Not-a-Number (NAN), in the interest of performance.
23979
d77de738 23980@opindex minline-plt
ddf6fe37 23981@item -minline-plt
d77de738
ML
23982Enable inlining of PLT entries in function calls to functions that are
23983not known to bind locally. It has no effect without @option{-mfdpic}.
23984
d77de738 23985@opindex mmulticore
ddf6fe37 23986@item -mmulticore
d77de738
ML
23987Build a standalone application for multicore Blackfin processors.
23988This option causes proper start files and link scripts supporting
23989multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23990It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23991
23992This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23993selects the one-application-per-core programming model. Without
23994@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23995programming model is used. In this model, the main function of Core B
23996should be named as @code{coreb_main}.
23997
23998If this option is not used, the single-core application programming
23999model is used.
24000
d77de738 24001@opindex mcorea
ddf6fe37 24002@item -mcorea
d77de738
ML
24003Build a standalone application for Core A of BF561 when using
24004the one-application-per-core programming model. Proper start files
24005and link scripts are used to support Core A, and the macro
24006@code{__BFIN_COREA} is defined.
24007This option can only be used in conjunction with @option{-mmulticore}.
24008
d77de738 24009@opindex mcoreb
ddf6fe37 24010@item -mcoreb
d77de738
ML
24011Build a standalone application for Core B of BF561 when using
24012the one-application-per-core programming model. Proper start files
24013and link scripts are used to support Core B, and the macro
24014@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
24015should be used instead of @code{main}.
24016This option can only be used in conjunction with @option{-mmulticore}.
24017
d77de738 24018@opindex msdram
ddf6fe37 24019@item -msdram
d77de738
ML
24020Build a standalone application for SDRAM. Proper start files and
24021link scripts are used to put the application into SDRAM, and the macro
24022@code{__BFIN_SDRAM} is defined.
24023The loader should initialize SDRAM before loading the application.
24024
d77de738 24025@opindex micplb
ddf6fe37 24026@item -micplb
d77de738
ML
24027Assume that ICPLBs are enabled at run time. This has an effect on certain
24028anomaly workarounds. For Linux targets, the default is to assume ICPLBs
24029are enabled; for standalone applications the default is off.
24030@end table
24031
24032@node C6X Options
24033@subsection C6X Options
24034@cindex C6X Options
24035
24036@table @gcctabopt
d77de738 24037@opindex march
ddf6fe37 24038@item -march=@var{name}
d77de738
ML
24039This specifies the name of the target architecture. GCC uses this
24040name to determine what kind of instructions it can emit when generating
24041assembly code. Permissible names are: @samp{c62x},
24042@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
24043
d77de738 24044@opindex mbig-endian
ddf6fe37 24045@item -mbig-endian
d77de738
ML
24046Generate code for a big-endian target.
24047
d77de738 24048@opindex mlittle-endian
ddf6fe37 24049@item -mlittle-endian
d77de738
ML
24050Generate code for a little-endian target. This is the default.
24051
d77de738 24052@opindex msim
ddf6fe37 24053@item -msim
d77de738
ML
24054Choose startup files and linker script suitable for the simulator.
24055
d77de738 24056@opindex msdata=default
ddf6fe37 24057@item -msdata=default
d77de738
ML
24058Put small global and static data in the @code{.neardata} section,
24059which is pointed to by register @code{B14}. Put small uninitialized
24060global and static data in the @code{.bss} section, which is adjacent
24061to the @code{.neardata} section. Put small read-only data into the
24062@code{.rodata} section. The corresponding sections used for large
24063pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
24064
d77de738 24065@opindex msdata=all
ddf6fe37 24066@item -msdata=all
d77de738
ML
24067Put all data, not just small objects, into the sections reserved for
24068small data, and use addressing relative to the @code{B14} register to
24069access them.
24070
d77de738 24071@opindex msdata=none
ddf6fe37 24072@item -msdata=none
d77de738
ML
24073Make no use of the sections reserved for small data, and use absolute
24074addresses to access all data. Put all initialized global and static
24075data in the @code{.fardata} section, and all uninitialized data in the
24076@code{.far} section. Put all constant data into the @code{.const}
24077section.
24078@end table
24079
24080@node CRIS Options
24081@subsection CRIS Options
24082@cindex CRIS Options
24083
24084These options are defined specifically for the CRIS ports.
24085
24086@table @gcctabopt
d77de738
ML
24087@opindex march
24088@opindex mcpu
ddf6fe37
AA
24089@item -march=@var{architecture-type}
24090@itemx -mcpu=@var{architecture-type}
d77de738
ML
24091Generate code for the specified architecture. The choices for
24092@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
24093respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
24094Default is @samp{v0}.
24095
d77de738 24096@opindex mtune
ddf6fe37 24097@item -mtune=@var{architecture-type}
d77de738
ML
24098Tune to @var{architecture-type} everything applicable about the generated
24099code, except for the ABI and the set of available instructions. The
24100choices for @var{architecture-type} are the same as for
24101@option{-march=@var{architecture-type}}.
24102
d77de738 24103@opindex mmax-stack-frame
ddf6fe37 24104@item -mmax-stack-frame=@var{n}
d77de738
ML
24105Warn when the stack frame of a function exceeds @var{n} bytes.
24106
d77de738
ML
24107@opindex metrax4
24108@opindex metrax100
ddf6fe37
AA
24109@item -metrax4
24110@itemx -metrax100
d77de738
ML
24111The options @option{-metrax4} and @option{-metrax100} are synonyms for
24112@option{-march=v3} and @option{-march=v8} respectively.
24113
d77de738
ML
24114@opindex mmul-bug-workaround
24115@opindex mno-mul-bug-workaround
ddf6fe37
AA
24116@item -mmul-bug-workaround
24117@itemx -mno-mul-bug-workaround
d77de738
ML
24118Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
24119models where it applies. This option is disabled by default.
24120
d77de738 24121@opindex mpdebug
ddf6fe37 24122@item -mpdebug
d77de738
ML
24123Enable CRIS-specific verbose debug-related information in the assembly
24124code. This option also has the effect of turning off the @samp{#NO_APP}
24125formatted-code indicator to the assembler at the beginning of the
24126assembly file.
24127
d77de738 24128@opindex mcc-init
ddf6fe37 24129@item -mcc-init
d77de738
ML
24130Do not use condition-code results from previous instruction; always emit
24131compare and test instructions before use of condition codes.
24132
d77de738
ML
24133@opindex mno-side-effects
24134@opindex mside-effects
ddf6fe37 24135@item -mno-side-effects
d77de738
ML
24136Do not emit instructions with side effects in addressing modes other than
24137post-increment.
24138
d77de738
ML
24139@opindex mstack-align
24140@opindex mno-stack-align
24141@opindex mdata-align
24142@opindex mno-data-align
24143@opindex mconst-align
24144@opindex mno-const-align
ddf6fe37
AA
24145@item -mstack-align
24146@itemx -mno-stack-align
24147@itemx -mdata-align
24148@itemx -mno-data-align
24149@itemx -mconst-align
24150@itemx -mno-const-align
d77de738
ML
24151These options (@samp{no-} options) arrange (eliminate arrangements) for the
24152stack frame, individual data and constants to be aligned for the maximum
24153single data access size for the chosen CPU model. The default is to
24154arrange for 32-bit alignment. ABI details such as structure layout are
24155not affected by these options.
24156
d77de738
ML
24157@opindex m32-bit
24158@opindex m16-bit
24159@opindex m8-bit
ddf6fe37
AA
24160@item -m32-bit
24161@itemx -m16-bit
24162@itemx -m8-bit
d77de738
ML
24163Similar to the stack- data- and const-align options above, these options
24164arrange for stack frame, writable data and constants to all be 32-bit,
2416516-bit or 8-bit aligned. The default is 32-bit alignment.
24166
d77de738
ML
24167@opindex mno-prologue-epilogue
24168@opindex mprologue-epilogue
ddf6fe37
AA
24169@item -mno-prologue-epilogue
24170@itemx -mprologue-epilogue
d77de738
ML
24171With @option{-mno-prologue-epilogue}, the normal function prologue and
24172epilogue which set up the stack frame are omitted and no return
24173instructions or return sequences are generated in the code. Use this
24174option only together with visual inspection of the compiled code: no
24175warnings or errors are generated when call-saved registers must be saved,
24176or storage for local variables needs to be allocated.
24177
d77de738 24178@opindex melf
ddf6fe37 24179@item -melf
d77de738
ML
24180Legacy no-op option.
24181
d77de738 24182@opindex sim
ddf6fe37 24183@item -sim
d77de738
ML
24184This option arranges
24185to link with input-output functions from a simulator library. Code,
24186initialized data and zero-initialized data are allocated consecutively.
24187
d77de738 24188@opindex sim2
ddf6fe37 24189@item -sim2
d77de738
ML
24190Like @option{-sim}, but pass linker options to locate initialized data at
241910x40000000 and zero-initialized data at 0x80000000.
24192@end table
24193
24194@node C-SKY Options
24195@subsection C-SKY Options
24196@cindex C-SKY Options
24197
24198GCC supports these options when compiling for C-SKY V2 processors.
24199
24200@table @gcctabopt
24201
d77de738 24202@opindex march=
ddf6fe37 24203@item -march=@var{arch}
d77de738
ML
24204Specify the C-SKY target architecture. Valid values for @var{arch} are:
24205@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
24206The default is @samp{ck810}.
24207
d77de738 24208@opindex mcpu=
ddf6fe37 24209@item -mcpu=@var{cpu}
d77de738
ML
24210Specify the C-SKY target processor. Valid values for @var{cpu} are:
24211@samp{ck801}, @samp{ck801t},
24212@samp{ck802}, @samp{ck802t}, @samp{ck802j},
24213@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
24214@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
24215@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
24216@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
24217@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
24218@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
24219@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
24220@samp{ck803eftr1}, @samp{ck803efhtr1},
24221@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
24222@samp{ck803sef}, @samp{ck803seft},
24223@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
24224@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
24225@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
24226@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
24227
d77de738 24228@opindex mbig-endian
d77de738 24229@opindex EB
d77de738 24230@opindex mlittle-endian
d77de738 24231@opindex EL
ddf6fe37
AA
24232@item -mbig-endian
24233@itemx -EB
24234@itemx -mlittle-endian
24235@itemx -EL
d77de738
ML
24236
24237Select big- or little-endian code. The default is little-endian.
24238
d77de738 24239@opindex mfloat-abi
ddf6fe37 24240@item -mfloat-abi=@var{name}
d77de738
ML
24241Specifies which floating-point ABI to use. Permissible values
24242are: @samp{soft}, @samp{softfp} and @samp{hard}.
24243
24244Specifying @samp{soft} causes GCC to generate output containing
24245library calls for floating-point operations.
24246@samp{softfp} allows the generation of code using hardware floating-point
24247instructions, but still uses the soft-float calling conventions.
24248@samp{hard} allows generation of floating-point instructions
24249and uses FPU-specific calling conventions.
24250
24251The default depends on the specific target configuration. Note that
24252the hard-float and soft-float ABIs are not link-compatible; you must
24253compile your entire program with the same ABI, and link with a
24254compatible set of libraries.
24255
d77de738 24256@opindex mhard-float
d77de738 24257@opindex msoft-float
ddf6fe37
AA
24258@item -mhard-float
24259@itemx -msoft-float
d77de738
ML
24260
24261Select hardware or software floating-point implementations.
24262The default is soft float.
24263
ddf6fe37 24264@opindex mdouble-float
d77de738
ML
24265@item -mdouble-float
24266@itemx -mno-double-float
d77de738
ML
24267When @option{-mhard-float} is in effect, enable generation of
24268double-precision float instructions. This is the default except
24269when compiling for CK803.
24270
ddf6fe37 24271@opindex mfdivdu
d77de738
ML
24272@item -mfdivdu
24273@itemx -mno-fdivdu
d77de738
ML
24274When @option{-mhard-float} is in effect, enable generation of
24275@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
24276This is the default except when compiling for CK803.
24277
d77de738 24278@opindex mfpu=
ddf6fe37 24279@item -mfpu=@var{fpu}
d77de738
ML
24280Select the floating-point processor. This option can only be used with
24281@option{-mhard-float}.
24282Values for @var{fpu} are
24283@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
24284@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
24285@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
24286
ddf6fe37 24287@opindex melrw
d77de738
ML
24288@item -melrw
24289@itemx -mno-elrw
d77de738
ML
24290Enable the extended @code{lrw} instruction. This option defaults to on
24291for CK801 and off otherwise.
24292
ddf6fe37 24293@opindex mistack
d77de738
ML
24294@item -mistack
24295@itemx -mno-istack
d77de738
ML
24296Enable interrupt stack instructions; the default is off.
24297
24298The @option{-mistack} option is required to handle the
24299@code{interrupt} and @code{isr} function attributes
24300(@pxref{C-SKY Function Attributes}).
24301
d77de738 24302@opindex mmp
ddf6fe37 24303@item -mmp
d77de738
ML
24304Enable multiprocessor instructions; the default is off.
24305
d77de738 24306@opindex mcp
ddf6fe37 24307@item -mcp
d77de738
ML
24308Enable coprocessor instructions; the default is off.
24309
d77de738 24310@opindex mcache
ddf6fe37 24311@item -mcache
d77de738
ML
24312Enable coprocessor instructions; the default is off.
24313
d77de738 24314@opindex msecurity
ddf6fe37 24315@item -msecurity
d77de738
ML
24316Enable C-SKY security instructions; the default is off.
24317
d77de738 24318@opindex mtrust
ddf6fe37 24319@item -mtrust
d77de738
ML
24320Enable C-SKY trust instructions; the default is off.
24321
d77de738 24322@opindex mdsp
d77de738 24323@opindex medsp
d77de738 24324@opindex mvdsp
ddf6fe37
AA
24325@item -mdsp
24326@itemx -medsp
24327@itemx -mvdsp
d77de738
ML
24328Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
24329All of these options default to off.
24330
ddf6fe37 24331@opindex mdiv
d77de738
ML
24332@item -mdiv
24333@itemx -mno-div
d77de738
ML
24334Generate divide instructions. Default is off.
24335
ddf6fe37 24336@opindex msmart
d77de738
ML
24337@item -msmart
24338@itemx -mno-smart
d77de738
ML
24339Generate code for Smart Mode, using only registers numbered 0-7 to allow
24340use of 16-bit instructions. This option is ignored for CK801 where this
24341is the required behavior, and it defaults to on for CK802.
24342For other targets, the default is off.
24343
ddf6fe37 24344@opindex mhigh-registers
d77de738
ML
24345@item -mhigh-registers
24346@itemx -mno-high-registers
d77de738
ML
24347Generate code using the high registers numbered 16-31. This option
24348is not supported on CK801, CK802, or CK803, and is enabled by default
24349for other processors.
24350
ddf6fe37 24351@opindex manchor
d77de738
ML
24352@item -manchor
24353@itemx -mno-anchor
d77de738
ML
24354Generate code using global anchor symbol addresses.
24355
ddf6fe37 24356@opindex mpushpop
d77de738
ML
24357@item -mpushpop
24358@itemx -mno-pushpop
d77de738
ML
24359Generate code using @code{push} and @code{pop} instructions. This option
24360defaults to on.
24361
ddf6fe37 24362@opindex mmultiple-stld
d77de738
ML
24363@item -mmultiple-stld
24364@itemx -mstm
24365@itemx -mno-multiple-stld
24366@itemx -mno-stm
d77de738
ML
24367Generate code using @code{stm} and @code{ldm} instructions. This option
24368isn't supported on CK801 but is enabled by default on other processors.
24369
ddf6fe37 24370@opindex mconstpool
d77de738
ML
24371@item -mconstpool
24372@itemx -mno-constpool
d77de738
ML
24373Create constant pools in the compiler instead of deferring it to the
24374assembler. This option is the default and required for correct code
24375generation on CK801 and CK802, and is optional on other processors.
24376
ddf6fe37 24377@opindex mstack-size
d77de738
ML
24378@item -mstack-size
24379@item -mno-stack-size
d77de738
ML
24380Emit @code{.stack_size} directives for each function in the assembly
24381output. This option defaults to off.
24382
ddf6fe37 24383@opindex mccrt
d77de738
ML
24384@item -mccrt
24385@itemx -mno-ccrt
d77de738
ML
24386Generate code for the C-SKY compiler runtime instead of libgcc. This
24387option defaults to off.
24388
d77de738 24389@opindex mbranch-cost=
ddf6fe37 24390@item -mbranch-cost=@var{n}
d77de738
ML
24391Set the branch costs to roughly @code{n} instructions. The default is 1.
24392
ddf6fe37 24393@opindex msched-prolog
d77de738
ML
24394@item -msched-prolog
24395@itemx -mno-sched-prolog
d77de738
ML
24396Permit scheduling of function prologue and epilogue sequences. Using
24397this option can result in code that is not compliant with the C-SKY V2 ABI
24398prologue requirements and that cannot be debugged or backtraced.
24399It is disabled by default.
24400
d77de738 24401@opindex msim
ddf6fe37 24402@item -msim
d77de738
ML
24403Links the library libsemi.a which is in compatible with simulator. Applicable
24404to ELF compiler only.
24405
24406@end table
24407
24408@node Darwin Options
24409@subsection Darwin Options
24410@cindex Darwin options
24411
24412These options are defined for all architectures running the Darwin operating
24413system.
24414
24415FSF GCC on Darwin does not create ``fat'' object files; it creates
24416an object file for the single architecture that GCC was built to
24417target. Apple's GCC on Darwin does create ``fat'' files if multiple
24418@option{-arch} options are used; it does so by running the compiler or
24419linker multiple times and joining the results together with
24420@file{lipo}.
24421
24422The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
24423@samp{i686}) is determined by the flags that specify the ISA
24424that GCC is targeting, like @option{-mcpu} or @option{-march}. The
24425@option{-force_cpusubtype_ALL} option can be used to override this.
24426
24427The Darwin tools vary in their behavior when presented with an ISA
24428mismatch. The assembler, @file{as}, only permits instructions to
24429be used that are valid for the subtype of the file it is generating,
24430so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24431The linker for shared libraries, @file{/usr/bin/libtool}, fails
24432and prints an error if asked to create a shared library with a less
24433restrictive subtype than its input files (for instance, trying to put
24434a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24435for executables, @command{ld}, quietly gives the executable the most
24436restrictive subtype of any of its input files.
24437
24438@table @gcctabopt
d77de738 24439@opindex F
ddf6fe37 24440@item -F@var{dir}
d77de738
ML
24441Add the framework directory @var{dir} to the head of the list of
24442directories to be searched for header files. These directories are
24443interleaved with those specified by @option{-I} options and are
24444scanned in a left-to-right order.
24445
24446A framework directory is a directory with frameworks in it. A
24447framework is a directory with a @file{Headers} and/or
24448@file{PrivateHeaders} directory contained directly in it that ends
24449in @file{.framework}. The name of a framework is the name of this
24450directory excluding the @file{.framework}. Headers associated with
24451the framework are found in one of those two directories, with
24452@file{Headers} being searched first. A subframework is a framework
24453directory that is in a framework's @file{Frameworks} directory.
24454Includes of subframework headers can only appear in a header of a
24455framework that contains the subframework, or in a sibling subframework
24456header. Two subframeworks are siblings if they occur in the same
24457framework. A subframework should not have the same name as a
24458framework; a warning is issued if this is violated. Currently a
24459subframework cannot have subframeworks; in the future, the mechanism
24460may be extended to support this. The standard frameworks can be found
24461in @file{/System/Library/Frameworks} and
24462@file{/Library/Frameworks}. An example include looks like
24463@code{#include <Framework/header.h>}, where @file{Framework} denotes
24464the name of the framework and @file{header.h} is found in the
24465@file{PrivateHeaders} or @file{Headers} directory.
24466
d77de738 24467@opindex iframework
ddf6fe37 24468@item -iframework@var{dir}
d77de738
ML
24469Like @option{-F} except the directory is a treated as a system
24470directory. The main difference between this @option{-iframework} and
24471@option{-F} is that with @option{-iframework} the compiler does not
24472warn about constructs contained within header files found via
24473@var{dir}. This option is valid only for the C family of languages.
24474
d77de738 24475@opindex gused
ddf6fe37 24476@item -gused
d77de738
ML
24477Emit debugging information for symbols that are used. For stabs
24478debugging format, this enables @option{-feliminate-unused-debug-symbols}.
24479This is by default ON@.
24480
d77de738 24481@opindex gfull
ddf6fe37 24482@item -gfull
d77de738
ML
24483Emit debugging information for all symbols and types.
24484
cdd4b3c0
IS
24485@opindex fconstant-cfstrings
24486@item -fconstant-cfstrings
24487The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
24488
24489@opindex mconstant-cfstrings
24490@item -mconstant-cfstrings
24491When the NeXT runtime is being used (the default on these systems), override
24492any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
24493literals to be laid out as constant CoreFoundation strings.
24494
24495@opindex mmacosx-version-min
d77de738 24496@item -mmacosx-version-min=@var{version}
cdd4b3c0
IS
24497The earliest version of MacOS X that this executable will run on is
24498@var{version}. Typical values supported for @var{version} include @code{12},
24499@code{10.12}, and @code{10.5.8}.
d77de738
ML
24500
24501If the compiler was built to use the system's headers by default,
24502then the default for this option is the system version on which the
24503compiler is running, otherwise the default is to make choices that
24504are compatible with as many systems and code bases as possible.
24505
d77de738 24506@opindex mkernel
ddf6fe37 24507@item -mkernel
d77de738
ML
24508Enable kernel development mode. The @option{-mkernel} option sets
24509@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
24510@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
24511@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
24512applicable. This mode also sets @option{-mno-altivec},
24513@option{-msoft-float}, @option{-fno-builtin} and
24514@option{-mlong-branch} for PowerPC targets.
24515
d77de738 24516@opindex mone-byte-bool
ddf6fe37 24517@item -mone-byte-bool
d77de738
ML
24518Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
24519By default @code{sizeof(bool)} is @code{4} when compiling for
24520Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
24521option has no effect on x86.
24522
24523@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
24524to generate code that is not binary compatible with code generated
24525without that switch. Using this switch may require recompiling all
24526other modules in a program, including system libraries. Use this
24527switch to conform to a non-default data model.
24528
d77de738
ML
24529@opindex mfix-and-continue
24530@opindex ffix-and-continue
24531@opindex findirect-data
ddf6fe37
AA
24532@item -mfix-and-continue
24533@itemx -ffix-and-continue
24534@itemx -findirect-data
d77de738
ML
24535Generate code suitable for fast turnaround development, such as to
24536allow GDB to dynamically load @file{.o} files into already-running
24537programs. @option{-findirect-data} and @option{-ffix-and-continue}
24538are provided for backwards compatibility.
24539
d77de738 24540@opindex all_load
ddf6fe37 24541@item -all_load
d77de738
ML
24542Loads all members of static archive libraries.
24543See man ld(1) for more information.
24544
d77de738 24545@opindex arch_errors_fatal
ddf6fe37 24546@item -arch_errors_fatal
d77de738
ML
24547Cause the errors having to do with files that have the wrong architecture
24548to be fatal.
24549
d77de738 24550@opindex bind_at_load
ddf6fe37 24551@item -bind_at_load
d77de738
ML
24552Causes the output file to be marked such that the dynamic linker will
24553bind all undefined references when the file is loaded or launched.
24554
d77de738 24555@opindex bundle
ddf6fe37 24556@item -bundle
d77de738
ML
24557Produce a Mach-o bundle format file.
24558See man ld(1) for more information.
24559
d77de738 24560@opindex bundle_loader
ddf6fe37 24561@item -bundle_loader @var{executable}
d77de738
ML
24562This option specifies the @var{executable} that will load the build
24563output file being linked. See man ld(1) for more information.
24564
d77de738 24565@opindex dynamiclib
ddf6fe37 24566@item -dynamiclib
d77de738
ML
24567When passed this option, GCC produces a dynamic library instead of
24568an executable when linking, using the Darwin @file{libtool} command.
24569
d77de738 24570@opindex force_cpusubtype_ALL
ddf6fe37 24571@item -force_cpusubtype_ALL
d77de738
ML
24572This causes GCC's output file to have the @samp{ALL} subtype, instead of
24573one controlled by the @option{-mcpu} or @option{-march} option.
24574
47b634a3
FXC
24575@opindex nodefaultrpaths
24576@item -nodefaultrpaths
24577Do not add default run paths for the compiler library directories to
24578executables, modules or dynamic libraries. On macOS 10.5 and later,
24579the embedded runpath is added by default unless the user adds
24580@option{-nodefaultrpaths} to the link line. Run paths are needed
24581(and therefore enforced) to build on macOS version 10.11 or later.
24582
d77de738
ML
24583@item -allowable_client @var{client_name}
24584@itemx -client_name
24585@itemx -compatibility_version
24586@itemx -current_version
24587@itemx -dead_strip
24588@itemx -dependency-file
24589@itemx -dylib_file
24590@itemx -dylinker_install_name
24591@itemx -dynamic
24592@itemx -exported_symbols_list
24593@itemx -filelist
24594@need 800
24595@itemx -flat_namespace
24596@itemx -force_flat_namespace
24597@itemx -headerpad_max_install_names
24598@itemx -image_base
24599@itemx -init
24600@itemx -install_name
24601@itemx -keep_private_externs
24602@itemx -multi_module
24603@itemx -multiply_defined
24604@itemx -multiply_defined_unused
24605@need 800
24606@itemx -noall_load
24607@itemx -no_dead_strip_inits_and_terms
24608@itemx -nofixprebinding
24609@itemx -nomultidefs
24610@itemx -noprebind
24611@itemx -noseglinkedit
24612@itemx -pagezero_size
24613@itemx -prebind
24614@itemx -prebind_all_twolevel_modules
24615@itemx -private_bundle
24616@need 800
24617@itemx -read_only_relocs
24618@itemx -sectalign
24619@itemx -sectobjectsymbols
24620@itemx -whyload
24621@itemx -seg1addr
24622@itemx -sectcreate
24623@itemx -sectobjectsymbols
24624@itemx -sectorder
24625@itemx -segaddr
24626@itemx -segs_read_only_addr
24627@need 800
24628@itemx -segs_read_write_addr
24629@itemx -seg_addr_table
24630@itemx -seg_addr_table_filename
24631@itemx -seglinkedit
24632@itemx -segprot
24633@itemx -segs_read_only_addr
24634@itemx -segs_read_write_addr
24635@itemx -single_module
24636@itemx -static
24637@itemx -sub_library
24638@need 800
d77de738
ML
24639@opindex allowable_client
24640@opindex client_name
24641@opindex compatibility_version
24642@opindex current_version
24643@opindex dead_strip
24644@opindex dependency-file
24645@opindex dylib_file
24646@opindex dylinker_install_name
24647@opindex dynamic
24648@opindex exported_symbols_list
24649@opindex filelist
24650@opindex flat_namespace
24651@opindex force_flat_namespace
24652@opindex headerpad_max_install_names
24653@opindex image_base
24654@opindex init
24655@opindex install_name
24656@opindex keep_private_externs
24657@opindex multi_module
24658@opindex multiply_defined
24659@opindex multiply_defined_unused
24660@opindex noall_load
24661@opindex no_dead_strip_inits_and_terms
24662@opindex nofixprebinding
24663@opindex nomultidefs
24664@opindex noprebind
24665@opindex noseglinkedit
24666@opindex pagezero_size
24667@opindex prebind
24668@opindex prebind_all_twolevel_modules
24669@opindex private_bundle
24670@opindex read_only_relocs
24671@opindex sectalign
24672@opindex sectobjectsymbols
24673@opindex whyload
24674@opindex seg1addr
24675@opindex sectcreate
24676@opindex sectobjectsymbols
24677@opindex sectorder
24678@opindex segaddr
24679@opindex segs_read_only_addr
24680@opindex segs_read_write_addr
24681@opindex seg_addr_table
24682@opindex seg_addr_table_filename
24683@opindex seglinkedit
24684@opindex segprot
24685@opindex segs_read_only_addr
24686@opindex segs_read_write_addr
24687@opindex single_module
24688@opindex static
24689@opindex sub_library
24690@opindex sub_umbrella
24691@opindex twolevel_namespace
24692@opindex umbrella
24693@opindex undefined
24694@opindex unexported_symbols_list
24695@opindex weak_reference_mismatches
24696@opindex whatsloaded
ddf6fe37
AA
24697@itemx -sub_umbrella
24698@itemx -twolevel_namespace
24699@itemx -umbrella
24700@itemx -undefined
24701@itemx -unexported_symbols_list
24702@itemx -weak_reference_mismatches
24703@itemx -whatsloaded
d77de738
ML
24704These options are passed to the Darwin linker. The Darwin linker man page
24705describes them in detail.
24706@end table
24707
24708@node DEC Alpha Options
24709@subsection DEC Alpha Options
24710
24711These @samp{-m} options are defined for the DEC Alpha implementations:
24712
24713@table @gcctabopt
d77de738
ML
24714@opindex mno-soft-float
24715@opindex msoft-float
ddf6fe37
AA
24716@item -mno-soft-float
24717@itemx -msoft-float
d77de738
ML
24718Use (do not use) the hardware floating-point instructions for
24719floating-point operations. When @option{-msoft-float} is specified,
24720functions in @file{libgcc.a} are used to perform floating-point
24721operations. Unless they are replaced by routines that emulate the
24722floating-point operations, or compiled in such a way as to call such
24723emulations routines, these routines issue floating-point
24724operations. If you are compiling for an Alpha without floating-point
24725operations, you must ensure that the library is built so as not to call
24726them.
24727
24728Note that Alpha implementations without floating-point operations are
24729required to have floating-point registers.
24730
d77de738
ML
24731@opindex mfp-reg
24732@opindex mno-fp-regs
ddf6fe37
AA
24733@item -mfp-reg
24734@itemx -mno-fp-regs
d77de738
ML
24735Generate code that uses (does not use) the floating-point register set.
24736@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24737register set is not used, floating-point operands are passed in integer
24738registers as if they were integers and floating-point results are passed
24739in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24740so any function with a floating-point argument or return value called by code
24741compiled with @option{-mno-fp-regs} must also be compiled with that
24742option.
24743
24744A typical use of this option is building a kernel that does not use,
24745and hence need not save and restore, any floating-point registers.
24746
d77de738 24747@opindex mieee
ddf6fe37 24748@item -mieee
d77de738
ML
24749The Alpha architecture implements floating-point hardware optimized for
24750maximum performance. It is mostly compliant with the IEEE floating-point
24751standard. However, for full compliance, software assistance is
24752required. This option generates code fully IEEE-compliant code
24753@emph{except} that the @var{inexact-flag} is not maintained (see below).
24754If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24755defined during compilation. The resulting code is less efficient but is
24756able to correctly support denormalized numbers and exceptional IEEE
24757values such as not-a-number and plus/minus infinity. Other Alpha
24758compilers call this option @option{-ieee_with_no_inexact}.
24759
d77de738 24760@opindex mieee-with-inexact
ddf6fe37 24761@item -mieee-with-inexact
d77de738
ML
24762This is like @option{-mieee} except the generated code also maintains
24763the IEEE @var{inexact-flag}. Turning on this option causes the
24764generated code to implement fully-compliant IEEE math. In addition to
24765@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24766macro. On some Alpha implementations the resulting code may execute
24767significantly slower than the code generated by default. Since there is
24768very little code that depends on the @var{inexact-flag}, you should
24769normally not specify this option. Other Alpha compilers call this
24770option @option{-ieee_with_inexact}.
24771
d77de738 24772@opindex mfp-trap-mode
ddf6fe37 24773@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24774This option controls what floating-point related traps are enabled.
24775Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24776The trap mode can be set to one of four values:
24777
24778@table @samp
24779@item n
24780This is the default (normal) setting. The only traps that are enabled
24781are the ones that cannot be disabled in software (e.g., division by zero
24782trap).
24783
24784@item u
24785In addition to the traps enabled by @samp{n}, underflow traps are enabled
24786as well.
24787
24788@item su
24789Like @samp{u}, but the instructions are marked to be safe for software
24790completion (see Alpha architecture manual for details).
24791
24792@item sui
24793Like @samp{su}, but inexact traps are enabled as well.
24794@end table
24795
d77de738 24796@opindex mfp-rounding-mode
ddf6fe37 24797@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24798Selects the IEEE rounding mode. Other Alpha compilers call this option
24799@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24800of:
24801
24802@table @samp
24803@item n
24804Normal IEEE rounding mode. Floating-point numbers are rounded towards
24805the nearest machine number or towards the even machine number in case
24806of a tie.
24807
24808@item m
24809Round towards minus infinity.
24810
24811@item c
24812Chopped rounding mode. Floating-point numbers are rounded towards zero.
24813
24814@item d
24815Dynamic rounding mode. A field in the floating-point control register
24816(@var{fpcr}, see Alpha architecture reference manual) controls the
24817rounding mode in effect. The C library initializes this register for
24818rounding towards plus infinity. Thus, unless your program modifies the
24819@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24820@end table
24821
d77de738 24822@opindex mtrap-precision
ddf6fe37 24823@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24824In the Alpha architecture, floating-point traps are imprecise. This
24825means without software assistance it is impossible to recover from a
24826floating trap and program execution normally needs to be terminated.
24827GCC can generate code that can assist operating system trap handlers
24828in determining the exact location that caused a floating-point trap.
24829Depending on the requirements of an application, different levels of
24830precisions can be selected:
24831
24832@table @samp
24833@item p
24834Program precision. This option is the default and means a trap handler
24835can only identify which program caused a floating-point exception.
24836
24837@item f
24838Function precision. The trap handler can determine the function that
24839caused a floating-point exception.
24840
24841@item i
24842Instruction precision. The trap handler can determine the exact
24843instruction that caused a floating-point exception.
24844@end table
24845
24846Other Alpha compilers provide the equivalent options called
24847@option{-scope_safe} and @option{-resumption_safe}.
24848
d77de738 24849@opindex mieee-conformant
ddf6fe37 24850@item -mieee-conformant
d77de738
ML
24851This option marks the generated code as IEEE conformant. You must not
24852use this option unless you also specify @option{-mtrap-precision=i} and either
24853@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24854is to emit the line @samp{.eflag 48} in the function prologue of the
24855generated assembly file.
24856
d77de738 24857@opindex mbuild-constants
ddf6fe37 24858@item -mbuild-constants
d77de738
ML
24859Normally GCC examines a 32- or 64-bit integer constant to
24860see if it can construct it from smaller constants in two or three
24861instructions. If it cannot, it outputs the constant as a literal and
24862generates code to load it from the data segment at run time.
24863
24864Use this option to require GCC to construct @emph{all} integer constants
24865using code, even if it takes more instructions (the maximum is six).
24866
24867You typically use this option to build a shared library dynamic
24868loader. Itself a shared library, it must relocate itself in memory
24869before it can find the variables and constants in its own data segment.
24870
d77de738
ML
24871@opindex mbwx
24872@opindex mno-bwx
24873@opindex mcix
24874@opindex mno-cix
24875@opindex mfix
24876@opindex mno-fix
24877@opindex mmax
24878@opindex mno-max
ddf6fe37
AA
24879@item -mbwx
24880@itemx -mno-bwx
24881@itemx -mcix
24882@itemx -mno-cix
24883@itemx -mfix
24884@itemx -mno-fix
24885@itemx -mmax
24886@itemx -mno-max
d77de738
ML
24887Indicate whether GCC should generate code to use the optional BWX,
24888CIX, FIX and MAX instruction sets. The default is to use the instruction
24889sets supported by the CPU type specified via @option{-mcpu=} option or that
24890of the CPU on which GCC was built if none is specified.
24891
d77de738
ML
24892@opindex mfloat-vax
24893@opindex mfloat-ieee
ddf6fe37
AA
24894@item -mfloat-vax
24895@itemx -mfloat-ieee
d77de738
ML
24896Generate code that uses (does not use) VAX F and G floating-point
24897arithmetic instead of IEEE single and double precision.
24898
d77de738
ML
24899@opindex mexplicit-relocs
24900@opindex mno-explicit-relocs
ddf6fe37
AA
24901@item -mexplicit-relocs
24902@itemx -mno-explicit-relocs
d77de738
ML
24903Older Alpha assemblers provided no way to generate symbol relocations
24904except via assembler macros. Use of these macros does not allow
24905optimal instruction scheduling. GNU binutils as of version 2.12
24906supports a new syntax that allows the compiler to explicitly mark
24907which relocations should apply to which instructions. This option
24908is mostly useful for debugging, as GCC detects the capabilities of
24909the assembler when it is built and sets the default accordingly.
24910
d77de738
ML
24911@opindex msmall-data
24912@opindex mlarge-data
ddf6fe37
AA
24913@item -msmall-data
24914@itemx -mlarge-data
d77de738
ML
24915When @option{-mexplicit-relocs} is in effect, static data is
24916accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24917is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24918(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2491916-bit relocations off of the @code{$gp} register. This limits the
24920size of the small data area to 64KB, but allows the variables to be
24921directly accessed via a single instruction.
24922
24923The default is @option{-mlarge-data}. With this option the data area
24924is limited to just below 2GB@. Programs that require more than 2GB of
24925data must use @code{malloc} or @code{mmap} to allocate the data in the
24926heap instead of in the program's data segment.
24927
24928When generating code for shared libraries, @option{-fpic} implies
24929@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24930
d77de738
ML
24931@opindex msmall-text
24932@opindex mlarge-text
ddf6fe37
AA
24933@item -msmall-text
24934@itemx -mlarge-text
d77de738
ML
24935When @option{-msmall-text} is used, the compiler assumes that the
24936code of the entire program (or shared library) fits in 4MB, and is
24937thus reachable with a branch instruction. When @option{-msmall-data}
24938is used, the compiler can assume that all local symbols share the
24939same @code{$gp} value, and thus reduce the number of instructions
24940required for a function call from 4 to 1.
24941
24942The default is @option{-mlarge-text}.
24943
d77de738 24944@opindex mcpu
ddf6fe37 24945@item -mcpu=@var{cpu_type}
d77de738
ML
24946Set the instruction set and instruction scheduling parameters for
24947machine type @var{cpu_type}. You can specify either the @samp{EV}
24948style name or the corresponding chip number. GCC supports scheduling
24949parameters for the EV4, EV5 and EV6 family of processors and
24950chooses the default values for the instruction set from the processor
24951you specify. If you do not specify a processor type, GCC defaults
24952to the processor on which the compiler was built.
24953
24954Supported values for @var{cpu_type} are
24955
24956@table @samp
24957@item ev4
24958@itemx ev45
24959@itemx 21064
24960Schedules as an EV4 and has no instruction set extensions.
24961
24962@item ev5
24963@itemx 21164
24964Schedules as an EV5 and has no instruction set extensions.
24965
24966@item ev56
24967@itemx 21164a
24968Schedules as an EV5 and supports the BWX extension.
24969
24970@item pca56
24971@itemx 21164pc
24972@itemx 21164PC
24973Schedules as an EV5 and supports the BWX and MAX extensions.
24974
24975@item ev6
24976@itemx 21264
24977Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24978
24979@item ev67
24980@itemx 21264a
24981Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24982@end table
24983
24984Native toolchains also support the value @samp{native},
24985which selects the best architecture option for the host processor.
24986@option{-mcpu=native} has no effect if GCC does not recognize
24987the processor.
24988
d77de738 24989@opindex mtune
ddf6fe37 24990@item -mtune=@var{cpu_type}
d77de738
ML
24991Set only the instruction scheduling parameters for machine type
24992@var{cpu_type}. The instruction set is not changed.
24993
24994Native toolchains also support the value @samp{native},
24995which selects the best architecture option for the host processor.
24996@option{-mtune=native} has no effect if GCC does not recognize
24997the processor.
24998
d77de738 24999@opindex mmemory-latency
ddf6fe37 25000@item -mmemory-latency=@var{time}
d77de738
ML
25001Sets the latency the scheduler should assume for typical memory
25002references as seen by the application. This number is highly
25003dependent on the memory access patterns used by the application
25004and the size of the external cache on the machine.
25005
25006Valid options for @var{time} are
25007
25008@table @samp
25009@item @var{number}
25010A decimal number representing clock cycles.
25011
25012@item L1
25013@itemx L2
25014@itemx L3
25015@itemx main
25016The compiler contains estimates of the number of clock cycles for
25017``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
25018(also called Dcache, Scache, and Bcache), as well as to main memory.
25019Note that L3 is only valid for EV5.
25020
25021@end table
25022@end table
25023
25024@node eBPF Options
25025@subsection eBPF Options
25026@cindex eBPF Options
25027
25028@table @gcctabopt
25029@item -mframe-limit=@var{bytes}
25030This specifies the hard limit for frame sizes, in bytes. Currently,
25031the value that can be specified should be less than or equal to
25032@samp{32767}. Defaults to whatever limit is imposed by the version of
25033the Linux kernel targeted.
25034
d77de738 25035@opindex mbig-endian
ddf6fe37 25036@item -mbig-endian
d77de738
ML
25037Generate code for a big-endian target.
25038
d77de738 25039@opindex mlittle-endian
ddf6fe37 25040@item -mlittle-endian
d77de738
ML
25041Generate code for a little-endian target. This is the default.
25042
d77de738 25043@opindex mjmpext
ddf6fe37 25044@item -mjmpext
9cbf4286
DF
25045@itemx -mno-jmpext
25046Enable or disable generation of extra conditional-branch instructions.
d77de738
ML
25047Enabled for CPU v2 and above.
25048
d77de738 25049@opindex mjmp32
ddf6fe37 25050@item -mjmp32
9cbf4286
DF
25051@itemx -mno-jmp32
25052Enable or disable generation of 32-bit jump instructions.
25053Enabled for CPU v3 and above.
d77de738 25054
d77de738 25055@opindex malu32
ddf6fe37 25056@item -malu32
9cbf4286
DF
25057@itemx -mno-alu32
25058Enable or disable generation of 32-bit ALU instructions.
25059Enabled for CPU v3 and above.
25060
25061@opindex mv3-atomics
25062@item -mv3-atomics
25063@itemx -mno-v3-atomics
25064Enable or disable instructions for general atomic operations introduced
25065in CPU v3. Enabled for CPU v3 and above.
d77de738 25066
f1e34551
JM
25067@opindex mbswap
25068@item -mbswap
9cbf4286
DF
25069@itemx -mno-bswap
25070Enable or disable byte swap instructions. Enabled for CPU v4 and above.
f1e34551 25071
4be3919f
JM
25072@opindex msdiv
25073@item -msdiv
9cbf4286
DF
25074@itemx -mno-sdiv
25075Enable or disable signed division and modulus instructions. Enabled for
25076CPU v4 and above.
db189d02 25077
14dab1a1
DF
25078@opindex msmov
25079@item -msmov
25080@itemx -mno-smov
25081Enable or disable sign-extending move and memory load instructions.
25082Enabled for CPU v4 and above.
25083
d77de738 25084@opindex mcpu
ddf6fe37 25085@item -mcpu=@var{version}
d77de738 25086This specifies which version of the eBPF ISA to target. Newer versions
f1e34551 25087may not be supported by all kernels. The default is @samp{v4}.
d77de738
ML
25088
25089Supported values for @var{version} are:
25090
25091@table @samp
25092@item v1
25093The first stable eBPF ISA with no special features or extensions.
25094
25095@item v2
25096Supports the jump extensions, as in @option{-mjmpext}.
25097
25098@item v3
25099All features of v2, plus:
25100@itemize @minus
25101@item 32-bit jump operations, as in @option{-mjmp32}
25102@item 32-bit ALU operations, as in @option{-malu32}
db189d02 25103@item general atomic operations, as in @option{-mv3-atomics}
d77de738
ML
25104@end itemize
25105
f1e34551
JM
25106@item v4
25107All features of v3, plus:
25108@itemize @minus
25109@item Byte swap instructions, as in @option{-mbswap}
9cbf4286 25110@item Signed division and modulus instructions, as in @option{-msdiv}
14dab1a1 25111@item Sign-extending move and memory load instructions, as in @option{-msmov}
f1e34551 25112@end itemize
d77de738
ML
25113@end table
25114
d77de738 25115@opindex mco-re
ddf6fe37 25116@item -mco-re
d77de738
ML
25117Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
25118is implied by @option{-gbtf}.
25119
d77de738 25120@opindex mno-co-re
ddf6fe37 25121@item -mno-co-re
d77de738
ML
25122Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
25123support is enabled by default when generating BTF debug information for
25124the BPF target.
25125
25126@item -mxbpf
25127Generate code for an expanded version of BPF, which relaxes some of
25128the restrictions imposed by the BPF architecture:
25129@itemize @minus
25130@item Save and restore callee-saved registers at function entry and
25131exit, respectively.
25132@end itemize
77d0f9ec
CM
25133
25134@opindex masm=@var{dialect}
25135@item -masm=@var{dialect}
25136Outputs assembly instructions using eBPF selected @var{dialect}. The default
25137is @samp{normal}.
25138
25139Supported values for @var{dialect} are:
25140
25141@table @samp
25142@item normal
25143Outputs normal assembly dialect.
25144
25145@item pseudoc
25146Outputs pseudo-c assembly dialect.
25147
25148@end table
25149
d77de738
ML
25150@end table
25151
25152@node FR30 Options
25153@subsection FR30 Options
25154@cindex FR30 Options
25155
25156These options are defined specifically for the FR30 port.
25157
25158@table @gcctabopt
25159
d77de738 25160@opindex msmall-model
ddf6fe37 25161@item -msmall-model
d77de738
ML
25162Use the small address space model. This can produce smaller code, but
25163it does assume that all symbolic values and addresses fit into a
2516420-bit range.
25165
d77de738 25166@opindex mno-lsim
ddf6fe37 25167@item -mno-lsim
d77de738
ML
25168Assume that runtime support has been provided and so there is no need
25169to include the simulator library (@file{libsim.a}) on the linker
25170command line.
25171
25172@end table
25173
25174@node FT32 Options
25175@subsection FT32 Options
25176@cindex FT32 Options
25177
25178These options are defined specifically for the FT32 port.
25179
25180@table @gcctabopt
25181
d77de738 25182@opindex msim
ddf6fe37 25183@item -msim
d77de738
ML
25184Specifies that the program will be run on the simulator. This causes
25185an alternate runtime startup and library to be linked.
25186You must not use this option when generating programs that will run on
25187real hardware; you must provide your own runtime library for whatever
25188I/O functions are needed.
25189
d77de738 25190@opindex mlra
ddf6fe37 25191@item -mlra
d77de738
ML
25192Enable Local Register Allocation. This is still experimental for FT32,
25193so by default the compiler uses standard reload.
25194
d77de738 25195@opindex mnodiv
ddf6fe37 25196@item -mnodiv
d77de738
ML
25197Do not use div and mod instructions.
25198
d77de738 25199@opindex mft32b
ddf6fe37 25200@item -mft32b
d77de738
ML
25201Enable use of the extended instructions of the FT32B processor.
25202
d77de738 25203@opindex mcompress
ddf6fe37 25204@item -mcompress
d77de738
ML
25205Compress all code using the Ft32B code compression scheme.
25206
d77de738 25207@opindex mnopm
ddf6fe37 25208@item -mnopm
d77de738
ML
25209Do not generate code that reads program memory.
25210
25211@end table
25212
25213@node FRV Options
25214@subsection FRV Options
25215@cindex FRV Options
25216
25217@table @gcctabopt
d77de738 25218@opindex mgpr-32
ddf6fe37 25219@item -mgpr-32
d77de738
ML
25220
25221Only use the first 32 general-purpose registers.
25222
d77de738 25223@opindex mgpr-64
ddf6fe37 25224@item -mgpr-64
d77de738
ML
25225
25226Use all 64 general-purpose registers.
25227
d77de738 25228@opindex mfpr-32
ddf6fe37 25229@item -mfpr-32
d77de738
ML
25230
25231Use only the first 32 floating-point registers.
25232
d77de738 25233@opindex mfpr-64
ddf6fe37 25234@item -mfpr-64
d77de738
ML
25235
25236Use all 64 floating-point registers.
25237
d77de738 25238@opindex mhard-float
ddf6fe37 25239@item -mhard-float
d77de738
ML
25240
25241Use hardware instructions for floating-point operations.
25242
d77de738 25243@opindex msoft-float
ddf6fe37 25244@item -msoft-float
d77de738
ML
25245
25246Use library routines for floating-point operations.
25247
d77de738 25248@opindex malloc-cc
ddf6fe37 25249@item -malloc-cc
d77de738
ML
25250
25251Dynamically allocate condition code registers.
25252
d77de738 25253@opindex mfixed-cc
ddf6fe37 25254@item -mfixed-cc
d77de738
ML
25255
25256Do not try to dynamically allocate condition code registers, only
25257use @code{icc0} and @code{fcc0}.
25258
d77de738 25259@opindex mdword
ddf6fe37 25260@item -mdword
d77de738
ML
25261
25262Change ABI to use double word insns.
25263
d77de738
ML
25264@opindex mno-dword
25265@opindex mdword
ddf6fe37 25266@item -mno-dword
d77de738
ML
25267
25268Do not use double word instructions.
25269
d77de738 25270@opindex mdouble
ddf6fe37 25271@item -mdouble
d77de738
ML
25272
25273Use floating-point double instructions.
25274
d77de738 25275@opindex mno-double
ddf6fe37 25276@item -mno-double
d77de738
ML
25277
25278Do not use floating-point double instructions.
25279
d77de738 25280@opindex mmedia
ddf6fe37 25281@item -mmedia
d77de738
ML
25282
25283Use media instructions.
25284
d77de738 25285@opindex mno-media
ddf6fe37 25286@item -mno-media
d77de738
ML
25287
25288Do not use media instructions.
25289
d77de738 25290@opindex mmuladd
ddf6fe37 25291@item -mmuladd
d77de738
ML
25292
25293Use multiply and add/subtract instructions.
25294
d77de738 25295@opindex mno-muladd
ddf6fe37 25296@item -mno-muladd
d77de738
ML
25297
25298Do not use multiply and add/subtract instructions.
25299
d77de738 25300@opindex mfdpic
ddf6fe37 25301@item -mfdpic
d77de738
ML
25302
25303Select the FDPIC ABI, which uses function descriptors to represent
25304pointers to functions. Without any PIC/PIE-related options, it
25305implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
25306assumes GOT entries and small data are within a 12-bit range from the
25307GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
25308are computed with 32 bits.
25309With a @samp{bfin-elf} target, this option implies @option{-msim}.
25310
d77de738 25311@opindex minline-plt
ddf6fe37 25312@item -minline-plt
d77de738
ML
25313
25314Enable inlining of PLT entries in function calls to functions that are
25315not known to bind locally. It has no effect without @option{-mfdpic}.
25316It's enabled by default if optimizing for speed and compiling for
25317shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
25318optimization option such as @option{-O3} or above is present in the
25319command line.
25320
d77de738 25321@opindex mTLS
ddf6fe37 25322@item -mTLS
d77de738
ML
25323
25324Assume a large TLS segment when generating thread-local code.
25325
d77de738 25326@opindex mtls
ddf6fe37 25327@item -mtls
d77de738
ML
25328
25329Do not assume a large TLS segment when generating thread-local code.
25330
d77de738 25331@opindex mgprel-ro
ddf6fe37 25332@item -mgprel-ro
d77de738
ML
25333
25334Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
25335that is known to be in read-only sections. It's enabled by default,
25336except for @option{-fpic} or @option{-fpie}: even though it may help
25337make the global offset table smaller, it trades 1 instruction for 4.
25338With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
25339one of which may be shared by multiple symbols, and it avoids the need
25340for a GOT entry for the referenced symbol, so it's more likely to be a
25341win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
25342
d77de738 25343@opindex multilib-library-pic
ddf6fe37 25344@item -multilib-library-pic
d77de738
ML
25345
25346Link with the (library, not FD) pic libraries. It's implied by
25347@option{-mlibrary-pic}, as well as by @option{-fPIC} and
25348@option{-fpic} without @option{-mfdpic}. You should never have to use
25349it explicitly.
25350
d77de738 25351@opindex mlinked-fp
ddf6fe37 25352@item -mlinked-fp
d77de738
ML
25353
25354Follow the EABI requirement of always creating a frame pointer whenever
25355a stack frame is allocated. This option is enabled by default and can
25356be disabled with @option{-mno-linked-fp}.
25357
d77de738 25358@opindex mlong-calls
ddf6fe37 25359@item -mlong-calls
d77de738
ML
25360
25361Use indirect addressing to call functions outside the current
25362compilation unit. This allows the functions to be placed anywhere
25363within the 32-bit address space.
25364
d77de738 25365@opindex malign-labels
ddf6fe37 25366@item -malign-labels
d77de738
ML
25367
25368Try to align labels to an 8-byte boundary by inserting NOPs into the
25369previous packet. This option only has an effect when VLIW packing
25370is enabled. It doesn't create new packets; it merely adds NOPs to
25371existing ones.
25372
d77de738 25373@opindex mlibrary-pic
ddf6fe37 25374@item -mlibrary-pic
d77de738
ML
25375
25376Generate position-independent EABI code.
25377
d77de738 25378@opindex macc-4
ddf6fe37 25379@item -macc-4
d77de738
ML
25380
25381Use only the first four media accumulator registers.
25382
d77de738 25383@opindex macc-8
ddf6fe37 25384@item -macc-8
d77de738
ML
25385
25386Use all eight media accumulator registers.
25387
d77de738 25388@opindex mpack
ddf6fe37 25389@item -mpack
d77de738
ML
25390
25391Pack VLIW instructions.
25392
d77de738 25393@opindex mno-pack
ddf6fe37 25394@item -mno-pack
d77de738
ML
25395
25396Do not pack VLIW instructions.
25397
d77de738 25398@opindex mno-eflags
ddf6fe37 25399@item -mno-eflags
d77de738
ML
25400
25401Do not mark ABI switches in e_flags.
25402
d77de738 25403@opindex mcond-move
ddf6fe37 25404@item -mcond-move
d77de738
ML
25405
25406Enable the use of conditional-move instructions (default).
25407
25408This switch is mainly for debugging the compiler and will likely be removed
25409in a future version.
25410
d77de738 25411@opindex mno-cond-move
ddf6fe37 25412@item -mno-cond-move
d77de738
ML
25413
25414Disable the use of conditional-move instructions.
25415
25416This switch is mainly for debugging the compiler and will likely be removed
25417in a future version.
25418
d77de738 25419@opindex mscc
ddf6fe37 25420@item -mscc
d77de738
ML
25421
25422Enable the use of conditional set instructions (default).
25423
25424This switch is mainly for debugging the compiler and will likely be removed
25425in a future version.
25426
d77de738 25427@opindex mno-scc
ddf6fe37 25428@item -mno-scc
d77de738
ML
25429
25430Disable the use of conditional set instructions.
25431
25432This switch is mainly for debugging the compiler and will likely be removed
25433in a future version.
25434
d77de738 25435@opindex mcond-exec
ddf6fe37 25436@item -mcond-exec
d77de738
ML
25437
25438Enable the use of conditional execution (default).
25439
25440This switch is mainly for debugging the compiler and will likely be removed
25441in a future version.
25442
d77de738 25443@opindex mno-cond-exec
ddf6fe37 25444@item -mno-cond-exec
d77de738
ML
25445
25446Disable the use of conditional execution.
25447
25448This switch is mainly for debugging the compiler and will likely be removed
25449in a future version.
25450
d77de738 25451@opindex mvliw-branch
ddf6fe37 25452@item -mvliw-branch
d77de738
ML
25453
25454Run a pass to pack branches into VLIW instructions (default).
25455
25456This switch is mainly for debugging the compiler and will likely be removed
25457in a future version.
25458
d77de738 25459@opindex mno-vliw-branch
ddf6fe37 25460@item -mno-vliw-branch
d77de738
ML
25461
25462Do not run a pass to pack branches into VLIW instructions.
25463
25464This switch is mainly for debugging the compiler and will likely be removed
25465in a future version.
25466
d77de738 25467@opindex mmulti-cond-exec
ddf6fe37 25468@item -mmulti-cond-exec
d77de738
ML
25469
25470Enable optimization of @code{&&} and @code{||} in conditional execution
25471(default).
25472
25473This switch is mainly for debugging the compiler and will likely be removed
25474in a future version.
25475
d77de738 25476@opindex mno-multi-cond-exec
ddf6fe37 25477@item -mno-multi-cond-exec
d77de738
ML
25478
25479Disable optimization of @code{&&} and @code{||} in conditional execution.
25480
25481This switch is mainly for debugging the compiler and will likely be removed
25482in a future version.
25483
d77de738 25484@opindex mnested-cond-exec
ddf6fe37 25485@item -mnested-cond-exec
d77de738
ML
25486
25487Enable nested conditional execution optimizations (default).
25488
25489This switch is mainly for debugging the compiler and will likely be removed
25490in a future version.
25491
d77de738 25492@opindex mno-nested-cond-exec
ddf6fe37 25493@item -mno-nested-cond-exec
d77de738
ML
25494
25495Disable nested conditional execution optimizations.
25496
25497This switch is mainly for debugging the compiler and will likely be removed
25498in a future version.
25499
d77de738 25500@opindex moptimize-membar
ddf6fe37 25501@item -moptimize-membar
d77de738
ML
25502
25503This switch removes redundant @code{membar} instructions from the
25504compiler-generated code. It is enabled by default.
25505
d77de738
ML
25506@opindex mno-optimize-membar
25507@opindex moptimize-membar
ddf6fe37 25508@item -mno-optimize-membar
d77de738
ML
25509
25510This switch disables the automatic removal of redundant @code{membar}
25511instructions from the generated code.
25512
d77de738 25513@opindex mtomcat-stats
ddf6fe37 25514@item -mtomcat-stats
d77de738
ML
25515
25516Cause gas to print out tomcat statistics.
25517
d77de738 25518@opindex mcpu
ddf6fe37 25519@item -mcpu=@var{cpu}
d77de738
ML
25520
25521Select the processor type for which to generate code. Possible values are
25522@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
25523@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
25524
25525@end table
25526
25527@node GNU/Linux Options
25528@subsection GNU/Linux Options
25529
25530These @samp{-m} options are defined for GNU/Linux targets:
25531
25532@table @gcctabopt
d77de738 25533@opindex mglibc
ddf6fe37 25534@item -mglibc
d77de738
ML
25535Use the GNU C library. This is the default except
25536on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
25537@samp{*-*-linux-*android*} targets.
25538
d77de738 25539@opindex muclibc
ddf6fe37 25540@item -muclibc
d77de738
ML
25541Use uClibc C library. This is the default on
25542@samp{*-*-linux-*uclibc*} targets.
25543
d77de738 25544@opindex mmusl
ddf6fe37 25545@item -mmusl
d77de738
ML
25546Use the musl C library. This is the default on
25547@samp{*-*-linux-*musl*} targets.
25548
d77de738 25549@opindex mbionic
ddf6fe37 25550@item -mbionic
d77de738
ML
25551Use Bionic C library. This is the default on
25552@samp{*-*-linux-*android*} targets.
25553
d77de738 25554@opindex mandroid
ddf6fe37 25555@item -mandroid
d77de738
ML
25556Compile code compatible with Android platform. This is the default on
25557@samp{*-*-linux-*android*} targets.
25558
25559When compiling, this option enables @option{-mbionic}, @option{-fPIC},
25560@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
25561this option makes the GCC driver pass Android-specific options to the linker.
25562Finally, this option causes the preprocessor macro @code{__ANDROID__}
25563to be defined.
25564
d77de738 25565@opindex tno-android-cc
ddf6fe37 25566@item -tno-android-cc
d77de738
ML
25567Disable compilation effects of @option{-mandroid}, i.e., do not enable
25568@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
25569@option{-fno-rtti} by default.
25570
d77de738 25571@opindex tno-android-ld
ddf6fe37 25572@item -tno-android-ld
d77de738
ML
25573Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
25574linking options to the linker.
25575
25576@end table
25577
25578@node H8/300 Options
25579@subsection H8/300 Options
25580
25581These @samp{-m} options are defined for the H8/300 implementations:
25582
25583@table @gcctabopt
d77de738 25584@opindex mrelax
ddf6fe37 25585@item -mrelax
d77de738
ML
25586Shorten some address references at link time, when possible; uses the
25587linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
25588ld, Using ld}, for a fuller description.
25589
d77de738 25590@opindex mh
ddf6fe37 25591@item -mh
d77de738
ML
25592Generate code for the H8/300H@.
25593
d77de738 25594@opindex ms
ddf6fe37 25595@item -ms
d77de738
ML
25596Generate code for the H8S@.
25597
d77de738 25598@opindex mn
ddf6fe37 25599@item -mn
d77de738
ML
25600Generate code for the H8S and H8/300H in the normal mode. This switch
25601must be used either with @option{-mh} or @option{-ms}.
25602
d77de738 25603@opindex ms2600
ddf6fe37 25604@item -ms2600
d77de738
ML
25605Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25606
d77de738 25607@opindex mexr
ddf6fe37 25608@item -mexr
d77de738
ML
25609Extended registers are stored on stack before execution of function
25610with monitor attribute. Default option is @option{-mexr}.
25611This option is valid only for H8S targets.
25612
d77de738
ML
25613@opindex mno-exr
25614@opindex mexr
ddf6fe37 25615@item -mno-exr
d77de738
ML
25616Extended registers are not stored on stack before execution of function
25617with monitor attribute. Default option is @option{-mno-exr}.
25618This option is valid only for H8S targets.
25619
d77de738 25620@opindex mint32
ddf6fe37 25621@item -mint32
d77de738
ML
25622Make @code{int} data 32 bits by default.
25623
d77de738 25624@opindex malign-300
ddf6fe37 25625@item -malign-300
d77de738
ML
25626On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25627The default for the H8/300H and H8S is to align longs and floats on
256284-byte boundaries.
25629@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25630This option has no effect on the H8/300.
25631@end table
25632
25633@node HPPA Options
25634@subsection HPPA Options
25635@cindex HPPA Options
25636
25637These @samp{-m} options are defined for the HPPA family of computers:
25638
25639@table @gcctabopt
d77de738 25640@opindex march
ddf6fe37 25641@item -march=@var{architecture-type}
d77de738
ML
25642Generate code for the specified architecture. The choices for
25643@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
256441.1, and @samp{2.0} for PA 2.0 processors. Refer to
25645@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25646architecture option for your machine. Code compiled for lower numbered
25647architectures runs on higher numbered architectures, but not the
25648other way around.
25649
d77de738
ML
25650@opindex mpa-risc-1-0
25651@opindex mpa-risc-1-1
25652@opindex mpa-risc-2-0
ddf6fe37
AA
25653@item -mpa-risc-1-0
25654@itemx -mpa-risc-1-1
25655@itemx -mpa-risc-2-0
d77de738
ML
25656Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25657
cf467fb9
JDA
25658@opindex matomic-libcalls
25659@opindex mno-atomic-libcalls
ddf6fe37 25660@item -matomic-libcalls
cf467fb9
JDA
25661Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25662This option is enabled by default. It only affects the generation of
25663atomic libcalls by the HPPA backend.
25664
25665Both the sync and @file{libatomic} libcall implementations use locking.
25666As a result, processor stores are not atomic with respect to other
25667atomic operations. Processor loads up to DImode are atomic with
25668respect to other atomic operations provided they are implemented as
25669a single access.
25670
25671The PA-RISC architecture does not support any atomic operations in
25672hardware except for the @code{ldcw} instruction. Thus, all atomic
25673support is implemented using sync and atomic libcalls. Sync libcall
25674support is in @file{libgcc.a}. Atomic libcall support is in
25675@file{libatomic}.
25676
25677This option generates @code{__atomic_exchange} calls for atomic stores.
25678It also provides special handling for atomic DImode accesses on 32-bit
25679targets.
25680
cf467fb9 25681@opindex mbig-switch
ddf6fe37 25682@item -mbig-switch
cf467fb9
JDA
25683Does nothing. Preserved for backward compatibility.
25684
d77de738 25685@opindex mcaller-copies
ddf6fe37 25686@item -mcaller-copies
d77de738
ML
25687The caller copies function arguments passed by hidden reference. This
25688option should be used with care as it is not compatible with the default
2568932-bit runtime. However, only aggregates larger than eight bytes are
25690passed by hidden reference and the option provides better compatibility
25691with OpenMP.
25692
cf467fb9 25693@opindex mcoherent-ldcw
ddf6fe37 25694@item -mcoherent-ldcw
cf467fb9 25695Use ldcw/ldcd coherent cache-control hint.
d77de738 25696
d77de738 25697@opindex mdisable-fpregs
ddf6fe37 25698@item -mdisable-fpregs
cf467fb9 25699Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25700
d77de738 25701@opindex mdisable-indexing
ddf6fe37 25702@item -mdisable-indexing
d77de738
ML
25703Prevent the compiler from using indexing address modes. This avoids some
25704rather obscure problems when compiling MIG generated code under MACH@.
25705
d77de738 25706@opindex mfast-indirect-calls
ddf6fe37 25707@item -mfast-indirect-calls
d77de738
ML
25708Generate code that assumes calls never cross space boundaries. This
25709allows GCC to emit code that performs faster indirect calls.
25710
25711This option does not work in the presence of shared libraries or nested
25712functions.
25713
d77de738 25714@opindex mfixed-range
ddf6fe37 25715@item -mfixed-range=@var{register-range}
d77de738
ML
25716Generate code treating the given register range as fixed registers.
25717A fixed register is one that the register allocator cannot use. This is
25718useful when compiling kernel code. A register range is specified as
25719two registers separated by a dash. Multiple register ranges can be
25720specified separated by a comma.
25721
d77de738 25722@opindex mgas
ddf6fe37 25723@item -mgas
d77de738
ML
25724Enable the use of assembler directives only GAS understands.
25725
d77de738 25726@opindex mgnu-ld
ddf6fe37 25727@item -mgnu-ld
d77de738
ML
25728Use options specific to GNU @command{ld}.
25729This passes @option{-shared} to @command{ld} when
25730building a shared library. It is the default when GCC is configured,
25731explicitly or implicitly, with the GNU linker. This option does not
25732affect which @command{ld} is called; it only changes what parameters
25733are passed to that @command{ld}.
25734The @command{ld} that is called is determined by the
25735@option{--with-ld} configure option, GCC's program search path, and
25736finally by the user's @env{PATH}. The linker used by GCC can be printed
25737using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25738on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25739
d77de738 25740@opindex mhp-ld
ddf6fe37 25741@item -mhp-ld
d77de738
ML
25742Use options specific to HP @command{ld}.
25743This passes @option{-b} to @command{ld} when building
25744a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25745links. It is the default when GCC is configured, explicitly or
25746implicitly, with the HP linker. This option does not affect
25747which @command{ld} is called; it only changes what parameters are passed to that
25748@command{ld}.
25749The @command{ld} that is called is determined by the @option{--with-ld}
25750configure option, GCC's program search path, and finally by the user's
25751@env{PATH}. The linker used by GCC can be printed using @samp{which
25752`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25753HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25754
cf467fb9 25755@opindex mlinker-opt
ddf6fe37 25756@item -mlinker-opt
cf467fb9
JDA
25757Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25758debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25759linkers in which they give bogus error messages when linking some programs.
25760
d77de738
ML
25761@opindex mno-long-calls
25762@opindex mlong-calls
ddf6fe37 25763@item -mlong-calls
d77de738
ML
25764Generate code that uses long call sequences. This ensures that a call
25765is always able to reach linker generated stubs. The default is to generate
25766long calls only when the distance from the call site to the beginning
25767of the function or translation unit, as the case may be, exceeds a
25768predefined limit set by the branch type being used. The limits for
25769normal calls are 7,600,000 and 240,000 bytes, respectively for the
25770PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25771240,000 bytes.
25772
25773Distances are measured from the beginning of functions when using the
25774@option{-ffunction-sections} option, or when using the @option{-mgas}
25775and @option{-mno-portable-runtime} options together under HP-UX with
25776the SOM linker.
25777
25778It is normally not desirable to use this option as it degrades
25779performance. However, it may be useful in large applications,
25780particularly when partial linking is used to build the application.
25781
25782The types of long calls used depends on the capabilities of the
25783assembler and linker, and the type of code being generated. The
25784impact on systems that support long absolute calls, and long pic
25785symbol-difference or pc-relative calls should be relatively small.
25786However, an indirect call is used on 32-bit ELF systems in pic code
25787and it is quite long.
25788
cf467fb9 25789@opindex mlong-load-store
ddf6fe37 25790@item -mlong-load-store
cf467fb9
JDA
25791Generate 3-instruction load and store sequences as sometimes required by
25792the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25793the HP compilers.
25794
cf467fb9 25795@opindex mjump-in-delay
ddf6fe37 25796@item -mjump-in-delay
cf467fb9
JDA
25797This option is ignored and provided for compatibility purposes only.
25798
cf467fb9
JDA
25799@opindex mno-space-regs
25800@opindex mspace-regs
ddf6fe37 25801@item -mno-space-regs
cf467fb9
JDA
25802Generate code that assumes the target has no space registers. This allows
25803GCC to generate faster indirect calls and use unscaled index address modes.
25804
25805Such code is suitable for level 0 PA systems and kernels.
25806
cf467fb9 25807@opindex mordered
ddf6fe37 25808@item -mordered
cf467fb9
JDA
25809Assume memory references are ordered and barriers are not needed.
25810
cf467fb9 25811@opindex mportable-runtime
ddf6fe37 25812@item -mportable-runtime
cf467fb9
JDA
25813Use the portable calling conventions proposed by HP for ELF systems.
25814
cf467fb9 25815@opindex mschedule
ddf6fe37 25816@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25817Schedule code according to the constraints for the machine type
25818@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25819@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25820to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25821proper scheduling option for your machine. The default scheduling is
25822@samp{8000}.
25823
cf467fb9 25824@opindex msio
ddf6fe37 25825@item -msio
cf467fb9
JDA
25826Generate the predefine, @code{_SIO}, for server IO@. The default is
25827@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25828@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25829options are available under HP-UX and HI-UX@.
25830
cf467fb9 25831@opindex msoft-float
ddf6fe37 25832@item -msoft-float
cf467fb9
JDA
25833Generate output containing library calls for floating point.
25834@strong{Warning:} the requisite libraries are not available for all HPPA
25835targets. Normally the facilities of the machine's usual C compiler are
25836used, but this cannot be done directly in cross-compilation. You must make
25837your own arrangements to provide suitable library functions for
25838cross-compilation.
25839
25840@option{-msoft-float} changes the calling convention in the output file;
25841therefore, it is only useful if you compile @emph{all} of a program with
25842this option. In particular, you need to compile @file{libgcc.a}, the
25843library that comes with GCC, with @option{-msoft-float} in order for
25844this to work.
25845
cf467fb9 25846@opindex msoft-mult
ddf6fe37 25847@item -msoft-mult
cf467fb9
JDA
25848Use software integer multiplication.
25849
25850This disables the use of the @code{xmpyu} instruction.
25851
d77de738 25852@opindex march
ddf6fe37 25853@item -munix=@var{unix-std}
d77de738
ML
25854Generate compiler predefines and select a startfile for the specified
25855UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25856and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25857is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2585811.11 and later. The default values are @samp{93} for HP-UX 10.00,
25859@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25860and later.
25861
25862@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25863@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25864and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25865@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25866@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25867@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25868
25869It is @emph{important} to note that this option changes the interfaces
25870for various library routines. It also affects the operational behavior
25871of the C library. Thus, @emph{extreme} care is needed in using this
25872option.
25873
25874Library code that is intended to operate with more than one UNIX
25875standard must test, set and restore the variable @code{__xpg4_extended_mask}
25876as appropriate. Most GNU software doesn't provide this capability.
25877
d77de738 25878@opindex nolibdld
ddf6fe37 25879@item -nolibdld
d77de738
ML
25880Suppress the generation of link options to search libdld.sl when the
25881@option{-static} option is specified on HP-UX 10 and later.
25882
d77de738 25883@opindex static
ddf6fe37 25884@item -static
d77de738
ML
25885The HP-UX implementation of setlocale in libc has a dependency on
25886libdld.sl. There isn't an archive version of libdld.sl. Thus,
25887when the @option{-static} option is specified, special link options
25888are needed to resolve this dependency.
25889
25890On HP-UX 10 and later, the GCC driver adds the necessary options to
25891link with libdld.sl when the @option{-static} option is specified.
25892This causes the resulting binary to be dynamic. On the 64-bit port,
25893the linkers generate dynamic binaries by default in any case. The
25894@option{-nolibdld} option can be used to prevent the GCC driver from
25895adding these link options.
25896
d77de738 25897@opindex threads
ddf6fe37 25898@item -threads
d77de738
ML
25899Add support for multithreading with the @dfn{dce thread} library
25900under HP-UX@. This option sets flags for both the preprocessor and
25901linker.
25902@end table
25903
25904@node IA-64 Options
25905@subsection IA-64 Options
25906@cindex IA-64 Options
25907
25908These are the @samp{-m} options defined for the Intel IA-64 architecture.
25909
25910@table @gcctabopt
d77de738 25911@opindex mbig-endian
ddf6fe37 25912@item -mbig-endian
d77de738
ML
25913Generate code for a big-endian target. This is the default for HP-UX@.
25914
d77de738 25915@opindex mlittle-endian
ddf6fe37 25916@item -mlittle-endian
d77de738
ML
25917Generate code for a little-endian target. This is the default for AIX5
25918and GNU/Linux.
25919
d77de738
ML
25920@opindex mgnu-as
25921@opindex mno-gnu-as
ddf6fe37
AA
25922@item -mgnu-as
25923@itemx -mno-gnu-as
d77de738
ML
25924Generate (or don't) code for the GNU assembler. This is the default.
25925@c Also, this is the default if the configure option @option{--with-gnu-as}
25926@c is used.
25927
d77de738
ML
25928@opindex mgnu-ld
25929@opindex mno-gnu-ld
ddf6fe37
AA
25930@item -mgnu-ld
25931@itemx -mno-gnu-ld
d77de738
ML
25932Generate (or don't) code for the GNU linker. This is the default.
25933@c Also, this is the default if the configure option @option{--with-gnu-ld}
25934@c is used.
25935
d77de738 25936@opindex mno-pic
ddf6fe37 25937@item -mno-pic
d77de738
ML
25938Generate code that does not use a global pointer register. The result
25939is not position independent code, and violates the IA-64 ABI@.
25940
d77de738
ML
25941@opindex mvolatile-asm-stop
25942@opindex mno-volatile-asm-stop
ddf6fe37
AA
25943@item -mvolatile-asm-stop
25944@itemx -mno-volatile-asm-stop
d77de738
ML
25945Generate (or don't) a stop bit immediately before and after volatile asm
25946statements.
25947
d77de738
ML
25948@opindex mregister-names
25949@opindex mno-register-names
ddf6fe37
AA
25950@item -mregister-names
25951@itemx -mno-register-names
d77de738
ML
25952Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25953the stacked registers. This may make assembler output more readable.
25954
d77de738
ML
25955@opindex mno-sdata
25956@opindex msdata
ddf6fe37
AA
25957@item -mno-sdata
25958@itemx -msdata
d77de738
ML
25959Disable (or enable) optimizations that use the small data section. This may
25960be useful for working around optimizer bugs.
25961
d77de738 25962@opindex mconstant-gp
ddf6fe37 25963@item -mconstant-gp
d77de738
ML
25964Generate code that uses a single constant global pointer value. This is
25965useful when compiling kernel code.
25966
d77de738 25967@opindex mauto-pic
ddf6fe37 25968@item -mauto-pic
d77de738
ML
25969Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25970This is useful when compiling firmware code.
25971
d77de738 25972@opindex minline-float-divide-min-latency
ddf6fe37 25973@item -minline-float-divide-min-latency
d77de738
ML
25974Generate code for inline divides of floating-point values
25975using the minimum latency algorithm.
25976
d77de738 25977@opindex minline-float-divide-max-throughput
ddf6fe37 25978@item -minline-float-divide-max-throughput
d77de738
ML
25979Generate code for inline divides of floating-point values
25980using the maximum throughput algorithm.
25981
d77de738 25982@opindex mno-inline-float-divide
ddf6fe37 25983@item -mno-inline-float-divide
d77de738
ML
25984Do not generate inline code for divides of floating-point values.
25985
d77de738 25986@opindex minline-int-divide-min-latency
ddf6fe37 25987@item -minline-int-divide-min-latency
d77de738
ML
25988Generate code for inline divides of integer values
25989using the minimum latency algorithm.
25990
d77de738 25991@opindex minline-int-divide-max-throughput
ddf6fe37 25992@item -minline-int-divide-max-throughput
d77de738
ML
25993Generate code for inline divides of integer values
25994using the maximum throughput algorithm.
25995
d77de738
ML
25996@opindex mno-inline-int-divide
25997@opindex minline-int-divide
ddf6fe37 25998@item -mno-inline-int-divide
d77de738
ML
25999Do not generate inline code for divides of integer values.
26000
d77de738 26001@opindex minline-sqrt-min-latency
ddf6fe37 26002@item -minline-sqrt-min-latency
d77de738
ML
26003Generate code for inline square roots
26004using the minimum latency algorithm.
26005
d77de738 26006@opindex minline-sqrt-max-throughput
ddf6fe37 26007@item -minline-sqrt-max-throughput
d77de738
ML
26008Generate code for inline square roots
26009using the maximum throughput algorithm.
26010
d77de738 26011@opindex mno-inline-sqrt
ddf6fe37 26012@item -mno-inline-sqrt
d77de738
ML
26013Do not generate inline code for @code{sqrt}.
26014
d77de738
ML
26015@opindex mfused-madd
26016@opindex mno-fused-madd
ddf6fe37
AA
26017@item -mfused-madd
26018@itemx -mno-fused-madd
d77de738
ML
26019Do (don't) generate code that uses the fused multiply/add or multiply/subtract
26020instructions. The default is to use these instructions.
26021
d77de738
ML
26022@opindex mno-dwarf2-asm
26023@opindex mdwarf2-asm
ddf6fe37
AA
26024@item -mno-dwarf2-asm
26025@itemx -mdwarf2-asm
d77de738
ML
26026Don't (or do) generate assembler code for the DWARF line number debugging
26027info. This may be useful when not using the GNU assembler.
26028
d77de738
ML
26029@opindex mearly-stop-bits
26030@opindex mno-early-stop-bits
ddf6fe37
AA
26031@item -mearly-stop-bits
26032@itemx -mno-early-stop-bits
d77de738
ML
26033Allow stop bits to be placed earlier than immediately preceding the
26034instruction that triggered the stop bit. This can improve instruction
26035scheduling, but does not always do so.
26036
d77de738 26037@opindex mfixed-range
ddf6fe37 26038@item -mfixed-range=@var{register-range}
d77de738
ML
26039Generate code treating the given register range as fixed registers.
26040A fixed register is one that the register allocator cannot use. This is
26041useful when compiling kernel code. A register range is specified as
26042two registers separated by a dash. Multiple register ranges can be
26043specified separated by a comma.
26044
d77de738 26045@opindex mtls-size
ddf6fe37 26046@item -mtls-size=@var{tls-size}
d77de738
ML
26047Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2604864.
26049
d77de738 26050@opindex mtune
ddf6fe37 26051@item -mtune=@var{cpu-type}
d77de738
ML
26052Tune the instruction scheduling for a particular CPU, Valid values are
26053@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
26054and @samp{mckinley}.
26055
d77de738
ML
26056@opindex milp32
26057@opindex mlp64
ddf6fe37
AA
26058@item -milp32
26059@itemx -mlp64
d77de738
ML
26060Generate code for a 32-bit or 64-bit environment.
26061The 32-bit environment sets int, long and pointer to 32 bits.
26062The 64-bit environment sets int to 32 bits and long and pointer
26063to 64 bits. These are HP-UX specific flags.
26064
d77de738
ML
26065@opindex mno-sched-br-data-spec
26066@opindex msched-br-data-spec
ddf6fe37
AA
26067@item -mno-sched-br-data-spec
26068@itemx -msched-br-data-spec
d77de738
ML
26069(Dis/En)able data speculative scheduling before reload.
26070This results in generation of @code{ld.a} instructions and
26071the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26072The default setting is disabled.
26073
d77de738
ML
26074@opindex msched-ar-data-spec
26075@opindex mno-sched-ar-data-spec
ddf6fe37
AA
26076@item -msched-ar-data-spec
26077@itemx -mno-sched-ar-data-spec
d77de738
ML
26078(En/Dis)able data speculative scheduling after reload.
26079This results in generation of @code{ld.a} instructions and
26080the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26081The default setting is enabled.
26082
d77de738
ML
26083@opindex mno-sched-control-spec
26084@opindex msched-control-spec
ddf6fe37
AA
26085@item -mno-sched-control-spec
26086@itemx -msched-control-spec
d77de738
ML
26087(Dis/En)able control speculative scheduling. This feature is
26088available only during region scheduling (i.e.@: before reload).
26089This results in generation of the @code{ld.s} instructions and
26090the corresponding check instructions @code{chk.s}.
26091The default setting is disabled.
26092
d77de738
ML
26093@opindex msched-br-in-data-spec
26094@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
26095@item -msched-br-in-data-spec
26096@itemx -mno-sched-br-in-data-spec
d77de738
ML
26097(En/Dis)able speculative scheduling of the instructions that
26098are dependent on the data speculative loads before reload.
26099This is effective only with @option{-msched-br-data-spec} enabled.
26100The default setting is enabled.
26101
d77de738
ML
26102@opindex msched-ar-in-data-spec
26103@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
26104@item -msched-ar-in-data-spec
26105@itemx -mno-sched-ar-in-data-spec
d77de738
ML
26106(En/Dis)able speculative scheduling of the instructions that
26107are dependent on the data speculative loads after reload.
26108This is effective only with @option{-msched-ar-data-spec} enabled.
26109The default setting is enabled.
26110
d77de738
ML
26111@opindex msched-in-control-spec
26112@opindex mno-sched-in-control-spec
ddf6fe37
AA
26113@item -msched-in-control-spec
26114@itemx -mno-sched-in-control-spec
d77de738
ML
26115(En/Dis)able speculative scheduling of the instructions that
26116are dependent on the control speculative loads.
26117This is effective only with @option{-msched-control-spec} enabled.
26118The default setting is enabled.
26119
d77de738
ML
26120@opindex mno-sched-prefer-non-data-spec-insns
26121@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
26122@item -mno-sched-prefer-non-data-spec-insns
26123@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
26124If enabled, data-speculative instructions are chosen for schedule
26125only if there are no other choices at the moment. This makes
26126the use of the data speculation much more conservative.
26127The default setting is disabled.
26128
d77de738
ML
26129@opindex mno-sched-prefer-non-control-spec-insns
26130@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
26131@item -mno-sched-prefer-non-control-spec-insns
26132@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
26133If enabled, control-speculative instructions are chosen for schedule
26134only if there are no other choices at the moment. This makes
26135the use of the control speculation much more conservative.
26136The default setting is disabled.
26137
d77de738
ML
26138@opindex mno-sched-count-spec-in-critical-path
26139@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
26140@item -mno-sched-count-spec-in-critical-path
26141@itemx -msched-count-spec-in-critical-path
d77de738
ML
26142If enabled, speculative dependencies are considered during
26143computation of the instructions priorities. This makes the use of the
26144speculation a bit more conservative.
26145The default setting is disabled.
26146
d77de738 26147@opindex msched-spec-ldc
ddf6fe37 26148@item -msched-spec-ldc
d77de738
ML
26149Use a simple data speculation check. This option is on by default.
26150
d77de738 26151@opindex msched-spec-ldc
ddf6fe37 26152@item -msched-control-spec-ldc
d77de738
ML
26153Use a simple check for control speculation. This option is on by default.
26154
d77de738 26155@opindex msched-stop-bits-after-every-cycle
ddf6fe37 26156@item -msched-stop-bits-after-every-cycle
d77de738
ML
26157Place a stop bit after every cycle when scheduling. This option is on
26158by default.
26159
d77de738 26160@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 26161@item -msched-fp-mem-deps-zero-cost
d77de738
ML
26162Assume that floating-point stores and loads are not likely to cause a conflict
26163when placed into the same instruction group. This option is disabled by
26164default.
26165
d77de738 26166@opindex msel-sched-dont-check-control-spec
ddf6fe37 26167@item -msel-sched-dont-check-control-spec
d77de738
ML
26168Generate checks for control speculation in selective scheduling.
26169This flag is disabled by default.
26170
d77de738 26171@opindex msched-max-memory-insns
ddf6fe37 26172@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
26173Limit on the number of memory insns per instruction group, giving lower
26174priority to subsequent memory insns attempting to schedule in the same
26175instruction group. Frequently useful to prevent cache bank conflicts.
26176The default value is 1.
26177
d77de738 26178@opindex msched-max-memory-insns-hard-limit
ddf6fe37 26179@item -msched-max-memory-insns-hard-limit
d77de738
ML
26180Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
26181disallowing more than that number in an instruction group.
26182Otherwise, the limit is ``soft'', meaning that non-memory operations
26183are preferred when the limit is reached, but memory operations may still
26184be scheduled.
26185
26186@end table
26187
26188@node LM32 Options
26189@subsection LM32 Options
26190@cindex LM32 options
26191
26192These @option{-m} options are defined for the LatticeMico32 architecture:
26193
26194@table @gcctabopt
d77de738 26195@opindex mbarrel-shift-enabled
ddf6fe37 26196@item -mbarrel-shift-enabled
d77de738
ML
26197Enable barrel-shift instructions.
26198
d77de738 26199@opindex mdivide-enabled
ddf6fe37 26200@item -mdivide-enabled
d77de738
ML
26201Enable divide and modulus instructions.
26202
d77de738 26203@opindex multiply-enabled
ddf6fe37 26204@item -mmultiply-enabled
d77de738
ML
26205Enable multiply instructions.
26206
d77de738 26207@opindex msign-extend-enabled
ddf6fe37 26208@item -msign-extend-enabled
d77de738
ML
26209Enable sign extend instructions.
26210
d77de738 26211@opindex muser-enabled
ddf6fe37 26212@item -muser-enabled
d77de738
ML
26213Enable user-defined instructions.
26214
26215@end table
26216
26217@node LoongArch Options
26218@subsection LoongArch Options
26219@cindex LoongArch Options
26220
26221These command-line options are defined for LoongArch targets:
26222
26223@table @gcctabopt
9c19597c 26224@opindex march
ddf6fe37 26225@item -march=@var{cpu-type}
d77de738
ML
26226Generate instructions for the machine type @var{cpu-type}. In contrast to
26227@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
26228for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
26229to generate code that may not run at all on processors other than the one
26230indicated. Specifying @option{-march=@var{cpu-type}} implies
26231@option{-mtune=@var{cpu-type}}, except where noted otherwise.
26232
26233The choices for @var{cpu-type} are:
26234
26235@table @samp
26236@item native
26237This selects the CPU to generate code for at compilation time by determining
26238the processor type of the compiling machine. Using @option{-march=native}
26239enables all instruction subsets supported by the local machine (hence
26240the result might not run on different machines). Using @option{-mtune=native}
26241produces code optimized for the local machine under the constraints
26242of the selected instruction set.
26243@item loongarch64
26244A generic CPU with 64-bit extensions.
26245@item la464
26246LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
26247@end table
26248
d77de738 26249@opindex mtune
ddf6fe37 26250@item -mtune=@var{cpu-type}
d77de738
ML
26251Optimize the output for the given processor, specified by microarchitecture
26252name.
26253
d77de738 26254@opindex mabi
ddf6fe37 26255@item -mabi=@var{base-abi-type}
d77de738
ML
26256Generate code for the specified calling convention.
26257@var{base-abi-type} can be one of:
26258@table @samp
26259@item lp64d
26260Uses 64-bit general purpose registers and 32/64-bit floating-point
26261registers for parameter passing. Data model is LP64, where @samp{int}
26262is 32 bits, while @samp{long int} and pointers are 64 bits.
26263@item lp64f
26264Uses 64-bit general purpose registers and 32-bit floating-point
26265registers for parameter passing. Data model is LP64, where @samp{int}
26266is 32 bits, while @samp{long int} and pointers are 64 bits.
26267@item lp64s
26268Uses 64-bit general purpose registers and no floating-point
26269registers for parameter passing. Data model is LP64, where @samp{int}
26270is 32 bits, while @samp{long int} and pointers are 64 bits.
26271@end table
26272
d77de738 26273@opindex mfpu
ddf6fe37 26274@item -mfpu=@var{fpu-type}
d77de738
ML
26275Generate code for the specified FPU type, which can be one of:
26276@table @samp
26277@item 64
26278Allow the use of hardware floating-point instructions for 32-bit
26279and 64-bit operations.
26280@item 32
26281Allow the use of hardware floating-point instructions for 32-bit
26282operations.
26283@item none
26284@item 0
26285Prevent the use of hardware floating-point instructions.
26286@end table
26287
bb4a8198
YY
26288@opindex msimd
26289@item -msimd=@var{simd-type}
26290Enable generation of LoongArch SIMD instructions for vectorization
26291and via builtin functions. The value can be one of:
26292@table @samp
26293@item lasx
26294Enable generating instructions from the 256-bit LoongArch Advanced
26295SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
26296@item lsx
26297Enable generating instructions from the 128-bit LoongArch SIMD
26298Extension (LSX).
26299@item none
26300No LoongArch SIMD instruction may be generated.
26301@end table
26302
d77de738 26303@opindex msoft-float
ddf6fe37 26304@item -msoft-float
d77de738
ML
26305Force @option{-mfpu=none} and prevents the use of floating-point
26306registers for parameter passing. This option may change the target
26307ABI.
26308
9c19597c 26309@opindex msingle-float
ddf6fe37 26310@item -msingle-float
d77de738
ML
26311Force @option{-mfpu=32} and allow the use of 32-bit floating-point
26312registers for parameter passing. This option may change the target
26313ABI.
26314
9c19597c 26315@opindex mdouble-float
ddf6fe37 26316@item -mdouble-float
d77de738
ML
26317Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
26318registers for parameter passing. This option may change the target
26319ABI.
26320
bb4a8198
YY
26321@opindex ml[a]sx
26322@item -mlasx
26323@itemx -mno-lasx
26324@item -mlsx
26325@itemx -mno-lsx
26326Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
26327that can be used by the compiler for code generation. Enabling LASX with
26328@option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
26329automatically disables LASX. These driver-only options act upon the final
26330@option{msimd} configuration state and make incremental chagnes in the order
26331they appear on the GCC driver's command line, deriving the final / canonicalized
26332@option{msimd} option that is passed to the compiler proper.
26333
9c19597c 26334@opindex mbranch-cost
ddf6fe37 26335@item -mbranch-cost=@var{n}
d77de738
ML
26336Set the cost of branches to roughly @var{n} instructions.
26337
ddf6fe37 26338@opindex mcheck-zero-division
d77de738
ML
26339@item -mcheck-zero-division
26340@itemx -mno-check-zero-divison
d77de738
ML
26341Trap (do not trap) on integer division by zero. The default is
26342@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
26343@option{-mno-check-zero-division} for other optimization levels.
26344
ddf6fe37 26345@opindex mcond-move-int
d77de738
ML
26346@item -mcond-move-int
26347@itemx -mno-cond-move-int
d77de738
ML
26348Conditional moves for integral data in general-purpose registers
26349are enabled (disabled). The default is @option{-mcond-move-int}.
26350
ddf6fe37 26351@opindex mcond-move-float
d77de738
ML
26352@item -mcond-move-float
26353@itemx -mno-cond-move-float
d77de738
ML
26354Conditional moves for floating-point registers are enabled (disabled).
26355The default is @option{-mcond-move-float}.
26356
ddf6fe37 26357@opindex mmemcpy
d77de738
ML
26358@item -mmemcpy
26359@itemx -mno-memcpy
d77de738
ML
26360Force (do not force) the use of @code{memcpy} for non-trivial block moves.
26361The default is @option{-mno-memcpy}, which allows GCC to inline most
26362constant-sized copies. Setting optimization level to @option{-Os} also
26363forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
26364behavior if explicitly specified, regardless of the order these options on
26365the command line.
26366
ddf6fe37 26367@opindex mstrict-align
d77de738
ML
26368@item -mstrict-align
26369@itemx -mno-strict-align
d77de738
ML
26370Avoid or allow generating memory accesses that may not be aligned on a natural
26371object boundary as described in the architecture specification. The default is
26372@option{-mno-strict-align}.
26373
9c19597c 26374@opindex msmall-data-limit
ddf6fe37 26375@item -msmall-data-limit=@var{number}
d77de738
ML
26376Put global and static data smaller than @var{number} bytes into a special
26377section (on some targets). The default value is 0.
26378
9c19597c 26379@opindex mmax-inline-memcpy-size
ddf6fe37 26380@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
26381Inline all block moves (such as calls to @code{memcpy} or structure copies)
26382less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
26383
26384@item -mcmodel=@var{code-model}
26385Set the code model to one of:
26386@table @samp
26387@item tiny-static (Not implemented yet)
26388@item tiny (Not implemented yet)
26389
26390@item normal
26391The text segment must be within 128MB addressing space. The data segment must
26392be within 2GB addressing space.
26393
26394@item medium
26395The text segment and data segment must be within 2GB addressing space.
26396
26397@item large (Not implemented yet)
26398
26399@item extreme
26400This mode does not limit the size of the code segment and data segment.
e1b1cba1
XR
26401The @option{-mcmodel=extreme} option is incompatible with @option{-fplt},
26402and it requires @option{-mexplicit-relocs=always}.
d77de738
ML
26403@end table
26404The default code model is @code{normal}.
26405
e1b1cba1
XR
26406@item -mexplicit-relocs=@var{style}
26407Set when to use assembler relocation operators when dealing with symbolic
d77de738 26408addresses. The alternative is to use assembler macros instead, which may
e1b1cba1
XR
26409limit instruction scheduling but allow linker relaxation.
26410with @option{-mexplicit-relocs=none} the assembler macros are always used,
26411with @option{-mexplicit-relocs=always} the assembler relocation operators
26412are always used, with @option{-mexplicit-relocs=auto} the compiler will
26413use the relocation operators where the linker relaxation is impossible to
26414improve the code quality, and macros elsewhere. The default
fe23a2ff
XR
26415value for the option is determined with the assembler capability detected
26416during GCC build-time and the setting of @option{-mrelax}:
e1b1cba1
XR
26417@option{-mexplicit-relocs=none} if the assembler does not support
26418relocation operators at all,
26419@option{-mexplicit-relocs=always} if the assembler supports relocation
fe23a2ff
XR
26420operators but @option{-mrelax} is not enabled,
26421@option{-mexplicit-relocs=auto} if the assembler supports relocation
26422operators and @option{-mrelax} is enabled.
d77de738 26423
e1b1cba1
XR
26424@opindex mexplicit-relocs
26425@item -mexplicit-relocs
26426An alias of @option{-mexplicit-relocs=always} for backward compatibility.
26427
26428@opindex mno-explicit-relocs
26429@item -mno-explicit-relocs
26430An alias of @option{-mexplicit-relocs=none} for backward compatibility.
26431
ddf6fe37 26432@opindex mdirect-extern-access
d77de738
ML
26433@item -mdirect-extern-access
26434@itemx -mno-direct-extern-access
d77de738
ML
26435Do not use or use GOT to access external symbols. The default is
26436@option{-mno-direct-extern-access}: GOT is used for external symbols with
26437default visibility, but not used for other external symbols.
26438
26439With @option{-mdirect-extern-access}, GOT is not used and all external
26440symbols are PC-relatively addressed. It is @strong{only} suitable for
26441environments where no dynamic link is performed, like firmwares, OS
26442kernels, executables linked with @option{-static} or @option{-static-pie}.
26443@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
26444@option{-fpic}.
8f4bbdc2 26445
fe23a2ff
XR
26446@item -mrelax
26447@itemx -mno-relax
26448Take (do not take) advantage of linker relaxations. If
26449@option{-mpass-mrelax-to-as} is enabled, this option is also passed to
26450the assembler. The default is determined during GCC build-time by
26451detecting corresponding assembler support:
26452@option{-mrelax} if the assembler supports both the @option{-mrelax}
26453option and the conditional branch relaxation (it's required or the
26454@code{.align} directives and conditional branch instructions in the
26455assembly code outputted by GCC may be rejected by the assembler because
26456of a relocation overflow), @option{-mno-relax} otherwise.
26457
26458@item -mpass-mrelax-to-as
26459@itemx -mno-pass-mrelax-to-as
26460Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option
26461to the assembler. The default is determined during GCC build-time by
26462detecting corresponding assembler support:
26463@option{-mpass-mrelax-to-as} if the assembler supports the
26464@option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise.
26465This option is mostly useful for debugging, or interoperation with
26466assemblers different from the build-time one.
26467
8f4bbdc2
JX
26468@item loongarch-vect-unroll-limit
26469The vectorizer will use available tuning information to determine whether it
26470would be beneficial to unroll the main vectorized loop and by how much. This
26471parameter set's the upper bound of how much the vectorizer will unroll the main
26472loop. The default value is six.
26473
d77de738
ML
26474@end table
26475
bb4a8198 26476
d77de738
ML
26477@node M32C Options
26478@subsection M32C Options
26479@cindex M32C options
26480
26481@table @gcctabopt
d77de738 26482@opindex mcpu=
ddf6fe37 26483@item -mcpu=@var{name}
d77de738
ML
26484Select the CPU for which code is generated. @var{name} may be one of
26485@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
26486/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
26487the M32C/80 series.
26488
d77de738 26489@opindex msim
ddf6fe37 26490@item -msim
d77de738
ML
26491Specifies that the program will be run on the simulator. This causes
26492an alternate runtime library to be linked in which supports, for
26493example, file I/O@. You must not use this option when generating
26494programs that will run on real hardware; you must provide your own
26495runtime library for whatever I/O functions are needed.
26496
d77de738 26497@opindex memregs=
ddf6fe37 26498@item -memregs=@var{number}
d77de738
ML
26499Specifies the number of memory-based pseudo-registers GCC uses
26500during code generation. These pseudo-registers are used like real
26501registers, so there is a tradeoff between GCC's ability to fit the
26502code into available registers, and the performance penalty of using
26503memory instead of registers. Note that all modules in a program must
26504be compiled with the same value for this option. Because of that, you
26505must not use this option with GCC's default runtime libraries.
26506
26507@end table
26508
26509@node M32R/D Options
26510@subsection M32R/D Options
26511@cindex M32R/D options
26512
26513These @option{-m} options are defined for Renesas M32R/D architectures:
26514
26515@table @gcctabopt
d77de738 26516@opindex m32r2
ddf6fe37 26517@item -m32r2
d77de738
ML
26518Generate code for the M32R/2@.
26519
d77de738 26520@opindex m32rx
ddf6fe37 26521@item -m32rx
d77de738
ML
26522Generate code for the M32R/X@.
26523
d77de738 26524@opindex m32r
ddf6fe37 26525@item -m32r
d77de738
ML
26526Generate code for the M32R@. This is the default.
26527
d77de738 26528@opindex mmodel=small
ddf6fe37 26529@item -mmodel=small
d77de738
ML
26530Assume all objects live in the lower 16MB of memory (so that their addresses
26531can be loaded with the @code{ld24} instruction), and assume all subroutines
26532are reachable with the @code{bl} instruction.
26533This is the default.
26534
26535The addressability of a particular object can be set with the
26536@code{model} attribute.
26537
d77de738 26538@opindex mmodel=medium
ddf6fe37 26539@item -mmodel=medium
d77de738
ML
26540Assume objects may be anywhere in the 32-bit address space (the compiler
26541generates @code{seth/add3} instructions to load their addresses), and
26542assume all subroutines are reachable with the @code{bl} instruction.
26543
d77de738 26544@opindex mmodel=large
ddf6fe37 26545@item -mmodel=large
d77de738
ML
26546Assume objects may be anywhere in the 32-bit address space (the compiler
26547generates @code{seth/add3} instructions to load their addresses), and
26548assume subroutines may not be reachable with the @code{bl} instruction
26549(the compiler generates the much slower @code{seth/add3/jl}
26550instruction sequence).
26551
d77de738 26552@opindex msdata=none
ddf6fe37 26553@item -msdata=none
d77de738
ML
26554Disable use of the small data area. Variables are put into
26555one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
26556@code{section} attribute has been specified).
26557This is the default.
26558
26559The small data area consists of sections @code{.sdata} and @code{.sbss}.
26560Objects may be explicitly put in the small data area with the
26561@code{section} attribute using one of these sections.
26562
d77de738 26563@opindex msdata=sdata
ddf6fe37 26564@item -msdata=sdata
d77de738
ML
26565Put small global and static data in the small data area, but do not
26566generate special code to reference them.
26567
d77de738 26568@opindex msdata=use
ddf6fe37 26569@item -msdata=use
d77de738
ML
26570Put small global and static data in the small data area, and generate
26571special instructions to reference them.
26572
d77de738
ML
26573@opindex G
26574@cindex smaller data references
f33d7a88 26575@item -G @var{num}
d77de738
ML
26576Put global and static objects less than or equal to @var{num} bytes
26577into the small data or BSS sections instead of the normal data or BSS
26578sections. The default value of @var{num} is 8.
26579The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
26580for this option to have any effect.
26581
26582All modules should be compiled with the same @option{-G @var{num}} value.
26583Compiling with different values of @var{num} may or may not work; if it
26584doesn't the linker gives an error message---incorrect code is not
26585generated.
26586
d77de738 26587@opindex mdebug
ddf6fe37 26588@item -mdebug
d77de738
ML
26589Makes the M32R-specific code in the compiler display some statistics
26590that might help in debugging programs.
26591
d77de738 26592@opindex malign-loops
ddf6fe37 26593@item -malign-loops
d77de738
ML
26594Align all loops to a 32-byte boundary.
26595
d77de738 26596@opindex mno-align-loops
ddf6fe37 26597@item -mno-align-loops
d77de738
ML
26598Do not enforce a 32-byte alignment for loops. This is the default.
26599
d77de738 26600@opindex missue-rate=@var{number}
ddf6fe37 26601@item -missue-rate=@var{number}
d77de738
ML
26602Issue @var{number} instructions per cycle. @var{number} can only be 1
26603or 2.
26604
d77de738 26605@opindex mbranch-cost=@var{number}
ddf6fe37 26606@item -mbranch-cost=@var{number}
d77de738
ML
26607@var{number} can only be 1 or 2. If it is 1 then branches are
26608preferred over conditional code, if it is 2, then the opposite applies.
26609
d77de738 26610@opindex mflush-trap=@var{number}
ddf6fe37 26611@item -mflush-trap=@var{number}
d77de738
ML
26612Specifies the trap number to use to flush the cache. The default is
2661312. Valid numbers are between 0 and 15 inclusive.
26614
d77de738 26615@opindex mno-flush-trap
ddf6fe37 26616@item -mno-flush-trap
d77de738
ML
26617Specifies that the cache cannot be flushed by using a trap.
26618
d77de738 26619@opindex mflush-func=@var{name}
ddf6fe37 26620@item -mflush-func=@var{name}
d77de738
ML
26621Specifies the name of the operating system function to call to flush
26622the cache. The default is @samp{_flush_cache}, but a function call
26623is only used if a trap is not available.
26624
d77de738 26625@opindex mno-flush-func
ddf6fe37 26626@item -mno-flush-func
d77de738
ML
26627Indicates that there is no OS function for flushing the cache.
26628
26629@end table
26630
26631@node M680x0 Options
26632@subsection M680x0 Options
26633@cindex M680x0 options
26634
26635These are the @samp{-m} options defined for M680x0 and ColdFire processors.
26636The default settings depend on which architecture was selected when
26637the compiler was configured; the defaults for the most common choices
26638are given below.
26639
26640@table @gcctabopt
d77de738 26641@opindex march
ddf6fe37 26642@item -march=@var{arch}
d77de738
ML
26643Generate code for a specific M680x0 or ColdFire instruction set
26644architecture. Permissible values of @var{arch} for M680x0
26645architectures are: @samp{68000}, @samp{68010}, @samp{68020},
26646@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
26647architectures are selected according to Freescale's ISA classification
26648and the permissible values are: @samp{isaa}, @samp{isaaplus},
26649@samp{isab} and @samp{isac}.
26650
26651GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
26652code for a ColdFire target. The @var{arch} in this macro is one of the
26653@option{-march} arguments given above.
26654
26655When used together, @option{-march} and @option{-mtune} select code
26656that runs on a family of similar processors but that is optimized
26657for a particular microarchitecture.
26658
d77de738 26659@opindex mcpu
ddf6fe37 26660@item -mcpu=@var{cpu}
d77de738
ML
26661Generate code for a specific M680x0 or ColdFire processor.
26662The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
26663@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
26664and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
26665below, which also classifies the CPUs into families:
26666
26667@multitable @columnfractions 0.20 0.80
26668@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
26669@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}
26670@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
26671@item @samp{5206e} @tab @samp{5206e}
26672@item @samp{5208} @tab @samp{5207} @samp{5208}
26673@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26674@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26675@item @samp{5216} @tab @samp{5214} @samp{5216}
26676@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26677@item @samp{5225} @tab @samp{5224} @samp{5225}
26678@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26679@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26680@item @samp{5249} @tab @samp{5249}
26681@item @samp{5250} @tab @samp{5250}
26682@item @samp{5271} @tab @samp{5270} @samp{5271}
26683@item @samp{5272} @tab @samp{5272}
26684@item @samp{5275} @tab @samp{5274} @samp{5275}
26685@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26686@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26687@item @samp{5307} @tab @samp{5307}
26688@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26689@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26690@item @samp{5407} @tab @samp{5407}
26691@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}
26692@end multitable
26693
26694@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26695@var{arch} is compatible with @var{cpu}. Other combinations of
26696@option{-mcpu} and @option{-march} are rejected.
26697
26698GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26699@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26700where the value of @var{family} is given by the table above.
26701
d77de738 26702@opindex mtune
ddf6fe37 26703@item -mtune=@var{tune}
d77de738
ML
26704Tune the code for a particular microarchitecture within the
26705constraints set by @option{-march} and @option{-mcpu}.
26706The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26707@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26708and @samp{cpu32}. The ColdFire microarchitectures
26709are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26710
26711You can also use @option{-mtune=68020-40} for code that needs
26712to run relatively well on 68020, 68030 and 68040 targets.
26713@option{-mtune=68020-60} is similar but includes 68060 targets
26714as well. These two options select the same tuning decisions as
26715@option{-m68020-40} and @option{-m68020-60} respectively.
26716
26717GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26718when tuning for 680x0 architecture @var{arch}. It also defines
26719@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26720option is used. If GCC is tuning for a range of architectures,
26721as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26722it defines the macros for every architecture in the range.
26723
26724GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26725ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26726of the arguments given above.
26727
d77de738
ML
26728@opindex m68000
26729@opindex mc68000
ddf6fe37
AA
26730@item -m68000
26731@itemx -mc68000
d77de738
ML
26732Generate output for a 68000. This is the default
26733when the compiler is configured for 68000-based systems.
26734It is equivalent to @option{-march=68000}.
26735
26736Use this option for microcontrollers with a 68000 or EC000 core,
26737including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26738
d77de738 26739@opindex m68010
ddf6fe37 26740@item -m68010
d77de738
ML
26741Generate output for a 68010. This is the default
26742when the compiler is configured for 68010-based systems.
26743It is equivalent to @option{-march=68010}.
26744
d77de738
ML
26745@opindex m68020
26746@opindex mc68020
ddf6fe37
AA
26747@item -m68020
26748@itemx -mc68020
d77de738
ML
26749Generate output for a 68020. This is the default
26750when the compiler is configured for 68020-based systems.
26751It is equivalent to @option{-march=68020}.
26752
d77de738 26753@opindex m68030
ddf6fe37 26754@item -m68030
d77de738
ML
26755Generate output for a 68030. This is the default when the compiler is
26756configured for 68030-based systems. It is equivalent to
26757@option{-march=68030}.
26758
d77de738 26759@opindex m68040
ddf6fe37 26760@item -m68040
d77de738
ML
26761Generate output for a 68040. This is the default when the compiler is
26762configured for 68040-based systems. It is equivalent to
26763@option{-march=68040}.
26764
26765This option inhibits the use of 68881/68882 instructions that have to be
26766emulated by software on the 68040. Use this option if your 68040 does not
26767have code to emulate those instructions.
26768
d77de738 26769@opindex m68060
ddf6fe37 26770@item -m68060
d77de738
ML
26771Generate output for a 68060. This is the default when the compiler is
26772configured for 68060-based systems. It is equivalent to
26773@option{-march=68060}.
26774
26775This option inhibits the use of 68020 and 68881/68882 instructions that
26776have to be emulated by software on the 68060. Use this option if your 68060
26777does not have code to emulate those instructions.
26778
d77de738 26779@opindex mcpu32
ddf6fe37 26780@item -mcpu32
d77de738
ML
26781Generate output for a CPU32. This is the default
26782when the compiler is configured for CPU32-based systems.
26783It is equivalent to @option{-march=cpu32}.
26784
26785Use this option for microcontrollers with a
26786CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2678768336, 68340, 68341, 68349 and 68360.
26788
d77de738 26789@opindex m5200
ddf6fe37 26790@item -m5200
d77de738
ML
26791Generate output for a 520X ColdFire CPU@. This is the default
26792when the compiler is configured for 520X-based systems.
26793It is equivalent to @option{-mcpu=5206}, and is now deprecated
26794in favor of that option.
26795
26796Use this option for microcontroller with a 5200 core, including
26797the MCF5202, MCF5203, MCF5204 and MCF5206.
26798
d77de738 26799@opindex m5206e
ddf6fe37 26800@item -m5206e
d77de738
ML
26801Generate output for a 5206e ColdFire CPU@. The option is now
26802deprecated in favor of the equivalent @option{-mcpu=5206e}.
26803
d77de738 26804@opindex m528x
ddf6fe37 26805@item -m528x
d77de738
ML
26806Generate output for a member of the ColdFire 528X family.
26807The option is now deprecated in favor of the equivalent
26808@option{-mcpu=528x}.
26809
d77de738 26810@opindex m5307
ddf6fe37 26811@item -m5307
d77de738
ML
26812Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26813in favor of the equivalent @option{-mcpu=5307}.
26814
d77de738 26815@opindex m5407
ddf6fe37 26816@item -m5407
d77de738
ML
26817Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26818in favor of the equivalent @option{-mcpu=5407}.
26819
d77de738 26820@opindex mcfv4e
ddf6fe37 26821@item -mcfv4e
d77de738
ML
26822Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26823This includes use of hardware floating-point instructions.
26824The option is equivalent to @option{-mcpu=547x}, and is now
26825deprecated in favor of that option.
26826
d77de738 26827@opindex m68020-40
ddf6fe37 26828@item -m68020-40
d77de738
ML
26829Generate output for a 68040, without using any of the new instructions.
26830This results in code that can run relatively efficiently on either a
2683168020/68881 or a 68030 or a 68040. The generated code does use the
2683268881 instructions that are emulated on the 68040.
26833
26834The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26835
d77de738 26836@opindex m68020-60
ddf6fe37 26837@item -m68020-60
d77de738
ML
26838Generate output for a 68060, without using any of the new instructions.
26839This results in code that can run relatively efficiently on either a
2684068020/68881 or a 68030 or a 68040. The generated code does use the
2684168881 instructions that are emulated on the 68060.
26842
26843The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26844
d77de738
ML
26845@opindex mhard-float
26846@opindex m68881
ddf6fe37
AA
26847@item -mhard-float
26848@itemx -m68881
d77de738
ML
26849Generate floating-point instructions. This is the default for 68020
26850and above, and for ColdFire devices that have an FPU@. It defines the
26851macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26852on ColdFire targets.
26853
d77de738 26854@opindex msoft-float
ddf6fe37 26855@item -msoft-float
d77de738
ML
26856Do not generate floating-point instructions; use library calls instead.
26857This is the default for 68000, 68010, and 68832 targets. It is also
26858the default for ColdFire devices that have no FPU.
26859
d77de738
ML
26860@opindex mdiv
26861@opindex mno-div
ddf6fe37
AA
26862@item -mdiv
26863@itemx -mno-div
d77de738
ML
26864Generate (do not generate) ColdFire hardware divide and remainder
26865instructions. If @option{-march} is used without @option{-mcpu},
26866the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26867architectures. Otherwise, the default is taken from the target CPU
26868(either the default CPU, or the one specified by @option{-mcpu}). For
26869example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26870@option{-mcpu=5206e}.
26871
26872GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26873
d77de738 26874@opindex mshort
ddf6fe37 26875@item -mshort
d77de738
ML
26876Consider type @code{int} to be 16 bits wide, like @code{short int}.
26877Additionally, parameters passed on the stack are also aligned to a
2687816-bit boundary even on targets whose API mandates promotion to 32-bit.
26879
d77de738 26880@opindex mno-short
ddf6fe37 26881@item -mno-short
d77de738
ML
26882Do not consider type @code{int} to be 16 bits wide. This is the default.
26883
d77de738
ML
26884@opindex mnobitfield
26885@opindex mno-bitfield
ddf6fe37
AA
26886@item -mnobitfield
26887@itemx -mno-bitfield
d77de738
ML
26888Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26889and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26890
d77de738 26891@opindex mbitfield
ddf6fe37 26892@item -mbitfield
d77de738
ML
26893Do use the bit-field instructions. The @option{-m68020} option implies
26894@option{-mbitfield}. This is the default if you use a configuration
26895designed for a 68020.
26896
d77de738 26897@opindex mrtd
ddf6fe37 26898@item -mrtd
d77de738
ML
26899Use a different function-calling convention, in which functions
26900that take a fixed number of arguments return with the @code{rtd}
26901instruction, which pops their arguments while returning. This
26902saves one instruction in the caller since there is no need to pop
26903the arguments there.
26904
26905This calling convention is incompatible with the one normally
26906used on Unix, so you cannot use it if you need to call libraries
26907compiled with the Unix compiler.
26908
26909Also, you must provide function prototypes for all functions that
26910take variable numbers of arguments (including @code{printf});
26911otherwise incorrect code is generated for calls to those
26912functions.
26913
26914In addition, seriously incorrect code results if you call a
26915function with too many arguments. (Normally, extra arguments are
26916harmlessly ignored.)
26917
26918The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2691968040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26920
26921The default is @option{-mno-rtd}.
26922
d77de738
ML
26923@opindex malign-int
26924@opindex mno-align-int
ddf6fe37
AA
26925@item -malign-int
26926@itemx -mno-align-int
d77de738
ML
26927Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26928@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26929boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26930Aligning variables on 32-bit boundaries produces code that runs somewhat
26931faster on processors with 32-bit busses at the expense of more memory.
26932
26933@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26934aligns structures containing the above types differently than
26935most published application binary interface specifications for the m68k.
26936
26937@opindex mpcrel
26938Use the pc-relative addressing mode of the 68000 directly, instead of
26939using a global offset table. At present, this option implies @option{-fpic},
26940allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26941not presently supported with @option{-mpcrel}, though this could be supported for
2694268020 and higher processors.
26943
d77de738
ML
26944@opindex mno-strict-align
26945@opindex mstrict-align
ddf6fe37
AA
26946@item -mno-strict-align
26947@itemx -mstrict-align
d77de738
ML
26948Do not (do) assume that unaligned memory references are handled by
26949the system.
26950
26951@item -msep-data
26952Generate code that allows the data segment to be located in a different
26953area of memory from the text segment. This allows for execute-in-place in
26954an environment without virtual memory management. This option implies
26955@option{-fPIC}.
26956
26957@item -mno-sep-data
26958Generate code that assumes that the data segment follows the text segment.
26959This is the default.
26960
26961@item -mid-shared-library
26962Generate code that supports shared libraries via the library ID method.
26963This allows for execute-in-place and shared libraries in an environment
26964without virtual memory management. This option implies @option{-fPIC}.
26965
26966@item -mno-id-shared-library
26967Generate code that doesn't assume ID-based shared libraries are being used.
26968This is the default.
26969
26970@item -mshared-library-id=n
26971Specifies the identification number of the ID-based shared library being
26972compiled. Specifying a value of 0 generates more compact code; specifying
26973other values forces the allocation of that number to the current
26974library, but is no more space- or time-efficient than omitting this option.
26975
d77de738
ML
26976@opindex mxgot
26977@opindex mno-xgot
ddf6fe37
AA
26978@item -mxgot
26979@itemx -mno-xgot
d77de738
ML
26980When generating position-independent code for ColdFire, generate code
26981that works if the GOT has more than 8192 entries. This code is
26982larger and slower than code generated without this option. On M680x0
26983processors, this option is not needed; @option{-fPIC} suffices.
26984
26985GCC normally uses a single instruction to load values from the GOT@.
26986While this is relatively efficient, it only works if the GOT
26987is smaller than about 64k. Anything larger causes the linker
26988to report an error such as:
26989
26990@cindex relocation truncated to fit (ColdFire)
26991@smallexample
26992relocation truncated to fit: R_68K_GOT16O foobar
26993@end smallexample
26994
26995If this happens, you should recompile your code with @option{-mxgot}.
26996It should then work with very large GOTs. However, code generated with
26997@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26998the value of a global symbol.
26999
27000Note that some linkers, including newer versions of the GNU linker,
27001can create multiple GOTs and sort GOT entries. If you have such a linker,
27002you should only need to use @option{-mxgot} when compiling a single
27003object file that accesses more than 8192 GOT entries. Very few do.
27004
27005These options have no effect unless GCC is generating
27006position-independent code.
27007
d77de738 27008@opindex mlong-jump-table-offsets
ddf6fe37 27009@item -mlong-jump-table-offsets
d77de738
ML
27010Use 32-bit offsets in @code{switch} tables. The default is to use
2701116-bit offsets.
27012
27013@end table
27014
27015@node MCore Options
27016@subsection MCore Options
27017@cindex MCore options
27018
27019These are the @samp{-m} options defined for the Motorola M*Core
27020processors.
27021
27022@table @gcctabopt
27023
d77de738
ML
27024@opindex mhardlit
27025@opindex mno-hardlit
ddf6fe37
AA
27026@item -mhardlit
27027@itemx -mno-hardlit
d77de738
ML
27028Inline constants into the code stream if it can be done in two
27029instructions or less.
27030
d77de738
ML
27031@opindex mdiv
27032@opindex mno-div
ddf6fe37
AA
27033@item -mdiv
27034@itemx -mno-div
d77de738
ML
27035Use the divide instruction. (Enabled by default).
27036
d77de738
ML
27037@opindex mrelax-immediate
27038@opindex mno-relax-immediate
ddf6fe37
AA
27039@item -mrelax-immediate
27040@itemx -mno-relax-immediate
d77de738
ML
27041Allow arbitrary-sized immediates in bit operations.
27042
d77de738
ML
27043@opindex mwide-bitfields
27044@opindex mno-wide-bitfields
ddf6fe37
AA
27045@item -mwide-bitfields
27046@itemx -mno-wide-bitfields
d77de738
ML
27047Always treat bit-fields as @code{int}-sized.
27048
d77de738
ML
27049@opindex m4byte-functions
27050@opindex mno-4byte-functions
ddf6fe37
AA
27051@item -m4byte-functions
27052@itemx -mno-4byte-functions
d77de738
ML
27053Force all functions to be aligned to a 4-byte boundary.
27054
d77de738
ML
27055@opindex mcallgraph-data
27056@opindex mno-callgraph-data
ddf6fe37
AA
27057@item -mcallgraph-data
27058@itemx -mno-callgraph-data
d77de738
ML
27059Emit callgraph information.
27060
d77de738
ML
27061@opindex mslow-bytes
27062@opindex mno-slow-bytes
ddf6fe37
AA
27063@item -mslow-bytes
27064@itemx -mno-slow-bytes
d77de738
ML
27065Prefer word access when reading byte quantities.
27066
d77de738
ML
27067@opindex mlittle-endian
27068@opindex mbig-endian
ddf6fe37
AA
27069@item -mlittle-endian
27070@itemx -mbig-endian
d77de738
ML
27071Generate code for a little-endian target.
27072
d77de738
ML
27073@opindex m210
27074@opindex m340
ddf6fe37
AA
27075@item -m210
27076@itemx -m340
d77de738
ML
27077Generate code for the 210 processor.
27078
d77de738 27079@opindex mno-lsim
ddf6fe37 27080@item -mno-lsim
d77de738
ML
27081Assume that runtime support has been provided and so omit the
27082simulator library (@file{libsim.a)} from the linker command line.
27083
d77de738 27084@opindex mstack-increment
ddf6fe37 27085@item -mstack-increment=@var{size}
d77de738
ML
27086Set the maximum amount for a single stack increment operation. Large
27087values can increase the speed of programs that contain functions
27088that need a large amount of stack space, but they can also trigger a
27089segmentation fault if the stack is extended too much. The default
27090value is 0x1000.
27091
27092@end table
27093
d77de738
ML
27094@node MicroBlaze Options
27095@subsection MicroBlaze Options
27096@cindex MicroBlaze Options
27097
27098@table @gcctabopt
27099
d77de738 27100@opindex msoft-float
ddf6fe37 27101@item -msoft-float
d77de738
ML
27102Use software emulation for floating point (default).
27103
d77de738 27104@opindex mhard-float
ddf6fe37 27105@item -mhard-float
d77de738
ML
27106Use hardware floating-point instructions.
27107
d77de738 27108@opindex mmemcpy
ddf6fe37 27109@item -mmemcpy
d77de738
ML
27110Do not optimize block moves, use @code{memcpy}.
27111
d77de738 27112@opindex mno-clearbss
ddf6fe37 27113@item -mno-clearbss
d77de738
ML
27114This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
27115
d77de738 27116@opindex mcpu=
ddf6fe37 27117@item -mcpu=@var{cpu-type}
d77de738
ML
27118Use features of, and schedule code for, the given CPU.
27119Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
27120where @var{X} is a major version, @var{YY} is the minor version, and
27121@var{Z} is compatibility code. Example values are @samp{v3.00.a},
27122@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
27123
d77de738 27124@opindex mxl-soft-mul
ddf6fe37 27125@item -mxl-soft-mul
d77de738
ML
27126Use software multiply emulation (default).
27127
d77de738 27128@opindex mxl-soft-div
ddf6fe37 27129@item -mxl-soft-div
d77de738
ML
27130Use software emulation for divides (default).
27131
d77de738 27132@opindex mxl-barrel-shift
ddf6fe37 27133@item -mxl-barrel-shift
d77de738
ML
27134Use the hardware barrel shifter.
27135
d77de738 27136@opindex mxl-pattern-compare
ddf6fe37 27137@item -mxl-pattern-compare
d77de738
ML
27138Use pattern compare instructions.
27139
d77de738 27140@opindex msmall-divides
ddf6fe37 27141@item -msmall-divides
d77de738
ML
27142Use table lookup optimization for small signed integer divisions.
27143
d77de738 27144@opindex mxl-stack-check
ddf6fe37 27145@item -mxl-stack-check
d77de738
ML
27146This option is deprecated. Use @option{-fstack-check} instead.
27147
d77de738 27148@opindex mxl-gp-opt
ddf6fe37 27149@item -mxl-gp-opt
d77de738
ML
27150Use GP-relative @code{.sdata}/@code{.sbss} sections.
27151
d77de738 27152@opindex mxl-multiply-high
ddf6fe37 27153@item -mxl-multiply-high
d77de738
ML
27154Use multiply high instructions for high part of 32x32 multiply.
27155
d77de738 27156@opindex mxl-float-convert
ddf6fe37 27157@item -mxl-float-convert
d77de738
ML
27158Use hardware floating-point conversion instructions.
27159
d77de738 27160@opindex mxl-float-sqrt
ddf6fe37 27161@item -mxl-float-sqrt
d77de738
ML
27162Use hardware floating-point square root instruction.
27163
d77de738 27164@opindex mbig-endian
ddf6fe37 27165@item -mbig-endian
d77de738
ML
27166Generate code for a big-endian target.
27167
d77de738 27168@opindex mlittle-endian
ddf6fe37 27169@item -mlittle-endian
d77de738
ML
27170Generate code for a little-endian target.
27171
d77de738 27172@opindex mxl-reorder
ddf6fe37 27173@item -mxl-reorder
d77de738
ML
27174Use reorder instructions (swap and byte reversed load/store).
27175
27176@item -mxl-mode-@var{app-model}
27177Select application model @var{app-model}. Valid models are
27178@table @samp
27179@item executable
27180normal executable (default), uses startup code @file{crt0.o}.
27181
27182@item xmdstub
27183for use with Xilinx Microprocessor Debugger (XMD) based
27184software intrusive debug agent called xmdstub. This uses startup file
27185@file{crt1.o} and sets the start address of the program to 0x800.
27186
27187@item bootstrap
27188for applications that are loaded using a bootloader.
27189This model uses startup file @file{crt2.o} which does not contain a processor
27190reset vector handler. This is suitable for transferring control on a
27191processor reset to the bootloader rather than the application.
27192
27193@item novectors
27194for applications that do not require any of the
27195MicroBlaze vectors. This option may be useful for applications running
27196within a monitoring application. This model uses @file{crt3.o} as a startup file.
27197@end table
27198
27199Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
27200@option{-mxl-mode-@var{app-model}}.
27201
d77de738 27202@opindex mpic-data-is-text-relative
ddf6fe37 27203@item -mpic-data-is-text-relative
d77de738
ML
27204Assume that the displacement between the text and data segments is fixed
27205at static link time. This allows data to be referenced by offset from start of
27206text address instead of GOT since PC-relative addressing is not supported.
27207
27208@end table
27209
27210@node MIPS Options
27211@subsection MIPS Options
27212@cindex MIPS options
27213
27214@table @gcctabopt
27215
d77de738 27216@opindex EB
ddf6fe37 27217@item -EB
d77de738
ML
27218Generate big-endian code.
27219
d77de738 27220@opindex EL
ddf6fe37 27221@item -EL
d77de738
ML
27222Generate little-endian code. This is the default for @samp{mips*el-*-*}
27223configurations.
27224
d77de738 27225@opindex march
ddf6fe37 27226@item -march=@var{arch}
d77de738
ML
27227Generate code that runs on @var{arch}, which can be the name of a
27228generic MIPS ISA, or the name of a particular processor.
27229The ISA names are:
27230@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
27231@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
27232@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
27233@samp{mips64r5} and @samp{mips64r6}.
27234The processor names are:
27235@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
27236@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
27237@samp{5kc}, @samp{5kf},
27238@samp{20kc},
27239@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
27240@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
27241@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
27242@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
27243@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
27244@samp{i6400}, @samp{i6500},
27245@samp{interaptiv},
27246@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
27247@samp{gs464e}, @samp{gs264e},
27248@samp{m4k},
27249@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
27250@samp{m5100}, @samp{m5101},
27251@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
27252@samp{orion},
27253@samp{p5600}, @samp{p6600},
27254@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
27255@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
27256@samp{r6000}, @samp{r8000},
27257@samp{rm7000}, @samp{rm9000},
27258@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
27259@samp{sb1},
27260@samp{sr71000},
27261@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
27262@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
27263@samp{xlr} and @samp{xlp}.
27264The special value @samp{from-abi} selects the
27265most compatible architecture for the selected ABI (that is,
27266@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
27267
27268The native Linux/GNU toolchain also supports the value @samp{native},
27269which selects the best architecture option for the host processor.
27270@option{-march=native} has no effect if GCC does not recognize
27271the processor.
27272
27273In processor names, a final @samp{000} can be abbreviated as @samp{k}
27274(for example, @option{-march=r2k}). Prefixes are optional, and
27275@samp{vr} may be written @samp{r}.
27276
27277Names of the form @samp{@var{n}f2_1} refer to processors with
27278FPUs clocked at half the rate of the core, names of the form
27279@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
27280rate as the core, and names of the form @samp{@var{n}f3_2} refer to
27281processors with FPUs clocked a ratio of 3:2 with respect to the core.
27282For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
27283for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
27284accepted as synonyms for @samp{@var{n}f1_1}.
27285
27286GCC defines two macros based on the value of this option. The first
27287is @code{_MIPS_ARCH}, which gives the name of target architecture, as
27288a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
27289where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
27290For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
27291to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
27292
27293Note that the @code{_MIPS_ARCH} macro uses the processor names given
27294above. In other words, it has the full prefix and does not
27295abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
27296the macro names the resolved architecture (either @code{"mips1"} or
27297@code{"mips3"}). It names the default architecture when no
27298@option{-march} option is given.
27299
d77de738 27300@opindex mtune
ddf6fe37 27301@item -mtune=@var{arch}
d77de738
ML
27302Optimize for @var{arch}. Among other things, this option controls
27303the way instructions are scheduled, and the perceived cost of arithmetic
27304operations. The list of @var{arch} values is the same as for
27305@option{-march}.
27306
27307When this option is not used, GCC optimizes for the processor
27308specified by @option{-march}. By using @option{-march} and
27309@option{-mtune} together, it is possible to generate code that
27310runs on a family of processors, but optimize the code for one
27311particular member of that family.
27312
27313@option{-mtune} defines the macros @code{_MIPS_TUNE} and
27314@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
27315@option{-march} ones described above.
27316
d77de738 27317@opindex mips1
ddf6fe37 27318@item -mips1
d77de738
ML
27319Equivalent to @option{-march=mips1}.
27320
d77de738 27321@opindex mips2
ddf6fe37 27322@item -mips2
d77de738
ML
27323Equivalent to @option{-march=mips2}.
27324
d77de738 27325@opindex mips3
ddf6fe37 27326@item -mips3
d77de738
ML
27327Equivalent to @option{-march=mips3}.
27328
d77de738 27329@opindex mips4
ddf6fe37 27330@item -mips4
d77de738
ML
27331Equivalent to @option{-march=mips4}.
27332
d77de738 27333@opindex mips32
ddf6fe37 27334@item -mips32
d77de738
ML
27335Equivalent to @option{-march=mips32}.
27336
d77de738 27337@opindex mips32r3
ddf6fe37 27338@item -mips32r3
d77de738
ML
27339Equivalent to @option{-march=mips32r3}.
27340
d77de738 27341@opindex mips32r5
ddf6fe37 27342@item -mips32r5
d77de738
ML
27343Equivalent to @option{-march=mips32r5}.
27344
d77de738 27345@opindex mips32r6
ddf6fe37 27346@item -mips32r6
d77de738
ML
27347Equivalent to @option{-march=mips32r6}.
27348
d77de738 27349@opindex mips64
ddf6fe37 27350@item -mips64
d77de738
ML
27351Equivalent to @option{-march=mips64}.
27352
d77de738 27353@opindex mips64r2
ddf6fe37 27354@item -mips64r2
d77de738
ML
27355Equivalent to @option{-march=mips64r2}.
27356
d77de738 27357@opindex mips64r3
ddf6fe37 27358@item -mips64r3
d77de738
ML
27359Equivalent to @option{-march=mips64r3}.
27360
d77de738 27361@opindex mips64r5
ddf6fe37 27362@item -mips64r5
d77de738
ML
27363Equivalent to @option{-march=mips64r5}.
27364
d77de738 27365@opindex mips64r6
ddf6fe37 27366@item -mips64r6
d77de738
ML
27367Equivalent to @option{-march=mips64r6}.
27368
d77de738
ML
27369@opindex mips16
27370@opindex mno-mips16
ddf6fe37
AA
27371@item -mips16
27372@itemx -mno-mips16
d77de738
ML
27373Generate (do not generate) MIPS16 code. If GCC is targeting a
27374MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
27375
27376MIPS16 code generation can also be controlled on a per-function basis
27377by means of @code{mips16} and @code{nomips16} attributes.
27378@xref{Function Attributes}, for more information.
27379
926f2d09
JM
27380@opindex mmips16e2
27381@opindex mno-mips16e2
27382@item -mmips16e2
27383@itemx -mno-mips16e2
27384Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
27385of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
27386
d77de738 27387@opindex mflip-mips16
ddf6fe37 27388@item -mflip-mips16
d77de738
ML
27389Generate MIPS16 code on alternating functions. This option is provided
27390for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
27391not intended for ordinary use in compiling user code.
27392
d77de738
ML
27393@opindex minterlink-compressed
27394@opindex mno-interlink-compressed
ddf6fe37
AA
27395@item -minterlink-compressed
27396@itemx -mno-interlink-compressed
d77de738
ML
27397Require (do not require) that code using the standard (uncompressed) MIPS ISA
27398be link-compatible with MIPS16 and microMIPS code, and vice versa.
27399
27400For example, code using the standard ISA encoding cannot jump directly
27401to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
27402@option{-minterlink-compressed} therefore disables direct jumps unless GCC
27403knows that the target of the jump is not compressed.
27404
d77de738
ML
27405@opindex minterlink-mips16
27406@opindex mno-interlink-mips16
ddf6fe37
AA
27407@item -minterlink-mips16
27408@itemx -mno-interlink-mips16
d77de738
ML
27409Aliases of @option{-minterlink-compressed} and
27410@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
27411and are retained for backwards compatibility.
27412
d77de738
ML
27413@opindex mabi=32
27414@opindex mabi=o64
27415@opindex mabi=n32
27416@opindex mabi=64
27417@opindex mabi=eabi
ddf6fe37
AA
27418@item -mabi=32
27419@itemx -mabi=o64
27420@itemx -mabi=n32
27421@itemx -mabi=64
27422@itemx -mabi=eabi
d77de738
ML
27423Generate code for the given ABI@.
27424
27425Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
27426generates 64-bit code when you select a 64-bit architecture, but you
27427can use @option{-mgp32} to get 32-bit code instead.
27428
27429For information about the O64 ABI, see
27430@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
27431
27432GCC supports a variant of the o32 ABI in which floating-point registers
27433are 64 rather than 32 bits wide. You can select this combination with
27434@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
27435and @code{mfhc1} instructions and is therefore only supported for
27436MIPS32R2, MIPS32R3 and MIPS32R5 processors.
27437
27438The register assignments for arguments and return values remain the
27439same, but each scalar value is passed in a single 64-bit register
27440rather than a pair of 32-bit registers. For example, scalar
27441floating-point values are returned in @samp{$f0} only, not a
27442@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
27443remains the same in that the even-numbered double-precision registers
27444are saved.
27445
27446Two additional variants of the o32 ABI are supported to enable
27447a transition from 32-bit to 64-bit registers. These are FPXX
27448(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
27449The FPXX extension mandates that all code must execute correctly
27450when run using 32-bit or 64-bit registers. The code can be interlinked
27451with either FP32 or FP64, but not both.
27452The FP64A extension is similar to the FP64 extension but forbids the
27453use of odd-numbered single-precision registers. This can be used
27454in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
27455processors and allows both FP32 and FP64A code to interlink and
27456run in the same process without changing FPU modes.
27457
d77de738
ML
27458@opindex mabicalls
27459@opindex mno-abicalls
ddf6fe37
AA
27460@item -mabicalls
27461@itemx -mno-abicalls
d77de738
ML
27462Generate (do not generate) code that is suitable for SVR4-style
27463dynamic objects. @option{-mabicalls} is the default for SVR4-based
27464systems.
27465
27466@item -mshared
27467@itemx -mno-shared
27468Generate (do not generate) code that is fully position-independent,
27469and that can therefore be linked into shared libraries. This option
27470only affects @option{-mabicalls}.
27471
27472All @option{-mabicalls} code has traditionally been position-independent,
27473regardless of options like @option{-fPIC} and @option{-fpic}. However,
27474as an extension, the GNU toolchain allows executables to use absolute
27475accesses for locally-binding symbols. It can also use shorter GP
27476initialization sequences and generate direct calls to locally-defined
27477functions. This mode is selected by @option{-mno-shared}.
27478
27479@option{-mno-shared} depends on binutils 2.16 or higher and generates
27480objects that can only be linked by the GNU linker. However, the option
27481does not affect the ABI of the final executable; it only affects the ABI
27482of relocatable objects. Using @option{-mno-shared} generally makes
27483executables both smaller and quicker.
27484
27485@option{-mshared} is the default.
27486
d77de738
ML
27487@opindex mplt
27488@opindex mno-plt
ddf6fe37
AA
27489@item -mplt
27490@itemx -mno-plt
d77de738
ML
27491Assume (do not assume) that the static and dynamic linkers
27492support PLTs and copy relocations. This option only affects
27493@option{-mno-shared -mabicalls}. For the n64 ABI, this option
27494has no effect without @option{-msym32}.
27495
27496You can make @option{-mplt} the default by configuring
27497GCC with @option{--with-mips-plt}. The default is
27498@option{-mno-plt} otherwise.
27499
d77de738
ML
27500@opindex mxgot
27501@opindex mno-xgot
ddf6fe37
AA
27502@item -mxgot
27503@itemx -mno-xgot
d77de738
ML
27504Lift (do not lift) the usual restrictions on the size of the global
27505offset table.
27506
27507GCC normally uses a single instruction to load values from the GOT@.
27508While this is relatively efficient, it only works if the GOT
27509is smaller than about 64k. Anything larger causes the linker
27510to report an error such as:
27511
27512@cindex relocation truncated to fit (MIPS)
27513@smallexample
27514relocation truncated to fit: R_MIPS_GOT16 foobar
27515@end smallexample
27516
27517If this happens, you should recompile your code with @option{-mxgot}.
27518This works with very large GOTs, although the code is also
27519less efficient, since it takes three instructions to fetch the
27520value of a global symbol.
27521
27522Note that some linkers can create multiple GOTs. If you have such a
27523linker, you should only need to use @option{-mxgot} when a single object
27524file accesses more than 64k's worth of GOT entries. Very few do.
27525
27526These options have no effect unless GCC is generating position
27527independent code.
27528
d77de738 27529@opindex mgp32
ddf6fe37 27530@item -mgp32
d77de738
ML
27531Assume that general-purpose registers are 32 bits wide.
27532
d77de738 27533@opindex mgp64
ddf6fe37 27534@item -mgp64
d77de738
ML
27535Assume that general-purpose registers are 64 bits wide.
27536
d77de738 27537@opindex mfp32
ddf6fe37 27538@item -mfp32
d77de738
ML
27539Assume that floating-point registers are 32 bits wide.
27540
d77de738 27541@opindex mfp64
ddf6fe37 27542@item -mfp64
d77de738
ML
27543Assume that floating-point registers are 64 bits wide.
27544
d77de738 27545@opindex mfpxx
ddf6fe37 27546@item -mfpxx
d77de738
ML
27547Do not assume the width of floating-point registers.
27548
d77de738 27549@opindex mhard-float
ddf6fe37 27550@item -mhard-float
d77de738
ML
27551Use floating-point coprocessor instructions.
27552
d77de738 27553@opindex msoft-float
ddf6fe37 27554@item -msoft-float
d77de738
ML
27555Do not use floating-point coprocessor instructions. Implement
27556floating-point calculations using library calls instead.
27557
d77de738 27558@opindex mno-float
ddf6fe37 27559@item -mno-float
d77de738
ML
27560Equivalent to @option{-msoft-float}, but additionally asserts that the
27561program being compiled does not perform any floating-point operations.
27562This option is presently supported only by some bare-metal MIPS
27563configurations, where it may select a special set of libraries
27564that lack all floating-point support (including, for example, the
27565floating-point @code{printf} formats).
27566If code compiled with @option{-mno-float} accidentally contains
27567floating-point operations, it is likely to suffer a link-time
27568or run-time failure.
27569
d77de738 27570@opindex msingle-float
ddf6fe37 27571@item -msingle-float
d77de738
ML
27572Assume that the floating-point coprocessor only supports single-precision
27573operations.
27574
d77de738 27575@opindex mdouble-float
ddf6fe37 27576@item -mdouble-float
d77de738
ML
27577Assume that the floating-point coprocessor supports double-precision
27578operations. This is the default.
27579
d77de738
ML
27580@opindex modd-spreg
27581@opindex mno-odd-spreg
ddf6fe37
AA
27582@item -modd-spreg
27583@itemx -mno-odd-spreg
d77de738
ML
27584Enable the use of odd-numbered single-precision floating-point registers
27585for the o32 ABI. This is the default for processors that are known to
27586support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
27587is set by default.
27588
d77de738
ML
27589@opindex mabs=2008
27590@opindex mabs=legacy
ddf6fe37
AA
27591@item -mabs=2008
27592@itemx -mabs=legacy
d77de738
ML
27593These options control the treatment of the special not-a-number (NaN)
27594IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
27595@code{neg.@i{fmt}} machine instructions.
27596
27597By default or when @option{-mabs=legacy} is used the legacy
27598treatment is selected. In this case these instructions are considered
27599arithmetic and avoided where correct operation is required and the
27600input operand might be a NaN. A longer sequence of instructions that
27601manipulate the sign bit of floating-point datum manually is used
27602instead unless the @option{-ffinite-math-only} option has also been
27603specified.
27604
27605The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
27606this case these instructions are considered non-arithmetic and therefore
27607operating correctly in all cases, including in particular where the
27608input operand is a NaN. These instructions are therefore always used
27609for the respective operations.
27610
d77de738
ML
27611@opindex mnan=2008
27612@opindex mnan=legacy
ddf6fe37
AA
27613@item -mnan=2008
27614@itemx -mnan=legacy
d77de738
ML
27615These options control the encoding of the special not-a-number (NaN)
27616IEEE 754 floating-point data.
27617
27618The @option{-mnan=legacy} option selects the legacy encoding. In this
27619case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
27620significand field being 0, whereas signaling NaNs (sNaNs) are denoted
27621by the first bit of their trailing significand field being 1.
27622
27623The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
27624this case qNaNs are denoted by the first bit of their trailing
27625significand field being 1, whereas sNaNs are denoted by the first bit of
27626their trailing significand field being 0.
27627
27628The default is @option{-mnan=legacy} unless GCC has been configured with
27629@option{--with-nan=2008}.
27630
d77de738
ML
27631@opindex mllsc
27632@opindex mno-llsc
ddf6fe37
AA
27633@item -mllsc
27634@itemx -mno-llsc
d77de738
ML
27635Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
27636implement atomic memory built-in functions. When neither option is
27637specified, GCC uses the instructions if the target architecture
27638supports them.
27639
27640@option{-mllsc} is useful if the runtime environment can emulate the
27641instructions and @option{-mno-llsc} can be useful when compiling for
27642nonstandard ISAs. You can make either option the default by
27643configuring GCC with @option{--with-llsc} and @option{--without-llsc}
27644respectively. @option{--with-llsc} is the default for some
27645configurations; see the installation documentation for details.
27646
d77de738
ML
27647@opindex mdsp
27648@opindex mno-dsp
ddf6fe37
AA
27649@item -mdsp
27650@itemx -mno-dsp
d77de738
ML
27651Use (do not use) revision 1 of the MIPS DSP ASE@.
27652@xref{MIPS DSP Built-in Functions}. This option defines the
27653preprocessor macro @code{__mips_dsp}. It also defines
27654@code{__mips_dsp_rev} to 1.
27655
d77de738
ML
27656@opindex mdspr2
27657@opindex mno-dspr2
ddf6fe37
AA
27658@item -mdspr2
27659@itemx -mno-dspr2
d77de738
ML
27660Use (do not use) revision 2 of the MIPS DSP ASE@.
27661@xref{MIPS DSP Built-in Functions}. This option defines the
27662preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
27663It also defines @code{__mips_dsp_rev} to 2.
27664
d77de738
ML
27665@opindex msmartmips
27666@opindex mno-smartmips
ddf6fe37
AA
27667@item -msmartmips
27668@itemx -mno-smartmips
d77de738
ML
27669Use (do not use) the MIPS SmartMIPS ASE.
27670
d77de738
ML
27671@opindex mpaired-single
27672@opindex mno-paired-single
ddf6fe37
AA
27673@item -mpaired-single
27674@itemx -mno-paired-single
d77de738
ML
27675Use (do not use) paired-single floating-point instructions.
27676@xref{MIPS Paired-Single Support}. This option requires
27677hardware floating-point support to be enabled.
27678
d77de738
ML
27679@opindex mdmx
27680@opindex mno-mdmx
ddf6fe37
AA
27681@item -mdmx
27682@itemx -mno-mdmx
d77de738
ML
27683Use (do not use) MIPS Digital Media Extension instructions.
27684This option can only be used when generating 64-bit code and requires
27685hardware floating-point support to be enabled.
27686
d77de738
ML
27687@opindex mips3d
27688@opindex mno-mips3d
ddf6fe37
AA
27689@item -mips3d
27690@itemx -mno-mips3d
d77de738
ML
27691Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27692The option @option{-mips3d} implies @option{-mpaired-single}.
27693
d77de738
ML
27694@opindex mmicromips
27695@opindex mno-mmicromips
ddf6fe37
AA
27696@item -mmicromips
27697@itemx -mno-micromips
d77de738
ML
27698Generate (do not generate) microMIPS code.
27699
27700MicroMIPS code generation can also be controlled on a per-function basis
27701by means of @code{micromips} and @code{nomicromips} attributes.
27702@xref{Function Attributes}, for more information.
27703
d77de738
ML
27704@opindex mmt
27705@opindex mno-mt
ddf6fe37
AA
27706@item -mmt
27707@itemx -mno-mt
d77de738
ML
27708Use (do not use) MT Multithreading instructions.
27709
d77de738
ML
27710@opindex mmcu
27711@opindex mno-mcu
ddf6fe37
AA
27712@item -mmcu
27713@itemx -mno-mcu
d77de738
ML
27714Use (do not use) the MIPS MCU ASE instructions.
27715
d77de738
ML
27716@opindex meva
27717@opindex mno-eva
ddf6fe37
AA
27718@item -meva
27719@itemx -mno-eva
d77de738
ML
27720Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27721
d77de738
ML
27722@opindex mvirt
27723@opindex mno-virt
ddf6fe37
AA
27724@item -mvirt
27725@itemx -mno-virt
d77de738
ML
27726Use (do not use) the MIPS Virtualization (VZ) instructions.
27727
d77de738
ML
27728@opindex mxpa
27729@opindex mno-xpa
ddf6fe37
AA
27730@item -mxpa
27731@itemx -mno-xpa
d77de738
ML
27732Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27733
d77de738
ML
27734@opindex mcrc
27735@opindex mno-crc
ddf6fe37
AA
27736@item -mcrc
27737@itemx -mno-crc
d77de738
ML
27738Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27739
d77de738
ML
27740@opindex mginv
27741@opindex mno-ginv
ddf6fe37
AA
27742@item -mginv
27743@itemx -mno-ginv
d77de738
ML
27744Use (do not use) the MIPS Global INValidate (GINV) instructions.
27745
d77de738
ML
27746@opindex mloongson-mmi
27747@opindex mno-loongson-mmi
ddf6fe37
AA
27748@item -mloongson-mmi
27749@itemx -mno-loongson-mmi
d77de738
ML
27750Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27751
d77de738
ML
27752@opindex mloongson-ext
27753@opindex mno-loongson-ext
ddf6fe37
AA
27754@item -mloongson-ext
27755@itemx -mno-loongson-ext
d77de738
ML
27756Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27757
d77de738
ML
27758@opindex mloongson-ext2
27759@opindex mno-loongson-ext2
ddf6fe37
AA
27760@item -mloongson-ext2
27761@itemx -mno-loongson-ext2
d77de738
ML
27762Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27763
d77de738 27764@opindex mlong64
ddf6fe37 27765@item -mlong64
d77de738
ML
27766Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27767an explanation of the default and the way that the pointer size is
27768determined.
27769
d77de738 27770@opindex mlong32
ddf6fe37 27771@item -mlong32
d77de738
ML
27772Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27773
27774The default size of @code{int}s, @code{long}s and pointers depends on
27775the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27776uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2777732-bit @code{long}s. Pointers are the same size as @code{long}s,
27778or the same size as integer registers, whichever is smaller.
27779
d77de738
ML
27780@opindex msym32
27781@opindex mno-sym32
ddf6fe37
AA
27782@item -msym32
27783@itemx -mno-sym32
d77de738
ML
27784Assume (do not assume) that all symbols have 32-bit values, regardless
27785of the selected ABI@. This option is useful in combination with
27786@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27787to generate shorter and faster references to symbolic addresses.
27788
d77de738 27789@opindex G
ddf6fe37 27790@item -G @var{num}
d77de738
ML
27791Put definitions of externally-visible data in a small data section
27792if that data is no bigger than @var{num} bytes. GCC can then generate
27793more efficient accesses to the data; see @option{-mgpopt} for details.
27794
27795The default @option{-G} option depends on the configuration.
27796
d77de738
ML
27797@opindex mlocal-sdata
27798@opindex mno-local-sdata
ddf6fe37
AA
27799@item -mlocal-sdata
27800@itemx -mno-local-sdata
d77de738
ML
27801Extend (do not extend) the @option{-G} behavior to local data too,
27802such as to static variables in C@. @option{-mlocal-sdata} is the
27803default for all configurations.
27804
27805If the linker complains that an application is using too much small data,
27806you might want to try rebuilding the less performance-critical parts with
27807@option{-mno-local-sdata}. You might also want to build large
27808libraries with @option{-mno-local-sdata}, so that the libraries leave
27809more room for the main program.
27810
d77de738
ML
27811@opindex mextern-sdata
27812@opindex mno-extern-sdata
ddf6fe37
AA
27813@item -mextern-sdata
27814@itemx -mno-extern-sdata
d77de738
ML
27815Assume (do not assume) that externally-defined data is in
27816a small data section if the size of that data is within the @option{-G} limit.
27817@option{-mextern-sdata} is the default for all configurations.
27818
27819If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27820@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27821that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27822is placed in a small data section. If @var{Var} is defined by another
27823module, you must either compile that module with a high-enough
27824@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27825definition. If @var{Var} is common, you must link the application
27826with a high-enough @option{-G} setting.
27827
27828The easiest way of satisfying these restrictions is to compile
27829and link every module with the same @option{-G} option. However,
27830you may wish to build a library that supports several different
27831small data limits. You can do this by compiling the library with
27832the highest supported @option{-G} setting and additionally using
27833@option{-mno-extern-sdata} to stop the library from making assumptions
27834about externally-defined data.
27835
d77de738
ML
27836@opindex mgpopt
27837@opindex mno-gpopt
ddf6fe37
AA
27838@item -mgpopt
27839@itemx -mno-gpopt
d77de738
ML
27840Use (do not use) GP-relative accesses for symbols that are known to be
27841in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27842@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27843configurations.
27844
27845@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27846might not hold the value of @code{_gp}. For example, if the code is
27847part of a library that might be used in a boot monitor, programs that
27848call boot monitor routines pass an unknown value in @code{$gp}.
27849(In such situations, the boot monitor itself is usually compiled
27850with @option{-G0}.)
27851
27852@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27853@option{-mno-extern-sdata}.
27854
d77de738
ML
27855@opindex membedded-data
27856@opindex mno-embedded-data
ddf6fe37
AA
27857@item -membedded-data
27858@itemx -mno-embedded-data
d77de738
ML
27859Allocate variables to the read-only data section first if possible, then
27860next in the small data section if possible, otherwise in data. This gives
27861slightly slower code than the default, but reduces the amount of RAM required
27862when executing, and thus may be preferred for some embedded systems.
27863
d77de738
ML
27864@opindex muninit-const-in-rodata
27865@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27866@item -muninit-const-in-rodata
27867@itemx -mno-uninit-const-in-rodata
d77de738
ML
27868Put uninitialized @code{const} variables in the read-only data section.
27869This option is only meaningful in conjunction with @option{-membedded-data}.
27870
d77de738 27871@opindex mcode-readable
ddf6fe37 27872@item -mcode-readable=@var{setting}
d77de738
ML
27873Specify whether GCC may generate code that reads from executable sections.
27874There are three possible settings:
27875
27876@table @gcctabopt
27877@item -mcode-readable=yes
27878Instructions may freely access executable sections. This is the
27879default setting.
27880
27881@item -mcode-readable=pcrel
27882MIPS16 PC-relative load instructions can access executable sections,
27883but other instructions must not do so. This option is useful on 4KSc
27884and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27885It is also useful on processors that can be configured to have a dual
27886instruction/data SRAM interface and that, like the M4K, automatically
27887redirect PC-relative loads to the instruction RAM.
27888
27889@item -mcode-readable=no
27890Instructions must not access executable sections. This option can be
27891useful on targets that are configured to have a dual instruction/data
27892SRAM interface but that (unlike the M4K) do not automatically redirect
27893PC-relative loads to the instruction RAM.
27894@end table
27895
d77de738
ML
27896@opindex msplit-addresses
27897@opindex mno-split-addresses
ddf6fe37
AA
27898@item -msplit-addresses
27899@itemx -mno-split-addresses
d77de738
ML
27900Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27901relocation operators. This option has been superseded by
27902@option{-mexplicit-relocs} but is retained for backwards compatibility.
27903
d77de738
ML
27904@opindex mexplicit-relocs
27905@opindex mno-explicit-relocs
ddf6fe37
AA
27906@item -mexplicit-relocs
27907@itemx -mno-explicit-relocs
d77de738
ML
27908Use (do not use) assembler relocation operators when dealing with symbolic
27909addresses. The alternative, selected by @option{-mno-explicit-relocs},
27910is to use assembler macros instead.
27911
27912@option{-mexplicit-relocs} is the default if GCC was configured
27913to use an assembler that supports relocation operators.
27914
d77de738
ML
27915@opindex mcheck-zero-division
27916@opindex mno-check-zero-division
ddf6fe37
AA
27917@item -mcheck-zero-division
27918@itemx -mno-check-zero-division
d77de738
ML
27919Trap (do not trap) on integer division by zero.
27920
27921The default is @option{-mcheck-zero-division}.
27922
d77de738
ML
27923@opindex mdivide-traps
27924@opindex mdivide-breaks
ddf6fe37
AA
27925@item -mdivide-traps
27926@itemx -mdivide-breaks
d77de738
ML
27927MIPS systems check for division by zero by generating either a
27928conditional trap or a break instruction. Using traps results in
27929smaller code, but is only supported on MIPS II and later. Also, some
27930versions of the Linux kernel have a bug that prevents trap from
27931generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27932allow conditional traps on architectures that support them and
27933@option{-mdivide-breaks} to force the use of breaks.
27934
27935The default is usually @option{-mdivide-traps}, but this can be
27936overridden at configure time using @option{--with-divide=breaks}.
27937Divide-by-zero checks can be completely disabled using
27938@option{-mno-check-zero-division}.
27939
d77de738
ML
27940@opindex mload-store-pairs
27941@opindex mno-load-store-pairs
ddf6fe37
AA
27942@item -mload-store-pairs
27943@itemx -mno-load-store-pairs
d77de738
ML
27944Enable (disable) an optimization that pairs consecutive load or store
27945instructions to enable load/store bonding. This option is enabled by
27946default but only takes effect when the selected architecture is known
27947to support bonding.
27948
d77de738
ML
27949@opindex munaligned-access
27950@opindex mno-unaligned-access
ddf6fe37
AA
27951@item -munaligned-access
27952@itemx -mno-unaligned-access
d77de738
ML
27953Enable (disable) direct unaligned access for MIPS Release 6.
27954MIPSr6 requires load/store unaligned-access support,
27955by hardware or trap&emulate.
27956So @option{-mno-unaligned-access} may be needed by kernel.
27957
d77de738
ML
27958@opindex mmemcpy
27959@opindex mno-memcpy
ddf6fe37
AA
27960@item -mmemcpy
27961@itemx -mno-memcpy
d77de738
ML
27962Force (do not force) the use of @code{memcpy} for non-trivial block
27963moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27964most constant-sized copies.
27965
d77de738
ML
27966@opindex mlong-calls
27967@opindex mno-long-calls
ddf6fe37
AA
27968@item -mlong-calls
27969@itemx -mno-long-calls
d77de738
ML
27970Disable (do not disable) use of the @code{jal} instruction. Calling
27971functions using @code{jal} is more efficient but requires the caller
27972and callee to be in the same 256 megabyte segment.
27973
27974This option has no effect on abicalls code. The default is
27975@option{-mno-long-calls}.
27976
d77de738
ML
27977@opindex mmad
27978@opindex mno-mad
ddf6fe37
AA
27979@item -mmad
27980@itemx -mno-mad
d77de738
ML
27981Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27982instructions, as provided by the R4650 ISA@.
27983
d77de738
ML
27984@opindex mimadd
27985@opindex mno-imadd
ddf6fe37
AA
27986@item -mimadd
27987@itemx -mno-imadd
d77de738
ML
27988Enable (disable) use of the @code{madd} and @code{msub} integer
27989instructions. The default is @option{-mimadd} on architectures
27990that support @code{madd} and @code{msub} except for the 74k
27991architecture where it was found to generate slower code.
27992
d77de738
ML
27993@opindex mfused-madd
27994@opindex mno-fused-madd
ddf6fe37
AA
27995@item -mfused-madd
27996@itemx -mno-fused-madd
d77de738
ML
27997Enable (disable) use of the floating-point multiply-accumulate
27998instructions, when they are available. The default is
27999@option{-mfused-madd}.
28000
28001On the R8000 CPU when multiply-accumulate instructions are used,
28002the intermediate product is calculated to infinite precision
28003and is not subject to the FCSR Flush to Zero bit. This may be
28004undesirable in some circumstances. On other processors the result
28005is numerically identical to the equivalent computation using
28006separate multiply, add, subtract and negate instructions.
28007
d77de738 28008@opindex nocpp
ddf6fe37 28009@item -nocpp
d77de738
ML
28010Tell the MIPS assembler to not run its preprocessor over user
28011assembler files (with a @samp{.s} suffix) when assembling them.
28012
d77de738
ML
28013@opindex mfix-24k
28014@opindex mno-fix-24k
ddf6fe37
AA
28015@item -mfix-24k
28016@itemx -mno-fix-24k
d77de738
ML
28017Work around the 24K E48 (lost data on stores during refill) errata.
28018The workarounds are implemented by the assembler rather than by GCC@.
28019
d77de738
ML
28020@opindex mfix-r4000
28021@opindex mno-fix-r4000
ddf6fe37
AA
28022@item -mfix-r4000
28023@itemx -mno-fix-r4000
d77de738
ML
28024Work around certain R4000 CPU errata:
28025@itemize @minus
28026@item
28027A double-word or a variable shift may give an incorrect result if executed
28028immediately after starting an integer division.
28029@item
28030A double-word or a variable shift may give an incorrect result if executed
28031while an integer multiplication is in progress.
28032@item
28033An integer division may give an incorrect result if started in a delay slot
28034of a taken branch or a jump.
28035@end itemize
28036
d77de738
ML
28037@opindex mfix-r4400
28038@opindex mno-fix-r4400
ddf6fe37
AA
28039@item -mfix-r4400
28040@itemx -mno-fix-r4400
d77de738
ML
28041Work around certain R4400 CPU errata:
28042@itemize @minus
28043@item
28044A double-word or a variable shift may give an incorrect result if executed
28045immediately after starting an integer division.
28046@end itemize
28047
d77de738
ML
28048@opindex mfix-r10000
28049@opindex mno-fix-r10000
ddf6fe37
AA
28050@item -mfix-r10000
28051@itemx -mno-fix-r10000
d77de738
ML
28052Work around certain R10000 errata:
28053@itemize @minus
28054@item
28055@code{ll}/@code{sc} sequences may not behave atomically on revisions
28056prior to 3.0. They may deadlock on revisions 2.6 and earlier.
28057@end itemize
28058
28059This option can only be used if the target architecture supports
28060branch-likely instructions. @option{-mfix-r10000} is the default when
28061@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
28062otherwise.
28063
ddf6fe37 28064@opindex mfix-r5900
d77de738
ML
28065@item -mfix-r5900
28066@itemx -mno-fix-r5900
d77de738
ML
28067Do not attempt to schedule the preceding instruction into the delay slot
28068of a branch instruction placed at the end of a short loop of six
28069instructions or fewer and always schedule a @code{nop} instruction there
28070instead. The short loop bug under certain conditions causes loops to
28071execute only once or twice, due to a hardware bug in the R5900 chip. The
28072workaround is implemented by the assembler rather than by GCC@.
28073
ddf6fe37 28074@opindex mfix-rm7000
d77de738
ML
28075@item -mfix-rm7000
28076@itemx -mno-fix-rm7000
d77de738
ML
28077Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
28078workarounds are implemented by the assembler rather than by GCC@.
28079
ddf6fe37 28080@opindex mfix-vr4120
d77de738
ML
28081@item -mfix-vr4120
28082@itemx -mno-fix-vr4120
d77de738
ML
28083Work around certain VR4120 errata:
28084@itemize @minus
28085@item
28086@code{dmultu} does not always produce the correct result.
28087@item
28088@code{div} and @code{ddiv} do not always produce the correct result if one
28089of the operands is negative.
28090@end itemize
28091The workarounds for the division errata rely on special functions in
28092@file{libgcc.a}. At present, these functions are only provided by
28093the @code{mips64vr*-elf} configurations.
28094
28095Other VR4120 errata require a NOP to be inserted between certain pairs of
28096instructions. These errata are handled by the assembler, not by GCC itself.
28097
d77de738 28098@opindex mfix-vr4130
ddf6fe37 28099@item -mfix-vr4130
d77de738
ML
28100Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
28101workarounds are implemented by the assembler rather than by GCC,
28102although GCC avoids using @code{mflo} and @code{mfhi} if the
28103VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
28104instructions are available instead.
28105
ddf6fe37 28106@opindex mfix-sb1
d77de738
ML
28107@item -mfix-sb1
28108@itemx -mno-fix-sb1
d77de738
ML
28109Work around certain SB-1 CPU core errata.
28110(This flag currently works around the SB-1 revision 2
28111``F1'' and ``F2'' floating-point errata.)
28112
d77de738 28113@opindex mr10k-cache-barrier
ddf6fe37 28114@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
28115Specify whether GCC should insert cache barriers to avoid the
28116side effects of speculation on R10K processors.
28117
28118In common with many processors, the R10K tries to predict the outcome
28119of a conditional branch and speculatively executes instructions from
28120the ``taken'' branch. It later aborts these instructions if the
28121predicted outcome is wrong. However, on the R10K, even aborted
28122instructions can have side effects.
28123
28124This problem only affects kernel stores and, depending on the system,
28125kernel loads. As an example, a speculatively-executed store may load
28126the target memory into cache and mark the cache line as dirty, even if
28127the store itself is later aborted. If a DMA operation writes to the
28128same area of memory before the ``dirty'' line is flushed, the cached
28129data overwrites the DMA-ed data. See the R10K processor manual
28130for a full description, including other potential problems.
28131
28132One workaround is to insert cache barrier instructions before every memory
28133access that might be speculatively executed and that might have side
28134effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
28135controls GCC's implementation of this workaround. It assumes that
28136aborted accesses to any byte in the following regions does not have
28137side effects:
28138
28139@enumerate
28140@item
28141the memory occupied by the current function's stack frame;
28142
28143@item
28144the memory occupied by an incoming stack argument;
28145
28146@item
28147the memory occupied by an object with a link-time-constant address.
28148@end enumerate
28149
28150It is the kernel's responsibility to ensure that speculative
28151accesses to these regions are indeed safe.
28152
28153If the input program contains a function declaration such as:
28154
28155@smallexample
28156void foo (void);
28157@end smallexample
28158
28159then the implementation of @code{foo} must allow @code{j foo} and
28160@code{jal foo} to be executed speculatively. GCC honors this
28161restriction for functions it compiles itself. It expects non-GCC
28162functions (such as hand-written assembly code) to do the same.
28163
28164The option has three forms:
28165
28166@table @gcctabopt
28167@item -mr10k-cache-barrier=load-store
28168Insert a cache barrier before a load or store that might be
28169speculatively executed and that might have side effects even
28170if aborted.
28171
28172@item -mr10k-cache-barrier=store
28173Insert a cache barrier before a store that might be speculatively
28174executed and that might have side effects even if aborted.
28175
28176@item -mr10k-cache-barrier=none
28177Disable the insertion of cache barriers. This is the default setting.
28178@end table
28179
ddf6fe37 28180@opindex mflush-func
d77de738
ML
28181@item -mflush-func=@var{func}
28182@itemx -mno-flush-func
d77de738
ML
28183Specifies the function to call to flush the I and D caches, or to not
28184call any such function. If called, the function must take the same
28185arguments as the common @code{_flush_func}, that is, the address of the
28186memory range for which the cache is being flushed, the size of the
28187memory range, and the number 3 (to flush both caches). The default
28188depends on the target GCC was configured for, but commonly is either
28189@code{_flush_func} or @code{__cpu_flush}.
28190
d77de738 28191@opindex mbranch-cost
ddf6fe37 28192@item mbranch-cost=@var{num}
d77de738
ML
28193Set the cost of branches to roughly @var{num} ``simple'' instructions.
28194This cost is only a heuristic and is not guaranteed to produce
28195consistent results across releases. A zero cost redundantly selects
28196the default, which is based on the @option{-mtune} setting.
28197
d77de738
ML
28198@opindex mbranch-likely
28199@opindex mno-branch-likely
ddf6fe37
AA
28200@item -mbranch-likely
28201@itemx -mno-branch-likely
d77de738
ML
28202Enable or disable use of Branch Likely instructions, regardless of the
28203default for the selected architecture. By default, Branch Likely
28204instructions may be generated if they are supported by the selected
28205architecture. An exception is for the MIPS32 and MIPS64 architectures
28206and processors that implement those architectures; for those, Branch
28207Likely instructions are not be generated by default because the MIPS32
28208and MIPS64 architectures specifically deprecate their use.
28209
d77de738
ML
28210@opindex mcompact-branches=never
28211@opindex mcompact-branches=optimal
28212@opindex mcompact-branches=always
ddf6fe37
AA
28213@item -mcompact-branches=never
28214@itemx -mcompact-branches=optimal
28215@itemx -mcompact-branches=always
d77de738
ML
28216These options control which form of branches will be generated. The
28217default is @option{-mcompact-branches=optimal}.
28218
28219The @option{-mcompact-branches=never} option ensures that compact branch
28220instructions will never be generated.
28221
28222The @option{-mcompact-branches=always} option ensures that a compact
28223branch instruction will be generated if available for MIPS Release 6 onwards.
28224If a compact branch instruction is not available (or pre-R6),
28225a delay slot form of the branch will be used instead.
28226
28227If it is used for MIPS16/microMIPS targets, it will be just ignored now.
28228The behaviour for MIPS16/microMIPS may change in future,
28229since they do have some compact branch instructions.
28230
28231The @option{-mcompact-branches=optimal} option will cause a delay slot
28232branch to be used if one is available in the current ISA and the delay
28233slot is successfully filled. If the delay slot is not filled, a compact
28234branch will be chosen if one is available.
28235
ddf6fe37 28236@opindex mfp-exceptions
d77de738
ML
28237@item -mfp-exceptions
28238@itemx -mno-fp-exceptions
d77de738
ML
28239Specifies whether FP exceptions are enabled. This affects how
28240FP instructions are scheduled for some processors.
28241The default is that FP exceptions are
28242enabled.
28243
28244For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2824564-bit code, then we can use both FP pipes. Otherwise, we can only use one
28246FP pipe.
28247
ddf6fe37 28248@opindex mvr4130-align
d77de738
ML
28249@item -mvr4130-align
28250@itemx -mno-vr4130-align
d77de738
ML
28251The VR4130 pipeline is two-way superscalar, but can only issue two
28252instructions together if the first one is 8-byte aligned. When this
28253option is enabled, GCC aligns pairs of instructions that it
28254thinks should execute in parallel.
28255
28256This option only has an effect when optimizing for the VR4130.
28257It normally makes code faster, but at the expense of making it bigger.
28258It is enabled by default at optimization level @option{-O3}.
28259
ddf6fe37 28260@opindex msynci
d77de738
ML
28261@item -msynci
28262@itemx -mno-synci
d77de738
ML
28263Enable (disable) generation of @code{synci} instructions on
28264architectures that support it. The @code{synci} instructions (if
28265enabled) are generated when @code{__builtin___clear_cache} is
28266compiled.
28267
28268This option defaults to @option{-mno-synci}, but the default can be
28269overridden by configuring GCC with @option{--with-synci}.
28270
28271When compiling code for single processor systems, it is generally safe
28272to use @code{synci}. However, on many multi-core (SMP) systems, it
28273does not invalidate the instruction caches on all cores and may lead
28274to undefined behavior.
28275
ddf6fe37 28276@opindex mrelax-pic-calls
d77de738
ML
28277@item -mrelax-pic-calls
28278@itemx -mno-relax-pic-calls
d77de738
ML
28279Try to turn PIC calls that are normally dispatched via register
28280@code{$25} into direct calls. This is only possible if the linker can
28281resolve the destination at link time and if the destination is within
28282range for a direct call.
28283
28284@option{-mrelax-pic-calls} is the default if GCC was configured to use
28285an assembler and a linker that support the @code{.reloc} assembly
28286directive and @option{-mexplicit-relocs} is in effect. With
28287@option{-mno-explicit-relocs}, this optimization can be performed by the
28288assembler and the linker alone without help from the compiler.
28289
d77de738
ML
28290@opindex mmcount-ra-address
28291@opindex mno-mcount-ra-address
ddf6fe37
AA
28292@item -mmcount-ra-address
28293@itemx -mno-mcount-ra-address
d77de738
ML
28294Emit (do not emit) code that allows @code{_mcount} to modify the
28295calling function's return address. When enabled, this option extends
28296the usual @code{_mcount} interface with a new @var{ra-address}
28297parameter, which has type @code{intptr_t *} and is passed in register
28298@code{$12}. @code{_mcount} can then modify the return address by
28299doing both of the following:
28300@itemize
28301@item
28302Returning the new address in register @code{$31}.
28303@item
28304Storing the new address in @code{*@var{ra-address}},
28305if @var{ra-address} is nonnull.
28306@end itemize
28307
28308The default is @option{-mno-mcount-ra-address}.
28309
ddf6fe37 28310@opindex mframe-header-opt
d77de738
ML
28311@item -mframe-header-opt
28312@itemx -mno-frame-header-opt
d77de738
ML
28313Enable (disable) frame header optimization in the o32 ABI. When using the
28314o32 ABI, calling functions will allocate 16 bytes on the stack for the called
28315function to write out register arguments. When enabled, this optimization
28316will suppress the allocation of the frame header if it can be determined that
28317it is unused.
28318
28319This optimization is off by default at all optimization levels.
28320
ddf6fe37 28321@opindex mlxc1-sxc1
d77de738
ML
28322@item -mlxc1-sxc1
28323@itemx -mno-lxc1-sxc1
d77de738
ML
28324When applicable, enable (disable) the generation of @code{lwxc1},
28325@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
28326
ddf6fe37 28327@opindex mmadd4
d77de738
ML
28328@item -mmadd4
28329@itemx -mno-madd4
d77de738
ML
28330When applicable, enable (disable) the generation of 4-operand @code{madd.s},
28331@code{madd.d} and related instructions. Enabled by default.
28332
28333@end table
28334
28335@node MMIX Options
28336@subsection MMIX Options
28337@cindex MMIX Options
28338
28339These options are defined for the MMIX:
28340
28341@table @gcctabopt
d77de738
ML
28342@opindex mlibfuncs
28343@opindex mno-libfuncs
ddf6fe37
AA
28344@item -mlibfuncs
28345@itemx -mno-libfuncs
d77de738
ML
28346Specify that intrinsic library functions are being compiled, passing all
28347values in registers, no matter the size.
28348
d77de738
ML
28349@opindex mepsilon
28350@opindex mno-epsilon
ddf6fe37
AA
28351@item -mepsilon
28352@itemx -mno-epsilon
d77de738
ML
28353Generate floating-point comparison instructions that compare with respect
28354to the @code{rE} epsilon register.
28355
d77de738
ML
28356@opindex mabi=mmixware
28357@opindex mabi=gnu
ddf6fe37
AA
28358@item -mabi=mmixware
28359@itemx -mabi=gnu
d77de738
ML
28360Generate code that passes function parameters and return values that (in
28361the called function) are seen as registers @code{$0} and up, as opposed to
28362the GNU ABI which uses global registers @code{$231} and up.
28363
d77de738
ML
28364@opindex mzero-extend
28365@opindex mno-zero-extend
ddf6fe37
AA
28366@item -mzero-extend
28367@itemx -mno-zero-extend
d77de738
ML
28368When reading data from memory in sizes shorter than 64 bits, use (do not
28369use) zero-extending load instructions by default, rather than
28370sign-extending ones.
28371
d77de738
ML
28372@opindex mknuthdiv
28373@opindex mno-knuthdiv
ddf6fe37
AA
28374@item -mknuthdiv
28375@itemx -mno-knuthdiv
d77de738
ML
28376Make the result of a division yielding a remainder have the same sign as
28377the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
28378remainder follows the sign of the dividend. Both methods are
28379arithmetically valid, the latter being almost exclusively used.
28380
d77de738
ML
28381@opindex mtoplevel-symbols
28382@opindex mno-toplevel-symbols
ddf6fe37
AA
28383@item -mtoplevel-symbols
28384@itemx -mno-toplevel-symbols
d77de738
ML
28385Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
28386code can be used with the @code{PREFIX} assembly directive.
28387
d77de738 28388@opindex melf
ddf6fe37 28389@item -melf
d77de738
ML
28390Generate an executable in the ELF format, rather than the default
28391@samp{mmo} format used by the @command{mmix} simulator.
28392
d77de738
ML
28393@opindex mbranch-predict
28394@opindex mno-branch-predict
ddf6fe37
AA
28395@item -mbranch-predict
28396@itemx -mno-branch-predict
d77de738
ML
28397Use (do not use) the probable-branch instructions, when static branch
28398prediction indicates a probable branch.
28399
d77de738
ML
28400@opindex mbase-addresses
28401@opindex mno-base-addresses
ddf6fe37
AA
28402@item -mbase-addresses
28403@itemx -mno-base-addresses
d77de738
ML
28404Generate (do not generate) code that uses @emph{base addresses}. Using a
28405base address automatically generates a request (handled by the assembler
28406and the linker) for a constant to be set up in a global register. The
28407register is used for one or more base address requests within the range 0
28408to 255 from the value held in the register. The generally leads to short
28409and fast code, but the number of different data items that can be
28410addressed is limited. This means that a program that uses lots of static
28411data may require @option{-mno-base-addresses}.
28412
d77de738
ML
28413@opindex msingle-exit
28414@opindex mno-single-exit
ddf6fe37
AA
28415@item -msingle-exit
28416@itemx -mno-single-exit
d77de738
ML
28417Force (do not force) generated code to have a single exit point in each
28418function.
28419@end table
28420
28421@node MN10300 Options
28422@subsection MN10300 Options
28423@cindex MN10300 options
28424
28425These @option{-m} options are defined for Matsushita MN10300 architectures:
28426
28427@table @gcctabopt
d77de738 28428@opindex mmult-bug
ddf6fe37 28429@item -mmult-bug
d77de738
ML
28430Generate code to avoid bugs in the multiply instructions for the MN10300
28431processors. This is the default.
28432
d77de738 28433@opindex mno-mult-bug
ddf6fe37 28434@item -mno-mult-bug
d77de738
ML
28435Do not generate code to avoid bugs in the multiply instructions for the
28436MN10300 processors.
28437
d77de738 28438@opindex mam33
ddf6fe37 28439@item -mam33
d77de738
ML
28440Generate code using features specific to the AM33 processor.
28441
d77de738 28442@opindex mno-am33
ddf6fe37 28443@item -mno-am33
d77de738
ML
28444Do not generate code using features specific to the AM33 processor. This
28445is the default.
28446
d77de738 28447@opindex mam33-2
ddf6fe37 28448@item -mam33-2
d77de738
ML
28449Generate code using features specific to the AM33/2.0 processor.
28450
d77de738 28451@opindex mam34
ddf6fe37 28452@item -mam34
d77de738
ML
28453Generate code using features specific to the AM34 processor.
28454
d77de738 28455@opindex mtune
ddf6fe37 28456@item -mtune=@var{cpu-type}
d77de738
ML
28457Use the timing characteristics of the indicated CPU type when
28458scheduling instructions. This does not change the targeted processor
28459type. The CPU type must be one of @samp{mn10300}, @samp{am33},
28460@samp{am33-2} or @samp{am34}.
28461
d77de738 28462@opindex mreturn-pointer-on-d0
ddf6fe37 28463@item -mreturn-pointer-on-d0
d77de738
ML
28464When generating a function that returns a pointer, return the pointer
28465in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
28466only in @code{a0}, and attempts to call such functions without a prototype
28467result in errors. Note that this option is on by default; use
28468@option{-mno-return-pointer-on-d0} to disable it.
28469
d77de738 28470@opindex mno-crt0
ddf6fe37 28471@item -mno-crt0
d77de738
ML
28472Do not link in the C run-time initialization object file.
28473
d77de738 28474@opindex mrelax
ddf6fe37 28475@item -mrelax
d77de738
ML
28476Indicate to the linker that it should perform a relaxation optimization pass
28477to shorten branches, calls and absolute memory addresses. This option only
28478has an effect when used on the command line for the final link step.
28479
28480This option makes symbolic debugging impossible.
28481
d77de738 28482@opindex mliw
ddf6fe37 28483@item -mliw
d77de738
ML
28484Allow the compiler to generate @emph{Long Instruction Word}
28485instructions if the target is the @samp{AM33} or later. This is the
28486default. This option defines the preprocessor macro @code{__LIW__}.
28487
d77de738 28488@opindex mno-liw
ddf6fe37 28489@item -mno-liw
d77de738
ML
28490Do not allow the compiler to generate @emph{Long Instruction Word}
28491instructions. This option defines the preprocessor macro
28492@code{__NO_LIW__}.
28493
d77de738 28494@opindex msetlb
ddf6fe37 28495@item -msetlb
d77de738
ML
28496Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
28497instructions if the target is the @samp{AM33} or later. This is the
28498default. This option defines the preprocessor macro @code{__SETLB__}.
28499
d77de738 28500@opindex mno-setlb
ddf6fe37 28501@item -mno-setlb
d77de738
ML
28502Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
28503instructions. This option defines the preprocessor macro
28504@code{__NO_SETLB__}.
28505
28506@end table
28507
28508@node Moxie Options
28509@subsection Moxie Options
28510@cindex Moxie Options
28511
28512@table @gcctabopt
28513
d77de738 28514@opindex meb
ddf6fe37 28515@item -meb
d77de738
ML
28516Generate big-endian code. This is the default for @samp{moxie-*-*}
28517configurations.
28518
d77de738 28519@opindex mel
ddf6fe37 28520@item -mel
d77de738
ML
28521Generate little-endian code.
28522
d77de738 28523@opindex mmul.x
ddf6fe37 28524@item -mmul.x
d77de738
ML
28525Generate mul.x and umul.x instructions. This is the default for
28526@samp{moxiebox-*-*} configurations.
28527
d77de738 28528@opindex mno-crt0
ddf6fe37 28529@item -mno-crt0
d77de738
ML
28530Do not link in the C run-time initialization object file.
28531
28532@end table
28533
28534@node MSP430 Options
28535@subsection MSP430 Options
28536@cindex MSP430 Options
28537
28538These options are defined for the MSP430:
28539
28540@table @gcctabopt
28541
d77de738 28542@opindex masm-hex
ddf6fe37 28543@item -masm-hex
d77de738
ML
28544Force assembly output to always use hex constants. Normally such
28545constants are signed decimals, but this option is available for
28546testsuite and/or aesthetic purposes.
28547
d77de738 28548@opindex mmcu=
ddf6fe37 28549@item -mmcu=
d77de738
ML
28550Select the MCU to target. This is used to create a C preprocessor
28551symbol based upon the MCU name, converted to upper case and pre- and
28552post-fixed with @samp{__}. This in turn is used by the
28553@file{msp430.h} header file to select an MCU-specific supplementary
28554header file.
28555
28556The option also sets the ISA to use. If the MCU name is one that is
28557known to only support the 430 ISA then that is selected, otherwise the
28558430X ISA is selected. A generic MCU name of @samp{msp430} can also be
28559used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
28560name selects the 430X ISA.
28561
28562In addition an MCU-specific linker script is added to the linker
28563command line. The script's name is the name of the MCU with
28564@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
28565command line defines the C preprocessor symbol @code{__XXX__} and
28566cause the linker to search for a script called @file{xxx.ld}.
28567
28568The ISA and hardware multiply supported for the different MCUs is hard-coded
28569into GCC. However, an external @samp{devices.csv} file can be used to
28570extend device support beyond those that have been hard-coded.
28571
28572GCC searches for the @samp{devices.csv} file using the following methods in the
28573given precedence order, where the first method takes precendence over the
28574second which takes precedence over the third.
28575
28576@table @asis
28577@item Include path specified with @code{-I} and @code{-L}
28578@samp{devices.csv} will be searched for in each of the directories specified by
28579include paths and linker library search paths.
28580@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
28581Define the value of the global environment variable
28582@samp{MSP430_GCC_INCLUDE_DIR}
28583to the full path to the directory containing devices.csv, and GCC will search
28584this directory for devices.csv. If devices.csv is found, this directory will
28585also be registered as an include path, and linker library path. Header files
28586and linker scripts in this directory can therefore be used without manually
28587specifying @code{-I} and @code{-L} on the command line.
28588@item The @samp{msp430-elf@{,bare@}/include/devices} directory
28589Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
28590toolchain root directory. This directory does not exist in a default
28591installation, but if the user has created it and copied @samp{devices.csv}
28592there, then the MCU data will be read. As above, this directory will
28593also be registered as an include path, and linker library path.
28594
28595@end table
28596If none of the above search methods find @samp{devices.csv}, then the
28597hard-coded MCU data is used.
28598
28599
d77de738
ML
28600@opindex mwarn-mcu
28601@opindex mno-warn-mcu
ddf6fe37
AA
28602@item -mwarn-mcu
28603@itemx -mno-warn-mcu
d77de738
ML
28604This option enables or disables warnings about conflicts between the
28605MCU name specified by the @option{-mmcu} option and the ISA set by the
28606@option{-mcpu} option and/or the hardware multiply support set by the
28607@option{-mhwmult} option. It also toggles warnings about unrecognized
28608MCU names. This option is on by default.
28609
d77de738 28610@opindex mcpu=
ddf6fe37 28611@item -mcpu=
d77de738
ML
28612Specifies the ISA to use. Accepted values are @samp{msp430},
28613@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
28614@option{-mmcu=} option should be used to select the ISA.
28615
d77de738 28616@opindex msim
ddf6fe37 28617@item -msim
d77de738
ML
28618Link to the simulator runtime libraries and linker script. Overrides
28619any scripts that would be selected by the @option{-mmcu=} option.
28620
d77de738 28621@opindex mlarge
ddf6fe37 28622@item -mlarge
d77de738
ML
28623Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
28624
d77de738 28625@opindex msmall
ddf6fe37 28626@item -msmall
d77de738
ML
28627Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
28628
d77de738 28629@opindex mrelax
ddf6fe37 28630@item -mrelax
d77de738
ML
28631This option is passed to the assembler and linker, and allows the
28632linker to perform certain optimizations that cannot be done until
28633the final link.
28634
d77de738 28635@opindex mhwmult=
ddf6fe37 28636@item mhwmult=
d77de738
ML
28637Describes the type of hardware multiply supported by the target.
28638Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
28639for the original 16-bit-only multiply supported by early MCUs.
28640@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
28641@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
28642A value of @samp{auto} can also be given. This tells GCC to deduce
28643the hardware multiply support based upon the MCU name provided by the
28644@option{-mmcu} option. If no @option{-mmcu} option is specified or if
28645the MCU name is not recognized then no hardware multiply support is
28646assumed. @code{auto} is the default setting.
28647
28648Hardware multiplies are normally performed by calling a library
28649routine. This saves space in the generated code. When compiling at
28650@option{-O3} or higher however the hardware multiplier is invoked
28651inline. This makes for bigger, but faster code.
28652
28653The hardware multiply routines disable interrupts whilst running and
28654restore the previous interrupt state when they finish. This makes
28655them safe to use inside interrupt handlers as well as in normal code.
28656
d77de738 28657@opindex minrt
ddf6fe37 28658@item -minrt
d77de738
ML
28659Enable the use of a minimum runtime environment - no static
28660initializers or constructors. This is intended for memory-constrained
28661devices. The compiler includes special symbols in some objects
28662that tell the linker and runtime which code fragments are required.
28663
d77de738 28664@opindex mtiny-printf
ddf6fe37 28665@item -mtiny-printf
d77de738
ML
28666Enable reduced code size @code{printf} and @code{puts} library functions.
28667The @samp{tiny} implementations of these functions are not reentrant, so
28668must be used with caution in multi-threaded applications.
28669
28670Support for streams has been removed and the string to be printed will
28671always be sent to stdout via the @code{write} syscall. The string is not
28672buffered before it is sent to write.
28673
28674This option requires Newlib Nano IO, so GCC must be configured with
28675@samp{--enable-newlib-nano-formatted-io}.
28676
d77de738 28677@opindex mmax-inline-shift=
ddf6fe37 28678@item -mmax-inline-shift=
d77de738
ML
28679This option takes an integer between 0 and 64 inclusive, and sets
28680the maximum number of inline shift instructions which should be emitted to
28681perform a shift operation by a constant amount. When this value needs to be
28682exceeded, an mspabi helper function is used instead. The default value is 4.
28683
28684This only affects cases where a shift by multiple positions cannot be
28685completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28686
28687Shifts of a 32-bit value are at least twice as costly, so the value passed for
28688this option is divided by 2 and the resulting value used instead.
28689
d77de738
ML
28690@opindex mcode-region
28691@opindex mdata-region
ddf6fe37
AA
28692@item -mcode-region=
28693@itemx -mdata-region=
d77de738
ML
28694These options tell the compiler where to place functions and data that
28695do not have one of the @code{lower}, @code{upper}, @code{either} or
28696@code{section} attributes. Possible values are @code{lower},
28697@code{upper}, @code{either} or @code{any}. The first three behave
28698like the corresponding attribute. The fourth possible value -
28699@code{any} - is the default. It leaves placement entirely up to the
28700linker script and how it assigns the standard sections
28701(@code{.text}, @code{.data}, etc) to the memory regions.
28702
d77de738 28703@opindex msilicon-errata
ddf6fe37 28704@item -msilicon-errata=
d77de738
ML
28705This option passes on a request to assembler to enable the fixes for
28706the named silicon errata.
28707
d77de738 28708@opindex msilicon-errata-warn
ddf6fe37 28709@item -msilicon-errata-warn=
d77de738
ML
28710This option passes on a request to the assembler to enable warning
28711messages when a silicon errata might need to be applied.
28712
d77de738
ML
28713@opindex mwarn-devices-csv
28714@opindex mno-warn-devices-csv
ddf6fe37
AA
28715@item -mwarn-devices-csv
28716@itemx -mno-warn-devices-csv
d77de738
ML
28717Warn if @samp{devices.csv} is not found or there are problem parsing it
28718(default: on).
28719
28720@end table
28721
28722@node NDS32 Options
28723@subsection NDS32 Options
28724@cindex NDS32 Options
28725
28726These options are defined for NDS32 implementations:
28727
28728@table @gcctabopt
28729
d77de738 28730@opindex mbig-endian
ddf6fe37 28731@item -mbig-endian
d77de738
ML
28732Generate code in big-endian mode.
28733
d77de738 28734@opindex mlittle-endian
ddf6fe37 28735@item -mlittle-endian
d77de738
ML
28736Generate code in little-endian mode.
28737
d77de738 28738@opindex mreduced-regs
ddf6fe37 28739@item -mreduced-regs
d77de738
ML
28740Use reduced-set registers for register allocation.
28741
d77de738 28742@opindex mfull-regs
ddf6fe37 28743@item -mfull-regs
d77de738
ML
28744Use full-set registers for register allocation.
28745
d77de738 28746@opindex mcmov
ddf6fe37 28747@item -mcmov
d77de738
ML
28748Generate conditional move instructions.
28749
d77de738 28750@opindex mno-cmov
ddf6fe37 28751@item -mno-cmov
d77de738
ML
28752Do not generate conditional move instructions.
28753
d77de738 28754@opindex mext-perf
ddf6fe37 28755@item -mext-perf
d77de738
ML
28756Generate performance extension instructions.
28757
d77de738 28758@opindex mno-ext-perf
ddf6fe37 28759@item -mno-ext-perf
d77de738
ML
28760Do not generate performance extension instructions.
28761
d77de738 28762@opindex mext-perf2
ddf6fe37 28763@item -mext-perf2
d77de738
ML
28764Generate performance extension 2 instructions.
28765
d77de738 28766@opindex mno-ext-perf2
ddf6fe37 28767@item -mno-ext-perf2
d77de738
ML
28768Do not generate performance extension 2 instructions.
28769
d77de738 28770@opindex mext-string
ddf6fe37 28771@item -mext-string
d77de738
ML
28772Generate string extension instructions.
28773
d77de738 28774@opindex mno-ext-string
ddf6fe37 28775@item -mno-ext-string
d77de738
ML
28776Do not generate string extension instructions.
28777
d77de738 28778@opindex mv3push
ddf6fe37 28779@item -mv3push
d77de738
ML
28780Generate v3 push25/pop25 instructions.
28781
d77de738 28782@opindex mno-v3push
ddf6fe37 28783@item -mno-v3push
d77de738
ML
28784Do not generate v3 push25/pop25 instructions.
28785
d77de738 28786@opindex m16-bit
ddf6fe37 28787@item -m16-bit
d77de738
ML
28788Generate 16-bit instructions.
28789
d77de738 28790@opindex mno-16-bit
ddf6fe37 28791@item -mno-16-bit
d77de738
ML
28792Do not generate 16-bit instructions.
28793
d77de738 28794@opindex misr-vector-size
ddf6fe37 28795@item -misr-vector-size=@var{num}
d77de738
ML
28796Specify the size of each interrupt vector, which must be 4 or 16.
28797
d77de738 28798@opindex mcache-block-size
ddf6fe37 28799@item -mcache-block-size=@var{num}
d77de738
ML
28800Specify the size of each cache block,
28801which must be a power of 2 between 4 and 512.
28802
d77de738 28803@opindex march
ddf6fe37 28804@item -march=@var{arch}
d77de738
ML
28805Specify the name of the target architecture.
28806
d77de738 28807@opindex mcmodel
ddf6fe37 28808@item -mcmodel=@var{code-model}
d77de738
ML
28809Set the code model to one of
28810@table @asis
28811@item @samp{small}
28812All the data and read-only data segments must be within 512KB addressing space.
28813The text segment must be within 16MB addressing space.
28814@item @samp{medium}
28815The data segment must be within 512KB while the read-only data segment can be
28816within 4GB addressing space. The text segment should be still within 16MB
28817addressing space.
28818@item @samp{large}
28819All the text and data segments can be within 4GB addressing space.
28820@end table
28821
d77de738 28822@opindex mctor-dtor
ddf6fe37 28823@item -mctor-dtor
d77de738
ML
28824Enable constructor/destructor feature.
28825
d77de738 28826@opindex mrelax
ddf6fe37 28827@item -mrelax
d77de738
ML
28828Guide linker to relax instructions.
28829
28830@end table
28831
28832@node Nios II Options
28833@subsection Nios II Options
28834@cindex Nios II options
28835@cindex Altera Nios II options
28836
28837These are the options defined for the Altera Nios II processor.
28838
28839@table @gcctabopt
28840
d77de738
ML
28841@opindex G
28842@cindex smaller data references
f33d7a88 28843@item -G @var{num}
d77de738
ML
28844Put global and static objects less than or equal to @var{num} bytes
28845into the small data or BSS sections instead of the normal data or BSS
28846sections. The default value of @var{num} is 8.
28847
ddf6fe37
AA
28848@opindex mgpopt
28849@opindex mno-gpopt
d77de738
ML
28850@item -mgpopt=@var{option}
28851@itemx -mgpopt
28852@itemx -mno-gpopt
d77de738
ML
28853Generate (do not generate) GP-relative accesses. The following
28854@var{option} names are recognized:
28855
28856@table @samp
28857
28858@item none
28859Do not generate GP-relative accesses.
28860
28861@item local
28862Generate GP-relative accesses for small data objects that are not
28863external, weak, or uninitialized common symbols.
28864Also use GP-relative addressing for objects that
28865have been explicitly placed in a small data section via a @code{section}
28866attribute.
28867
28868@item global
28869As for @samp{local}, but also generate GP-relative accesses for
28870small data objects that are external, weak, or common. If you use this option,
28871you must ensure that all parts of your program (including libraries) are
28872compiled with the same @option{-G} setting.
28873
28874@item data
28875Generate GP-relative accesses for all data objects in the program. If you
28876use this option, the entire data and BSS segments
28877of your program must fit in 64K of memory and you must use an appropriate
28878linker script to allocate them within the addressable range of the
28879global pointer.
28880
28881@item all
28882Generate GP-relative addresses for function pointers as well as data
28883pointers. If you use this option, the entire text, data, and BSS segments
28884of your program must fit in 64K of memory and you must use an appropriate
28885linker script to allocate them within the addressable range of the
28886global pointer.
28887
28888@end table
28889
28890@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28891@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28892
28893The default is @option{-mgpopt} except when @option{-fpic} or
28894@option{-fPIC} is specified to generate position-independent code.
28895Note that the Nios II ABI does not permit GP-relative accesses from
28896shared libraries.
28897
28898You may need to specify @option{-mno-gpopt} explicitly when building
28899programs that include large amounts of small data, including large
28900GOT data sections. In this case, the 16-bit offset for GP-relative
28901addressing may not be large enough to allow access to the entire
28902small data section.
28903
d77de738 28904@opindex mgprel-sec
ddf6fe37 28905@item -mgprel-sec=@var{regexp}
d77de738
ML
28906This option specifies additional section names that can be accessed via
28907GP-relative addressing. It is most useful in conjunction with
28908@code{section} attributes on variable declarations
28909(@pxref{Common Variable Attributes}) and a custom linker script.
28910The @var{regexp} is a POSIX Extended Regular Expression.
28911
28912This option does not affect the behavior of the @option{-G} option, and
28913the specified sections are in addition to the standard @code{.sdata}
28914and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28915
d77de738 28916@opindex mr0rel-sec
ddf6fe37 28917@item -mr0rel-sec=@var{regexp}
d77de738
ML
28918This option specifies names of sections that can be accessed via a
2891916-bit offset from @code{r0}; that is, in the low 32K or high 32K
28920of the 32-bit address space. It is most useful in conjunction with
28921@code{section} attributes on variable declarations
28922(@pxref{Common Variable Attributes}) and a custom linker script.
28923The @var{regexp} is a POSIX Extended Regular Expression.
28924
28925In contrast to the use of GP-relative addressing for small data,
28926zero-based addressing is never generated by default and there are no
28927conventional section names used in standard linker scripts for sections
28928in the low or high areas of memory.
28929
d77de738
ML
28930@opindex mel
28931@opindex meb
ddf6fe37
AA
28932@item -mel
28933@itemx -meb
d77de738
ML
28934Generate little-endian (default) or big-endian (experimental) code,
28935respectively.
28936
d77de738 28937@opindex march
ddf6fe37 28938@item -march=@var{arch}
d77de738
ML
28939This specifies the name of the target Nios II architecture. GCC uses this
28940name to determine what kind of instructions it can emit when generating
28941assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28942
28943The preprocessor macro @code{__nios2_arch__} is available to programs,
28944with value 1 or 2, indicating the targeted ISA level.
28945
d77de738
ML
28946@opindex mno-bypass-cache
28947@opindex mbypass-cache
ddf6fe37
AA
28948@item -mbypass-cache
28949@itemx -mno-bypass-cache
d77de738
ML
28950Force all load and store instructions to always bypass cache by
28951using I/O variants of the instructions. The default is not to
28952bypass the cache.
28953
d77de738
ML
28954@opindex mcache-volatile
28955@opindex mno-cache-volatile
ddf6fe37
AA
28956@item -mno-cache-volatile
28957@itemx -mcache-volatile
d77de738
ML
28958Volatile memory access bypass the cache using the I/O variants of
28959the load and store instructions. The default is not to bypass the cache.
28960
d77de738
ML
28961@opindex mno-fast-sw-div
28962@opindex mfast-sw-div
ddf6fe37
AA
28963@item -mno-fast-sw-div
28964@itemx -mfast-sw-div
d77de738
ML
28965Do not use table-based fast divide for small numbers. The default
28966is to use the fast divide at @option{-O3} and above.
28967
d77de738
ML
28968@opindex mno-hw-mul
28969@opindex mhw-mul
28970@opindex mno-hw-mulx
28971@opindex mhw-mulx
28972@opindex mno-hw-div
28973@opindex mhw-div
ddf6fe37
AA
28974@item -mno-hw-mul
28975@itemx -mhw-mul
28976@itemx -mno-hw-mulx
28977@itemx -mhw-mulx
28978@itemx -mno-hw-div
28979@itemx -mhw-div
d77de738
ML
28980Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28981instructions by the compiler. The default is to emit @code{mul}
28982and not emit @code{div} and @code{mulx}.
28983
28984@item -mbmx
28985@itemx -mno-bmx
28986@itemx -mcdx
28987@itemx -mno-cdx
28988Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28989CDX (code density) instructions. Enabling these instructions also
28990requires @option{-march=r2}. Since these instructions are optional
28991extensions to the R2 architecture, the default is not to emit them.
28992
d77de738
ML
28993@opindex mcustom-@var{insn}
28994@opindex mno-custom-@var{insn}
ddf6fe37
AA
28995@item -mcustom-@var{insn}=@var{N}
28996@itemx -mno-custom-@var{insn}
d77de738
ML
28997Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28998custom instruction with encoding @var{N} when generating code that uses
28999@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
29000instruction 253 for single-precision floating-point add operations instead
29001of the default behavior of using a library call.
29002
29003The following values of @var{insn} are supported. Except as otherwise
29004noted, floating-point operations are expected to be implemented with
29005normal IEEE 754 semantics and correspond directly to the C operators or the
29006equivalent GCC built-in functions (@pxref{Other Builtins}).
29007
29008Single-precision floating point:
29009@table @asis
29010
29011@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
29012Binary arithmetic operations.
29013
29014@item @samp{fnegs}
29015Unary negation.
29016
29017@item @samp{fabss}
29018Unary absolute value.
29019
29020@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
29021Comparison operations.
29022
29023@item @samp{fmins}, @samp{fmaxs}
29024Floating-point minimum and maximum. These instructions are only
29025generated if @option{-ffinite-math-only} is specified.
29026
29027@item @samp{fsqrts}
29028Unary square root operation.
29029
29030@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
29031Floating-point trigonometric and exponential functions. These instructions
29032are only generated if @option{-funsafe-math-optimizations} is also specified.
29033
29034@end table
29035
29036Double-precision floating point:
29037@table @asis
29038
29039@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
29040Binary arithmetic operations.
29041
29042@item @samp{fnegd}
29043Unary negation.
29044
29045@item @samp{fabsd}
29046Unary absolute value.
29047
29048@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
29049Comparison operations.
29050
29051@item @samp{fmind}, @samp{fmaxd}
29052Double-precision minimum and maximum. These instructions are only
29053generated if @option{-ffinite-math-only} is specified.
29054
29055@item @samp{fsqrtd}
29056Unary square root operation.
29057
29058@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
29059Double-precision trigonometric and exponential functions. These instructions
29060are only generated if @option{-funsafe-math-optimizations} is also specified.
29061
29062@end table
29063
29064Conversions:
29065@table @asis
29066@item @samp{fextsd}
29067Conversion from single precision to double precision.
29068
29069@item @samp{ftruncds}
29070Conversion from double precision to single precision.
29071
29072@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
29073Conversion from floating point to signed or unsigned integer types, with
29074truncation towards zero.
29075
29076@item @samp{round}
29077Conversion from single-precision floating point to signed integer,
29078rounding to the nearest integer and ties away from zero.
29079This corresponds to the @code{__builtin_lroundf} function when
29080@option{-fno-math-errno} is used.
29081
29082@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
29083Conversion from signed or unsigned integer types to floating-point types.
29084
29085@end table
29086
29087In addition, all of the following transfer instructions for internal
29088registers X and Y must be provided to use any of the double-precision
29089floating-point instructions. Custom instructions taking two
29090double-precision source operands expect the first operand in the
2909164-bit register X. The other operand (or only operand of a unary
29092operation) is given to the custom arithmetic instruction with the
29093least significant half in source register @var{src1} and the most
29094significant half in @var{src2}. A custom instruction that returns a
29095double-precision result returns the most significant 32 bits in the
29096destination register and the other half in 32-bit register Y.
29097GCC automatically generates the necessary code sequences to write
29098register X and/or read register Y when double-precision floating-point
29099instructions are used.
29100
29101@table @asis
29102
29103@item @samp{fwrx}
29104Write @var{src1} into the least significant half of X and @var{src2} into
29105the most significant half of X.
29106
29107@item @samp{fwry}
29108Write @var{src1} into Y.
29109
29110@item @samp{frdxhi}, @samp{frdxlo}
29111Read the most or least (respectively) significant half of X and store it in
29112@var{dest}.
29113
29114@item @samp{frdy}
29115Read the value of Y and store it into @var{dest}.
29116@end table
29117
29118Note that you can gain more local control over generation of Nios II custom
29119instructions by using the @code{target("custom-@var{insn}=@var{N}")}
29120and @code{target("no-custom-@var{insn}")} function attributes
29121(@pxref{Function Attributes})
29122or pragmas (@pxref{Function Specific Option Pragmas}).
29123
d77de738 29124@opindex mcustom-fpu-cfg
ddf6fe37 29125@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
29126
29127This option enables a predefined, named set of custom instruction encodings
29128(see @option{-mcustom-@var{insn}} above).
29129Currently, the following sets are defined:
29130
29131@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
29132@gccoptlist{-mcustom-fmuls=252
29133-mcustom-fadds=253
29134-mcustom-fsubs=254
d77de738
ML
29135-fsingle-precision-constant}
29136
29137@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
29138@gccoptlist{-mcustom-fmuls=252
29139-mcustom-fadds=253
29140-mcustom-fsubs=254
29141-mcustom-fdivs=255
d77de738
ML
29142-fsingle-precision-constant}
29143
29144@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
29145@gccoptlist{-mcustom-floatus=243
29146-mcustom-fixsi=244
29147-mcustom-floatis=245
29148-mcustom-fcmpgts=246
29149-mcustom-fcmples=249
29150-mcustom-fcmpeqs=250
29151-mcustom-fcmpnes=251
29152-mcustom-fmuls=252
29153-mcustom-fadds=253
29154-mcustom-fsubs=254
29155-mcustom-fdivs=255
d77de738
ML
29156-fsingle-precision-constant}
29157
29158@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
29159@gccoptlist{-mcustom-fabss=224
29160-mcustom-fnegs=225
29161-mcustom-fcmpnes=226
29162-mcustom-fcmpeqs=227
29163-mcustom-fcmpges=228
29164-mcustom-fcmpgts=229
29165-mcustom-fcmples=230
29166-mcustom-fcmplts=231
29167-mcustom-fmaxs=232
29168-mcustom-fmins=233
29169-mcustom-round=248
29170-mcustom-fixsi=249
29171-mcustom-floatis=250
29172-mcustom-fsqrts=251
29173-mcustom-fmuls=252
29174-mcustom-fadds=253
29175-mcustom-fsubs=254
29176-mcustom-fdivs=255}
d77de738
ML
29177
29178Custom instruction assignments given by individual
29179@option{-mcustom-@var{insn}=} options override those given by
29180@option{-mcustom-fpu-cfg=}, regardless of the
29181order of the options on the command line.
29182
29183Note that you can gain more local control over selection of a FPU
29184configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
29185function attribute (@pxref{Function Attributes})
29186or pragma (@pxref{Function Specific Option Pragmas}).
29187
29188The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
29189Hardware 2 Component}. Please note that the custom instructions enabled by
29190@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
29191if @option{-ffinite-math-only} is specified. The custom instruction enabled by
29192@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
29193specified. In contrast to the other configurations,
29194@option{-fsingle-precision-constant} is not set.
29195
29196@end table
29197
29198These additional @samp{-m} options are available for the Altera Nios II
29199ELF (bare-metal) target:
29200
29201@table @gcctabopt
29202
d77de738 29203@opindex mhal
ddf6fe37 29204@item -mhal
d77de738
ML
29205Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
29206startup and termination code, and is typically used in conjunction with
29207@option{-msys-crt0=} to specify the location of the alternate startup code
29208provided by the HAL BSP.
29209
d77de738 29210@opindex msmallc
ddf6fe37 29211@item -msmallc
d77de738
ML
29212Link with a limited version of the C library, @option{-lsmallc}, rather than
29213Newlib.
29214
d77de738 29215@opindex msys-crt0
ddf6fe37 29216@item -msys-crt0=@var{startfile}
d77de738
ML
29217@var{startfile} is the file name of the startfile (crt0) to use
29218when linking. This option is only useful in conjunction with @option{-mhal}.
29219
d77de738 29220@opindex msys-lib
ddf6fe37 29221@item -msys-lib=@var{systemlib}
d77de738
ML
29222@var{systemlib} is the library name of the library that provides
29223low-level system calls required by the C library,
29224e.g.@: @code{read} and @code{write}.
29225This option is typically used to link with a library provided by a HAL BSP.
29226
29227@end table
29228
29229@node Nvidia PTX Options
29230@subsection Nvidia PTX Options
29231@cindex Nvidia PTX options
29232@cindex nvptx options
29233
29234These options are defined for Nvidia PTX:
29235
29236@table @gcctabopt
29237
d77de738 29238@opindex m64
ddf6fe37 29239@item -m64
d77de738
ML
29240Ignored, but preserved for backward compatibility. Only 64-bit ABI is
29241supported.
29242
d77de738 29243@opindex march
ddf6fe37 29244@item -march=@var{architecture-string}
d77de738
ML
29245Generate code for the specified PTX ISA target architecture
29246(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
29247@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
29248@samp{sm_80}.
29249The default depends on how the compiler has been configured, see
29250@option{--with-arch}.
29251
29252This option sets the value of the preprocessor macro
29253@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
29254@samp{350}.
29255
d77de738 29256@opindex misa
ddf6fe37 29257@item -misa=@var{architecture-string}
d77de738
ML
29258Alias of @option{-march=}.
29259
d77de738 29260@opindex march
ddf6fe37 29261@item -march-map=@var{architecture-string}
d77de738
ML
29262Select the closest available @option{-march=} value that is not more
29263capable. For instance, for @option{-march-map=sm_50} select
29264@option{-march=sm_35}, and for @option{-march-map=sm_53} select
29265@option{-march=sm_53}.
29266
d77de738 29267@opindex mptx
ddf6fe37 29268@item -mptx=@var{version-string}
d77de738
ML
29269Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
29270Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
29271@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
29272version is required for specified PTX ISA target architecture via
29273option @option{-march=}.
29274
29275This option sets the values of the preprocessor macros
29276@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
29277for instance, for @samp{3.1} the macros have the values @samp{3} and
29278@samp{1}, respectively.
29279
d77de738 29280@opindex mmainkernel
ddf6fe37 29281@item -mmainkernel
d77de738
ML
29282Link in code for a __main kernel. This is for stand-alone instead of
29283offloading execution.
29284
d77de738 29285@opindex moptimize
ddf6fe37 29286@item -moptimize
d77de738
ML
29287Apply partitioned execution optimizations. This is the default when any
29288level of optimization is selected.
29289
d77de738 29290@opindex msoft-stack
ddf6fe37 29291@item -msoft-stack
d77de738
ML
29292Generate code that does not use @code{.local} memory
29293directly for stack storage. Instead, a per-warp stack pointer is
29294maintained explicitly. This enables variable-length stack allocation (with
29295variable-length arrays or @code{alloca}), and when global memory is used for
29296underlying storage, makes it possible to access automatic variables from other
29297threads, or with atomic instructions. This code generation variant is used
29298for OpenMP offloading, but the option is exposed on its own for the purpose
29299of testing the compiler; to generate code suitable for linking into programs
29300using OpenMP offloading, use option @option{-mgomp}.
29301
d77de738 29302@opindex muniform-simt
ddf6fe37 29303@item -muniform-simt
d77de738
ML
29304Switch to code generation variant that allows to execute all threads in each
29305warp, while maintaining memory state and side effects as if only one thread
29306in each warp was active outside of OpenMP SIMD regions. All atomic operations
29307and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
29308current lane index equals the master lane index), and the register being
29309assigned is copied via a shuffle instruction from the master lane. Outside of
29310SIMD regions lane 0 is the master; inside, each thread sees itself as the
29311master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
29312all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
29313regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
29314with current lane index to compute the master lane index.
29315
d77de738 29316@opindex mgomp
ddf6fe37 29317@item -mgomp
d77de738
ML
29318Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
29319@option{-muniform-simt} options, and selects corresponding multilib variant.
29320
29321@end table
29322
29323@node OpenRISC Options
29324@subsection OpenRISC Options
29325@cindex OpenRISC Options
29326
29327These options are defined for OpenRISC:
29328
29329@table @gcctabopt
29330
d77de738 29331@opindex mboard
ddf6fe37 29332@item -mboard=@var{name}
d77de738
ML
29333Configure a board specific runtime. This will be passed to the linker for
29334newlib board library linking. The default is @code{or1ksim}.
29335
d77de738 29336@opindex mnewlib
ddf6fe37 29337@item -mnewlib
d77de738
ML
29338This option is ignored; it is for compatibility purposes only. This used to
29339select linker and preprocessor options for use with newlib.
29340
d77de738
ML
29341@opindex msoft-div
29342@opindex mhard-div
ddf6fe37
AA
29343@item -msoft-div
29344@itemx -mhard-div
d77de738
ML
29345Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
29346This default is hardware divide.
29347
d77de738
ML
29348@opindex msoft-mul
29349@opindex mhard-mul
ddf6fe37
AA
29350@item -msoft-mul
29351@itemx -mhard-mul
d77de738
ML
29352Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
29353This default is hardware multiply.
29354
d77de738
ML
29355@opindex msoft-float
29356@opindex mhard-float
ddf6fe37
AA
29357@item -msoft-float
29358@itemx -mhard-float
d77de738
ML
29359Select software or hardware for floating point operations.
29360The default is software.
29361
d77de738 29362@opindex mdouble-float
ddf6fe37 29363@item -mdouble-float
d77de738
ML
29364When @option{-mhard-float} is selected, enables generation of double-precision
29365floating point instructions. By default functions from @file{libgcc} are used
29366to perform double-precision floating point operations.
29367
d77de738 29368@opindex munordered-float
ddf6fe37 29369@item -munordered-float
d77de738
ML
29370When @option{-mhard-float} is selected, enables generation of unordered
29371floating point compare and set flag (@code{lf.sfun*}) instructions. By default
29372functions from @file{libgcc} are used to perform unordered floating point
29373compare and set flag operations.
29374
d77de738 29375@opindex mcmov
ddf6fe37 29376@item -mcmov
d77de738
ML
29377Enable generation of conditional move (@code{l.cmov}) instructions. By
29378default the equivalent will be generated using set and branch.
29379
d77de738 29380@opindex mror
ddf6fe37 29381@item -mror
d77de738
ML
29382Enable generation of rotate right (@code{l.ror}) instructions. By default
29383functions from @file{libgcc} are used to perform rotate right operations.
29384
d77de738 29385@opindex mrori
ddf6fe37 29386@item -mrori
d77de738
ML
29387Enable generation of rotate right with immediate (@code{l.rori}) instructions.
29388By default functions from @file{libgcc} are used to perform rotate right with
29389immediate operations.
29390
d77de738 29391@opindex msext
ddf6fe37 29392@item -msext
d77de738
ML
29393Enable generation of sign extension (@code{l.ext*}) instructions. By default
29394memory loads are used to perform sign extension.
29395
d77de738 29396@opindex msfimm
ddf6fe37 29397@item -msfimm
d77de738
ML
29398Enable generation of compare and set flag with immediate (@code{l.sf*i})
29399instructions. By default extra instructions will be generated to store the
29400immediate to a register first.
29401
d77de738 29402@opindex mshftimm
ddf6fe37 29403@item -mshftimm
d77de738
ML
29404Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
29405@code{l.slli}) instructions. By default extra instructions will be generated
29406to store the immediate to a register first.
29407
d77de738 29408@opindex mcmodel=small
ddf6fe37 29409@item -mcmodel=small
d77de738
ML
29410Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
29411the default model.
29412
d77de738 29413@opindex mcmodel=large
ddf6fe37 29414@item -mcmodel=large
d77de738
ML
29415Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
29416
29417
29418@end table
29419
29420@node PDP-11 Options
29421@subsection PDP-11 Options
29422@cindex PDP-11 Options
29423
29424These options are defined for the PDP-11:
29425
29426@table @gcctabopt
d77de738 29427@opindex mfpu
ddf6fe37 29428@item -mfpu
d77de738
ML
29429Use hardware FPP floating point. This is the default. (FIS floating
29430point on the PDP-11/40 is not supported.) Implies -m45.
29431
d77de738 29432@opindex msoft-float
ddf6fe37 29433@item -msoft-float
d77de738
ML
29434Do not use hardware floating point.
29435
d77de738 29436@opindex mac0
ddf6fe37 29437@item -mac0
d77de738
ML
29438Return floating-point results in ac0 (fr0 in Unix assembler syntax).
29439
d77de738 29440@opindex mno-ac0
ddf6fe37 29441@item -mno-ac0
d77de738
ML
29442Return floating-point results in memory. This is the default.
29443
d77de738 29444@opindex m40
ddf6fe37 29445@item -m40
d77de738
ML
29446Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
29447
d77de738 29448@opindex m45
ddf6fe37 29449@item -m45
d77de738
ML
29450Generate code for a PDP-11/45. This is the default.
29451
d77de738 29452@opindex m10
ddf6fe37 29453@item -m10
d77de738
ML
29454Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
29455
d77de738
ML
29456@opindex mint16
29457@opindex mno-int32
ddf6fe37
AA
29458@item -mint16
29459@itemx -mno-int32
d77de738
ML
29460Use 16-bit @code{int}. This is the default.
29461
d77de738
ML
29462@opindex mint32
29463@opindex mno-int16
ddf6fe37
AA
29464@item -mint32
29465@itemx -mno-int16
d77de738
ML
29466Use 32-bit @code{int}.
29467
d77de738 29468@opindex msplit
ddf6fe37 29469@item -msplit
d77de738
ML
29470Target has split instruction and data space. Implies -m45.
29471
d77de738 29472@opindex munix-asm
ddf6fe37 29473@item -munix-asm
d77de738
ML
29474Use Unix assembler syntax.
29475
d77de738 29476@opindex mdec-asm
ddf6fe37 29477@item -mdec-asm
d77de738
ML
29478Use DEC assembler syntax.
29479
d77de738 29480@opindex mgnu-asm
ddf6fe37 29481@item -mgnu-asm
d77de738
ML
29482Use GNU assembler syntax. This is the default.
29483
d77de738 29484@opindex mlra
ddf6fe37 29485@item -mlra
d77de738
ML
29486Use the new LRA register allocator. By default, the old ``reload''
29487allocator is used.
29488@end table
29489
d77de738
ML
29490@node PowerPC Options
29491@subsection PowerPC Options
29492@cindex PowerPC options
29493
29494These are listed under @xref{RS/6000 and PowerPC Options}.
29495
29496@node PRU Options
29497@subsection PRU Options
29498@cindex PRU Options
29499
29500These command-line options are defined for PRU target:
29501
29502@table @gcctabopt
d77de738 29503@opindex minrt
ddf6fe37 29504@item -minrt
d77de738
ML
29505Link with a minimum runtime environment, with no support for static
29506initializers and constructors. Using this option can significantly reduce
29507the size of the final ELF binary. Beware that the compiler could still
29508generate code with static initializers and constructors. It is up to the
29509programmer to ensure that the source program will not use those features.
29510
d77de738 29511@opindex mmcu
ddf6fe37 29512@item -mmcu=@var{mcu}
d77de738
ML
29513Specify the PRU MCU variant to use. Check Newlib for the exact list of
29514supported MCUs.
29515
d77de738 29516@opindex mno-relax
ddf6fe37 29517@item -mno-relax
d77de738
ML
29518Make GCC pass the @option{--no-relax} command-line option to the linker
29519instead of the @option{--relax} option.
29520
d77de738 29521@opindex mloop
ddf6fe37 29522@item -mloop
d77de738
ML
29523Allow (or do not allow) GCC to use the LOOP instruction.
29524
d77de738 29525@opindex mabi
ddf6fe37 29526@item -mabi=@var{variant}
d77de738
ML
29527Specify the ABI variant to output code for. @option{-mabi=ti} selects the
29528unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
29529more naturally with certain GCC assumptions. These are the differences:
29530
29531@table @samp
29532@item Function Pointer Size
29533TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
29534supports only 32-bit data and code pointers.
29535
29536@item Optional Return Value Pointer
29537Function return values larger than 64 bits are passed by using a hidden
29538pointer as the first argument of the function. TI ABI, though, mandates that
29539the pointer can be NULL in case the caller is not using the returned value.
29540GNU always passes and expects a valid return value pointer.
29541
29542@end table
29543
29544The current @option{-mabi=ti} implementation simply raises a compile error
29545when any of the above code constructs is detected. As a consequence
29546the standard C library cannot be built and it is omitted when linking with
29547@option{-mabi=ti}.
29548
29549Relaxation is a GNU feature and for safety reasons is disabled when using
29550@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
29551instructions, so the GNU linker cannot adjust them when shortening adjacent
29552LDI32 pseudo instructions.
29553
29554@end table
29555
29556@node RISC-V Options
29557@subsection RISC-V Options
29558@cindex RISC-V Options
29559
29560These command-line options are defined for RISC-V targets:
29561
29562@table @gcctabopt
d77de738 29563@opindex mbranch-cost
ddf6fe37 29564@item -mbranch-cost=@var{n}
d77de738
ML
29565Set the cost of branches to roughly @var{n} instructions.
29566
ddf6fe37 29567@opindex plt
d77de738
ML
29568@item -mplt
29569@itemx -mno-plt
d77de738
ML
29570When generating PIC code, do or don't allow the use of PLTs. Ignored for
29571non-PIC. The default is @option{-mplt}.
29572
d77de738 29573@opindex mabi
ddf6fe37 29574@item -mabi=@var{ABI-string}
d77de738
ML
29575Specify integer and floating-point calling convention. @var{ABI-string}
29576contains two parts: the size of integer types and the registers used for
29577floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
29578@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2957932-bit), and that floating-point values up to 64 bits wide are passed in F
29580registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
29581allows the compiler to generate code that uses the F and D extensions but only
29582allows floating-point values up to 32 bits long to be passed in registers; or
29583@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
29584passed in registers.
29585
29586The default for this argument is system dependent, users who want a specific
29587calling convention should specify one explicitly. The valid calling
29588conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
29589@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
29590implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
29591invalid because the ABI requires 64-bit values be passed in F registers, but F
29592registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
29593only be used with the @samp{rv32e} architecture. This ABI is not well
29594specified at present, and is subject to change.
29595
ddf6fe37 29596@opindex mfdiv
d77de738
ML
29597@item -mfdiv
29598@itemx -mno-fdiv
d77de738
ML
29599Do or don't use hardware floating-point divide and square root instructions.
29600This requires the F or D extensions for floating-point registers. The default
29601is to use them if the specified architecture has these instructions.
29602
ddf6fe37 29603@opindex mdiv
d77de738
ML
29604@item -mdiv
29605@itemx -mno-div
d77de738
ML
29606Do or don't use hardware instructions for integer division. This requires the
29607M extension. The default is to use them if the specified architecture has
29608these instructions.
29609
d77de738 29610@opindex misa-spec
ddf6fe37 29611@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
29612Specify the version of the RISC-V Unprivileged (formerly User-Level)
29613ISA specification to produce code conforming to. The possibilities
29614for @var{ISA-spec-string} are:
29615@table @code
29616@item 2.2
29617Produce code conforming to version 2.2.
29618@item 20190608
29619Produce code conforming to version 20190608.
29620@item 20191213
29621Produce code conforming to version 20191213.
29622@end table
29623The default is @option{-misa-spec=20191213} unless GCC has been configured
29624with @option{--with-isa-spec=} specifying a different default version.
29625
d77de738 29626@opindex march
ddf6fe37 29627@item -march=@var{ISA-string}
d77de738
ML
29628Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
29629lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
29630@samp{rv32imaf}.
29631
29632When @option{-march=} is not specified, use the setting from @option{-mcpu}.
29633
29634If both @option{-march} and @option{-mcpu=} are not specified, the default for
29635this argument is system dependent, users who want a specific architecture
29636extensions should specify one explicitly.
29637
d77de738 29638@opindex mcpu
ddf6fe37 29639@item -mcpu=@var{processor-string}
d77de738
ML
29640Use architecture of and optimize the output for the given processor, specified
29641by particular CPU name.
29642Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
29643@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
29644@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 29645@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 29646
d77de738 29647@opindex mtune
ddf6fe37 29648@item -mtune=@var{processor-string}
d77de738
ML
29649Optimize the output for the given processor, specified by microarchitecture or
29650particular CPU name. Permissible values for this option are: @samp{rocket},
29651@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 29652@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
29653
29654When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
29655the default is @samp{rocket} if both are not specified.
29656
29657The @samp{size} choice is not intended for use by end-users. This is used
29658when @option{-Os} is specified. It overrides the instruction cost info
29659provided by @option{-mtune=}, but does not override the pipeline info. This
29660helps reduce code size while still giving good performance.
29661
d77de738 29662@opindex mpreferred-stack-boundary
ddf6fe37 29663@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
29664Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
29665byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
29666the default is 4 (16 bytes or 128-bits).
29667
29668@strong{Warning:} If you use this switch, then you must build all modules with
29669the same value, including any libraries. This includes the system libraries
29670and startup modules.
29671
d77de738 29672@opindex msmall-data-limit
ddf6fe37 29673@item -msmall-data-limit=@var{n}
d77de738
ML
29674Put global and static data smaller than @var{n} bytes into a special section
29675(on some targets).
29676
ddf6fe37 29677@opindex msave-restore
d77de738
ML
29678@item -msave-restore
29679@itemx -mno-save-restore
d77de738
ML
29680Do or don't use smaller but slower prologue and epilogue code that uses
29681library function calls. The default is to use fast inline prologues and
29682epilogues.
29683
f797260a
PN
29684@opindex minline-atomics
29685@item -minline-atomics
29686@itemx -mno-inline-atomics
29687Do or don't use smaller but slower subword atomic emulation code that uses
29688libatomic function calls. The default is to use fast inline subword atomics
29689that do not require libatomic.
29690
df48285b
CM
29691@opindex minline-strlen
29692@item -minline-strlen
29693@itemx -mno-inline-strlen
29694Do or do not attempt to inline strlen calls if possible.
29695Inlining will only be done if the string is properly aligned
29696and instructions for accelerated processing are available.
29697The default is to not inline strlen calls.
29698
949f1ccf
CM
29699@opindex minline-strcmp
29700@item -minline-strcmp
29701@itemx -mno-inline-strcmp
29702Do or do not attempt to inline strcmp calls if possible.
29703Inlining will only be done if the strings are properly aligned
29704and instructions for accelerated processing are available.
29705The default is to not inline strcmp calls.
29706
29707@opindex minline-strncmp
29708@item -minline-strncmp
29709@itemx -mno-inline-strncmp
29710Do or do not attempt to inline strncmp calls if possible.
29711Inlining will only be done if the strings are properly aligned
29712and instructions for accelerated processing are available.
29713The default is to not inline strncmp calls.
29714
ddf6fe37 29715@opindex mshorten-memrefs
d77de738
ML
29716@item -mshorten-memrefs
29717@itemx -mno-shorten-memrefs
d77de738
ML
29718Do or do not attempt to make more use of compressed load/store instructions by
29719replacing a load/store of 'base register + large offset' with a new load/store
29720of 'new base + small offset'. If the new base gets stored in a compressed
29721register, then the new load/store can be compressed. Currently targets 32-bit
29722integer load/stores only.
29723
ddf6fe37 29724@opindex mstrict-align
d77de738
ML
29725@item -mstrict-align
29726@itemx -mno-strict-align
d77de738
ML
29727Do not or do generate unaligned memory accesses. The default is set depending
29728on whether the processor we are optimizing for supports fast unaligned access
29729or not.
29730
d77de738 29731@opindex mcmodel=medlow
ddf6fe37 29732@item -mcmodel=medlow
d77de738
ML
29733Generate code for the medium-low code model. The program and its statically
29734defined symbols must lie within a single 2 GiB address range and must lie
29735between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29736statically or dynamically linked. This is the default code model.
29737
d77de738 29738@opindex mcmodel=medany
ddf6fe37 29739@item -mcmodel=medany
d77de738
ML
29740Generate code for the medium-any code model. The program and its statically
29741defined symbols must be within any single 2 GiB address range. Programs can be
29742statically or dynamically linked.
29743
29744The code generated by the medium-any code model is position-independent, but is
29745not guaranteed to function correctly when linked into position-independent
29746executables or libraries.
29747
29748@item -mexplicit-relocs
29749@itemx -mno-exlicit-relocs
29750Use or do not use assembler relocation operators when dealing with symbolic
29751addresses. The alternative is to use assembler macros instead, which may
29752limit optimization.
29753
ddf6fe37 29754@opindex mrelax
d77de738
ML
29755@item -mrelax
29756@itemx -mno-relax
d77de738
ML
29757Take advantage of linker relaxations to reduce the number of instructions
29758required to materialize symbol addresses. The default is to take advantage of
29759linker relaxations.
29760
ddf6fe37 29761@opindex mriscv-attribute
d77de738
ML
29762@item -mriscv-attribute
29763@itemx -mno-riscv-attribute
d77de738
ML
29764Emit (do not emit) RISC-V attribute to record extra information into ELF
29765objects. This feature requires at least binutils 2.32.
29766
ddf6fe37 29767@opindex mcsr-check
d77de738
ML
29768@item -mcsr-check
29769@itemx -mno-csr-check
d77de738
ML
29770Enables or disables the CSR checking.
29771
d77de738 29772@opindex malign-data
ddf6fe37 29773@item -malign-data=@var{type}
d77de738
ML
29774Control how GCC aligns variables and constants of array, structure, or union
29775types. Supported values for @var{type} are @samp{xlen} which uses x register
29776width as the alignment value, and @samp{natural} which uses natural alignment.
29777@samp{xlen} is the default.
29778
d77de738 29779@opindex mbig-endian
ddf6fe37 29780@item -mbig-endian
d77de738
ML
29781Generate big-endian code. This is the default when GCC is configured for a
29782@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29783
d77de738 29784@opindex mlittle-endian
ddf6fe37 29785@item -mlittle-endian
d77de738
ML
29786Generate little-endian code. This is the default when GCC is configured for a
29787@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29788@samp{riscv32be-*-*} target.
29789
d77de738
ML
29790@opindex mstack-protector-guard
29791@opindex mstack-protector-guard-reg
29792@opindex mstack-protector-guard-offset
ddf6fe37
AA
29793@item -mstack-protector-guard=@var{guard}
29794@itemx -mstack-protector-guard-reg=@var{reg}
29795@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29796Generate stack protection code using canary at @var{guard}. Supported
29797locations are @samp{global} for a global canary or @samp{tls} for per-thread
29798canary in the TLS block.
29799
29800With the latter choice the options
29801@option{-mstack-protector-guard-reg=@var{reg}} and
29802@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29803which register to use as base register for reading the canary,
29804and from what offset from that base register. There is no default
29805register or offset as this is entirely for use within the Linux
29806kernel.
29807@end table
29808
29809@node RL78 Options
29810@subsection RL78 Options
29811@cindex RL78 Options
29812
29813@table @gcctabopt
29814
d77de738 29815@opindex msim
ddf6fe37 29816@item -msim
d77de738
ML
29817Links in additional target libraries to support operation within a
29818simulator.
29819
ddf6fe37 29820@opindex mmul
d77de738
ML
29821@item -mmul=none
29822@itemx -mmul=g10
29823@itemx -mmul=g13
29824@itemx -mmul=g14
29825@itemx -mmul=rl78
d77de738
ML
29826Specifies the type of hardware multiplication and division support to
29827be used. The simplest is @code{none}, which uses software for both
29828multiplication and division. This is the default. The @code{g13}
29829value is for the hardware multiply/divide peripheral found on the
29830RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29831the multiplication and division instructions supported by the RL78/G14
29832(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29833the value @code{mg10} is an alias for @code{none}.
29834
29835In addition a C preprocessor macro is defined, based upon the setting
29836of this option. Possible values are: @code{__RL78_MUL_NONE__},
29837@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29838
ddf6fe37 29839@opindex mcpu
d77de738
ML
29840@item -mcpu=g10
29841@itemx -mcpu=g13
29842@itemx -mcpu=g14
29843@itemx -mcpu=rl78
d77de738
ML
29844Specifies the RL78 core to target. The default is the G14 core, also
29845known as an S3 core or just RL78. The G13 or S2 core does not have
29846multiply or divide instructions, instead it uses a hardware peripheral
29847for these operations. The G10 or S1 core does not have register
29848banks, so it uses a different calling convention.
29849
29850If this option is set it also selects the type of hardware multiply
29851support to use, unless this is overridden by an explicit
29852@option{-mmul=none} option on the command line. Thus specifying
29853@option{-mcpu=g13} enables the use of the G13 hardware multiply
29854peripheral and specifying @option{-mcpu=g10} disables the use of
29855hardware multiplications altogether.
29856
29857Note, although the RL78/G14 core is the default target, specifying
29858@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29859change the behavior of the toolchain since it also enables G14
29860hardware multiply support. If these options are not specified on the
29861command line then software multiplication routines will be used even
29862though the code targets the RL78 core. This is for backwards
29863compatibility with older toolchains which did not have hardware
29864multiply and divide support.
29865
29866In addition a C preprocessor macro is defined, based upon the setting
29867of this option. Possible values are: @code{__RL78_G10__},
29868@code{__RL78_G13__} or @code{__RL78_G14__}.
29869
d77de738
ML
29870@opindex mg10
29871@opindex mg13
29872@opindex mg14
29873@opindex mrl78
ddf6fe37
AA
29874@item -mg10
29875@itemx -mg13
29876@itemx -mg14
29877@itemx -mrl78
d77de738
ML
29878These are aliases for the corresponding @option{-mcpu=} option. They
29879are provided for backwards compatibility.
29880
d77de738 29881@opindex mallregs
ddf6fe37 29882@item -mallregs
d77de738
ML
29883Allow the compiler to use all of the available registers. By default
29884registers @code{r24..r31} are reserved for use in interrupt handlers.
29885With this option enabled these registers can be used in ordinary
29886functions as well.
29887
d77de738
ML
29888@opindex m64bit-doubles
29889@opindex m32bit-doubles
ddf6fe37
AA
29890@item -m64bit-doubles
29891@itemx -m32bit-doubles
d77de738
ML
29892Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29893or 32 bits (@option{-m32bit-doubles}) in size. The default is
29894@option{-m32bit-doubles}.
29895
d77de738
ML
29896@opindex msave-mduc-in-interrupts
29897@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29898@item -msave-mduc-in-interrupts
29899@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29900Specifies that interrupt handler functions should preserve the
29901MDUC registers. This is only necessary if normal code might use
29902the MDUC registers, for example because it performs multiplication
29903and division operations. The default is to ignore the MDUC registers
29904as this makes the interrupt handlers faster. The target option -mg13
29905needs to be passed for this to work as this feature is only available
29906on the G13 target (S2 core). The MDUC registers will only be saved
29907if the interrupt handler performs a multiplication or division
29908operation or it calls another function.
29909
29910@end table
29911
29912@node RS/6000 and PowerPC Options
29913@subsection IBM RS/6000 and PowerPC Options
29914@cindex RS/6000 and PowerPC Options
29915@cindex IBM RS/6000 and PowerPC Options
29916
29917These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29918@table @gcctabopt
29919@item -mpowerpc-gpopt
29920@itemx -mno-powerpc-gpopt
29921@itemx -mpowerpc-gfxopt
29922@itemx -mno-powerpc-gfxopt
29923@need 800
29924@itemx -mpowerpc64
29925@itemx -mno-powerpc64
29926@itemx -mmfcrf
29927@itemx -mno-mfcrf
29928@itemx -mpopcntb
29929@itemx -mno-popcntb
29930@itemx -mpopcntd
29931@itemx -mno-popcntd
29932@itemx -mfprnd
29933@itemx -mno-fprnd
29934@need 800
d77de738
ML
29935@opindex mpowerpc-gpopt
29936@opindex mno-powerpc-gpopt
29937@opindex mpowerpc-gfxopt
29938@opindex mno-powerpc-gfxopt
29939@opindex mpowerpc64
29940@opindex mno-powerpc64
29941@opindex mmfcrf
29942@opindex mno-mfcrf
29943@opindex mpopcntb
29944@opindex mno-popcntb
29945@opindex mpopcntd
29946@opindex mno-popcntd
29947@opindex mfprnd
29948@opindex mno-fprnd
29949@opindex mcmpb
29950@opindex mno-cmpb
29951@opindex mhard-dfp
29952@opindex mno-hard-dfp
ddf6fe37
AA
29953@itemx -mcmpb
29954@itemx -mno-cmpb
29955@itemx -mhard-dfp
29956@itemx -mno-hard-dfp
d77de738
ML
29957You use these options to specify which instructions are available on the
29958processor you are using. The default value of these options is
29959determined when configuring GCC@. Specifying the
29960@option{-mcpu=@var{cpu_type}} overrides the specification of these
29961options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29962rather than the options listed above.
29963
29964Specifying @option{-mpowerpc-gpopt} allows
29965GCC to use the optional PowerPC architecture instructions in the
29966General Purpose group, including floating-point square root. Specifying
29967@option{-mpowerpc-gfxopt} allows GCC to
29968use the optional PowerPC architecture instructions in the Graphics
29969group, including floating-point select.
29970
29971The @option{-mmfcrf} option allows GCC to generate the move from
29972condition register field instruction implemented on the POWER4
29973processor and other processors that support the PowerPC V2.01
29974architecture.
29975The @option{-mpopcntb} option allows GCC to generate the popcount and
29976double-precision FP reciprocal estimate instruction implemented on the
29977POWER5 processor and other processors that support the PowerPC V2.02
29978architecture.
29979The @option{-mpopcntd} option allows GCC to generate the popcount
29980instruction implemented on the POWER7 processor and other processors
29981that support the PowerPC V2.06 architecture.
29982The @option{-mfprnd} option allows GCC to generate the FP round to
29983integer instructions implemented on the POWER5+ processor and other
29984processors that support the PowerPC V2.03 architecture.
29985The @option{-mcmpb} option allows GCC to generate the compare bytes
29986instruction implemented on the POWER6 processor and other processors
29987that support the PowerPC V2.05 architecture.
29988The @option{-mhard-dfp} option allows GCC to generate the decimal
29989floating-point instructions implemented on some POWER processors.
29990
29991The @option{-mpowerpc64} option allows GCC to generate the additional
2999264-bit instructions that are found in the full PowerPC64 architecture
29993and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29994@option{-mno-powerpc64}.
29995
d77de738 29996@opindex mcpu
ddf6fe37 29997@item -mcpu=@var{cpu_type}
d77de738
ML
29998Set architecture type, register usage, and
29999instruction scheduling parameters for machine type @var{cpu_type}.
30000Supported values for @var{cpu_type} are @samp{401}, @samp{403},
30001@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
30002@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
30003@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
30004@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
30005@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
30006@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
30007@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
30008@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
30009@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
30010@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
30011@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
30012
30013@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
30014@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
30015endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
30016architecture machine types, with an appropriate, generic processor
30017model assumed for scheduling purposes.
30018
30019Specifying @samp{native} as cpu type detects and selects the
30020architecture option that corresponds to the host processor of the
30021system performing the compilation.
30022@option{-mcpu=native} has no effect if GCC does not recognize the
30023processor.
30024
30025The other options specify a specific processor. Code generated under
30026those options runs best on that processor, and may not run at all on
30027others.
30028
30029The @option{-mcpu} options automatically enable or disable the
30030following options:
30031
43b72ede
AA
30032@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
30033-mpopcntb -mpopcntd -mpowerpc64
30034-mpowerpc-gpopt -mpowerpc-gfxopt
30035-mmulhw -mdlmzb -mmfpgpr -mvsx
30036-mcrypto -mhtm -mpower8-fusion -mpower8-vector
30037-mquad-memory -mquad-memory-atomic -mfloat128
30038-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
30039-mrop-protect}
30040
30041The particular options set for any particular CPU varies between
30042compiler versions, depending on what setting seems to produce optimal
30043code for that CPU; it doesn't necessarily reflect the actual hardware's
30044capabilities. If you wish to set an individual option to a particular
30045value, you may specify it after the @option{-mcpu} option, like
30046@option{-mcpu=970 -mno-altivec}.
30047
30048On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
30049not enabled or disabled by the @option{-mcpu} option at present because
30050AIX does not have full support for these options. You may still
30051enable or disable them individually if you're sure it'll work in your
30052environment.
30053
d77de738 30054@opindex mtune
ddf6fe37 30055@item -mtune=@var{cpu_type}
d77de738
ML
30056Set the instruction scheduling parameters for machine type
30057@var{cpu_type}, but do not set the architecture type or register usage,
30058as @option{-mcpu=@var{cpu_type}} does. The same
30059values for @var{cpu_type} are used for @option{-mtune} as for
30060@option{-mcpu}. If both are specified, the code generated uses the
30061architecture and registers set by @option{-mcpu}, but the
30062scheduling parameters set by @option{-mtune}.
30063
d77de738 30064@opindex mcmodel=small
ddf6fe37 30065@item -mcmodel=small
d77de738
ML
30066Generate PowerPC64 code for the small model: The TOC is limited to
3006764k.
30068
d77de738 30069@opindex mcmodel=medium
ddf6fe37 30070@item -mcmodel=medium
d77de738
ML
30071Generate PowerPC64 code for the medium model: The TOC and other static
30072data may be up to a total of 4G in size. This is the default for 64-bit
30073Linux.
30074
d77de738 30075@opindex mcmodel=large
ddf6fe37 30076@item -mcmodel=large
d77de738
ML
30077Generate PowerPC64 code for the large model: The TOC may be up to 4G
30078in size. Other data and code is only limited by the 64-bit address
30079space.
30080
d77de738
ML
30081@opindex maltivec
30082@opindex mno-altivec
ddf6fe37
AA
30083@item -maltivec
30084@itemx -mno-altivec
d77de738
ML
30085Generate code that uses (does not use) AltiVec instructions, and also
30086enable the use of built-in functions that allow more direct access to
30087the AltiVec instruction set. You may also need to set
30088@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
30089enhancements.
30090
30091When @option{-maltivec} is used, the element order for AltiVec intrinsics
30092such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
30093match array element order corresponding to the endianness of the
30094target. That is, element zero identifies the leftmost element in a
30095vector register when targeting a big-endian platform, and identifies
30096the rightmost element in a vector register when targeting a
30097little-endian platform.
30098
d77de738
ML
30099@opindex mvrsave
30100@opindex mno-vrsave
ddf6fe37
AA
30101@item -mvrsave
30102@itemx -mno-vrsave
d77de738
ML
30103Generate VRSAVE instructions when generating AltiVec code.
30104
d77de738 30105@opindex msecure-plt
ddf6fe37 30106@item -msecure-plt
d77de738
ML
30107Generate code that allows @command{ld} and @command{ld.so}
30108to build executables and shared
30109libraries with non-executable @code{.plt} and @code{.got} sections.
30110This is a PowerPC
3011132-bit SYSV ABI option.
30112
d77de738 30113@opindex mbss-plt
ddf6fe37 30114@item -mbss-plt
d77de738
ML
30115Generate code that uses a BSS @code{.plt} section that @command{ld.so}
30116fills in, and
30117requires @code{.plt} and @code{.got}
30118sections that are both writable and executable.
30119This is a PowerPC 32-bit SYSV ABI option.
30120
d77de738
ML
30121@opindex misel
30122@opindex mno-isel
ddf6fe37
AA
30123@item -misel
30124@itemx -mno-isel
d77de738
ML
30125This switch enables or disables the generation of ISEL instructions.
30126
d77de738
ML
30127@opindex mvsx
30128@opindex mno-vsx
ddf6fe37
AA
30129@item -mvsx
30130@itemx -mno-vsx
d77de738
ML
30131Generate code that uses (does not use) vector/scalar (VSX)
30132instructions, and also enable the use of built-in functions that allow
30133more direct access to the VSX instruction set.
30134
d77de738
ML
30135@opindex mcrypto
30136@opindex mno-crypto
ddf6fe37
AA
30137@item -mcrypto
30138@itemx -mno-crypto
d77de738
ML
30139Enable the use (disable) of the built-in functions that allow direct
30140access to the cryptographic instructions that were added in version
301412.07 of the PowerPC ISA.
30142
d77de738
ML
30143@opindex mhtm
30144@opindex mno-htm
ddf6fe37
AA
30145@item -mhtm
30146@itemx -mno-htm
d77de738
ML
30147Enable (disable) the use of the built-in functions that allow direct
30148access to the Hardware Transactional Memory (HTM) instructions that
30149were added in version 2.07 of the PowerPC ISA.
30150
d77de738
ML
30151@opindex mpower8-fusion
30152@opindex mno-power8-fusion
ddf6fe37
AA
30153@item -mpower8-fusion
30154@itemx -mno-power8-fusion
d77de738
ML
30155Generate code that keeps (does not keeps) some integer operations
30156adjacent so that the instructions can be fused together on power8 and
30157later processors.
30158
d77de738
ML
30159@opindex mpower8-vector
30160@opindex mno-power8-vector
ddf6fe37
AA
30161@item -mpower8-vector
30162@itemx -mno-power8-vector
d77de738
ML
30163Generate code that uses (does not use) the vector and scalar
30164instructions that were added in version 2.07 of the PowerPC ISA. Also
30165enable the use of built-in functions that allow more direct access to
30166the vector instructions.
30167
d77de738
ML
30168@opindex mquad-memory
30169@opindex mno-quad-memory
ddf6fe37
AA
30170@item -mquad-memory
30171@itemx -mno-quad-memory
d77de738
ML
30172Generate code that uses (does not use) the non-atomic quad word memory
30173instructions. The @option{-mquad-memory} option requires use of
3017464-bit mode.
30175
d77de738
ML
30176@opindex mquad-memory-atomic
30177@opindex mno-quad-memory-atomic
ddf6fe37
AA
30178@item -mquad-memory-atomic
30179@itemx -mno-quad-memory-atomic
d77de738
ML
30180Generate code that uses (does not use) the atomic quad word memory
30181instructions. The @option{-mquad-memory-atomic} option requires use of
3018264-bit mode.
30183
d77de738
ML
30184@opindex mfloat128
30185@opindex mno-float128
ddf6fe37
AA
30186@item -mfloat128
30187@itemx -mno-float128
d77de738
ML
30188Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
30189and use either software emulation for IEEE 128-bit floating point or
30190hardware instructions.
30191
30192The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
30193128-bit floating point support. The IEEE 128-bit floating point is only
30194supported on Linux.
30195
30196The default for @option{-mfloat128} is enabled on PowerPC Linux
30197systems using the VSX instruction set, and disabled on other systems.
30198
30199If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
30200@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
30201point support will also enable the generation of ISA 3.0 IEEE 128-bit
30202floating point instructions. Otherwise, if you do not specify to
30203generate ISA 3.0 instructions or you are targeting a 32-bit big endian
30204system, IEEE 128-bit floating point will be done with software
30205emulation.
30206
d77de738
ML
30207@opindex mfloat128-hardware
30208@opindex mno-float128-hardware
ddf6fe37
AA
30209@item -mfloat128-hardware
30210@itemx -mno-float128-hardware
d77de738
ML
30211Enable/disable using ISA 3.0 hardware instructions to support the
30212@var{__float128} data type.
30213
30214The default for @option{-mfloat128-hardware} is enabled on PowerPC
30215Linux systems using the ISA 3.0 instruction set, and disabled on other
30216systems.
30217
d77de738
ML
30218@opindex m32
30219@opindex m64
ddf6fe37
AA
30220@item -m32
30221@itemx -m64
d77de738
ML
30222Generate code for 32-bit or 64-bit environments of Darwin and SVR4
30223targets (including GNU/Linux). The 32-bit environment sets int, long
30224and pointer to 32 bits and generates code that runs on any PowerPC
30225variant. The 64-bit environment sets int to 32 bits and long and
30226pointer to 64 bits, and generates code for PowerPC64, as for
30227@option{-mpowerpc64}.
30228
d77de738
ML
30229@opindex mfull-toc
30230@opindex mno-fp-in-toc
30231@opindex mno-sum-in-toc
30232@opindex mminimal-toc
ddf6fe37
AA
30233@item -mfull-toc
30234@itemx -mno-fp-in-toc
30235@itemx -mno-sum-in-toc
30236@itemx -mminimal-toc
d77de738
ML
30237Modify generation of the TOC (Table Of Contents), which is created for
30238every executable file. The @option{-mfull-toc} option is selected by
30239default. In that case, GCC allocates at least one TOC entry for
30240each unique non-automatic variable reference in your program. GCC
30241also places floating-point constants in the TOC@. However, only
3024216,384 entries are available in the TOC@.
30243
30244If you receive a linker error message that saying you have overflowed
30245the available TOC space, you can reduce the amount of TOC space used
30246with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
30247@option{-mno-fp-in-toc} prevents GCC from putting floating-point
30248constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
30249generate code to calculate the sum of an address and a constant at
30250run time instead of putting that sum into the TOC@. You may specify one
30251or both of these options. Each causes GCC to produce very slightly
30252slower and larger code at the expense of conserving TOC space.
30253
30254If you still run out of space in the TOC even when you specify both of
30255these options, specify @option{-mminimal-toc} instead. This option causes
30256GCC to make only one TOC entry for every file. When you specify this
30257option, GCC produces code that is slower and larger but which
30258uses extremely little TOC space. You may wish to use this option
30259only on files that contain less frequently-executed code.
30260
d77de738
ML
30261@opindex maix64
30262@opindex maix32
ddf6fe37
AA
30263@item -maix64
30264@itemx -maix32
d77de738
ML
30265Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
30266@code{long} type, and the infrastructure needed to support them.
30267Specifying @option{-maix64} implies @option{-mpowerpc64},
30268while @option{-maix32} disables the 64-bit ABI and
30269implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
30270
d77de738
ML
30271@opindex mxl-compat
30272@opindex mno-xl-compat
ddf6fe37
AA
30273@item -mxl-compat
30274@itemx -mno-xl-compat
d77de738
ML
30275Produce code that conforms more closely to IBM XL compiler semantics
30276when using AIX-compatible ABI@. Pass floating-point arguments to
30277prototyped functions beyond the register save area (RSA) on the stack
30278in addition to argument FPRs. Do not assume that most significant
30279double in 128-bit long double value is properly rounded when comparing
30280values and converting to double. Use XL symbol names for long double
30281support routines.
30282
30283The AIX calling convention was extended but not initially documented to
30284handle an obscure K&R C case of calling a function that takes the
30285address of its arguments with fewer arguments than declared. IBM XL
30286compilers access floating-point arguments that do not fit in the
30287RSA from the stack when a subroutine is compiled without
30288optimization. Because always storing floating-point arguments on the
30289stack is inefficient and rarely needed, this option is not enabled by
30290default and only is necessary when calling subroutines compiled by IBM
30291XL compilers without optimization.
30292
d77de738 30293@opindex mpe
ddf6fe37 30294@item -mpe
d77de738
ML
30295Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
30296application written to use message passing with special startup code to
30297enable the application to run. The system must have PE installed in the
30298standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
30299must be overridden with the @option{-specs=} option to specify the
30300appropriate directory location. The Parallel Environment does not
30301support threads, so the @option{-mpe} option and the @option{-pthread}
30302option are incompatible.
30303
d77de738
ML
30304@opindex malign-natural
30305@opindex malign-power
ddf6fe37
AA
30306@item -malign-natural
30307@itemx -malign-power
d77de738
ML
30308On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
30309@option{-malign-natural} overrides the ABI-defined alignment of larger
30310types, such as floating-point doubles, on their natural size-based boundary.
30311The option @option{-malign-power} instructs GCC to follow the ABI-specified
30312alignment rules. GCC defaults to the standard alignment defined in the ABI@.
30313
30314On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
30315is not supported.
30316
d77de738
ML
30317@opindex msoft-float
30318@opindex mhard-float
ddf6fe37
AA
30319@item -msoft-float
30320@itemx -mhard-float
d77de738
ML
30321Generate code that does not use (uses) the floating-point register set.
30322Software floating-point emulation is provided if you use the
30323@option{-msoft-float} option, and pass the option to GCC when linking.
30324
d77de738
ML
30325@opindex mmultiple
30326@opindex mno-multiple
ddf6fe37
AA
30327@item -mmultiple
30328@itemx -mno-multiple
d77de738
ML
30329Generate code that uses (does not use) the load multiple word
30330instructions and the store multiple word instructions. These
30331instructions are generated by default on POWER systems, and not
30332generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
30333PowerPC systems, since those instructions do not work when the
30334processor is in little-endian mode. The exceptions are PPC740 and
30335PPC750 which permit these instructions in little-endian mode.
30336
d77de738
ML
30337@opindex mupdate
30338@opindex mno-update
ddf6fe37
AA
30339@item -mupdate
30340@itemx -mno-update
d77de738
ML
30341Generate code that uses (does not use) the load or store instructions
30342that update the base register to the address of the calculated memory
30343location. These instructions are generated by default. If you use
30344@option{-mno-update}, there is a small window between the time that the
30345stack pointer is updated and the address of the previous frame is
30346stored, which means code that walks the stack frame across interrupts or
30347signals may get corrupted data.
30348
d77de738
ML
30349@opindex mavoid-indexed-addresses
30350@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
30351@item -mavoid-indexed-addresses
30352@itemx -mno-avoid-indexed-addresses
d77de738
ML
30353Generate code that tries to avoid (not avoid) the use of indexed load
30354or store instructions. These instructions can incur a performance
30355penalty on Power6 processors in certain situations, such as when
30356stepping through large arrays that cross a 16M boundary. This option
30357is enabled by default when targeting Power6 and disabled otherwise.
30358
d77de738
ML
30359@opindex mfused-madd
30360@opindex mno-fused-madd
ddf6fe37
AA
30361@item -mfused-madd
30362@itemx -mno-fused-madd
d77de738
ML
30363Generate code that uses (does not use) the floating-point multiply and
30364accumulate instructions. These instructions are generated by default
30365if hardware floating point is used. The machine-dependent
30366@option{-mfused-madd} option is now mapped to the machine-independent
30367@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
30368mapped to @option{-ffp-contract=off}.
30369
d77de738
ML
30370@opindex mmulhw
30371@opindex mno-mulhw
ddf6fe37
AA
30372@item -mmulhw
30373@itemx -mno-mulhw
d77de738
ML
30374Generate code that uses (does not use) the half-word multiply and
30375multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
30376These instructions are generated by default when targeting those
30377processors.
30378
d77de738
ML
30379@opindex mdlmzb
30380@opindex mno-dlmzb
ddf6fe37
AA
30381@item -mdlmzb
30382@itemx -mno-dlmzb
d77de738
ML
30383Generate code that uses (does not use) the string-search @samp{dlmzb}
30384instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
30385generated by default when targeting those processors.
30386
d77de738
ML
30387@opindex mno-bit-align
30388@opindex mbit-align
ddf6fe37
AA
30389@item -mno-bit-align
30390@itemx -mbit-align
d77de738
ML
30391On System V.4 and embedded PowerPC systems do not (do) force structures
30392and unions that contain bit-fields to be aligned to the base type of the
30393bit-field.
30394
30395For example, by default a structure containing nothing but 8
30396@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
30397boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
30398the structure is aligned to a 1-byte boundary and is 1 byte in
30399size.
30400
d77de738
ML
30401@opindex mno-strict-align
30402@opindex mstrict-align
ddf6fe37
AA
30403@item -mno-strict-align
30404@itemx -mstrict-align
d77de738
ML
30405On System V.4 and embedded PowerPC systems do not (do) assume that
30406unaligned memory references are handled by the system.
30407
d77de738
ML
30408@opindex mrelocatable
30409@opindex mno-relocatable
ddf6fe37
AA
30410@item -mrelocatable
30411@itemx -mno-relocatable
d77de738
ML
30412Generate code that allows (does not allow) a static executable to be
30413relocated to a different address at run time. A simple embedded
30414PowerPC system loader should relocate the entire contents of
30415@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
30416a table of 32-bit addresses generated by this option. For this to
30417work, all objects linked together must be compiled with
30418@option{-mrelocatable} or @option{-mrelocatable-lib}.
30419@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
30420
d77de738
ML
30421@opindex mrelocatable-lib
30422@opindex mno-relocatable-lib
ddf6fe37
AA
30423@item -mrelocatable-lib
30424@itemx -mno-relocatable-lib
d77de738
ML
30425Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
30426@code{.fixup} section to allow static executables to be relocated at
30427run time, but @option{-mrelocatable-lib} does not use the smaller stack
30428alignment of @option{-mrelocatable}. Objects compiled with
30429@option{-mrelocatable-lib} may be linked with objects compiled with
30430any combination of the @option{-mrelocatable} options.
30431
d77de738
ML
30432@opindex mno-toc
30433@opindex mtoc
ddf6fe37
AA
30434@item -mno-toc
30435@itemx -mtoc
d77de738
ML
30436On System V.4 and embedded PowerPC systems do not (do) assume that
30437register 2 contains a pointer to a global area pointing to the addresses
30438used in the program.
30439
d77de738
ML
30440@opindex mlittle
30441@opindex mlittle-endian
ddf6fe37
AA
30442@item -mlittle
30443@itemx -mlittle-endian
d77de738
ML
30444On System V.4 and embedded PowerPC systems compile code for the
30445processor in little-endian mode. The @option{-mlittle-endian} option is
30446the same as @option{-mlittle}.
30447
d77de738
ML
30448@opindex mbig
30449@opindex mbig-endian
ddf6fe37
AA
30450@item -mbig
30451@itemx -mbig-endian
d77de738
ML
30452On System V.4 and embedded PowerPC systems compile code for the
30453processor in big-endian mode. The @option{-mbig-endian} option is
30454the same as @option{-mbig}.
30455
d77de738 30456@opindex mdynamic-no-pic
ddf6fe37 30457@item -mdynamic-no-pic
a335cf24 30458On Darwin / macOS systems, compile code so that it is not
d77de738
ML
30459relocatable, but that its external references are relocatable. The
30460resulting code is suitable for applications, but not shared
30461libraries.
30462
d77de738 30463@opindex msingle-pic-base
ddf6fe37 30464@item -msingle-pic-base
d77de738
ML
30465Treat the register used for PIC addressing as read-only, rather than
30466loading it in the prologue for each function. The runtime system is
30467responsible for initializing this register with an appropriate value
30468before execution begins.
30469
d77de738 30470@opindex mprioritize-restricted-insns
ddf6fe37 30471@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
30472This option controls the priority that is assigned to
30473dispatch-slot restricted instructions during the second scheduling
30474pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
30475or @samp{2} to assign no, highest, or second-highest (respectively)
30476priority to dispatch-slot restricted
30477instructions.
30478
d77de738 30479@opindex msched-costly-dep
ddf6fe37 30480@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
30481This option controls which dependences are considered costly
30482by the target during instruction scheduling. The argument
30483@var{dependence_type} takes one of the following values:
30484
30485@table @asis
30486@item @samp{no}
30487No dependence is costly.
30488
30489@item @samp{all}
30490All dependences are costly.
30491
30492@item @samp{true_store_to_load}
30493A true dependence from store to load is costly.
30494
30495@item @samp{store_to_load}
30496Any dependence from store to load is costly.
30497
30498@item @var{number}
30499Any dependence for which the latency is greater than or equal to
30500@var{number} is costly.
30501@end table
30502
d77de738 30503@opindex minsert-sched-nops
ddf6fe37 30504@item -minsert-sched-nops=@var{scheme}
d77de738
ML
30505This option controls which NOP insertion scheme is used during
30506the second scheduling pass. The argument @var{scheme} takes one of the
30507following values:
30508
30509@table @asis
30510@item @samp{no}
30511Don't insert NOPs.
30512
30513@item @samp{pad}
30514Pad with NOPs any dispatch group that has vacant issue slots,
30515according to the scheduler's grouping.
30516
30517@item @samp{regroup_exact}
30518Insert NOPs to force costly dependent insns into
30519separate groups. Insert exactly as many NOPs as needed to force an insn
30520to a new group, according to the estimated processor grouping.
30521
30522@item @var{number}
30523Insert NOPs to force costly dependent insns into
30524separate groups. Insert @var{number} NOPs to force an insn to a new group.
30525@end table
30526
d77de738 30527@opindex mcall-sysv
ddf6fe37 30528@item -mcall-sysv
d77de738
ML
30529On System V.4 and embedded PowerPC systems compile code using calling
30530conventions that adhere to the March 1995 draft of the System V
30531Application Binary Interface, PowerPC processor supplement. This is the
30532default unless you configured GCC using @samp{powerpc-*-eabiaix}.
30533
d77de738
ML
30534@opindex mcall-sysv-eabi
30535@opindex mcall-eabi
ddf6fe37
AA
30536@item -mcall-sysv-eabi
30537@itemx -mcall-eabi
d77de738
ML
30538Specify both @option{-mcall-sysv} and @option{-meabi} options.
30539
d77de738 30540@opindex mcall-sysv-noeabi
ddf6fe37 30541@item -mcall-sysv-noeabi
d77de738
ML
30542Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
30543
d7971cf7 30544@opindex mcall-aixdesc
ddf6fe37 30545@item -mcall-aixdesc
d77de738
ML
30546On System V.4 and embedded PowerPC systems compile code for the AIX
30547operating system.
30548
d77de738 30549@opindex mcall-linux
ddf6fe37 30550@item -mcall-linux
d77de738
ML
30551On System V.4 and embedded PowerPC systems compile code for the
30552Linux-based GNU system.
30553
d77de738 30554@opindex mcall-freebsd
ddf6fe37 30555@item -mcall-freebsd
d77de738
ML
30556On System V.4 and embedded PowerPC systems compile code for the
30557FreeBSD operating system.
30558
d77de738 30559@opindex mcall-netbsd
ddf6fe37 30560@item -mcall-netbsd
d77de738
ML
30561On System V.4 and embedded PowerPC systems compile code for the
30562NetBSD operating system.
30563
d7971cf7 30564@opindex mcall-openbsd
ddf6fe37 30565@item -mcall-openbsd
d77de738
ML
30566On System V.4 and embedded PowerPC systems compile code for the
30567OpenBSD operating system.
30568
d77de738 30569@opindex mtraceback
ddf6fe37 30570@item -mtraceback=@var{traceback_type}
d77de738
ML
30571Select the type of traceback table. Valid values for @var{traceback_type}
30572are @samp{full}, @samp{part}, and @samp{no}.
30573
d77de738 30574@opindex maix-struct-return
ddf6fe37 30575@item -maix-struct-return
d77de738
ML
30576Return all structures in memory (as specified by the AIX ABI)@.
30577
d77de738 30578@opindex msvr4-struct-return
ddf6fe37 30579@item -msvr4-struct-return
d77de738
ML
30580Return structures smaller than 8 bytes in registers (as specified by the
30581SVR4 ABI)@.
30582
d77de738 30583@opindex mabi
ddf6fe37 30584@item -mabi=@var{abi-type}
d77de738
ML
30585Extend the current ABI with a particular extension, or remove such extension.
30586Valid values are: @samp{altivec}, @samp{no-altivec},
30587@samp{ibmlongdouble}, @samp{ieeelongdouble},
30588@samp{elfv1}, @samp{elfv2},
30589and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
30590
d77de738 30591@opindex mabi=ibmlongdouble
ddf6fe37 30592@item -mabi=ibmlongdouble
d77de738
ML
30593Change the current ABI to use IBM extended-precision long double.
30594This is not likely to work if your system defaults to using IEEE
30595extended-precision long double. If you change the long double type
30596from IEEE extended-precision, the compiler will issue a warning unless
30597you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30598to be enabled.
30599
d77de738 30600@opindex mabi=ieeelongdouble
ddf6fe37 30601@item -mabi=ieeelongdouble
d77de738
ML
30602Change the current ABI to use IEEE extended-precision long double.
30603This is not likely to work if your system defaults to using IBM
30604extended-precision long double. If you change the long double type
30605from IBM extended-precision, the compiler will issue a warning unless
30606you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30607to be enabled.
30608
d77de738 30609@opindex mabi=elfv1
ddf6fe37 30610@item -mabi=elfv1
d77de738
ML
30611Change the current ABI to use the ELFv1 ABI.
30612This is the default ABI for big-endian PowerPC 64-bit Linux.
30613Overriding the default ABI requires special system support and is
30614likely to fail in spectacular ways.
30615
d77de738 30616@opindex mabi=elfv2
ddf6fe37 30617@item -mabi=elfv2
d77de738
ML
30618Change the current ABI to use the ELFv2 ABI.
30619This is the default ABI for little-endian PowerPC 64-bit Linux.
30620Overriding the default ABI requires special system support and is
30621likely to fail in spectacular ways.
30622
d77de738
ML
30623@opindex mgnu-attribute
30624@opindex mno-gnu-attribute
ddf6fe37
AA
30625@item -mgnu-attribute
30626@itemx -mno-gnu-attribute
d77de738
ML
30627Emit .gnu_attribute assembly directives to set tag/value pairs in a
30628.gnu.attributes section that specify ABI variations in function
30629parameters or return values.
30630
d77de738
ML
30631@opindex mprototype
30632@opindex mno-prototype
ddf6fe37
AA
30633@item -mprototype
30634@itemx -mno-prototype
d77de738
ML
30635On System V.4 and embedded PowerPC systems assume that all calls to
30636variable argument functions are properly prototyped. Otherwise, the
30637compiler must insert an instruction before every non-prototyped call to
30638set or clear bit 6 of the condition code register (@code{CR}) to
30639indicate whether floating-point values are passed in the floating-point
30640registers in case the function takes variable arguments. With
30641@option{-mprototype}, only calls to prototyped variable argument functions
30642set or clear the bit.
30643
d77de738 30644@opindex msim
ddf6fe37 30645@item -msim
d77de738
ML
30646On embedded PowerPC systems, assume that the startup module is called
30647@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
30648@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
30649configurations.
30650
d77de738 30651@opindex mmvme
ddf6fe37 30652@item -mmvme
d77de738
ML
30653On embedded PowerPC systems, assume that the startup module is called
30654@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
30655@file{libc.a}.
30656
d77de738 30657@opindex mads
ddf6fe37 30658@item -mads
d77de738
ML
30659On embedded PowerPC systems, assume that the startup module is called
30660@file{crt0.o} and the standard C libraries are @file{libads.a} and
30661@file{libc.a}.
30662
d77de738 30663@opindex myellowknife
ddf6fe37 30664@item -myellowknife
d77de738
ML
30665On embedded PowerPC systems, assume that the startup module is called
30666@file{crt0.o} and the standard C libraries are @file{libyk.a} and
30667@file{libc.a}.
30668
d77de738 30669@opindex mvxworks
ddf6fe37 30670@item -mvxworks
d77de738
ML
30671On System V.4 and embedded PowerPC systems, specify that you are
30672compiling for a VxWorks system.
30673
d77de738 30674@opindex memb
ddf6fe37 30675@item -memb
d77de738
ML
30676On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
30677header to indicate that @samp{eabi} extended relocations are used.
30678
d77de738
ML
30679@opindex meabi
30680@opindex mno-eabi
ddf6fe37
AA
30681@item -meabi
30682@itemx -mno-eabi
d77de738
ML
30683On System V.4 and embedded PowerPC systems do (do not) adhere to the
30684Embedded Applications Binary Interface (EABI), which is a set of
30685modifications to the System V.4 specifications. Selecting @option{-meabi}
30686means that the stack is aligned to an 8-byte boundary, a function
30687@code{__eabi} is called from @code{main} to set up the EABI
30688environment, and the @option{-msdata} option can use both @code{r2} and
30689@code{r13} to point to two separate small data areas. Selecting
30690@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
30691no EABI initialization function is called from @code{main}, and the
30692@option{-msdata} option only uses @code{r13} to point to a single
30693small data area. The @option{-meabi} option is on by default if you
30694configured GCC using one of the @samp{powerpc*-*-eabi*} options.
30695
d77de738 30696@opindex msdata=eabi
ddf6fe37 30697@item -msdata=eabi
d77de738
ML
30698On System V.4 and embedded PowerPC systems, put small initialized
30699@code{const} global and static data in the @code{.sdata2} section, which
30700is pointed to by register @code{r2}. Put small initialized
30701non-@code{const} global and static data in the @code{.sdata} section,
30702which is pointed to by register @code{r13}. Put small uninitialized
30703global and static data in the @code{.sbss} section, which is adjacent to
30704the @code{.sdata} section. The @option{-msdata=eabi} option is
30705incompatible with the @option{-mrelocatable} option. The
30706@option{-msdata=eabi} option also sets the @option{-memb} option.
30707
d77de738 30708@opindex msdata=sysv
ddf6fe37 30709@item -msdata=sysv
d77de738
ML
30710On System V.4 and embedded PowerPC systems, put small global and static
30711data in the @code{.sdata} section, which is pointed to by register
30712@code{r13}. Put small uninitialized global and static data in the
30713@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30714The @option{-msdata=sysv} option is incompatible with the
30715@option{-mrelocatable} option.
30716
d77de738
ML
30717@opindex msdata=default
30718@opindex msdata
ddf6fe37
AA
30719@item -msdata=default
30720@itemx -msdata
d77de738
ML
30721On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30722compile code the same as @option{-msdata=eabi}, otherwise compile code the
30723same as @option{-msdata=sysv}.
30724
d77de738 30725@opindex msdata=data
ddf6fe37 30726@item -msdata=data
d77de738
ML
30727On System V.4 and embedded PowerPC systems, put small global
30728data in the @code{.sdata} section. Put small uninitialized global
30729data in the @code{.sbss} section. Do not use register @code{r13}
30730to address small data however. This is the default behavior unless
30731other @option{-msdata} options are used.
30732
d77de738
ML
30733@opindex msdata=none
30734@opindex mno-sdata
ddf6fe37
AA
30735@item -msdata=none
30736@itemx -mno-sdata
d77de738
ML
30737On embedded PowerPC systems, put all initialized global and static data
30738in the @code{.data} section, and all uninitialized data in the
30739@code{.bss} section.
30740
d77de738
ML
30741@opindex mreadonly-in-sdata
30742@opindex mno-readonly-in-sdata
ddf6fe37 30743@item -mreadonly-in-sdata
d77de738
ML
30744Put read-only objects in the @code{.sdata} section as well. This is the
30745default.
30746
d77de738 30747@opindex mblock-move-inline-limit
ddf6fe37 30748@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30749Inline all block moves (such as calls to @code{memcpy} or structure
30750copies) less than or equal to @var{num} bytes. The minimum value for
30751@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30752targets. The default value is target-specific.
30753
d77de738 30754@opindex mblock-compare-inline-limit
ddf6fe37 30755@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30756Generate non-looping inline code for all block compares (such as calls
30757to @code{memcmp} or structure compares) less than or equal to @var{num}
30758bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30759block compare is disabled. The default value is target-specific.
30760
d77de738 30761@opindex mblock-compare-inline-loop-limit
ddf6fe37 30762@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30763Generate an inline expansion using loop code for all block compares that
30764are less than or equal to @var{num} bytes, but greater than the limit
30765for non-loop inline block compare expansion. If the block length is not
30766constant, at most @var{num} bytes will be compared before @code{memcmp}
30767is called to compare the remainder of the block. The default value is
30768target-specific.
30769
d77de738 30770@opindex mstring-compare-inline-limit
ddf6fe37 30771@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30772Compare at most @var{num} string bytes with inline code.
30773If the difference or end of string is not found at the
30774end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30775take care of the rest of the comparison. The default is 64 bytes.
30776
d77de738
ML
30777@opindex G
30778@cindex smaller data references (PowerPC)
30779@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30780@item -G @var{num}
d77de738
ML
30781On embedded PowerPC systems, put global and static items less than or
30782equal to @var{num} bytes into the small data or BSS sections instead of
30783the normal data or BSS section. By default, @var{num} is 8. The
30784@option{-G @var{num}} switch is also passed to the linker.
30785All modules should be compiled with the same @option{-G @var{num}} value.
30786
d77de738
ML
30787@opindex mregnames
30788@opindex mno-regnames
ddf6fe37
AA
30789@item -mregnames
30790@itemx -mno-regnames
d77de738
ML
30791On System V.4 and embedded PowerPC systems do (do not) emit register
30792names in the assembly language output using symbolic forms.
30793
d77de738
ML
30794@opindex mlongcall
30795@opindex mno-longcall
ddf6fe37
AA
30796@item -mlongcall
30797@itemx -mno-longcall
d77de738
ML
30798By default assume that all calls are far away so that a longer and more
30799expensive calling sequence is required. This is required for calls
30800farther than 32 megabytes (33,554,432 bytes) from the current location.
30801A short call is generated if the compiler knows
30802the call cannot be that far away. This setting can be overridden by
30803the @code{shortcall} function attribute, or by @code{#pragma
30804longcall(0)}.
30805
30806Some linkers are capable of detecting out-of-range calls and generating
30807glue code on the fly. On these systems, long calls are unnecessary and
30808generate slower code. As of this writing, the AIX linker can do this,
30809as can the GNU linker for PowerPC/64. It is planned to add this feature
30810to the GNU linker for 32-bit PowerPC systems as well.
30811
30812On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30813GCC can generate long calls using an inline PLT call sequence (see
30814@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30815ELFv1 (big-endian) do not support inline PLT calls.
30816
30817On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30818callee, L42}, plus a @dfn{branch island} (glue code). The two target
30819addresses represent the callee and the branch island. The
30820Darwin/PPC linker prefers the first address and generates a @code{bl
30821callee} if the PPC @code{bl} instruction reaches the callee directly;
30822otherwise, the linker generates @code{bl L42} to call the branch
30823island. The branch island is appended to the body of the
30824calling function; it computes the full 32-bit address of the callee
30825and jumps to it.
30826
30827On Mach-O (Darwin) systems, this option directs the compiler emit to
30828the glue for every direct call, and the Darwin linker decides whether
30829to use or discard it.
30830
30831In the future, GCC may ignore all longcall specifications
30832when the linker is known to generate glue.
30833
d77de738
ML
30834@opindex mpltseq
30835@opindex mno-pltseq
ddf6fe37
AA
30836@item -mpltseq
30837@itemx -mno-pltseq
d77de738
ML
30838Implement (do not implement) -fno-plt and long calls using an inline
30839PLT call sequence that supports lazy linking and long calls to
30840functions in dlopen'd shared libraries. Inline PLT calls are only
30841supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30842linkers, and are enabled by default if the support is detected when
30843configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30844configured with @option{--enable-secureplt}. @option{-mpltseq} code
30845and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30846linked together.
30847
d77de738
ML
30848@opindex mtls-markers
30849@opindex mno-tls-markers
ddf6fe37
AA
30850@item -mtls-markers
30851@itemx -mno-tls-markers
d77de738
ML
30852Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30853specifying the function argument. The relocation allows the linker to
30854reliably associate function call with argument setup instructions for
30855TLS optimization, which in turn allows GCC to better schedule the
30856sequence.
30857
ddf6fe37 30858@opindex mrecip
d77de738
ML
30859@item -mrecip
30860@itemx -mno-recip
d77de738
ML
30861This option enables use of the reciprocal estimate and
30862reciprocal square root estimate instructions with additional
30863Newton-Raphson steps to increase precision instead of doing a divide or
30864square root and divide for floating-point arguments. You should use
30865the @option{-ffast-math} option when using @option{-mrecip} (or at
30866least @option{-funsafe-math-optimizations},
30867@option{-ffinite-math-only}, @option{-freciprocal-math} and
30868@option{-fno-trapping-math}). Note that while the throughput of the
30869sequence is generally higher than the throughput of the non-reciprocal
30870instruction, the precision of the sequence can be decreased by up to 2
30871ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30872roots.
30873
d77de738 30874@opindex mrecip=opt
ddf6fe37 30875@item -mrecip=@var{opt}
d77de738
ML
30876This option controls which reciprocal estimate instructions
30877may be used. @var{opt} is a comma-separated list of options, which may
30878be preceded by a @code{!} to invert the option:
30879
30880@table @samp
30881
30882@item all
30883Enable all estimate instructions.
30884
30885@item default
30886Enable the default instructions, equivalent to @option{-mrecip}.
30887
30888@item none
30889Disable all estimate instructions, equivalent to @option{-mno-recip}.
30890
30891@item div
30892Enable the reciprocal approximation instructions for both
30893single and double precision.
30894
30895@item divf
30896Enable the single-precision reciprocal approximation instructions.
30897
30898@item divd
30899Enable the double-precision reciprocal approximation instructions.
30900
30901@item rsqrt
30902Enable the reciprocal square root approximation instructions for both
30903single and double precision.
30904
30905@item rsqrtf
30906Enable the single-precision reciprocal square root approximation instructions.
30907
30908@item rsqrtd
30909Enable the double-precision reciprocal square root approximation instructions.
30910
30911@end table
30912
30913So, for example, @option{-mrecip=all,!rsqrtd} enables
30914all of the reciprocal estimate instructions, except for the
30915@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30916which handle the double-precision reciprocal square root calculations.
30917
ddf6fe37 30918@opindex mrecip-precision
d77de738
ML
30919@item -mrecip-precision
30920@itemx -mno-recip-precision
d77de738
ML
30921Assume (do not assume) that the reciprocal estimate instructions
30922provide higher-precision estimates than is mandated by the PowerPC
30923ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30924@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30925The double-precision square root estimate instructions are not generated by
30926default on low-precision machines, since they do not provide an
30927estimate that converges after three steps.
30928
d77de738 30929@opindex mveclibabi
ddf6fe37 30930@item -mveclibabi=@var{type}
d77de738
ML
30931Specifies the ABI type to use for vectorizing intrinsics using an
30932external library. The only type supported at present is @samp{mass},
30933which specifies to use IBM's Mathematical Acceleration Subsystem
30934(MASS) libraries for vectorizing intrinsics using external libraries.
30935GCC currently emits calls to @code{acosd2}, @code{acosf4},
30936@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30937@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30938@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30939@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30940@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30941@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30942@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30943@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30944@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30945@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30946@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30947@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30948@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30949for power7. Both @option{-ftree-vectorize} and
30950@option{-funsafe-math-optimizations} must also be enabled. The MASS
30951libraries must be specified at link time.
30952
ddf6fe37 30953@opindex mfriz
d77de738
ML
30954@item -mfriz
30955@itemx -mno-friz
d77de738
ML
30956Generate (do not generate) the @code{friz} instruction when the
30957@option{-funsafe-math-optimizations} option is used to optimize
30958rounding of floating-point values to 64-bit integer and back to floating
30959point. The @code{friz} instruction does not return the same value if
30960the floating-point number is too large to fit in an integer.
30961
ddf6fe37 30962@opindex mpointers-to-nested-functions
d77de738
ML
30963@item -mpointers-to-nested-functions
30964@itemx -mno-pointers-to-nested-functions
d77de738
ML
30965Generate (do not generate) code to load up the static chain register
30966(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30967systems where a function pointer points to a 3-word descriptor giving
30968the function address, TOC value to be loaded in register @code{r2}, and
30969static chain value to be loaded in register @code{r11}. The
30970@option{-mpointers-to-nested-functions} is on by default. You cannot
30971call through pointers to nested functions or pointers
30972to functions compiled in other languages that use the static chain if
30973you use @option{-mno-pointers-to-nested-functions}.
30974
ddf6fe37 30975@opindex msave-toc-indirect
d77de738
ML
30976@item -msave-toc-indirect
30977@itemx -mno-save-toc-indirect
d77de738
ML
30978Generate (do not generate) code to save the TOC value in the reserved
30979stack location in the function prologue if the function calls through
30980a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30981saved in the prologue, it is saved just before the call through the
30982pointer. The @option{-mno-save-toc-indirect} option is the default.
30983
ddf6fe37 30984@opindex mcompat-align-parm
d77de738
ML
30985@item -mcompat-align-parm
30986@itemx -mno-compat-align-parm
d77de738
ML
30987Generate (do not generate) code to pass structure parameters with a
30988maximum alignment of 64 bits, for compatibility with older versions
30989of GCC.
30990
30991Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30992structure parameter on a 128-bit boundary when that structure contained
30993a member requiring 128-bit alignment. This is corrected in more
30994recent versions of GCC. This option may be used to generate code
30995that is compatible with functions compiled with older versions of
30996GCC.
30997
30998The @option{-mno-compat-align-parm} option is the default.
30999
d77de738
ML
31000@opindex mstack-protector-guard
31001@opindex mstack-protector-guard-reg
31002@opindex mstack-protector-guard-offset
31003@opindex mstack-protector-guard-symbol
ddf6fe37
AA
31004@item -mstack-protector-guard=@var{guard}
31005@itemx -mstack-protector-guard-reg=@var{reg}
31006@itemx -mstack-protector-guard-offset=@var{offset}
31007@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
31008Generate stack protection code using canary at @var{guard}. Supported
31009locations are @samp{global} for global canary or @samp{tls} for per-thread
31010canary in the TLS block (the default with GNU libc version 2.4 or later).
31011
31012With the latter choice the options
31013@option{-mstack-protector-guard-reg=@var{reg}} and
31014@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
31015which register to use as base register for reading the canary, and from what
31016offset from that base register. The default for those is as specified in the
31017relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
31018the offset with a symbol reference to a canary in the TLS block.
31019
d77de738
ML
31020@opindex mpcrel
31021@opindex mno-pcrel
ddf6fe37
AA
31022@item -mpcrel
31023@itemx -mno-pcrel
d77de738
ML
31024Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
31025option requires that the medium code model (@option{-mcmodel=medium})
31026and prefixed addressing (@option{-mprefixed}) options are enabled.
31027
d77de738
ML
31028@opindex mprefixed
31029@opindex mno-prefixed
ddf6fe37
AA
31030@item -mprefixed
31031@itemx -mno-prefixed
d77de738
ML
31032Generate (do not generate) addressing modes using prefixed load and
31033store instructions. The @option{-mprefixed} option requires that
31034the option @option{-mcpu=power10} (or later) is enabled.
31035
d77de738
ML
31036@opindex mmma
31037@opindex mno-mma
ddf6fe37
AA
31038@item -mmma
31039@itemx -mno-mma
d77de738
ML
31040Generate (do not generate) the MMA instructions. The @option{-mma}
31041option requires that the option @option{-mcpu=power10} (or later)
31042is enabled.
31043
d77de738
ML
31044@opindex mrop-protect
31045@opindex mno-rop-protect
ddf6fe37
AA
31046@item -mrop-protect
31047@itemx -mno-rop-protect
d77de738
ML
31048Generate (do not generate) ROP protection instructions when the target
31049processor supports them. Currently this option disables the shrink-wrap
31050optimization (@option{-fshrink-wrap}).
31051
d77de738
ML
31052@opindex mprivileged
31053@opindex mno-privileged
ddf6fe37
AA
31054@item -mprivileged
31055@itemx -mno-privileged
d77de738
ML
31056Generate (do not generate) code that will run in privileged state.
31057
d77de738
ML
31058@opindex block-ops-unaligned-vsx
31059@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
31060@item -mblock-ops-unaligned-vsx
31061@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
31062Generate (do not generate) unaligned vsx loads and stores for
31063inline expansion of @code{memcpy} and @code{memmove}.
31064
31065@item --param rs6000-vect-unroll-limit=
31066The vectorizer will check with target information to determine whether it
31067would be beneficial to unroll the main vectorized loop and by how much. This
31068parameter sets the upper bound of how much the vectorizer will unroll the main
31069loop. The default value is four.
31070
31071@end table
31072
31073@node RX Options
31074@subsection RX Options
31075@cindex RX Options
31076
31077These command-line options are defined for RX targets:
31078
31079@table @gcctabopt
d77de738
ML
31080@opindex m64bit-doubles
31081@opindex m32bit-doubles
ddf6fe37
AA
31082@item -m64bit-doubles
31083@itemx -m32bit-doubles
d77de738
ML
31084Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
31085or 32 bits (@option{-m32bit-doubles}) in size. The default is
31086@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
31087works on 32-bit values, which is why the default is
31088@option{-m32bit-doubles}.
31089
d77de738
ML
31090@opindex fpu
31091@opindex nofpu
ddf6fe37
AA
31092@item -fpu
31093@itemx -nofpu
d77de738
ML
31094Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
31095floating-point hardware. The default is enabled for the RX600
31096series and disabled for the RX200 series.
31097
31098Floating-point instructions are only generated for 32-bit floating-point
31099values, however, so the FPU hardware is not used for doubles if the
31100@option{-m64bit-doubles} option is used.
31101
31102@emph{Note} If the @option{-fpu} option is enabled then
31103@option{-funsafe-math-optimizations} is also enabled automatically.
31104This is because the RX FPU instructions are themselves unsafe.
31105
d77de738 31106@opindex mcpu
ddf6fe37 31107@item -mcpu=@var{name}
d77de738
ML
31108Selects the type of RX CPU to be targeted. Currently three types are
31109supported, the generic @samp{RX600} and @samp{RX200} series hardware and
31110the specific @samp{RX610} CPU. The default is @samp{RX600}.
31111
31112The only difference between @samp{RX600} and @samp{RX610} is that the
31113@samp{RX610} does not support the @code{MVTIPL} instruction.
31114
31115The @samp{RX200} series does not have a hardware floating-point unit
31116and so @option{-nofpu} is enabled by default when this type is
31117selected.
31118
d77de738
ML
31119@opindex mbig-endian-data
31120@opindex mlittle-endian-data
ddf6fe37
AA
31121@item -mbig-endian-data
31122@itemx -mlittle-endian-data
d77de738
ML
31123Store data (but not code) in the big-endian format. The default is
31124@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
31125format.
31126
d77de738 31127@opindex msmall-data-limit
ddf6fe37 31128@item -msmall-data-limit=@var{N}
d77de738
ML
31129Specifies the maximum size in bytes of global and static variables
31130which can be placed into the small data area. Using the small data
31131area can lead to smaller and faster code, but the size of area is
31132limited and it is up to the programmer to ensure that the area does
31133not overflow. Also when the small data area is used one of the RX's
31134registers (usually @code{r13}) is reserved for use pointing to this
31135area, so it is no longer available for use by the compiler. This
31136could result in slower and/or larger code if variables are pushed onto
31137the stack instead of being held in this register.
31138
31139Note, common variables (variables that have not been initialized) and
31140constants are not placed into the small data area as they are assigned
31141to other sections in the output executable.
31142
31143The default value is zero, which disables this feature. Note, this
31144feature is not enabled by default with higher optimization levels
31145(@option{-O2} etc) because of the potentially detrimental effects of
31146reserving a register. It is up to the programmer to experiment and
31147discover whether this feature is of benefit to their program. See the
31148description of the @option{-mpid} option for a description of how the
31149actual register to hold the small data area pointer is chosen.
31150
d77de738
ML
31151@opindex msim
31152@opindex mno-sim
ddf6fe37
AA
31153@item -msim
31154@itemx -mno-sim
d77de738
ML
31155Use the simulator runtime. The default is to use the libgloss
31156board-specific runtime.
31157
d77de738
ML
31158@opindex mas100-syntax
31159@opindex mno-as100-syntax
ddf6fe37
AA
31160@item -mas100-syntax
31161@itemx -mno-as100-syntax
d77de738
ML
31162When generating assembler output use a syntax that is compatible with
31163Renesas's AS100 assembler. This syntax can also be handled by the GAS
31164assembler, but it has some restrictions so it is not generated by default.
31165
d77de738 31166@opindex mmax-constant-size
ddf6fe37 31167@item -mmax-constant-size=@var{N}
d77de738
ML
31168Specifies the maximum size, in bytes, of a constant that can be used as
31169an operand in a RX instruction. Although the RX instruction set does
31170allow constants of up to 4 bytes in length to be used in instructions,
31171a longer value equates to a longer instruction. Thus in some
31172circumstances it can be beneficial to restrict the size of constants
31173that are used in instructions. Constants that are too big are instead
31174placed into a constant pool and referenced via register indirection.
31175
31176The value @var{N} can be between 0 and 4. A value of 0 (the default)
31177or 4 means that constants of any size are allowed.
31178
d77de738 31179@opindex mrelax
ddf6fe37 31180@item -mrelax
d77de738
ML
31181Enable linker relaxation. Linker relaxation is a process whereby the
31182linker attempts to reduce the size of a program by finding shorter
31183versions of various instructions. Disabled by default.
31184
d77de738 31185@opindex mint-register
ddf6fe37 31186@item -mint-register=@var{N}
d77de738
ML
31187Specify the number of registers to reserve for fast interrupt handler
31188functions. The value @var{N} can be between 0 and 4. A value of 1
31189means that register @code{r13} is reserved for the exclusive use
31190of fast interrupt handlers. A value of 2 reserves @code{r13} and
31191@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
31192@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
31193A value of 0, the default, does not reserve any registers.
31194
d77de738 31195@opindex msave-acc-in-interrupts
ddf6fe37 31196@item -msave-acc-in-interrupts
d77de738
ML
31197Specifies that interrupt handler functions should preserve the
31198accumulator register. This is only necessary if normal code might use
31199the accumulator register, for example because it performs 64-bit
31200multiplications. The default is to ignore the accumulator as this
31201makes the interrupt handlers faster.
31202
d77de738
ML
31203@opindex mpid
31204@opindex mno-pid
ddf6fe37
AA
31205@item -mpid
31206@itemx -mno-pid
d77de738
ML
31207Enables the generation of position independent data. When enabled any
31208access to constant data is done via an offset from a base address
31209held in a register. This allows the location of constant data to be
31210determined at run time without requiring the executable to be
31211relocated, which is a benefit to embedded applications with tight
31212memory constraints. Data that can be modified is not affected by this
31213option.
31214
31215Note, using this feature reserves a register, usually @code{r13}, for
31216the constant data base address. This can result in slower and/or
31217larger code, especially in complicated functions.
31218
31219The actual register chosen to hold the constant data base address
31220depends upon whether the @option{-msmall-data-limit} and/or the
31221@option{-mint-register} command-line options are enabled. Starting
31222with register @code{r13} and proceeding downwards, registers are
31223allocated first to satisfy the requirements of @option{-mint-register},
31224then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
31225is possible for the small data area register to be @code{r8} if both
31226@option{-mint-register=4} and @option{-mpid} are specified on the
31227command line.
31228
31229By default this feature is not enabled. The default can be restored
31230via the @option{-mno-pid} command-line option.
31231
d77de738
ML
31232@opindex mno-warn-multiple-fast-interrupts
31233@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
31234@item -mno-warn-multiple-fast-interrupts
31235@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
31236Prevents GCC from issuing a warning message if it finds more than one
31237fast interrupt handler when it is compiling a file. The default is to
31238issue a warning for each extra fast interrupt handler found, as the RX
31239only supports one such interrupt.
31240
d77de738
ML
31241@opindex mallow-string-insns
31242@opindex mno-allow-string-insns
ddf6fe37
AA
31243@item -mallow-string-insns
31244@itemx -mno-allow-string-insns
d77de738
ML
31245Enables or disables the use of the string manipulation instructions
31246@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
31247@code{SWHILE} and also the @code{RMPA} instruction. These
31248instructions may prefetch data, which is not safe to do if accessing
31249an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
31250for more information).
31251
31252The default is to allow these instructions, but it is not possible for
31253GCC to reliably detect all circumstances where a string instruction
31254might be used to access an I/O register, so their use cannot be
31255disabled automatically. Instead it is reliant upon the programmer to
31256use the @option{-mno-allow-string-insns} option if their program
31257accesses I/O space.
31258
31259When the instructions are enabled GCC defines the C preprocessor
31260symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
31261symbol @code{__RX_DISALLOW_STRING_INSNS__}.
31262
d77de738
ML
31263@opindex mjsr
31264@opindex mno-jsr
ddf6fe37
AA
31265@item -mjsr
31266@itemx -mno-jsr
d77de738
ML
31267Use only (or not only) @code{JSR} instructions to access functions.
31268This option can be used when code size exceeds the range of @code{BSR}
31269instructions. Note that @option{-mno-jsr} does not mean to not use
31270@code{JSR} but instead means that any type of branch may be used.
31271@end table
31272
31273@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
31274has special significance to the RX port when used with the
31275@code{interrupt} function attribute. This attribute indicates a
31276function intended to process fast interrupts. GCC ensures
31277that it only uses the registers @code{r10}, @code{r11}, @code{r12}
31278and/or @code{r13} and only provided that the normal use of the
31279corresponding registers have been restricted via the
31280@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
31281options.
31282
31283@node S/390 and zSeries Options
31284@subsection S/390 and zSeries Options
31285@cindex S/390 and zSeries Options
31286
31287These are the @samp{-m} options defined for the S/390 and zSeries architecture.
31288
31289@table @gcctabopt
d77de738
ML
31290@opindex mhard-float
31291@opindex msoft-float
ddf6fe37
AA
31292@item -mhard-float
31293@itemx -msoft-float
d77de738
ML
31294Use (do not use) the hardware floating-point instructions and registers
31295for floating-point operations. When @option{-msoft-float} is specified,
31296functions in @file{libgcc.a} are used to perform floating-point
31297operations. When @option{-mhard-float} is specified, the compiler
31298generates IEEE floating-point instructions. This is the default.
31299
d77de738
ML
31300@opindex mhard-dfp
31301@opindex mno-hard-dfp
ddf6fe37
AA
31302@item -mhard-dfp
31303@itemx -mno-hard-dfp
d77de738
ML
31304Use (do not use) the hardware decimal-floating-point instructions for
31305decimal-floating-point operations. When @option{-mno-hard-dfp} is
31306specified, functions in @file{libgcc.a} are used to perform
31307decimal-floating-point operations. When @option{-mhard-dfp} is
31308specified, the compiler generates decimal-floating-point hardware
31309instructions. This is the default for @option{-march=z9-ec} or higher.
31310
d77de738
ML
31311@opindex mlong-double-64
31312@opindex mlong-double-128
ddf6fe37
AA
31313@item -mlong-double-64
31314@itemx -mlong-double-128
d77de738
ML
31315These switches control the size of @code{long double} type. A size
31316of 64 bits makes the @code{long double} type equivalent to the @code{double}
31317type. This is the default.
31318
d77de738
ML
31319@opindex mbackchain
31320@opindex mno-backchain
ddf6fe37
AA
31321@item -mbackchain
31322@itemx -mno-backchain
d77de738
ML
31323Store (do not store) the address of the caller's frame as backchain pointer
31324into the callee's stack frame.
31325A backchain may be needed to allow debugging using tools that do not understand
31326DWARF call frame information.
31327When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
31328at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
31329the backchain is placed into the topmost word of the 96/160 byte register
31330save area.
31331
31332In general, code compiled with @option{-mbackchain} is call-compatible with
31333code compiled with @option{-mno-backchain}; however, use of the backchain
31334for debugging purposes usually requires that the whole binary is built with
31335@option{-mbackchain}. Note that the combination of @option{-mbackchain},
31336@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31337to build a linux kernel use @option{-msoft-float}.
31338
31339The default is to not maintain the backchain.
31340
d77de738
ML
31341@opindex mpacked-stack
31342@opindex mno-packed-stack
ddf6fe37
AA
31343@item -mpacked-stack
31344@itemx -mno-packed-stack
d77de738
ML
31345Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
31346specified, the compiler uses the all fields of the 96/160 byte register save
31347area only for their default purpose; unused fields still take up stack space.
31348When @option{-mpacked-stack} is specified, register save slots are densely
31349packed at the top of the register save area; unused space is reused for other
31350purposes, allowing for more efficient use of the available stack space.
31351However, when @option{-mbackchain} is also in effect, the topmost word of
31352the save area is always used to store the backchain, and the return address
31353register is always saved two words below the backchain.
31354
31355As long as the stack frame backchain is not used, code generated with
31356@option{-mpacked-stack} is call-compatible with code generated with
31357@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
31358S/390 or zSeries generated code that uses the stack frame backchain at run
31359time, not just for debugging purposes. Such code is not call-compatible
31360with code compiled with @option{-mpacked-stack}. Also, note that the
31361combination of @option{-mbackchain},
31362@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31363to build a linux kernel use @option{-msoft-float}.
31364
31365The default is to not use the packed stack layout.
31366
d77de738
ML
31367@opindex msmall-exec
31368@opindex mno-small-exec
ddf6fe37
AA
31369@item -msmall-exec
31370@itemx -mno-small-exec
d77de738
ML
31371Generate (or do not generate) code using the @code{bras} instruction
31372to do subroutine calls.
31373This only works reliably if the total executable size does not
31374exceed 64k. The default is to use the @code{basr} instruction instead,
31375which does not have this limitation.
31376
d77de738
ML
31377@opindex m64
31378@opindex m31
ddf6fe37
AA
31379@item -m64
31380@itemx -m31
d77de738
ML
31381When @option{-m31} is specified, generate code compliant to the
31382GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
31383code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
31384particular to generate 64-bit instructions. For the @samp{s390}
31385targets, the default is @option{-m31}, while the @samp{s390x}
31386targets default to @option{-m64}.
31387
d77de738
ML
31388@opindex mzarch
31389@opindex mesa
ddf6fe37
AA
31390@item -mzarch
31391@itemx -mesa
d77de738
ML
31392When @option{-mzarch} is specified, generate code using the
31393instructions available on z/Architecture.
31394When @option{-mesa} is specified, generate code using the
31395instructions available on ESA/390. Note that @option{-mesa} is
31396not possible with @option{-m64}.
31397When generating code compliant to the GNU/Linux for S/390 ABI,
31398the default is @option{-mesa}. When generating code compliant
31399to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
31400
d77de738
ML
31401@opindex mhtm
31402@opindex mno-htm
ddf6fe37
AA
31403@item -mhtm
31404@itemx -mno-htm
d77de738
ML
31405The @option{-mhtm} option enables a set of builtins making use of
31406instructions available with the transactional execution facility
31407introduced with the IBM zEnterprise EC12 machine generation
31408@ref{S/390 System z Built-in Functions}.
31409@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
31410
d77de738
ML
31411@opindex mvx
31412@opindex mno-vx
ddf6fe37
AA
31413@item -mvx
31414@itemx -mno-vx
d77de738
ML
31415When @option{-mvx} is specified, generate code using the instructions
31416available with the vector extension facility introduced with the IBM
31417z13 machine generation.
31418This option changes the ABI for some vector type values with regard to
31419alignment and calling conventions. In case vector type values are
31420being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
31421command will be added to mark the resulting binary with the ABI used.
31422@option{-mvx} is enabled by default when using @option{-march=z13}.
31423
d77de738
ML
31424@opindex mzvector
31425@opindex mno-zvector
ddf6fe37
AA
31426@item -mzvector
31427@itemx -mno-zvector
d77de738
ML
31428The @option{-mzvector} option enables vector language extensions and
31429builtins using instructions available with the vector extension
31430facility introduced with the IBM z13 machine generation.
31431This option adds support for @samp{vector} to be used as a keyword to
31432define vector type variables and arguments. @samp{vector} is only
31433available when GNU extensions are enabled. It will not be expanded
31434when requesting strict standard compliance e.g.@: with @option{-std=c99}.
31435In addition to the GCC low-level builtins @option{-mzvector} enables
31436a set of builtins added for compatibility with AltiVec-style
31437implementations like Power and Cell. In order to make use of these
31438builtins the header file @file{vecintrin.h} needs to be included.
31439@option{-mzvector} is disabled by default.
31440
d77de738
ML
31441@opindex mmvcle
31442@opindex mno-mvcle
ddf6fe37
AA
31443@item -mmvcle
31444@itemx -mno-mvcle
d77de738
ML
31445Generate (or do not generate) code using the @code{mvcle} instruction
31446to perform block moves. When @option{-mno-mvcle} is specified,
31447use a @code{mvc} loop instead. This is the default unless optimizing for
31448size.
31449
d77de738
ML
31450@opindex mdebug
31451@opindex mno-debug
ddf6fe37
AA
31452@item -mdebug
31453@itemx -mno-debug
d77de738
ML
31454Print (or do not print) additional debug information when compiling.
31455The default is to not print debug information.
31456
d77de738 31457@opindex march
ddf6fe37 31458@item -march=@var{cpu-type}
d77de738
ML
31459Generate code that runs on @var{cpu-type}, which is the name of a
31460system representing a certain processor type. Possible values for
31461@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
31462@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
31463@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
31464@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
31465@samp{z16}/@samp{arch14}, and @samp{native}.
31466
31467The default is @option{-march=z900}.
31468
31469Specifying @samp{native} as cpu type can be used to select the best
31470architecture option for the host processor.
31471@option{-march=native} has no effect if GCC does not recognize the
31472processor.
31473
d77de738 31474@opindex mtune
ddf6fe37 31475@item -mtune=@var{cpu-type}
d77de738
ML
31476Tune to @var{cpu-type} everything applicable about the generated code,
31477except for the ABI and the set of available instructions.
31478The list of @var{cpu-type} values is the same as for @option{-march}.
31479The default is the value used for @option{-march}.
31480
d77de738
ML
31481@opindex mtpf-trace
31482@opindex mno-tpf-trace
ddf6fe37
AA
31483@item -mtpf-trace
31484@itemx -mno-tpf-trace
d77de738
ML
31485Generate code that adds (does not add) in TPF OS specific branches to trace
31486routines in the operating system. This option is off by default, even
31487when compiling for the TPF OS@.
31488
d77de738
ML
31489@opindex mtpf-trace-skip
31490@opindex mno-tpf-trace-skip
ddf6fe37
AA
31491@item -mtpf-trace-skip
31492@itemx -mno-tpf-trace-skip
d77de738
ML
31493Generate code that changes (does not change) the default branch
31494targets enabled by @option{-mtpf-trace} to point to specialized trace
31495routines providing the ability of selectively skipping function trace
31496entries for the TPF OS. This option is off by default, even when
31497compiling for the TPF OS and specifying @option{-mtpf-trace}.
31498
d77de738
ML
31499@opindex mfused-madd
31500@opindex mno-fused-madd
ddf6fe37
AA
31501@item -mfused-madd
31502@itemx -mno-fused-madd
d77de738
ML
31503Generate code that uses (does not use) the floating-point multiply and
31504accumulate instructions. These instructions are generated by default if
31505hardware floating point is used.
31506
d77de738 31507@opindex mwarn-framesize
ddf6fe37 31508@item -mwarn-framesize=@var{framesize}
d77de738
ML
31509Emit a warning if the current function exceeds the given frame size. Because
31510this is a compile-time check it doesn't need to be a real problem when the program
31511runs. It is intended to identify functions that most probably cause
31512a stack overflow. It is useful to be used in an environment with limited stack
31513size e.g.@: the linux kernel.
31514
d77de738 31515@opindex mwarn-dynamicstack
ddf6fe37 31516@item -mwarn-dynamicstack
d77de738
ML
31517Emit a warning if the function calls @code{alloca} or uses dynamically-sized
31518arrays. This is generally a bad idea with a limited stack size.
31519
d77de738
ML
31520@opindex mstack-guard
31521@opindex mstack-size
ddf6fe37
AA
31522@item -mstack-guard=@var{stack-guard}
31523@itemx -mstack-size=@var{stack-size}
d77de738
ML
31524If these options are provided the S/390 back end emits additional instructions in
31525the function prologue that trigger a trap if the stack size is @var{stack-guard}
31526bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
31527If the @var{stack-guard} option is omitted the smallest power of 2 larger than
31528the frame size of the compiled function is chosen.
31529These options are intended to be used to help debugging stack overflow problems.
31530The additionally emitted code causes only little overhead and hence can also be
31531used in production-like systems without greater performance degradation. The given
31532values have to be exact powers of 2 and @var{stack-size} has to be greater than
31533@var{stack-guard} without exceeding 64k.
31534In order to be efficient the extra code makes the assumption that the stack starts
31535at an address aligned to the value given by @var{stack-size}.
31536The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
31537
d77de738 31538@opindex mhotpatch
ddf6fe37 31539@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
31540If the hotpatch option is enabled, a ``hot-patching'' function
31541prologue is generated for all functions in the compilation unit.
31542The funtion label is prepended with the given number of two-byte
31543NOP instructions (@var{pre-halfwords}, maximum 1000000). After
31544the label, 2 * @var{post-halfwords} bytes are appended, using the
31545largest NOP like instructions the architecture allows (maximum
315461000000).
31547
31548If both arguments are zero, hotpatching is disabled.
31549
31550This option can be overridden for individual functions with the
31551@code{hotpatch} attribute.
31552@end table
31553
d77de738
ML
31554@node SH Options
31555@subsection SH Options
31556
31557These @samp{-m} options are defined for the SH implementations:
31558
31559@table @gcctabopt
d77de738 31560@opindex m1
ddf6fe37 31561@item -m1
d77de738
ML
31562Generate code for the SH1.
31563
d77de738 31564@opindex m2
ddf6fe37 31565@item -m2
d77de738
ML
31566Generate code for the SH2.
31567
31568@item -m2e
31569Generate code for the SH2e.
31570
d77de738 31571@opindex m2a-nofpu
ddf6fe37 31572@item -m2a-nofpu
d77de738
ML
31573Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
31574that the floating-point unit is not used.
31575
d77de738 31576@opindex m2a-single-only
ddf6fe37 31577@item -m2a-single-only
d77de738
ML
31578Generate code for the SH2a-FPU, in such a way that no double-precision
31579floating-point operations are used.
31580
d77de738 31581@opindex m2a-single
ddf6fe37 31582@item -m2a-single
d77de738
ML
31583Generate code for the SH2a-FPU assuming the floating-point unit is in
31584single-precision mode by default.
31585
d77de738 31586@opindex m2a
ddf6fe37 31587@item -m2a
d77de738
ML
31588Generate code for the SH2a-FPU assuming the floating-point unit is in
31589double-precision mode by default.
31590
d77de738 31591@opindex m3
ddf6fe37 31592@item -m3
d77de738
ML
31593Generate code for the SH3.
31594
d77de738 31595@opindex m3e
ddf6fe37 31596@item -m3e
d77de738
ML
31597Generate code for the SH3e.
31598
d77de738 31599@opindex m4-nofpu
ddf6fe37 31600@item -m4-nofpu
d77de738
ML
31601Generate code for the SH4 without a floating-point unit.
31602
d77de738 31603@opindex m4-single-only
ddf6fe37 31604@item -m4-single-only
d77de738
ML
31605Generate code for the SH4 with a floating-point unit that only
31606supports single-precision arithmetic.
31607
d77de738 31608@opindex m4-single
ddf6fe37 31609@item -m4-single
d77de738
ML
31610Generate code for the SH4 assuming the floating-point unit is in
31611single-precision mode by default.
31612
d77de738 31613@opindex m4
ddf6fe37 31614@item -m4
d77de738
ML
31615Generate code for the SH4.
31616
d77de738 31617@opindex m4-100
ddf6fe37 31618@item -m4-100
d77de738
ML
31619Generate code for SH4-100.
31620
d77de738 31621@opindex m4-100-nofpu
ddf6fe37 31622@item -m4-100-nofpu
d77de738
ML
31623Generate code for SH4-100 in such a way that the
31624floating-point unit is not used.
31625
d77de738 31626@opindex m4-100-single
ddf6fe37 31627@item -m4-100-single
d77de738
ML
31628Generate code for SH4-100 assuming the floating-point unit is in
31629single-precision mode by default.
31630
d77de738 31631@opindex m4-100-single-only
ddf6fe37 31632@item -m4-100-single-only
d77de738
ML
31633Generate code for SH4-100 in such a way that no double-precision
31634floating-point operations are used.
31635
d77de738 31636@opindex m4-200
ddf6fe37 31637@item -m4-200
d77de738
ML
31638Generate code for SH4-200.
31639
d77de738 31640@opindex m4-200-nofpu
ddf6fe37 31641@item -m4-200-nofpu
d77de738
ML
31642Generate code for SH4-200 without in such a way that the
31643floating-point unit is not used.
31644
d77de738 31645@opindex m4-200-single
ddf6fe37 31646@item -m4-200-single
d77de738
ML
31647Generate code for SH4-200 assuming the floating-point unit is in
31648single-precision mode by default.
31649
d77de738 31650@opindex m4-200-single-only
ddf6fe37 31651@item -m4-200-single-only
d77de738
ML
31652Generate code for SH4-200 in such a way that no double-precision
31653floating-point operations are used.
31654
d77de738 31655@opindex m4-300
ddf6fe37 31656@item -m4-300
d77de738
ML
31657Generate code for SH4-300.
31658
d77de738 31659@opindex m4-300-nofpu
ddf6fe37 31660@item -m4-300-nofpu
d77de738
ML
31661Generate code for SH4-300 without in such a way that the
31662floating-point unit is not used.
31663
d77de738 31664@opindex m4-300-single
ddf6fe37 31665@item -m4-300-single
d77de738
ML
31666Generate code for SH4-300 in such a way that no double-precision
31667floating-point operations are used.
31668
d77de738 31669@opindex m4-300-single-only
ddf6fe37 31670@item -m4-300-single-only
d77de738
ML
31671Generate code for SH4-300 in such a way that no double-precision
31672floating-point operations are used.
31673
d77de738 31674@opindex m4-340
ddf6fe37 31675@item -m4-340
d77de738
ML
31676Generate code for SH4-340 (no MMU, no FPU).
31677
d77de738 31678@opindex m4-500
ddf6fe37 31679@item -m4-500
d77de738
ML
31680Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
31681assembler.
31682
d77de738 31683@opindex m4a-nofpu
ddf6fe37 31684@item -m4a-nofpu
d77de738
ML
31685Generate code for the SH4al-dsp, or for a SH4a in such a way that the
31686floating-point unit is not used.
31687
d77de738 31688@opindex m4a-single-only
ddf6fe37 31689@item -m4a-single-only
d77de738
ML
31690Generate code for the SH4a, in such a way that no double-precision
31691floating-point operations are used.
31692
d77de738 31693@opindex m4a-single
ddf6fe37 31694@item -m4a-single
d77de738
ML
31695Generate code for the SH4a assuming the floating-point unit is in
31696single-precision mode by default.
31697
d77de738 31698@opindex m4a
ddf6fe37 31699@item -m4a
d77de738
ML
31700Generate code for the SH4a.
31701
d77de738 31702@opindex m4al
ddf6fe37 31703@item -m4al
d77de738
ML
31704Same as @option{-m4a-nofpu}, except that it implicitly passes
31705@option{-dsp} to the assembler. GCC doesn't generate any DSP
31706instructions at the moment.
31707
d77de738 31708@opindex mb
ddf6fe37 31709@item -mb
d77de738
ML
31710Compile code for the processor in big-endian mode.
31711
d77de738 31712@opindex ml
ddf6fe37 31713@item -ml
d77de738
ML
31714Compile code for the processor in little-endian mode.
31715
d77de738 31716@opindex mdalign
ddf6fe37 31717@item -mdalign
d77de738
ML
31718Align doubles at 64-bit boundaries. Note that this changes the calling
31719conventions, and thus some functions from the standard C library do
31720not work unless you recompile it first with @option{-mdalign}.
31721
d77de738 31722@opindex mrelax
ddf6fe37 31723@item -mrelax
d77de738
ML
31724Shorten some address references at link time, when possible; uses the
31725linker option @option{-relax}.
31726
d77de738 31727@opindex mbigtable
ddf6fe37 31728@item -mbigtable
d77de738
ML
31729Use 32-bit offsets in @code{switch} tables. The default is to use
3173016-bit offsets.
31731
d77de738 31732@opindex mbitops
ddf6fe37 31733@item -mbitops
d77de738
ML
31734Enable the use of bit manipulation instructions on SH2A.
31735
d77de738 31736@opindex mfmovd
ddf6fe37 31737@item -mfmovd
d77de738
ML
31738Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31739alignment constraints.
31740
d77de738 31741@opindex mrenesas
ddf6fe37 31742@item -mrenesas
d77de738
ML
31743Comply with the calling conventions defined by Renesas.
31744
d77de738 31745@opindex mno-renesas
ddf6fe37 31746@item -mno-renesas
d77de738
ML
31747Comply with the calling conventions defined for GCC before the Renesas
31748conventions were available. This option is the default for all
31749targets of the SH toolchain.
31750
d77de738 31751@opindex mnomacsave
ddf6fe37 31752@item -mnomacsave
d77de738
ML
31753Mark the @code{MAC} register as call-clobbered, even if
31754@option{-mrenesas} is given.
31755
d77de738
ML
31756@opindex mieee
31757@opindex mno-ieee
ddf6fe37
AA
31758@item -mieee
31759@itemx -mno-ieee
d77de738
ML
31760Control the IEEE compliance of floating-point comparisons, which affects the
31761handling of cases where the result of a comparison is unordered. By default
31762@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31763enabled @option{-mno-ieee} is implicitly set, which results in faster
31764floating-point greater-equal and less-equal comparisons. The implicit settings
31765can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31766
d77de738 31767@opindex minline-ic_invalidate
ddf6fe37 31768@item -minline-ic_invalidate
d77de738
ML
31769Inline code to invalidate instruction cache entries after setting up
31770nested function trampolines.
31771This option has no effect if @option{-musermode} is in effect and the selected
31772code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31773instruction.
31774If the selected code generation option does not allow the use of the @code{icbi}
31775instruction, and @option{-musermode} is not in effect, the inlined code
31776manipulates the instruction cache address array directly with an associative
31777write. This not only requires privileged mode at run time, but it also
31778fails if the cache line had been mapped via the TLB and has become unmapped.
31779
d77de738 31780@opindex misize
ddf6fe37 31781@item -misize
d77de738
ML
31782Dump instruction size and location in the assembly code.
31783
d77de738 31784@opindex mpadstruct
ddf6fe37 31785@item -mpadstruct
d77de738
ML
31786This option is deprecated. It pads structures to multiple of 4 bytes,
31787which is incompatible with the SH ABI@.
31788
d77de738 31789@opindex matomic-model=@var{model}
ddf6fe37 31790@item -matomic-model=@var{model}
d77de738
ML
31791Sets the model of atomic operations and additional parameters as a comma
31792separated list. For details on the atomic built-in functions see
31793@ref{__atomic Builtins}. The following models and parameters are supported:
31794
31795@table @samp
31796
31797@item none
31798Disable compiler generated atomic sequences and emit library calls for atomic
31799operations. This is the default if the target is not @code{sh*-*-linux*}.
31800
31801@item soft-gusa
31802Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31803built-in functions. The generated atomic sequences require additional support
31804from the interrupt/exception handling code of the system and are only suitable
31805for SH3* and SH4* single-core systems. This option is enabled by default when
31806the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31807this option also partially utilizes the hardware atomic instructions
31808@code{movli.l} and @code{movco.l} to create more efficient code, unless
31809@samp{strict} is specified.
31810
31811@item soft-tcb
31812Generate software atomic sequences that use a variable in the thread control
31813block. This is a variation of the gUSA sequences which can also be used on
31814SH1* and SH2* targets. The generated atomic sequences require additional
31815support from the interrupt/exception handling code of the system and are only
31816suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31817parameter has to be specified as well.
31818
31819@item soft-imask
31820Generate software atomic sequences that temporarily disable interrupts by
31821setting @code{SR.IMASK = 1111}. This model works only when the program runs
31822in privileged mode and is only suitable for single-core systems. Additional
31823support from the interrupt/exception handling code of the system is not
31824required. This model is enabled by default when the target is
31825@code{sh*-*-linux*} and SH1* or SH2*.
31826
31827@item hard-llcs
31828Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31829instructions only. This is only available on SH4A and is suitable for
31830multi-core systems. Since the hardware instructions support only 32 bit atomic
31831variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31832Code compiled with this option is also compatible with other software
31833atomic model interrupt/exception handling systems if executed on an SH4A
31834system. Additional support from the interrupt/exception handling code of the
31835system is not required for this model.
31836
31837@item gbr-offset=
31838This parameter specifies the offset in bytes of the variable in the thread
31839control block structure that should be used by the generated atomic sequences
31840when the @samp{soft-tcb} model has been selected. For other models this
31841parameter is ignored. The specified value must be an integer multiple of four
31842and in the range 0-1020.
31843
31844@item strict
31845This parameter prevents mixed usage of multiple atomic models, even if they
31846are compatible, and makes the compiler generate atomic sequences of the
31847specified model only.
31848
31849@end table
31850
d77de738 31851@opindex mtas
ddf6fe37 31852@item -mtas
d77de738
ML
31853Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31854Notice that depending on the particular hardware and software configuration
31855this can degrade overall performance due to the operand cache line flushes
31856that are implied by the @code{tas.b} instruction. On multi-core SH4A
31857processors the @code{tas.b} instruction must be used with caution since it
31858can result in data corruption for certain cache configurations.
31859
d77de738 31860@opindex mprefergot
ddf6fe37 31861@item -mprefergot
d77de738
ML
31862When generating position-independent code, emit function calls using
31863the Global Offset Table instead of the Procedure Linkage Table.
31864
d77de738
ML
31865@opindex musermode
31866@opindex mno-usermode
ddf6fe37
AA
31867@item -musermode
31868@itemx -mno-usermode
d77de738
ML
31869Don't allow (allow) the compiler generating privileged mode code. Specifying
31870@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31871inlined code would not work in user mode. @option{-musermode} is the default
31872when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31873@option{-musermode} has no effect, since there is no user mode.
31874
d77de738 31875@opindex multcost=@var{number}
ddf6fe37 31876@item -multcost=@var{number}
d77de738
ML
31877Set the cost to assume for a multiply insn.
31878
d77de738 31879@opindex mdiv=@var{strategy}
ddf6fe37 31880@item -mdiv=@var{strategy}
d77de738
ML
31881Set the division strategy to be used for integer division operations.
31882@var{strategy} can be one of:
31883
31884@table @samp
31885
31886@item call-div1
31887Calls a library function that uses the single-step division instruction
31888@code{div1} to perform the operation. Division by zero calculates an
31889unspecified result and does not trap. This is the default except for SH4,
31890SH2A and SHcompact.
31891
31892@item call-fp
31893Calls a library function that performs the operation in double precision
31894floating point. Division by zero causes a floating-point exception. This is
31895the default for SHcompact with FPU. Specifying this for targets that do not
31896have a double precision FPU defaults to @code{call-div1}.
31897
31898@item call-table
31899Calls a library function that uses a lookup table for small divisors and
31900the @code{div1} instruction with case distinction for larger divisors. Division
31901by zero calculates an unspecified result and does not trap. This is the default
31902for SH4. Specifying this for targets that do not have dynamic shift
31903instructions defaults to @code{call-div1}.
31904
31905@end table
31906
31907When a division strategy has not been specified the default strategy is
31908selected based on the current target. For SH2A the default strategy is to
31909use the @code{divs} and @code{divu} instructions instead of library function
31910calls.
31911
d77de738 31912@opindex maccumulate-outgoing-args
ddf6fe37 31913@item -maccumulate-outgoing-args
d77de738
ML
31914Reserve space once for outgoing arguments in the function prologue rather
31915than around each call. Generally beneficial for performance and size. Also
31916needed for unwinding to avoid changing the stack frame around conditional code.
31917
d77de738 31918@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31919@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31920Set the name of the library function used for 32-bit signed division to
31921@var{name}.
31922This only affects the name used in the @samp{call} division strategies, and
31923the compiler still expects the same sets of input/output/clobbered registers as
31924if this option were not present.
31925
d77de738 31926@opindex mfixed-range
ddf6fe37 31927@item -mfixed-range=@var{register-range}
d77de738
ML
31928Generate code treating the given register range as fixed registers.
31929A fixed register is one that the register allocator cannot use. This is
31930useful when compiling kernel code. A register range is specified as
31931two registers separated by a dash. Multiple register ranges can be
31932specified separated by a comma.
31933
d77de738 31934@opindex mbranch-cost=@var{num}
ddf6fe37 31935@item -mbranch-cost=@var{num}
d77de738
ML
31936Assume @var{num} to be the cost for a branch instruction. Higher numbers
31937make the compiler try to generate more branch-free code if possible.
31938If not specified the value is selected depending on the processor type that
31939is being compiled for.
31940
d77de738
ML
31941@opindex mzdcbranch
31942@opindex mno-zdcbranch
ddf6fe37
AA
31943@item -mzdcbranch
31944@itemx -mno-zdcbranch
d77de738
ML
31945Assume (do not assume) that zero displacement conditional branch instructions
31946@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31947compiler prefers zero displacement branch code sequences. This is
31948enabled by default when generating code for SH4 and SH4A. It can be explicitly
31949disabled by specifying @option{-mno-zdcbranch}.
31950
d77de738 31951@opindex mcbranch-force-delay-slot
ddf6fe37 31952@item -mcbranch-force-delay-slot
d77de738
ML
31953Force the usage of delay slots for conditional branches, which stuffs the delay
31954slot with a @code{nop} if a suitable instruction cannot be found. By default
31955this option is disabled. It can be enabled to work around hardware bugs as
31956found in the original SH7055.
31957
d77de738
ML
31958@opindex mfused-madd
31959@opindex mno-fused-madd
ddf6fe37
AA
31960@item -mfused-madd
31961@itemx -mno-fused-madd
d77de738
ML
31962Generate code that uses (does not use) the floating-point multiply and
31963accumulate instructions. These instructions are generated by default
31964if hardware floating point is used. The machine-dependent
31965@option{-mfused-madd} option is now mapped to the machine-independent
31966@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31967mapped to @option{-ffp-contract=off}.
31968
d77de738
ML
31969@opindex mfsca
31970@opindex mno-fsca
ddf6fe37
AA
31971@item -mfsca
31972@itemx -mno-fsca
d77de738
ML
31973Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31974and cosine approximations. The option @option{-mfsca} must be used in
31975combination with @option{-funsafe-math-optimizations}. It is enabled by default
31976when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31977approximations even if @option{-funsafe-math-optimizations} is in effect.
31978
d77de738
ML
31979@opindex mfsrra
31980@opindex mno-fsrra
ddf6fe37
AA
31981@item -mfsrra
31982@itemx -mno-fsrra
d77de738
ML
31983Allow or disallow the compiler to emit the @code{fsrra} instruction for
31984reciprocal square root approximations. The option @option{-mfsrra} must be used
31985in combination with @option{-funsafe-math-optimizations} and
31986@option{-ffinite-math-only}. It is enabled by default when generating code for
31987SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31988even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31989in effect.
31990
d77de738 31991@opindex mpretend-cmove
ddf6fe37 31992@item -mpretend-cmove
d77de738
ML
31993Prefer zero-displacement conditional branches for conditional move instruction
31994patterns. This can result in faster code on the SH4 processor.
31995
d77de738 31996@opindex fdpic
ddf6fe37 31997@item -mfdpic
d77de738
ML
31998Generate code using the FDPIC ABI.
31999
32000@end table
32001
32002@node Solaris 2 Options
32003@subsection Solaris 2 Options
32004@cindex Solaris 2 options
32005
32006These @samp{-m} options are supported on Solaris 2:
32007
32008@table @gcctabopt
d77de738 32009@opindex mclear-hwcap
ddf6fe37 32010@item -mclear-hwcap
d77de738
ML
32011@option{-mclear-hwcap} tells the compiler to remove the hardware
32012capabilities generated by the Solaris assembler. This is only necessary
32013when object files use ISA extensions not supported by the current
32014machine, but check at runtime whether or not to use them.
32015
d77de738 32016@opindex mimpure-text
ddf6fe37 32017@item -mimpure-text
d77de738
ML
32018@option{-mimpure-text}, used in addition to @option{-shared}, tells
32019the compiler to not pass @option{-z text} to the linker when linking a
32020shared object. Using this option, you can link position-dependent
32021code into a shared object.
32022
32023@option{-mimpure-text} suppresses the ``relocations remain against
32024allocatable but non-writable sections'' linker error message.
32025However, the necessary relocations trigger copy-on-write, and the
32026shared object is not actually shared across processes. Instead of
32027using @option{-mimpure-text}, you should compile all source code with
32028@option{-fpic} or @option{-fPIC}.
32029
32030@end table
32031
32032These switches are supported in addition to the above on Solaris 2:
32033
32034@table @gcctabopt
d77de738 32035@opindex pthreads
ddf6fe37 32036@item -pthreads
d77de738
ML
32037This is a synonym for @option{-pthread}.
32038@end table
32039
32040@node SPARC Options
32041@subsection SPARC Options
32042@cindex SPARC options
32043
32044These @samp{-m} options are supported on the SPARC:
32045
32046@table @gcctabopt
d77de738
ML
32047@opindex mno-app-regs
32048@opindex mapp-regs
ddf6fe37
AA
32049@item -mno-app-regs
32050@itemx -mapp-regs
d77de738
ML
32051Specify @option{-mapp-regs} to generate output using the global registers
320522 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
32053global register 1, each global register 2 through 4 is then treated as an
32054allocable register that is clobbered by function calls. This is the default.
32055
32056To be fully SVR4 ABI-compliant at the cost of some performance loss,
32057specify @option{-mno-app-regs}. You should compile libraries and system
32058software with this option.
32059
d77de738
ML
32060@opindex mflat
32061@opindex mno-flat
ddf6fe37
AA
32062@item -mflat
32063@itemx -mno-flat
d77de738
ML
32064With @option{-mflat}, the compiler does not generate save/restore instructions
32065and uses a ``flat'' or single register window model. This model is compatible
32066with the regular register window model. The local registers and the input
32067registers (0--5) are still treated as ``call-saved'' registers and are
32068saved on the stack as needed.
32069
32070With @option{-mno-flat} (the default), the compiler generates save/restore
32071instructions (except for leaf functions). This is the normal operating mode.
32072
d77de738
ML
32073@opindex mfpu
32074@opindex mhard-float
ddf6fe37
AA
32075@item -mfpu
32076@itemx -mhard-float
d77de738
ML
32077Generate output containing floating-point instructions. This is the
32078default.
32079
d77de738
ML
32080@opindex mno-fpu
32081@opindex msoft-float
ddf6fe37
AA
32082@item -mno-fpu
32083@itemx -msoft-float
d77de738
ML
32084Generate output containing library calls for floating point.
32085@strong{Warning:} the requisite libraries are not available for all SPARC
32086targets. Normally the facilities of the machine's usual C compiler are
32087used, but this cannot be done directly in cross-compilation. You must make
32088your own arrangements to provide suitable library functions for
32089cross-compilation. The embedded targets @samp{sparc-*-aout} and
32090@samp{sparclite-*-*} do provide software floating-point support.
32091
32092@option{-msoft-float} changes the calling convention in the output file;
32093therefore, it is only useful if you compile @emph{all} of a program with
32094this option. In particular, you need to compile @file{libgcc.a}, the
32095library that comes with GCC, with @option{-msoft-float} in order for
32096this to work.
32097
d77de738 32098@opindex mhard-quad-float
ddf6fe37 32099@item -mhard-quad-float
d77de738
ML
32100Generate output containing quad-word (long double) floating-point
32101instructions.
32102
d77de738 32103@opindex msoft-quad-float
ddf6fe37 32104@item -msoft-quad-float
d77de738
ML
32105Generate output containing library calls for quad-word (long double)
32106floating-point instructions. The functions called are those specified
32107in the SPARC ABI@. This is the default.
32108
32109As of this writing, there are no SPARC implementations that have hardware
32110support for the quad-word floating-point instructions. They all invoke
32111a trap handler for one of these instructions, and then the trap handler
32112emulates the effect of the instruction. Because of the trap handler overhead,
32113this is much slower than calling the ABI library routines. Thus the
32114@option{-msoft-quad-float} option is the default.
32115
d77de738
ML
32116@opindex mno-unaligned-doubles
32117@opindex munaligned-doubles
ddf6fe37
AA
32118@item -mno-unaligned-doubles
32119@itemx -munaligned-doubles
d77de738
ML
32120Assume that doubles have 8-byte alignment. This is the default.
32121
32122With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
32123alignment only if they are contained in another type, or if they have an
32124absolute address. Otherwise, it assumes they have 4-byte alignment.
32125Specifying this option avoids some rare compatibility problems with code
32126generated by other compilers. It is not the default because it results
32127in a performance loss, especially for floating-point code.
32128
d77de738
ML
32129@opindex muser-mode
32130@opindex mno-user-mode
ddf6fe37
AA
32131@item -muser-mode
32132@itemx -mno-user-mode
d77de738
ML
32133Do not generate code that can only run in supervisor mode. This is relevant
32134only for the @code{casa} instruction emitted for the LEON3 processor. This
32135is the default.
32136
d77de738
ML
32137@opindex mfaster-structs
32138@opindex mno-faster-structs
ddf6fe37
AA
32139@item -mfaster-structs
32140@itemx -mno-faster-structs
d77de738
ML
32141With @option{-mfaster-structs}, the compiler assumes that structures
32142should have 8-byte alignment. This enables the use of pairs of
32143@code{ldd} and @code{std} instructions for copies in structure
32144assignment, in place of twice as many @code{ld} and @code{st} pairs.
32145However, the use of this changed alignment directly violates the SPARC
32146ABI@. Thus, it's intended only for use on targets where the developer
32147acknowledges that their resulting code is not directly in line with
32148the rules of the ABI@.
32149
d77de738
ML
32150@opindex mstd-struct-return
32151@opindex mno-std-struct-return
ddf6fe37
AA
32152@item -mstd-struct-return
32153@itemx -mno-std-struct-return
d77de738
ML
32154With @option{-mstd-struct-return}, the compiler generates checking code
32155in functions returning structures or unions to detect size mismatches
32156between the two sides of function calls, as per the 32-bit ABI@.
32157
32158The default is @option{-mno-std-struct-return}. This option has no effect
32159in 64-bit mode.
32160
d77de738
ML
32161@opindex mlra
32162@opindex mno-lra
ddf6fe37
AA
32163@item -mlra
32164@itemx -mno-lra
d77de738
ML
32165Enable Local Register Allocation. This is the default for SPARC since GCC 7
32166so @option{-mno-lra} needs to be passed to get old Reload.
32167
d77de738 32168@opindex mcpu
ddf6fe37 32169@item -mcpu=@var{cpu_type}
d77de738
ML
32170Set the instruction set, register set, and instruction scheduling parameters
32171for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32172@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
32173@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
32174@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
32175@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
32176@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
32177@samp{m8}.
32178
32179Native Solaris and GNU/Linux toolchains also support the value @samp{native},
32180which selects the best architecture option for the host processor.
32181@option{-mcpu=native} has no effect if GCC does not recognize
32182the processor.
32183
32184Default instruction scheduling parameters are used for values that select
32185an architecture and not an implementation. These are @samp{v7}, @samp{v8},
32186@samp{sparclite}, @samp{sparclet}, @samp{v9}.
32187
32188Here is a list of each supported architecture and their supported
32189implementations.
32190
32191@table @asis
32192@item v7
32193cypress, leon3v7
32194
32195@item v8
32196supersparc, hypersparc, leon, leon3, leon5
32197
32198@item sparclite
32199f930, f934, sparclite86x
32200
32201@item sparclet
32202tsc701
32203
32204@item v9
32205ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
32206niagara7, m8
32207@end table
32208
32209By default (unless configured otherwise), GCC generates code for the V7
32210variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
32211additionally optimizes it for the Cypress CY7C602 chip, as used in the
32212SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
32213SPARCStation 1, 2, IPX etc.
32214
32215With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
32216architecture. The only difference from V7 code is that the compiler emits
32217the integer multiply and integer divide instructions which exist in SPARC-V8
32218but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
32219optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
322202000 series.
32221
32222With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
32223the SPARC architecture. This adds the integer multiply, integer divide step
32224and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
32225With @option{-mcpu=f930}, the compiler additionally optimizes it for the
32226Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
32227@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
32228MB86934 chip, which is the more recent SPARClite with FPU@.
32229
32230With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
32231the SPARC architecture. This adds the integer multiply, multiply/accumulate,
32232integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
32233but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
32234optimizes it for the TEMIC SPARClet chip.
32235
32236With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
32237architecture. This adds 64-bit integer and floating-point move instructions,
322383 additional floating-point condition code registers and conditional move
32239instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
32240optimizes it for the Sun UltraSPARC I/II/IIi chips. With
32241@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
32242Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
32243@option{-mcpu=niagara}, the compiler additionally optimizes it for
32244Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
32245additionally optimizes it for Sun UltraSPARC T2 chips. With
32246@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
32247UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
32248additionally optimizes it for Sun UltraSPARC T4 chips. With
32249@option{-mcpu=niagara7}, the compiler additionally optimizes it for
32250Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
32251additionally optimizes it for Oracle M8 chips.
32252
d77de738 32253@opindex mtune
ddf6fe37 32254@item -mtune=@var{cpu_type}
d77de738
ML
32255Set the instruction scheduling parameters for machine type
32256@var{cpu_type}, but do not set the instruction set or register set that the
32257option @option{-mcpu=@var{cpu_type}} does.
32258
32259The same values for @option{-mcpu=@var{cpu_type}} can be used for
32260@option{-mtune=@var{cpu_type}}, but the only useful values are those
32261that select a particular CPU implementation. Those are
32262@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
32263@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
32264@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
32265@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
32266@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
32267and GNU/Linux toolchains, @samp{native} can also be used.
32268
d77de738
ML
32269@opindex mv8plus
32270@opindex mno-v8plus
ddf6fe37
AA
32271@item -mv8plus
32272@itemx -mno-v8plus
d77de738
ML
32273With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
32274difference from the V8 ABI is that the global and out registers are
32275considered 64 bits wide. This is enabled by default on Solaris in 32-bit
32276mode for all SPARC-V9 processors.
32277
d77de738
ML
32278@opindex mvis
32279@opindex mno-vis
ddf6fe37
AA
32280@item -mvis
32281@itemx -mno-vis
d77de738
ML
32282With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
32283Visual Instruction Set extensions. The default is @option{-mno-vis}.
32284
d77de738
ML
32285@opindex mvis2
32286@opindex mno-vis2
ddf6fe37
AA
32287@item -mvis2
32288@itemx -mno-vis2
d77de738
ML
32289With @option{-mvis2}, GCC generates code that takes advantage of
32290version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
32291default is @option{-mvis2} when targeting a cpu that supports such
32292instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
32293also sets @option{-mvis}.
32294
d77de738
ML
32295@opindex mvis3
32296@opindex mno-vis3
ddf6fe37
AA
32297@item -mvis3
32298@itemx -mno-vis3
d77de738
ML
32299With @option{-mvis3}, GCC generates code that takes advantage of
32300version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
32301default is @option{-mvis3} when targeting a cpu that supports such
32302instructions, such as niagara-3 and later. Setting @option{-mvis3}
32303also sets @option{-mvis2} and @option{-mvis}.
32304
d77de738
ML
32305@opindex mvis4
32306@opindex mno-vis4
ddf6fe37
AA
32307@item -mvis4
32308@itemx -mno-vis4
d77de738
ML
32309With @option{-mvis4}, GCC generates code that takes advantage of
32310version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
32311default is @option{-mvis4} when targeting a cpu that supports such
32312instructions, such as niagara-7 and later. Setting @option{-mvis4}
32313also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
32314
d77de738
ML
32315@opindex mvis4b
32316@opindex mno-vis4b
ddf6fe37
AA
32317@item -mvis4b
32318@itemx -mno-vis4b
d77de738
ML
32319With @option{-mvis4b}, GCC generates code that takes advantage of
32320version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
32321the additional VIS instructions introduced in the Oracle SPARC
32322Architecture 2017. The default is @option{-mvis4b} when targeting a
32323cpu that supports such instructions, such as m8 and later. Setting
32324@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
32325@option{-mvis2} and @option{-mvis}.
32326
d77de738
ML
32327@opindex mcbcond
32328@opindex mno-cbcond
ddf6fe37
AA
32329@item -mcbcond
32330@itemx -mno-cbcond
d77de738
ML
32331With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
32332Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
32333when targeting a CPU that supports such instructions, such as Niagara-4 and
32334later.
32335
d77de738
ML
32336@opindex mfmaf
32337@opindex mno-fmaf
ddf6fe37
AA
32338@item -mfmaf
32339@itemx -mno-fmaf
d77de738
ML
32340With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
32341Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
32342when targeting a CPU that supports such instructions, such as Niagara-3 and
32343later.
32344
d77de738
ML
32345@opindex mfsmuld
32346@opindex mno-fsmuld
ddf6fe37
AA
32347@item -mfsmuld
32348@itemx -mno-fsmuld
d77de738
ML
32349With @option{-mfsmuld}, GCC generates code that takes advantage of the
32350Floating-point Multiply Single to Double (FsMULd) instruction. The default is
32351@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
32352or V9 with FPU except @option{-mcpu=leon}.
32353
d77de738
ML
32354@opindex mpopc
32355@opindex mno-popc
ddf6fe37
AA
32356@item -mpopc
32357@itemx -mno-popc
d77de738
ML
32358With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
32359Population Count instruction. The default is @option{-mpopc}
32360when targeting a CPU that supports such an instruction, such as Niagara-2 and
32361later.
32362
d77de738
ML
32363@opindex msubxc
32364@opindex mno-subxc
ddf6fe37
AA
32365@item -msubxc
32366@itemx -mno-subxc
d77de738
ML
32367With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
32368Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
32369when targeting a CPU that supports such an instruction, such as Niagara-7 and
32370later.
32371
d77de738 32372@opindex mfix-at697f
ddf6fe37 32373@item -mfix-at697f
d77de738
ML
32374Enable the documented workaround for the single erratum of the Atmel AT697F
32375processor (which corresponds to erratum #13 of the AT697E processor).
32376
d77de738 32377@opindex mfix-ut699
ddf6fe37 32378@item -mfix-ut699
d77de738
ML
32379Enable the documented workarounds for the floating-point errata and the data
32380cache nullify errata of the UT699 processor.
32381
d77de738 32382@opindex mfix-ut700
ddf6fe37 32383@item -mfix-ut700
d77de738
ML
32384Enable the documented workaround for the back-to-back store errata of
32385the UT699E/UT700 processor.
32386
d77de738 32387@opindex mfix-gr712rc
ddf6fe37 32388@item -mfix-gr712rc
d77de738
ML
32389Enable the documented workaround for the back-to-back store errata of
32390the GR712RC processor.
32391@end table
32392
32393These @samp{-m} options are supported in addition to the above
32394on SPARC-V9 processors in 64-bit environments:
32395
32396@table @gcctabopt
d77de738
ML
32397@opindex m32
32398@opindex m64
ddf6fe37
AA
32399@item -m32
32400@itemx -m64
d77de738
ML
32401Generate code for a 32-bit or 64-bit environment.
32402The 32-bit environment sets int, long and pointer to 32 bits.
32403The 64-bit environment sets int to 32 bits and long and pointer
32404to 64 bits.
32405
d77de738 32406@opindex mcmodel
ddf6fe37 32407@item -mcmodel=@var{which}
d77de738
ML
32408Set the code model to one of
32409
32410@table @samp
32411@item medlow
32412The Medium/Low code model: 64-bit addresses, programs
32413must be linked in the low 32 bits of memory. Programs can be statically
32414or dynamically linked.
32415
32416@item medmid
32417The Medium/Middle code model: 64-bit addresses, programs
32418must be linked in the low 44 bits of memory, the text and data segments must
32419be less than 2GB in size and the data segment must be located within 2GB of
32420the text segment.
32421
32422@item medany
32423The Medium/Anywhere code model: 64-bit addresses, programs
32424may be linked anywhere in memory, the text and data segments must be less
32425than 2GB in size and the data segment must be located within 2GB of the
32426text segment.
32427
32428@item embmedany
32429The Medium/Anywhere code model for embedded systems:
3243064-bit addresses, the text and data segments must be less than 2GB in
32431size, both starting anywhere in memory (determined at link time). The
32432global register %g4 points to the base of the data segment. Programs
32433are statically linked and PIC is not supported.
32434@end table
32435
d77de738 32436@opindex mmemory-model
ddf6fe37 32437@item -mmemory-model=@var{mem-model}
d77de738
ML
32438Set the memory model in force on the processor to one of
32439
32440@table @samp
32441@item default
32442The default memory model for the processor and operating system.
32443
32444@item rmo
32445Relaxed Memory Order
32446
32447@item pso
32448Partial Store Order
32449
32450@item tso
32451Total Store Order
32452
32453@item sc
32454Sequential Consistency
32455@end table
32456
32457These memory models are formally defined in Appendix D of the SPARC-V9
32458architecture manual, as set in the processor's @code{PSTATE.MM} field.
32459
d77de738
ML
32460@opindex mstack-bias
32461@opindex mno-stack-bias
ddf6fe37
AA
32462@item -mstack-bias
32463@itemx -mno-stack-bias
d77de738
ML
32464With @option{-mstack-bias}, GCC assumes that the stack pointer, and
32465frame pointer if present, are offset by @minus{}2047 which must be added back
32466when making stack frame references. This is the default in 64-bit mode.
32467Otherwise, assume no such offset is present.
32468@end table
32469
32470@node System V Options
32471@subsection Options for System V
32472
32473These additional options are available on System V Release 4 for
32474compatibility with other compilers on those systems:
32475
32476@table @gcctabopt
d77de738 32477@opindex G
ddf6fe37 32478@item -G
d77de738
ML
32479Create a shared object.
32480It is recommended that @option{-symbolic} or @option{-shared} be used instead.
32481
d77de738 32482@opindex Qy
ddf6fe37 32483@item -Qy
d77de738
ML
32484Identify the versions of each tool used by the compiler, in a
32485@code{.ident} assembler directive in the output.
32486
d77de738 32487@opindex Qn
ddf6fe37 32488@item -Qn
d77de738
ML
32489Refrain from adding @code{.ident} directives to the output file (this is
32490the default).
32491
d77de738 32492@opindex YP
ddf6fe37 32493@item -YP,@var{dirs}
d77de738
ML
32494Search the directories @var{dirs}, and no others, for libraries
32495specified with @option{-l}.
32496
d77de738 32497@opindex Ym
ddf6fe37 32498@item -Ym,@var{dir}
d77de738
ML
32499Look in the directory @var{dir} to find the M4 preprocessor.
32500The assembler uses this option.
32501@c This is supposed to go with a -Yd for predefined M4 macro files, but
32502@c the generic assembler that comes with Solaris takes just -Ym.
32503@end table
32504
32505@node V850 Options
32506@subsection V850 Options
32507@cindex V850 Options
32508
32509These @samp{-m} options are defined for V850 implementations:
32510
32511@table @gcctabopt
d77de738
ML
32512@opindex mlong-calls
32513@opindex mno-long-calls
ddf6fe37
AA
32514@item -mlong-calls
32515@itemx -mno-long-calls
d77de738
ML
32516Treat all calls as being far away (near). If calls are assumed to be
32517far away, the compiler always loads the function's address into a
32518register, and calls indirect through the pointer.
32519
d77de738
ML
32520@opindex mno-ep
32521@opindex mep
ddf6fe37
AA
32522@item -mno-ep
32523@itemx -mep
d77de738
ML
32524Do not optimize (do optimize) basic blocks that use the same index
32525pointer 4 or more times to copy pointer into the @code{ep} register, and
32526use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
32527option is on by default if you optimize.
32528
d77de738
ML
32529@opindex mno-prolog-function
32530@opindex mprolog-function
ddf6fe37
AA
32531@item -mno-prolog-function
32532@itemx -mprolog-function
d77de738
ML
32533Do not use (do use) external functions to save and restore registers
32534at the prologue and epilogue of a function. The external functions
32535are slower, but use less code space if more than one function saves
32536the same number of registers. The @option{-mprolog-function} option
32537is on by default if you optimize.
32538
d77de738 32539@opindex mspace
ddf6fe37 32540@item -mspace
d77de738
ML
32541Try to make the code as small as possible. At present, this just turns
32542on the @option{-mep} and @option{-mprolog-function} options.
32543
d77de738 32544@opindex mtda
ddf6fe37 32545@item -mtda=@var{n}
d77de738
ML
32546Put static or global variables whose size is @var{n} bytes or less into
32547the tiny data area that register @code{ep} points to. The tiny data
32548area can hold up to 256 bytes in total (128 bytes for byte references).
32549
d77de738 32550@opindex msda
ddf6fe37 32551@item -msda=@var{n}
d77de738
ML
32552Put static or global variables whose size is @var{n} bytes or less into
32553the small data area that register @code{gp} points to. The small data
32554area can hold up to 64 kilobytes.
32555
d77de738 32556@opindex mzda
ddf6fe37 32557@item -mzda=@var{n}
d77de738
ML
32558Put static or global variables whose size is @var{n} bytes or less into
32559the first 32 kilobytes of memory.
32560
d77de738 32561@opindex mv850
ddf6fe37 32562@item -mv850
d77de738
ML
32563Specify that the target processor is the V850.
32564
d77de738 32565@opindex mv850e3v5
ddf6fe37 32566@item -mv850e3v5
d77de738
ML
32567Specify that the target processor is the V850E3V5. The preprocessor
32568constant @code{__v850e3v5__} is defined if this option is used.
32569
d77de738 32570@opindex mv850e2v4
ddf6fe37 32571@item -mv850e2v4
d77de738
ML
32572Specify that the target processor is the V850E3V5. This is an alias for
32573the @option{-mv850e3v5} option.
32574
d77de738 32575@opindex mv850e2v3
ddf6fe37 32576@item -mv850e2v3
d77de738
ML
32577Specify that the target processor is the V850E2V3. The preprocessor
32578constant @code{__v850e2v3__} is defined if this option is used.
32579
d77de738 32580@opindex mv850e2
ddf6fe37 32581@item -mv850e2
d77de738
ML
32582Specify that the target processor is the V850E2. The preprocessor
32583constant @code{__v850e2__} is defined if this option is used.
32584
d77de738 32585@opindex mv850e1
ddf6fe37 32586@item -mv850e1
d77de738
ML
32587Specify that the target processor is the V850E1. The preprocessor
32588constants @code{__v850e1__} and @code{__v850e__} are defined if
32589this option is used.
32590
d77de738 32591@opindex mv850es
ddf6fe37 32592@item -mv850es
d77de738
ML
32593Specify that the target processor is the V850ES. This is an alias for
32594the @option{-mv850e1} option.
32595
d77de738 32596@opindex mv850e
ddf6fe37 32597@item -mv850e
d77de738
ML
32598Specify that the target processor is the V850E@. The preprocessor
32599constant @code{__v850e__} is defined if this option is used.
32600
32601If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
32602nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
32603are defined then a default target processor is chosen and the
32604relevant @samp{__v850*__} preprocessor constant is defined.
32605
32606The preprocessor constants @code{__v850} and @code{__v851__} are always
32607defined, regardless of which processor variant is the target.
32608
d77de738
ML
32609@opindex mdisable-callt
32610@opindex mno-disable-callt
ddf6fe37
AA
32611@item -mdisable-callt
32612@itemx -mno-disable-callt
d77de738
ML
32613This option suppresses generation of the @code{CALLT} instruction for the
32614v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
32615architecture.
32616
32617This option is enabled by default when the RH850 ABI is
32618in use (see @option{-mrh850-abi}), and disabled by default when the
32619GCC ABI is in use. If @code{CALLT} instructions are being generated
32620then the C preprocessor symbol @code{__V850_CALLT__} is defined.
32621
d77de738
ML
32622@opindex mrelax
32623@opindex mno-relax
ddf6fe37
AA
32624@item -mrelax
32625@itemx -mno-relax
d77de738
ML
32626Pass on (or do not pass on) the @option{-mrelax} command-line option
32627to the assembler.
32628
d77de738
ML
32629@opindex mlong-jumps
32630@opindex mno-long-jumps
ddf6fe37
AA
32631@item -mlong-jumps
32632@itemx -mno-long-jumps
d77de738
ML
32633Disable (or re-enable) the generation of PC-relative jump instructions.
32634
d77de738
ML
32635@opindex msoft-float
32636@opindex mhard-float
ddf6fe37
AA
32637@item -msoft-float
32638@itemx -mhard-float
d77de738
ML
32639Disable (or re-enable) the generation of hardware floating point
32640instructions. This option is only significant when the target
32641architecture is @samp{V850E2V3} or higher. If hardware floating point
32642instructions are being generated then the C preprocessor symbol
32643@code{__FPU_OK__} is defined, otherwise the symbol
32644@code{__NO_FPU__} is defined.
32645
d77de738 32646@opindex mloop
ddf6fe37 32647@item -mloop
d77de738
ML
32648Enables the use of the e3v5 LOOP instruction. The use of this
32649instruction is not enabled by default when the e3v5 architecture is
32650selected because its use is still experimental.
32651
d77de738
ML
32652@opindex mrh850-abi
32653@opindex mghs
ddf6fe37
AA
32654@item -mrh850-abi
32655@itemx -mghs
d77de738
ML
32656Enables support for the RH850 version of the V850 ABI. This is the
32657default. With this version of the ABI the following rules apply:
32658
32659@itemize
32660@item
32661Integer sized structures and unions are returned via a memory pointer
32662rather than a register.
32663
32664@item
32665Large structures and unions (more than 8 bytes in size) are passed by
32666value.
32667
32668@item
32669Functions are aligned to 16-bit boundaries.
32670
32671@item
32672The @option{-m8byte-align} command-line option is supported.
32673
32674@item
32675The @option{-mdisable-callt} command-line option is enabled by
32676default. The @option{-mno-disable-callt} command-line option is not
32677supported.
32678@end itemize
32679
32680When this version of the ABI is enabled the C preprocessor symbol
32681@code{__V850_RH850_ABI__} is defined.
32682
d77de738 32683@opindex mgcc-abi
ddf6fe37 32684@item -mgcc-abi
d77de738
ML
32685Enables support for the old GCC version of the V850 ABI. With this
32686version of the ABI the following rules apply:
32687
32688@itemize
32689@item
32690Integer sized structures and unions are returned in register @code{r10}.
32691
32692@item
32693Large structures and unions (more than 8 bytes in size) are passed by
32694reference.
32695
32696@item
32697Functions are aligned to 32-bit boundaries, unless optimizing for
32698size.
32699
32700@item
32701The @option{-m8byte-align} command-line option is not supported.
32702
32703@item
32704The @option{-mdisable-callt} command-line option is supported but not
32705enabled by default.
32706@end itemize
32707
32708When this version of the ABI is enabled the C preprocessor symbol
32709@code{__V850_GCC_ABI__} is defined.
32710
d77de738
ML
32711@opindex m8byte-align
32712@opindex mno-8byte-align
ddf6fe37
AA
32713@item -m8byte-align
32714@itemx -mno-8byte-align
d77de738
ML
32715Enables support for @code{double} and @code{long long} types to be
32716aligned on 8-byte boundaries. The default is to restrict the
32717alignment of all objects to at most 4-bytes. When
32718@option{-m8byte-align} is in effect the C preprocessor symbol
32719@code{__V850_8BYTE_ALIGN__} is defined.
32720
d77de738 32721@opindex mbig-switch
ddf6fe37 32722@item -mbig-switch
d77de738
ML
32723Generate code suitable for big switch tables. Use this option only if
32724the assembler/linker complain about out of range branches within a switch
32725table.
32726
d77de738 32727@opindex mapp-regs
ddf6fe37 32728@item -mapp-regs
d77de738
ML
32729This option causes r2 and r5 to be used in the code generated by
32730the compiler. This setting is the default.
32731
d77de738 32732@opindex mno-app-regs
ddf6fe37 32733@item -mno-app-regs
d77de738
ML
32734This option causes r2 and r5 to be treated as fixed registers.
32735
32736@end table
32737
32738@node VAX Options
32739@subsection VAX Options
32740@cindex VAX options
32741
32742These @samp{-m} options are defined for the VAX:
32743
32744@table @gcctabopt
d77de738 32745@opindex munix
ddf6fe37 32746@item -munix
d77de738
ML
32747Do not output certain jump instructions (@code{aobleq} and so on)
32748that the Unix assembler for the VAX cannot handle across long
32749ranges.
32750
d77de738 32751@opindex mgnu
ddf6fe37 32752@item -mgnu
d77de738
ML
32753Do output those jump instructions, on the assumption that the
32754GNU assembler is being used.
32755
d77de738 32756@opindex mg
ddf6fe37 32757@item -mg
d77de738
ML
32758Output code for G-format floating-point numbers instead of D-format.
32759
d77de738
ML
32760@opindex mlra
32761@opindex mno-lra
ddf6fe37
AA
32762@item -mlra
32763@itemx -mno-lra
d77de738
ML
32764Enable Local Register Allocation. This is still experimental for the VAX,
32765so by default the compiler uses standard reload.
32766@end table
32767
32768@node Visium Options
32769@subsection Visium Options
32770@cindex Visium options
32771
32772@table @gcctabopt
32773
d77de738 32774@opindex mdebug
ddf6fe37 32775@item -mdebug
d77de738
ML
32776A program which performs file I/O and is destined to run on an MCM target
32777should be linked with this option. It causes the libraries libc.a and
32778libdebug.a to be linked. The program should be run on the target under
32779the control of the GDB remote debugging stub.
32780
d77de738 32781@opindex msim
ddf6fe37 32782@item -msim
d77de738
ML
32783A program which performs file I/O and is destined to run on the simulator
32784should be linked with option. This causes libraries libc.a and libsim.a to
32785be linked.
32786
d77de738
ML
32787@opindex mfpu
32788@opindex mhard-float
ddf6fe37
AA
32789@item -mfpu
32790@itemx -mhard-float
d77de738
ML
32791Generate code containing floating-point instructions. This is the
32792default.
32793
d77de738
ML
32794@opindex mno-fpu
32795@opindex msoft-float
ddf6fe37
AA
32796@item -mno-fpu
32797@itemx -msoft-float
d77de738
ML
32798Generate code containing library calls for floating-point.
32799
32800@option{-msoft-float} changes the calling convention in the output file;
32801therefore, it is only useful if you compile @emph{all} of a program with
32802this option. In particular, you need to compile @file{libgcc.a}, the
32803library that comes with GCC, with @option{-msoft-float} in order for
32804this to work.
32805
d77de738 32806@opindex mcpu
ddf6fe37 32807@item -mcpu=@var{cpu_type}
d77de738
ML
32808Set the instruction set, register set, and instruction scheduling parameters
32809for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32810@samp{mcm}, @samp{gr5} and @samp{gr6}.
32811
32812@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32813
32814By default (unless configured otherwise), GCC generates code for the GR5
32815variant of the Visium architecture.
32816
32817With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32818architecture. The only difference from GR5 code is that the compiler will
32819generate block move instructions.
32820
d77de738 32821@opindex mtune
ddf6fe37 32822@item -mtune=@var{cpu_type}
d77de738
ML
32823Set the instruction scheduling parameters for machine type @var{cpu_type},
32824but do not set the instruction set or register set that the option
32825@option{-mcpu=@var{cpu_type}} would.
32826
d77de738 32827@opindex msv-mode
ddf6fe37 32828@item -msv-mode
d77de738
ML
32829Generate code for the supervisor mode, where there are no restrictions on
32830the access to general registers. This is the default.
32831
d77de738 32832@opindex muser-mode
ddf6fe37 32833@item -muser-mode
d77de738
ML
32834Generate code for the user mode, where the access to some general registers
32835is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32836mode; on the GR6, only registers r29 to r31 are affected.
32837@end table
32838
32839@node VMS Options
32840@subsection VMS Options
32841
32842These @samp{-m} options are defined for the VMS implementations:
32843
32844@table @gcctabopt
d77de738 32845@opindex mvms-return-codes
ddf6fe37 32846@item -mvms-return-codes
d77de738
ML
32847Return VMS condition codes from @code{main}. The default is to return POSIX-style
32848condition (e.g.@: error) codes.
32849
d77de738 32850@opindex mdebug-main=@var{prefix}
ddf6fe37 32851@item -mdebug-main=@var{prefix}
d77de738
ML
32852Flag the first routine whose name starts with @var{prefix} as the main
32853routine for the debugger.
32854
d77de738 32855@opindex mmalloc64
ddf6fe37 32856@item -mmalloc64
d77de738
ML
32857Default to 64-bit memory allocation routines.
32858
d77de738 32859@opindex mpointer-size=@var{size}
ddf6fe37 32860@item -mpointer-size=@var{size}
d77de738
ML
32861Set the default size of pointers. Possible options for @var{size} are
32862@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32863for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32864The later option disables @code{pragma pointer_size}.
32865@end table
32866
32867@node VxWorks Options
32868@subsection VxWorks Options
32869@cindex VxWorks Options
32870
32871The options in this section are defined for all VxWorks targets.
32872Options specific to the target hardware are listed with the other
32873options for that target.
32874
32875@table @gcctabopt
d77de738 32876@opindex mrtp
ddf6fe37 32877@item -mrtp
d77de738
ML
32878GCC can generate code for both VxWorks kernels and real time processes
32879(RTPs). This option switches from the former to the latter. It also
32880defines the preprocessor macro @code{__RTP__}.
32881
b6f4b000
AO
32882@opindex msmp
32883@item -msmp
32884Select SMP runtimes for linking. Not available on architectures other
32885than PowerPC, nor on VxWorks version 7 or later, in which the selection
32886is part of the VxWorks build configuration and the library paths are the
32887same for either choice.
32888
d77de738 32889@opindex non-static
ddf6fe37 32890@item -non-static
d77de738
ML
32891Link an RTP executable against shared libraries rather than static
32892libraries. The options @option{-static} and @option{-shared} can
32893also be used for RTPs (@pxref{Link Options}); @option{-static}
32894is the default.
32895
d77de738
ML
32896@opindex Bstatic
32897@opindex Bdynamic
ddf6fe37
AA
32898@item -Bstatic
32899@itemx -Bdynamic
d77de738
ML
32900These options are passed down to the linker. They are defined for
32901compatibility with Diab.
32902
d77de738 32903@opindex Xbind-lazy
ddf6fe37 32904@item -Xbind-lazy
d77de738
ML
32905Enable lazy binding of function calls. This option is equivalent to
32906@option{-Wl,-z,now} and is defined for compatibility with Diab.
32907
d77de738 32908@opindex Xbind-now
ddf6fe37 32909@item -Xbind-now
d77de738
ML
32910Disable lazy binding of function calls. This option is the default and
32911is defined for compatibility with Diab.
32912@end table
32913
32914@node x86 Options
32915@subsection x86 Options
32916@cindex x86 Options
32917
32918These @samp{-m} options are defined for the x86 family of computers.
32919
32920@table @gcctabopt
32921
d77de738 32922@opindex march
ddf6fe37 32923@item -march=@var{cpu-type}
d77de738
ML
32924Generate instructions for the machine type @var{cpu-type}. In contrast to
32925@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32926for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32927to generate code that may not run at all on processors other than the one
32928indicated. Specifying @option{-march=@var{cpu-type}} implies
32929@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32930
32931The choices for @var{cpu-type} are:
32932
32933@table @samp
32934@item native
32935This selects the CPU to generate code for at compilation time by determining
32936the processor type of the compiling machine. Using @option{-march=native}
32937enables all instruction subsets supported by the local machine (hence
32938the result might not run on different machines). Using @option{-mtune=native}
32939produces code optimized for the local machine under the constraints
32940of the selected instruction set.
32941
32942@item x86-64
32943A generic CPU with 64-bit extensions.
32944
32945@item x86-64-v2
32946@itemx x86-64-v3
32947@itemx x86-64-v4
32948These choices for @var{cpu-type} select the corresponding
32949micro-architecture level from the x86-64 psABI. On ABIs other than
32950the x86-64 psABI they select the same CPU features as the x86-64 psABI
32951documents for the particular micro-architecture level.
32952
32953Since these @var{cpu-type} values do not have a corresponding
32954@option{-mtune} setting, using @option{-march} with these values enables
32955generic tuning. Specific tuning can be enabled using the
32956@option{-mtune=@var{other-cpu-type}} option with an appropriate
32957@var{other-cpu-type} value.
32958
32959@item i386
32960Original Intel i386 CPU@.
32961
32962@item i486
32963Intel i486 CPU@. (No scheduling is implemented for this chip.)
32964
32965@item i586
32966@itemx pentium
32967Intel Pentium CPU with no MMX support.
32968
32969@item lakemont
32970Intel Lakemont MCU, based on Intel Pentium CPU.
32971
32972@item pentium-mmx
32973Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32974
32975@item pentiumpro
32976Intel Pentium Pro CPU@.
32977
32978@item i686
32979When used with @option{-march}, the Pentium Pro
32980instruction set is used, so the code runs on all i686 family chips.
32981When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32982
32983@item pentium2
32984Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32985set support.
32986
32987@item pentium3
32988@itemx pentium3m
32989Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32990instruction set support.
32991
32992@item pentium-m
32993Intel Pentium M; low-power version of Intel Pentium III CPU
32994with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32995notebooks.
32996
32997@item pentium4
32998@itemx pentium4m
32999Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
33000
33001@item prescott
33002Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
33003instruction set support.
33004
33005@item nocona
33006Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
33007SSE2, SSE3 and FXSR instruction set support.
33008
33009@item core2
33010Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
33011SAHF and FXSR instruction set support.
33012
33013@item nehalem
33014Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
33015SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
33016
33017@item westmere
33018Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
33019SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
33020
33021@item sandybridge
33022Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
33023SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
33024support.
33025
33026@item ivybridge
33027Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
33028SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
33029and F16C instruction set support.
33030
33031@item haswell
33032Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33033SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33034F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
33035
33036@item broadwell
33037Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33038SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33039F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
33040instruction set support.
33041
33042@item skylake
33043Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33044SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33045F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33046CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
33047
33048@item bonnell
33049Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
33050instruction set support.
33051
33052@item silvermont
33053Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33054SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
33055instruction set support.
33056
33057@item goldmont
33058Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33059SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
33060RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
33061set support.
33062
33063@item goldmont-plus
33064Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33065SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
33066SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
33067RDPID and SGX instruction set support.
33068
33069@item tremont
33070Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33071SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
33072RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
33073SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
33074support.
33075
33076@item sierraforest
33077Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33078SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33079XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33080MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33081PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
33082AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
33083support.
d77de738
ML
33084
33085@item grandridge
33086Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33087SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33088XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33089MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33090PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
33091AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT
33092instruction set support.
d77de738 33093
7370c479
HJ
33094@item clearwaterforest
33095Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
33096SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
33097XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
33098MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
33099LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
faa0e82b
HJ
33100ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
33101SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
f019251a 33102
d77de738
ML
33103@item knl
33104Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33105SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33106RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33107AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
33108
33109@item knm
33110Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33111SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33112RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33113AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
33114AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
33115
33116@item skylake-avx512
33117Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33118SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33119RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33120AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
33121AVX512DQ and AVX512CD instruction set support.
33122
33123@item cannonlake
33124Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
33125SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
33126FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
33127PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
33128AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
33129support.
33130
33131@item icelake-client
33132Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33133SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33134RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33135AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33136AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
33137, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
33138
33139@item icelake-server
33140Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33141SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33142RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33143AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33144AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
33145, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
33146instruction set support.
33147
33148@item cascadelake
33149Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33150SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33151F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33152CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
33153AVX512CD and AVX512VNNI instruction set support.
33154
33155@item cooperlake
33156Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33157SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33158F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33159CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
33160AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
33161
33162@item tigerlake
33163Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33164SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33165F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33166CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
33167PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33168VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
33169AVX512VP2INTERSECT and KEYLOCKER instruction set support.
33170
33171@item sapphirerapids
33172Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33173SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33174RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33175AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33176AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33177VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
33178MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 33179UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
33180instruction set support.
33181
33182@item alderlake
33183Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33184SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
33185XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
33186CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
33187VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
33188support.
33189
33190@item rocketlake
33191Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
33192, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33193F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33194CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
33195PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33196VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
33197
33198@item graniterapids
33199Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33200SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33201RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33202AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33203AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33204VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
33205MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
33206UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
33207and PREFETCHI instruction set support.
d77de738 33208
a0cb65d3
MZ
33209@item graniterapids-d
33210Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33211SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33212RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33213AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33214AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33215VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
33216MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
33217UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
33218PREFETCHI and AMX-COMPLEX instruction set support.
a0cb65d3 33219
faa0e82b
HJ
33220@item arrowlake
33221Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33222SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33223XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33224MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33225PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33226UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set
33227support.
33228
33229@item arrowlake-s
33230Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33231SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33232XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33233MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33234PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33235UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
33236SM3 and SM4 instruction set support.
33237
33238@item pantherlake
33239Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33240SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33241XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33242MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33243PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33244UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
33245SM3, SM4 and PREFETCHI instruction set support.
33246
d77de738
ML
33247@item k6
33248AMD K6 CPU with MMX instruction set support.
33249
33250@item k6-2
33251@itemx k6-3
33252Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
33253
33254@item athlon
33255@itemx athlon-tbird
33256AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
33257support.
33258
33259@item athlon-4
33260@itemx athlon-xp
33261@itemx athlon-mp
33262Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
33263instruction set support.
33264
33265@item k8
33266@itemx opteron
33267@itemx athlon64
33268@itemx athlon-fx
33269Processors based on the AMD K8 core with x86-64 instruction set support,
33270including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
33271(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
33272instruction set extensions.)
33273
33274@item k8-sse3
33275@itemx opteron-sse3
33276@itemx athlon64-sse3
33277Improved versions of AMD K8 cores with SSE3 instruction set support.
33278
33279@item amdfam10
33280@itemx barcelona
33281CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
33282supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
33283instruction set extensions.)
33284
33285@item bdver1
33286CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
33287supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
33288SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
33289
33290@item bdver2
33291AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33292supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
33293SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
33294extensions.)
33295
33296@item bdver3
33297AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33298supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
33299PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3330064-bit instruction set extensions.)
33301
33302@item bdver4
33303AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33304supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
33305AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
33306SSE4.2, ABM and 64-bit instruction set extensions.)
33307
33308@item znver1
33309AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33310supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
33311SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
33312SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
33313instruction set extensions.)
33314
33315@item znver2
33316AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33317supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33318MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33319SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33320WBNOINVD, and 64-bit instruction set extensions.)
33321
33322@item znver3
33323AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33324supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33325MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33326SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33327WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
33328
33329@item znver4
33330AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33331supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33332MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33333SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33334WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
33335AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
33336AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
33337
33338@item btver1
33339CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
33340supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
33341instruction set extensions.)
33342
33343@item btver2
33344CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
33345includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
33346SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
33347
33348@item winchip-c6
33349IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
33350set support.
33351
33352@item winchip2
33353IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
33354instruction set support.
33355
33356@item c3
33357VIA C3 CPU with MMX and 3DNow!@: instruction set support.
33358(No scheduling is implemented for this chip.)
33359
33360@item c3-2
33361VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
33362(No scheduling is implemented for this chip.)
33363
33364@item c7
33365VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33366(No scheduling is implemented for this chip.)
33367
33368@item samuel-2
33369VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
33370(No scheduling is implemented for this chip.)
33371
33372@item nehemiah
33373VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
33374(No scheduling is implemented for this chip.)
33375
33376@item esther
33377VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33378(No scheduling is implemented for this chip.)
33379
33380@item eden-x2
33381VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
33382(No scheduling is implemented for this chip.)
33383
33384@item eden-x4
33385VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
33386AVX and AVX2 instruction set support.
33387(No scheduling is implemented for this chip.)
33388
33389@item nano
33390Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33391instruction set support.
33392(No scheduling is implemented for this chip.)
33393
33394@item nano-1000
33395VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33396instruction set support.
33397(No scheduling is implemented for this chip.)
33398
33399@item nano-2000
33400VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33401instruction set support.
33402(No scheduling is implemented for this chip.)
33403
33404@item nano-3000
33405VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33406instruction set support.
33407(No scheduling is implemented for this chip.)
33408
33409@item nano-x2
33410VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33411instruction set support.
33412(No scheduling is implemented for this chip.)
33413
33414@item nano-x4
33415VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33416instruction set support.
33417(No scheduling is implemented for this chip.)
33418
33419@item lujiazui
33420ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
33421SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
33422ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
33423
94c0b26f
M
33424@item yongfeng
33425ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
33426SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
33427ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
33428instruction set support.
33429
d77de738
ML
33430@item geode
33431AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
33432@end table
33433
d77de738 33434@opindex mtune
ddf6fe37 33435@item -mtune=@var{cpu-type}
d77de738
ML
33436Tune to @var{cpu-type} everything applicable about the generated code, except
33437for the ABI and the set of available instructions.
33438While picking a specific @var{cpu-type} schedules things appropriately
33439for that particular chip, the compiler does not generate any code that
33440cannot run on the default machine type unless you use a
33441@option{-march=@var{cpu-type}} option.
33442For example, if GCC is configured for i686-pc-linux-gnu
33443then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
33444but still runs on i686 machines.
33445
33446The choices for @var{cpu-type} are the same as for @option{-march}.
33447In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
33448
33449@table @samp
33450@item generic
33451Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
33452If you know the CPU on which your code will run, then you should use
33453the corresponding @option{-mtune} or @option{-march} option instead of
33454@option{-mtune=generic}. But, if you do not know exactly what CPU users
33455of your application will have, then you should use this option.
33456
33457As new processors are deployed in the marketplace, the behavior of this
33458option will change. Therefore, if you upgrade to a newer version of
33459GCC, code generation controlled by this option will change to reflect
33460the processors
33461that are most common at the time that version of GCC is released.
33462
33463There is no @option{-march=generic} option because @option{-march}
33464indicates the instruction set the compiler can use, and there is no
33465generic instruction set applicable to all processors. In contrast,
33466@option{-mtune} indicates the processor (or, in this case, collection of
33467processors) for which the code is optimized.
33468
33469@item intel
33470Produce code optimized for the most current Intel processors, which are
33471Haswell and Silvermont for this version of GCC. If you know the CPU
33472on which your code will run, then you should use the corresponding
33473@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
33474But, if you want your application performs better on both Haswell and
33475Silvermont, then you should use this option.
33476
33477As new Intel processors are deployed in the marketplace, the behavior of
33478this option will change. Therefore, if you upgrade to a newer version of
33479GCC, code generation controlled by this option will change to reflect
33480the most current Intel processors at the time that version of GCC is
33481released.
33482
33483There is no @option{-march=intel} option because @option{-march} indicates
33484the instruction set the compiler can use, and there is no common
33485instruction set applicable to all processors. In contrast,
33486@option{-mtune} indicates the processor (or, in this case, collection of
33487processors) for which the code is optimized.
33488@end table
33489
d77de738 33490@opindex mcpu
ddf6fe37 33491@item -mcpu=@var{cpu-type}
d77de738
ML
33492A deprecated synonym for @option{-mtune}.
33493
d77de738 33494@opindex mfpmath
ddf6fe37 33495@item -mfpmath=@var{unit}
d77de738
ML
33496Generate floating-point arithmetic for selected unit @var{unit}. The choices
33497for @var{unit} are:
33498
33499@table @samp
33500@item 387
33501Use the standard 387 floating-point coprocessor present on the majority of chips and
33502emulated otherwise. Code compiled with this option runs almost everywhere.
33503The temporary results are computed in 80-bit precision instead of the precision
33504specified by the type, resulting in slightly different results compared to most
33505of other chips. See @option{-ffloat-store} for more detailed description.
33506
33507This is the default choice for non-Darwin x86-32 targets.
33508
33509@item sse
33510Use scalar floating-point instructions present in the SSE instruction set.
33511This instruction set is supported by Pentium III and newer chips,
33512and in the AMD line
33513by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
33514instruction set supports only single-precision arithmetic, thus the double and
33515extended-precision arithmetic are still done using 387. A later version, present
33516only in Pentium 4 and AMD x86-64 chips, supports double-precision
33517arithmetic too.
33518
33519For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
33520or @option{-msse2} switches to enable SSE extensions and make this option
33521effective. For the x86-64 compiler, these extensions are enabled by default.
33522
33523The resulting code should be considerably faster in the majority of cases and avoid
33524the numerical instability problems of 387 code, but may break some existing
33525code that expects temporaries to be 80 bits.
33526
33527This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
33528and the default choice for x86-32 targets with the SSE2 instruction set
33529when @option{-ffast-math} is enabled.
33530
33531@item sse,387
33532@itemx sse+387
33533@itemx both
33534Attempt to utilize both instruction sets at once. This effectively doubles the
33535amount of available registers, and on chips with separate execution units for
33536387 and SSE the execution resources too. Use this option with care, as it is
33537still experimental, because the GCC register allocator does not model separate
33538functional units well, resulting in unstable performance.
33539@end table
33540
d77de738 33541@opindex masm=@var{dialect}
ddf6fe37 33542@item -masm=@var{dialect}
d77de738
ML
33543Output assembly instructions using selected @var{dialect}. Also affects
33544which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
33545extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
33546order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
33547not support @samp{intel}.
33548
d77de738
ML
33549@opindex mieee-fp
33550@opindex mno-ieee-fp
ddf6fe37
AA
33551@item -mieee-fp
33552@itemx -mno-ieee-fp
d77de738
ML
33553Control whether or not the compiler uses IEEE floating-point
33554comparisons. These correctly handle the case where the result of a
33555comparison is unordered.
33556
30348d30 33557@opindex m80387
d77de738 33558@opindex mhard-float
ddf6fe37
AA
33559@item -m80387
33560@itemx -mhard-float
d77de738
ML
33561Generate output containing 80387 instructions for floating point.
33562
d77de738
ML
33563@opindex no-80387
33564@opindex msoft-float
ddf6fe37
AA
33565@item -mno-80387
33566@itemx -msoft-float
d77de738
ML
33567Generate output containing library calls for floating point.
33568
33569@strong{Warning:} the requisite libraries are not part of GCC@.
33570Normally the facilities of the machine's usual C compiler are used, but
33571this cannot be done directly in cross-compilation. You must make your
33572own arrangements to provide suitable library functions for
33573cross-compilation.
33574
33575On machines where a function returns floating-point results in the 80387
33576register stack, some floating-point opcodes may be emitted even if
33577@option{-msoft-float} is used.
33578
d77de738
ML
33579@opindex mno-fp-ret-in-387
33580@opindex mfp-ret-in-387
ddf6fe37 33581@item -mno-fp-ret-in-387
d77de738
ML
33582Do not use the FPU registers for return values of functions.
33583
33584The usual calling convention has functions return values of types
33585@code{float} and @code{double} in an FPU register, even if there
33586is no FPU@. The idea is that the operating system should emulate
33587an FPU@.
33588
33589The option @option{-mno-fp-ret-in-387} causes such values to be returned
33590in ordinary CPU registers instead.
33591
d77de738
ML
33592@opindex mno-fancy-math-387
33593@opindex mfancy-math-387
ddf6fe37 33594@item -mno-fancy-math-387
d77de738
ML
33595Some 387 emulators do not support the @code{sin}, @code{cos} and
33596@code{sqrt} instructions for the 387. Specify this option to avoid
33597generating those instructions.
33598This option is overridden when @option{-march}
33599indicates that the target CPU always has an FPU and so the
33600instruction does not need emulation. These
33601instructions are not generated unless you also use the
33602@option{-funsafe-math-optimizations} switch.
33603
d77de738
ML
33604@opindex malign-double
33605@opindex mno-align-double
ddf6fe37
AA
33606@item -malign-double
33607@itemx -mno-align-double
d77de738
ML
33608Control whether GCC aligns @code{double}, @code{long double}, and
33609@code{long long} variables on a two-word boundary or a one-word
33610boundary. Aligning @code{double} variables on a two-word boundary
33611produces code that runs somewhat faster on a Pentium at the
33612expense of more memory.
33613
33614On x86-64, @option{-malign-double} is enabled by default.
33615
33616@strong{Warning:} if you use the @option{-malign-double} switch,
33617structures containing the above types are aligned differently than
33618the published application binary interface specifications for the x86-32
33619and are not binary compatible with structures in code compiled
33620without that switch.
33621
d77de738
ML
33622@opindex m96bit-long-double
33623@opindex m128bit-long-double
ddf6fe37
AA
33624@item -m96bit-long-double
33625@itemx -m128bit-long-double
d77de738
ML
33626These switches control the size of @code{long double} type. The x86-32
33627application binary interface specifies the size to be 96 bits,
33628so @option{-m96bit-long-double} is the default in 32-bit mode.
33629
33630Modern architectures (Pentium and newer) prefer @code{long double}
33631to be aligned to an 8- or 16-byte boundary. In arrays or structures
33632conforming to the ABI, this is not possible. So specifying
33633@option{-m128bit-long-double} aligns @code{long double}
33634to a 16-byte boundary by padding the @code{long double} with an additional
3363532-bit zero.
33636
33637In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
33638its ABI specifies that @code{long double} is aligned on 16-byte boundary.
33639
33640Notice that neither of these options enable any extra precision over the x87
33641standard of 80 bits for a @code{long double}.
33642
33643@strong{Warning:} if you override the default value for your target ABI, this
33644changes the size of
33645structures and arrays containing @code{long double} variables,
33646as well as modifying the function calling convention for functions taking
33647@code{long double}. Hence they are not binary-compatible
33648with code compiled without that switch.
33649
d77de738
ML
33650@opindex mlong-double-64
33651@opindex mlong-double-80
33652@opindex mlong-double-128
ddf6fe37
AA
33653@item -mlong-double-64
33654@itemx -mlong-double-80
33655@itemx -mlong-double-128
d77de738
ML
33656These switches control the size of @code{long double} type. A size
33657of 64 bits makes the @code{long double} type equivalent to the @code{double}
33658type. This is the default for 32-bit Bionic C library. A size
33659of 128 bits makes the @code{long double} type equivalent to the
33660@code{__float128} type. This is the default for 64-bit Bionic C library.
33661
33662@strong{Warning:} if you override the default value for your target ABI, this
33663changes the size of
33664structures and arrays containing @code{long double} variables,
33665as well as modifying the function calling convention for functions taking
33666@code{long double}. Hence they are not binary-compatible
33667with code compiled without that switch.
33668
d77de738 33669@opindex malign-data
ddf6fe37 33670@item -malign-data=@var{type}
d77de738
ML
33671Control how GCC aligns variables. Supported values for @var{type} are
33672@samp{compat} uses increased alignment value compatible uses GCC 4.8
33673and earlier, @samp{abi} uses alignment value as specified by the
33674psABI, and @samp{cacheline} uses increased alignment value to match
33675the cache line size. @samp{compat} is the default.
33676
d77de738 33677@opindex mlarge-data-threshold
ddf6fe37 33678@item -mlarge-data-threshold=@var{threshold}
1a64156c
UB
33679When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
33680objects larger than @var{threshold} are placed in large data sections. The
33681default is 65535.
d77de738 33682
d77de738 33683@opindex mrtd
ddf6fe37 33684@item -mrtd
d77de738
ML
33685Use a different function-calling convention, in which functions that
33686take a fixed number of arguments return with the @code{ret @var{num}}
33687instruction, which pops their arguments while returning. This saves one
33688instruction in the caller since there is no need to pop the arguments
33689there.
33690
33691You can specify that an individual function is called with this calling
33692sequence with the function attribute @code{stdcall}. You can also
33693override the @option{-mrtd} option by using the function attribute
33694@code{cdecl}. @xref{Function Attributes}.
33695
33696@strong{Warning:} this calling convention is incompatible with the one
33697normally used on Unix, so you cannot use it if you need to call
33698libraries compiled with the Unix compiler.
33699
33700Also, you must provide function prototypes for all functions that
33701take variable numbers of arguments (including @code{printf});
33702otherwise incorrect code is generated for calls to those
33703functions.
33704
33705In addition, seriously incorrect code results if you call a
33706function with too many arguments. (Normally, extra arguments are
33707harmlessly ignored.)
33708
d77de738 33709@opindex mregparm
ddf6fe37 33710@item -mregparm=@var{num}
d77de738
ML
33711Control how many registers are used to pass integer arguments. By
33712default, no registers are used to pass arguments, and at most 3
33713registers can be used. You can control this behavior for a specific
33714function by using the function attribute @code{regparm}.
33715@xref{Function Attributes}.
33716
33717@strong{Warning:} if you use this switch, and
33718@var{num} is nonzero, then you must build all modules with the same
33719value, including any libraries. This includes the system libraries and
33720startup modules.
33721
d77de738 33722@opindex msseregparm
ddf6fe37 33723@item -msseregparm
d77de738
ML
33724Use SSE register passing conventions for float and double arguments
33725and return values. You can control this behavior for a specific
33726function by using the function attribute @code{sseregparm}.
33727@xref{Function Attributes}.
33728
33729@strong{Warning:} if you use this switch then you must build all
33730modules with the same value, including any libraries. This includes
33731the system libraries and startup modules.
33732
d77de738 33733@opindex mvect8-ret-in-mem
ddf6fe37 33734@item -mvect8-ret-in-mem
d77de738
ML
33735Return 8-byte vectors in memory instead of MMX registers. This is the
33736default on VxWorks to match the ABI of the Sun Studio compilers until
33737version 12. @emph{Only} use this option if you need to remain
33738compatible with existing code produced by those previous compiler
33739versions or older versions of GCC@.
33740
d77de738
ML
33741@opindex mpc32
33742@opindex mpc64
33743@opindex mpc80
ddf6fe37
AA
33744@item -mpc32
33745@itemx -mpc64
33746@itemx -mpc80
d77de738
ML
33747
33748Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
33749is specified, the significands of results of floating-point operations are
33750rounded to 24 bits (single precision); @option{-mpc64} rounds the
33751significands of results of floating-point operations to 53 bits (double
33752precision) and @option{-mpc80} rounds the significands of results of
33753floating-point operations to 64 bits (extended double precision), which is
33754the default. When this option is used, floating-point operations in higher
33755precisions are not available to the programmer without setting the FPU
33756control word explicitly.
33757
33758Setting the rounding of floating-point operations to less than the default
3375980 bits can speed some programs by 2% or more. Note that some mathematical
33760libraries assume that extended-precision (80-bit) floating-point operations
33761are enabled by default; routines in such libraries could suffer significant
33762loss of accuracy, typically through so-called ``catastrophic cancellation'',
33763when this option is used to set the precision to less than extended precision.
33764
e54375d8 33765@opindex mdaz-ftz
ddf6fe37 33766@item -mdaz-ftz
e54375d8 33767
33768The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
33769are used to control floating-point calculations.SSE and AVX instructions
33770including scalar and vector instructions could benefit from enabling the FTZ
33771and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33772when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33773will set FTZ/DAZ flags even with @option{-shared}.
33774
d77de738 33775@opindex mstackrealign
ddf6fe37 33776@item -mstackrealign
d77de738
ML
33777Realign the stack at entry. On the x86, the @option{-mstackrealign}
33778option generates an alternate prologue and epilogue that realigns the
33779run-time stack if necessary. This supports mixing legacy codes that keep
337804-byte stack alignment with modern codes that keep 16-byte stack alignment for
33781SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33782applicable to individual functions.
33783
d77de738 33784@opindex mpreferred-stack-boundary
ddf6fe37 33785@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33786Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33787byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33788the default is 4 (16 bytes or 128 bits).
33789
33790@strong{Warning:} When generating code for the x86-64 architecture with
33791SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33792used to keep the stack boundary aligned to 8 byte boundary. Since
33793x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33794intended to be used in controlled environment where stack space is
33795important limitation. This option leads to wrong code when functions
33796compiled with 16 byte stack alignment (such as functions from a standard
33797library) are called with misaligned stack. In this case, SSE
33798instructions may lead to misaligned memory access traps. In addition,
33799variable arguments are handled incorrectly for 16 byte aligned
33800objects (including x87 long double and __int128), leading to wrong
33801results. You must build all modules with
33802@option{-mpreferred-stack-boundary=3}, including any libraries. This
33803includes the system libraries and startup modules.
33804
d77de738 33805@opindex mincoming-stack-boundary
ddf6fe37 33806@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33807Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33808boundary. If @option{-mincoming-stack-boundary} is not specified,
33809the one specified by @option{-mpreferred-stack-boundary} is used.
33810
33811On Pentium and Pentium Pro, @code{double} and @code{long double} values
33812should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33813suffer significant run time performance penalties. On Pentium III, the
33814Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33815properly if it is not 16-byte aligned.
33816
33817To ensure proper alignment of this values on the stack, the stack boundary
33818must be as aligned as that required by any value stored on the stack.
33819Further, every function must be generated such that it keeps the stack
33820aligned. Thus calling a function compiled with a higher preferred
33821stack boundary from a function compiled with a lower preferred stack
33822boundary most likely misaligns the stack. It is recommended that
33823libraries that use callbacks always use the default setting.
33824
33825This extra alignment does consume extra stack space, and generally
33826increases code size. Code that is sensitive to stack space usage, such
33827as embedded systems and operating system kernels, may want to reduce the
33828preferred alignment to @option{-mpreferred-stack-boundary=2}.
33829
33830@need 200
d77de738 33831@opindex mmmx
ddf6fe37 33832@item -mmmx
d77de738 33833@need 200
d77de738 33834@opindex msse
ddf6fe37 33835@itemx -msse
d77de738 33836@need 200
d77de738 33837@opindex msse2
ddf6fe37 33838@itemx -msse2
d77de738 33839@need 200
d77de738 33840@opindex msse3
ddf6fe37 33841@itemx -msse3
d77de738 33842@need 200
d77de738 33843@opindex mssse3
ddf6fe37 33844@itemx -mssse3
d77de738 33845@need 200
d77de738 33846@opindex msse4
ddf6fe37 33847@itemx -msse4
d77de738 33848@need 200
d77de738 33849@opindex msse4a
ddf6fe37 33850@itemx -msse4a
d77de738 33851@need 200
d77de738 33852@opindex msse4.1
ddf6fe37 33853@itemx -msse4.1
d77de738 33854@need 200
d77de738 33855@opindex msse4.2
ddf6fe37 33856@itemx -msse4.2
d77de738 33857@need 200
d77de738 33858@opindex mavx
ddf6fe37 33859@itemx -mavx
d77de738 33860@need 200
d77de738 33861@opindex mavx2
ddf6fe37 33862@itemx -mavx2
d77de738 33863@need 200
d77de738 33864@opindex mavx512f
ddf6fe37 33865@itemx -mavx512f
d77de738 33866@need 200
d77de738 33867@opindex mavx512pf
ddf6fe37 33868@itemx -mavx512pf
d77de738 33869@need 200
d77de738 33870@opindex mavx512er
ddf6fe37 33871@itemx -mavx512er
d77de738 33872@need 200
d77de738 33873@opindex mavx512cd
ddf6fe37 33874@itemx -mavx512cd
d77de738 33875@need 200
d77de738 33876@opindex mavx512vl
ddf6fe37 33877@itemx -mavx512vl
d77de738 33878@need 200
d77de738 33879@opindex mavx512bw
ddf6fe37 33880@itemx -mavx512bw
d77de738 33881@need 200
d77de738 33882@opindex mavx512dq
ddf6fe37 33883@itemx -mavx512dq
d77de738 33884@need 200
d77de738 33885@opindex mavx512ifma
ddf6fe37 33886@itemx -mavx512ifma
d77de738 33887@need 200
d77de738 33888@opindex mavx512vbmi
ddf6fe37 33889@itemx -mavx512vbmi
d77de738 33890@need 200
d77de738 33891@opindex msha
ddf6fe37 33892@itemx -msha
d77de738 33893@need 200
d77de738 33894@opindex maes
ddf6fe37 33895@itemx -maes
d77de738 33896@need 200
d77de738 33897@opindex mpclmul
ddf6fe37 33898@itemx -mpclmul
d77de738 33899@need 200
d77de738 33900@opindex mclflushopt
ddf6fe37 33901@itemx -mclflushopt
d77de738 33902@need 200
d77de738 33903@opindex mclwb
ddf6fe37 33904@itemx -mclwb
d77de738 33905@need 200
d77de738 33906@opindex mfsgsbase
ddf6fe37 33907@itemx -mfsgsbase
d77de738 33908@need 200
d77de738 33909@opindex mptwrite
ddf6fe37 33910@itemx -mptwrite
d77de738 33911@need 200
d77de738 33912@opindex mrdrnd
ddf6fe37 33913@itemx -mrdrnd
d77de738 33914@need 200
d77de738 33915@opindex mf16c
ddf6fe37 33916@itemx -mf16c
d77de738 33917@need 200
d77de738 33918@opindex mfma
ddf6fe37 33919@itemx -mfma
d77de738 33920@need 200
d77de738 33921@opindex mpconfig
ddf6fe37 33922@itemx -mpconfig
d77de738 33923@need 200
d77de738 33924@opindex mwbnoinvd
ddf6fe37 33925@itemx -mwbnoinvd
d77de738 33926@need 200
d77de738 33927@opindex mfma4
ddf6fe37 33928@itemx -mfma4
d77de738 33929@need 200
d77de738 33930@opindex mprfchw
ddf6fe37 33931@itemx -mprfchw
d77de738 33932@need 200
d77de738 33933@opindex mrdpid
ddf6fe37 33934@itemx -mrdpid
d77de738 33935@need 200
d77de738 33936@opindex mprefetchwt1
ddf6fe37 33937@itemx -mprefetchwt1
d77de738 33938@need 200
d77de738 33939@opindex mrdseed
ddf6fe37 33940@itemx -mrdseed
d77de738 33941@need 200
d77de738 33942@opindex msgx
ddf6fe37 33943@itemx -msgx
d77de738 33944@need 200
d77de738 33945@opindex mxop
ddf6fe37 33946@itemx -mxop
d77de738 33947@need 200
d77de738 33948@opindex mlwp
ddf6fe37 33949@itemx -mlwp
d77de738 33950@need 200
d77de738 33951@opindex m3dnow
ddf6fe37 33952@itemx -m3dnow
d77de738 33953@need 200
d77de738 33954@opindex m3dnowa
ddf6fe37 33955@itemx -m3dnowa
d77de738 33956@need 200
d77de738 33957@opindex mpopcnt
ddf6fe37 33958@itemx -mpopcnt
d77de738 33959@need 200
d77de738 33960@opindex mabm
ddf6fe37 33961@itemx -mabm
d77de738 33962@need 200
d77de738 33963@opindex madx
ddf6fe37 33964@itemx -madx
d77de738 33965@need 200
d77de738 33966@opindex mbmi
ddf6fe37 33967@itemx -mbmi
d77de738 33968@need 200
d77de738 33969@opindex mbmi2
ddf6fe37 33970@itemx -mbmi2
d77de738 33971@need 200
d77de738 33972@opindex mlzcnt
ddf6fe37 33973@itemx -mlzcnt
d77de738 33974@need 200
d77de738 33975@opindex mfxsr
ddf6fe37 33976@itemx -mfxsr
d77de738 33977@need 200
d77de738 33978@opindex mxsave
ddf6fe37 33979@itemx -mxsave
d77de738 33980@need 200
d77de738 33981@opindex mxsaveopt
ddf6fe37 33982@itemx -mxsaveopt
d77de738 33983@need 200
d77de738 33984@opindex mxsavec
ddf6fe37 33985@itemx -mxsavec
d77de738 33986@need 200
d77de738 33987@opindex mxsaves
ddf6fe37 33988@itemx -mxsaves
d77de738 33989@need 200
d77de738 33990@opindex mrtm
ddf6fe37 33991@itemx -mrtm
d77de738 33992@need 200
d77de738 33993@opindex mhle
ddf6fe37 33994@itemx -mhle
d77de738 33995@need 200
d77de738 33996@opindex mtbm
ddf6fe37 33997@itemx -mtbm
d77de738 33998@need 200
d77de738 33999@opindex mmwaitx
ddf6fe37 34000@itemx -mmwaitx
d77de738 34001@need 200
d77de738 34002@opindex mclzero
ddf6fe37 34003@itemx -mclzero
d77de738 34004@need 200
d77de738 34005@opindex mpku
ddf6fe37 34006@itemx -mpku
d77de738 34007@need 200
d77de738 34008@opindex mavx512vbmi2
ddf6fe37 34009@itemx -mavx512vbmi2
d77de738 34010@need 200
d77de738 34011@opindex mavx512bf16
ddf6fe37 34012@itemx -mavx512bf16
d77de738 34013@need 200
d77de738 34014@opindex mavx512fp16
ddf6fe37 34015@itemx -mavx512fp16
d77de738 34016@need 200
d77de738 34017@opindex mgfni
ddf6fe37 34018@itemx -mgfni
d77de738 34019@need 200
d77de738 34020@opindex mvaes
ddf6fe37 34021@itemx -mvaes
d77de738 34022@need 200
d77de738 34023@opindex mwaitpkg
ddf6fe37 34024@itemx -mwaitpkg
d77de738 34025@need 200
d77de738 34026@opindex mvpclmulqdq
ddf6fe37 34027@itemx -mvpclmulqdq
d77de738 34028@need 200
d77de738 34029@opindex mavx512bitalg
ddf6fe37 34030@itemx -mavx512bitalg
d77de738 34031@need 200
d77de738 34032@opindex mmovdiri
ddf6fe37 34033@itemx -mmovdiri
d77de738 34034@need 200
d77de738 34035@opindex mmovdir64b
ddf6fe37 34036@itemx -mmovdir64b
d77de738 34037@need 200
d77de738 34038@opindex menqcmd
d77de738 34039@opindex muintr
ddf6fe37
AA
34040@itemx -menqcmd
34041@itemx -muintr
d77de738 34042@need 200
d77de738 34043@opindex mtsxldtrk
ddf6fe37 34044@itemx -mtsxldtrk
d77de738 34045@need 200
d77de738 34046@opindex mavx512vpopcntdq
ddf6fe37 34047@itemx -mavx512vpopcntdq
d77de738 34048@need 200
d77de738 34049@opindex mavx512vp2intersect
ddf6fe37 34050@itemx -mavx512vp2intersect
d77de738 34051@need 200
d77de738 34052@opindex mavx5124fmaps
ddf6fe37 34053@itemx -mavx5124fmaps
d77de738 34054@need 200
d77de738 34055@opindex mavx512vnni
ddf6fe37 34056@itemx -mavx512vnni
d77de738 34057@need 200
d77de738 34058@opindex mavxvnni
ddf6fe37 34059@itemx -mavxvnni
d77de738 34060@need 200
d77de738 34061@opindex mavx5124vnniw
ddf6fe37 34062@itemx -mavx5124vnniw
d77de738 34063@need 200
d77de738 34064@opindex mcldemote
ddf6fe37 34065@itemx -mcldemote
d77de738 34066@need 200
d77de738 34067@opindex mserialize
ddf6fe37 34068@itemx -mserialize
d77de738 34069@need 200
d77de738 34070@opindex mamx-tile
ddf6fe37 34071@itemx -mamx-tile
d77de738 34072@need 200
d77de738 34073@opindex mamx-int8
ddf6fe37 34074@itemx -mamx-int8
d77de738 34075@need 200
d77de738 34076@opindex mamx-bf16
ddf6fe37 34077@itemx -mamx-bf16
d77de738 34078@need 200
d77de738 34079@opindex mhreset
d77de738 34080@opindex mkl
ddf6fe37
AA
34081@itemx -mhreset
34082@itemx -mkl
d77de738 34083@need 200
d77de738 34084@opindex mwidekl
ddf6fe37 34085@itemx -mwidekl
d77de738 34086@need 200
d77de738 34087@opindex mavxifma
ddf6fe37 34088@itemx -mavxifma
d77de738 34089@need 200
d77de738 34090@opindex mavxvnniint8
ddf6fe37 34091@itemx -mavxvnniint8
d77de738 34092@need 200
d77de738 34093@opindex mavxneconvert
ddf6fe37 34094@itemx -mavxneconvert
d77de738 34095@need 200
d77de738 34096@opindex mcmpccxadd
ddf6fe37 34097@itemx -mcmpccxadd
d77de738 34098@need 200
d77de738 34099@opindex mamx-fp16
ddf6fe37 34100@itemx -mamx-fp16
d77de738 34101@need 200
d77de738 34102@opindex mprefetchi
ddf6fe37 34103@itemx -mprefetchi
d77de738 34104@need 200
d77de738 34105@opindex mraoint
ddf6fe37 34106@itemx -mraoint
efa6a82b
HJ
34107@need 200
34108@opindex mamx-complex
34109@itemx -mamx-complex
1dbc1081
KL
34110@need 200
34111@opindex mavxvnniint16
34112@itemx -mavxvnniint16
8643bcba
HJ
34113@need 200
34114@opindex msm3
34115@itemx -msm3
86446132
HJ
34116@need 200
34117@opindex msha512
34118@itemx -msha512
37bdeb8f
HJ
34119@need 200
34120@opindex msm4
34121@itemx -msm4
e686416b
KL
34122@need 200
34123@opindex mapxf
34124@itemx -mapxf
5fbd91b1
HL
34125@need 200
34126@opindex musermsr
34127@itemx -musermsr
2f8f7ee2
HJ
34128@need 200
34129@opindex mavx10.1
34130@itemx -mavx10.1
34131@need 200
34132@opindex mavx10.1-256
34133@itemx -mavx10.1-256
34134@need 200
34135@opindex mavx10.1-512
34136@itemx -mavx10.1-512
d77de738 34137These switches enable the use of instructions in the MMX, SSE,
d77de738
ML
34138AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
34139AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
34140WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
341413DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
34142XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
34143GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
34144ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 34145UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b 34146AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
2f8f7ee2
HJ
34147AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR, AVX10.1 or
34148CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
34149option to disable use of these instructions.
d77de738
ML
34150
34151These extensions are also available as built-in functions: see
34152@ref{x86 Built-in Functions}, for details of the functions enabled and
34153disabled by these switches.
34154
34155To generate SSE/SSE2 instructions automatically from floating-point
34156code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
34157
34158GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
34159generates new AVX instructions or AVX equivalence for all SSEx instructions
34160when needed.
34161
34162These options enable GCC to use these extended instructions in
34163generated code, even without @option{-mfpmath=sse}. Applications that
34164perform run-time CPU detection must compile separate files for each
34165supported architecture, using the appropriate flags. In particular,
34166the file containing the CPU detection code should be compiled without
34167these options.
34168
d77de738 34169@opindex mdump-tune-features
ddf6fe37 34170@item -mdump-tune-features
d77de738
ML
34171This option instructs GCC to dump the names of the x86 performance
34172tuning features and default settings. The names can be used in
34173@option{-mtune-ctrl=@var{feature-list}}.
34174
d77de738 34175@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 34176@item -mtune-ctrl=@var{feature-list}
d77de738
ML
34177This option is used to do fine grain control of x86 code generation features.
34178@var{feature-list} is a comma separated list of @var{feature} names. See also
34179@option{-mdump-tune-features}. When specified, the @var{feature} is turned
34180on if it is not preceded with @samp{^}, otherwise, it is turned off.
34181@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
34182developers. Using it may lead to code paths not covered by testing and can
34183potentially result in compiler ICEs or runtime errors.
34184
d77de738 34185@opindex mno-default
ddf6fe37 34186@item -mno-default
d77de738
ML
34187This option instructs GCC to turn off all tunable features. See also
34188@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
34189
d77de738 34190@opindex mcld
ddf6fe37 34191@item -mcld
d77de738
ML
34192This option instructs GCC to emit a @code{cld} instruction in the prologue
34193of functions that use string instructions. String instructions depend on
34194the DF flag to select between autoincrement or autodecrement mode. While the
34195ABI specifies the DF flag to be cleared on function entry, some operating
34196systems violate this specification by not clearing the DF flag in their
34197exception dispatchers. The exception handler can be invoked with the DF flag
34198set, which leads to wrong direction mode when string instructions are used.
34199This option can be enabled by default on 32-bit x86 targets by configuring
34200GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
34201instructions can be suppressed with the @option{-mno-cld} compiler option
34202in this case.
34203
d77de738 34204@opindex mvzeroupper
ddf6fe37 34205@item -mvzeroupper
d77de738
ML
34206This option instructs GCC to emit a @code{vzeroupper} instruction
34207before a transfer of control flow out of the function to minimize
34208the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
34209intrinsics.
34210
d77de738 34211@opindex mprefer-avx128
ddf6fe37 34212@item -mprefer-avx128
d77de738
ML
34213This option instructs GCC to use 128-bit AVX instructions instead of
34214256-bit AVX instructions in the auto-vectorizer.
34215
d77de738 34216@opindex mprefer-vector-width
ddf6fe37 34217@item -mprefer-vector-width=@var{opt}
d77de738
ML
34218This option instructs GCC to use @var{opt}-bit vector width in instructions
34219instead of default on the selected platform.
34220
ad5b757d
UB
34221@opindex mpartial-vector-fp-math
34222@item -mpartial-vector-fp-math
34223This option enables GCC to generate floating-point operations that might
34224affect the set of floating-point status flags on partial vectors, where
34225vector elements reside in the low part of the 128-bit SSE register. Unless
34226@option{-fno-trapping-math} is specified, the compiler guarantees correct
34227behavior by sanitizing all input operands to have zeroes in the unused
34228upper part of the vector register. Note that by using built-in functions
34229or inline assembly with partial vector arguments, NaNs, denormal or invalid
34230values can leak into the upper part of the vector, causing possible
34231performance issues when @option{-fno-trapping-math} is in effect. These
34232issues can be mitigated by manually sanitizing the upper part of the partial
34233vector argument register or by using @option{-mdaz-ftz} to set
34234denormals-are-zero (DAZ) flag in the MXCSR register.
34235
34236This option is enabled by default.
34237
d77de738 34238@opindex mmove-max
ddf6fe37 34239@item -mmove-max=@var{bits}
d77de738
ML
34240This option instructs GCC to set the maximum number of bits can be
34241moved from memory to memory efficiently to @var{bits}. The valid
34242@var{bits} are 128, 256 and 512.
34243
d77de738 34244@opindex mstore-max
ddf6fe37 34245@item -mstore-max=@var{bits}
d77de738
ML
34246This option instructs GCC to set the maximum number of bits can be
34247stored to memory efficiently to @var{bits}. The valid @var{bits} are
34248128, 256 and 512.
34249
34250@table @samp
34251@item none
34252No extra limitations applied to GCC other than defined by the selected platform.
34253
34254@item 128
34255Prefer 128-bit vector width for instructions.
34256
34257@item 256
34258Prefer 256-bit vector width for instructions.
34259
34260@item 512
34261Prefer 512-bit vector width for instructions.
34262@end table
34263
d77de738 34264@opindex mcx16
ddf6fe37 34265@item -mcx16
d77de738
ML
34266This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
34267code to implement compare-and-exchange operations on 16-byte aligned 128-bit
34268objects. This is useful for atomic updates of data structures exceeding one
34269machine word in size. The compiler uses this instruction to implement
34270@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
34271128-bit integers, a library call is always used.
34272
d77de738 34273@opindex msahf
ddf6fe37 34274@item -msahf
d77de738
ML
34275This option enables generation of @code{SAHF} instructions in 64-bit code.
34276Early Intel Pentium 4 CPUs with Intel 64 support,
34277prior to the introduction of Pentium 4 G1 step in December 2005,
34278lacked the @code{LAHF} and @code{SAHF} instructions
34279which are supported by AMD64.
34280These are load and store instructions, respectively, for certain status flags.
34281In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
34282@code{drem}, and @code{remainder} built-in functions;
34283see @ref{Other Builtins} for details.
34284
d77de738 34285@opindex mmovbe
ddf6fe37 34286@item -mmovbe
d77de738
ML
34287This option enables use of the @code{movbe} instruction to implement
34288@code{__builtin_bswap32} and @code{__builtin_bswap64}.
34289
d77de738 34290@opindex mshstk
ddf6fe37 34291@item -mshstk
d77de738
ML
34292The @option{-mshstk} option enables shadow stack built-in functions
34293from x86 Control-flow Enforcement Technology (CET).
34294
d77de738 34295@opindex mcrc32
ddf6fe37 34296@item -mcrc32
d77de738
ML
34297This option enables built-in functions @code{__builtin_ia32_crc32qi},
34298@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
34299@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
34300
d77de738 34301@opindex mmwait
ddf6fe37 34302@item -mmwait
d77de738
ML
34303This option enables built-in functions @code{__builtin_ia32_monitor},
34304and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
34305@code{mwait} machine instructions.
34306
d77de738 34307@opindex mrecip
ddf6fe37 34308@item -mrecip
d77de738
ML
34309This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
34310(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
34311with an additional Newton-Raphson step
34312to increase precision instead of @code{DIVSS} and @code{SQRTSS}
34313(and their vectorized
34314variants) for single-precision floating-point arguments. These instructions
34315are generated only when @option{-funsafe-math-optimizations} is enabled
34316together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
34317Note that while the throughput of the sequence is higher than the throughput
34318of the non-reciprocal instruction, the precision of the sequence can be
34319decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
34320
34321Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
34322(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
34323combination), and doesn't need @option{-mrecip}.
34324
34325Also note that GCC emits the above sequence with additional Newton-Raphson step
34326for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
34327already with @option{-ffast-math} (or the above option combination), and
34328doesn't need @option{-mrecip}.
34329
d77de738 34330@opindex mrecip=opt
ddf6fe37 34331@item -mrecip=@var{opt}
d77de738
ML
34332This option controls which reciprocal estimate instructions
34333may be used. @var{opt} is a comma-separated list of options, which may
34334be preceded by a @samp{!} to invert the option:
34335
34336@table @samp
34337@item all
34338Enable all estimate instructions.
34339
34340@item default
34341Enable the default instructions, equivalent to @option{-mrecip}.
34342
34343@item none
34344Disable all estimate instructions, equivalent to @option{-mno-recip}.
34345
34346@item div
34347Enable the approximation for scalar division.
34348
34349@item vec-div
34350Enable the approximation for vectorized division.
34351
34352@item sqrt
34353Enable the approximation for scalar square root.
34354
34355@item vec-sqrt
34356Enable the approximation for vectorized square root.
34357@end table
34358
34359So, for example, @option{-mrecip=all,!sqrt} enables
34360all of the reciprocal approximations, except for square root.
34361
d77de738 34362@opindex mveclibabi
ddf6fe37 34363@item -mveclibabi=@var{type}
d77de738
ML
34364Specifies the ABI type to use for vectorizing intrinsics using an
34365external library. Supported values for @var{type} are @samp{svml}
34366for the Intel short
34367vector math library and @samp{acml} for the AMD math core library.
34368To use this option, both @option{-ftree-vectorize} and
34369@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
34370ABI-compatible library must be specified at link time.
34371
34372GCC currently emits calls to @code{vmldExp2},
34373@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
34374@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
34375@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
34376@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
34377@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
34378@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
34379@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
34380@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
34381@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
34382function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
34383@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
34384@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
34385@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
34386@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
34387when @option{-mveclibabi=acml} is used.
34388
d77de738 34389@opindex mabi
ddf6fe37 34390@item -mabi=@var{name}
d77de738
ML
34391Generate code for the specified calling convention. Permissible values
34392are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
34393@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
34394ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
34395You can control this behavior for specific functions by
34396using the function attributes @code{ms_abi} and @code{sysv_abi}.
34397@xref{Function Attributes}.
34398
d77de738 34399@opindex mforce-indirect-call
ddf6fe37 34400@item -mforce-indirect-call
d77de738
ML
34401Force all calls to functions to be indirect. This is useful
34402when using Intel Processor Trace where it generates more precise timing
34403information for function calls.
34404
d77de738 34405@opindex mmanual-endbr
ddf6fe37 34406@item -mmanual-endbr
d77de738
ML
34407Insert ENDBR instruction at function entry only via the @code{cf_check}
34408function attribute. This is useful when used with the option
34409@option{-fcf-protection=branch} to control ENDBR insertion at the
34410function entry.
34411
d77de738 34412@opindex mcet-switch
ddf6fe37 34413@item -mcet-switch
d77de738
ML
34414By default, CET instrumentation is turned off on switch statements that
34415use a jump table and indirect branch track is disabled. Since jump
34416tables are stored in read-only memory, this does not result in a direct
34417loss of hardening. But if the jump table index is attacker-controlled,
34418the indirect jump may not be constrained by CET. This option turns on
34419CET instrumentation to enable indirect branch track for switch statements
34420with jump tables which leads to the jump targets reachable via any indirect
34421jumps.
34422
d77de738
ML
34423@opindex mcall-ms2sysv-xlogues
34424@opindex mno-call-ms2sysv-xlogues
ddf6fe37 34425@item -mcall-ms2sysv-xlogues
d77de738
ML
34426Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
34427System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
34428default, the code for saving and restoring these registers is emitted inline,
34429resulting in fairly lengthy prologues and epilogues. Using
34430@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
34431use stubs in the static portion of libgcc to perform these saves and restores,
34432thus reducing function size at the cost of a few extra instructions.
34433
d77de738 34434@opindex mtls-dialect
ddf6fe37 34435@item -mtls-dialect=@var{type}
d77de738
ML
34436Generate code to access thread-local storage using the @samp{gnu} or
34437@samp{gnu2} conventions. @samp{gnu} is the conservative default;
34438@samp{gnu2} is more efficient, but it may add compile- and run-time
34439requirements that cannot be satisfied on all systems.
34440
d77de738
ML
34441@opindex mpush-args
34442@opindex mno-push-args
ddf6fe37
AA
34443@item -mpush-args
34444@itemx -mno-push-args
d77de738
ML
34445Use PUSH operations to store outgoing parameters. This method is shorter
34446and usually equally fast as method using SUB/MOV operations and is enabled
34447by default. In some cases disabling it may improve performance because of
34448improved scheduling and reduced dependencies.
34449
d77de738 34450@opindex maccumulate-outgoing-args
ddf6fe37 34451@item -maccumulate-outgoing-args
d77de738
ML
34452If enabled, the maximum amount of space required for outgoing arguments is
34453computed in the function prologue. This is faster on most modern CPUs
34454because of reduced dependencies, improved scheduling and reduced stack usage
34455when the preferred stack boundary is not equal to 2. The drawback is a notable
34456increase in code size. This switch implies @option{-mno-push-args}.
34457
d77de738 34458@opindex mthreads
ddf6fe37 34459@item -mthreads
d77de738
ML
34460Support thread-safe exception handling on MinGW. Programs that rely
34461on thread-safe exception handling must compile and link all code with the
34462@option{-mthreads} option. When compiling, @option{-mthreads} defines
34463@option{-D_MT}; when linking, it links in a special thread helper library
34464@option{-lmingwthrd} which cleans up per-thread exception-handling data.
34465
d77de738
ML
34466@opindex mms-bitfields
34467@opindex mno-ms-bitfields
ddf6fe37
AA
34468@item -mms-bitfields
34469@itemx -mno-ms-bitfields
d77de738
ML
34470
34471Enable/disable bit-field layout compatible with the native Microsoft
34472Windows compiler.
34473
34474If @code{packed} is used on a structure, or if bit-fields are used,
34475it may be that the Microsoft ABI lays out the structure differently
34476than the way GCC normally does. Particularly when moving packed
34477data between functions compiled with GCC and the native Microsoft compiler
34478(either via function call or as data in a file), it may be necessary to access
34479either format.
34480
34481This option is enabled by default for Microsoft Windows
34482targets. This behavior can also be controlled locally by use of variable
34483or type attributes. For more information, see @ref{x86 Variable Attributes}
34484and @ref{x86 Type Attributes}.
34485
34486The Microsoft structure layout algorithm is fairly simple with the exception
34487of the bit-field packing.
34488The padding and alignment of members of structures and whether a bit-field
34489can straddle a storage-unit boundary are determine by these rules:
34490
34491@enumerate
34492@item Structure members are stored sequentially in the order in which they are
34493declared: the first member has the lowest memory address and the last member
34494the highest.
34495
34496@item Every data object has an alignment requirement. The alignment requirement
34497for all data except structures, unions, and arrays is either the size of the
34498object or the current packing size (specified with either the
34499@code{aligned} attribute or the @code{pack} pragma),
34500whichever is less. For structures, unions, and arrays,
34501the alignment requirement is the largest alignment requirement of its members.
34502Every object is allocated an offset so that:
34503
34504@smallexample
34505offset % alignment_requirement == 0
34506@end smallexample
34507
34508@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
34509unit if the integral types are the same size and if the next bit-field fits
34510into the current allocation unit without crossing the boundary imposed by the
34511common alignment requirements of the bit-fields.
34512@end enumerate
34513
34514MSVC interprets zero-length bit-fields in the following ways:
34515
34516@enumerate
34517@item If a zero-length bit-field is inserted between two bit-fields that
34518are normally coalesced, the bit-fields are not coalesced.
34519
34520For example:
34521
34522@smallexample
34523struct
34524 @{
34525 unsigned long bf_1 : 12;
34526 unsigned long : 0;
34527 unsigned long bf_2 : 12;
34528 @} t1;
34529@end smallexample
34530
34531@noindent
34532The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
34533zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
34534
34535@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
34536alignment of the zero-length bit-field is greater than the member that follows it,
34537@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
34538
34539For example:
34540
34541@smallexample
34542struct
34543 @{
34544 char foo : 4;
34545 short : 0;
34546 char bar;
34547 @} t2;
34548
34549struct
34550 @{
34551 char foo : 4;
34552 short : 0;
34553 double bar;
34554 @} t3;
34555@end smallexample
34556
34557@noindent
34558For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
34559Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
34560bit-field does not affect the alignment of @code{bar} or, as a result, the size
34561of the structure.
34562
34563Taking this into account, it is important to note the following:
34564
34565@enumerate
34566@item If a zero-length bit-field follows a normal bit-field, the type of the
34567zero-length bit-field may affect the alignment of the structure as whole. For
34568example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
34569normal bit-field, and is of type short.
34570
34571@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
34572still affect the alignment of the structure:
34573
34574@smallexample
34575struct
34576 @{
34577 char foo : 6;
34578 long : 0;
34579 @} t4;
34580@end smallexample
34581
34582@noindent
34583Here, @code{t4} takes up 4 bytes.
34584@end enumerate
34585
34586@item Zero-length bit-fields following non-bit-field members are ignored:
34587
34588@smallexample
34589struct
34590 @{
34591 char foo;
34592 long : 0;
34593 char bar;
34594 @} t5;
34595@end smallexample
34596
34597@noindent
34598Here, @code{t5} takes up 2 bytes.
34599@end enumerate
34600
34601
d77de738
ML
34602@opindex mno-align-stringops
34603@opindex malign-stringops
ddf6fe37 34604@item -mno-align-stringops
d77de738
ML
34605Do not align the destination of inlined string operations. This switch reduces
34606code size and improves performance in case the destination is already aligned,
34607but GCC doesn't know about it.
34608
d77de738 34609@opindex minline-all-stringops
ddf6fe37 34610@item -minline-all-stringops
d77de738
ML
34611By default GCC inlines string operations only when the destination is
34612known to be aligned to least a 4-byte boundary.
34613This enables more inlining and increases code
34614size, but may improve performance of code that depends on fast
34615@code{memcpy} and @code{memset} for short lengths.
34616The option enables inline expansion of @code{strlen} for all
34617pointer alignments.
34618
d77de738 34619@opindex minline-stringops-dynamically
ddf6fe37 34620@item -minline-stringops-dynamically
d77de738
ML
34621For string operations of unknown size, use run-time checks with
34622inline code for small blocks and a library call for large blocks.
34623
d77de738 34624@opindex mstringop-strategy=@var{alg}
ddf6fe37 34625@item -mstringop-strategy=@var{alg}
d77de738
ML
34626Override the internal decision heuristic for the particular algorithm to use
34627for inlining string operations. The allowed values for @var{alg} are:
34628
34629@table @samp
34630@item rep_byte
34631@itemx rep_4byte
34632@itemx rep_8byte
34633Expand using i386 @code{rep} prefix of the specified size.
34634
34635@item byte_loop
34636@itemx loop
34637@itemx unrolled_loop
34638Expand into an inline loop.
34639
34640@item libcall
34641Always use a library call.
34642@end table
34643
d77de738 34644@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 34645@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
34646Override the internal decision heuristic to decide if @code{__builtin_memcpy}
34647should be inlined and what inline algorithm to use when the expected size
34648of the copy operation is known. @var{strategy}
34649is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
34650@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
34651the max byte size with which inline algorithm @var{alg} is allowed. For the last
34652triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
34653in the list must be specified in increasing order. The minimal byte size for
34654@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
34655preceding range.
34656
d77de738 34657@opindex mmemset-strategy=@var{strategy}
ddf6fe37 34658@item -mmemset-strategy=@var{strategy}
d77de738
ML
34659The option is similar to @option{-mmemcpy-strategy=} except that it is to control
34660@code{__builtin_memset} expansion.
34661
d77de738 34662@opindex momit-leaf-frame-pointer
ddf6fe37 34663@item -momit-leaf-frame-pointer
d77de738
ML
34664Don't keep the frame pointer in a register for leaf functions. This
34665avoids the instructions to save, set up, and restore frame pointers and
34666makes an extra register available in leaf functions. The option
34667@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
34668which might make debugging harder.
34669
ddf6fe37 34670@opindex mtls-direct-seg-refs
d77de738
ML
34671@item -mtls-direct-seg-refs
34672@itemx -mno-tls-direct-seg-refs
d77de738
ML
34673Controls whether TLS variables may be accessed with offsets from the
34674TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
34675or whether the thread base pointer must be added. Whether or not this
34676is valid depends on the operating system, and whether it maps the
34677segment to cover the entire TLS area.
34678
34679For systems that use the GNU C Library, the default is on.
34680
ddf6fe37 34681@opindex msse2avx
d77de738
ML
34682@item -msse2avx
34683@itemx -mno-sse2avx
d77de738
ML
34684Specify that the assembler should encode SSE instructions with VEX
34685prefix. The option @option{-mavx} turns this on by default.
34686
ddf6fe37 34687@opindex mfentry
d77de738
ML
34688@item -mfentry
34689@itemx -mno-fentry
d77de738
ML
34690If profiling is active (@option{-pg}), put the profiling
34691counter call before the prologue.
34692Note: On x86 architectures the attribute @code{ms_hook_prologue}
34693isn't possible at the moment for @option{-mfentry} and @option{-pg}.
34694
ddf6fe37 34695@opindex mrecord-mcount
d77de738
ML
34696@item -mrecord-mcount
34697@itemx -mno-record-mcount
d77de738
ML
34698If profiling is active (@option{-pg}), generate a __mcount_loc section
34699that contains pointers to each profiling call. This is useful for
34700automatically patching and out calls.
34701
ddf6fe37 34702@opindex mnop-mcount
d77de738
ML
34703@item -mnop-mcount
34704@itemx -mno-nop-mcount
d77de738
ML
34705If profiling is active (@option{-pg}), generate the calls to
34706the profiling functions as NOPs. This is useful when they
34707should be patched in later dynamically. This is likely only
34708useful together with @option{-mrecord-mcount}.
34709
d77de738 34710@opindex minstrument-return
ddf6fe37 34711@item -minstrument-return=@var{type}
d77de738
ML
34712Instrument function exit in -pg -mfentry instrumented functions with
34713call to specified function. This only instruments true returns ending
34714with ret, but not sibling calls ending with jump. Valid types
34715are @var{none} to not instrument, @var{call} to generate a call to __return__,
34716or @var{nop5} to generate a 5 byte nop.
34717
ddf6fe37 34718@opindex mrecord-return
d77de738
ML
34719@item -mrecord-return
34720@itemx -mno-record-return
d77de738
ML
34721Generate a __return_loc section pointing to all return instrumentation code.
34722
d77de738 34723@opindex mfentry-name
ddf6fe37 34724@item -mfentry-name=@var{name}
d77de738
ML
34725Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
34726
d77de738 34727@opindex mfentry-section
ddf6fe37 34728@item -mfentry-section=@var{name}
d77de738
ML
34729Set name of section to record -mrecord-mcount calls (default __mcount_loc).
34730
ddf6fe37 34731@opindex mskip-rax-setup
d77de738
ML
34732@item -mskip-rax-setup
34733@itemx -mno-skip-rax-setup
d77de738
ML
34734When generating code for the x86-64 architecture with SSE extensions
34735disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
34736register when there are no variable arguments passed in vector registers.
34737
34738@strong{Warning:} Since RAX register is used to avoid unnecessarily
34739saving vector registers on stack when passing variable arguments, the
34740impacts of this option are callees may waste some stack space,
34741misbehave or jump to a random location. GCC 4.4 or newer don't have
34742those issues, regardless the RAX register value.
34743
ddf6fe37 34744@opindex m8bit-idiv
d77de738
ML
34745@item -m8bit-idiv
34746@itemx -mno-8bit-idiv
d77de738
ML
34747On some processors, like Intel Atom, 8-bit unsigned integer divide is
34748much faster than 32-bit/64-bit integer divide. This option generates a
34749run-time check. If both dividend and divisor are within range of 0
34750to 255, 8-bit unsigned integer divide is used instead of
3475132-bit/64-bit integer divide.
34752
d77de738
ML
34753@opindex mavx256-split-unaligned-load
34754@opindex mavx256-split-unaligned-store
ddf6fe37
AA
34755@item -mavx256-split-unaligned-load
34756@itemx -mavx256-split-unaligned-store
d77de738
ML
34757Split 32-byte AVX unaligned load and store.
34758
d77de738
ML
34759@opindex mstack-protector-guard
34760@opindex mstack-protector-guard-reg
34761@opindex mstack-protector-guard-offset
ddf6fe37
AA
34762@item -mstack-protector-guard=@var{guard}
34763@itemx -mstack-protector-guard-reg=@var{reg}
34764@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
34765Generate stack protection code using canary at @var{guard}. Supported
34766locations are @samp{global} for global canary or @samp{tls} for per-thread
34767canary in the TLS block (the default). This option has effect only when
34768@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
34769
34770With the latter choice the options
34771@option{-mstack-protector-guard-reg=@var{reg}} and
34772@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
34773which segment register (@code{%fs} or @code{%gs}) to use as base register
34774for reading the canary, and from what offset from that base register.
34775The default for those is as specified in the relevant ABI.
34776
d77de738 34777@opindex mgeneral-regs-only
ddf6fe37 34778@item -mgeneral-regs-only
d77de738
ML
34779Generate code that uses only the general-purpose registers. This
34780prevents the compiler from using floating-point, vector, mask and bound
34781registers.
34782
d77de738 34783@opindex mrelax-cmpxchg-loop
ddf6fe37 34784@item -mrelax-cmpxchg-loop
85966f0d
AM
34785When emitting a compare-and-swap loop for @ref{__sync Builtins}
34786and @ref{__atomic Builtins} lacking a native instruction, optimize
34787for the highly contended case by issuing an atomic load before the
34788@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
34789to save CPU power when restarting the loop.
d77de738 34790
d77de738 34791@opindex mindirect-branch
ddf6fe37 34792@item -mindirect-branch=@var{choice}
d77de738
ML
34793Convert indirect call and jump with @var{choice}. The default is
34794@samp{keep}, which keeps indirect call and jump unmodified.
34795@samp{thunk} converts indirect call and jump to call and return thunk.
34796@samp{thunk-inline} converts indirect call and jump to inlined call
34797and return thunk. @samp{thunk-extern} converts indirect call and jump
34798to external call and return thunk provided in a separate object file.
34799You can control this behavior for a specific function by using the
34800function attribute @code{indirect_branch}. @xref{Function Attributes}.
34801
34802Note that @option{-mcmodel=large} is incompatible with
34803@option{-mindirect-branch=thunk} and
34804@option{-mindirect-branch=thunk-extern} since the thunk function may
34805not be reachable in the large code model.
34806
34807Note that @option{-mindirect-branch=thunk-extern} is compatible with
34808@option{-fcf-protection=branch} since the external thunk can be made
34809to enable control-flow check.
34810
d77de738 34811@opindex mfunction-return
ddf6fe37 34812@item -mfunction-return=@var{choice}
d77de738
ML
34813Convert function return with @var{choice}. The default is @samp{keep},
34814which keeps function return unmodified. @samp{thunk} converts function
34815return to call and return thunk. @samp{thunk-inline} converts function
34816return to inlined call and return thunk. @samp{thunk-extern} converts
34817function return to external call and return thunk provided in a separate
34818object file. You can control this behavior for a specific function by
34819using the function attribute @code{function_return}.
34820@xref{Function Attributes}.
34821
34822Note that @option{-mindirect-return=thunk-extern} is compatible with
34823@option{-fcf-protection=branch} since the external thunk can be made
34824to enable control-flow check.
34825
34826Note that @option{-mcmodel=large} is incompatible with
34827@option{-mfunction-return=thunk} and
34828@option{-mfunction-return=thunk-extern} since the thunk function may
34829not be reachable in the large code model.
34830
34831
d77de738 34832@opindex mindirect-branch-register
ddf6fe37 34833@item -mindirect-branch-register
d77de738
ML
34834Force indirect call and jump via register.
34835
d77de738 34836@opindex mharden-sls
ddf6fe37 34837@item -mharden-sls=@var{choice}
d77de738
ML
34838Generate code to mitigate against straight line speculation (SLS) with
34839@var{choice}. The default is @samp{none} which disables all SLS
34840hardening. @samp{return} enables SLS hardening for function returns.
34841@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34842@samp{all} enables all SLS hardening.
34843
d77de738 34844@opindex mindirect-branch-cs-prefix
ddf6fe37 34845@item -mindirect-branch-cs-prefix
d77de738
ML
34846Add CS prefix to call and jmp to indirect thunk with branch target in
34847r8-r15 registers so that the call and jmp instruction length is 6 bytes
34848to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34849@samp{lfence; jmp *%r8-r15} at run-time.
34850
34851@end table
34852
34853These @samp{-m} switches are supported in addition to the above
34854on x86-64 processors in 64-bit environments.
34855
34856@table @gcctabopt
d77de738
ML
34857@opindex m32
34858@opindex m64
34859@opindex mx32
34860@opindex m16
34861@opindex miamcu
ddf6fe37
AA
34862@item -m32
34863@itemx -m64
34864@itemx -mx32
34865@itemx -m16
34866@itemx -miamcu
d77de738
ML
34867Generate code for a 16-bit, 32-bit or 64-bit environment.
34868The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34869to 32 bits, and
eeb92704 34870generates code that runs in 32-bit mode.
d77de738
ML
34871
34872The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34873types to 64 bits, and generates code for the x86-64 architecture.
34874For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34875and @option{-mdynamic-no-pic} options.
34876
34877The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34878to 32 bits, and
34879generates code for the x86-64 architecture.
34880
34881The @option{-m16} option is the same as @option{-m32}, except for that
34882it outputs the @code{.code16gcc} assembly directive at the beginning of
34883the assembly output so that the binary can run in 16-bit mode.
34884
34885The @option{-miamcu} option generates code which conforms to Intel MCU
34886psABI. It requires the @option{-m32} option to be turned on.
34887
d77de738
ML
34888@opindex mno-red-zone
34889@opindex mred-zone
ddf6fe37 34890@item -mno-red-zone
d77de738
ML
34891Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34892by the x86-64 ABI; it is a 128-byte area beyond the location of the
34893stack pointer that is not modified by signal or interrupt handlers
34894and therefore can be used for temporary data without adjusting the stack
34895pointer. The flag @option{-mno-red-zone} disables this red zone.
34896
d77de738 34897@opindex mcmodel=small
ddf6fe37 34898@item -mcmodel=small
d77de738
ML
34899Generate code for the small code model: the program and its symbols must
34900be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34901Programs can be statically or dynamically linked. This is the default
34902code model.
34903
d77de738 34904@opindex mcmodel=kernel
ddf6fe37 34905@item -mcmodel=kernel
d77de738
ML
34906Generate code for the kernel code model. The kernel runs in the
34907negative 2 GB of the address space.
34908This model has to be used for Linux kernel code.
34909
d77de738 34910@opindex mcmodel=medium
ddf6fe37 34911@item -mcmodel=medium
d77de738
ML
34912Generate code for the medium model: the program is linked in the lower 2
34913GB of the address space. Small symbols are also placed there. Symbols
34914with sizes larger than @option{-mlarge-data-threshold} are put into
34915large data or BSS sections and can be located above 2GB. Programs can
34916be statically or dynamically linked.
34917
d77de738 34918@opindex mcmodel=large
ddf6fe37 34919@item -mcmodel=large
d77de738
ML
34920Generate code for the large model. This model makes no assumptions
34921about addresses and sizes of sections.
34922
d77de738 34923@opindex maddress-mode=long
ddf6fe37 34924@item -maddress-mode=long
d77de738
ML
34925Generate code for long address mode. This is only supported for 64-bit
34926and x32 environments. It is the default address mode for 64-bit
34927environments.
34928
d77de738 34929@opindex maddress-mode=short
ddf6fe37 34930@item -maddress-mode=short
d77de738
ML
34931Generate code for short address mode. This is only supported for 32-bit
34932and x32 environments. It is the default address mode for 32-bit and
34933x32 environments.
34934
ddf6fe37 34935@opindex mneeded
d77de738
ML
34936@item -mneeded
34937@itemx -mno-needed
d77de738
ML
34938Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34939indicate the micro-architecture ISA level required to execute the binary.
34940
d77de738
ML
34941@opindex mno-direct-extern-access
34942@opindex mdirect-extern-access
ddf6fe37 34943@item -mno-direct-extern-access
d77de738
ML
34944Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34945to access external symbols. With @option{-fpic} or @option{-fPIC},
34946treat access to protected symbols as local symbols. The default is
34947@option{-mdirect-extern-access}.
34948
34949@strong{Warning:} shared libraries compiled with
34950@option{-mno-direct-extern-access} and executable compiled with
34951@option{-mdirect-extern-access} may not be binary compatible if
34952protected symbols are used in shared libraries and executable.
ce51e843 34953
ce51e843
ML
34954@opindex munroll-only-small-loops
34955@opindex mno-unroll-only-small-loops
ddf6fe37 34956@item -munroll-only-small-loops
ce51e843
ML
34957Controls conservative small loop unrolling. It is default enabled by
34958O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34959-f[no-]unroll-[all-]loops would disable this flag to avoid any
34960unintended unrolling behavior that user does not want.
bb576017 34961
bb576017 34962@opindex mlam
ddf6fe37 34963@item -mlam=@var{choice}
bb576017 34964LAM(linear-address masking) allows special bits in the pointer to be used
34965for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34966positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34967positions 62:57 can be used for metadata.
d77de738
ML
34968@end table
34969
34970@node x86 Windows Options
34971@subsection x86 Windows Options
34972@cindex x86 Windows Options
34973@cindex Windows Options for x86
34974
34975These additional options are available for Microsoft Windows targets:
34976
34977@table @gcctabopt
d77de738 34978@opindex mconsole
ddf6fe37 34979@item -mconsole
d77de738
ML
34980This option
34981specifies that a console application is to be generated, by
34982instructing the linker to set the PE header subsystem type
34983required for console applications.
34984This option is available for Cygwin and MinGW targets and is
34985enabled by default on those targets.
34986
453cb585
PR
34987@opindex mcrtdll
34988@item -mcrtdll=@var{library}
34989Preprocess, compile or link with specified C RunTime DLL @var{library}.
34990This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}
34991and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose
34992start file for CRT @var{library} and link with CRT @var{library}.
34993Recognized CRT library names for proprocessor are:
34994@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40},
34995@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90},
34996@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}.
34997If this options is not specified then the default MinGW import library
34998@code{msvcrt} is used for linking and no other adjustment for
34999preprocessor is done. MinGW import library @code{msvcrt} is just a
35000symlink to (or a copy of) another MinGW CRT import library
35001chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
35002is for Windows system CRT DLL library @code{msvcrt.dll} and
35003in most cases is the default MinGW import library.
35004Generally speaking, changing the CRT DLL requires recompiling
35005the entire MinGW CRT. This option is for experimental and testing
35006purposes only.
35007This option is available for MinGW targets.
35008
d77de738 35009@opindex mdll
ddf6fe37 35010@item -mdll
d77de738
ML
35011This option is available for Cygwin and MinGW targets. It
35012specifies that a DLL---a dynamic link library---is to be
35013generated, enabling the selection of the required runtime
35014startup object and entry point.
35015
d77de738 35016@opindex mnop-fun-dllimport
ddf6fe37 35017@item -mnop-fun-dllimport
d77de738
ML
35018This option is available for Cygwin and MinGW targets. It
35019specifies that the @code{dllimport} attribute should be ignored.
35020
d77de738 35021@opindex mthreads
ddf6fe37 35022@item -mthreads
d77de738
ML
35023This option is available for MinGW targets. It specifies
35024that MinGW-specific thread support is to be used.
35025
d77de738 35026@opindex municode
ddf6fe37 35027@item -municode
d77de738
ML
35028This option is available for MinGW-w64 targets. It causes
35029the @code{UNICODE} preprocessor macro to be predefined, and
35030chooses Unicode-capable runtime startup code.
35031
d77de738 35032@opindex mwin32
ddf6fe37 35033@item -mwin32
d77de738
ML
35034This option is available for Cygwin and MinGW targets. It
35035specifies that the typical Microsoft Windows predefined macros are to
35036be set in the pre-processor, but does not influence the choice
35037of runtime library/startup code.
35038
d77de738 35039@opindex mwindows
ddf6fe37 35040@item -mwindows
d77de738
ML
35041This option is available for Cygwin and MinGW targets. It
35042specifies that a GUI application is to be generated by
35043instructing the linker to set the PE header subsystem type
35044appropriately.
35045
d77de738
ML
35046@opindex fno-set-stack-executable
35047@opindex fset-stack-executable
ddf6fe37 35048@item -fno-set-stack-executable
d77de738
ML
35049This option is available for MinGW targets. It specifies that
35050the executable flag for the stack used by nested functions isn't
35051set. This is necessary for binaries running in kernel mode of
35052Microsoft Windows, as there the User32 API, which is used to set executable
35053privileges, isn't available.
35054
d77de738
ML
35055@opindex fno-writable-relocated-rdata
35056@opindex fwritable-relocated-rdata
ddf6fe37 35057@item -fwritable-relocated-rdata
d77de738
ML
35058This option is available for MinGW and Cygwin targets. It specifies
35059that relocated-data in read-only section is put into the @code{.data}
35060section. This is a necessary for older runtimes not supporting
35061modification of @code{.rdata} sections for pseudo-relocation.
35062
d77de738 35063@opindex mpe-aligned-commons
ddf6fe37 35064@item -mpe-aligned-commons
d77de738
ML
35065This option is available for Cygwin and MinGW targets. It
35066specifies that the GNU extension to the PE file format that
35067permits the correct alignment of COMMON variables should be
35068used when generating code. It is enabled by default if
35069GCC detects that the target assembler found during configuration
35070supports the feature.
35071@end table
35072
35073See also under @ref{x86 Options} for standard options.
35074
35075@node Xstormy16 Options
35076@subsection Xstormy16 Options
35077@cindex Xstormy16 Options
35078
35079These options are defined for Xstormy16:
35080
35081@table @gcctabopt
d77de738 35082@opindex msim
ddf6fe37 35083@item -msim
d77de738
ML
35084Choose startup files and linker script suitable for the simulator.
35085@end table
35086
35087@node Xtensa Options
35088@subsection Xtensa Options
35089@cindex Xtensa Options
35090
35091These options are supported for Xtensa targets:
35092
35093@table @gcctabopt
d77de738
ML
35094@opindex mconst16
35095@opindex mno-const16
ddf6fe37
AA
35096@item -mconst16
35097@itemx -mno-const16
d77de738
ML
35098Enable or disable use of @code{CONST16} instructions for loading
35099constant values. The @code{CONST16} instruction is currently not a
35100standard option from Tensilica. When enabled, @code{CONST16}
35101instructions are always used in place of the standard @code{L32R}
35102instructions. The use of @code{CONST16} is enabled by default only if
35103the @code{L32R} instruction is not available.
35104
d77de738
ML
35105@opindex mfused-madd
35106@opindex mno-fused-madd
ddf6fe37
AA
35107@item -mfused-madd
35108@itemx -mno-fused-madd
d77de738
ML
35109Enable or disable use of fused multiply/add and multiply/subtract
35110instructions in the floating-point option. This has no effect if the
35111floating-point option is not also enabled. Disabling fused multiply/add
35112and multiply/subtract instructions forces the compiler to use separate
35113instructions for the multiply and add/subtract operations. This may be
35114desirable in some cases where strict IEEE 754-compliant results are
35115required: the fused multiply add/subtract instructions do not round the
35116intermediate result, thereby producing results with @emph{more} bits of
35117precision than specified by the IEEE standard. Disabling fused multiply
35118add/subtract instructions also ensures that the program output is not
35119sensitive to the compiler's ability to combine multiply and add/subtract
35120operations.
35121
d77de738
ML
35122@opindex mserialize-volatile
35123@opindex mno-serialize-volatile
ddf6fe37
AA
35124@item -mserialize-volatile
35125@itemx -mno-serialize-volatile
d77de738
ML
35126When this option is enabled, GCC inserts @code{MEMW} instructions before
35127@code{volatile} memory references to guarantee sequential consistency.
35128The default is @option{-mserialize-volatile}. Use
35129@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
35130
d77de738 35131@opindex mforce-no-pic
ddf6fe37 35132@item -mforce-no-pic
d77de738
ML
35133For targets, like GNU/Linux, where all user-mode Xtensa code must be
35134position-independent code (PIC), this option disables PIC for compiling
35135kernel code.
35136
d77de738
ML
35137@opindex mtext-section-literals
35138@opindex mno-text-section-literals
ddf6fe37
AA
35139@item -mtext-section-literals
35140@itemx -mno-text-section-literals
d77de738
ML
35141These options control the treatment of literal pools. The default is
35142@option{-mno-text-section-literals}, which places literals in a separate
35143section in the output file. This allows the literal pool to be placed
35144in a data RAM/ROM, and it also allows the linker to combine literal
35145pools from separate object files to remove redundant literals and
35146improve code size. With @option{-mtext-section-literals}, the literals
35147are interspersed in the text section in order to keep them as close as
35148possible to their references. This may be necessary for large assembly
35149files. Literals for each function are placed right before that function.
35150
d77de738
ML
35151@opindex mauto-litpools
35152@opindex mno-auto-litpools
ddf6fe37
AA
35153@item -mauto-litpools
35154@itemx -mno-auto-litpools
d77de738
ML
35155These options control the treatment of literal pools. The default is
35156@option{-mno-auto-litpools}, which places literals in a separate
35157section in the output file unless @option{-mtext-section-literals} is
35158used. With @option{-mauto-litpools} the literals are interspersed in
35159the text section by the assembler. Compiler does not produce explicit
35160@code{.literal} directives and loads literals into registers with
35161@code{MOVI} instructions instead of @code{L32R} to let the assembler
35162do relaxation and place literals as necessary. This option allows
35163assembler to create several literal pools per function and assemble
35164very big functions, which may not be possible with
35165@option{-mtext-section-literals}.
35166
d77de738
ML
35167@opindex mtarget-align
35168@opindex mno-target-align
ddf6fe37
AA
35169@item -mtarget-align
35170@itemx -mno-target-align
d77de738
ML
35171When this option is enabled, GCC instructs the assembler to
35172automatically align instructions to reduce branch penalties at the
35173expense of some code density. The assembler attempts to widen density
35174instructions to align branch targets and the instructions following call
35175instructions. If there are not enough preceding safe density
35176instructions to align a target, no widening is performed. The
35177default is @option{-mtarget-align}. These options do not affect the
35178treatment of auto-aligned instructions like @code{LOOP}, which the
35179assembler always aligns, either by widening density instructions or
35180by inserting NOP instructions.
35181
d77de738
ML
35182@opindex mlongcalls
35183@opindex mno-longcalls
ddf6fe37
AA
35184@item -mlongcalls
35185@itemx -mno-longcalls
d77de738
ML
35186When this option is enabled, GCC instructs the assembler to translate
35187direct calls to indirect calls unless it can determine that the target
35188of a direct call is in the range allowed by the call instruction. This
35189translation typically occurs for calls to functions in other source
35190files. Specifically, the assembler translates a direct @code{CALL}
35191instruction into an @code{L32R} followed by a @code{CALLX} instruction.
35192The default is @option{-mno-longcalls}. This option should be used in
35193programs where the call target can potentially be out of range. This
35194option is implemented in the assembler, not the compiler, so the
35195assembly code generated by GCC still shows direct call
35196instructions---look at the disassembled object code to see the actual
35197instructions. Note that the assembler uses an indirect call for
35198every cross-file call, not just those that really are out of range.
35199
d77de738 35200@opindex mabi
ddf6fe37 35201@item -mabi=@var{name}
d77de738
ML
35202Generate code for the specified ABI@. Permissible values are: @samp{call0},
35203@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
35204
d77de738 35205@opindex mabi=call0
ddf6fe37 35206@item -mabi=call0
d77de738
ML
35207When this option is enabled function parameters are passed in registers
35208@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
35209caller-saved, and register @code{a15} may be used as a frame pointer.
35210When this version of the ABI is enabled the C preprocessor symbol
35211@code{__XTENSA_CALL0_ABI__} is defined.
35212
d77de738 35213@opindex mabi=windowed
ddf6fe37 35214@item -mabi=windowed
d77de738
ML
35215When this option is enabled function parameters are passed in registers
35216@code{a10} through @code{a15}, and called function rotates register window
35217by 8 registers on entry so that its arguments are found in registers
35218@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
35219pointer. Register window is rotated 8 registers back upon return.
35220When this version of the ABI is enabled the C preprocessor symbol
35221@code{__XTENSA_WINDOWED_ABI__} is defined.
35222
d77de738 35223@opindex mextra-l32r-costs
ddf6fe37 35224@item -mextra-l32r-costs=@var{n}
d77de738
ML
35225Specify an extra cost of instruction RAM/ROM access for @code{L32R}
35226instructions, in clock cycles. This affects, when optimizing for speed,
35227whether loading a constant from literal pool using @code{L32R} or
35228synthesizing the constant from a small one with a couple of arithmetic
35229instructions. The default value is 0.
675b390e
MF
35230
35231@opindex mstrict-align
35232@opindex mno-strict-align
35233@item -mstrict-align
35234@itemx -mno-strict-align
35235Avoid or allow generating memory accesses that may not be aligned on a natural
35236object boundary as described in the architecture specification.
35237The default is @option{-mno-strict-align} for cores that support both
35238unaligned loads and stores in hardware and @option{-mstrict-align} for all
35239other cores.
35240
d77de738
ML
35241@end table
35242
35243@node zSeries Options
35244@subsection zSeries Options
35245@cindex zSeries options
35246
35247These are listed under @xref{S/390 and zSeries Options}.
35248
35249
35250@c man end
35251
35252@node Spec Files
35253@section Specifying Subprocesses and the Switches to Pass to Them
35254@cindex Spec Files
35255
35256@command{gcc} is a driver program. It performs its job by invoking a
35257sequence of other programs to do the work of compiling, assembling and
35258linking. GCC interprets its command-line parameters and uses these to
35259deduce which programs it should invoke, and which command-line options
35260it ought to place on their command lines. This behavior is controlled
35261by @dfn{spec strings}. In most cases there is one spec string for each
35262program that GCC can invoke, but a few programs have multiple spec
35263strings to control their behavior. The spec strings built into GCC can
35264be overridden by using the @option{-specs=} command-line switch to specify
35265a spec file.
35266
35267@dfn{Spec files} are plain-text files that are used to construct spec
35268strings. They consist of a sequence of directives separated by blank
35269lines. The type of directive is determined by the first non-whitespace
35270character on the line, which can be one of the following:
35271
35272@table @code
35273@item %@var{command}
35274Issues a @var{command} to the spec file processor. The commands that can
35275appear here are:
35276
35277@table @code
d77de738 35278@cindex @code{%include}
f33d7a88 35279@item %include <@var{file}>
d77de738
ML
35280Search for @var{file} and insert its text at the current point in the
35281specs file.
35282
d77de738 35283@cindex @code{%include_noerr}
f33d7a88 35284@item %include_noerr <@var{file}>
d77de738
ML
35285Just like @samp{%include}, but do not generate an error message if the include
35286file cannot be found.
35287
d77de738 35288@cindex @code{%rename}
f33d7a88 35289@item %rename @var{old_name} @var{new_name}
d77de738
ML
35290Rename the spec string @var{old_name} to @var{new_name}.
35291
35292@end table
35293
35294@item *[@var{spec_name}]:
35295This tells the compiler to create, override or delete the named spec
35296string. All lines after this directive up to the next directive or
35297blank line are considered to be the text for the spec string. If this
35298results in an empty string then the spec is deleted. (Or, if the
35299spec did not exist, then nothing happens.) Otherwise, if the spec
35300does not currently exist a new spec is created. If the spec does
35301exist then its contents are overridden by the text of this
35302directive, unless the first character of that text is the @samp{+}
35303character, in which case the text is appended to the spec.
35304
35305@item [@var{suffix}]:
35306Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
35307and up to the next directive or blank line are considered to make up the
35308spec string for the indicated suffix. When the compiler encounters an
35309input file with the named suffix, it processes the spec string in
35310order to work out how to compile that file. For example:
35311
35312@smallexample
35313.ZZ:
35314z-compile -input %i
35315@end smallexample
35316
35317This says that any input file whose name ends in @samp{.ZZ} should be
35318passed to the program @samp{z-compile}, which should be invoked with the
35319command-line switch @option{-input} and with the result of performing the
35320@samp{%i} substitution. (See below.)
35321
35322As an alternative to providing a spec string, the text following a
35323suffix directive can be one of the following:
35324
35325@table @code
35326@item @@@var{language}
35327This says that the suffix is an alias for a known @var{language}. This is
35328similar to using the @option{-x} command-line switch to GCC to specify a
35329language explicitly. For example:
35330
35331@smallexample
35332.ZZ:
35333@@c++
35334@end smallexample
35335
35336Says that .ZZ files are, in fact, C++ source files.
35337
35338@item #@var{name}
35339This causes an error messages saying:
35340
35341@smallexample
35342@var{name} compiler not installed on this system.
35343@end smallexample
35344@end table
35345
35346GCC already has an extensive list of suffixes built into it.
35347This directive adds an entry to the end of the list of suffixes, but
35348since the list is searched from the end backwards, it is effectively
35349possible to override earlier entries using this technique.
35350
35351@end table
35352
35353GCC has the following spec strings built into it. Spec files can
35354override these strings or create their own. Note that individual
35355targets can also add their own spec strings to this list.
35356
35357@smallexample
35358asm Options to pass to the assembler
35359asm_final Options to pass to the assembler post-processor
35360cpp Options to pass to the C preprocessor
35361cc1 Options to pass to the C compiler
35362cc1plus Options to pass to the C++ compiler
35363endfile Object files to include at the end of the link
35364link Options to pass to the linker
35365lib Libraries to include on the command line to the linker
35366libgcc Decides which GCC support library to pass to the linker
35367linker Sets the name of the linker
35368predefines Defines to be passed to the C preprocessor
35369signed_char Defines to pass to CPP to say whether @code{char} is signed
35370 by default
35371startfile Object files to include at the start of the link
35372@end smallexample
35373
35374Here is a small example of a spec file:
35375
35376@smallexample
35377%rename lib old_lib
35378
35379*lib:
35380--start-group -lgcc -lc -leval1 --end-group %(old_lib)
35381@end smallexample
35382
35383This example renames the spec called @samp{lib} to @samp{old_lib} and
35384then overrides the previous definition of @samp{lib} with a new one.
35385The new definition adds in some extra command-line options before
35386including the text of the old definition.
35387
35388@dfn{Spec strings} are a list of command-line options to be passed to their
35389corresponding program. In addition, the spec strings can contain
35390@samp{%}-prefixed sequences to substitute variable text or to
35391conditionally insert text into the command line. Using these constructs
35392it is possible to generate quite complex command lines.
35393
35394Here is a table of all defined @samp{%}-sequences for spec
35395strings. Note that spaces are not generated automatically around the
35396results of expanding these sequences. Therefore you can concatenate them
35397together or combine them with constant text in a single argument.
35398
35399@table @code
35400@item %%
35401Substitute one @samp{%} into the program name or argument.
35402
35403@item %"
35404Substitute an empty argument.
35405
35406@item %i
35407Substitute the name of the input file being processed.
35408
35409@item %b
35410Substitute the basename for outputs related with the input file being
35411processed. This is often the substring up to (and not including) the
35412last period and not including the directory but, unless %w is active, it
35413expands to the basename for auxiliary outputs, which may be influenced
35414by an explicit output name, and by various other options that control
35415how auxiliary outputs are named.
35416
35417@item %B
35418This is the same as @samp{%b}, but include the file suffix (text after
35419the last period). Without %w, it expands to the basename for dump
35420outputs.
35421
35422@item %d
35423Marks the argument containing or following the @samp{%d} as a
35424temporary file name, so that that file is deleted if GCC exits
35425successfully. Unlike @samp{%g}, this contributes no text to the
35426argument.
35427
35428@item %g@var{suffix}
35429Substitute a file name that has suffix @var{suffix} and is chosen
35430once per compilation, and mark the argument in the same way as
35431@samp{%d}. To reduce exposure to denial-of-service attacks, the file
35432name is now chosen in a way that is hard to predict even when previously
35433chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
35434might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
35435the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
35436treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
35437was simply substituted with a file name chosen once per compilation,
35438without regard to any appended suffix (which was therefore treated
35439just like ordinary text), making such attacks more likely to succeed.
35440
35441@item %u@var{suffix}
35442Like @samp{%g}, but generates a new temporary file name
35443each time it appears instead of once per compilation.
35444
35445@item %U@var{suffix}
35446Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
35447new one if there is no such last file name. In the absence of any
35448@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
35449the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
35450involves the generation of two distinct file names, one
35451for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
35452simply substituted with a file name chosen for the previous @samp{%u},
35453without regard to any appended suffix.
35454
35455@item %j@var{suffix}
35456Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
35457writable, and if @option{-save-temps} is not used;
35458otherwise, substitute the name
35459of a temporary file, just like @samp{%u}. This temporary file is not
35460meant for communication between processes, but rather as a junk
35461disposal mechanism.
35462
35463@item %|@var{suffix}
35464@itemx %m@var{suffix}
35465Like @samp{%g}, except if @option{-pipe} is in effect. In that case
35466@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
35467all. These are the two most common ways to instruct a program that it
35468should read from standard input or write to standard output. If you
35469need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
35470construct: see for example @file{gcc/fortran/lang-specs.h}.
35471
35472@item %.@var{SUFFIX}
35473Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
35474when it is subsequently output with @samp{%*}. @var{SUFFIX} is
35475terminated by the next space or %.
35476
35477@item %w
35478Marks the argument containing or following the @samp{%w} as the
35479designated output file of this compilation. This puts the argument
35480into the sequence of arguments that @samp{%o} substitutes.
35481
35482@item %V
35483Indicates that this compilation produces no output file.
35484
35485@item %o
35486Substitutes the names of all the output files, with spaces
35487automatically placed around them. You should write spaces
35488around the @samp{%o} as well or the results are undefined.
35489@samp{%o} is for use in the specs for running the linker.
35490Input files whose names have no recognized suffix are not compiled
35491at all, but they are included among the output files, so they are
35492linked.
35493
35494@item %O
35495Substitutes the suffix for object files. Note that this is
35496handled specially when it immediately follows @samp{%g, %u, or %U},
35497because of the need for those to form complete file names. The
35498handling is such that @samp{%O} is treated exactly as if it had already
35499been substituted, except that @samp{%g, %u, and %U} do not currently
35500support additional @var{suffix} characters following @samp{%O} as they do
35501following, for example, @samp{.o}.
35502
35503@item %I
35504Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
35505@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
35506@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
35507and @option{-imultilib} as necessary.
35508
35509@item %s
35510Current argument is the name of a library or startup file of some sort.
35511Search for that file in a standard list of directories and substitute
35512the full name found. The current working directory is included in the
35513list of directories scanned.
35514
35515@item %T
35516Current argument is the name of a linker script. Search for that file
35517in the current list of directories to scan for libraries. If the file
35518is located insert a @option{--script} option into the command line
35519followed by the full path name found. If the file is not found then
35520generate an error message. Note: the current working directory is not
35521searched.
35522
35523@item %e@var{str}
35524Print @var{str} as an error message. @var{str} is terminated by a newline.
35525Use this when inconsistent options are detected.
35526
35527@item %n@var{str}
35528Print @var{str} as a notice. @var{str} is terminated by a newline.
35529
35530@item %(@var{name})
35531Substitute the contents of spec string @var{name} at this point.
35532
35533@item %x@{@var{option}@}
35534Accumulate an option for @samp{%X}.
35535
35536@item %X
35537Output the accumulated linker options specified by a @samp{%x} spec string.
35538
35539@item %Y
35540Output the accumulated assembler options specified by @option{-Wa}.
35541
35542@item %Z
35543Output the accumulated preprocessor options specified by @option{-Wp}.
35544
35545@item %M
35546Output @code{multilib_os_dir}.
35547
35548@item %R
35549Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
35550
35551@item %a
35552Process the @code{asm} spec. This is used to compute the
35553switches to be passed to the assembler.
35554
35555@item %A
35556Process the @code{asm_final} spec. This is a spec string for
35557passing switches to an assembler post-processor, if such a program is
35558needed.
35559
35560@item %l
35561Process the @code{link} spec. This is the spec for computing the
35562command line passed to the linker. Typically it makes use of the
35563@samp{%L %G %S %D and %E} sequences.
35564
35565@item %D
35566Dump out a @option{-L} option for each directory that GCC believes might
35567contain startup files. If the target supports multilibs then the
35568current multilib directory is prepended to each of these paths.
35569
35570@item %L
35571Process the @code{lib} spec. This is a spec string for deciding which
35572libraries are included on the command line to the linker.
35573
35574@item %G
35575Process the @code{libgcc} spec. This is a spec string for deciding
35576which GCC support library is included on the command line to the linker.
35577
35578@item %S
35579Process the @code{startfile} spec. This is a spec for deciding which
35580object files are the first ones passed to the linker. Typically
35581this might be a file named @file{crt0.o}.
35582
35583@item %E
35584Process the @code{endfile} spec. This is a spec string that specifies
35585the last object files that are passed to the linker.
35586
35587@item %C
35588Process the @code{cpp} spec. This is used to construct the arguments
35589to be passed to the C preprocessor.
35590
35591@item %1
35592Process the @code{cc1} spec. This is used to construct the options to be
35593passed to the actual C compiler (@command{cc1}).
35594
35595@item %2
35596Process the @code{cc1plus} spec. This is used to construct the options to be
35597passed to the actual C++ compiler (@command{cc1plus}).
35598
35599@item %*
35600Substitute the variable part of a matched option. See below.
35601Note that each comma in the substituted string is replaced by
35602a single space.
35603
35604@item %<S
35605Remove all occurrences of @code{-S} from the command line. Note---this
35606command is position dependent. @samp{%} commands in the spec string
35607before this one see @code{-S}, @samp{%} commands in the spec string
35608after this one do not.
35609
35610@item %<S*
35611Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
35612
35613@item %>S
35614Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
35615
35616@item %:@var{function}(@var{args})
35617Call the named function @var{function}, passing it @var{args}.
35618@var{args} is first processed as a nested spec string, then split
35619into an argument vector in the usual fashion. The function returns
35620a string which is processed as if it had appeared literally as part
35621of the current spec.
35622
35623The following built-in spec functions are provided:
35624
35625@table @code
35626@item @code{getenv}
35627The @code{getenv} spec function takes two arguments: an environment
35628variable name and a string. If the environment variable is not
35629defined, a fatal error is issued. Otherwise, the return value is the
35630value of the environment variable concatenated with the string. For
35631example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
35632
35633@smallexample
35634%:getenv(TOPDIR /include)
35635@end smallexample
35636
35637expands to @file{/path/to/top/include}.
35638
35639@item @code{if-exists}
35640The @code{if-exists} spec function takes one argument, an absolute
35641pathname to a file. If the file exists, @code{if-exists} returns the
35642pathname. Here is a small example of its usage:
35643
35644@smallexample
35645*startfile:
35646crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
35647@end smallexample
35648
35649@item @code{if-exists-else}
35650The @code{if-exists-else} spec function is similar to the @code{if-exists}
35651spec function, except that it takes two arguments. The first argument is
35652an absolute pathname to a file. If the file exists, @code{if-exists-else}
35653returns the pathname. If it does not exist, it returns the second argument.
35654This way, @code{if-exists-else} can be used to select one file or another,
35655based on the existence of the first. Here is a small example of its usage:
35656
35657@smallexample
35658*startfile:
35659crt0%O%s %:if-exists(crti%O%s) \
35660%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
35661@end smallexample
35662
35663@item @code{if-exists-then-else}
35664The @code{if-exists-then-else} spec function takes at least two arguments
35665and an optional third one. The first argument is an absolute pathname to a
35666file. If the file exists, the function returns the second argument.
35667If the file does not exist, the function returns the third argument if there
35668is one, or NULL otherwise. This can be used to expand one text, or optionally
35669another, based on the existence of a file. Here is a small example of its
35670usage:
35671
35672@smallexample
35673-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
35674@end smallexample
35675
35676@item @code{sanitize}
35677The @code{sanitize} spec function takes no arguments. It returns non-NULL if
35678any address, thread or undefined behavior sanitizers are active.
35679
35680@smallexample
35681%@{%:sanitize(address):-funwind-tables@}
35682@end smallexample
35683
35684@item @code{replace-outfile}
35685The @code{replace-outfile} spec function takes two arguments. It looks for the
35686first argument in the outfiles array and replaces it with the second argument. Here
35687is a small example of its usage:
35688
35689@smallexample
35690%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
35691@end smallexample
35692
35693@item @code{remove-outfile}
35694The @code{remove-outfile} spec function takes one argument. It looks for the
35695first argument in the outfiles array and removes it. Here is a small example
35696its usage:
35697
35698@smallexample
35699%:remove-outfile(-lm)
35700@end smallexample
35701
35702@item @code{version-compare}
35703The @code{version-compare} spec function takes four or five arguments of the following
35704form:
35705
35706@smallexample
35707<comparison-op> <arg1> [<arg2>] <switch> <result>
35708@end smallexample
35709
35710It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
35711The supported @code{comparison-op} values are:
35712
35713@table @code
35714@item >=
35715True if @code{switch} is a later (or same) version than @code{arg1}
35716
35717@item !>
35718Opposite of @code{>=}
35719
35720@item <
35721True if @code{switch} is an earlier version than @code{arg1}
35722
35723@item !<
35724Opposite of @code{<}
35725
35726@item ><
35727True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
35728
35729@item <>
35730True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
35731@end table
35732
35733If the @code{switch} is not present at all, the condition is false unless the first character
35734of the @code{comparison-op} is @code{!}.
35735
35736@smallexample
35737%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
35738@end smallexample
35739
35740The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
35741passed.
35742
35743@item @code{include}
35744The @code{include} spec function behaves much like @code{%include}, with the advantage
35745that it can be nested inside a spec and thus be conditionalized. It takes one argument,
35746the filename, and looks for it in the startfile path. It always returns NULL.
35747
35748@smallexample
35749%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
35750@end smallexample
35751
35752@item @code{pass-through-libs}
35753The @code{pass-through-libs} spec function takes any number of arguments. It
35754finds any @option{-l} options and any non-options ending in @file{.a} (which it
35755assumes are the names of linker input library archive files) and returns a
35756result containing all the found arguments each prepended by
35757@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
35758intended to be passed to the LTO linker plugin.
35759
35760@smallexample
35761%:pass-through-libs(%G %L %G)
35762@end smallexample
35763
35764@item @code{print-asm-header}
35765The @code{print-asm-header} function takes no arguments and simply
35766prints a banner like:
35767
35768@smallexample
35769Assembler options
35770=================
35771
35772Use "-Wa,OPTION" to pass "OPTION" to the assembler.
35773@end smallexample
35774
35775It is used to separate compiler options from assembler options
35776in the @option{--target-help} output.
35777
35778@item @code{gt}
35779The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
35780empty string) if the second-to-last argument is greater than the last argument, and NULL
35781otherwise. The following example inserts the @code{link_gomp} spec if the last
35782@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
35783
35784@smallexample
35785%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
35786@end smallexample
35787
35788@item @code{debug-level-gt}
35789The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
35790empty string) if @code{debug_info_level} is greater than the specified number, and NULL
35791otherwise.
35792
35793@smallexample
35794%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
35795@end smallexample
35796@end table
35797
35798@item %@{S@}
35799Substitutes the @code{-S} switch, if that switch is given to GCC@.
35800If that switch is not specified, this substitutes nothing. Note that
35801the leading dash is omitted when specifying this option, and it is
35802automatically inserted if the substitution is performed. Thus the spec
35803string @samp{%@{foo@}} matches the command-line option @option{-foo}
35804and outputs the command-line option @option{-foo}.
35805
35806@item %W@{S@}
35807Like %@{@code{S}@} but mark last argument supplied within as a file to be
35808deleted on failure.
35809
35810@item %@@@{S@}
35811Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
35812@code{@@FILE} if an @code{@@file} argument has been supplied.
35813
35814@item %@{S*@}
35815Substitutes all the switches specified to GCC whose names start
35816with @code{-S}, but which also take an argument. This is used for
35817switches like @option{-o}, @option{-D}, @option{-I}, etc.
35818GCC considers @option{-o foo} as being
35819one switch whose name starts with @samp{o}. %@{o*@} substitutes this
35820text, including the space. Thus two arguments are generated.
35821
35822@item %@{S*&T*@}
35823Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
35824(the order of @code{S} and @code{T} in the spec is not significant).
35825There can be any number of ampersand-separated variables; for each the
35826wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
35827
35828@item %@{S:X@}
35829Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
35830
35831@item %@{!S:X@}
35832Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
35833
35834@item %@{S*:X@}
35835Substitutes @code{X} if one or more switches whose names start with
35836@code{-S} are specified to GCC@. Normally @code{X} is substituted only
35837once, no matter how many such switches appeared. However, if @code{%*}
35838appears somewhere in @code{X}, then @code{X} is substituted once
35839for each matching switch, with the @code{%*} replaced by the part of
35840that switch matching the @code{*}.
35841
35842If @code{%*} appears as the last part of a spec sequence then a space
35843is added after the end of the last substitution. If there is more
35844text in the sequence, however, then a space is not generated. This
35845allows the @code{%*} substitution to be used as part of a larger
35846string. For example, a spec string like this:
35847
35848@smallexample
35849%@{mcu=*:--script=%*/memory.ld@}
35850@end smallexample
35851
35852@noindent
35853when matching an option like @option{-mcu=newchip} produces:
35854
35855@smallexample
35856--script=newchip/memory.ld
35857@end smallexample
35858
35859@item %@{.S:X@}
35860Substitutes @code{X}, if processing a file with suffix @code{S}.
35861
35862@item %@{!.S:X@}
35863Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35864
35865@item %@{,S:X@}
35866Substitutes @code{X}, if processing a file for language @code{S}.
35867
35868@item %@{!,S:X@}
35869Substitutes @code{X}, if not processing a file for language @code{S}.
35870
35871@item %@{S|P:X@}
35872Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35873GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35874@code{*} sequences as well, although they have a stronger binding than
35875the @samp{|}. If @code{%*} appears in @code{X}, all of the
35876alternatives must be starred, and only the first matching alternative
35877is substituted.
35878
35879For example, a spec string like this:
35880
35881@smallexample
35882%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35883@end smallexample
35884
35885@noindent
35886outputs the following command-line options from the following input
35887command-line options:
35888
35889@smallexample
35890fred.c -foo -baz
35891jim.d -bar -boggle
35892-d fred.c -foo -baz -boggle
35893-d jim.d -bar -baz -boggle
35894@end smallexample
35895
35896@item %@{%:@var{function}(@var{args}):X@}
35897
35898Call function named @var{function} with args @var{args}. If the
35899function returns non-NULL, then @code{X} is substituted, if it returns
35900NULL, it isn't substituted.
35901
35902@item %@{S:X; T:Y; :D@}
35903
35904If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35905given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35906be as many clauses as you need. This may be combined with @code{.},
35907@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35908
35909
35910@end table
35911
35912The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35913or similar construct can use a backslash to ignore the special meaning
35914of the character following it, thus allowing literal matching of a
35915character that is otherwise specially treated. For example,
35916@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35917@option{-std=iso9899:1999} option is given.
35918
35919The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35920construct may contain other nested @samp{%} constructs or spaces, or
35921even newlines. They are processed as usual, as described above.
35922Trailing white space in @code{X} is ignored. White space may also
35923appear anywhere on the left side of the colon in these constructs,
35924except between @code{.} or @code{*} and the corresponding word.
35925
35926The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35927handled specifically in these constructs. If another value of
35928@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35929@option{-W} switch is found later in the command line, the earlier
35930switch value is ignored, except with @{@code{S}*@} where @code{S} is
35931just one letter, which passes all matching options.
35932
35933The character @samp{|} at the beginning of the predicate text is used to
35934indicate that a command should be piped to the following command, but
35935only if @option{-pipe} is specified.
35936
35937It is built into GCC which switches take arguments and which do not.
35938(You might think it would be useful to generalize this to allow each
35939compiler's spec to say which switches take arguments. But this cannot
35940be done in a consistent fashion. GCC cannot even decide which input
35941files have been specified without knowing which switches take arguments,
35942and it must know which input files to compile in order to tell which
35943compilers to run).
35944
35945GCC also knows implicitly that arguments starting in @option{-l} are to be
35946treated as compiler output files, and passed to the linker in their
35947proper position among the other output files.
35948
35949@node Environment Variables
35950@section Environment Variables Affecting GCC
35951@cindex environment variables
35952
35953@c man begin ENVIRONMENT
35954This section describes several environment variables that affect how GCC
35955operates. Some of them work by specifying directories or prefixes to use
35956when searching for various kinds of files. Some are used to specify other
35957aspects of the compilation environment.
35958
35959Note that you can also specify places to search using options such as
35960@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35961take precedence over places specified using environment variables, which
35962in turn take precedence over those specified by the configuration of GCC@.
35963@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35964GNU Compiler Collection (GCC) Internals}.
35965
35966@table @env
f33d7a88
AA
35967@vindex LANG
35968@vindex LC_CTYPE
35969@c @vindex LC_COLLATE
35970@vindex LC_MESSAGES
35971@c @vindex LC_MONETARY
35972@c @vindex LC_NUMERIC
35973@c @vindex LC_TIME
35974@vindex LC_ALL
35975@cindex locale
d77de738
ML
35976@item LANG
35977@itemx LC_CTYPE
35978@c @itemx LC_COLLATE
35979@itemx LC_MESSAGES
35980@c @itemx LC_MONETARY
35981@c @itemx LC_NUMERIC
35982@c @itemx LC_TIME
35983@itemx LC_ALL
d77de738
ML
35984These environment variables control the way that GCC uses
35985localization information which allows GCC to work with different
35986national conventions. GCC inspects the locale categories
35987@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35988so. These locale categories can be set to any value supported by your
35989installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35990Kingdom encoded in UTF-8.
35991
35992The @env{LC_CTYPE} environment variable specifies character
35993classification. GCC uses it to determine the character boundaries in
35994a string; this is needed for some multibyte encodings that contain quote
35995and escape characters that are otherwise interpreted as a string
35996end or escape.
35997
35998The @env{LC_MESSAGES} environment variable specifies the language to
35999use in diagnostic messages.
36000
36001If the @env{LC_ALL} environment variable is set, it overrides the value
36002of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
36003and @env{LC_MESSAGES} default to the value of the @env{LANG}
36004environment variable. If none of these variables are set, GCC
36005defaults to traditional C English behavior.
36006
f33d7a88 36007@vindex TMPDIR
d77de738 36008@item TMPDIR
d77de738
ML
36009If @env{TMPDIR} is set, it specifies the directory to use for temporary
36010files. GCC uses temporary files to hold the output of one stage of
36011compilation which is to be used as input to the next stage: for example,
36012the output of the preprocessor, which is the input to the compiler
36013proper.
36014
f33d7a88 36015@vindex GCC_COMPARE_DEBUG
d77de738 36016@item GCC_COMPARE_DEBUG
d77de738
ML
36017Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
36018@option{-fcompare-debug} to the compiler driver. See the documentation
36019of this option for more details.
36020
f33d7a88 36021@vindex GCC_EXEC_PREFIX
d77de738 36022@item GCC_EXEC_PREFIX
d77de738
ML
36023If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
36024names of the subprograms executed by the compiler. No slash is added
36025when this prefix is combined with the name of a subprogram, but you can
36026specify a prefix that ends with a slash if you wish.
36027
36028If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
36029an appropriate prefix to use based on the pathname it is invoked with.
36030
36031If GCC cannot find the subprogram using the specified prefix, it
36032tries looking in the usual places for the subprogram.
36033
36034The default value of @env{GCC_EXEC_PREFIX} is
36035@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
36036the installed compiler. In many cases @var{prefix} is the value
36037of @code{prefix} when you ran the @file{configure} script.
36038
36039Other prefixes specified with @option{-B} take precedence over this prefix.
36040
36041This prefix is also used for finding files such as @file{crt0.o} that are
36042used for linking.
36043
36044In addition, the prefix is used in an unusual way in finding the
36045directories to search for header files. For each of the standard
36046directories whose name normally begins with @samp{/usr/local/lib/gcc}
36047(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
36048replacing that beginning with the specified prefix to produce an
36049alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
36050@file{foo/bar} just before it searches the standard directory
36051@file{/usr/local/lib/bar}.
36052If a standard directory begins with the configured
36053@var{prefix} then the value of @var{prefix} is replaced by
36054@env{GCC_EXEC_PREFIX} when looking for header files.
36055
f33d7a88 36056@vindex COMPILER_PATH
d77de738 36057@item COMPILER_PATH
d77de738
ML
36058The value of @env{COMPILER_PATH} is a colon-separated list of
36059directories, much like @env{PATH}. GCC tries the directories thus
36060specified when searching for subprograms, if it cannot find the
36061subprograms using @env{GCC_EXEC_PREFIX}.
36062
f33d7a88 36063@vindex LIBRARY_PATH
d77de738 36064@item LIBRARY_PATH
d77de738
ML
36065The value of @env{LIBRARY_PATH} is a colon-separated list of
36066directories, much like @env{PATH}. When configured as a native compiler,
36067GCC tries the directories thus specified when searching for special
36068linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
36069using GCC also uses these directories when searching for ordinary
36070libraries for the @option{-l} option (but directories specified with
36071@option{-L} come first).
36072
f33d7a88 36073@vindex LANG
d77de738 36074@cindex locale definition
f33d7a88 36075@item LANG
d77de738
ML
36076This variable is used to pass locale information to the compiler. One way in
36077which this information is used is to determine the character set to be used
36078when character literals, string literals and comments are parsed in C and C++.
36079When the compiler is configured to allow multibyte characters,
36080the following values for @env{LANG} are recognized:
36081
36082@table @samp
36083@item C-JIS
36084Recognize JIS characters.
36085@item C-SJIS
36086Recognize SJIS characters.
36087@item C-EUCJP
36088Recognize EUCJP characters.
36089@end table
36090
36091If @env{LANG} is not defined, or if it has some other value, then the
36092compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
36093recognize and translate multibyte characters.
36094
f33d7a88 36095@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 36096@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
36097If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
36098then additional text will be emitted to stderr when fix-it hints are
36099emitted. @option{-fdiagnostics-parseable-fixits} and
36100@option{-fno-diagnostics-parseable-fixits} take precedence over this
36101environment variable.
36102
36103@table @samp
36104@item fixits-v1
36105Emit parseable fix-it hints, equivalent to
36106@option{-fdiagnostics-parseable-fixits}. In particular, columns are
36107expressed as a count of bytes, starting at byte 1 for the initial column.
36108
36109@item fixits-v2
36110As @code{fixits-v1}, but columns are expressed as display columns,
36111as per @option{-fdiagnostics-column-unit=display}.
36112@end table
36113
36114@end table
36115
36116@noindent
36117Some additional environment variables affect the behavior of the
36118preprocessor.
36119
36120@include cppenv.texi
36121
36122@c man end
36123
36124@node Precompiled Headers
36125@section Using Precompiled Headers
36126@cindex precompiled headers
36127@cindex speed of compilation
36128
36129Often large projects have many header files that are included in every
36130source file. The time the compiler takes to process these header files
36131over and over again can account for nearly all of the time required to
36132build the project. To make builds faster, GCC allows you to
36133@dfn{precompile} a header file.
36134
36135To create a precompiled header file, simply compile it as you would any
36136other file, if necessary using the @option{-x} option to make the driver
36137treat it as a C or C++ header file. You may want to use a
36138tool like @command{make} to keep the precompiled header up-to-date when
36139the headers it contains change.
36140
36141A precompiled header file is searched for when @code{#include} is
36142seen in the compilation. As it searches for the included file
36143(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
36144compiler looks for a precompiled header in each directory just before it
36145looks for the include file in that directory. The name searched for is
36146the name specified in the @code{#include} with @samp{.gch} appended. If
36147the precompiled header file cannot be used, it is ignored.
36148
36149For instance, if you have @code{#include "all.h"}, and you have
36150@file{all.h.gch} in the same directory as @file{all.h}, then the
36151precompiled header file is used if possible, and the original
36152header is used otherwise.
36153
36154Alternatively, you might decide to put the precompiled header file in a
36155directory and use @option{-I} to ensure that directory is searched
36156before (or instead of) the directory containing the original header.
36157Then, if you want to check that the precompiled header file is always
36158used, you can put a file of the same name as the original header in this
36159directory containing an @code{#error} command.
36160
36161This also works with @option{-include}. So yet another way to use
36162precompiled headers, good for projects not designed with precompiled
36163header files in mind, is to simply take most of the header files used by
36164a project, include them from another header file, precompile that header
36165file, and @option{-include} the precompiled header. If the header files
36166have guards against multiple inclusion, they are skipped because
36167they've already been included (in the precompiled header).
36168
36169If you need to precompile the same header file for different
36170languages, targets, or compiler options, you can instead make a
36171@emph{directory} named like @file{all.h.gch}, and put each precompiled
36172header in the directory, perhaps using @option{-o}. It doesn't matter
36173what you call the files in the directory; every precompiled header in
36174the directory is considered. The first precompiled header
36175encountered in the directory that is valid for this compilation is
36176used; they're searched in no particular order.
36177
36178There are many other possibilities, limited only by your imagination,
36179good sense, and the constraints of your build system.
36180
36181A precompiled header file can be used only when these conditions apply:
36182
36183@itemize
36184@item
36185Only one precompiled header can be used in a particular compilation.
36186
36187@item
36188A precompiled header cannot be used once the first C token is seen. You
36189can have preprocessor directives before a precompiled header; you cannot
36190include a precompiled header from inside another header.
36191
36192@item
36193The precompiled header file must be produced for the same language as
36194the current compilation. You cannot use a C precompiled header for a C++
36195compilation.
36196
36197@item
36198The precompiled header file must have been produced by the same compiler
36199binary as the current compilation is using.
36200
36201@item
36202Any macros defined before the precompiled header is included must
36203either be defined in the same way as when the precompiled header was
36204generated, or must not affect the precompiled header, which usually
36205means that they don't appear in the precompiled header at all.
36206
36207The @option{-D} option is one way to define a macro before a
36208precompiled header is included; using a @code{#define} can also do it.
36209There are also some options that define macros implicitly, like
36210@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
36211defined this way.
36212
36213@item If debugging information is output when using the precompiled
36214header, using @option{-g} or similar, the same kind of debugging information
36215must have been output when building the precompiled header. However,
36216a precompiled header built using @option{-g} can be used in a compilation
36217when no debugging information is being output.
36218
36219@item The same @option{-m} options must generally be used when building
36220and using the precompiled header. @xref{Submodel Options},
36221for any cases where this rule is relaxed.
36222
36223@item Each of the following options must be the same when building and using
36224the precompiled header:
36225
36226@gccoptlist{-fexceptions}
36227
36228@item
36229Some other command-line options starting with @option{-f},
36230@option{-p}, or @option{-O} must be defined in the same way as when
36231the precompiled header was generated. At present, it's not clear
36232which options are safe to change and which are not; the safest choice
36233is to use exactly the same options when generating and using the
36234precompiled header. The following are known to be safe:
36235
43b72ede
AA
36236@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
36237-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
36238-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
36239-pedantic-errors}
36240
36241@item Address space layout randomization (ASLR) can lead to not binary identical
36242PCH files. If you rely on stable PCH file contents disable ASLR when generating
36243PCH files.
36244
36245@end itemize
36246
36247For all of these except the last, the compiler automatically
36248ignores the precompiled header if the conditions aren't met. If you
36249find an option combination that doesn't work and doesn't cause the
36250precompiled header to be ignored, please consider filing a bug report,
36251see @ref{Bugs}.
36252
36253If you do use differing options when generating and using the
36254precompiled header, the actual behavior is a mixture of the
36255behavior for the options. For instance, if you use @option{-g} to
36256generate the precompiled header but not when using it, you may or may
36257not get debugging information for routines in the precompiled header.
36258
36259@node C++ Modules
36260@section C++ Modules
36261@cindex speed of compilation
36262
36263Modules are a C++20 language feature. As the name suggests, they
36264provides a modular compilation system, intending to provide both
36265faster builds and better library isolation. The ``Merging Modules''
36266paper @uref{https://wg21.link/p1103}, provides the easiest to read set
36267of changes to the standard, although it does not capture later
36268changes.
36269
36270@emph{G++'s modules support is not complete.} Other than bugs, the
36271known missing pieces are:
36272
36273@table @emph
36274
36275@item Private Module Fragment
36276The Private Module Fragment is recognized, but an error is emitted.
36277
36278@item Partition definition visibility rules
36279Entities may be defined in implementation partitions, and those
36280definitions are not available outside of the module. This is not
36281implemented, and the definitions are available to extra-module use.
36282
36283@item Textual merging of reachable GM entities
36284Entities may be multiply defined across different header-units.
36285These must be de-duplicated, and this is implemented across imports,
36286or when an import redefines a textually-defined entity. However the
36287reverse is not implemented---textually redefining an entity that has
36288been defined in an imported header-unit. A redefinition error is
36289emitted.
36290
36291@item Translation-Unit local referencing rules
36292Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
36293(@uref{https://wg21.link/p2003}) add limitations on which entities an
36294exported region may reference (for instance, the entities an exported
36295template definition may reference). These are not fully implemented.
36296
36297@item Standard Library Header Units
36298The Standard Library is not provided as importable header units. If
36299you want to import such units, you must explicitly build them first.
36300If you do not do this with care, you may have multiple declarations,
36301which the module machinery must merge---compiler resource usage can be
36302affected by how you partition header files into header units.
36303
36304@end table
36305
36306Modular compilation is @emph{not} enabled with just the
36307@option{-std=c++20} option. You must explicitly enable it with the
36308@option{-fmodules-ts} option. It is independent of the language
36309version selected, although in pre-C++20 versions, it is of course an
36310extension.
36311
36312No new source file suffixes are required or supported. If you wish to
36313use a non-standard suffix (@pxref{Overall Options}), you also need
36314to provide a @option{-x c++} option too.@footnote{Some users like to
36315distinguish module interface files with a new suffix, such as naming
36316the source @code{module.cppm}, which involves
36317teaching all tools about the new suffix. A different scheme, such as
36318naming @code{module-m.cpp} would be less invasive.}
36319
36320Compiling a module interface unit produces an additional output (to
36321the assembly or object file), called a Compiled Module Interface
36322(CMI). This encodes the exported declarations of the module.
36323Importing a module reads in the CMI. The import graph is a Directed
36324Acyclic Graph (DAG). You must build imports before the importer.
36325
36326Header files may themselves be compiled to header units, which are a
36327transitional ability aiming at faster compilation. The
36328@option{-fmodule-header} option is used to enable this, and implies
36329the @option{-fmodules-ts} option. These CMIs are named by the fully
36330resolved underlying header file, and thus may be a complete pathname
36331containing subdirectories. If the header file is found at an absolute
36332pathname, the CMI location is still relative to a CMI root directory.
36333
36334As header files often have no suffix, you commonly have to specify a
36335@option{-x} option to tell the compiler the source is a header file.
36336You may use @option{-x c++-header}, @option{-x c++-user-header} or
36337@option{-x c++-system-header}. When used in conjunction with
36338@option{-fmodules-ts}, these all imply an appropriate
36339@option{-fmodule-header} option. The latter two variants use the
36340user or system include path to search for the file specified. This
36341allows you to, for instance, compile standard library header files as
36342header units, without needing to know exactly where they are
36343installed. Specifying the language as one of these variants also
36344inhibits output of the object file, as header files have no associated
36345object file.
36346
36347The @option{-fmodule-only} option disables generation of the
36348associated object file for compiling a module interface. Only the CMI
36349is generated. This option is implied when using the
36350@option{-fmodule-header} option.
36351
36352The @option{-flang-info-include-translate} and
36353@option{-flang-info-include-translate-not} options notes whether
36354include translation occurs or not. With no argument, the first will
36355note all include translation. The second will note all
36356non-translations of include files not known to intentionally be
36357textual. With an argument, queries about include translation of a
36358header files with that particular trailing pathname are noted. You
36359may repeat this form to cover several different header files. This
36360option may be helpful in determining whether include translation is
36361happening---if it is working correctly, it behaves as if it isn't
36362there at all.
36363
36364The @option{-flang-info-module-cmi} option can be used to determine
36365where the compiler is reading a CMI from. Without the option, the
36366compiler is silent when such a read is successful. This option has an
36367optional argument, which will restrict the notification to just the
36368set of named modules or header units specified.
36369
36370The @option{-Winvalid-imported-macros} option causes all imported macros
36371to be resolved at the end of compilation. Without this, imported
36372macros are only resolved when expanded or (re)defined. This option
36373detects conflicting import definitions for all macros.
36374
36375For details of the @option{-fmodule-mapper} family of options,
36376@pxref{C++ Module Mapper}.
36377
36378@menu
36379* C++ Module Mapper:: Module Mapper
36380* C++ Module Preprocessing:: Module Preprocessing
36381* C++ Compiled Module Interface:: Compiled Module Interface
36382@end menu
36383
36384@node C++ Module Mapper
36385@subsection Module Mapper
36386@cindex C++ Module Mapper
36387
36388A module mapper provides a server or file that the compiler queries to
36389determine the mapping between module names and CMI files. It is also
36390used to build CMIs on demand. @emph{Mapper functionality is in its
36391infancy and is intended for experimentation with build system
36392interactions.}
36393
36394You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
36395option or @env{CXX_MODULE_MAPPER} environment variable. The value may
36396have one of the following forms:
36397
36398@table @gcctabopt
36399
36400@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
36401An optional hostname and a numeric port number to connect to. If the
36402hostname is omitted, the loopback address is used. If the hostname
36403corresponds to multiple IPV6 addresses, these are tried in turn, until
36404one is successful. If your host lacks IPv6, this form is
36405non-functional. If you must use IPv4 use
36406@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
36407
36408@item =@var{socket}@r{[}?@var{ident}@r{]}
36409A local domain socket. If your host lacks local domain sockets, this
36410form is non-functional.
36411
36412@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
36413A program to spawn, and communicate with on its stdin/stdout streams.
36414Your @var{PATH} environment variable is searched for the program.
36415Arguments are separated by space characters, (it is not possible for
36416one of the arguments delivered to the program to contain a space). An
36417exception is if @var{program} begins with @@. In that case
36418@var{program} (sans @@) is looked for in the compiler's internal
36419binary directory. Thus the sample mapper-server can be specified
36420with @code{@@g++-mapper-server}.
36421
36422@item <>@r{[}?@var{ident}@r{]}
36423@item <>@var{inout}@r{[}?@var{ident}@r{]}
36424@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
36425Named pipes or file descriptors to communicate over. The first form,
36426@option{<>}, communicates over stdin and stdout. The other forms
36427allow you to specify a file descriptor or name a pipe. A numeric value
36428is interpreted as a file descriptor, otherwise named pipe is opened.
36429The second form specifies a bidirectional pipe and the last form
36430allows specifying two independent pipes. Using file descriptors
36431directly in this manner is fragile in general, as it can require the
36432cooperation of intermediate processes. In particular using stdin &
36433stdout is fraught with danger as other compiler options might also
36434cause the compiler to read stdin or write stdout, and it can have
36435unfortunate interactions with signal delivery from the terminal.
36436
36437@item @var{file}@r{[}?@var{ident}@r{]}
36438A mapping file consisting of space-separated module-name, filename
36439pairs, one per line. Only the mappings for the direct imports and any
36440module export name need be provided. If other mappings are provided,
36441they override those stored in any imported CMI files. A repository
36442root may be specified in the mapping file by using @samp{$root} as the
36443module name in the first active line. Use of this option will disable
36444any default module->CMI name mapping.
36445
36446@end table
36447
36448As shown, an optional @var{ident} may suffix the first word of the
36449option, indicated by a @samp{?} prefix. The value is used in the
36450initial handshake with the module server, or to specify a prefix on
36451mapping file lines. In the server case, the main source file name is
36452used if no @var{ident} is specified. In the file case, all non-blank
36453lines are significant, unless a value is specified, in which case only
36454lines beginning with @var{ident} are significant. The @var{ident}
36455must be separated by whitespace from the module name. Be aware that
36456@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
36457significant to the shell, and therefore may need quoting.
36458
36459The mapper is connected to or loaded lazily, when the first module
36460mapping is required. The networking protocols are only supported on
36461hosts that provide networking. If no mapper is specified a default is
36462provided.
36463
36464A project-specific mapper is expected to be provided by the build
36465system that invokes the compiler. It is not expected that a
36466general-purpose server is provided for all compilations. As such, the
36467server will know the build configuration, the compiler it invoked, and
36468the environment (such as working directory) in which that is
36469operating. As it may parallelize builds, several compilations may
36470connect to the same socket.
36471
36472The default mapper generates CMI files in a @samp{gcm.cache}
36473directory. CMI files have a @samp{.gcm} suffix. The module unit name
36474is used directly to provide the basename. Header units construct a
36475relative path using the underlying header file name. If the path is
36476already relative, a @samp{,} directory is prepended. Internal
36477@samp{..} components are translated to @samp{,,}. No attempt is made
36478to canonicalize these filenames beyond that done by the preprocessor's
36479include search algorithm, as in general it is ambiguous when symbolic
36480links are present.
36481
36482The mapper protocol was published as ``A Module Mapper''
36483@uref{https://wg21.link/p1184}. The implementation is provided by
36484@command{libcody}, @uref{https://github.com/urnathan/libcody},
36485which specifies the canonical protocol definition. A proof of concept
36486server implementation embedded in @command{make} was described in
36487''Make Me A Module'', @uref{https://wg21.link/p1602}.
36488
36489@node C++ Module Preprocessing
36490@subsection Module Preprocessing
36491@cindex C++ Module Preprocessing
36492
36493Modules affect preprocessing because of header units and include
36494translation. Some uses of the preprocessor as a separate step either
36495do not produce a correct output, or require CMIs to be available.
36496
36497Header units import macros. These macros can affect later conditional
36498inclusion, which therefore can cascade to differing import sets. When
36499preprocessing, it is necessary to load the CMI. If a header unit is
36500unavailable, the preprocessor issues a warning and continue (when
36501not just preprocessing, an error is emitted). Detecting such imports
36502requires preprocessor tokenization of the input stream to phase 4
36503(macro expansion).
36504
36505Include translation converts @code{#include}, @code{#include_next} and
36506@code{#import} directives to internal @code{import} declarations.
36507Whether a particular directive is translated is controlled by the
36508module mapper. Header unit names are canonicalized during
36509preprocessing.
36510
36511Dependency information can be emitted for macro import, extending the
36512functionality of @option{-MD} and @option{-MMD} options. Detection of
36513import declarations also requires phase 4 preprocessing, and thus
36514requires full preprocessing (or compilation).
36515
36516The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
36517preprocessing before phase 4.
36518
36519The @option{-save-temps} option uses @option{-fdirectives-only} for
36520preprocessing, and preserve the macro definitions in the preprocessed
36521output. Usually you also want to use this option when explicitly
36522preprocessing a header-unit, or consuming such preprocessed output:
36523
36524@smallexample
36525g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
36526g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
36527@end smallexample
36528
36529@node C++ Compiled Module Interface
36530@subsection Compiled Module Interface
36531@cindex C++ Compiled Module Interface
36532
36533CMIs are an additional artifact when compiling named module
36534interfaces, partitions or header units. These are read when
36535importing. CMI contents are implementation-specific, and in GCC's
36536case tied to the compiler version. Consider them a rebuildable cache
36537artifact, not a distributable object.
36538
36539When creating an output CMI, any missing directory components are
36540created in a manner that is safe for concurrent builds creating
36541multiple, different, CMIs within a common subdirectory tree.
36542
36543CMI contents are written to a temporary file, which is then atomically
36544renamed. Observers either see old contents (if there is an
36545existing file), or complete new contents. They do not observe the
36546CMI during its creation. This is unlike object file writing, which
36547may be observed by an external process.
36548
36549CMIs are read in lazily, if the host OS provides @code{mmap}
36550functionality. Generally blocks are read when name lookup or template
36551instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
36552option may be used.
36553
36554The @option{--param lazy-modules=@var{n}} parameter controls the limit
36555on the number of concurrently open module files during lazy loading.
36556Should more modules be imported, an LRU algorithm is used to determine
36557which files to close---until that file is needed again. This limit
36558may be exceeded with deep module dependency hierarchies. With large
36559code bases there may be more imports than the process limit of file
36560descriptors. By default, the limit is a few less than the per-process
36561file descriptor hard limit, if that is determinable.@footnote{Where
36562applicable the soft limit is incremented as needed towards the hard limit.}
36563
36564GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
36565You may use @command{readelf} to inspect them, although section
36566contents are largely undecipherable. There is a section named
36567@code{.gnu.c++.README}, which contains human-readable text. Other
36568than the first line, each line consists of @code{@var{tag}: @code{value}}
36569tuples.
36570
36571@smallexample
36572> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
36573
36574String dump of section '.gnu.c++.README':
36575 [ 0] GNU C++ primary module interface
36576 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
36577 [ 6f] version: 2020/11/16-04:54
36578 [ 89] module: foo
36579 [ 95] source: c_b.ii
36580 [ a4] dialect: C++20/coroutines
36581 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
36582 [ ee] repository: gcm.cache
36583 [ 104] buildtime: 2020/11/16 15:03:21 UTC
36584 [ 127] localtime: 2020/11/16 07:03:21 PST
36585 [ 14a] export: foo:part1 foo-part1.gcm
36586@end smallexample
36587
36588Amongst other things, this lists the source that was built, C++
36589dialect used and imports of the module.@footnote{The precise contents
36590of this output may change.} The timestamp is the same value as that
36591provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
36592explicitly specified with the environment variable
36593@code{SOURCE_DATE_EPOCH}. For further details
36594@pxref{Environment Variables}.
36595
36596A set of related CMIs may be copied, provided the relative pathnames
36597are preserved.
36598
36599The @code{.gnu.c++.README} contents do not affect CMI integrity, and
36600it may be removed or altered. The section numbering of the sections
36601whose names do not begin with @code{.gnu.c++.}, or are not the string
36602section is significant and must not be altered.