]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
gcc.dg/Wmissing-parameter-type*: Test the intended warning
[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
451-fdump-analyzer-json
452-fdump-analyzer-state-purge
453-fdump-analyzer-stderr
454-fdump-analyzer-supergraph
455-fdump-analyzer-untracked
456-Wno-analyzer-double-fclose
457-Wno-analyzer-double-free
458-Wno-analyzer-exposure-through-output-file
459-Wno-analyzer-exposure-through-uninit-copy
460-Wno-analyzer-fd-access-mode-mismatch
461-Wno-analyzer-fd-double-close
462-Wno-analyzer-fd-leak
463-Wno-analyzer-fd-phase-mismatch
464-Wno-analyzer-fd-type-mismatch
465-Wno-analyzer-fd-use-after-close
466-Wno-analyzer-fd-use-without-check
467-Wno-analyzer-file-leak
468-Wno-analyzer-free-of-non-heap
469-Wno-analyzer-imprecise-fp-arithmetic
470-Wno-analyzer-infinite-recursion
471-Wno-analyzer-jump-through-null
472-Wno-analyzer-malloc-leak
473-Wno-analyzer-mismatching-deallocation
474-Wno-analyzer-null-argument
475-Wno-analyzer-null-dereference
476-Wno-analyzer-out-of-bounds
034d99e8 477-Wno-analyzer-overlapping-buffers
43b72ede
AA
478-Wno-analyzer-possible-null-argument
479-Wno-analyzer-possible-null-dereference
480-Wno-analyzer-putenv-of-auto-var
481-Wno-analyzer-shift-count-negative
482-Wno-analyzer-shift-count-overflow
483-Wno-analyzer-stale-setjmp-buffer
484-Wno-analyzer-tainted-allocation-size
485-Wno-analyzer-tainted-assertion
486-Wno-analyzer-tainted-array-index
487-Wno-analyzer-tainted-divisor
488-Wno-analyzer-tainted-offset
489-Wno-analyzer-tainted-size
490-Wanalyzer-too-complex
491-Wno-analyzer-unsafe-call-within-signal-handler
492-Wno-analyzer-use-after-free
493-Wno-analyzer-use-of-pointer-in-stale-stack-frame
494-Wno-analyzer-use-of-uninitialized-value
495-Wno-analyzer-va-arg-type-mismatch
496-Wno-analyzer-va-list-exhausted
497-Wno-analyzer-va-list-leak
498-Wno-analyzer-va-list-use-after-va-end
499-Wno-analyzer-write-to-const
500-Wno-analyzer-write-to-string-literal
d77de738
ML
501}
502
503@item C and Objective-C-only Warning Options
43b72ede 504@gccoptlist{-Wbad-function-cast -Wmissing-declarations
ffc74822
HM
505-Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations
506-Wnested-externs -Wold-style-declaration -Wold-style-definition
43b72ede 507-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
d77de738
ML
508-Wdeclaration-after-statement -Wpointer-sign}
509
510@item Debugging Options
511@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
512@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
513-gbtf -gctf -gctf@var{level}
514-ggdb -grecord-gcc-switches -gno-record-gcc-switches
515-gstrict-dwarf -gno-strict-dwarf
516-gas-loc-support -gno-as-loc-support
517-gas-locview-support -gno-as-locview-support
3eeb4801 518-gcodeview
43b72ede
AA
519-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
520-gstatement-frontiers -gno-statement-frontiers
521-gvariable-location-views -gno-variable-location-views
522-ginternal-reset-location-views -gno-internal-reset-location-views
523-ginline-points -gno-inline-points
524-gvms -gz@r{[}=@var{type}@r{]}
525-gsplit-dwarf -gdescribe-dies -gno-describe-dies
526-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
527-fno-eliminate-unused-debug-types
528-femit-struct-debug-baseonly -femit-struct-debug-reduced
529-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
530-fno-eliminate-unused-debug-symbols -femit-class-debug-always
531-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
532-fvar-tracking -fvar-tracking-assignments}
533
534@item Optimization Options
535@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
536@gccoptlist{-faggressive-loop-optimizations
537-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
538-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
539-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
540-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
541-fno-allocation-dce -fallow-store-data-races
542-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
543-fauto-inc-dec -fbranch-probabilities
544-fcaller-saves
545-fcombine-stack-adjustments -fconserve-stack
04c9cf5c 546-ffold-mem-offsets
43b72ede
AA
547-fcompare-elim -fcprop-registers -fcrossjumping
548-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
549-fcx-limited-range
550-fdata-sections -fdce -fdelayed-branch
551-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
552-fdevirtualize-at-ltrans -fdse
553-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
554-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
555-ffinite-loops
556-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
557-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
558-fgcse-sm -fhoist-adjacent-loads -fif-conversion
559-fif-conversion2 -findirect-inlining
560-finline-functions -finline-functions-called-once -finline-limit=@var{n}
561-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
562-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
563-fipa-reference -fipa-reference-addressable
564-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
565-flive-patching=@var{level}
566-fira-region=@var{region} -fira-hoist-pressure
567-fira-loop-pressure -fno-ira-share-save-slots
568-fno-ira-share-spill-slots
569-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
570-fivopts -fkeep-inline-functions -fkeep-static-functions
571-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
572-floop-block -floop-interchange -floop-strip-mine
573-floop-unroll-and-jam -floop-nest-optimize
574-floop-parallelize-all -flra-remat -flto -flto-compression-level
575-flto-partition=@var{alg} -fmerge-all-constants
576-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
577-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
578-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
579-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
580-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
581-fno-sched-spec -fno-signed-zeros
582-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
583-fomit-frame-pointer -foptimize-sibling-calls
584-fpartial-inlining -fpeel-loops -fpredictive-commoning
585-fprefetch-loop-arrays
586-fprofile-correction
587-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
588-fprofile-values -fprofile-reorder-functions
589-freciprocal-math -free -frename-registers -freorder-blocks
590-freorder-blocks-algorithm=@var{algorithm}
591-freorder-blocks-and-partition -freorder-functions
592-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
593-frounding-math -fsave-optimization-record
594-fsched2-use-superblocks -fsched-pressure
595-fsched-spec-load -fsched-spec-load-dangerous
596-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
597-fsched-group-heuristic -fsched-critical-path-heuristic
598-fsched-spec-insn-heuristic -fsched-rank-heuristic
599-fsched-last-insn-heuristic -fsched-dep-count-heuristic
600-fschedule-fusion
601-fschedule-insns -fschedule-insns2 -fsection-anchors
602-fselective-scheduling -fselective-scheduling2
603-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
604-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
605-fsignaling-nans
606-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
607-fsplit-paths
608-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
609-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
610-fthread-jumps -ftracer -ftree-bit-ccp
611-ftree-builtin-call-dce -ftree-ccp -ftree-ch
612-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
613-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
614-ftree-loop-if-convert -ftree-loop-im
615-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
616-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
617-ftree-loop-vectorize
618-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
619-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
620-ftree-switch-conversion -ftree-tail-merge
621-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
622-funconstrained-commons -funit-at-a-time -funroll-all-loops
623-funroll-loops -funsafe-math-optimizations -funswitch-loops
624-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
625-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
626--param @var{name}=@var{value}
627-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
628
629@item Program Instrumentation Options
630@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede
AA
631@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
632-fprofile-abs-path
633-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
634-fprofile-info-section -fprofile-info-section=@var{name}
635-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
636-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
637-fprofile-exclude-files=@var{regex}
638-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
639-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
640-fsanitize-trap -fsanitize-trap=@var{style}
641-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
642-fsanitize-undefined-trap-on-error -fbounds-check
643-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
644-fharden-compares -fharden-conditional-branches
551935d1
AO
645-fharden-control-flow-redundancy -fhardcfr-skip-leaf
646-fhardcfr-check-exceptions -fhardcfr-check-returning-calls
647-fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
43b72ede
AA
648-fstack-protector -fstack-protector-all -fstack-protector-strong
649-fstack-protector-explicit -fstack-check
650-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
651-fno-stack-limit -fsplit-stack
652-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
653-fvtv-counts -fvtv-debug
654-finstrument-functions -finstrument-functions-once
655-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
656-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
657-fprofile-prefix-map=@var{old}=@var{new}}
d77de738
ML
658
659@item Preprocessor Options
660@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
661@gccoptlist{-A@var{question}=@var{answer}
662-A-@var{question}@r{[}=@var{answer}@r{]}
663-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
664-dD -dI -dM -dN -dU
665-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
666-fexec-charset=@var{charset} -fextended-identifiers
667-finput-charset=@var{charset} -flarge-source-files
668-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
669-fno-canonical-system-headers -fpch-deps -fpch-preprocess
670-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
671-fwide-exec-charset=@var{charset} -fworking-directory
672-H -imacros @var{file} -include @var{file}
673-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
674-no-integrated-cpp -P -pthread -remap
675-traditional -traditional-cpp -trigraphs
676-U@var{macro} -undef
d77de738
ML
677-Wp,@var{option} -Xpreprocessor @var{option}}
678
679@item Assembler Options
680@xref{Assembler Options,,Passing Options to the Assembler}.
681@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
682
683@item Linker Options
684@xref{Link Options,,Options for Linking}.
43b72ede
AA
685@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
686-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
687-e @var{entry} --entry=@var{entry}
688-pie -pthread -r -rdynamic
689-s -static -static-pie -static-libgcc -static-libstdc++
690-static-libasan -static-libtsan -static-liblsan -static-libubsan
691-shared -shared-libgcc -symbolic
692-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
693-u @var{symbol} -z @var{keyword}}
694
695@item Directory Options
696@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
697@gccoptlist{-B@var{prefix} -I@var{dir} -I-
698-idirafter @var{dir}
699-imacros @var{file} -imultilib @var{dir}
700-iplugindir=@var{dir} -iprefix @var{file}
701-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
702-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
703-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
704-nostdinc -nostdinc++ --sysroot=@var{dir}}
705
706@item Code Generation Options
707@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
708@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
709-ffixed-@var{reg} -fexceptions
710-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
711-fasynchronous-unwind-tables
712-fno-gnu-unique
713-finhibit-size-directive -fcommon -fno-ident
714-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
715-fno-jump-tables -fno-bit-tests
716-frecord-gcc-switches
717-freg-struct-return -fshort-enums -fshort-wchar
718-fverbose-asm -fpack-struct[=@var{n}]
719-fleading-underscore -ftls-model=@var{model}
720-fstack-reuse=@var{reuse_level}
28d8c680
AB
721-ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
722-ftrapv -fwrapv
43b72ede 723-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
724-fstrict-volatile-bitfields -fsync-libcalls}
725
726@item Developer Options
727@xref{Developer Options,,GCC Developer Options}.
43b72ede 728@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 729-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
730-fchecking -fchecking=@var{n}
731-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
732-fdisable-ipa-@var{pass_name}
733-fdisable-rtl-@var{pass_name}
734-fdisable-rtl-@var{pass-name}=@var{range-list}
735-fdisable-tree-@var{pass_name}
736-fdisable-tree-@var{pass-name}=@var{range-list}
737-fdump-debug -fdump-earlydebug
738-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
739-fdump-final-insns@r{[}=@var{file}@r{]}
740-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
741-fdump-lang-all
742-fdump-lang-@var{switch}
743-fdump-lang-@var{switch}-@var{options}
744-fdump-lang-@var{switch}-@var{options}=@var{filename}
745-fdump-passes
746-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
747-fdump-statistics
748-fdump-tree-all
749-fdump-tree-@var{switch}
750-fdump-tree-@var{switch}-@var{options}
751-fdump-tree-@var{switch}-@var{options}=@var{filename}
752-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
753-fenable-@var{kind}-@var{pass}
754-fenable-@var{kind}-@var{pass}=@var{range-list}
755-fira-verbose=@var{n}
756-flto-report -flto-report-wpa -fmem-report-wpa
757-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
758-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
759-fmultiflags -fprofile-report
760-frandom-seed=@var{string} -fsched-verbose=@var{n}
761-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
762-fstats -fstack-usage -ftime-report -ftime-report-details
763-fvar-tracking-assignments-toggle -gtoggle
764-print-file-name=@var{library} -print-libgcc-file-name
765-print-multi-directory -print-multi-lib -print-multi-os-directory
766-print-prog-name=@var{program} -print-search-dirs -Q
767-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
768-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
769
770@item Machine-Dependent Options
771@xref{Submodel Options,,Machine-Dependent Options}.
772@c This list is ordered alphanumerically by subsection name.
773@c Try and put the significant identifier (CPU or system) first,
774@c so users have a clue at guessing where the ones they want will be.
775
776@emph{AArch64 Options}
43b72ede
AA
777@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
778-mgeneral-regs-only
779-mcmodel=tiny -mcmodel=small -mcmodel=large
780-mstrict-align -mno-strict-align
781-momit-leaf-frame-pointer
782-mtls-dialect=desc -mtls-dialect=traditional
783-mtls-size=@var{size}
784-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
785-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
786-mpc-relative-literal-loads
787-msign-return-address=@var{scope}
d77de738 788-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
43b72ede
AA
789+@var{b-key}]|@var{bti}
790-mharden-sls=@var{opts}
791-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
792-moverride=@var{string} -mverbose-cost-dump
793-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
794-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
d77de738
ML
795-moutline-atomics }
796
797@emph{Adapteva Epiphany Options}
43b72ede
AA
798@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
799-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
800-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
801-mround-nearest -mlong-calls -mshort-calls -msmall16
802-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
803-msplit-vecmove-early -m1reg-@var{reg}}
804
805@emph{AMD GCN Options}
806@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
807
808@emph{ARC Options}
43b72ede
AA
809@gccoptlist{-mbarrel-shifter -mjli-always
810-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
811-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
812-mea -mno-mpy -mmul32x16 -mmul64 -matomic
813-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
814-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
815-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
816-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
817-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
818-mvolatile-cache -mtp-regno=@var{regno}
819-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
820-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
821-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
822-mlra-priority-compact -mlra-priority-noncompact -mmillicode
823-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
824-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
825-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
826-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
827
828@emph{ARM Options}
43b72ede
AA
829@gccoptlist{-mapcs-frame -mno-apcs-frame
830-mabi=@var{name}
831-mapcs-stack-check -mno-apcs-stack-check
832-mapcs-reentrant -mno-apcs-reentrant
833-mgeneral-regs-only
834-msched-prolog -mno-sched-prolog
835-mlittle-endian -mbig-endian
836-mbe8 -mbe32
837-mfloat-abi=@var{name}
d77de738 838-mfp16-format=@var{name}
43b72ede
AA
839-mthumb-interwork -mno-thumb-interwork
840-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
841-mtune=@var{name} -mprint-tune-info
842-mstructure-size-boundary=@var{n}
843-mabort-on-noreturn
844-mlong-calls -mno-long-calls
845-msingle-pic-base -mno-single-pic-base
846-mpic-register=@var{reg}
847-mnop-fun-dllimport
848-mpoke-function-name
849-mthumb -marm -mflip-thumb
850-mtpcs-frame -mtpcs-leaf-frame
851-mcaller-super-interworking -mcallee-super-interworking
852-mtp=@var{name} -mtls-dialect=@var{dialect}
853-mword-relocations
854-mfix-cortex-m3-ldrd
855-mfix-cortex-a57-aes-1742098
856-mfix-cortex-a72-aes-1655431
857-munaligned-access
858-mneon-for-64bits
859-mslow-flash-data
860-masm-syntax-unified
861-mrestrict-it
862-mverbose-cost-dump
863-mpure-code
864-mcmse
865-mfix-cmse-cve-2021-35465
866-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
867-mfdpic
14fab5fb
AC
868-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
869[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
870
871@emph{AVR Options}
43b72ede
AA
872@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
873-mbranch-cost=@var{cost}
874-mcall-prologues -mgas-isr-prologues -mint8
875-mdouble=@var{bits} -mlong-double=@var{bits}
876-mn_flash=@var{size} -mno-interrupts
877-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
878-mfract-convert-truncate
879-mshort-calls -nodevicelib -nodevicespecs
d77de738
ML
880-Waddr-space-convert -Wmisspelled-isr}
881
882@emph{Blackfin Options}
43b72ede
AA
883@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
884-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
885-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
886-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
887-mno-id-shared-library -mshared-library-id=@var{n}
888-mleaf-id-shared-library -mno-leaf-id-shared-library
889-msep-data -mno-sep-data -mlong-calls -mno-long-calls
890-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
891-micplb}
892
893@emph{C6X Options}
43b72ede 894@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
895-msim -msdata=@var{sdata-type}}
896
897@emph{CRIS Options}
898@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
899-mtune=@var{cpu} -mmax-stack-frame=@var{n}
900-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
901-mstack-align -mdata-align -mconst-align
902-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
903-melf -maout -sim -sim2
d77de738
ML
904-mmul-bug-workaround -mno-mul-bug-workaround}
905
906@emph{C-SKY Options}
43b72ede
AA
907@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
908-mbig-endian -EB -mlittle-endian -EL
909-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
910-mfloat-abi=@var{name}
911-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
912-mdsp -medsp -mvdsp
913-mdiv -msmart -mhigh-registers -manchor
914-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
915-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
916
917@emph{Darwin Options}
43b72ede
AA
918@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
919-arch_only -bind_at_load -bundle -bundle_loader
920-client_name -compatibility_version -current_version
921-dead_strip
922-dependency-file -dylib_file -dylinker_install_name
923-dynamic -dynamiclib -exported_symbols_list
924-filelist -flat_namespace -force_cpusubtype_ALL
925-force_flat_namespace -headerpad_max_install_names
926-iframework
927-image_base -init -install_name -keep_private_externs
928-multi_module -multiply_defined -multiply_defined_unused
47b634a3 929-noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
43b72ede
AA
930-nofixprebinding -nomultidefs -noprebind -noseglinkedit
931-pagezero_size -prebind -prebind_all_twolevel_modules
932-private_bundle -read_only_relocs -sectalign
933-sectobjectsymbols -whyload -seg1addr
934-sectcreate -sectobjectsymbols -sectorder
935-segaddr -segs_read_only_addr -segs_read_write_addr
936-seg_addr_table -seg_addr_table_filename -seglinkedit
937-segprot -segs_read_only_addr -segs_read_write_addr
938-single_module -static -sub_library -sub_umbrella
939-twolevel_namespace -umbrella -undefined
940-unexported_symbols_list -weak_reference_mismatches
941-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
942-mkernel -mone-byte-bool}
943
944@emph{DEC Alpha Options}
43b72ede
AA
945@gccoptlist{-mno-fp-regs -msoft-float
946-mieee -mieee-with-inexact -mieee-conformant
947-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
948-mtrap-precision=@var{mode} -mbuild-constants
949-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
950-mbwx -mmax -mfix -mcix
951-mfloat-vax -mfloat-ieee
952-mexplicit-relocs -msmall-data -mlarge-data
953-msmall-text -mlarge-text
d77de738
ML
954-mmemory-latency=@var{time}}
955
956@emph{eBPF Options}
9cbf4286 957@gccoptlist{-mbig-endian -mlittle-endian
77d0f9ec 958-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
14dab1a1 959-mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
9cbf4286 960-masm=@var{dialect}}
d77de738
ML
961
962@emph{FR30 Options}
963@gccoptlist{-msmall-model -mno-lsim}
964
965@emph{FT32 Options}
966@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
967
968@emph{FRV Options}
43b72ede
AA
969@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
970-mhard-float -msoft-float
971-malloc-cc -mfixed-cc -mdword -mno-dword
972-mdouble -mno-double
973-mmedia -mno-media -mmuladd -mno-muladd
974-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
975-mlinked-fp -mlong-calls -malign-labels
976-mlibrary-pic -macc-4 -macc-8
977-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
978-moptimize-membar -mno-optimize-membar
979-mscc -mno-scc -mcond-exec -mno-cond-exec
980-mvliw-branch -mno-vliw-branch
981-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
982-mno-nested-cond-exec -mtomcat-stats
983-mTLS -mtls
d77de738
ML
984-mcpu=@var{cpu}}
985
986@emph{GNU/Linux Options}
43b72ede 987@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
988-tno-android-cc -tno-android-ld}
989
990@emph{H8/300 Options}
991@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
992
993@emph{HPPA Options}
43b72ede
AA
994@gccoptlist{-march=@var{architecture-type}
995-matomic-libcalls -mbig-switch
996-mcaller-copies -mdisable-fpregs -mdisable-indexing
997-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
998-mfixed-range=@var{register-range}
999-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1000-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1001-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1002-mno-jump-in-delay -mno-long-load-store
1003-mno-portable-runtime -mno-soft-float
1004-mno-space-regs -msoft-float -mpa-risc-1-0
1005-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1006-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
1007-munix=@var{unix-std} -nolibdld -static -threads}
1008
1009@emph{IA-64 Options}
43b72ede
AA
1010@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1011-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1012-mconstant-gp -mauto-pic -mfused-madd
1013-minline-float-divide-min-latency
1014-minline-float-divide-max-throughput
1015-mno-inline-float-divide
1016-minline-int-divide-min-latency
1017-minline-int-divide-max-throughput
1018-mno-inline-int-divide
1019-minline-sqrt-min-latency -minline-sqrt-max-throughput
1020-mno-inline-sqrt
1021-mdwarf2-asm -mearly-stop-bits
1022-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1023-mtune=@var{cpu-type} -milp32 -mlp64
1024-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1025-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1026-msched-spec-ldc -msched-spec-control-ldc
1027-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1028-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1029-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1030-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1031
1032@emph{LM32 Options}
43b72ede 1033@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1034-msign-extend-enabled -muser-enabled}
1035
1036@emph{LoongArch Options}
43b72ede 1037@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
bb4a8198
YY
1038-mfpu=@var{fpu-type} -msimd=@var{simd-type}
1039-msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
43b72ede
AA
1040-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1041-mcond-move-int -mno-cond-move-int
1042-mcond-move-float -mno-cond-move-float
1043-memcpy -mno-memcpy -mstrict-align -mno-strict-align
1044-mmax-inline-memcpy-size=@var{n}
e1b1cba1 1045-mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
43b72ede 1046-mdirect-extern-access -mno-direct-extern-access
d77de738
ML
1047-mcmodel=@var{code-model}}
1048
1049@emph{M32R/D Options}
43b72ede
AA
1050@gccoptlist{-m32r2 -m32rx -m32r
1051-mdebug
1052-malign-loops -mno-align-loops
1053-missue-rate=@var{number}
1054-mbranch-cost=@var{number}
1055-mmodel=@var{code-size-model-type}
1056-msdata=@var{sdata-type}
1057-mno-flush-func -mflush-func=@var{name}
1058-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1059-G @var{num}}
1060
1061@emph{M32C Options}
1062@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1063
1064@emph{M680x0 Options}
43b72ede
AA
1065@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1066-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1067-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1068-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1069-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1070-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1071-malign-int -mstrict-align -msep-data -mno-sep-data
1072-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1073-mxgot -mno-xgot -mlong-jump-table-offsets}
1074
1075@emph{MCore Options}
43b72ede
AA
1076@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1077-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1078-m4byte-functions -mno-4byte-functions -mcallgraph-data
1079-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1080-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1081
d77de738 1082@emph{MicroBlaze Options}
43b72ede
AA
1083@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1084-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1085-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1086-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1087-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1088-mpic-data-is-text-relative}
1089
1090@emph{MIPS Options}
43b72ede
AA
1091@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1092-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1093-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1094-mips16 -mno-mips16 -mflip-mips16
1095-minterlink-compressed -mno-interlink-compressed
1096-minterlink-mips16 -mno-interlink-mips16
1097-mabi=@var{abi} -mabicalls -mno-abicalls
1098-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1099-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1100-mno-float -msingle-float -mdouble-float
1101-modd-spreg -mno-odd-spreg
1102-mabs=@var{mode} -mnan=@var{encoding}
1103-mdsp -mno-dsp -mdspr2 -mno-dspr2
1104-mmcu -mmno-mcu
1105-meva -mno-eva
1106-mvirt -mno-virt
1107-mxpa -mno-xpa
1108-mcrc -mno-crc
1109-mginv -mno-ginv
1110-mmicromips -mno-micromips
1111-mmsa -mno-msa
1112-mloongson-mmi -mno-loongson-mmi
1113-mloongson-ext -mno-loongson-ext
1114-mloongson-ext2 -mno-loongson-ext2
1115-mfpu=@var{fpu-type}
1116-msmartmips -mno-smartmips
1117-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1118-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1119-mlong64 -mlong32 -msym32 -mno-sym32
1120-G@var{num} -mlocal-sdata -mno-local-sdata
1121-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1122-membedded-data -mno-embedded-data
1123-muninit-const-in-rodata -mno-uninit-const-in-rodata
1124-mcode-readable=@var{setting}
1125-msplit-addresses -mno-split-addresses
1126-mexplicit-relocs -mno-explicit-relocs
1127-mcheck-zero-division -mno-check-zero-division
1128-mdivide-traps -mdivide-breaks
1129-mload-store-pairs -mno-load-store-pairs
1130-munaligned-access -mno-unaligned-access
1131-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1132-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1133-mfix-24k -mno-fix-24k
1134-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1135-mfix-r5900 -mno-fix-r5900
1136-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1137-mfix-vr4120 -mno-fix-vr4120
1138-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1139-mflush-func=@var{func} -mno-flush-func
1140-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1141-mcompact-branches=@var{policy}
1142-mfp-exceptions -mno-fp-exceptions
1143-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1144-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1145-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1146-mframe-header-opt -mno-frame-header-opt}
1147
1148@emph{MMIX Options}
43b72ede
AA
1149@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1150-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1151-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1152-mno-base-addresses -msingle-exit -mno-single-exit}
1153
1154@emph{MN10300 Options}
43b72ede
AA
1155@gccoptlist{-mmult-bug -mno-mult-bug
1156-mno-am33 -mam33 -mam33-2 -mam34
1157-mtune=@var{cpu-type}
1158-mreturn-pointer-on-d0
d77de738
ML
1159-mno-crt0 -mrelax -mliw -msetlb}
1160
1161@emph{Moxie Options}
1162@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1163
1164@emph{MSP430 Options}
43b72ede
AA
1165@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1166-mwarn-mcu
1167-mcode-region= -mdata-region=
1168-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1169-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1170
1171@emph{NDS32 Options}
43b72ede
AA
1172@gccoptlist{-mbig-endian -mlittle-endian
1173-mreduced-regs -mfull-regs
1174-mcmov -mno-cmov
1175-mext-perf -mno-ext-perf
1176-mext-perf2 -mno-ext-perf2
1177-mext-string -mno-ext-string
1178-mv3push -mno-v3push
1179-m16bit -mno-16bit
1180-misr-vector-size=@var{num}
1181-mcache-block-size=@var{num}
1182-march=@var{arch}
1183-mcmodel=@var{code-model}
d77de738
ML
1184-mctor-dtor -mrelax}
1185
1186@emph{Nios II Options}
43b72ede
AA
1187@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1188-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1189-mel -meb
1190-mno-bypass-cache -mbypass-cache
1191-mno-cache-volatile -mcache-volatile
1192-mno-fast-sw-div -mfast-sw-div
1193-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1194-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1195-mcustom-fpu-cfg=@var{name}
1196-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
d77de738
ML
1197-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1198
1199@emph{Nvidia PTX Options}
1200@gccoptlist{-m64 -mmainkernel -moptimize}
1201
1202@emph{OpenRISC Options}
43b72ede
AA
1203@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1204-msoft-mul -msoft-div
1205-msoft-float -mhard-float -mdouble-float -munordered-float
1206-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1207-mcmodel=@var{code-model}}
1208
1209@emph{PDP-11 Options}
43b72ede
AA
1210@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1211-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1212-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1213
d77de738
ML
1214@emph{PowerPC Options}
1215See RS/6000 and PowerPC Options.
1216
1217@emph{PRU Options}
43b72ede 1218@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1219-mabi=@var{variant}}
d77de738
ML
1220
1221@emph{RISC-V Options}
43b72ede
AA
1222@gccoptlist{-mbranch-cost=@var{N-instruction}
1223-mplt -mno-plt
1224-mabi=@var{ABI-string}
1225-mfdiv -mno-fdiv
1226-mdiv -mno-div
1227-misa-spec=@var{ISA-spec-string}
1228-march=@var{ISA-string}
1229-mtune=@var{processor-string}
1230-mpreferred-stack-boundary=@var{num}
1231-msmall-data-limit=@var{N-bytes}
1232-msave-restore -mno-save-restore
1233-mshorten-memrefs -mno-shorten-memrefs
1234-mstrict-align -mno-strict-align
1235-mcmodel=medlow -mcmodel=medany
1236-mexplicit-relocs -mno-explicit-relocs
1237-mrelax -mno-relax
1238-mriscv-attribute -mno-riscv-attribute
1239-malign-data=@var{type}
1240-mbig-endian -mlittle-endian
1241-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1242-mstack-protector-guard-offset=@var{offset}
f797260a 1243-mcsr-check -mno-csr-check
df48285b 1244-minline-atomics -mno-inline-atomics
949f1ccf
CM
1245-minline-strlen -mno-inline-strlen
1246-minline-strcmp -mno-inline-strcmp
1247-minline-strncmp -mno-inline-strncmp}
d77de738
ML
1248
1249@emph{RL78 Options}
43b72ede
AA
1250@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1251-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1252-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1253
1254@emph{RS/6000 and PowerPC Options}
43b72ede
AA
1255@gccoptlist{-mcpu=@var{cpu-type}
1256-mtune=@var{cpu-type}
1257-mcmodel=@var{code-model}
1258-mpowerpc64
1259-maltivec -mno-altivec
1260-mpowerpc-gpopt -mno-powerpc-gpopt
1261-mpowerpc-gfxopt -mno-powerpc-gfxopt
1262-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1263-mfprnd -mno-fprnd
1264-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1265-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1266-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1267-malign-power -malign-natural
1268-msoft-float -mhard-float -mmultiple -mno-multiple
1269-mupdate -mno-update
1270-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1271-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1272-mstrict-align -mno-strict-align -mrelocatable
1273-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1274-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1275-mdynamic-no-pic -mswdiv -msingle-pic-base
1276-mprioritize-restricted-insns=@var{priority}
1277-msched-costly-dep=@var{dependence_type}
1278-minsert-sched-nops=@var{scheme}
1279-mcall-aixdesc -mcall-eabi -mcall-freebsd
1280-mcall-linux -mcall-netbsd -mcall-openbsd
1281-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1282-mtraceback=@var{traceback_type}
1283-maix-struct-return -msvr4-struct-return
1284-mabi=@var{abi-type} -msecure-plt -mbss-plt
1285-mlongcall -mno-longcall -mpltseq -mno-pltseq
1286-mblock-move-inline-limit=@var{num}
1287-mblock-compare-inline-limit=@var{num}
1288-mblock-compare-inline-loop-limit=@var{num}
1289-mno-block-ops-unaligned-vsx
1290-mstring-compare-inline-limit=@var{num}
1291-misel -mno-isel
1292-mvrsave -mno-vrsave
1293-mmulhw -mno-mulhw
1294-mdlmzb -mno-dlmzb
1295-mprototype -mno-prototype
1296-msim -mmvme -mads -myellowknife -memb -msdata
1297-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1298-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1299-mno-recip-precision
1300-mveclibabi=@var{type} -mfriz -mno-friz
1301-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1302-msave-toc-indirect -mno-save-toc-indirect
1303-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector
1304-mcrypto -mno-crypto -mhtm -mno-htm
1305-mquad-memory -mno-quad-memory
1306-mquad-memory-atomic -mno-quad-memory-atomic
1307-mcompat-align-parm -mno-compat-align-parm
1308-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1309-mgnu-attribute -mno-gnu-attribute
1310-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1311-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1312-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1313-mprivileged -mno-privileged}
1314
1315@emph{RX Options}
43b72ede
AA
1316@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1317-mcpu=
1318-mbig-endian-data -mlittle-endian-data
1319-msmall-data
1320-msim -mno-sim
1321-mas100-syntax -mno-as100-syntax
1322-mrelax
1323-mmax-constant-size=
1324-mint-register=
1325-mpid
1326-mallow-string-insns -mno-allow-string-insns
1327-mjsr
1328-mno-warn-multiple-fast-interrupts
d77de738
ML
1329-msave-acc-in-interrupts}
1330
1331@emph{S/390 and zSeries Options}
43b72ede
AA
1332@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1333-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1334-mlong-double-64 -mlong-double-128
1335-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1336-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1337-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1338-mhtm -mvx -mzvector
1339-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1340-mfused-madd -mno-fused-madd
1341-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1342-mhotpatch=@var{halfwords},@var{halfwords}}
1343
d77de738 1344@emph{SH Options}
43b72ede
AA
1345@gccoptlist{-m1 -m2 -m2e
1346-m2a-nofpu -m2a-single-only -m2a-single -m2a
1347-m3 -m3e
1348-m4-nofpu -m4-single-only -m4-single -m4
1349-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1350-mb -ml -mdalign -mrelax
1351-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1352-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1353-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1354-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1355-maccumulate-outgoing-args
1356-matomic-model=@var{atomic-model}
1357-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1358-mcbranch-force-delay-slot
1359-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1360-mpretend-cmove -mtas}
1361
1362@emph{Solaris 2 Options}
43b72ede 1363@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1364-pthreads}
1365
1366@emph{SPARC Options}
43b72ede
AA
1367@gccoptlist{-mcpu=@var{cpu-type}
1368-mtune=@var{cpu-type}
1369-mcmodel=@var{code-model}
1370-mmemory-model=@var{mem-model}
1371-m32 -m64 -mapp-regs -mno-app-regs
1372-mfaster-structs -mno-faster-structs -mflat -mno-flat
1373-mfpu -mno-fpu -mhard-float -msoft-float
1374-mhard-quad-float -msoft-quad-float
1375-mstack-bias -mno-stack-bias
1376-mstd-struct-return -mno-std-struct-return
1377-munaligned-doubles -mno-unaligned-doubles
1378-muser-mode -mno-user-mode
1379-mv8plus -mno-v8plus -mvis -mno-vis
1380-mvis2 -mno-vis2 -mvis3 -mno-vis3
1381-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1382-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1383-mpopc -mno-popc -msubxc -mno-subxc
1384-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
d77de738
ML
1385-mlra -mno-lra}
1386
1387@emph{System V Options}
1388@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1389
1390@emph{V850 Options}
43b72ede
AA
1391@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1392-mprolog-function -mno-prolog-function -mspace
1393-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1394-mapp-regs -mno-app-regs
1395-mdisable-callt -mno-disable-callt
1396-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1397-mv850e -mv850 -mv850e3v5
1398-mloop
1399-mrelax
1400-mlong-jumps
1401-msoft-float
1402-mhard-float
1403-mgcc-abi
1404-mrh850-abi
d77de738
ML
1405-mbig-switch}
1406
1407@emph{VAX Options}
1408@gccoptlist{-mg -mgnu -munix -mlra}
1409
1410@emph{Visium Options}
43b72ede 1411@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1412-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1413
1414@emph{VMS Options}
43b72ede 1415@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1416-mpointer-size=@var{size}}
1417
1418@emph{VxWorks Options}
b6f4b000 1419@gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
d77de738
ML
1420-Xbind-lazy -Xbind-now}
1421
1422@emph{x86 Options}
43b72ede
AA
1423@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1424-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1425-mfpmath=@var{unit}
1426-masm=@var{dialect} -mno-fancy-math-387
1427-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1428-mno-wide-multiply -mrtd -malign-double
1429-mpreferred-stack-boundary=@var{num}
1430-mincoming-stack-boundary=@var{num}
1431-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1432-mrecip -mrecip=@var{opt}
1433-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
ad5b757d 1434-mpartial-vector-fp-math
43b72ede
AA
1435-mmove-max=@var{bits} -mstore-max=@var{bits}
1436-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1437-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1438-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1439-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1440-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1441-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1442-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1443-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1444-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1445-mavx512vbmi2 -mavx512bf16 -menqcmd
1446-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1447-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1448-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1449-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1450-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
e686416b 1451-mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
5fbd91b1 1452-musermsr
43b72ede
AA
1453-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1454-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1455-mkl -mwidekl
1456-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1457-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1458-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1459-mregparm=@var{num} -msseregparm
1460-mveclibabi=@var{type} -mvect8-ret-in-mem
1461-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1462-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1463-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1464-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1465-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1466-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1467-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1468-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1469-mstack-protector-guard-reg=@var{reg}
1470-mstack-protector-guard-offset=@var{offset}
1471-mstack-protector-guard-symbol=@var{symbol}
1472-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1473-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1474-mindirect-branch-register -mharden-sls=@var{choice}
1475-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1476-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1477
1478@emph{x86 Windows Options}
453cb585 1479@gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll
43b72ede 1480-mnop-fun-dllimport -mthread
d77de738
ML
1481-municode -mwin32 -mwindows -fno-set-stack-executable}
1482
1483@emph{Xstormy16 Options}
1484@gccoptlist{-msim}
1485
1486@emph{Xtensa Options}
43b72ede
AA
1487@gccoptlist{-mconst16 -mno-const16
1488-mfused-madd -mno-fused-madd
1489-mforce-no-pic
1490-mserialize-volatile -mno-serialize-volatile
1491-mtext-section-literals -mno-text-section-literals
1492-mauto-litpools -mno-auto-litpools
1493-mtarget-align -mno-target-align
1494-mlongcalls -mno-longcalls
1495-mabi=@var{abi-type}
675b390e
MF
1496-mextra-l32r-costs=@var{cycles}
1497-mstrict-align -mno-strict-align}
d77de738
ML
1498
1499@emph{zSeries Options}
1500See S/390 and zSeries Options.
1501@end table
1502
1503
1504@node Overall Options
1505@section Options Controlling the Kind of Output
1506
1507Compilation can involve up to four stages: preprocessing, compilation
1508proper, assembly and linking, always in that order. GCC is capable of
1509preprocessing and compiling several files either into several
1510assembler input files, or into one assembler input file; then each
1511assembler input file produces an object file, and linking combines all
1512the object files (those newly compiled, and those specified as input)
1513into an executable file.
1514
1515@cindex file name suffix
1516For any given input file, the file name suffix determines what kind of
1517compilation is done:
1518
1519@table @gcctabopt
1520@item @var{file}.c
1521C source code that must be preprocessed.
1522
1523@item @var{file}.i
1524C source code that should not be preprocessed.
1525
1526@item @var{file}.ii
1527C++ source code that should not be preprocessed.
1528
1529@item @var{file}.m
1530Objective-C source code. Note that you must link with the @file{libobjc}
1531library to make an Objective-C program work.
1532
1533@item @var{file}.mi
1534Objective-C source code that should not be preprocessed.
1535
1536@item @var{file}.mm
1537@itemx @var{file}.M
1538Objective-C++ source code. Note that you must link with the @file{libobjc}
1539library to make an Objective-C++ program work. Note that @samp{.M} refers
1540to a literal capital M@.
1541
1542@item @var{file}.mii
1543Objective-C++ source code that should not be preprocessed.
1544
1545@item @var{file}.h
1546C, C++, Objective-C or Objective-C++ header file to be turned into a
1547precompiled header (default), or C, C++ header file to be turned into an
1548Ada spec (via the @option{-fdump-ada-spec} switch).
1549
1550@item @var{file}.cc
1551@itemx @var{file}.cp
1552@itemx @var{file}.cxx
1553@itemx @var{file}.cpp
1554@itemx @var{file}.CPP
1555@itemx @var{file}.c++
1556@itemx @var{file}.C
1557C++ source code that must be preprocessed. Note that in @samp{.cxx},
1558the last two letters must both be literally @samp{x}. Likewise,
1559@samp{.C} refers to a literal capital C@.
1560
1561@item @var{file}.mm
1562@itemx @var{file}.M
1563Objective-C++ source code that must be preprocessed.
1564
1565@item @var{file}.mii
1566Objective-C++ source code that should not be preprocessed.
1567
1568@item @var{file}.hh
1569@itemx @var{file}.H
1570@itemx @var{file}.hp
1571@itemx @var{file}.hxx
1572@itemx @var{file}.hpp
1573@itemx @var{file}.HPP
1574@itemx @var{file}.h++
1575@itemx @var{file}.tcc
1576C++ header file to be turned into a precompiled header or Ada spec.
1577
1578@item @var{file}.f
1579@itemx @var{file}.for
1580@itemx @var{file}.ftn
1581Fixed form Fortran source code that should not be preprocessed.
1582
1583@item @var{file}.F
1584@itemx @var{file}.FOR
1585@itemx @var{file}.fpp
1586@itemx @var{file}.FPP
1587@itemx @var{file}.FTN
1588Fixed form Fortran source code that must be preprocessed (with the traditional
1589preprocessor).
1590
1591@item @var{file}.f90
1592@itemx @var{file}.f95
1593@itemx @var{file}.f03
1594@itemx @var{file}.f08
1595Free form Fortran source code that should not be preprocessed.
1596
1597@item @var{file}.F90
1598@itemx @var{file}.F95
1599@itemx @var{file}.F03
1600@itemx @var{file}.F08
1601Free form Fortran source code that must be preprocessed (with the
1602traditional preprocessor).
1603
1604@item @var{file}.go
1605Go source code.
1606
1607@item @var{file}.d
1608D source code.
1609
1610@item @var{file}.di
1611D interface file.
1612
1613@item @var{file}.dd
1614D documentation code (Ddoc).
1615
1616@item @var{file}.ads
1617Ada source code file that contains a library unit declaration (a
1618declaration of a package, subprogram, or generic, or a generic
1619instantiation), or a library unit renaming declaration (a package,
1620generic, or subprogram renaming declaration). Such files are also
1621called @dfn{specs}.
1622
1623@item @var{file}.adb
1624Ada source code file containing a library unit body (a subprogram or
1625package body). Such files are also called @dfn{bodies}.
1626
1627@c GCC also knows about some suffixes for languages not yet included:
1628@c Ratfor:
1629@c @var{file}.r
1630
1631@item @var{file}.s
1632Assembler code.
1633
1634@item @var{file}.S
1635@itemx @var{file}.sx
1636Assembler code that must be preprocessed.
1637
1638@item @var{other}
1639An object file to be fed straight into linking.
1640Any file name with no recognized suffix is treated this way.
1641@end table
1642
1643@opindex x
1644You can specify the input language explicitly with the @option{-x} option:
1645
1646@table @gcctabopt
1647@item -x @var{language}
1648Specify explicitly the @var{language} for the following input files
1649(rather than letting the compiler choose a default based on the file
1650name suffix). This option applies to all following input files until
1651the next @option{-x} option. Possible values for @var{language} are:
1652@smallexample
1653c c-header cpp-output
1654c++ c++-header c++-system-header c++-user-header c++-cpp-output
1655objective-c objective-c-header objective-c-cpp-output
1656objective-c++ objective-c++-header objective-c++-cpp-output
1657assembler assembler-with-cpp
1658ada
1659d
1660f77 f77-cpp-input f95 f95-cpp-input
1661go
1662@end smallexample
1663
1664@item -x none
1665Turn off any specification of a language, so that subsequent files are
1666handled according to their file name suffixes (as they are if @option{-x}
1667has not been used at all).
1668@end table
1669
1670If you only want some of the stages of compilation, you can use
1671@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1672one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1673@command{gcc} is to stop. Note that some combinations (for example,
1674@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1675
1676@table @gcctabopt
d77de738 1677@opindex c
ddf6fe37 1678@item -c
d77de738
ML
1679Compile or assemble the source files, but do not link. The linking
1680stage simply is not done. The ultimate output is in the form of an
1681object file for each source file.
1682
1683By default, the object file name for a source file is made by replacing
1684the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1685
1686Unrecognized input files, not requiring compilation or assembly, are
1687ignored.
1688
d77de738 1689@opindex S
ddf6fe37 1690@item -S
d77de738
ML
1691Stop after the stage of compilation proper; do not assemble. The output
1692is in the form of an assembler code file for each non-assembler input
1693file specified.
1694
1695By default, the assembler file name for a source file is made by
1696replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1697
1698Input files that don't require compilation are ignored.
1699
d77de738 1700@opindex E
ddf6fe37 1701@item -E
d77de738
ML
1702Stop after the preprocessing stage; do not run the compiler proper. The
1703output is in the form of preprocessed source code, which is sent to the
1704standard output.
1705
1706Input files that don't require preprocessing are ignored.
1707
1708@cindex output file option
d77de738 1709@opindex o
ddf6fe37 1710@item -o @var{file}
d77de738
ML
1711Place the primary output in file @var{file}. This applies to whatever
1712sort of output is being produced, whether it be an executable file, an
1713object file, an assembler file or preprocessed C code.
1714
1715If @option{-o} is not specified, the default is to put an executable
1716file in @file{a.out}, the object file for
1717@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1718assembler file in @file{@var{source}.s}, a precompiled header file in
1719@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1720standard output.
1721
1722Though @option{-o} names only the primary output, it also affects the
1723naming of auxiliary and dump outputs. See the examples below. Unless
1724overridden, both auxiliary outputs and dump outputs are placed in the
1725same directory as the primary output. In auxiliary outputs, the suffix
1726of the input file is replaced with that of the auxiliary output file
1727type; in dump outputs, the suffix of the dump file is appended to the
1728input file suffix. In compilation commands, the base name of both
1729auxiliary and dump outputs is that of the primary output; in compile and
1730link commands, the primary output name, minus the executable suffix, is
1731combined with the input file name. If both share the same base name,
1732disregarding the suffix, the result of the combination is that base
1733name, otherwise, they are concatenated, separated by a dash.
1734
1735@smallexample
1736gcc -c foo.c ...
1737@end smallexample
1738
1739will use @file{foo.o} as the primary output, and place aux outputs and
1740dumps next to it, e.g., aux file @file{foo.dwo} for
1741@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1742@option{-fdump-rtl-final}.
1743
1744If a non-linker output file is explicitly specified, aux and dump files
1745by default take the same base name:
1746
1747@smallexample
1748gcc -c foo.c -o dir/foobar.o ...
1749@end smallexample
1750
1751will name aux outputs @file{dir/foobar.*} and dump outputs
1752@file{dir/foobar.c.*}.
1753
1754A linker output will instead prefix aux and dump outputs:
1755
1756@smallexample
1757gcc foo.c bar.c -o dir/foobar ...
1758@end smallexample
1759
1760will generally name aux outputs @file{dir/foobar-foo.*} and
1761@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1762@file{dir/foobar-bar.c.*}.
1763
1764The one exception to the above is when the executable shares the base
1765name with the single input:
1766
1767@smallexample
1768gcc foo.c -o dir/foo ...
1769@end smallexample
1770
1771in which case aux outputs are named @file{dir/foo.*} and dump outputs
1772named @file{dir/foo.c.*}.
1773
1774The location and the names of auxiliary and dump outputs can be adjusted
1775by the options @option{-dumpbase}, @option{-dumpbase-ext},
1776@option{-dumpdir}, @option{-save-temps=cwd}, and
1777@option{-save-temps=obj}.
1778
1779
d77de738 1780@opindex dumpbase
ddf6fe37 1781@item -dumpbase @var{dumpbase}
d77de738
ML
1782This option sets the base name for auxiliary and dump output files. It
1783does not affect the name of the primary output file. Intermediate
1784outputs, when preserved, are not regarded as primary outputs, but as
1785auxiliary outputs:
1786
1787@smallexample
1788gcc -save-temps -S foo.c
1789@end smallexample
1790
1791saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1792then compiles to the (implied) output file @file{foo.s}, whereas:
1793
1794@smallexample
1795gcc -save-temps -dumpbase save-foo -c foo.c
1796@end smallexample
1797
1798preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1799an intermediate, thus auxiliary output), and then assembles to the
1800(implied) output file @file{foo.o}.
1801
1802Absent this option, dump and aux files take their names from the input
1803file, or from the (non-linker) output file, if one is explicitly
1804specified: dump output files (e.g. those requested by @option{-fdump-*}
1805options) with the input name suffix, and aux output files (those
1806requested by other non-dump options, e.g. @code{-save-temps},
1807@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1808
1809Similar suffix differentiation of dump and aux outputs can be attained
1810for explicitly-given @option{-dumpbase basename.suf} by also specifying
1811@option{-dumpbase-ext .suf}.
1812
1813If @var{dumpbase} is explicitly specified with any directory component,
1814any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1815@option{-save-temps=*}) is ignored, and instead of appending to it,
1816@var{dumpbase} fully overrides it:
1817
1818@smallexample
1819gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1820 -dumpdir pfx- -save-temps=cwd ...
1821@end smallexample
1822
1823creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1824@file{dir/} in @option{-o}, the @file{./} prefix implied by
1825@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1826
1827When @option{-dumpbase} is specified in a command that compiles multiple
1828inputs, or that compiles and then links, it may be combined with
1829@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1830file is compiled using the combined @var{dumppfx}, and default values
1831for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1832file:
1833
1834@smallexample
1835gcc foo.c bar.c -c -dumpbase main ...
1836@end smallexample
1837
1838creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1839overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1840as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1841and @file{main-bar.*}.
1842
1843An empty string specified as @var{dumpbase} avoids the influence of the
1844output basename in the naming of auxiliary and dump outputs during
1845compilation, computing default values :
1846
1847@smallexample
1848gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1849@end smallexample
1850
1851will name aux outputs @file{dir/foo.*} and dump outputs
1852@file{dir/foo.c.*}. Note how their basenames are taken from the input
1853name, but the directory still defaults to that of the output.
1854
1855The empty-string dumpbase does not prevent the use of the output
1856basename for outputs during linking:
1857
1858@smallexample
1859gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1860@end smallexample
1861
1862The compilation of the source files will name auxiliary outputs
1863@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1864@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1865linking will use @file{dir/foobar.} as the prefix for dumps and
1866auxiliary files.
1867
1868
d77de738 1869@opindex dumpbase-ext
ddf6fe37 1870@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1871When forming the name of an auxiliary (but not a dump) output file, drop
1872trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1873suffixes. If not specified, this option defaults to the suffix of a
1874default @var{dumpbase}, i.e., the suffix of the input file when
1875@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1876is combined with @var{dumppfx}.
1877
1878@smallexample
1879gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1880@end smallexample
1881
1882creates @file{dir/foo.o} as the main output, and generates auxiliary
1883outputs in @file{dir/x-foo.*}, taking the location of the primary
1884output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1885outputs retain the suffix: @file{dir/x-foo.c.*}.
1886
1887This option is disregarded if it does not match the suffix of a
1888specified @var{dumpbase}, except as an alternative to the executable
1889suffix when appending the linker output base name to @var{dumppfx}, as
1890specified below:
1891
1892@smallexample
1893gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1894@end smallexample
1895
1896creates @file{main.out} as the primary output, and avoids overwriting
1897the auxiliary and dump outputs by using the executable name minus
1898@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1899@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1900@file{main-foo.c.*} and @file{main-bar.c.*}.
1901
1902
d77de738 1903@opindex dumpdir
ddf6fe37 1904@item -dumpdir @var{dumppfx}
d77de738
ML
1905When forming the name of an auxiliary or dump output file, use
1906@var{dumppfx} as a prefix:
1907
1908@smallexample
1909gcc -dumpdir pfx- -c foo.c ...
1910@end smallexample
1911
1912creates @file{foo.o} as the primary output, and auxiliary outputs named
1913@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1914@var{dumpbase} derived from the default primary output, derived in turn
1915from the input name. Dump outputs also take the input name suffix:
1916@file{pfx-foo.c.*}.
1917
1918If @var{dumppfx} is to be used as a directory name, it must end with a
1919directory separator:
1920
1921@smallexample
1922gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1923@end smallexample
1924
1925creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1926named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1927default @var{dumpbase} derived from the primary output name. Dump
1928outputs also take the input name suffix: @file{dir/bar.c.*}.
1929
1930It defaults to the location of the output file, unless the output
1931file is a special file like @code{/dev/null}. Options
1932@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1933default, just like an explicit @option{-dumpdir} option. In case
1934multiple such options are given, the last one prevails:
1935
1936@smallexample
1937gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1938@end smallexample
1939
1940outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1941@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1942@option{-dumpdir} option. It does not matter that @option{=obj} is the
1943default for @option{-save-temps}, nor that the output directory is
1944implicitly the current directory. Dump outputs are named
1945@file{foo.c.*}.
1946
1947When compiling from multiple input files, if @option{-dumpbase} is
1948specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1949are appended to (or override, if containing any directory components) an
1950explicit or defaulted @var{dumppfx}, so that each of the multiple
1951compilations gets differently-named aux and dump outputs.
1952
1953@smallexample
1954gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1955@end smallexample
1956
1957outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1958@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1959Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1960and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1961single-input compilation:
1962
1963@smallexample
1964gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1965@end smallexample
1966
1967that, applying @option{-dumpbase} to a single source, does not compute
1968and append a separate @var{dumpbase} per input file. Its auxiliary and
1969dump outputs go in @file{dir/pfx-main.*}.
1970
1971When compiling and then linking from multiple input files, a defaulted
1972or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1973transformation above (e.g. the compilation of @file{foo.c} and
1974@file{bar.c} above, but without @option{-c}). If neither
1975@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1976base name, minus @var{auxdropsuf}, if specified, or the executable
1977suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1978instead. Note, however, that unlike earlier cases of linking:
1979
1980@smallexample
1981gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1982@end smallexample
1983
1984does not append the output name @file{main} to @var{dumppfx}, because
1985@option{-dumpdir} is explicitly specified. The goal is that the
1986explicitly-specified @var{dumppfx} may contain the specified output name
1987as part of the prefix, if desired; only an explicitly-specified
1988@option{-dumpbase} would be combined with it, in order to avoid simply
1989discarding a meaningful option.
1990
1991When compiling and then linking from a single input file, the linker
1992output base name will only be appended to the default @var{dumppfx} as
1993above if it does not share the base name with the single input file
1994name. This has been covered in single-input linking cases above, but
1995not with an explicit @option{-dumpdir} that inhibits the combination,
1996even if overridden by @option{-save-temps=*}:
1997
1998@smallexample
1999gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2000@end smallexample
2001
2002Auxiliary outputs are named @file{foo.*}, and dump outputs
2003@file{foo.c.*}, in the current working directory as ultimately requested
2004by @option{-save-temps=cwd}.
2005
2006Summing it all up for an intuitive though slightly imprecise data flow:
2007the primary output name is broken into a directory part and a basename
2008part; @var{dumppfx} is set to the former, unless overridden by
2009@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2010to the latter, unless overriden by @option{-dumpbase}. If there are
2011multiple inputs or linking, this @var{dumpbase} may be combined with
2012@var{dumppfx} and taken from each input file. Auxiliary output names
2013for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2014minus suffix, and the auxiliary output suffix; dump output names are
2015only different in that the suffix from @var{dumpbase} is retained.
2016
2017When it comes to auxiliary and dump outputs created during LTO
2018recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2019given or as derived from the linker output name but not from inputs,
2020even in cases in which this combination would not otherwise be used as
2021such, is passed down with a trailing period replacing the compiler-added
2022dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2023being involved in linking, this program does not normally get any
2024@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2025
2026When running sub-compilers, @command{lto-wrapper} appends LTO stage
2027names to the received @var{dumppfx}, ensures it contains a directory
2028component so that it overrides any @option{-dumpdir}, and passes that as
2029@option{-dumpbase} to sub-compilers.
2030
d77de738 2031@opindex v
ddf6fe37 2032@item -v
d77de738
ML
2033Print (on standard error output) the commands executed to run the stages
2034of compilation. Also print the version number of the compiler driver
2035program and of the preprocessor and the compiler proper.
2036
d77de738 2037@opindex ###
ddf6fe37 2038@item -###
d77de738
ML
2039Like @option{-v} except the commands are not executed and arguments
2040are quoted unless they contain only alphanumeric characters or @code{./-_}.
2041This is useful for shell scripts to capture the driver-generated command lines.
2042
d77de738 2043@opindex help
ddf6fe37 2044@item --help
d77de738
ML
2045Print (on the standard output) a description of the command-line options
2046understood by @command{gcc}. If the @option{-v} option is also specified
2047then @option{--help} is also passed on to the various processes
2048invoked by @command{gcc}, so that they can display the command-line options
2049they accept. If the @option{-Wextra} option has also been specified
2050(prior to the @option{--help} option), then command-line options that
2051have no documentation associated with them are also displayed.
2052
d77de738 2053@opindex target-help
ddf6fe37 2054@item --target-help
d77de738
ML
2055Print (on the standard output) a description of target-specific command-line
2056options for each tool. For some targets extra target-specific
2057information may also be printed.
2058
2059@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2060Print (on the standard output) a description of the command-line
2061options understood by the compiler that fit into all specified classes
2062and qualifiers. These are the supported classes:
2063
2064@table @asis
2065@item @samp{optimizers}
2066Display all of the optimization options supported by the
2067compiler.
2068
2069@item @samp{warnings}
2070Display all of the options controlling warning messages
2071produced by the compiler.
2072
2073@item @samp{target}
2074Display target-specific options. Unlike the
2075@option{--target-help} option however, target-specific options of the
2076linker and assembler are not displayed. This is because those
2077tools do not currently support the extended @option{--help=} syntax.
2078
2079@item @samp{params}
2080Display the values recognized by the @option{--param}
2081option.
2082
2083@item @var{language}
2084Display the options supported for @var{language}, where
2085@var{language} is the name of one of the languages supported in this
2086version of GCC@. If an option is supported by all languages, one needs
2087to select @samp{common} class.
2088
2089@item @samp{common}
2090Display the options that are common to all languages.
2091@end table
2092
2093These are the supported qualifiers:
2094
2095@table @asis
2096@item @samp{undocumented}
2097Display only those options that are undocumented.
2098
2099@item @samp{joined}
2100Display options taking an argument that appears after an equal
2101sign in the same continuous piece of text, such as:
2102@samp{--help=target}.
2103
2104@item @samp{separate}
2105Display options taking an argument that appears as a separate word
2106following the original option, such as: @samp{-o output-file}.
2107@end table
2108
2109Thus for example to display all the undocumented target-specific
2110switches supported by the compiler, use:
2111
2112@smallexample
2113--help=target,undocumented
2114@end smallexample
2115
2116The sense of a qualifier can be inverted by prefixing it with the
2117@samp{^} character, so for example to display all binary warning
2118options (i.e., ones that are either on or off and that do not take an
2119argument) that have a description, use:
2120
2121@smallexample
2122--help=warnings,^joined,^undocumented
2123@end smallexample
2124
2125The argument to @option{--help=} should not consist solely of inverted
2126qualifiers.
2127
2128Combining several classes is possible, although this usually
2129restricts the output so much that there is nothing to display. One
2130case where it does work, however, is when one of the classes is
2131@var{target}. For example, to display all the target-specific
2132optimization options, use:
2133
2134@smallexample
2135--help=target,optimizers
2136@end smallexample
2137
2138The @option{--help=} option can be repeated on the command line. Each
2139successive use displays its requested class of options, skipping
2140those that have already been displayed. If @option{--help} is also
2141specified anywhere on the command line then this takes precedence
2142over any @option{--help=} option.
2143
2144If the @option{-Q} option appears on the command line before the
2145@option{--help=} option, then the descriptive text displayed by
2146@option{--help=} is changed. Instead of describing the displayed
2147options, an indication is given as to whether the option is enabled,
2148disabled or set to a specific value (assuming that the compiler
2149knows this at the point where the @option{--help=} option is used).
2150
2151Here is a truncated example from the ARM port of @command{gcc}:
2152
2153@smallexample
2154 % gcc -Q -mabi=2 --help=target -c
2155 The following options are target specific:
2156 -mabi= 2
2157 -mabort-on-noreturn [disabled]
2158 -mapcs [disabled]
2159@end smallexample
2160
2161The output is sensitive to the effects of previous command-line
2162options, so for example it is possible to find out which optimizations
2163are enabled at @option{-O2} by using:
2164
2165@smallexample
2166-Q -O2 --help=optimizers
2167@end smallexample
2168
2169Alternatively you can discover which binary optimizations are enabled
2170by @option{-O3} by using:
2171
2172@smallexample
2173gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2174gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2175diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2176@end smallexample
2177
d77de738 2178@opindex version
ddf6fe37 2179@item --version
d77de738
ML
2180Display the version number and copyrights of the invoked GCC@.
2181
d77de738 2182@opindex pass-exit-codes
ddf6fe37 2183@item -pass-exit-codes
d77de738
ML
2184Normally the @command{gcc} program exits with the code of 1 if any
2185phase of the compiler returns a non-success return code. If you specify
2186@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2187the numerically highest error produced by any phase returning an error
2188indication. The C, C++, and Fortran front ends return 4 if an internal
2189compiler error is encountered.
2190
d77de738 2191@opindex pipe
ddf6fe37 2192@item -pipe
d77de738
ML
2193Use pipes rather than temporary files for communication between the
2194various stages of compilation. This fails to work on some systems where
2195the assembler is unable to read from a pipe; but the GNU assembler has
2196no trouble.
2197
d77de738 2198@opindex specs
ddf6fe37 2199@item -specs=@var{file}
d77de738
ML
2200Process @var{file} after the compiler reads in the standard @file{specs}
2201file, in order to override the defaults which the @command{gcc} driver
2202program uses when determining what switches to pass to @command{cc1},
2203@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2204@option{-specs=@var{file}} can be specified on the command line, and they
2205are processed in order, from left to right. @xref{Spec Files}, for
2206information about the format of the @var{file}.
2207
d77de738 2208@opindex wrapper
ddf6fe37 2209@item -wrapper
d77de738
ML
2210Invoke all subcommands under a wrapper program. The name of the
2211wrapper program and its parameters are passed as a comma separated
2212list.
2213
2214@smallexample
2215gcc -c t.c -wrapper gdb,--args
2216@end smallexample
2217
2218@noindent
2219This invokes all subprograms of @command{gcc} under
2220@samp{gdb --args}, thus the invocation of @command{cc1} is
2221@samp{gdb --args cc1 @dots{}}.
2222
d77de738 2223@opindex ffile-prefix-map
ddf6fe37 2224@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2225When compiling files residing in directory @file{@var{old}}, record
2226any references to them in the result of the compilation as if the
2227files resided in directory @file{@var{new}} instead. Specifying this
2228option is equivalent to specifying all the individual
2229@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2230builds that are location independent. Directories referenced by
2eb0191a
JJ
2231directives are not affected by these options. See also
2232@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2233@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2234
2eb0191a 2235@opindex fcanon-prefix-map
e54b01a1 2236@item -fcanon-prefix-map
2eb0191a
JJ
2237For the @option{-f*-prefix-map} options normally comparison
2238of @file{@var{old}} prefix against the filename that would be normally
2239referenced in the result of the compilation is done using textual
2240comparison of the prefixes, or ignoring character case for case insensitive
2241filesystems and considering slashes and backslashes as equal on DOS based
2242filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2243to be done on canonicalized paths of @file{@var{old}}
2244and the referenced filename.
d77de738 2245
d77de738 2246@opindex fplugin
ddf6fe37 2247@item -fplugin=@var{name}.so
d77de738
ML
2248Load the plugin code in file @var{name}.so, assumed to be a
2249shared object to be dlopen'd by the compiler. The base name of
2250the shared object file is used to identify the plugin for the
2251purposes of argument parsing (See
2252@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2253Each plugin should define the callback functions specified in the
2254Plugins API.
2255
d77de738 2256@opindex fplugin-arg
ddf6fe37 2257@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2258Define an argument called @var{key} with a value of @var{value}
2259for the plugin called @var{name}.
2260
d77de738 2261@opindex fdump-ada-spec
ddf6fe37 2262@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2263For C and C++ source and include files, generate corresponding Ada specs.
2264@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2265GNAT User's Guide}, which provides detailed documentation on this feature.
2266
d77de738 2267@opindex fada-spec-parent
ddf6fe37 2268@item -fada-spec-parent=@var{unit}
d77de738
ML
2269In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2270Ada specs as child units of parent @var{unit}.
2271
d77de738 2272@opindex fdump-go-spec
ddf6fe37 2273@item -fdump-go-spec=@var{file}
d77de738
ML
2274For input files in any language, generate corresponding Go
2275declarations in @var{file}. This generates Go @code{const},
2276@code{type}, @code{var}, and @code{func} declarations which may be a
2277useful way to start writing a Go interface to code written in some
2278other language.
2279
2280@include @value{srcdir}/../libiberty/at-file.texi
2281@end table
2282
2283@node Invoking G++
2284@section Compiling C++ Programs
2285
2286@cindex suffixes for C++ source
2287@cindex C++ source file suffixes
2288C++ source files conventionally use one of the suffixes @samp{.C},
2289@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2290@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2291@samp{.H}, or (for shared template code) @samp{.tcc}; and
2292preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2293files with these names and compiles them as C++ programs even if you
2294call the compiler the same way as for compiling C programs (usually
2295with the name @command{gcc}).
2296
2297@findex g++
2298@findex c++
2299However, the use of @command{gcc} does not add the C++ library.
2300@command{g++} is a program that calls GCC and automatically specifies linking
2301against the C++ library. It treats @samp{.c},
2302@samp{.h} and @samp{.i} files as C++ source files instead of C source
2303files unless @option{-x} is used. This program is also useful when
2304precompiling a C header file with a @samp{.h} extension for use in C++
2305compilations. On many systems, @command{g++} is also installed with
2306the name @command{c++}.
2307
2308@cindex invoking @command{g++}
2309When you compile C++ programs, you may specify many of the same
2310command-line options that you use for compiling programs in any
2311language; or command-line options meaningful for C and related
2312languages; or options that are meaningful only for C++ programs.
2313@xref{C Dialect Options,,Options Controlling C Dialect}, for
2314explanations of options for languages related to C@.
2315@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2316explanations of options that are meaningful only for C++ programs.
2317
2318@node C Dialect Options
2319@section Options Controlling C Dialect
2320@cindex dialect options
2321@cindex language dialect options
2322@cindex options, dialect
2323
2324The following options control the dialect of C (or languages derived
2325from C, such as C++, Objective-C and Objective-C++) that the compiler
2326accepts:
2327
2328@table @gcctabopt
2329@cindex ANSI support
2330@cindex ISO support
d77de738 2331@opindex ansi
ddf6fe37 2332@item -ansi
d77de738
ML
2333In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2334equivalent to @option{-std=c++98}.
2335
2336This turns off certain features of GCC that are incompatible with ISO
2337C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2338such as the @code{asm} and @code{typeof} keywords, and
2339predefined macros such as @code{unix} and @code{vax} that identify the
2340type of system you are using. It also enables the undesirable and
2341rarely used ISO trigraph feature. For the C compiler,
2342it disables recognition of C++ style @samp{//} comments as well as
2343the @code{inline} keyword.
2344
2345The alternate keywords @code{__asm__}, @code{__extension__},
2346@code{__inline__} and @code{__typeof__} continue to work despite
2347@option{-ansi}. You would not want to use them in an ISO C program, of
2348course, but it is useful to put them in header files that might be included
2349in compilations done with @option{-ansi}. Alternate predefined macros
2350such as @code{__unix__} and @code{__vax__} are also available, with or
2351without @option{-ansi}.
2352
2353The @option{-ansi} option does not cause non-ISO programs to be
2354rejected gratuitously. For that, @option{-Wpedantic} is required in
2355addition to @option{-ansi}. @xref{Warning Options}.
2356
2357The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2358option is used. Some header files may notice this macro and refrain
2359from declaring certain functions or defining certain macros that the
2360ISO standard doesn't call for; this is to avoid interfering with any
2361programs that might use these names for other things.
2362
2363Functions that are normally built in but do not have semantics
2364defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2365functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2366built-in functions provided by GCC}, for details of the functions
2367affected.
2368
d77de738 2369@opindex std
ddf6fe37 2370@item -std=
d77de738
ML
2371Determine the language standard. @xref{Standards,,Language Standards
2372Supported by GCC}, for details of these standard versions. This option
2373is currently only supported when compiling C or C++.
2374
2375The compiler can accept several base standards, such as @samp{c90} or
2376@samp{c++98}, and GNU dialects of those standards, such as
2377@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2378compiler accepts all programs following that standard plus those
2379using GNU extensions that do not contradict it. For example,
2380@option{-std=c90} turns off certain features of GCC that are
2381incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2382keywords, but not other GNU extensions that do not have a meaning in
2383ISO C90, such as omitting the middle term of a @code{?:}
2384expression. On the other hand, when a GNU dialect of a standard is
2385specified, all features supported by the compiler are enabled, even when
2386those features change the meaning of the base standard. As a result, some
2387strict-conforming programs may be rejected. The particular standard
2388is used by @option{-Wpedantic} to identify which features are GNU
2389extensions given that version of the standard. For example
2390@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2391comments, while @option{-std=gnu99 -Wpedantic} does not.
2392
2393A value for this option must be provided; possible values are
2394
2395@table @samp
2396@item c90
2397@itemx c89
2398@itemx iso9899:1990
2399Support all ISO C90 programs (certain GNU extensions that conflict
2400with ISO C90 are disabled). Same as @option{-ansi} for C code.
2401
2402@item iso9899:199409
2403ISO C90 as modified in amendment 1.
2404
2405@item c99
2406@itemx c9x
2407@itemx iso9899:1999
2408@itemx iso9899:199x
2409ISO C99. This standard is substantially completely supported, modulo
2410bugs and floating-point issues
2411(mainly but not entirely relating to optional C99 features from
2412Annexes F and G). See
2413@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2414names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2415
2416@item c11
2417@itemx c1x
2418@itemx iso9899:2011
2419ISO C11, the 2011 revision of the ISO C standard. This standard is
2420substantially completely supported, modulo bugs, floating-point issues
2421(mainly but not entirely relating to optional C11 features from
2422Annexes F and G) and the optional Annexes K (Bounds-checking
2423interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2424
2425@item c17
2426@itemx c18
2427@itemx iso9899:2017
2428@itemx iso9899:2018
2429ISO C17, the 2017 revision of the ISO C standard
2430(published in 2018). This standard is
2431same as C11 except for corrections of defects (all of which are also
2432applied with @option{-std=c11}) and a new value of
2433@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2434
fad61bf7
JM
2435@item c23
2436@itemx c2x
2437@itemx iso9899:2024
2438ISO C23, the 2023 revision of the ISO C standard (expected to be
2439published in 2024). The support for this version is experimental and
2440incomplete. The name @samp{c2x} is deprecated.
d77de738
ML
2441
2442@item gnu90
2443@itemx gnu89
2444GNU dialect of ISO C90 (including some C99 features).
2445
2446@item gnu99
2447@itemx gnu9x
2448GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2449
2450@item gnu11
2451@itemx gnu1x
2452GNU dialect of ISO C11.
2453The name @samp{gnu1x} is deprecated.
2454
2455@item gnu17
2456@itemx gnu18
2457GNU dialect of ISO C17. This is the default for C code.
2458
fad61bf7
JM
2459@item gnu23
2460@itemx gnu2x
d77de738
ML
2461The next version of the ISO C standard, still under development, plus
2462GNU extensions. The support for this version is experimental and
fad61bf7 2463incomplete. The name @samp{gnu2x} is deprecated.
d77de738
ML
2464
2465@item c++98
2466@itemx c++03
2467The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2468additional defect reports. Same as @option{-ansi} for C++ code.
2469
2470@item gnu++98
2471@itemx gnu++03
2472GNU dialect of @option{-std=c++98}.
2473
2474@item c++11
2475@itemx c++0x
2476The 2011 ISO C++ standard plus amendments.
2477The name @samp{c++0x} is deprecated.
2478
2479@item gnu++11
2480@itemx gnu++0x
2481GNU dialect of @option{-std=c++11}.
2482The name @samp{gnu++0x} is deprecated.
2483
2484@item c++14
2485@itemx c++1y
2486The 2014 ISO C++ standard plus amendments.
2487The name @samp{c++1y} is deprecated.
2488
2489@item gnu++14
2490@itemx gnu++1y
2491GNU dialect of @option{-std=c++14}.
2492The name @samp{gnu++1y} is deprecated.
2493
2494@item c++17
2495@itemx c++1z
2496The 2017 ISO C++ standard plus amendments.
2497The name @samp{c++1z} is deprecated.
2498
2499@item gnu++17
2500@itemx gnu++1z
2501GNU dialect of @option{-std=c++17}.
2502This is the default for C++ code.
2503The name @samp{gnu++1z} is deprecated.
2504
2505@item c++20
2506@itemx c++2a
2507The 2020 ISO C++ standard plus amendments.
2508Support is experimental, and could change in incompatible ways in
2509future releases.
2510The name @samp{c++2a} is deprecated.
2511
2512@item gnu++20
2513@itemx gnu++2a
2514GNU dialect of @option{-std=c++20}.
2515Support is experimental, and could change in incompatible ways in
2516future releases.
2517The name @samp{gnu++2a} is deprecated.
2518
2519@item c++2b
2520@itemx c++23
2521The next revision of the ISO C++ standard, planned for
25222023. Support is highly experimental, and will almost certainly
2523change in incompatible ways in future releases.
2524
2525@item gnu++2b
2526@itemx gnu++23
2527GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2528and will almost certainly change in incompatible ways in future
2529releases.
5388a43f
MP
2530
2531@item c++2c
2532@itemx c++26
2533The next revision of the ISO C++ standard, planned for
25342026. Support is highly experimental, and will almost certainly
2535change in incompatible ways in future releases.
2536
2537@item gnu++2c
2538@itemx gnu++26
2539GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2540and will almost certainly change in incompatible ways in future
2541releases.
d77de738
ML
2542@end table
2543
d77de738 2544@opindex aux-info
ddf6fe37 2545@item -aux-info @var{filename}
d77de738
ML
2546Output to the given filename prototyped declarations for all functions
2547declared and/or defined in a translation unit, including those in header
2548files. This option is silently ignored in any language other than C@.
2549
2550Besides declarations, the file indicates, in comments, the origin of
2551each declaration (source file and line), whether the declaration was
2552implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2553@samp{O} for old, respectively, in the first character after the line
2554number and the colon), and whether it came from a declaration or a
2555definition (@samp{C} or @samp{F}, respectively, in the following
2556character). In the case of function definitions, a K&R-style list of
2557arguments followed by their declarations is also provided, inside
2558comments, after the declaration.
2559
d77de738
ML
2560@opindex fno-asm
2561@opindex fasm
ddf6fe37 2562@item -fno-asm
d77de738
ML
2563Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2564keyword, so that code can use these words as identifiers. You can use
2565the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2566instead. In C, @option{-ansi} implies @option{-fno-asm}.
2567
2568In C++, @code{inline} is a standard keyword and is not affected by
2569this switch. You may want to use the @option{-fno-gnu-keywords} flag
2570instead, which disables @code{typeof} but not @code{asm} and
2571@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2572this switch only affects the @code{asm} and @code{typeof} keywords,
fad61bf7
JM
2573since @code{inline} is a standard keyword in ISO C99. In C23 mode
2574(@option{-std=c23} or @option{-std=gnu23}), this switch only affects
d77de738 2575the @code{asm} keyword, since @code{typeof} is a standard keyword in
fad61bf7 2576ISO C23.
d77de738 2577
d77de738
ML
2578@opindex fno-builtin
2579@opindex fbuiltin
f33d7a88 2580@cindex built-in functions
ddf6fe37
AA
2581@item -fno-builtin
2582@itemx -fno-builtin-@var{function}
d77de738
ML
2583Don't recognize built-in functions that do not begin with
2584@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2585functions provided by GCC}, for details of the functions affected,
2586including those which are not built-in functions when @option{-ansi} or
2587@option{-std} options for strict ISO C conformance are used because they
2588do not have an ISO standard meaning.
2589
2590GCC normally generates special code to handle certain built-in functions
2591more efficiently; for instance, calls to @code{alloca} may become single
2592instructions which adjust the stack directly, and calls to @code{memcpy}
2593may become inline copy loops. The resulting code is often both smaller
2594and faster, but since the function calls no longer appear as such, you
2595cannot set a breakpoint on those calls, nor can you change the behavior
2596of the functions by linking with a different library. In addition,
2597when a function is recognized as a built-in function, GCC may use
2598information about that function to warn about problems with calls to
2599that function, or to generate more efficient code, even if the
2600resulting code still contains calls to that function. For example,
2601warnings are given with @option{-Wformat} for bad calls to
2602@code{printf} when @code{printf} is built in and @code{strlen} is
2603known not to modify global memory.
2604
2605With the @option{-fno-builtin-@var{function}} option
2606only the built-in function @var{function} is
2607disabled. @var{function} must not begin with @samp{__builtin_}. If a
2608function is named that is not built-in in this version of GCC, this
2609option is ignored. There is no corresponding
2610@option{-fbuiltin-@var{function}} option; if you wish to enable
2611built-in functions selectively when using @option{-fno-builtin} or
2612@option{-ffreestanding}, you may define macros such as:
2613
2614@smallexample
2615#define abs(n) __builtin_abs ((n))
2616#define strcpy(d, s) __builtin_strcpy ((d), (s))
2617@end smallexample
2618
d77de738 2619@opindex fcond-mismatch
ddf6fe37 2620@item -fcond-mismatch
d77de738
ML
2621Allow conditional expressions with mismatched types in the second and
2622third arguments. The value of such an expression is void. This option
2623is not supported for C++.
2624
d77de738
ML
2625@opindex ffreestanding
2626@cindex hosted environment
f33d7a88 2627@item -ffreestanding
d77de738
ML
2628
2629Assert that compilation targets a freestanding environment. This
2630implies @option{-fno-builtin}. A freestanding environment
2631is one in which the standard library may not exist, and program startup may
2632not necessarily be at @code{main}. The most obvious example is an OS kernel.
2633This is equivalent to @option{-fno-hosted}.
2634
2635@xref{Standards,,Language Standards Supported by GCC}, for details of
2636freestanding and hosted environments.
2637
d77de738 2638@opindex fgimple
ddf6fe37 2639@item -fgimple
d77de738
ML
2640
2641Enable parsing of function definitions marked with @code{__GIMPLE}.
2642This is an experimental feature that allows unit testing of GIMPLE
2643passes.
2644
d77de738 2645@opindex fgnu-tm
ddf6fe37 2646@item -fgnu-tm
d77de738
ML
2647When the option @option{-fgnu-tm} is specified, the compiler
2648generates code for the Linux variant of Intel's current Transactional
2649Memory ABI specification document (Revision 1.1, May 6 2009). This is
2650an experimental feature whose interface may change in future versions
2651of GCC, as the official specification changes. Please note that not
2652all architectures are supported for this feature.
2653
2654For more information on GCC's support for transactional memory,
2655@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2656Transactional Memory Library}.
2657
2658Note that the transactional memory feature is not supported with
2659non-call exceptions (@option{-fnon-call-exceptions}).
2660
d77de738 2661@opindex fgnu89-inline
ddf6fe37 2662@item -fgnu89-inline
d77de738
ML
2663The option @option{-fgnu89-inline} tells GCC to use the traditional
2664GNU semantics for @code{inline} functions when in C99 mode.
2665@xref{Inline,,An Inline Function is As Fast As a Macro}.
2666Using this option is roughly equivalent to adding the
2667@code{gnu_inline} function attribute to all inline functions
2668(@pxref{Function Attributes}).
2669
2670The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2671C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2672specifies the default behavior).
2673This option is not supported in @option{-std=c90} or
2674@option{-std=gnu90} mode.
2675
2676The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2677@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2678in effect for @code{inline} functions. @xref{Common Predefined
2679Macros,,,cpp,The C Preprocessor}.
2680
d77de738
ML
2681@opindex fhosted
2682@cindex hosted environment
f33d7a88 2683@item -fhosted
d77de738
ML
2684
2685Assert that compilation targets a hosted environment. This implies
2686@option{-fbuiltin}. A hosted environment is one in which the
2687entire standard library is available, and in which @code{main} has a return
2688type of @code{int}. Examples are nearly everything except a kernel.
2689This is equivalent to @option{-fno-freestanding}.
2690
d77de738 2691@opindex flax-vector-conversions
ddf6fe37 2692@item -flax-vector-conversions
d77de738
ML
2693Allow implicit conversions between vectors with differing numbers of
2694elements and/or incompatible element types. This option should not be
2695used for new code.
2696
d77de738 2697@opindex fms-extensions
ddf6fe37 2698@item -fms-extensions
d77de738
ML
2699Accept some non-standard constructs used in Microsoft header files.
2700
2701In C++ code, this allows member names in structures to be similar
2702to previous types declarations.
2703
2704@smallexample
2705typedef int UOW;
2706struct ABC @{
2707 UOW UOW;
2708@};
2709@end smallexample
2710
2711Some cases of unnamed fields in structures and unions are only
2712accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2713fields within structs/unions}, for details.
2714
2715Note that this option is off for all targets except for x86
2716targets using ms-abi.
2717
ddf6fe37 2718@opindex foffload
d77de738
ML
2719@cindex Offloading targets
2720@cindex OpenACC offloading targets
2721@cindex OpenMP offloading targets
f33d7a88
AA
2722@item -foffload=disable
2723@itemx -foffload=default
2724@itemx -foffload=@var{target-list}
d77de738
ML
2725Specify for which OpenMP and OpenACC offload targets code should be generated.
2726The default behavior, equivalent to @option{-foffload=default}, is to generate
2727code for all supported offload targets. The @option{-foffload=disable} form
2728generates code only for the host fallback, while
2729@option{-foffload=@var{target-list}} generates code only for the specified
2730comma-separated list of offload targets.
2731
2732Offload targets are specified in GCC's internal target-triplet format. You can
2733run the compiler with @option{-v} to show the list of configured offload targets
2734under @code{OFFLOAD_TARGET_NAMES}.
2735
ddf6fe37 2736@opindex foffload-options
d77de738
ML
2737@cindex Offloading options
2738@cindex OpenACC offloading options
2739@cindex OpenMP offloading options
f33d7a88
AA
2740@item -foffload-options=@var{options}
2741@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2742
2743With @option{-foffload-options=@var{options}}, GCC passes the specified
2744@var{options} to the compilers for all enabled offloading targets. You can
2745specify options that apply only to a specific target or targets by using
2746the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2747@var{target-list} is a comma-separated list in the same format as for the
2748@option{-foffload=} option.
2749
2750Typical command lines are
2751
2752@smallexample
4bcb46b3 2753-foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic
e9c1679c 2754-foffload-options=amdgcn-amdhsa=-march=gfx906
d77de738
ML
2755@end smallexample
2756
d77de738
ML
2757@opindex fopenacc
2758@cindex OpenACC accelerator programming
f33d7a88 2759@item -fopenacc
643a5223
TB
2760Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
2761@samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
2762@samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified,
2763the compiler generates accelerated code according to the OpenACC Application
d77de738
ML
2764Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2765implies @option{-pthread}, and thus is only supported on targets that
2766have support for @option{-pthread}.
2767
d77de738
ML
2768@opindex fopenacc-dim
2769@cindex OpenACC accelerator programming
f33d7a88 2770@item -fopenacc-dim=@var{geom}
d77de738
ML
2771Specify default compute dimensions for parallel offload regions that do
2772not explicitly specify. The @var{geom} value is a triple of
2773':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2774can be omitted, to use a target-specific default value.
2775
d77de738
ML
2776@opindex fopenmp
2777@cindex OpenMP parallel
f33d7a88 2778@item -fopenmp
75e5a467 2779Enable handling of OpenMP directives @samp{#pragma omp},
643a5223 2780@samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and
75e5a467 2781@samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It
643a5223
TB
2782additionally enables the conditional compilation sentinel @samp{!$} in
2783Fortran. In fixed source form Fortran, the sentinels can also start with
2784@samp{c} or @samp{*}. When @option{-fopenmp} is specified, the
d77de738
ML
2785compiler generates parallel code according to the OpenMP Application
2786Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2787implies @option{-pthread}, and thus is only supported on targets that
2788have support for @option{-pthread}. @option{-fopenmp} implies
2789@option{-fopenmp-simd}.
2790
d77de738
ML
2791@opindex fopenmp-simd
2792@cindex OpenMP SIMD
2793@cindex SIMD
f33d7a88 2794@item -fopenmp-simd
d77de738 2795Enable handling of OpenMP's @code{simd}, @code{declare simd},
1fab441d
TB
2796@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
2797and @code{loop} directive, and of combined or composite directives with
75e5a467 2798@code{simd} as constituent with @code{#pragma omp},
1fab441d 2799@code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
75e5a467 2800@code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
643a5223
TB
2801additionally enables the conditional compilation sentinel @samp{!$} in
2802Fortran. In fixed source form Fortran, the sentinels can also start with
2803@samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
2804@option{-fopenmp} is additionally specified, the @code{loop} region binds
2805to the current task region, independent of the specified @code{bind} clause.
d77de738 2806
ddf6fe37 2807@opindex fopenmp-target-simd-clone
f33d7a88 2808@cindex OpenMP target SIMD clone
309e2d95
SL
2809@item -fopenmp-target-simd-clone
2810@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2811In addition to generating SIMD clones for functions marked with the
2812@code{declare simd} directive, GCC also generates clones
2813for functions marked with the OpenMP @code{declare target} directive
2814that are suitable for vectorization when this option is in effect. The
2815@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2816and @code{any}, which correspond to keywords for the @code{device_type}
2817clause of the @code{declare target} directive; clones are generated for
2818the intersection of devices specified.
2819@option{-fopenmp-target-simd-clone} is equivalent to
2820@option{-fopenmp-target-simd-clone=any} and
2821@option{-fno-openmp-target-simd-clone} is equivalent to
2822@option{-fopenmp-target-simd-clone=none}.
2823
2824At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2825optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2826it is disabled by default.
2827
d77de738
ML
2828@opindex fpermitted-flt-eval-methods
2829@opindex fpermitted-flt-eval-methods=c11
2830@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2831@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2832ISO/IEC TS 18661-3 defines new permissible values for
2833@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2834a semantic type that is an interchange or extended format should be
2835evaluated to the precision and range of that type. These new values are
2836a superset of those permitted under C99/C11, which does not specify the
2837meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2838conforming to C11 may not have been written expecting the possibility of
2839the new values.
2840
2841@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2842should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2843or the extended set of values specified in ISO/IEC TS 18661-3.
2844
2845@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2846
2847The default when in a standards compliant mode (@option{-std=c11} or similar)
2848is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2849dialect (@option{-std=gnu11} or similar) is
2850@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2851
024f135a
BB
2852@opindex fdeps-
2853The @samp{-fdeps-*} options are used to extract structured dependency
2854information for a source. This involves determining what resources provided by
2855other source files will be required to compile the source as well as what
2856resources are provided by the source. This information can be used to add
2857required dependencies between compilation rules of dependent sources based on
2858their contents rather than requiring such information be reflected within the
2859build tools as well.
2860
2861@opindex fdeps-file
2862@item -fdeps-file=@var{file}
2863Where to write structured dependency information.
2864
2865@opindex fdeps-format
2866@item -fdeps-format=@var{format}
2867The format to use for structured dependency information. @samp{p1689r5} is the
2868only supported format right now. Note that when this argument is specified, the
2869output of @samp{-MF} is stripped of some information (namely C++ modules) so
2870that it does not use extended makefile syntax not understood by most tools.
2871
2872@opindex fdeps-target
2873@item -fdeps-target=@var{file}
2874Analogous to @option{-MT} but for structured dependency information. This
2875indicates the target which will ultimately need any required resources and
2876provide any resources extracted from the source that may be required by other
2877sources.
2878
d77de738 2879@opindex fplan9-extensions
ddf6fe37 2880@item -fplan9-extensions
d77de738
ML
2881Accept some non-standard constructs used in Plan 9 code.
2882
2883This enables @option{-fms-extensions}, permits passing pointers to
2884structures with anonymous fields to functions that expect pointers to
2885elements of the type of the field, and permits referring to anonymous
2886fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2887struct/union fields within structs/unions}, for details. This is only
2888supported for C, not C++.
2889
d77de738
ML
2890@opindex fsigned-bitfields
2891@opindex funsigned-bitfields
2892@opindex fno-signed-bitfields
2893@opindex fno-unsigned-bitfields
ddf6fe37
AA
2894@item -fsigned-bitfields
2895@itemx -funsigned-bitfields
2896@itemx -fno-signed-bitfields
2897@itemx -fno-unsigned-bitfields
d77de738
ML
2898These options control whether a bit-field is signed or unsigned, when the
2899declaration does not use either @code{signed} or @code{unsigned}. By
2900default, such a bit-field is signed, because this is consistent: the
2901basic integer types such as @code{int} are signed types.
2902
d77de738 2903@opindex fsigned-char
ddf6fe37 2904@item -fsigned-char
d77de738
ML
2905Let the type @code{char} be signed, like @code{signed char}.
2906
2907Note that this is equivalent to @option{-fno-unsigned-char}, which is
2908the negative form of @option{-funsigned-char}. Likewise, the option
2909@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2910
d77de738 2911@opindex funsigned-char
ddf6fe37 2912@item -funsigned-char
d77de738
ML
2913Let the type @code{char} be unsigned, like @code{unsigned char}.
2914
2915Each kind of machine has a default for what @code{char} should
2916be. It is either like @code{unsigned char} by default or like
2917@code{signed char} by default.
2918
2919Ideally, a portable program should always use @code{signed char} or
2920@code{unsigned char} when it depends on the signedness of an object.
2921But many programs have been written to use plain @code{char} and
2922expect it to be signed, or expect it to be unsigned, depending on the
2923machines they were written for. This option, and its inverse, let you
2924make such a program work with the opposite default.
2925
2926The type @code{char} is always a distinct type from each of
2927@code{signed char} or @code{unsigned char}, even though its behavior
2928is always just like one of those two.
2929
d77de738
ML
2930@opindex fstrict-flex-arrays
2931@opindex fno-strict-flex-arrays
ddf6fe37 2932@item -fstrict-flex-arrays
d77de738
ML
2933Control when to treat the trailing array of a structure as a flexible array
2934member for the purpose of accessing the elements of such an array.
2935The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2936strictest. A trailing array is treated as a flexible array member only when it
2937is declared as a flexible array member per C99 standard onwards.
2938The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2939least strict. All trailing arrays of structures are treated as flexible array
2940members.
2941
d77de738 2942@opindex fstrict-flex-arrays=@var{level}
ddf6fe37 2943@item -fstrict-flex-arrays=@var{level}
d77de738
ML
2944Control when to treat the trailing array of a structure as a flexible array
2945member for the purpose of accessing the elements of such an array. The value
2946of @var{level} controls the level of strictness.
2947
2948The possible values of @var{level} are the same as for the
2949@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2950
2951You can control this behavior for a specific trailing array field of a
2952structure by using the variable attribute @code{strict_flex_array} attribute
2953(@pxref{Variable Attributes}).
2954
d77de738 2955@opindex fsso-struct
ddf6fe37 2956@item -fsso-struct=@var{endianness}
d77de738
ML
2957Set the default scalar storage order of structures and unions to the
2958specified endianness. The accepted values are @samp{big-endian},
2959@samp{little-endian} and @samp{native} for the native endianness of
2960the target (the default). This option is not supported for C++.
2961
2962@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2963code that is not binary compatible with code generated without it if the
2964specified endianness is not the native endianness of the target.
2965@end table
2966
2967@node C++ Dialect Options
2968@section Options Controlling C++ Dialect
2969
2970@cindex compiler options, C++
2971@cindex C++ options, command-line
2972@cindex options, C++
2973This section describes the command-line options that are only meaningful
2974for C++ programs. You can also use most of the GNU compiler options
2975regardless of what language your program is in. For example, you
2976might compile a file @file{firstClass.C} like this:
2977
2978@smallexample
2979g++ -g -fstrict-enums -O -c firstClass.C
2980@end smallexample
2981
2982@noindent
2983In this example, only @option{-fstrict-enums} is an option meant
2984only for C++ programs; you can use the other options with any
2985language supported by GCC@.
2986
2987Some options for compiling C programs, such as @option{-std}, are also
2988relevant for C++ programs.
2989@xref{C Dialect Options,,Options Controlling C Dialect}.
2990
2991Here is a list of options that are @emph{only} for compiling C++ programs:
2992
2993@table @gcctabopt
2994
d77de738 2995@opindex fabi-version
ddf6fe37 2996@item -fabi-version=@var{n}
d77de738
ML
2997Use version @var{n} of the C++ ABI@. The default is version 0.
2998
2999Version 0 refers to the version conforming most closely to
3000the C++ ABI specification. Therefore, the ABI obtained using version 0
3001will change in different versions of G++ as ABI bugs are fixed.
3002
3003Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
3004
3005Version 2 is the version of the C++ ABI that first appeared in G++
30063.4, and was the default through G++ 4.9.
3007
3008Version 3 corrects an error in mangling a constant address as a
3009template argument.
3010
3011Version 4, which first appeared in G++ 4.5, implements a standard
3012mangling for vector types.
3013
3014Version 5, which first appeared in G++ 4.6, corrects the mangling of
3015attribute const/volatile on function pointer types, decltype of a
3016plain decl, and use of a function parameter in the declaration of
3017another parameter.
3018
3019Version 6, which first appeared in G++ 4.7, corrects the promotion
3020behavior of C++11 scoped enums and the mangling of template argument
3021packs, const/static_cast, prefix ++ and --, and a class scope function
3022used as a template argument.
3023
3024Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
3025builtin type and corrects the mangling of lambdas in default argument
3026scope.
3027
3028Version 8, which first appeared in G++ 4.9, corrects the substitution
3029behavior of function types with function-cv-qualifiers.
3030
3031Version 9, which first appeared in G++ 5.2, corrects the alignment of
3032@code{nullptr_t}.
3033
3034Version 10, which first appeared in G++ 6.1, adds mangling of
3035attributes that affect type identity, such as ia32 calling convention
3036attributes (e.g.@: @samp{stdcall}).
3037
3038Version 11, which first appeared in G++ 7, corrects the mangling of
3039sizeof... expressions and operator names. For multiple entities with
3040the same name within a function, that are declared in different scopes,
3041the mangling now changes starting with the twelfth occurrence. It also
3042implies @option{-fnew-inheriting-ctors}.
3043
3044Version 12, which first appeared in G++ 8, corrects the calling
3045conventions for empty classes on the x86_64 target and for classes
3046with only deleted copy/move constructors. It accidentally changes the
3047calling convention for classes with a deleted copy constructor and a
3048trivial move constructor.
3049
3050Version 13, which first appeared in G++ 8.2, fixes the accidental
3051change in version 12.
3052
3053Version 14, which first appeared in G++ 10, corrects the mangling of
3054the nullptr expression.
3055
3056Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
3057tag regression.
3058
3059Version 16, which first appeared in G++ 11, changes the mangling of
3060@code{__alignof__} to be distinct from that of @code{alignof}, and
3061dependent operator names.
3062
3063Version 17, which first appeared in G++ 12, fixes layout of classes
3064that inherit from aggregate classes with default member initializers
3065in C++14 and up.
3066
3067Version 18, which first appeard in G++ 13, fixes manglings of lambdas
3068that have additional context.
3069
cd37325b
JJ
3070Version 19, which first appeard in G++ 14, fixes manglings of structured
3071bindings to include ABI tags.
3072
d77de738
ML
3073See also @option{-Wabi}.
3074
d77de738 3075@opindex fabi-compat-version
ddf6fe37 3076@item -fabi-compat-version=@var{n}
d77de738
ML
3077On targets that support strong aliases, G++
3078works around mangling changes by creating an alias with the correct
3079mangled name when defining a symbol with an incorrect mangled name.
3080This switch specifies which ABI version to use for the alias.
3081
3082With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3083compatibility). If another ABI version is explicitly selected, this
3084defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3085use @option{-fabi-compat-version=2}.
3086
3087If this option is not provided but @option{-Wabi=@var{n}} is, that
3088version is used for compatibility aliases. If this option is provided
3089along with @option{-Wabi} (without the version), the version from this
3090option is used for the warning.
3091
d77de738
ML
3092@opindex fno-access-control
3093@opindex faccess-control
ddf6fe37 3094@item -fno-access-control
d77de738
ML
3095Turn off all access checking. This switch is mainly useful for working
3096around bugs in the access control code.
3097
d77de738 3098@opindex faligned-new
ddf6fe37 3099@item -faligned-new
d77de738
ML
3100Enable support for C++17 @code{new} of types that require more
3101alignment than @code{void* ::operator new(std::size_t)} provides. A
3102numeric argument such as @code{-faligned-new=32} can be used to
3103specify how much alignment (in bytes) is provided by that function,
3104but few users will need to override the default of
3105@code{alignof(std::max_align_t)}.
3106
3107This flag is enabled by default for @option{-std=c++17}.
3108
d77de738
ML
3109@opindex fchar8_t
3110@opindex fno-char8_t
ddf6fe37
AA
3111@item -fchar8_t
3112@itemx -fno-char8_t
d77de738
ML
3113Enable support for @code{char8_t} as adopted for C++20. This includes
3114the addition of a new @code{char8_t} fundamental type, changes to the
3115types of UTF-8 string and character literals, new signatures for
3116user-defined literals, associated standard library updates, and new
3117@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3118
3119This option enables functions to be overloaded for ordinary and UTF-8
3120strings:
3121
3122@smallexample
3123int f(const char *); // #1
3124int f(const char8_t *); // #2
3125int v1 = f("text"); // Calls #1
3126int v2 = f(u8"text"); // Calls #2
3127@end smallexample
3128
3129@noindent
3130and introduces new signatures for user-defined literals:
3131
3132@smallexample
3133int operator""_udl1(char8_t);
3134int v3 = u8'x'_udl1;
3135int operator""_udl2(const char8_t*, std::size_t);
3136int v4 = u8"text"_udl2;
3137template<typename T, T...> int operator""_udl3();
3138int v5 = u8"text"_udl3;
3139@end smallexample
3140
3141@noindent
3142The change to the types of UTF-8 string and character literals introduces
3143incompatibilities with ISO C++11 and later standards. For example, the
3144following code is well-formed under ISO C++11, but is ill-formed when
3145@option{-fchar8_t} is specified.
3146
3147@smallexample
d77de738
ML
3148const char *cp = u8"xx";// error: invalid conversion from
3149 // `const char8_t*' to `const char*'
3150int f(const char*);
3151auto v = f(u8"xx"); // error: invalid conversion from
3152 // `const char8_t*' to `const char*'
3153std::string s@{u8"xx"@}; // error: no matching function for call to
3154 // `std::basic_string<char>::basic_string()'
3155using namespace std::literals;
3156s = u8"xx"s; // error: conversion from
3157 // `basic_string<char8_t>' to non-scalar
3158 // type `basic_string<char>' requested
3159@end smallexample
3160
d77de738 3161@opindex fcheck-new
ddf6fe37 3162@item -fcheck-new
d77de738
ML
3163Check that the pointer returned by @code{operator new} is non-null
3164before attempting to modify the storage allocated. This check is
3165normally unnecessary because the C++ standard specifies that
3166@code{operator new} only returns @code{0} if it is declared
3167@code{throw()}, in which case the compiler always checks the
3168return value even without this option. In all other cases, when
3169@code{operator new} has a non-empty exception specification, memory
3170exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3171@samp{new (nothrow)}.
3172
d77de738
ML
3173@opindex fconcepts
3174@opindex fconcepts-ts
ddf6fe37
AA
3175@item -fconcepts
3176@itemx -fconcepts-ts
d77de738
ML
3177Enable support for the C++ Concepts feature for constraining template
3178arguments. With @option{-std=c++20} and above, Concepts are part of
3179the language standard, so @option{-fconcepts} defaults to on.
3180
3181Some constructs that were allowed by the earlier C++ Extensions for
3182Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3183into the standard, can additionally be enabled by
3184@option{-fconcepts-ts}.
3185
d77de738 3186@opindex fconstexpr-depth
ddf6fe37 3187@item -fconstexpr-depth=@var{n}
d77de738
ML
3188Set the maximum nested evaluation depth for C++11 constexpr functions
3189to @var{n}. A limit is needed to detect endless recursion during
3190constant expression evaluation. The minimum specified by the standard
3191is 512.
3192
d77de738 3193@opindex fconstexpr-cache-depth
ddf6fe37 3194@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3195Set the maximum level of nested evaluation depth for C++11 constexpr
3196functions that will be cached to @var{n}. This is a heuristic that
3197trades off compilation speed (when the cache avoids repeated
3198calculations) against memory consumption (when the cache grows very
3199large from highly recursive evaluations). The default is 8. Very few
3200users are likely to want to adjust it, but if your code does heavy
3201constexpr calculations you might want to experiment to find which
3202value works best for you.
3203
d77de738 3204@opindex fconstexpr-fp-except
ddf6fe37 3205@item -fconstexpr-fp-except
d77de738
ML
3206Annex F of the C standard specifies that IEC559 floating point
3207exceptions encountered at compile time should not stop compilation.
3208C++ compilers have historically not followed this guidance, instead
3209treating floating point division by zero as non-constant even though
3210it has a well defined value. This flag tells the compiler to give
3211Annex F priority over other rules saying that a particular operation
3212is undefined.
3213
3214@smallexample
3215constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3216@end smallexample
3217
d77de738 3218@opindex fconstexpr-loop-limit
ddf6fe37 3219@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3220Set the maximum number of iterations for a loop in C++14 constexpr functions
3221to @var{n}. A limit is needed to detect infinite loops during
3222constant expression evaluation. The default is 262144 (1<<18).
3223
d77de738 3224@opindex fconstexpr-ops-limit
ddf6fe37 3225@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3226Set the maximum number of operations during a single constexpr evaluation.
3227Even when number of iterations of a single loop is limited with the above limit,
3228if there are several nested loops and each of them has many iterations but still
3229smaller than the above limit, or if in a body of some loop or even outside
3230of a loop too many expressions need to be evaluated, the resulting constexpr
3231evaluation might take too long.
3232The default is 33554432 (1<<25).
3233
2efb237f 3234@opindex fcontracts
ddf6fe37 3235@item -fcontracts
2efb237f
JCI
3236Enable experimental support for the C++ Contracts feature, as briefly
3237added to and then removed from the C++20 working paper (N4820). The
3238implementation also includes proposed enhancements from papers P1290,
3239P1332, and P1429. This functionality is intended mostly for those
3240interested in experimentation towards refining the feature to get it
3241into shape for a future C++ standard.
3242
3243On violation of a checked contract, the violation handler is called.
3244Users can replace the violation handler by defining
3245@smallexample
4ace81b6
SL
3246void
3247handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3248@end smallexample
3249
3250There are different sets of additional flags that can be used together
3251to specify which contracts will be checked and how, for N4820
3252contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3253used together.
3254
3255@table @gcctabopt
2efb237f 3256@opindex fcontract-mode
ddf6fe37 3257@item -fcontract-mode=[on|off]
2efb237f
JCI
3258Control whether any contracts have any semantics at all. Defaults to on.
3259
2efb237f 3260@opindex fcontract-assumption-mode
ddf6fe37 3261@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3262[N4820] Control whether contracts with level @samp{axiom}
3263should have the assume semantic. Defaults to on.
3264
2efb237f 3265@opindex fcontract-build-level
ddf6fe37 3266@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3267[N4820] Specify which level of contracts to generate checks
3268for. Defaults to @samp{default}.
3269
2efb237f 3270@opindex fcontract-continuation-mode
ddf6fe37 3271@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3272[N4820] Control whether to allow the program to continue executing
3273after a contract violation. That is, do checked contracts have the
3274@samp{maybe} semantic described below rather than the @samp{never}
3275semantic. Defaults to off.
3276
2efb237f 3277@opindex fcontract-role
ddf6fe37 3278@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3279[P1332] Specify the concrete semantics for each contract level
3280of a particular contract role.
3281
3282@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3283[P1429] Specify the concrete semantic for a particular
3284contract level.
3285
2efb237f 3286@opindex fcontract-strict-declarations
ddf6fe37 3287@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3288Control whether to reject adding contracts to a function after its
3289first declaration. Defaults to off.
3290@end table
3291
3292The possible concrete semantics for that can be specified with
3293@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3294
3295@table @code
3296@item ignore
3297This contract has no effect.
3298
3299@item assume
3300This contract is treated like C++23 @code{[[assume]]}.
3301
3302@item check_never_continue
3303@itemx never
3304@itemx abort
3305This contract is checked. If it fails, the violation handler is
3306called. If the handler returns, @code{std::terminate} is called.
3307
3308@item check_maybe_continue
3309@itemx maybe
3310This contract is checked. If it fails, the violation handler is
3311called. If the handler returns, execution continues normally.
3312@end table
3313
d77de738 3314@opindex fcoroutines
ddf6fe37 3315@item -fcoroutines
d77de738
ML
3316Enable support for the C++ coroutines extension (experimental).
3317
d77de738
ML
3318@opindex fno-elide-constructors
3319@opindex felide-constructors
ddf6fe37 3320@item -fno-elide-constructors
d77de738
ML
3321The C++ standard allows an implementation to omit creating a temporary
3322that is only used to initialize another object of the same type.
3323Specifying this option disables that optimization, and forces G++ to
3324call the copy constructor in all cases. This option also causes G++
3325to call trivial member functions which otherwise would be expanded inline.
3326
3327In C++17, the compiler is required to omit these temporaries, but this
3328option still affects trivial member functions.
3329
d77de738
ML
3330@opindex fno-enforce-eh-specs
3331@opindex fenforce-eh-specs
ddf6fe37 3332@item -fno-enforce-eh-specs
d77de738
ML
3333Don't generate code to check for violation of exception specifications
3334at run time. This option violates the C++ standard, but may be useful
3335for reducing code size in production builds, much like defining
3336@code{NDEBUG}. This does not give user code permission to throw
3337exceptions in violation of the exception specifications; the compiler
3338still optimizes based on the specifications, so throwing an
3339unexpected exception results in undefined behavior at run time.
3340
d77de738
ML
3341@opindex fextern-tls-init
3342@opindex fno-extern-tls-init
ddf6fe37
AA
3343@item -fextern-tls-init
3344@itemx -fno-extern-tls-init
d77de738
ML
3345The C++11 and OpenMP standards allow @code{thread_local} and
3346@code{threadprivate} variables to have dynamic (runtime)
3347initialization. To support this, any use of such a variable goes
3348through a wrapper function that performs any necessary initialization.
3349When the use and definition of the variable are in the same
3350translation unit, this overhead can be optimized away, but when the
3351use is in a different translation unit there is significant overhead
3352even if the variable doesn't actually need dynamic initialization. If
3353the programmer can be sure that no use of the variable in a
3354non-defining TU needs to trigger dynamic initialization (either
3355because the variable is statically initialized, or a use of the
3356variable in the defining TU will be executed before any uses in
3357another TU), they can avoid this overhead with the
3358@option{-fno-extern-tls-init} option.
3359
3360On targets that support symbol aliases, the default is
3361@option{-fextern-tls-init}. On targets that do not support symbol
3362aliases, the default is @option{-fno-extern-tls-init}.
3363
d77de738
ML
3364@opindex ffold-simple-inlines
3365@opindex fno-fold-simple-inlines
ddf6fe37
AA
3366@item -ffold-simple-inlines
3367@itemx -fno-fold-simple-inlines
d77de738
ML
3368Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3369@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3370means no debug information will be generated for such calls. Since these
3371functions are rarely interesting to debug, this flag is enabled by default
3372unless @option{-fno-inline} is active.
3373
d77de738
ML
3374@opindex fno-gnu-keywords
3375@opindex fgnu-keywords
ddf6fe37 3376@item -fno-gnu-keywords
d77de738
ML
3377Do not recognize @code{typeof} as a keyword, so that code can use this
3378word as an identifier. You can use the keyword @code{__typeof__} instead.
3379This option is implied by the strict ISO C++ dialects: @option{-ansi},
3380@option{-std=c++98}, @option{-std=c++11}, etc.
3381
d77de738 3382@opindex fimplicit-constexpr
ddf6fe37 3383@item -fimplicit-constexpr
d77de738
ML
3384Make inline functions implicitly constexpr, if they satisfy the
3385requirements for a constexpr function. This option can be used in
3386C++14 mode or later. This can result in initialization changing from
3387dynamic to static and other optimizations.
3388
d77de738
ML
3389@opindex fno-implicit-templates
3390@opindex fimplicit-templates
ddf6fe37 3391@item -fno-implicit-templates
d77de738
ML
3392Never emit code for non-inline templates that are instantiated
3393implicitly (i.e.@: by use); only emit code for explicit instantiations.
3394If you use this option, you must take care to structure your code to
3395include all the necessary explicit instantiations to avoid getting
3396undefined symbols at link time.
3397@xref{Template Instantiation}, for more information.
3398
d77de738
ML
3399@opindex fno-implicit-inline-templates
3400@opindex fimplicit-inline-templates
ddf6fe37 3401@item -fno-implicit-inline-templates
d77de738
ML
3402Don't emit code for implicit instantiations of inline templates, either.
3403The default is to handle inlines differently so that compiles with and
3404without optimization need the same set of explicit instantiations.
3405
d77de738
ML
3406@opindex fno-implement-inlines
3407@opindex fimplement-inlines
ddf6fe37 3408@item -fno-implement-inlines
d77de738
ML
3409To save space, do not emit out-of-line copies of inline functions
3410controlled by @code{#pragma implementation}. This causes linker
3411errors if these functions are not inlined everywhere they are called.
3412
d77de738
ML
3413@opindex fmodules-ts
3414@opindex fno-modules-ts
ddf6fe37
AA
3415@item -fmodules-ts
3416@itemx -fno-modules-ts
d77de738
ML
3417Enable support for C++20 modules (@pxref{C++ Modules}). The
3418@option{-fno-modules-ts} is usually not needed, as that is the
3419default. Even though this is a C++20 feature, it is not currently
3420implicitly enabled by selecting that standard version.
3421
ddf6fe37 3422@opindex fmodule-header
d77de738
ML
3423@item -fmodule-header
3424@itemx -fmodule-header=user
3425@itemx -fmodule-header=system
d77de738
ML
3426Compile a header file to create an importable header unit.
3427
d77de738 3428@opindex fmodule-implicit-inline
ddf6fe37 3429@item -fmodule-implicit-inline
d77de738
ML
3430Member functions defined in their class definitions are not implicitly
3431inline for modular code. This is different to traditional C++
3432behavior, for good reasons. However, it may result in a difficulty
3433during code porting. This option makes such function definitions
3434implicitly inline. It does however generate an ABI incompatibility,
3435so you must use it everywhere or nowhere. (Such definitions outside
3436of a named module remain implicitly inline, regardless.)
3437
d77de738
ML
3438@opindex fno-module-lazy
3439@opindex fmodule-lazy
ddf6fe37 3440@item -fno-module-lazy
d77de738
ML
3441Disable lazy module importing and module mapper creation.
3442
f33d7a88
AA
3443@vindex CXX_MODULE_MAPPER @r{environment variable}
3444@opindex fmodule-mapper
d77de738
ML
3445@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3446@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3447@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3448@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3449@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3450@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3451An oracle to query for module name to filename mappings. If
3452unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3453and if that is unset, an in-process default is provided.
3454
d77de738 3455@opindex fmodule-only
ddf6fe37 3456@item -fmodule-only
d77de738
ML
3457Only emit the Compiled Module Interface, inhibiting any object file.
3458
d77de738 3459@opindex fms-extensions
ddf6fe37 3460@item -fms-extensions
d77de738
ML
3461Disable Wpedantic warnings about constructs used in MFC, such as implicit
3462int and getting a pointer to member function via non-standard syntax.
3463
d77de738 3464@opindex fnew-inheriting-ctors
ddf6fe37 3465@item -fnew-inheriting-ctors
d77de738
ML
3466Enable the P0136 adjustment to the semantics of C++11 constructor
3467inheritance. This is part of C++17 but also considered to be a Defect
3468Report against C++11 and C++14. This flag is enabled by default
3469unless @option{-fabi-version=10} or lower is specified.
3470
d77de738 3471@opindex fnew-ttp-matching
ddf6fe37 3472@item -fnew-ttp-matching
d77de738
ML
3473Enable the P0522 resolution to Core issue 150, template template
3474parameters and default arguments: this allows a template with default
3475template arguments as an argument for a template template parameter
3476with fewer template parameters. This flag is enabled by default for
3477@option{-std=c++17}.
3478
d77de738
ML
3479@opindex fno-nonansi-builtins
3480@opindex fnonansi-builtins
ddf6fe37 3481@item -fno-nonansi-builtins
d77de738
ML
3482Disable built-in declarations of functions that are not mandated by
3483ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3484@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3485
d77de738 3486@opindex fnothrow-opt
ddf6fe37 3487@item -fnothrow-opt
d77de738
ML
3488Treat a @code{throw()} exception specification as if it were a
3489@code{noexcept} specification to reduce or eliminate the text size
3490overhead relative to a function with no exception specification. If
3491the function has local variables of types with non-trivial
3492destructors, the exception specification actually makes the
3493function smaller because the EH cleanups for those variables can be
3494optimized away. The semantic effect is that an exception thrown out of
3495a function with such an exception specification results in a call
3496to @code{terminate} rather than @code{unexpected}.
3497
d77de738
ML
3498@opindex fno-operator-names
3499@opindex foperator-names
ddf6fe37 3500@item -fno-operator-names
d77de738
ML
3501Do not treat the operator name keywords @code{and}, @code{bitand},
3502@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3503synonyms as keywords.
3504
d77de738
ML
3505@opindex fno-optional-diags
3506@opindex foptional-diags
ddf6fe37 3507@item -fno-optional-diags
d77de738
ML
3508Disable diagnostics that the standard says a compiler does not need to
3509issue. Currently, the only such diagnostic issued by G++ is the one for
3510a name having multiple meanings within a class.
3511
d77de738
ML
3512@opindex fno-pretty-templates
3513@opindex fpretty-templates
ddf6fe37 3514@item -fno-pretty-templates
d77de738
ML
3515When an error message refers to a specialization of a function
3516template, the compiler normally prints the signature of the
3517template followed by the template arguments and any typedefs or
3518typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3519rather than @code{void f(int)}) so that it's clear which template is
3520involved. When an error message refers to a specialization of a class
3521template, the compiler omits any template arguments that match
3522the default template arguments for that template. If either of these
3523behaviors make it harder to understand the error message rather than
3524easier, you can use @option{-fno-pretty-templates} to disable them.
3525
d77de738
ML
3526@opindex fno-rtti
3527@opindex frtti
ddf6fe37 3528@item -fno-rtti
d77de738
ML
3529Disable generation of information about every class with virtual
3530functions for use by the C++ run-time type identification features
3531(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3532of the language, you can save some space by using this flag. Note that
3533exception handling uses the same information, but G++ generates it as
3534needed. The @code{dynamic_cast} operator can still be used for casts that
3535do not require run-time type information, i.e.@: casts to @code{void *} or to
3536unambiguous base classes.
3537
3538Mixing code compiled with @option{-frtti} with that compiled with
3539@option{-fno-rtti} may not work. For example, programs may
3540fail to link if a class compiled with @option{-fno-rtti} is used as a base
3541for a class compiled with @option{-frtti}.
3542
d77de738 3543@opindex fsized-deallocation
ddf6fe37 3544@item -fsized-deallocation
d77de738
ML
3545Enable the built-in global declarations
3546@smallexample
3547void operator delete (void *, std::size_t) noexcept;
3548void operator delete[] (void *, std::size_t) noexcept;
3549@end smallexample
3550as introduced in C++14. This is useful for user-defined replacement
3551deallocation functions that, for example, use the size of the object
3552to make deallocation faster. Enabled by default under
3553@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3554warns about places that might want to add a definition.
3555
d77de738 3556@opindex fstrict-enums
ddf6fe37 3557@item -fstrict-enums
d77de738
ML
3558Allow the compiler to optimize using the assumption that a value of
3559enumerated type can only be one of the values of the enumeration (as
3560defined in the C++ standard; basically, a value that can be
3561represented in the minimum number of bits needed to represent all the
3562enumerators). This assumption may not be valid if the program uses a
3563cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3564This option has no effect for an enumeration type with a fixed underlying
3565type.
d77de738 3566
d77de738 3567@opindex fstrong-eval-order
ddf6fe37 3568@item -fstrong-eval-order
d77de738
ML
3569Evaluate member access, array subscripting, and shift expressions in
3570left-to-right order, and evaluate assignment in right-to-left order,
3571as adopted for C++17. Enabled by default with @option{-std=c++17}.
3572@option{-fstrong-eval-order=some} enables just the ordering of member
3573access and shift expressions, and is the default without
3574@option{-std=c++17}.
3575
d77de738 3576@opindex ftemplate-backtrace-limit
ddf6fe37 3577@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3578Set the maximum number of template instantiation notes for a single
3579warning or error to @var{n}. The default value is 10.
3580
d77de738 3581@opindex ftemplate-depth
ddf6fe37 3582@item -ftemplate-depth=@var{n}
d77de738
ML
3583Set the maximum instantiation depth for template classes to @var{n}.
3584A limit on the template instantiation depth is needed to detect
3585endless recursions during template class instantiation. ANSI/ISO C++
3586conforming programs must not rely on a maximum depth greater than 17
3587(changed to 1024 in C++11). The default value is 900, as the compiler
3588can run out of stack space before hitting 1024 in some situations.
3589
d77de738
ML
3590@opindex fno-threadsafe-statics
3591@opindex fthreadsafe-statics
ddf6fe37 3592@item -fno-threadsafe-statics
d77de738
ML
3593Do not emit the extra code to use the routines specified in the C++
3594ABI for thread-safe initialization of local statics. You can use this
3595option to reduce code size slightly in code that doesn't need to be
3596thread-safe.
3597
d77de738 3598@opindex fuse-cxa-atexit
ddf6fe37 3599@item -fuse-cxa-atexit
d77de738
ML
3600Register destructors for objects with static storage duration with the
3601@code{__cxa_atexit} function rather than the @code{atexit} function.
3602This option is required for fully standards-compliant handling of static
3603destructors, but only works if your C library supports
3604@code{__cxa_atexit}.
3605
d77de738
ML
3606@opindex fno-use-cxa-get-exception-ptr
3607@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3608@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3609Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3610causes @code{std::uncaught_exception} to be incorrect, but is necessary
3611if the runtime routine is not available.
3612
d77de738 3613@opindex fvisibility-inlines-hidden
ddf6fe37 3614@item -fvisibility-inlines-hidden
d77de738
ML
3615This switch declares that the user does not attempt to compare
3616pointers to inline functions or methods where the addresses of the two functions
3617are taken in different shared objects.
3618
3619The effect of this is that GCC may, effectively, mark inline methods with
3620@code{__attribute__ ((visibility ("hidden")))} so that they do not
3621appear in the export table of a DSO and do not require a PLT indirection
3622when used within the DSO@. Enabling this option can have a dramatic effect
3623on load and link times of a DSO as it massively reduces the size of the
3624dynamic export table when the library makes heavy use of templates.
3625
3626The behavior of this switch is not quite the same as marking the
3627methods as hidden directly, because it does not affect static variables
3628local to the function or cause the compiler to deduce that
3629the function is defined in only one shared object.
3630
3631You may mark a method as having a visibility explicitly to negate the
3632effect of the switch for that method. For example, if you do want to
3633compare pointers to a particular inline method, you might mark it as
3634having default visibility. Marking the enclosing class with explicit
3635visibility has no effect.
3636
3637Explicitly instantiated inline methods are unaffected by this option
3638as their linkage might otherwise cross a shared library boundary.
3639@xref{Template Instantiation}.
3640
d77de738 3641@opindex fvisibility-ms-compat
ddf6fe37 3642@item -fvisibility-ms-compat
d77de738
ML
3643This flag attempts to use visibility settings to make GCC's C++
3644linkage model compatible with that of Microsoft Visual Studio.
3645
3646The flag makes these changes to GCC's linkage model:
3647
3648@enumerate
3649@item
3650It sets the default visibility to @code{hidden}, like
3651@option{-fvisibility=hidden}.
3652
3653@item
3654Types, but not their members, are not hidden by default.
3655
3656@item
3657The One Definition Rule is relaxed for types without explicit
3658visibility specifications that are defined in more than one
3659shared object: those declarations are permitted if they are
3660permitted when this option is not used.
3661@end enumerate
3662
3663In new code it is better to use @option{-fvisibility=hidden} and
3664export those classes that are intended to be externally visible.
3665Unfortunately it is possible for code to rely, perhaps accidentally,
3666on the Visual Studio behavior.
3667
3668Among the consequences of these changes are that static data members
3669of the same type with the same name but defined in different shared
3670objects are different, so changing one does not change the other;
3671and that pointers to function members defined in different shared
3672objects may not compare equal. When this flag is given, it is a
3673violation of the ODR to define types with the same name differently.
3674
d77de738
ML
3675@opindex fno-weak
3676@opindex fweak
ddf6fe37 3677@item -fno-weak
d77de738
ML
3678Do not use weak symbol support, even if it is provided by the linker.
3679By default, G++ uses weak symbols if they are available. This
3680option exists only for testing, and should not be used by end-users;
3681it results in inferior code and has no benefits. This option may
3682be removed in a future release of G++.
3683
d77de738
ML
3684@opindex fext-numeric-literals
3685@opindex fno-ext-numeric-literals
ddf6fe37 3686@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3687Accept imaginary, fixed-point, or machine-defined
3688literal number suffixes as GNU extensions.
3689When this option is turned off these suffixes are treated
3690as C++11 user-defined literal numeric suffixes.
3691This is on by default for all pre-C++11 dialects and all GNU dialects:
3692@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3693@option{-std=gnu++14}.
3694This option is off by default
3695for ISO C++11 onwards (@option{-std=c++11}, ...).
3696
d77de738 3697@opindex nostdinc++
ddf6fe37 3698@item -nostdinc++
d77de738
ML
3699Do not search for header files in the standard directories specific to
3700C++, but do still search the other standard directories. (This option
3701is used when building the C++ library.)
3702
ddf6fe37
AA
3703@opindex flang-info-include-translate
3704@opindex flang-info-include-translate-not
d77de738
ML
3705@item -flang-info-include-translate
3706@itemx -flang-info-include-translate-not
3707@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3708Inform of include translation events. The first will note accepted
3709include translations, the second will note declined include
3710translations. The @var{header} form will inform of include
3711translations relating to that specific header. If @var{header} is of
3712the form @code{"user"} or @code{<system>} it will be resolved to a
3713specific user or system header using the include path.
3714
ddf6fe37 3715@opindex flang-info-module-cmi
d77de738
ML
3716@item -flang-info-module-cmi
3717@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3718Inform of Compiled Module Interface pathnames. The first will note
3719all read CMI pathnames. The @var{module} form will not reading a
3720specific module's CMI. @var{module} may be a named module or a
3721header-unit (the latter indicated by either being a pathname containing
3722directory separators or enclosed in @code{<>} or @code{""}).
3723
d77de738 3724@opindex stdlib
ddf6fe37 3725@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3726When G++ is configured to support this option, it allows specification of
3727alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3728(the default, native C++ runtime for G++) and @var{libc++} which is the
3729C++ runtime installed on some operating systems (e.g. Darwin versions from
3730Darwin11 onwards). The option switches G++ to use the headers from the
3731specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3732when a C++ runtime is required for linking.
3733@end table
3734
3735In addition, these warning options have meanings only for C++ programs:
3736
3737@table @gcctabopt
d77de738 3738@opindex Wabi-tag
ddf6fe37 3739@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3740Warn when a type with an ABI tag is used in a context that does not
3741have that ABI tag. See @ref{C++ Attributes} for more information
3742about ABI tags.
3743
d77de738
ML
3744@opindex Wcomma-subscript
3745@opindex Wno-comma-subscript
ddf6fe37 3746@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3747Warn about uses of a comma expression within a subscripting expression.
3748This usage was deprecated in C++20 and is going to be removed in C++23.
3749However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3750
3751@smallexample
3752@group
3753void f(int *a, int b, int c) @{
3754 a[b,c]; // deprecated in C++20, invalid in C++23
3755 a[(b,c)]; // OK
3756@}
3757@end group
3758@end smallexample
3759
3760In C++23 it is valid to have comma separated expressions in a subscript
3761when an overloaded subscript operator is found and supports the right
3762number and types of arguments. G++ will accept the formerly valid syntax
3763for code that is not valid in C++23 but used to be valid but deprecated
3764in C++20 with a pedantic warning that can be disabled with
3765@option{-Wno-comma-subscript}.
3766
3767Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3768and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3769
5fccebdb
JM
3770This warning is upgraded to an error by @option{-pedantic-errors} in
3771C++23 mode or later.
3772
d77de738
ML
3773@opindex Wctad-maybe-unsupported
3774@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3775@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3776Warn when performing class template argument deduction (CTAD) on a type with
3777no explicitly written deduction guides. This warning will point out cases
3778where CTAD succeeded only because the compiler synthesized the implicit
3779deduction guides, which might not be what the programmer intended. Certain
3780style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3781types that are designed to support CTAD. This warning can be suppressed with
3782the following pattern:
3783
3784@smallexample
3785struct allow_ctad_t; // any name works
3786template <typename T> struct S @{
3787 S(T) @{ @}
3788@};
4ace81b6
SL
3789// Guide with incomplete parameter type will never be considered.
3790S(allow_ctad_t) -> S<void>;
d77de738
ML
3791@end smallexample
3792
d77de738
ML
3793@opindex Wctor-dtor-privacy
3794@opindex Wno-ctor-dtor-privacy
ddf6fe37 3795@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3796Warn when a class seems unusable because all the constructors or
3797destructors in that class are private, and it has neither friends nor
3798public static member functions. Also warn if there are no non-private
3799methods, and there's at least one private member function that isn't
3800a constructor or destructor.
3801
d77de738
ML
3802@opindex Wdangling-reference
3803@opindex Wno-dangling-reference
ddf6fe37 3804@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3805Warn when a reference is bound to a temporary whose lifetime has ended.
3806For example:
3807
3808@smallexample
3809int n = 1;
3810const int& r = std::max(n - 1, n + 1); // r is dangling
3811@end smallexample
3812
3813In the example above, two temporaries are created, one for each
3814argument, and a reference to one of the temporaries is returned.
3815However, both temporaries are destroyed at the end of the full
3816expression, so the reference @code{r} is dangling. This warning
3817also detects dangling references in member initializer lists:
3818
3819@smallexample
3820const int& f(const int& i) @{ return i; @}
3821struct S @{
3822 const int &r; // r is dangling
3823 S() : r(f(10)) @{ @}
3824@};
3825@end smallexample
3826
3827Member functions are checked as well, but only their object argument:
3828
3829@smallexample
3830struct S @{
3831 const S& self () @{ return *this; @}
3832@};
3833const S& s = S().self(); // s is dangling
3834@end smallexample
3835
3836Certain functions are safe in this respect, for example @code{std::use_facet}:
3837they take and return a reference, but they don't return one of its arguments,
3838which can fool the warning. Such functions can be excluded from the warning
3839by wrapping them in a @code{#pragma}:
3840
3841@smallexample
3842#pragma GCC diagnostic push
3843#pragma GCC diagnostic ignored "-Wdangling-reference"
3844const T& foo (const T&) @{ @dots{} @}
3845#pragma GCC diagnostic pop
3846@end smallexample
3847
ce51e843
ML
3848@option{-Wdangling-reference} also warns about code like
3849
3850@smallexample
3851auto p = std::minmax(1, 2);
3852@end smallexample
3853
3854where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3855both references dangle after the end of the full expression that contains
3856the call to @code{std::minmax}.
3857
d77de738
ML
3858This warning is enabled by @option{-Wall}.
3859
d77de738
ML
3860@opindex Wdelete-non-virtual-dtor
3861@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3862@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3863Warn when @code{delete} is used to destroy an instance of a class that
3864has virtual functions and non-virtual destructor. It is unsafe to delete
3865an instance of a derived class through a pointer to a base class if the
3866base class does not have a virtual destructor. This warning is enabled
3867by @option{-Wall}.
3868
d77de738
ML
3869@opindex Wdeprecated-copy
3870@opindex Wno-deprecated-copy
ddf6fe37 3871@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3872Warn that the implicit declaration of a copy constructor or copy
3873assignment operator is deprecated if the class has a user-provided
3874copy constructor or copy assignment operator, in C++11 and up. This
3875warning is enabled by @option{-Wextra}. With
3876@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3877user-provided destructor.
3878
d77de738
ML
3879@opindex Wdeprecated-enum-enum-conversion
3880@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3881@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3882Disable the warning about the case when the usual arithmetic conversions
3883are applied on operands where one is of enumeration type and the other is
3884of a different enumeration type. This conversion was deprecated in C++20.
3885For example:
3886
3887@smallexample
3888enum E1 @{ e @};
3889enum E2 @{ f @};
3890int k = f - e;
3891@end smallexample
3892
3893@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3894@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3895by @option{-Wenum-conversion}.
3896
d77de738
ML
3897@opindex Wdeprecated-enum-float-conversion
3898@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3899@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3900Disable the warning about the case when the usual arithmetic conversions
3901are applied on operands where one is of enumeration type and the other is
3902of a floating-point type. This conversion was deprecated in C++20. For
3903example:
3904
3905@smallexample
3906enum E1 @{ e @};
3907enum E2 @{ f @};
3908bool b = e <= 3.7;
3909@end smallexample
3910
3911@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3912@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3913by @option{-Wenum-conversion}.
3914
b106f11d
AC
3915@opindex Welaborated-enum-base
3916@opindex Wno-elaborated-enum-base
3917@item -Wno-elaborated-enum-base
3918For C++11 and above, warn if an (invalid) additional enum-base is used
3919in an elaborated-type-specifier. That is, if an enum with given
3920underlying type and no enumerator list is used in a declaration other
3921than just a standalone declaration of the enum. Enabled by default. This
3922warning is upgraded to an error with -pedantic-errors.
3923
d77de738
ML
3924@opindex Winit-list-lifetime
3925@opindex Wno-init-list-lifetime
ddf6fe37 3926@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3927Do not warn about uses of @code{std::initializer_list} that are likely
3928to result in dangling pointers. Since the underlying array for an
3929@code{initializer_list} is handled like a normal C++ temporary object,
3930it is easy to inadvertently keep a pointer to the array past the end
3931of the array's lifetime. For example:
3932
3933@itemize @bullet
3934@item
3935If a function returns a temporary @code{initializer_list}, or a local
3936@code{initializer_list} variable, the array's lifetime ends at the end
3937of the return statement, so the value returned has a dangling pointer.
3938
3939@item
3940If a new-expression creates an @code{initializer_list}, the array only
3941lives until the end of the enclosing full-expression, so the
3942@code{initializer_list} in the heap has a dangling pointer.
3943
3944@item
3945When an @code{initializer_list} variable is assigned from a
3946brace-enclosed initializer list, the temporary array created for the
3947right side of the assignment only lives until the end of the
3948full-expression, so at the next statement the @code{initializer_list}
3949variable has a dangling pointer.
3950
3951@smallexample
3952// li's initial underlying array lives as long as li
3953std::initializer_list<int> li = @{ 1,2,3 @};
3954// assignment changes li to point to a temporary array
3955li = @{ 4, 5 @};
3956// now the temporary is gone and li has a dangling pointer
3957int i = li.begin()[0] // undefined behavior
3958@end smallexample
3959
3960@item
3961When a list constructor stores the @code{begin} pointer from the
3962@code{initializer_list} argument, this doesn't extend the lifetime of
3963the array, so if a class variable is constructed from a temporary
3964@code{initializer_list}, the pointer is left dangling by the end of
3965the variable declaration statement.
3966
3967@end itemize
3968
c85f8dbb
MP
3969@opindex Winvalid-constexpr
3970@opindex Wno-invalid-constexpr
ddf6fe37 3971@item -Winvalid-constexpr
c85f8dbb
MP
3972
3973Warn when a function never produces a constant expression. In C++20
3974and earlier, for every @code{constexpr} function and function template,
3975there must be at least one set of function arguments in at least one
3976instantiation such that an invocation of the function or constructor
3977could be an evaluated subexpression of a core constant expression.
3978C++23 removed this restriction, so it's possible to have a function
3979or a function template marked @code{constexpr} for which no invocation
3980satisfies the requirements of a core constant expression.
3981
3982This warning is enabled as a pedantic warning by default in C++20 and
3983earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3984which case it will be an ordinary warning. For example:
3985
3986@smallexample
3987void f (int& i);
3988constexpr void
3989g (int& i)
3990@{
4ace81b6
SL
3991 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3992 f(i);
c85f8dbb
MP
3993@}
3994@end smallexample
3995
d77de738
ML
3996@opindex Winvalid-imported-macros
3997@opindex Wno-invalid-imported-macros
ddf6fe37 3998@item -Winvalid-imported-macros
d77de738
ML
3999Verify all imported macro definitions are valid at the end of
4000compilation. This is not enabled by default, as it requires
4001additional processing to determine. It may be useful when preparing
4002sets of header-units to ensure consistent macros.
4003
d77de738
ML
4004@opindex Wliteral-suffix
4005@opindex Wno-literal-suffix
ddf6fe37 4006@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
4007Do not warn when a string or character literal is followed by a
4008ud-suffix which does not begin with an underscore. As a conforming
4009extension, GCC treats such suffixes as separate preprocessing tokens
4010in order to maintain backwards compatibility with code that uses
4011formatting macros from @code{<inttypes.h>}. For example:
4012
4013@smallexample
4014#define __STDC_FORMAT_MACROS
4015#include <inttypes.h>
4016#include <stdio.h>
4017
4018int main() @{
4019 int64_t i64 = 123;
4020 printf("My int64: %" PRId64"\n", i64);
4021@}
4022@end smallexample
4023
4024In this case, @code{PRId64} is treated as a separate preprocessing token.
4025
4026This option also controls warnings when a user-defined literal
4027operator is declared with a literal suffix identifier that doesn't
4028begin with an underscore. Literal suffix identifiers that don't begin
4029with an underscore are reserved for future standardization.
4030
4031These warnings are enabled by default.
4032
d77de738
ML
4033@opindex Wnarrowing
4034@opindex Wno-narrowing
ddf6fe37 4035@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
4036For C++11 and later standards, narrowing conversions are diagnosed by default,
4037as required by the standard. A narrowing conversion from a constant produces
4038an error, and a narrowing conversion from a non-constant produces a warning,
4039but @option{-Wno-narrowing} suppresses the diagnostic.
4040Note that this does not affect the meaning of well-formed code;
4041narrowing conversions are still considered ill-formed in SFINAE contexts.
4042
4043With @option{-Wnarrowing} in C++98, warn when a narrowing
4044conversion prohibited by C++11 occurs within
4045@samp{@{ @}}, e.g.
4046
4047@smallexample
4048int i = @{ 2.2 @}; // error: narrowing from double to int
4049@end smallexample
4050
4051This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4052
d77de738
ML
4053@opindex Wnoexcept
4054@opindex Wno-noexcept
ddf6fe37 4055@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
4056Warn when a noexcept-expression evaluates to false because of a call
4057to a function that does not have a non-throwing exception
4058specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4059the compiler to never throw an exception.
4060
d77de738
ML
4061@opindex Wnoexcept-type
4062@opindex Wno-noexcept-type
ddf6fe37 4063@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
4064Warn if the C++17 feature making @code{noexcept} part of a function
4065type changes the mangled name of a symbol relative to C++14. Enabled
4066by @option{-Wabi} and @option{-Wc++17-compat}.
4067
4068As an example:
4069
4070@smallexample
4071template <class T> void f(T t) @{ t(); @};
4072void g() noexcept;
4073void h() @{ f(g); @}
4074@end smallexample
4075
4076@noindent
4077In C++14, @code{f} calls @code{f<void(*)()>}, but in
4078C++17 it calls @code{f<void(*)()noexcept>}.
4079
d77de738
ML
4080@opindex Wclass-memaccess
4081@opindex Wno-class-memaccess
ddf6fe37 4082@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4083Warn when the destination of a call to a raw memory function such as
4084@code{memset} or @code{memcpy} is an object of class type, and when writing
4085into such an object might bypass the class non-trivial or deleted constructor
4086or copy assignment, violate const-correctness or encapsulation, or corrupt
4087virtual table pointers. Modifying the representation of such objects may
4088violate invariants maintained by member functions of the class. For example,
4089the call to @code{memset} below is undefined because it modifies a non-trivial
4090class object and is, therefore, diagnosed. The safe way to either initialize
4091or clear the storage of objects of such types is by using the appropriate
4092constructor or assignment operator, if one is available.
4093@smallexample
4094std::string str = "abc";
4095memset (&str, 0, sizeof str);
4096@end smallexample
4097The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4098Explicitly casting the pointer to the class object to @code{void *} or
4099to a type that can be safely accessed by the raw memory function suppresses
4100the warning.
4101
d77de738
ML
4102@opindex Wnon-virtual-dtor
4103@opindex Wno-non-virtual-dtor
ddf6fe37 4104@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4105Warn when a class has virtual functions and an accessible non-virtual
4106destructor itself or in an accessible polymorphic base class, in which
4107case it is possible but unsafe to delete an instance of a derived
4108class through a pointer to the class itself or base class. This
4109warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4110The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4111should be preferred because it warns about the unsafe cases without false
4112positives.
d77de738 4113
d77de738
ML
4114@opindex Wregister
4115@opindex Wno-register
ddf6fe37 4116@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4117Warn on uses of the @code{register} storage class specifier, except
4118when it is part of the GNU @ref{Explicit Register Variables} extension.
4119The use of the @code{register} keyword as storage class specifier has
4120been deprecated in C++11 and removed in C++17.
4121Enabled by default with @option{-std=c++17}.
4122
d77de738
ML
4123@opindex Wreorder
4124@opindex Wno-reorder
4125@cindex reordering, warning
4126@cindex warning for reordering of member initializers
f33d7a88 4127@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4128Warn when the order of member initializers given in the code does not
4129match the order in which they must be executed. For instance:
4130
4131@smallexample
4132struct A @{
4133 int i;
4134 int j;
4135 A(): j (0), i (1) @{ @}
4136@};
4137@end smallexample
4138
4139@noindent
4140The compiler rearranges the member initializers for @code{i}
4141and @code{j} to match the declaration order of the members, emitting
4142a warning to that effect. This warning is enabled by @option{-Wall}.
4143
d77de738
ML
4144@opindex Wpessimizing-move
4145@opindex Wno-pessimizing-move
ddf6fe37 4146@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4147This warning warns when a call to @code{std::move} prevents copy
4148elision. A typical scenario when copy elision can occur is when returning in
4149a function with a class return type, when the expression being returned is the
4150name of a non-volatile automatic object, and is not a function parameter, and
4151has the same type as the function return type.
4152
4153@smallexample
4154struct T @{
4155@dots{}
4156@};
4157T fn()
4158@{
4159 T t;
4160 @dots{}
4161 return std::move (t);
4162@}
4163@end smallexample
4164
4165But in this example, the @code{std::move} call prevents copy elision.
4166
4167This warning is enabled by @option{-Wall}.
4168
d77de738
ML
4169@opindex Wredundant-move
4170@opindex Wno-redundant-move
ddf6fe37 4171@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4172This warning warns about redundant calls to @code{std::move}; that is, when
4173a move operation would have been performed even without the @code{std::move}
4174call. This happens because the compiler is forced to treat the object as if
4175it were an rvalue in certain situations such as returning a local variable,
4176where copy elision isn't applicable. Consider:
4177
4178@smallexample
4179struct T @{
4180@dots{}
4181@};
4182T fn(T t)
4183@{
4184 @dots{}
4185 return std::move (t);
4186@}
4187@end smallexample
4188
4189Here, the @code{std::move} call is redundant. Because G++ implements Core
4190Issue 1579, another example is:
4191
4192@smallexample
4193struct T @{ // convertible to U
4194@dots{}
4195@};
4196struct U @{
4197@dots{}
4198@};
4199U fn()
4200@{
4201 T t;
4202 @dots{}
4203 return std::move (t);
4204@}
4205@end smallexample
4206In this example, copy elision isn't applicable because the type of the
4207expression being returned and the function return type differ, yet G++
4208treats the return value as if it were designated by an rvalue.
4209
4210This warning is enabled by @option{-Wextra}.
4211
d77de738
ML
4212@opindex Wrange-loop-construct
4213@opindex Wno-range-loop-construct
ddf6fe37 4214@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4215This warning warns when a C++ range-based for-loop is creating an unnecessary
4216copy. This can happen when the range declaration is not a reference, but
4217probably should be. For example:
4218
4219@smallexample
4220struct S @{ char arr[128]; @};
4221void fn () @{
4222 S arr[5];
4223 for (const auto x : arr) @{ @dots{} @}
4224@}
4225@end smallexample
4226
4227It does not warn when the type being copied is a trivially-copyable type whose
4228size is less than 64 bytes.
4229
4230This warning also warns when a loop variable in a range-based for-loop is
4231initialized with a value of a different type resulting in a copy. For example:
4232
4233@smallexample
4234void fn() @{
4235 int arr[10];
4236 for (const double &x : arr) @{ @dots{} @}
4237@}
4238@end smallexample
4239
4240In the example above, in every iteration of the loop a temporary value of
4241type @code{double} is created and destroyed, to which the reference
4242@code{const double &} is bound.
4243
4244This warning is enabled by @option{-Wall}.
4245
d77de738
ML
4246@opindex Wredundant-tags
4247@opindex Wno-redundant-tags
ddf6fe37 4248@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4249Warn about redundant class-key and enum-key in references to class types
4250and enumerated types in contexts where the key can be eliminated without
4251causing an ambiguity. For example:
4252
4253@smallexample
4254struct foo;
4255struct foo *p; // warn that keyword struct can be eliminated
4256@end smallexample
4257
4258@noindent
4259On the other hand, in this example there is no warning:
4260
4261@smallexample
4262struct foo;
4263void foo (); // "hides" struct foo
4264void bar (struct foo&); // no warning, keyword struct is necessary
4265@end smallexample
4266
d77de738
ML
4267@opindex Wsubobject-linkage
4268@opindex Wno-subobject-linkage
ddf6fe37 4269@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4270Do not warn
4271if a class type has a base or a field whose type uses the anonymous
4272namespace or depends on a type with no linkage. If a type A depends on
4273a type B with no or internal linkage, defining it in multiple
4274translation units would be an ODR violation because the meaning of B
4275is different in each translation unit. If A only appears in a single
4276translation unit, the best way to silence the warning is to give it
4277internal linkage by putting it in an anonymous namespace as well. The
4278compiler doesn't give this warning for types defined in the main .C
4279file, as those are unlikely to have multiple definitions.
4280@option{-Wsubobject-linkage} is enabled by default.
4281
d77de738
ML
4282@opindex Weffc++
4283@opindex Wno-effc++
ddf6fe37 4284@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4285Warn about violations of the following style guidelines from Scott Meyers'
4286@cite{Effective C++} series of books:
4287
4288@itemize @bullet
4289@item
4290Define a copy constructor and an assignment operator for classes
4291with dynamically-allocated memory.
4292
4293@item
4294Prefer initialization to assignment in constructors.
4295
4296@item
4297Have @code{operator=} return a reference to @code{*this}.
4298
4299@item
4300Don't try to return a reference when you must return an object.
4301
4302@item
4303Distinguish between prefix and postfix forms of increment and
4304decrement operators.
4305
4306@item
4307Never overload @code{&&}, @code{||}, or @code{,}.
4308
4309@end itemize
4310
4311This option also enables @option{-Wnon-virtual-dtor}, which is also
4312one of the effective C++ recommendations. However, the check is
4313extended to warn about the lack of virtual destructor in accessible
4314non-polymorphic bases classes too.
4315
4316When selecting this option, be aware that the standard library
4317headers do not obey all of these guidelines; use @samp{grep -v}
4318to filter out those warnings.
4319
d77de738
ML
4320@opindex Wexceptions
4321@opindex Wno-exceptions
ddf6fe37 4322@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4323Disable the warning about the case when an exception handler is shadowed by
4324another handler, which can point out a wrong ordering of exception handlers.
4325
d77de738
ML
4326@opindex Wstrict-null-sentinel
4327@opindex Wno-strict-null-sentinel
ddf6fe37 4328@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4329Warn about the use of an uncasted @code{NULL} as sentinel. When
4330compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4331to @code{__null}. Although it is a null pointer constant rather than a
4332null pointer, it is guaranteed to be of the same size as a pointer.
4333But this use is not portable across different compilers.
4334
d77de738
ML
4335@opindex Wno-non-template-friend
4336@opindex Wnon-template-friend
ddf6fe37 4337@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4338Disable warnings when non-template friend functions are declared
4339within a template. In very old versions of GCC that predate implementation
4340of the ISO standard, declarations such as
4341@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4342could be interpreted as a particular specialization of a template
4343function; the warning exists to diagnose compatibility problems,
4344and is enabled by default.
4345
d77de738
ML
4346@opindex Wold-style-cast
4347@opindex Wno-old-style-cast
ddf6fe37 4348@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4349Warn if an old-style (C-style) cast to a non-void type is used within
4350a C++ program. The new-style casts (@code{dynamic_cast},
4351@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4352less vulnerable to unintended effects and much easier to search for.
4353
d77de738
ML
4354@opindex Woverloaded-virtual
4355@opindex Wno-overloaded-virtual
4356@cindex overloaded virtual function, warning
4357@cindex warning for overloaded virtual function
f33d7a88
AA
4358@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4359@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4360Warn when a function declaration hides virtual functions from a
4361base class. For example, in:
4362
4363@smallexample
4364struct A @{
4365 virtual void f();
4366@};
4367
4368struct B: public A @{
4369 void f(int); // does not override
4370@};
4371@end smallexample
4372
4373the @code{A} class version of @code{f} is hidden in @code{B}, and code
4374like:
4375
4376@smallexample
4377B* b;
4378b->f();
4379@end smallexample
4380
4381@noindent
4382fails to compile.
4383
d82490d5
JW
4384In cases where the different signatures are not an accident, the
4385simplest solution is to add a using-declaration to the derived class
4386to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4387
d77de738
ML
4388The optional level suffix controls the behavior when all the
4389declarations in the derived class override virtual functions in the
4390base class, even if not all of the base functions are overridden:
4391
4392@smallexample
4393struct C @{
4394 virtual void f();
4395 virtual void f(int);
4396@};
4397
4398struct D: public C @{
4399 void f(int); // does override
4400@}
4401@end smallexample
4402
4403This pattern is less likely to be a mistake; if D is only used
4404virtually, the user might have decided that the base class semantics
4405for some of the overloads are fine.
4406
4407At level 1, this case does not warn; at level 2, it does.
4408@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4409included in @option{-Wall}.
4410
d77de738
ML
4411@opindex Wno-pmf-conversions
4412@opindex Wpmf-conversions
ddf6fe37 4413@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4414Disable the diagnostic for converting a bound pointer to member function
4415to a plain pointer.
4416
d77de738
ML
4417@opindex Wsign-promo
4418@opindex Wno-sign-promo
ddf6fe37 4419@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4420Warn when overload resolution chooses a promotion from unsigned or
4421enumerated type to a signed type, over a conversion to an unsigned type of
4422the same size. Previous versions of G++ tried to preserve
4423unsignedness, but the standard mandates the current behavior.
4424
d77de738
ML
4425@opindex Wtemplates
4426@opindex Wno-templates
ddf6fe37 4427@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4428Warn when a primary template declaration is encountered. Some coding
4429rules disallow templates, and this may be used to enforce that rule.
4430The warning is inactive inside a system header file, such as the STL, so
4431one can still use the STL. One may also instantiate or specialize
4432templates.
4433
d77de738
ML
4434@opindex Wmismatched-new-delete
4435@opindex Wno-mismatched-new-delete
ddf6fe37 4436@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4437Warn for mismatches between calls to @code{operator new} or @code{operator
4438delete} and the corresponding call to the allocation or deallocation function.
4439This includes invocations of C++ @code{operator delete} with pointers
4440returned from either mismatched forms of @code{operator new}, or from other
4441functions that allocate objects for which the @code{operator delete} isn't
4442a suitable deallocator, as well as calls to other deallocation functions
4443with pointers returned from @code{operator new} for which the deallocation
4444function isn't suitable.
4445
4446For example, the @code{delete} expression in the function below is diagnosed
4447because it doesn't match the array form of the @code{new} expression
4448the pointer argument was returned from. Similarly, the call to @code{free}
4449is also diagnosed.
4450
4451@smallexample
4452void f ()
4453@{
4454 int *a = new int[n];
4455 delete a; // warning: mismatch in array forms of expressions
4456
4457 char *p = new char[n];
4458 free (p); // warning: mismatch between new and free
4459@}
4460@end smallexample
4461
4462The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4463involving allocation and deallocation functions other than @code{operator
4464new} and @code{operator delete}.
4465
4466@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4467
d77de738
ML
4468@opindex Wmismatched-tags
4469@opindex Wno-mismatched-tags
ddf6fe37 4470@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4471Warn for declarations of structs, classes, and class templates and their
4472specializations with a class-key that does not match either the definition
4473or the first declaration if no definition is provided.
4474
4475For example, the declaration of @code{struct Object} in the argument list
4476of @code{draw} triggers the warning. To avoid it, either remove the redundant
4477class-key @code{struct} or replace it with @code{class} to match its definition.
4478@smallexample
4479class Object @{
4480public:
4481 virtual ~Object () = 0;
4482@};
4483void draw (struct Object*);
4484@end smallexample
4485
4486It is not wrong to declare a class with the class-key @code{struct} as
4487the example above shows. The @option{-Wmismatched-tags} option is intended
4488to help achieve a consistent style of class declarations. In code that is
4489intended to be portable to Windows-based compilers the warning helps prevent
4490unresolved references due to the difference in the mangling of symbols
4491declared with different class-keys. The option can be used either on its
4492own or in conjunction with @option{-Wredundant-tags}.
4493
d77de738
ML
4494@opindex Wmultiple-inheritance
4495@opindex Wno-multiple-inheritance
ddf6fe37 4496@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4497Warn when a class is defined with multiple direct base classes. Some
4498coding rules disallow multiple inheritance, and this may be used to
4499enforce that rule. The warning is inactive inside a system header file,
4500such as the STL, so one can still use the STL. One may also define
4501classes that indirectly use multiple inheritance.
4502
d77de738
ML
4503@opindex Wvirtual-inheritance
4504@opindex Wno-virtual-inheritance
ddf6fe37 4505@item -Wvirtual-inheritance
d77de738
ML
4506Warn when a class is defined with a virtual direct base class. Some
4507coding rules disallow multiple inheritance, and this may be used to
4508enforce that rule. The warning is inactive inside a system header file,
4509such as the STL, so one can still use the STL. One may also define
4510classes that indirectly use virtual inheritance.
4511
d77de738
ML
4512@opindex Wvirtual-move-assign
4513@opindex Wno-virtual-move-assign
ddf6fe37 4514@item -Wno-virtual-move-assign
d77de738
ML
4515Suppress warnings about inheriting from a virtual base with a
4516non-trivial C++11 move assignment operator. This is dangerous because
4517if the virtual base is reachable along more than one path, it is
4518moved multiple times, which can mean both objects end up in the
4519moved-from state. If the move assignment operator is written to avoid
4520moving from a moved-from object, this warning can be disabled.
4521
d77de738
ML
4522@opindex Wnamespaces
4523@opindex Wno-namespaces
ddf6fe37 4524@item -Wnamespaces
d77de738
ML
4525Warn when a namespace definition is opened. Some coding rules disallow
4526namespaces, and this may be used to enforce that rule. The warning is
4527inactive inside a system header file, such as the STL, so one can still
4528use the STL. One may also use using directives and qualified names.
4529
d77de738
ML
4530@opindex Wterminate
4531@opindex Wno-terminate
ddf6fe37 4532@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4533Disable the warning about a throw-expression that will immediately
4534result in a call to @code{terminate}.
4535
d77de738
ML
4536@opindex Wvexing-parse
4537@opindex Wno-vexing-parse
ddf6fe37 4538@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4539Warn about the most vexing parse syntactic ambiguity. This warns about
4540the cases when a declaration looks like a variable definition, but the
4541C++ language requires it to be interpreted as a function declaration.
4542For instance:
4543
4544@smallexample
4545void f(double a) @{
4546 int i(); // extern int i (void);
4547 int n(int(a)); // extern int n (int);
4548@}
4549@end smallexample
4550
4551Another example:
4552
4553@smallexample
4554struct S @{ S(int); @};
4555void f(double a) @{
4556 S x(int(a)); // extern struct S x (int);
4557 S y(int()); // extern struct S y (int (*) (void));
4558 S z(); // extern struct S z (void);
4559@}
4560@end smallexample
4561
4562The warning will suggest options how to deal with such an ambiguity; e.g.,
4563it can suggest removing the parentheses or using braces instead.
4564
4565This warning is enabled by default.
4566
d77de738
ML
4567@opindex Wno-class-conversion
4568@opindex Wclass-conversion
ddf6fe37 4569@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4570Do not warn when a conversion function converts an
4571object to the same type, to a base class of that type, or to void; such
4572a conversion function will never be called.
4573
d77de738
ML
4574@opindex Wvolatile
4575@opindex Wno-volatile
ddf6fe37 4576@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4577Warn about deprecated uses of the @code{volatile} qualifier. This includes
4578postfix and prefix @code{++} and @code{--} expressions of
4579@code{volatile}-qualified types, using simple assignments where the left
4580operand is a @code{volatile}-qualified non-class type for their value,
4581compound assignments where the left operand is a @code{volatile}-qualified
4582non-class type, @code{volatile}-qualified function return type,
4583@code{volatile}-qualified parameter type, and structured bindings of a
4584@code{volatile}-qualified type. This usage was deprecated in C++20.
4585
4586Enabled by default with @option{-std=c++20}.
4587
d77de738
ML
4588@opindex Wzero-as-null-pointer-constant
4589@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4590@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4591Warn when a literal @samp{0} is used as null pointer constant. This can
4592be useful to facilitate the conversion to @code{nullptr} in C++11.
4593
d77de738
ML
4594@opindex Waligned-new
4595@opindex Wno-aligned-new
ddf6fe37 4596@item -Waligned-new
d77de738
ML
4597Warn about a new-expression of a type that requires greater alignment
4598than the @code{alignof(std::max_align_t)} but uses an allocation
4599function without an explicit alignment parameter. This option is
4600enabled by @option{-Wall}.
4601
4602Normally this only warns about global allocation functions, but
4603@option{-Waligned-new=all} also warns about class member allocation
4604functions.
4605
d77de738
ML
4606@opindex Wplacement-new
4607@opindex Wno-placement-new
ddf6fe37
AA
4608@item -Wno-placement-new
4609@itemx -Wplacement-new=@var{n}
d77de738
ML
4610Warn about placement new expressions with undefined behavior, such as
4611constructing an object in a buffer that is smaller than the type of
4612the object. For example, the placement new expression below is diagnosed
4613because it attempts to construct an array of 64 integers in a buffer only
461464 bytes large.
4615@smallexample
4616char buf [64];
4617new (buf) int[64];
4618@end smallexample
4619This warning is enabled by default.
4620
4621@table @gcctabopt
4622@item -Wplacement-new=1
4623This is the default warning level of @option{-Wplacement-new}. At this
4624level the warning is not issued for some strictly undefined constructs that
4625GCC allows as extensions for compatibility with legacy code. For example,
4626the following @code{new} expression is not diagnosed at this level even
4627though it has undefined behavior according to the C++ standard because
4628it writes past the end of the one-element array.
4629@smallexample
4630struct S @{ int n, a[1]; @};
4631S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4632new (s->a)int [32]();
4633@end smallexample
4634
4635@item -Wplacement-new=2
4636At this level, in addition to diagnosing all the same constructs as at level
46371, a diagnostic is also issued for placement new expressions that construct
4638an object in the last member of structure whose type is an array of a single
4639element and whose size is less than the size of the object being constructed.
4640While the previous example would be diagnosed, the following construct makes
4641use of the flexible member array extension to avoid the warning at level 2.
4642@smallexample
4643struct S @{ int n, a[]; @};
4644S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4645new (s->a)int [32]();
4646@end smallexample
4647
4648@end table
4649
d77de738
ML
4650@opindex Wcatch-value
4651@opindex Wno-catch-value
ddf6fe37
AA
4652@item -Wcatch-value
4653@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4654Warn about catch handlers that do not catch via reference.
4655With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4656warn about polymorphic class types that are caught by value.
4657With @option{-Wcatch-value=2} warn about all class types that are caught
4658by value. With @option{-Wcatch-value=3} warn about all types that are
4659not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4660
d77de738
ML
4661@opindex Wconditionally-supported
4662@opindex Wno-conditionally-supported
ddf6fe37 4663@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4664Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4665
d77de738
ML
4666@opindex Wdelete-incomplete
4667@opindex Wno-delete-incomplete
ddf6fe37 4668@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4669Do not warn when deleting a pointer to incomplete type, which may cause
4670undefined behavior at runtime. This warning is enabled by default.
4671
d77de738
ML
4672@opindex Wextra-semi
4673@opindex Wno-extra-semi
ddf6fe37 4674@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4675Warn about redundant semicolons after in-class function definitions.
4676
d77de738
ML
4677@opindex Winaccessible-base
4678@opindex Wno-inaccessible-base
ddf6fe37 4679@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4680This option controls warnings
4681when a base class is inaccessible in a class derived from it due to
4682ambiguity. The warning is enabled by default.
4683Note that the warning for ambiguous virtual
4684bases is enabled by the @option{-Wextra} option.
4685@smallexample
4686@group
4687struct A @{ int a; @};
4688
4689struct B : A @{ @};
4690
4691struct C : B, A @{ @};
4692@end group
4693@end smallexample
4694
d77de738
ML
4695@opindex Winherited-variadic-ctor
4696@opindex Wno-inherited-variadic-ctor
ddf6fe37 4697@item -Wno-inherited-variadic-ctor
d77de738
ML
4698Suppress warnings about use of C++11 inheriting constructors when the
4699base class inherited from has a C variadic constructor; the warning is
4700on by default because the ellipsis is not inherited.
4701
d77de738
ML
4702@opindex Wno-invalid-offsetof
4703@opindex Winvalid-offsetof
ddf6fe37 4704@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4705Suppress warnings from applying the @code{offsetof} macro to a non-POD
4706type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4707to a non-standard-layout type is undefined. In existing C++ implementations,
4708however, @code{offsetof} typically gives meaningful results.
4709This flag is for users who are aware that they are
4710writing nonportable code and who have deliberately chosen to ignore the
4711warning about it.
4712
4713The restrictions on @code{offsetof} may be relaxed in a future version
4714of the C++ standard.
4715
d77de738
ML
4716@opindex Wsized-deallocation
4717@opindex Wno-sized-deallocation
ddf6fe37 4718@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4719Warn about a definition of an unsized deallocation function
4720@smallexample
4721void operator delete (void *) noexcept;
4722void operator delete[] (void *) noexcept;
4723@end smallexample
4724without a definition of the corresponding sized deallocation function
4725@smallexample
4726void operator delete (void *, std::size_t) noexcept;
4727void operator delete[] (void *, std::size_t) noexcept;
4728@end smallexample
4729or vice versa. Enabled by @option{-Wextra} along with
4730@option{-fsized-deallocation}.
4731
d77de738
ML
4732@opindex Wno-suggest-final-types
4733@opindex Wsuggest-final-types
ddf6fe37 4734@item -Wsuggest-final-types
d77de738
ML
4735Warn about types with virtual methods where code quality would be improved
4736if the type were declared with the C++11 @code{final} specifier,
4737or, if possible,
4738declared in an anonymous namespace. This allows GCC to more aggressively
4739devirtualize the polymorphic calls. This warning is more effective with
4740link-time optimization,
4741where the information about the class hierarchy graph is
4742more complete.
4743
d77de738
ML
4744@opindex Wno-suggest-final-methods
4745@opindex Wsuggest-final-methods
ddf6fe37 4746@item -Wsuggest-final-methods
d77de738
ML
4747Warn about virtual methods where code quality would be improved if the method
4748were declared with the C++11 @code{final} specifier,
4749or, if possible, its type were
4750declared in an anonymous namespace or with the @code{final} specifier.
4751This warning is
4752more effective with link-time optimization, where the information about the
4753class hierarchy graph is more complete. It is recommended to first consider
4754suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4755annotations.
4756
d77de738
ML
4757@opindex Wsuggest-override
4758@opindex Wno-suggest-override
ddf6fe37 4759@item -Wsuggest-override
d77de738
ML
4760Warn about overriding virtual functions that are not marked with the
4761@code{override} keyword.
4762
d77de738
ML
4763@opindex Wuse-after-free
4764@opindex Wno-use-after-free
ddf6fe37
AA
4765@item -Wuse-after-free
4766@itemx -Wuse-after-free=@var{n}
d77de738
ML
4767Warn about uses of pointers to dynamically allocated objects that have
4768been rendered indeterminate by a call to a deallocation function.
4769The warning is enabled at all optimization levels but may yield different
4770results with optimization than without.
4771
4772@table @gcctabopt
4773@item -Wuse-after-free=1
4774At level 1 the warning attempts to diagnose only unconditional uses
4775of pointers made indeterminate by a deallocation call or a successful
4776call to @code{realloc}, regardless of whether or not the call resulted
4777in an actual reallocatio of memory. This includes double-@code{free}
4778calls as well as uses in arithmetic and relational expressions. Although
4779undefined, uses of indeterminate pointers in equality (or inequality)
4780expressions are not diagnosed at this level.
4781@item -Wuse-after-free=2
4782At level 2, in addition to unconditional uses, the warning also diagnoses
4783conditional uses of pointers made indeterminate by a deallocation call.
4784As at level 2, uses in equality (or inequality) expressions are not
4785diagnosed. For example, the second call to @code{free} in the following
4786function is diagnosed at this level:
4787@smallexample
4788struct A @{ int refcount; void *data; @};
4789
4790void release (struct A *p)
4791@{
4792 int refcount = --p->refcount;
4793 free (p);
4794 if (refcount == 0)
4795 free (p->data); // warning: p may be used after free
4796@}
4797@end smallexample
4798@item -Wuse-after-free=3
4799At level 3, the warning also diagnoses uses of indeterminate pointers in
4800equality expressions. All uses of indeterminate pointers are undefined
4801but equality tests sometimes appear after calls to @code{realloc} as
4802an attempt to determine whether the call resulted in relocating the object
4803to a different address. They are diagnosed at a separate level to aid
4804legacy code gradually transition to safe alternatives. For example,
4805the equality test in the function below is diagnosed at this level:
4806@smallexample
4807void adjust_pointers (int**, int);
4808
4809void grow (int **p, int n)
4810@{
4811 int **q = (int**)realloc (p, n *= 2);
4812 if (q == p)
4813 return;
4814 adjust_pointers ((int**)q, n);
4815@}
4816@end smallexample
4817To avoid the warning at this level, store offsets into allocated memory
4818instead of pointers. This approach obviates needing to adjust the stored
4819pointers after reallocation.
4820@end table
4821
4822@option{-Wuse-after-free=2} is included in @option{-Wall}.
4823
d77de738
ML
4824@opindex Wuseless-cast
4825@opindex Wno-useless-cast
68783211 4826@item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
4827Warn when an expression is cast to its own type. This warning does not
4828occur when a class object is converted to a non-reference type as that
4829is a way to create a temporary:
4830
4831@smallexample
4832struct S @{ @};
4833void g (S&&);
4834void f (S&& arg)
4835@{
4836 g (S(arg)); // make arg prvalue so that it can bind to S&&
4837@}
4838@end smallexample
4839
d77de738
ML
4840@opindex Wconversion-null
4841@opindex Wno-conversion-null
ddf6fe37 4842@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4843Do not warn for conversions between @code{NULL} and non-pointer
4844types. @option{-Wconversion-null} is enabled by default.
4845
4846@end table
4847
4848@node Objective-C and Objective-C++ Dialect Options
4849@section Options Controlling Objective-C and Objective-C++ Dialects
4850
4851@cindex compiler options, Objective-C and Objective-C++
4852@cindex Objective-C and Objective-C++ options, command-line
4853@cindex options, Objective-C and Objective-C++
4854(NOTE: This manual does not describe the Objective-C and Objective-C++
4855languages themselves. @xref{Standards,,Language Standards
4856Supported by GCC}, for references.)
4857
4858This section describes the command-line options that are only meaningful
4859for Objective-C and Objective-C++ programs. You can also use most of
4860the language-independent GNU compiler options.
4861For example, you might compile a file @file{some_class.m} like this:
4862
4863@smallexample
4864gcc -g -fgnu-runtime -O -c some_class.m
4865@end smallexample
4866
4867@noindent
4868In this example, @option{-fgnu-runtime} is an option meant only for
4869Objective-C and Objective-C++ programs; you can use the other options with
4870any language supported by GCC@.
4871
4872Note that since Objective-C is an extension of the C language, Objective-C
4873compilations may also use options specific to the C front-end (e.g.,
4874@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4875C++-specific options (e.g., @option{-Wabi}).
4876
4877Here is a list of options that are @emph{only} for compiling Objective-C
4878and Objective-C++ programs:
4879
4880@table @gcctabopt
d77de738 4881@opindex fconstant-string-class
ddf6fe37 4882@item -fconstant-string-class=@var{class-name}
d77de738
ML
4883Use @var{class-name} as the name of the class to instantiate for each
4884literal string specified with the syntax @code{@@"@dots{}"}. The default
4885class name is @code{NXConstantString} if the GNU runtime is being used, and
cdd4b3c0 4886@code{NSConstantString} if the NeXT runtime is being used (see below). On
a335cf24 4887Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
cdd4b3c0
IS
4888also present, overrides the @option{-fconstant-string-class} setting and cause
4889@code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
4890Note that @option{-fconstant-cfstrings} is an alias for the target-specific
4891@option{-mconstant-cfstrings} equivalent.
d77de738 4892
d77de738 4893@opindex fgnu-runtime
ddf6fe37 4894@item -fgnu-runtime
d77de738
ML
4895Generate object code compatible with the standard GNU Objective-C
4896runtime. This is the default for most types of systems.
4897
d77de738 4898@opindex fnext-runtime
ddf6fe37 4899@item -fnext-runtime
d77de738 4900Generate output compatible with the NeXT runtime. This is the default
a335cf24 4901for NeXT-based systems, including Darwin / macOS. The macro
d77de738
ML
4902@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4903used.
4904
d77de738
ML
4905@opindex fno-nil-receivers
4906@opindex fnil-receivers
ddf6fe37 4907@item -fno-nil-receivers
d77de738
ML
4908Assume that all Objective-C message dispatches (@code{[receiver
4909message:arg]}) in this translation unit ensure that the receiver is
4910not @code{nil}. This allows for more efficient entry points in the
4911runtime to be used. This option is only available in conjunction with
4912the NeXT runtime and ABI version 0 or 1.
4913
d77de738 4914@opindex fobjc-abi-version
ddf6fe37 4915@item -fobjc-abi-version=@var{n}
d77de738
ML
4916Use version @var{n} of the Objective-C ABI for the selected runtime.
4917This option is currently supported only for the NeXT runtime. In that
4918case, Version 0 is the traditional (32-bit) ABI without support for
4919properties and other Objective-C 2.0 additions. Version 1 is the
4920traditional (32-bit) ABI with support for properties and other
4921Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4922nothing is specified, the default is Version 0 on 32-bit target
4923machines, and Version 2 on 64-bit target machines.
4924
d77de738 4925@opindex fobjc-call-cxx-cdtors
ddf6fe37 4926@item -fobjc-call-cxx-cdtors
d77de738
ML
4927For each Objective-C class, check if any of its instance variables is a
4928C++ object with a non-trivial default constructor. If so, synthesize a
4929special @code{- (id) .cxx_construct} instance method which runs
4930non-trivial default constructors on any such instance variables, in order,
4931and then return @code{self}. Similarly, check if any instance variable
4932is a C++ object with a non-trivial destructor, and if so, synthesize a
4933special @code{- (void) .cxx_destruct} method which runs
4934all such default destructors, in reverse order.
4935
4936The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4937methods thusly generated only operate on instance variables
4938declared in the current Objective-C class, and not those inherited
4939from superclasses. It is the responsibility of the Objective-C
4940runtime to invoke all such methods in an object's inheritance
4941hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4942by the runtime immediately after a new object instance is allocated;
4943the @code{- (void) .cxx_destruct} methods are invoked immediately
4944before the runtime deallocates an object instance.
4945
4946As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4947support for invoking the @code{- (id) .cxx_construct} and
4948@code{- (void) .cxx_destruct} methods.
4949
d77de738 4950@opindex fobjc-direct-dispatch
ddf6fe37 4951@item -fobjc-direct-dispatch
d77de738
ML
4952Allow fast jumps to the message dispatcher. On Darwin this is
4953accomplished via the comm page.
4954
d77de738 4955@opindex fobjc-exceptions
ddf6fe37 4956@item -fobjc-exceptions
d77de738
ML
4957Enable syntactic support for structured exception handling in
4958Objective-C, similar to what is offered by C++. This option
4959is required to use the Objective-C keywords @code{@@try},
4960@code{@@throw}, @code{@@catch}, @code{@@finally} and
4961@code{@@synchronized}. This option is available with both the GNU
4962runtime and the NeXT runtime (but not available in conjunction with
4963the NeXT runtime on Mac OS X 10.2 and earlier).
4964
d77de738 4965@opindex fobjc-gc
ddf6fe37 4966@item -fobjc-gc
d77de738
ML
4967Enable garbage collection (GC) in Objective-C and Objective-C++
4968programs. This option is only available with the NeXT runtime; the
4969GNU runtime has a different garbage collection implementation that
4970does not require special compiler flags.
4971
d77de738 4972@opindex fobjc-nilcheck
ddf6fe37 4973@item -fobjc-nilcheck
d77de738
ML
4974For the NeXT runtime with version 2 of the ABI, check for a nil
4975receiver in method invocations before doing the actual method call.
4976This is the default and can be disabled using
4977@option{-fno-objc-nilcheck}. Class methods and super calls are never
4978checked for nil in this way no matter what this flag is set to.
4979Currently this flag does nothing when the GNU runtime, or an older
4980version of the NeXT runtime ABI, is used.
4981
d77de738 4982@opindex fobjc-std
ddf6fe37 4983@item -fobjc-std=objc1
d77de738
ML
4984Conform to the language syntax of Objective-C 1.0, the language
4985recognized by GCC 4.0. This only affects the Objective-C additions to
4986the C/C++ language; it does not affect conformance to C/C++ standards,
4987which is controlled by the separate C/C++ dialect option flags. When
4988this option is used with the Objective-C or Objective-C++ compiler,
4989any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4990This is useful if you need to make sure that your Objective-C code can
4991be compiled with older versions of GCC@.
4992
d77de738 4993@opindex freplace-objc-classes
ddf6fe37 4994@item -freplace-objc-classes
d77de738
ML
4995Emit a special marker instructing @command{ld(1)} not to statically link in
4996the resulting object file, and allow @command{dyld(1)} to load it in at
4997run time instead. This is used in conjunction with the Fix-and-Continue
4998debugging mode, where the object file in question may be recompiled and
4999dynamically reloaded in the course of program execution, without the need
5000to restart the program itself. Currently, Fix-and-Continue functionality
5001is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5002and later.
5003
d77de738 5004@opindex fzero-link
ddf6fe37 5005@item -fzero-link
d77de738
ML
5006When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5007to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5008compile time) with static class references that get initialized at load time,
5009which improves run-time performance. Specifying the @option{-fzero-link} flag
5010suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5011to be retained. This is useful in Zero-Link debugging mode, since it allows
5012for individual class implementations to be modified during program execution.
5013The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5014regardless of command-line options.
5015
d77de738
ML
5016@opindex fno-local-ivars
5017@opindex flocal-ivars
ddf6fe37 5018@item -fno-local-ivars
d77de738
ML
5019By default instance variables in Objective-C can be accessed as if
5020they were local variables from within the methods of the class they're
5021declared in. This can lead to shadowing between instance variables
5022and other variables declared either locally inside a class method or
5023globally with the same name. Specifying the @option{-fno-local-ivars}
5024flag disables this behavior thus avoiding variable shadowing issues.
5025
d77de738 5026@opindex fivar-visibility
ddf6fe37 5027@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
5028Set the default instance variable visibility to the specified option
5029so that instance variables declared outside the scope of any access
5030modifier directives default to the specified visibility.
5031
d77de738 5032@opindex gen-decls
ddf6fe37 5033@item -gen-decls
d77de738
ML
5034Dump interface declarations for all classes seen in the source file to a
5035file named @file{@var{sourcename}.decl}.
5036
d77de738
ML
5037@opindex Wassign-intercept
5038@opindex Wno-assign-intercept
ddf6fe37 5039@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5040Warn whenever an Objective-C assignment is being intercepted by the
5041garbage collector.
5042
d77de738
ML
5043@opindex Wproperty-assign-default
5044@opindex Wno-property-assign-default
ddf6fe37 5045@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5046Do not warn if a property for an Objective-C object has no assign
5047semantics specified.
5048
d77de738
ML
5049@opindex Wno-protocol
5050@opindex Wprotocol
ddf6fe37 5051@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5052If a class is declared to implement a protocol, a warning is issued for
5053every method in the protocol that is not implemented by the class. The
5054default behavior is to issue a warning for every method not explicitly
5055implemented in the class, even if a method implementation is inherited
5056from the superclass. If you use the @option{-Wno-protocol} option, then
5057methods inherited from the superclass are considered to be implemented,
5058and no warning is issued for them.
5059
d77de738 5060@opindex Wobjc-root-class
ddf6fe37 5061@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5062Warn if a class interface lacks a superclass. Most classes will inherit
5063from @code{NSObject} (or @code{Object}) for example. When declaring
5064classes intended to be root classes, the warning can be suppressed by
5065marking their interfaces with @code{__attribute__((objc_root_class))}.
5066
d77de738
ML
5067@opindex Wselector
5068@opindex Wno-selector
ddf6fe37 5069@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5070Warn if multiple methods of different types for the same selector are
5071found during compilation. The check is performed on the list of methods
5072in the final stage of compilation. Additionally, a check is performed
5073for each selector appearing in a @code{@@selector(@dots{})}
5074expression, and a corresponding method for that selector has been found
5075during compilation. Because these checks scan the method table only at
5076the end of compilation, these warnings are not produced if the final
5077stage of compilation is not reached, for example because an error is
5078found during compilation, or because the @option{-fsyntax-only} option is
5079being used.
5080
d77de738
ML
5081@opindex Wstrict-selector-match
5082@opindex Wno-strict-selector-match
ddf6fe37 5083@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5084Warn if multiple methods with differing argument and/or return types are
5085found for a given selector when attempting to send a message using this
5086selector to a receiver of type @code{id} or @code{Class}. When this flag
5087is off (which is the default behavior), the compiler omits such warnings
5088if any differences found are confined to types that share the same size
5089and alignment.
5090
d77de738
ML
5091@opindex Wundeclared-selector
5092@opindex Wno-undeclared-selector
ddf6fe37 5093@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5094Warn if a @code{@@selector(@dots{})} expression referring to an
5095undeclared selector is found. A selector is considered undeclared if no
5096method with that name has been declared before the
5097@code{@@selector(@dots{})} expression, either explicitly in an
5098@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5099an @code{@@implementation} section. This option always performs its
5100checks as soon as a @code{@@selector(@dots{})} expression is found,
5101while @option{-Wselector} only performs its checks in the final stage of
5102compilation. This also enforces the coding style convention
5103that methods and selectors must be declared before being used.
5104
d77de738 5105@opindex print-objc-runtime-info
ddf6fe37 5106@item -print-objc-runtime-info
d77de738
ML
5107Generate C header describing the largest structure that is passed by
5108value, if any.
5109
5110@end table
5111
5112@node Diagnostic Message Formatting Options
5113@section Options to Control Diagnostic Messages Formatting
5114@cindex options to control diagnostics formatting
5115@cindex diagnostic messages
5116@cindex message formatting
5117
5118Traditionally, diagnostic messages have been formatted irrespective of
5119the output device's aspect (e.g.@: its width, @dots{}). You can use the
5120options described below
5121to control the formatting algorithm for diagnostic messages,
5122e.g.@: how many characters per line, how often source location
5123information should be reported. Note that some language front ends may not
5124honor these options.
5125
5126@table @gcctabopt
d77de738 5127@opindex fmessage-length
ddf6fe37 5128@item -fmessage-length=@var{n}
d77de738
ML
5129Try to format error messages so that they fit on lines of about
5130@var{n} characters. If @var{n} is zero, then no line-wrapping is
5131done; each error message appears on a single line. This is the
5132default for all front ends.
5133
5134Note - this option also affects the display of the @samp{#error} and
5135@samp{#warning} pre-processor directives, and the @samp{deprecated}
5136function/type/variable attribute. It does not however affect the
5137@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5138
5139@item -fdiagnostics-plain-output
5140This option requests that diagnostic output look as plain as possible, which
5141may be useful when running @command{dejagnu} or other utilities that need to
5142parse diagnostics output and prefer that it remain more stable over time.
5143@option{-fdiagnostics-plain-output} is currently equivalent to the following
5144options:
43b72ede
AA
5145@gccoptlist{-fno-diagnostics-show-caret
5146-fno-diagnostics-show-line-numbers
5147-fdiagnostics-color=never
5148-fdiagnostics-urls=never
4f01ae37
DM
5149-fdiagnostics-path-format=separate-events
5150-fdiagnostics-text-art-charset=none}
d77de738
ML
5151In the future, if GCC changes the default appearance of its diagnostics, the
5152corresponding option to disable the new behavior will be added to this list.
5153
d77de738 5154@opindex fdiagnostics-show-location
ddf6fe37 5155@item -fdiagnostics-show-location=once
d77de738
ML
5156Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5157reporter to emit source location information @emph{once}; that is, in
5158case the message is too long to fit on a single physical line and has to
5159be wrapped, the source location won't be emitted (as prefix) again,
5160over and over, in subsequent continuation lines. This is the default
5161behavior.
5162
5163@item -fdiagnostics-show-location=every-line
5164Only meaningful in line-wrapping mode. Instructs the diagnostic
5165messages reporter to emit the same source location information (as
5166prefix) for physical lines that result from the process of breaking
5167a message which is too long to fit on a single line.
5168
ddf6fe37 5169@opindex fdiagnostics-color
d77de738
ML
5170@cindex highlight, color
5171@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5172@item -fdiagnostics-color[=@var{WHEN}]
5173@itemx -fno-diagnostics-color
d77de738
ML
5174Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5175or @samp{auto}. The default depends on how the compiler has been configured,
5176it can be any of the above @var{WHEN} options or also @samp{never}
5177if @env{GCC_COLORS} environment variable isn't present in the environment,
5178and @samp{auto} otherwise.
5179@samp{auto} makes GCC use color only when the standard error is a terminal,
5180and when not executing in an emacs shell.
5181The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5182aliases for @option{-fdiagnostics-color=always} and
5183@option{-fdiagnostics-color=never}, respectively.
5184
5185The colors are defined by the environment variable @env{GCC_COLORS}.
5186Its value is a colon-separated list of capabilities and Select Graphic
5187Rendition (SGR) substrings. SGR commands are interpreted by the
5188terminal or terminal emulator. (See the section in the documentation
5189of your text terminal for permitted values and their meanings as
5190character attributes.) These substring values are integers in decimal
5191representation and can be concatenated with semicolons.
5192Common values to concatenate include
5193@samp{1} for bold,
5194@samp{4} for underline,
5195@samp{5} for blink,
5196@samp{7} for inverse,
5197@samp{39} for default foreground color,
5198@samp{30} to @samp{37} for foreground colors,
5199@samp{90} to @samp{97} for 16-color mode foreground colors,
5200@samp{38;5;0} to @samp{38;5;255}
5201for 88-color and 256-color modes foreground colors,
5202@samp{49} for default background color,
5203@samp{40} to @samp{47} for background colors,
5204@samp{100} to @samp{107} for 16-color mode background colors,
5205and @samp{48;5;0} to @samp{48;5;255}
5206for 88-color and 256-color modes background colors.
5207
5208The default @env{GCC_COLORS} is
5209@smallexample
5210error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5211quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5212diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5213type-diff=01;32:fnname=01;32:targs=35
5214@end smallexample
5215@noindent
5216where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5217@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5218@samp{01} is bold, and @samp{31} is red.
5219Setting @env{GCC_COLORS} to the empty string disables colors.
5220Supported capabilities are as follows.
5221
5222@table @code
d77de738 5223@vindex error GCC_COLORS @r{capability}
f33d7a88 5224@item error=
d77de738
ML
5225SGR substring for error: markers.
5226
d77de738 5227@vindex warning GCC_COLORS @r{capability}
f33d7a88 5228@item warning=
d77de738
ML
5229SGR substring for warning: markers.
5230
d77de738 5231@vindex note GCC_COLORS @r{capability}
f33d7a88 5232@item note=
d77de738
ML
5233SGR substring for note: markers.
5234
d77de738 5235@vindex path GCC_COLORS @r{capability}
f33d7a88 5236@item path=
d77de738
ML
5237SGR substring for colorizing paths of control-flow events as printed
5238via @option{-fdiagnostics-path-format=}, such as the identifiers of
5239individual events and lines indicating interprocedural calls and returns.
5240
d77de738 5241@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5242@item range1=
d77de738
ML
5243SGR substring for first additional range.
5244
d77de738 5245@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5246@item range2=
d77de738
ML
5247SGR substring for second additional range.
5248
d77de738 5249@vindex locus GCC_COLORS @r{capability}
f33d7a88 5250@item locus=
d77de738
ML
5251SGR substring for location information, @samp{file:line} or
5252@samp{file:line:column} etc.
5253
d77de738 5254@vindex quote GCC_COLORS @r{capability}
f33d7a88 5255@item quote=
d77de738
ML
5256SGR substring for information printed within quotes.
5257
d77de738 5258@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5259@item fnname=
d77de738
ML
5260SGR substring for names of C++ functions.
5261
d77de738 5262@vindex targs GCC_COLORS @r{capability}
f33d7a88 5263@item targs=
d77de738
ML
5264SGR substring for C++ function template parameter bindings.
5265
d77de738 5266@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5267@item fixit-insert=
d77de738
ML
5268SGR substring for fix-it hints suggesting text to
5269be inserted or replaced.
5270
d77de738 5271@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5272@item fixit-delete=
d77de738
ML
5273SGR substring for fix-it hints suggesting text to
5274be deleted.
5275
d77de738 5276@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5277@item diff-filename=
d77de738
ML
5278SGR substring for filename headers within generated patches.
5279
d77de738 5280@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5281@item diff-hunk=
d77de738
ML
5282SGR substring for the starts of hunks within generated patches.
5283
d77de738 5284@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5285@item diff-delete=
d77de738
ML
5286SGR substring for deleted lines within generated patches.
5287
d77de738 5288@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5289@item diff-insert=
d77de738
ML
5290SGR substring for inserted lines within generated patches.
5291
d77de738 5292@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5293@item type-diff=
d77de738
ML
5294SGR substring for highlighting mismatching types within template
5295arguments in the C++ frontend.
5296@end table
5297
d77de738
ML
5298@opindex fdiagnostics-urls
5299@cindex urls
5300@vindex GCC_URLS @r{environment variable}
5301@vindex TERM_URLS @r{environment variable}
f33d7a88 5302@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5303Use escape sequences to embed URLs in diagnostics. For example, when
5304@option{-fdiagnostics-show-option} emits text showing the command-line
5305option controlling a diagnostic, embed a URL for documentation of that
5306option.
5307
5308@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5309@samp{auto} makes GCC use URL escape sequences only when the standard error
5310is a terminal, and when not executing in an emacs shell or any graphical
5311terminal which is known to be incompatible with this feature, see below.
5312
5313The default depends on how the compiler has been configured.
5314It can be any of the above @var{WHEN} options.
5315
5316GCC can also be configured (via the
5317@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5318so that the default is affected by environment variables.
5319Under such a configuration, GCC defaults to using @samp{auto}
5320if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5321present and non-empty in the environment of the compiler, or @samp{never}
5322if neither are.
5323
5324However, even with @option{-fdiagnostics-urls=always} the behavior is
5325dependent on those environment variables:
5326If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5327diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5328If set to @samp{bel}, the default, URLs use BEL escape sequences.
5329Any other non-empty value enables the feature.
5330If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5331Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5332BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5333
5334At this time GCC tries to detect also a few terminals that are known to
5335not implement the URL feature, and have bugs or at least had bugs in
5336some versions that are still in use, where the URL escapes are likely
5337to misbehave, i.e. print garbage on the screen.
5338That list is currently xfce4-terminal, certain known to be buggy
5339gnome-terminal versions, the linux console, and mingw.
5340This check can be skipped with the @option{-fdiagnostics-urls=always}.
5341
d77de738
ML
5342@opindex fno-diagnostics-show-option
5343@opindex fdiagnostics-show-option
ddf6fe37 5344@item -fno-diagnostics-show-option
d77de738
ML
5345By default, each diagnostic emitted includes text indicating the
5346command-line option that directly controls the diagnostic (if such an
5347option is known to the diagnostic machinery). Specifying the
5348@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5349
d77de738
ML
5350@opindex fno-diagnostics-show-caret
5351@opindex fdiagnostics-show-caret
ddf6fe37 5352@item -fno-diagnostics-show-caret
d77de738
ML
5353By default, each diagnostic emitted includes the original source line
5354and a caret @samp{^} indicating the column. This option suppresses this
5355information. The source line is truncated to @var{n} characters, if
5356the @option{-fmessage-length=n} option is given. When the output is done
5357to the terminal, the width is limited to the width given by the
5358@env{COLUMNS} environment variable or, if not set, to the terminal width.
5359
d77de738
ML
5360@opindex fno-diagnostics-show-labels
5361@opindex fdiagnostics-show-labels
ddf6fe37 5362@item -fno-diagnostics-show-labels
d77de738
ML
5363By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5364diagnostics can label ranges of source code with pertinent information, such
5365as the types of expressions:
5366
5367@smallexample
5368 printf ("foo %s bar", long_i + long_j);
5369 ~^ ~~~~~~~~~~~~~~~
5370 | |
5371 char * long int
5372@end smallexample
5373
5374This option suppresses the printing of these labels (in the example above,
5375the vertical bars and the ``char *'' and ``long int'' text).
5376
d77de738
ML
5377@opindex fno-diagnostics-show-cwe
5378@opindex fdiagnostics-show-cwe
ddf6fe37 5379@item -fno-diagnostics-show-cwe
d77de738
ML
5380Diagnostic messages can optionally have an associated
5381@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5382GCC itself only provides such metadata for some of the @option{-fanalyzer}
5383diagnostics. GCC plugins may also provide diagnostics with such metadata.
5384By default, if this information is present, it will be printed with
5385the diagnostic. This option suppresses the printing of this metadata.
5386
d77de738
ML
5387@opindex fno-diagnostics-show-rules
5388@opindex fdiagnostics-show-rules
ddf6fe37 5389@item -fno-diagnostics-show-rules
d77de738
ML
5390Diagnostic messages can optionally have rules associated with them, such
5391as from a coding standard, or a specification.
5392GCC itself does not do this for any of its diagnostics, but plugins may do so.
5393By default, if this information is present, it will be printed with
5394the diagnostic. This option suppresses the printing of this metadata.
5395
d77de738
ML
5396@opindex fno-diagnostics-show-line-numbers
5397@opindex fdiagnostics-show-line-numbers
ddf6fe37 5398@item -fno-diagnostics-show-line-numbers
d77de738
ML
5399By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5400a left margin is printed, showing line numbers. This option suppresses this
5401left margin.
5402
d77de738 5403@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5404@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5405This option controls the minimum width of the left margin printed by
5406@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5407
d77de738 5408@opindex fdiagnostics-parseable-fixits
ddf6fe37 5409@item -fdiagnostics-parseable-fixits
d77de738
ML
5410Emit fix-it hints in a machine-parseable format, suitable for consumption
5411by IDEs. For each fix-it, a line will be printed after the relevant
5412diagnostic, starting with the string ``fix-it:''. For example:
5413
5414@smallexample
5415fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5416@end smallexample
5417
5418The location is expressed as a half-open range, expressed as a count of
5419bytes, starting at byte 1 for the initial column. In the above example,
5420bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5421given string:
5422
5423@smallexample
542400000000011111111112222222222
542512345678901234567890123456789
5426 gtk_widget_showall (dlg);
5427 ^^^^^^^^^^^^^^^^^^
5428 gtk_widget_show_all
5429@end smallexample
5430
5431The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5432newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5433(e.g. vertical tab as ``\013'').
5434
5435An empty replacement string indicates that the given range is to be removed.
5436An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5437be inserted at the given position.
5438
d77de738 5439@opindex fdiagnostics-generate-patch
ddf6fe37 5440@item -fdiagnostics-generate-patch
d77de738
ML
5441Print fix-it hints to stderr in unified diff format, after any diagnostics
5442are printed. For example:
5443
5444@smallexample
5445--- test.c
5446+++ test.c
5447@@ -42,5 +42,5 @@
5448
5449 void show_cb(GtkDialog *dlg)
5450 @{
5451- gtk_widget_showall(dlg);
5452+ gtk_widget_show_all(dlg);
5453 @}
5454
5455@end smallexample
5456
5457The diff may or may not be colorized, following the same rules
5458as for diagnostics (see @option{-fdiagnostics-color}).
5459
d77de738 5460@opindex fdiagnostics-show-template-tree
ddf6fe37 5461@item -fdiagnostics-show-template-tree
d77de738
ML
5462
5463In the C++ frontend, when printing diagnostics showing mismatching
5464template types, such as:
5465
5466@smallexample
5467 could not convert 'std::map<int, std::vector<double> >()'
5468 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5469@end smallexample
5470
5471the @option{-fdiagnostics-show-template-tree} flag enables printing a
5472tree-like structure showing the common and differing parts of the types,
5473such as:
5474
5475@smallexample
5476 map<
5477 [...],
5478 vector<
5479 [double != float]>>
5480@end smallexample
5481
5482The parts that differ are highlighted with color (``double'' and
5483``float'' in this case).
5484
d77de738
ML
5485@opindex fno-elide-type
5486@opindex felide-type
ddf6fe37 5487@item -fno-elide-type
d77de738
ML
5488By default when the C++ frontend prints diagnostics showing mismatching
5489template types, common parts of the types are printed as ``[...]'' to
5490simplify the error message. For example:
5491
5492@smallexample
5493 could not convert 'std::map<int, std::vector<double> >()'
5494 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5495@end smallexample
5496
5497Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5498This flag also affects the output of the
5499@option{-fdiagnostics-show-template-tree} flag.
5500
d77de738 5501@opindex fdiagnostics-path-format
ddf6fe37 5502@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5503Specify how to print paths of control-flow events for diagnostics that
5504have such a path associated with them.
5505
5506@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5507the default.
5508
5509@samp{none} means to not print diagnostic paths.
5510
5511@samp{separate-events} means to print a separate ``note'' diagnostic for
5512each event within the diagnostic. For example:
5513
5514@smallexample
5515test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5516test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5517test.c:27:3: note: (2) when 'i < count'
5518test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5519@end smallexample
5520
5521@samp{inline-events} means to print the events ``inline'' within the source
5522code. This view attempts to consolidate the events into runs of
5523sufficiently-close events, printing them as labelled ranges within the source.
5524
5525For example, the same events as above might be printed as:
5526
5527@smallexample
5528 'test': events 1-3
5529 |
5530 | 25 | list = PyList_New(0);
5531 | | ^~~~~~~~~~~~~
5532 | | |
5533 | | (1) when 'PyList_New' fails, returning NULL
5534 | 26 |
5535 | 27 | for (i = 0; i < count; i++) @{
5536 | | ~~~
5537 | | |
5538 | | (2) when 'i < count'
5539 | 28 | item = PyLong_FromLong(random());
5540 | 29 | PyList_Append(list, item);
5541 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5542 | | |
5543 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5544 |
5545@end smallexample
5546
5547Interprocedural control flow is shown by grouping the events by stack frame,
5548and using indentation to show how stack frames are nested, pushed, and popped.
5549
5550For example:
5551
5552@smallexample
5553 'test': events 1-2
5554 |
5555 | 133 | @{
5556 | | ^
5557 | | |
5558 | | (1) entering 'test'
5559 | 134 | boxed_int *obj = make_boxed_int (i);
5560 | | ~~~~~~~~~~~~~~~~~~
5561 | | |
5562 | | (2) calling 'make_boxed_int'
5563 |
5564 +--> 'make_boxed_int': events 3-4
5565 |
5566 | 120 | @{
5567 | | ^
5568 | | |
5569 | | (3) entering 'make_boxed_int'
5570 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5571 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5572 | | |
5573 | | (4) calling 'wrapped_malloc'
5574 |
5575 +--> 'wrapped_malloc': events 5-6
5576 |
5577 | 7 | @{
5578 | | ^
5579 | | |
5580 | | (5) entering 'wrapped_malloc'
5581 | 8 | return malloc (size);
5582 | | ~~~~~~~~~~~~~
5583 | | |
5584 | | (6) calling 'malloc'
5585 |
5586 <-------------+
5587 |
5588 'test': event 7
5589 |
5590 | 138 | free_boxed_int (obj);
5591 | | ^~~~~~~~~~~~~~~~~~~~
5592 | | |
5593 | | (7) calling 'free_boxed_int'
5594 |
5595(etc)
5596@end smallexample
5597
d77de738 5598@opindex fdiagnostics-show-path-depths
ddf6fe37 5599@item -fdiagnostics-show-path-depths
d77de738
ML
5600This option provides additional information when printing control-flow paths
5601associated with a diagnostic.
5602
5603If this is option is provided then the stack depth will be printed for
5604each run of events within @option{-fdiagnostics-path-format=inline-events}.
5605If provided with @option{-fdiagnostics-path-format=separate-events}, then
5606the stack depth and function declaration will be appended when printing
5607each event.
5608
5609This is intended for use by GCC developers and plugin developers when
5610debugging diagnostics that report interprocedural control flow.
5611
d77de738
ML
5612@opindex fno-show-column
5613@opindex fshow-column
ddf6fe37 5614@item -fno-show-column
d77de738
ML
5615Do not print column numbers in diagnostics. This may be necessary if
5616diagnostics are being scanned by a program that does not understand the
5617column numbers, such as @command{dejagnu}.
5618
d77de738 5619@opindex fdiagnostics-column-unit
ddf6fe37 5620@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5621Select the units for the column number. This affects traditional diagnostics
5622(in the absence of @option{-fno-show-column}), as well as JSON format
5623diagnostics if requested.
5624
5625The default @var{UNIT}, @samp{display}, considers the number of display
5626columns occupied by each character. This may be larger than the number
5627of bytes required to encode the character, in the case of tab
5628characters, or it may be smaller, in the case of multibyte characters.
5629For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5630display column, and its UTF-8 encoding requires two bytes; the character
5631``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5632its UTF-8 encoding requires four bytes.
5633
5634Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5635count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5636
d77de738 5637@opindex fdiagnostics-column-origin
ddf6fe37 5638@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5639Select the origin for column numbers, i.e. the column number assigned to the
5640first column. The default value of 1 corresponds to traditional GCC
5641behavior and to the GNU style guide. Some utilities may perform better with an
5642origin of 0; any non-negative value may be specified.
5643
d77de738 5644@opindex fdiagnostics-escape-format
ddf6fe37 5645@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5646When GCC prints pertinent source lines for a diagnostic it normally attempts
5647to print the source bytes directly. However, some diagnostics relate to encoding
5648issues in the source file, such as malformed UTF-8, or issues with Unicode
5649normalization. These diagnostics are flagged so that GCC will escape bytes
5650that are not printable ASCII when printing their pertinent source lines.
5651
5652This option controls how such bytes should be escaped.
5653
5654The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5655are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5656correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5657displayed as hexadecimal in the form @samp{<XX>}.
5658
5659For example, a source line containing the string @samp{before} followed by the
5660Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
56610xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5662the string @samp{after} will be printed for such a diagnostic as:
5663
5664@smallexample
5665 before<U+03C0><BF>after
5666@end smallexample
5667
5668Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5669in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5670Unicode characters. For the example above, the following will be printed:
5671
5672@smallexample
5673 before<CF><80><BF>after
5674@end smallexample
5675
4f01ae37
DM
5676@opindex fdiagnostics-text-art-charset
5677@item -fdiagnostics-text-art-charset=@var{CHARSET}
5678Some diagnostics can contain ``text art'' diagrams: visualizations created
5679from text, intended to be viewed in a monospaced font.
5680
5681This option selects which characters should be used for printing such
5682diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
5683or @samp{emoji}.
5684
5685The @samp{none} value suppresses the printing of such diagrams.
5686The @samp{ascii} value will ensure that such diagrams are pure ASCII
5687(``ASCII art''). The @samp{unicode} value will allow for conservative use of
5688unicode drawing characters (such as box-drawing characters). The @samp{emoji}
5689value further adds the possibility of emoji in the output (such as emitting
5690U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
5691emoji variant of the character).
5692
04013e44
DM
5693The default is @samp{emoji}, except when the environment variable @env{LANG}
5694is set to @samp{C}, in which case the default is @samp{ascii}.
4f01ae37 5695
d77de738 5696@opindex fdiagnostics-format
ddf6fe37 5697@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5698Select a different format for printing diagnostics.
5699@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5700@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5701
5702The default is @samp{text}.
5703
5704The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5705diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5706named @file{@var{source}.sarif}, respectively.
5707
5708The @samp{json} format is a synonym for @samp{json-stderr}.
5709The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5710where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5711whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5712
5713The emitted JSON consists of a top-level JSON array containing JSON objects
5714representing the diagnostics. The JSON is emitted as one line, without
5715formatting; the examples below have been formatted for clarity.
5716
5717Diagnostics can have child diagnostics. For example, this error and note:
5718
5719@smallexample
5720misleading-indentation.c:15:3: warning: this 'if' clause does not
5721 guard... [-Wmisleading-indentation]
5722 15 | if (flag)
5723 | ^~
5724misleading-indentation.c:17:5: note: ...this statement, but the latter
5725 is misleadingly indented as if it were guarded by the 'if'
5726 17 | y = 2;
5727 | ^
5728@end smallexample
5729
5730@noindent
5731might be printed in JSON form (after formatting) like this:
5732
5733@smallexample
5734[
5735 @{
5736 "kind": "warning",
5737 "locations": [
5738 @{
5739 "caret": @{
5740 "display-column": 3,
5741 "byte-column": 3,
5742 "column": 3,
5743 "file": "misleading-indentation.c",
5744 "line": 15
5745 @},
5746 "finish": @{
5747 "display-column": 4,
5748 "byte-column": 4,
5749 "column": 4,
5750 "file": "misleading-indentation.c",
5751 "line": 15
5752 @}
5753 @}
5754 ],
5755 "message": "this \u2018if\u2019 clause does not guard...",
5756 "option": "-Wmisleading-indentation",
5757 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5758 "children": [
5759 @{
5760 "kind": "note",
5761 "locations": [
5762 @{
5763 "caret": @{
5764 "display-column": 5,
5765 "byte-column": 5,
5766 "column": 5,
5767 "file": "misleading-indentation.c",
5768 "line": 17
5769 @}
5770 @}
5771 ],
5772 "escape-source": false,
5773 "message": "...this statement, but the latter is @dots{}"
5774 @}
5775 ]
5776 "escape-source": false,
5777 "column-origin": 1,
5778 @}
5779]
5780@end smallexample
5781
5782@noindent
5783where the @code{note} is a child of the @code{warning}.
5784
5785A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5786an @code{option} key describing the command-line option controlling the
5787warning.
5788
5789A diagnostic can contain zero or more locations. Each location has an
5790optional @code{label} string and up to three positions within it: a
5791@code{caret} position and optional @code{start} and @code{finish} positions.
5792A position is described by a @code{file} name, a @code{line} number, and
5793three numbers indicating a column position:
5794@itemize @bullet
5795
5796@item
5797@code{display-column} counts display columns, accounting for tabs and
5798multibyte characters.
5799
5800@item
5801@code{byte-column} counts raw bytes.
5802
5803@item
5804@code{column} is equal to one of
5805the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5806option.
5807
5808@end itemize
5809All three columns are relative to the origin specified by
5810@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5811be set, for instance, to 0 for compatibility with other utilities that
5812number columns from 0. The column origin is recorded in the JSON output in
5813the @code{column-origin} tag. In the remaining examples below, the extra
5814column number outputs have been omitted for brevity.
5815
5816For example, this error:
5817
5818@smallexample
5819bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5820 'struct s'@} and 'T' @{aka 'struct t'@})
5821 64 | return callee_4a () + callee_4b ();
5822 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5823 | | |
5824 | | T @{aka struct t@}
5825 | S @{aka struct s@}
5826@end smallexample
5827
5828@noindent
5829has three locations. Its primary location is at the ``+'' token at column
583023. It has two secondary locations, describing the left and right-hand sides
5831of the expression, which have labels. It might be printed in JSON form as:
5832
5833@smallexample
5834 @{
5835 "children": [],
5836 "kind": "error",
5837 "locations": [
5838 @{
5839 "caret": @{
5840 "column": 23, "file": "bad-binary-ops.c", "line": 64
5841 @}
5842 @},
5843 @{
5844 "caret": @{
5845 "column": 10, "file": "bad-binary-ops.c", "line": 64
5846 @},
5847 "finish": @{
5848 "column": 21, "file": "bad-binary-ops.c", "line": 64
5849 @},
5850 "label": "S @{aka struct s@}"
5851 @},
5852 @{
5853 "caret": @{
5854 "column": 25, "file": "bad-binary-ops.c", "line": 64
5855 @},
5856 "finish": @{
5857 "column": 36, "file": "bad-binary-ops.c", "line": 64
5858 @},
5859 "label": "T @{aka struct t@}"
5860 @}
5861 ],
5862 "escape-source": false,
5863 "message": "invalid operands to binary + @dots{}"
5864 @}
5865@end smallexample
5866
5867If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5868consisting of half-open intervals, similar to the output of
5869@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5870with a replacement fix-it hint:
5871
5872@smallexample
5873demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5874 mean 'color'?
5875 8 | return ptr->colour;
5876 | ^~~~~~
5877 | color
5878@end smallexample
5879
5880@noindent
5881might be printed in JSON form as:
5882
5883@smallexample
5884 @{
5885 "children": [],
5886 "fixits": [
5887 @{
5888 "next": @{
5889 "column": 21,
5890 "file": "demo.c",
5891 "line": 8
5892 @},
5893 "start": @{
5894 "column": 15,
5895 "file": "demo.c",
5896 "line": 8
5897 @},
5898 "string": "color"
5899 @}
5900 ],
5901 "kind": "error",
5902 "locations": [
5903 @{
5904 "caret": @{
5905 "column": 15,
5906 "file": "demo.c",
5907 "line": 8
5908 @},
5909 "finish": @{
5910 "column": 20,
5911 "file": "demo.c",
5912 "line": 8
5913 @}
5914 @}
5915 ],
5916 "escape-source": false,
5917 "message": "\u2018struct s\u2019 has no member named @dots{}"
5918 @}
5919@end smallexample
5920
5921@noindent
5922where the fix-it hint suggests replacing the text from @code{start} up
5923to but not including @code{next} with @code{string}'s value. Deletions
5924are expressed via an empty value for @code{string}, insertions by
5925having @code{start} equal @code{next}.
5926
5927If the diagnostic has a path of control-flow events associated with it,
5928it has a @code{path} array of objects representing the events. Each
5929event object has a @code{description} string, a @code{location} object,
5930along with a @code{function} string and a @code{depth} number for
5931representing interprocedural paths. The @code{function} represents the
5932current function at that event, and the @code{depth} represents the
5933stack depth relative to some baseline: the higher, the more frames are
5934within the stack.
5935
5936For example, the intraprocedural example shown for
5937@option{-fdiagnostics-path-format=} might have this JSON for its path:
5938
5939@smallexample
5940 "path": [
5941 @{
5942 "depth": 0,
5943 "description": "when 'PyList_New' fails, returning NULL",
5944 "function": "test",
5945 "location": @{
5946 "column": 10,
5947 "file": "test.c",
5948 "line": 25
5949 @}
5950 @},
5951 @{
5952 "depth": 0,
5953 "description": "when 'i < count'",
5954 "function": "test",
5955 "location": @{
5956 "column": 3,
5957 "file": "test.c",
5958 "line": 27
5959 @}
5960 @},
5961 @{
5962 "depth": 0,
5963 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5964 "function": "test",
5965 "location": @{
5966 "column": 5,
5967 "file": "test.c",
5968 "line": 29
5969 @}
5970 @}
5971 ]
5972@end smallexample
5973
5974Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5975non-ASCII bytes should be escaped when printing the pertinent lines of
5976source code (@code{true} for diagnostics involving source encoding issues).
5977
5978@end table
5979
5980@node Warning Options
5981@section Options to Request or Suppress Warnings
5982@cindex options to control warnings
5983@cindex warning messages
5984@cindex messages, warning
5985@cindex suppressing warnings
5986
5987Warnings are diagnostic messages that report constructions that
5988are not inherently erroneous but that are risky or suggest there
5989may have been an error.
5990
5991The following language-independent options do not enable specific
5992warnings but control the kinds of diagnostics produced by GCC@.
5993
5994@table @gcctabopt
5995@cindex syntax checking
d77de738 5996@opindex fsyntax-only
ddf6fe37 5997@item -fsyntax-only
d77de738
ML
5998Check the code for syntax errors, but don't do anything beyond that.
5999
d77de738 6000@opindex fmax-errors
ddf6fe37 6001@item -fmax-errors=@var{n}
d77de738
ML
6002Limits the maximum number of error messages to @var{n}, at which point
6003GCC bails out rather than attempting to continue processing the source
6004code. If @var{n} is 0 (the default), there is no limit on the number
6005of error messages produced. If @option{-Wfatal-errors} is also
6006specified, then @option{-Wfatal-errors} takes precedence over this
6007option.
6008
d77de738 6009@opindex w
ddf6fe37 6010@item -w
d77de738
ML
6011Inhibit all warning messages.
6012
d77de738
ML
6013@opindex Werror
6014@opindex Wno-error
ddf6fe37 6015@item -Werror
d77de738
ML
6016Make all warnings into errors.
6017
d77de738
ML
6018@opindex Werror=
6019@opindex Wno-error=
ddf6fe37 6020@item -Werror=
d77de738
ML
6021Make the specified warning into an error. The specifier for a warning
6022is appended; for example @option{-Werror=switch} turns the warnings
6023controlled by @option{-Wswitch} into errors. This switch takes a
6024negative form, to be used to negate @option{-Werror} for specific
6025warnings; for example @option{-Wno-error=switch} makes
6026@option{-Wswitch} warnings not be errors, even when @option{-Werror}
6027is in effect.
6028
6029The warning message for each controllable warning includes the
6030option that controls the warning. That option can then be used with
6031@option{-Werror=} and @option{-Wno-error=} as described above.
6032(Printing of the option in the warning message can be disabled using the
6033@option{-fno-diagnostics-show-option} flag.)
6034
6035Note that specifying @option{-Werror=}@var{foo} automatically implies
6036@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6037imply anything.
6038
d77de738
ML
6039@opindex Wfatal-errors
6040@opindex Wno-fatal-errors
ddf6fe37 6041@item -Wfatal-errors
d77de738
ML
6042This option causes the compiler to abort compilation on the first error
6043occurred rather than trying to keep going and printing further error
6044messages.
6045
6046@end table
6047
6048You can request many specific warnings with options beginning with
6049@samp{-W}, for example @option{-Wimplicit} to request warnings on
6050implicit declarations. Each of these specific warning options also
6051has a negative form beginning @samp{-Wno-} to turn off warnings; for
6052example, @option{-Wno-implicit}. This manual lists only one of the
6053two forms, whichever is not the default. For further
6054language-specific options also refer to @ref{C++ Dialect Options} and
6055@ref{Objective-C and Objective-C++ Dialect Options}.
6056Additional warnings can be produced by enabling the static analyzer;
6057@xref{Static Analyzer Options}.
6058
6059Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6060options, such as @option{-Wunused}, which may turn on further options,
6061such as @option{-Wunused-value}. The combined effect of positive and
6062negative forms is that more specific options have priority over less
6063specific ones, independently of their position in the command-line. For
6064options of the same specificity, the last one takes effect. Options
6065enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6066as if they appeared at the end of the command-line.
6067
6068When an unrecognized warning option is requested (e.g.,
6069@option{-Wunknown-warning}), GCC emits a diagnostic stating
6070that the option is not recognized. However, if the @option{-Wno-} form
6071is used, the behavior is slightly different: no diagnostic is
6072produced for @option{-Wno-unknown-warning} unless other diagnostics
6073are being produced. This allows the use of new @option{-Wno-} options
6074with old compilers, but if something goes wrong, the compiler
6075warns that an unrecognized option is present.
6076
6077The effectiveness of some warnings depends on optimizations also being
6078enabled. For example @option{-Wsuggest-final-types} is more effective
6079with link-time optimization and some instances of other warnings may
6080not be issued at all unless optimization is enabled. While optimization
6081in general improves the efficacy of control and data flow sensitive
6082warnings, in some cases it may also cause false positives.
6083
6084@table @gcctabopt
d77de738
ML
6085@opindex pedantic
6086@opindex Wpedantic
6087@opindex Wno-pedantic
ddf6fe37
AA
6088@item -Wpedantic
6089@itemx -pedantic
d77de738 6090Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
6091diagnose all programs that use forbidden extensions, and some other
6092programs that do not follow ISO C and ISO C++. This follows the version
6093of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
6094
6095Valid ISO C and ISO C++ programs should compile properly with or without
6096this option (though a rare few require @option{-ansi} or a
5fccebdb 6097@option{-std} option specifying the version of the standard)@. However,
d77de738 6098without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6099features are supported as well. With this option, they are diagnosed
6100(or rejected with @option{-pedantic-errors}).
d77de738
ML
6101
6102@option{-Wpedantic} does not cause warning messages for use of the
6103alternate keywords whose names begin and end with @samp{__}. This alternate
6104format can also be used to disable warnings for non-ISO @samp{__intN} types,
6105i.e. @samp{__intN__}.
6106Pedantic warnings are also disabled in the expression that follows
6107@code{__extension__}. However, only system header files should use
6108these escape routes; application programs should avoid them.
6109@xref{Alternate Keywords}.
6110
5fccebdb
JM
6111Some warnings about non-conforming programs are controlled by options
6112other than @option{-Wpedantic}; in many cases they are implied by
6113@option{-Wpedantic} but can be disabled separately by their specific
6114option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6115
6116Where the standard specified with @option{-std} represents a GNU
6117extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6118corresponding @dfn{base standard}, the version of ISO C on which the GNU
6119extended dialect is based. Warnings from @option{-Wpedantic} are given
6120where they are required by the base standard. (It does not make sense
6121for such warnings to be given only for features not in the specified GNU
6122C dialect, since by definition the GNU dialects of C include all
6123features the compiler supports with the given option, and there would be
6124nothing to warn about.)
6125
d77de738 6126@opindex pedantic-errors
ddf6fe37 6127@item -pedantic-errors
d77de738
ML
6128Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6129requires a diagnostic, in some cases where there is undefined behavior
6130at compile-time and in some other cases that do not prevent compilation
6131of programs that are valid according to the standard. This is not
5fccebdb
JM
6132equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6133useful, as it only makes errors of the diagnostics that are controlled by
6134@option{-Wpedantic}, whereas this option also affects required diagnostics that
6135are always enabled or controlled by options other than @option{-Wpedantic}.
6136
6137If you want the required diagnostics that are warnings by default to
6138be errors instead, but don't also want to enable the @option{-Wpedantic}
6139diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6140(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6141only as warnings).
6142
6143Some required diagnostics are errors by default, but can be reduced to
6144warnings using @option{-fpermissive} or their specific warning option,
6145e.g. @option{-Wno-error=narrowing}.
6146
6147Some diagnostics for non-ISO practices are controlled by specific
6148warning options other than @option{-Wpedantic}, but are also made
6149errors by @option{-pedantic-errors}. For instance:
6150
6151@gccoptlist{
6152-Wattributes @r{(for standard attributes)}
6153-Wchanges-meaning @r{(C++)}
6154-Wcomma-subscript @r{(C++23 or later)}
6155-Wdeclaration-after-statement @r{(C90 or earlier)}
b106f11d 6156-Welaborated-enum-base @r{(C++11 or later)}
5fccebdb
JM
6157-Wimplicit-int @r{(C99 or later)}
6158-Wimplicit-function-declaration @r{(C99 or later)}
6159-Wincompatible-pointer-types
6160-Wint-conversion
6161-Wlong-long @r{(C90 or earlier)}
6162-Wmain
6163-Wnarrowing @r{(C++11 or later)}
6164-Wpointer-arith
6165-Wpointer-sign
6166-Wincompatible-pointer-types
6167-Wregister @r{(C++17 or later)}
6168-Wvla @r{(C90 or earlier)}
6169-Wwrite-strings @r{(C++11 or later)}
6170}
d77de738 6171
ef10cb86
JM
6172@opindex fpermissive
6173@item -fpermissive
6174Downgrade some required diagnostics about nonconformant code from
6175errors to warnings. Thus, using @option{-fpermissive} allows some
6176nonconforming code to compile. Some C++ diagnostics are controlled
da4315f5
FW
6177only by this flag, but it also downgrades some C and C++ diagnostics
6178that have their own flag:
ef10cb86
JM
6179
6180@gccoptlist{
6181-Wnarrowing @r{(C++)}
6182}
6183
da4315f5
FW
6184The @option{-fpermissive} option is the default for historic C language
6185modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6186@option{-std=gnu90}).
6187
d77de738
ML
6188@opindex Wall
6189@opindex Wno-all
ddf6fe37 6190@item -Wall
d77de738
ML
6191This enables all the warnings about constructions that some users
6192consider questionable, and that are easy to avoid (or modify to
6193prevent the warning), even in conjunction with macros. This also
6194enables some language-specific warnings described in @ref{C++ Dialect
6195Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6196
6197@option{-Wall} turns on the following warning flags:
6198
43b72ede
AA
6199@gccoptlist{-Waddress
6200-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6201-Warray-compare
6202-Warray-parameter=2 @r{(C and Objective-C only)}
6203-Wbool-compare
6204-Wbool-operation
6205-Wc++11-compat -Wc++14-compat
6206-Wcatch-value @r{(C++ and Objective-C++ only)}
6207-Wchar-subscripts
6208-Wcomment
6209-Wdangling-pointer=2
6210-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6211-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6212-Wenum-int-mismatch @r{(C and Objective-C only)}
6213-Wformat
6214-Wformat-overflow
6215-Wformat-truncation
6216-Wint-in-bool-context
6217-Wimplicit @r{(C and Objective-C only)}
6218-Wimplicit-int @r{(C and Objective-C only)}
6219-Wimplicit-function-declaration @r{(C and Objective-C only)}
6220-Winit-self @r{(only for C++)}
6221-Wlogical-not-parentheses
6222-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6223-Wmaybe-uninitialized
6224-Wmemset-elt-size
6225-Wmemset-transposed-args
6226-Wmisleading-indentation @r{(only for C/C++)}
6227-Wmismatched-dealloc
6228-Wmismatched-new-delete @r{(only for C/C++)}
6229-Wmissing-attributes
6230-Wmissing-braces @r{(only for C/ObjC)}
6231-Wmultistatement-macros
6232-Wnarrowing @r{(only for C++)}
6233-Wnonnull
6234-Wnonnull-compare
6235-Wopenmp-simd
6236-Wparentheses
6237-Wpessimizing-move @r{(only for C++)}
6238-Wpointer-sign
6239-Wrange-loop-construct @r{(only for C++)}
6240-Wreorder
6241-Wrestrict
6242-Wreturn-type
6243-Wself-move @r{(only for C++)}
6244-Wsequence-point
6245-Wsign-compare @r{(only in C++)}
6246-Wsizeof-array-div
6247-Wsizeof-pointer-div
6248-Wsizeof-pointer-memaccess
6249-Wstrict-aliasing
6250-Wstrict-overflow=1
6251-Wswitch
6252-Wtautological-compare
6253-Wtrigraphs
6254-Wuninitialized
6255-Wunknown-pragmas
6256-Wunused-function
6257-Wunused-label
6258-Wunused-value
6259-Wunused-variable
6260-Wuse-after-free=2
6261-Wvla-parameter @r{(C and Objective-C only)}
6262-Wvolatile-register-var
d77de738
ML
6263-Wzero-length-bounds}
6264
6265Note that some warning flags are not implied by @option{-Wall}. Some of
6266them warn about constructions that users generally do not consider
6267questionable, but which occasionally you might wish to check for;
6268others warn about constructions that are necessary or hard to avoid in
6269some cases, and there is no simple way to modify the code to suppress
6270the warning. Some of them are enabled by @option{-Wextra} but many of
6271them must be enabled individually.
6272
d77de738
ML
6273@opindex W
6274@opindex Wextra
6275@opindex Wno-extra
ddf6fe37 6276@item -Wextra
d77de738
ML
6277This enables some extra warning flags that are not enabled by
6278@option{-Wall}. (This option used to be called @option{-W}. The older
6279name is still supported, but the newer name is more descriptive.)
6280
43b72ede
AA
6281@gccoptlist{-Wclobbered
6282-Wcast-function-type
6283-Wdeprecated-copy @r{(C++ only)}
6284-Wempty-body
6285-Wenum-conversion @r{(C only)}
6286-Wignored-qualifiers
6287-Wimplicit-fallthrough=3
6288-Wmissing-field-initializers
6289-Wmissing-parameter-type @r{(C only)}
6290-Wold-style-declaration @r{(C only)}
6291-Woverride-init
6292-Wsign-compare @r{(C only)}
6293-Wstring-compare
6294-Wredundant-move @r{(only for C++)}
6295-Wtype-limits
6296-Wuninitialized
6297-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6298-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6299-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6300
6301
6302The option @option{-Wextra} also prints warning messages for the
6303following cases:
6304
6305@itemize @bullet
6306
6307@item
6308A pointer is compared against integer zero with @code{<}, @code{<=},
6309@code{>}, or @code{>=}.
6310
6311@item
6312(C++ only) An enumerator and a non-enumerator both appear in a
6313conditional expression.
6314
6315@item
6316(C++ only) Ambiguous virtual bases.
6317
6318@item
6319(C++ only) Subscripting an array that has been declared @code{register}.
6320
6321@item
6322(C++ only) Taking the address of a variable that has been declared
6323@code{register}.
6324
6325@item
6326(C++ only) A base class is not initialized in the copy constructor
6327of a derived class.
6328
6329@end itemize
6330
d77de738
ML
6331@opindex Wabi
6332@opindex Wno-abi
ddf6fe37 6333@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6334
6335Warn about code affected by ABI changes. This includes code that may
6336not be compatible with the vendor-neutral C++ ABI as well as the psABI
6337for the particular target.
6338
6339Since G++ now defaults to updating the ABI with each major release,
6340normally @option{-Wabi} warns only about C++ ABI compatibility
6341problems if there is a check added later in a release series for an
6342ABI issue discovered since the initial release. @option{-Wabi} warns
6343about more things if an older ABI version is selected (with
6344@option{-fabi-version=@var{n}}).
6345
6346@option{-Wabi} can also be used with an explicit version number to
6347warn about C++ ABI compatibility with a particular @option{-fabi-version}
6348level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6349@option{-fabi-version=2}.
6350
6351If an explicit version number is provided and
6352@option{-fabi-compat-version} is not specified, the version number
6353from this option is used for compatibility aliases. If no explicit
6354version number is provided with this option, but
6355@option{-fabi-compat-version} is specified, that version number is
6356used for C++ ABI warnings.
6357
6358Although an effort has been made to warn about
6359all such cases, there are probably some cases that are not warned about,
6360even though G++ is generating incompatible code. There may also be
6361cases where warnings are emitted even though the code that is generated
6362is compatible.
6363
6364You should rewrite your code to avoid these warnings if you are
6365concerned about the fact that code generated by G++ may not be binary
6366compatible with code generated by other compilers.
6367
6368Known incompatibilities in @option{-fabi-version=2} (which was the
6369default from GCC 3.4 to 4.9) include:
6370
6371@itemize @bullet
6372
6373@item
6374A template with a non-type template parameter of reference type was
6375mangled incorrectly:
6376@smallexample
6377extern int N;
6378template <int &> struct S @{@};
6379void n (S<N>) @{2@}
6380@end smallexample
6381
6382This was fixed in @option{-fabi-version=3}.
6383
6384@item
6385SIMD vector types declared using @code{__attribute ((vector_size))} were
6386mangled in a non-standard way that does not allow for overloading of
6387functions taking vectors of different sizes.
6388
6389The mangling was changed in @option{-fabi-version=4}.
6390
6391@item
6392@code{__attribute ((const))} and @code{noreturn} were mangled as type
6393qualifiers, and @code{decltype} of a plain declaration was folded away.
6394
6395These mangling issues were fixed in @option{-fabi-version=5}.
6396
6397@item
6398Scoped enumerators passed as arguments to a variadic function are
6399promoted like unscoped enumerators, causing @code{va_arg} to complain.
6400On most targets this does not actually affect the parameter passing
6401ABI, as there is no way to pass an argument smaller than @code{int}.
6402
6403Also, the ABI changed the mangling of template argument packs,
6404@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6405a class scope function used as a template argument.
6406
6407These issues were corrected in @option{-fabi-version=6}.
6408
6409@item
6410Lambdas in default argument scope were mangled incorrectly, and the
6411ABI changed the mangling of @code{nullptr_t}.
6412
6413These issues were corrected in @option{-fabi-version=7}.
6414
6415@item
6416When mangling a function type with function-cv-qualifiers, the
6417un-qualified function type was incorrectly treated as a substitution
6418candidate.
6419
6420This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6421
6422@item
6423@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6424unaligned accesses. Note that this did not affect the ABI of a
6425function with a @code{nullptr_t} parameter, as parameters have a
6426minimum alignment.
6427
6428This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6429
6430@item
6431Target-specific attributes that affect the identity of a type, such as
6432ia32 calling conventions on a function type (stdcall, regparm, etc.),
6433did not affect the mangled name, leading to name collisions when
6434function pointers were used as template arguments.
6435
6436This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6437
6438@end itemize
6439
6440This option also enables warnings about psABI-related changes.
6441The known psABI changes at this point include:
6442
6443@itemize @bullet
6444
6445@item
6446For SysV/x86-64, unions with @code{long double} members are
6447passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6448the case. For example:
6449
6450@smallexample
6451union U @{
6452 long double ld;
6453 int i;
6454@};
6455@end smallexample
6456
6457@noindent
6458@code{union U} is now always passed in memory.
6459
6460@end itemize
6461
e2f939d3
JM
6462@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6463C++ requires that unqualified uses of a name within a class have the
6464same meaning in the complete scope of the class, so declaring the name
6465after using it is ill-formed:
6466@smallexample
6467struct A;
6468struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6469struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6470@end smallexample
6471By default, the B1 case is only a warning because the two declarations
6472have the same type, while the B2 case is an error. Both diagnostics
6473can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6474error case can be reduced to a warning with
6475@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6476
6477Both diagnostics are also suppressed by @option{-fms-extensions}.
6478
d77de738
ML
6479@opindex Wchar-subscripts
6480@opindex Wno-char-subscripts
ddf6fe37 6481@item -Wchar-subscripts
d77de738
ML
6482Warn if an array subscript has type @code{char}. This is a common cause
6483of error, as programmers often forget that this type is signed on some
6484machines.
6485This warning is enabled by @option{-Wall}.
6486
d77de738
ML
6487@opindex Wno-coverage-mismatch
6488@opindex Wcoverage-mismatch
ddf6fe37 6489@item -Wno-coverage-mismatch
d77de738
ML
6490Warn if feedback profiles do not match when using the
6491@option{-fprofile-use} option.
6492If a source file is changed between compiling with @option{-fprofile-generate}
6493and with @option{-fprofile-use}, the files with the profile feedback can fail
6494to match the source file and GCC cannot use the profile feedback
6495information. By default, this warning is enabled and is treated as an
6496error. @option{-Wno-coverage-mismatch} can be used to disable the
6497warning or @option{-Wno-error=coverage-mismatch} can be used to
6498disable the error. Disabling the error for this warning can result in
6499poorly optimized code and is useful only in the
6500case of very minor changes such as bug fixes to an existing code-base.
6501Completely disabling the warning is not recommended.
6502
d77de738
ML
6503@opindex Wno-coverage-invalid-line-number
6504@opindex Wcoverage-invalid-line-number
ddf6fe37 6505@item -Wno-coverage-invalid-line-number
d77de738
ML
6506Warn in case a function ends earlier than it begins due
6507to an invalid linenum macros. The warning is emitted only
6508with @option{--coverage} enabled.
6509
6510By default, this warning is enabled and is treated as an
6511error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6512warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6513disable the error.
6514
d77de738
ML
6515@opindex Wno-cpp
6516@opindex Wcpp
ddf6fe37 6517@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6518Suppress warning messages emitted by @code{#warning} directives.
6519
d77de738
ML
6520@opindex Wdouble-promotion
6521@opindex Wno-double-promotion
ddf6fe37 6522@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6523Give a warning when a value of type @code{float} is implicitly
6524promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6525floating-point unit implement @code{float} in hardware, but emulate
6526@code{double} in software. On such a machine, doing computations
6527using @code{double} values is much more expensive because of the
6528overhead required for software emulation.
6529
6530It is easy to accidentally do computations with @code{double} because
6531floating-point literals are implicitly of type @code{double}. For
6532example, in:
6533@smallexample
6534@group
6535float area(float radius)
6536@{
6537 return 3.14159 * radius * radius;
6538@}
6539@end group
6540@end smallexample
6541the compiler performs the entire computation with @code{double}
6542because the floating-point literal is a @code{double}.
6543
d77de738
ML
6544@opindex Wduplicate-decl-specifier
6545@opindex Wno-duplicate-decl-specifier
ddf6fe37 6546@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6547Warn if a declaration has duplicate @code{const}, @code{volatile},
6548@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6549@option{-Wall}.
6550
d77de738
ML
6551@opindex Wformat
6552@opindex Wno-format
6553@opindex ffreestanding
6554@opindex fno-builtin
6555@opindex Wformat=
ddf6fe37
AA
6556@item -Wformat
6557@itemx -Wformat=@var{n}
d77de738
ML
6558Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6559the arguments supplied have types appropriate to the format string
6560specified, and that the conversions specified in the format string make
6561sense. This includes standard functions, and others specified by format
6562attributes (@pxref{Function Attributes}), in the @code{printf},
6563@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6564not in the C standard) families (or other target-specific families).
6565Which functions are checked without format attributes having been
6566specified depends on the standard version selected, and such checks of
6567functions without the attribute specified are disabled by
6568@option{-ffreestanding} or @option{-fno-builtin}.
6569
6570The formats are checked against the format features supported by GNU
6571libc version 2.2. These include all ISO C90 and C99 features, as well
6572as features from the Single Unix Specification and some BSD and GNU
6573extensions. Other library implementations may not support all these
6574features; GCC does not support warning about features that go beyond a
6575particular library's limitations. However, if @option{-Wpedantic} is used
6576with @option{-Wformat}, warnings are given about format features not
6577in the selected standard version (but not for @code{strfmon} formats,
6578since those are not in any version of the C standard). @xref{C Dialect
6579Options,,Options Controlling C Dialect}.
6580
6581@table @gcctabopt
d77de738
ML
6582@opindex Wformat
6583@opindex Wformat=1
ddf6fe37
AA
6584@item -Wformat=1
6585@itemx -Wformat
d77de738
ML
6586Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6587@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6588@option{-Wformat} also checks for null format arguments for several
6589functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6590aspects of this level of format checking can be disabled by the
6591options: @option{-Wno-format-contains-nul},
6592@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6593@option{-Wformat} is enabled by @option{-Wall}.
6594
d77de738 6595@opindex Wformat=2
ddf6fe37 6596@item -Wformat=2
d77de738
ML
6597Enable @option{-Wformat} plus additional format checks. Currently
6598equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6599-Wformat-y2k}.
6600@end table
6601
d77de738
ML
6602@opindex Wno-format-contains-nul
6603@opindex Wformat-contains-nul
ddf6fe37 6604@item -Wno-format-contains-nul
d77de738
ML
6605If @option{-Wformat} is specified, do not warn about format strings that
6606contain NUL bytes.
6607
d77de738
ML
6608@opindex Wno-format-extra-args
6609@opindex Wformat-extra-args
ddf6fe37 6610@item -Wno-format-extra-args
d77de738
ML
6611If @option{-Wformat} is specified, do not warn about excess arguments to a
6612@code{printf} or @code{scanf} format function. The C standard specifies
6613that such arguments are ignored.
6614
6615Where the unused arguments lie between used arguments that are
6616specified with @samp{$} operand number specifications, normally
6617warnings are still given, since the implementation could not know what
6618type to pass to @code{va_arg} to skip the unused arguments. However,
6619in the case of @code{scanf} formats, this option suppresses the
6620warning if the unused arguments are all pointers, since the Single
6621Unix Specification says that such unused arguments are allowed.
6622
d77de738
ML
6623@opindex Wformat-overflow
6624@opindex Wno-format-overflow
ddf6fe37
AA
6625@item -Wformat-overflow
6626@itemx -Wformat-overflow=@var{level}
d77de738
ML
6627Warn about calls to formatted input/output functions such as @code{sprintf}
6628and @code{vsprintf} that might overflow the destination buffer. When the
6629exact number of bytes written by a format directive cannot be determined
6630at compile-time it is estimated based on heuristics that depend on the
6631@var{level} argument and on optimization. While enabling optimization
6632will in most cases improve the accuracy of the warning, it may also
6633result in false positives.
6634
6635@table @gcctabopt
d77de738
ML
6636@opindex Wformat-overflow
6637@opindex Wno-format-overflow
ddf6fe37
AA
6638@item -Wformat-overflow
6639@itemx -Wformat-overflow=1
d77de738
ML
6640Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6641employs a conservative approach that warns only about calls that most
6642likely overflow the buffer. At this level, numeric arguments to format
6643directives with unknown values are assumed to have the value of one, and
6644strings of unknown length to be empty. Numeric arguments that are known
6645to be bounded to a subrange of their type, or string arguments whose output
6646is bounded either by their directive's precision or by a finite set of
6647string literals, are assumed to take on the value within the range that
6648results in the most bytes on output. For example, the call to @code{sprintf}
6649below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6650the terminating NUL character (@code{'\0'}) appended by the function
6651to the destination buffer will be written past its end. Increasing
6652the size of the buffer by a single byte is sufficient to avoid the
6653warning, though it may not be sufficient to avoid the overflow.
6654
6655@smallexample
6656void f (int a, int b)
6657@{
6658 char buf [13];
6659 sprintf (buf, "a = %i, b = %i\n", a, b);
6660@}
6661@end smallexample
6662
6663@item -Wformat-overflow=2
6664Level @var{2} warns also about calls that might overflow the destination
6665buffer given an argument of sufficient length or magnitude. At level
6666@var{2}, unknown numeric arguments are assumed to have the minimum
6667representable value for signed types with a precision greater than 1, and
6668the maximum representable value otherwise. Unknown string arguments whose
6669length cannot be assumed to be bounded either by the directive's precision,
6670or by a finite set of string literals they may evaluate to, or the character
6671array they may point to, are assumed to be 1 character long.
6672
6673At level @var{2}, the call in the example above is again diagnosed, but
6674this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6675@code{%i} directive will write some of its digits beyond the end of
6676the destination buffer. To make the call safe regardless of the values
6677of the two variables, the size of the destination buffer must be increased
6678to at least 34 bytes. GCC includes the minimum size of the buffer in
6679an informational note following the warning.
6680
6681An alternative to increasing the size of the destination buffer is to
6682constrain the range of formatted values. The maximum length of string
6683arguments can be bounded by specifying the precision in the format
6684directive. When numeric arguments of format directives can be assumed
6685to be bounded by less than the precision of their type, choosing
6686an appropriate length modifier to the format specifier will reduce
6687the required buffer size. For example, if @var{a} and @var{b} in the
6688example above can be assumed to be within the precision of
6689the @code{short int} type then using either the @code{%hi} format
6690directive or casting the argument to @code{short} reduces the maximum
6691required size of the buffer to 24 bytes.
6692
6693@smallexample
6694void f (int a, int b)
6695@{
6696 char buf [23];
6697 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6698@}
6699@end smallexample
6700@end table
6701
d77de738
ML
6702@opindex Wno-format-zero-length
6703@opindex Wformat-zero-length
ddf6fe37 6704@item -Wno-format-zero-length
d77de738
ML
6705If @option{-Wformat} is specified, do not warn about zero-length formats.
6706The C standard specifies that zero-length formats are allowed.
6707
d77de738
ML
6708@opindex Wformat-nonliteral
6709@opindex Wno-format-nonliteral
ddf6fe37 6710@item -Wformat-nonliteral
d77de738
ML
6711If @option{-Wformat} is specified, also warn if the format string is not a
6712string literal and so cannot be checked, unless the format function
6713takes its format arguments as a @code{va_list}.
6714
d77de738
ML
6715@opindex Wformat-security
6716@opindex Wno-format-security
ddf6fe37 6717@item -Wformat-security
d77de738
ML
6718If @option{-Wformat} is specified, also warn about uses of format
6719functions that represent possible security problems. At present, this
6720warns about calls to @code{printf} and @code{scanf} functions where the
6721format string is not a string literal and there are no format arguments,
6722as in @code{printf (foo);}. This may be a security hole if the format
6723string came from untrusted input and contains @samp{%n}. (This is
6724currently a subset of what @option{-Wformat-nonliteral} warns about, but
6725in future warnings may be added to @option{-Wformat-security} that are not
6726included in @option{-Wformat-nonliteral}.)
6727
d77de738
ML
6728@opindex Wformat-signedness
6729@opindex Wno-format-signedness
ddf6fe37 6730@item -Wformat-signedness
d77de738
ML
6731If @option{-Wformat} is specified, also warn if the format string
6732requires an unsigned argument and the argument is signed and vice versa.
6733
d77de738
ML
6734@opindex Wformat-truncation
6735@opindex Wno-format-truncation
ddf6fe37
AA
6736@item -Wformat-truncation
6737@itemx -Wformat-truncation=@var{level}
d77de738
ML
6738Warn about calls to formatted input/output functions such as @code{snprintf}
6739and @code{vsnprintf} that might result in output truncation. When the exact
6740number of bytes written by a format directive cannot be determined at
6741compile-time it is estimated based on heuristics that depend on
6742the @var{level} argument and on optimization. While enabling optimization
6743will in most cases improve the accuracy of the warning, it may also result
6744in false positives. Except as noted otherwise, the option uses the same
6745logic @option{-Wformat-overflow}.
6746
6747@table @gcctabopt
d77de738
ML
6748@opindex Wformat-truncation
6749@opindex Wno-format-truncation
ddf6fe37
AA
6750@item -Wformat-truncation
6751@itemx -Wformat-truncation=1
d77de738
ML
6752Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6753employs a conservative approach that warns only about calls to bounded
6754functions whose return value is unused and that will most likely result
6755in output truncation.
6756
6757@item -Wformat-truncation=2
6758Level @var{2} warns also about calls to bounded functions whose return
6759value is used and that might result in truncation given an argument of
6760sufficient length or magnitude.
6761@end table
6762
d77de738
ML
6763@opindex Wformat-y2k
6764@opindex Wno-format-y2k
ddf6fe37 6765@item -Wformat-y2k
d77de738
ML
6766If @option{-Wformat} is specified, also warn about @code{strftime}
6767formats that may yield only a two-digit year.
6768
d77de738
ML
6769@opindex Wnonnull
6770@opindex Wno-nonnull
ddf6fe37 6771@item -Wnonnull
d77de738
ML
6772Warn about passing a null pointer for arguments marked as
6773requiring a non-null value by the @code{nonnull} function attribute.
6774
6775@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6776can be disabled with the @option{-Wno-nonnull} option.
6777
d77de738
ML
6778@opindex Wnonnull-compare
6779@opindex Wno-nonnull-compare
ddf6fe37 6780@item -Wnonnull-compare
d77de738
ML
6781Warn when comparing an argument marked with the @code{nonnull}
6782function attribute against null inside the function.
6783
6784@option{-Wnonnull-compare} is included in @option{-Wall}. It
6785can be disabled with the @option{-Wno-nonnull-compare} option.
6786
d77de738
ML
6787@opindex Wnull-dereference
6788@opindex Wno-null-dereference
ddf6fe37 6789@item -Wnull-dereference
d77de738
ML
6790Warn if the compiler detects paths that trigger erroneous or
6791undefined behavior due to dereferencing a null pointer. This option
6792is only active when @option{-fdelete-null-pointer-checks} is active,
6793which is enabled by optimizations in most targets. The precision of
6794the warnings depends on the optimization options used.
6795
2ae5384d
JM
6796@opindex Wnrvo
6797@opindex Wno-nrvo
6798@item -Wnrvo @r{(C++ and Objective-C++ only)}
6799Warn if the compiler does not elide the copy from a local variable to
6800the return value of a function in a context where it is allowed by
6801[class.copy.elision]. This elision is commonly known as the Named
6802Return Value Optimization. For instance, in the example below the
72cfa0f7 6803compiler cannot elide copies from both v1 and v2, so it elides neither.
2ae5384d
JM
6804
6805@smallexample
6806std::vector<int> f()
6807@{
6808 std::vector<int> v1, v2;
6809 // ...
6810 if (cond) return v1;
6811 else return v2; // warning: not eliding copy
6812@}
6813@end smallexample
6814
d77de738
ML
6815@opindex Winfinite-recursion
6816@opindex Wno-infinite-recursion
ddf6fe37 6817@item -Winfinite-recursion
d77de738
ML
6818Warn about infinitely recursive calls. The warning is effective at all
6819optimization levels but requires optimization in order to detect infinite
6820recursion in calls between two or more functions.
6821@option{-Winfinite-recursion} is included in @option{-Wall}.
6822
ce51e843
ML
6823Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6824similar diagnostic, but is implemented in a different way (as part of
6825@option{-fanalyzer}).
6826
d77de738
ML
6827@opindex Winit-self
6828@opindex Wno-init-self
ddf6fe37 6829@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6830Warn about uninitialized variables that are initialized with themselves.
6831Note this option can only be used with the @option{-Wuninitialized} option.
6832
6833For example, GCC warns about @code{i} being uninitialized in the
6834following snippet only when @option{-Winit-self} has been specified:
6835@smallexample
6836@group
6837int f()
6838@{
6839 int i = i;
6840 return i;
6841@}
6842@end group
6843@end smallexample
6844
6845This warning is enabled by @option{-Wall} in C++.
6846
d77de738
ML
6847@opindex Wimplicit-int
6848@opindex Wno-implicit-int
ddf6fe37 6849@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6850This option controls warnings when a declaration does not specify a type.
6851This warning is enabled by default in C99 and later dialects of C,
6852and also by @option{-Wall}.
6853
5fccebdb
JM
6854This warning is upgraded to an error by @option{-pedantic-errors}.
6855
d77de738
ML
6856@opindex Wimplicit-function-declaration
6857@opindex Wno-implicit-function-declaration
ddf6fe37 6858@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6859This option controls warnings when a function is used before being declared.
6860This warning is enabled by default in C99 and later dialects of C,
6861and also by @option{-Wall}.
5fccebdb
JM
6862
6863This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 6864
d77de738
ML
6865@opindex Wimplicit
6866@opindex Wno-implicit
ddf6fe37 6867@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6868Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6869This warning is enabled by @option{-Wall}.
6870
d77de738
ML
6871@opindex Wimplicit-fallthrough
6872@opindex Wno-implicit-fallthrough
ddf6fe37 6873@item -Wimplicit-fallthrough
d77de738
ML
6874@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6875and @option{-Wno-implicit-fallthrough} is the same as
6876@option{-Wimplicit-fallthrough=0}.
6877
d77de738 6878@opindex Wimplicit-fallthrough=
ddf6fe37 6879@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6880Warn when a switch case falls through. For example:
6881
6882@smallexample
6883@group
6884switch (cond)
6885 @{
6886 case 1:
6887 a = 1;
6888 break;
6889 case 2:
6890 a = 2;
6891 case 3:
6892 a = 3;
6893 break;
6894 @}
6895@end group
6896@end smallexample
6897
6898This warning does not warn when the last statement of a case cannot
6899fall through, e.g. when there is a return statement or a call to function
6900declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6901also takes into account control flow statements, such as ifs, and only
6902warns when appropriate. E.g.@:
6903
6904@smallexample
6905@group
6906switch (cond)
6907 @{
6908 case 1:
6909 if (i > 3) @{
6910 bar (5);
6911 break;
6912 @} else if (i < 1) @{
6913 bar (0);
6914 @} else
6915 return;
6916 default:
6917 @dots{}
6918 @}
6919@end group
6920@end smallexample
6921
6922Since there are occasions where a switch case fall through is desirable,
6923GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6924to be used along with a null statement to suppress this warning that
6925would normally occur:
6926
6927@smallexample
6928@group
6929switch (cond)
6930 @{
6931 case 1:
6932 bar (0);
6933 __attribute__ ((fallthrough));
6934 default:
6935 @dots{}
6936 @}
6937@end group
6938@end smallexample
6939
6940C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6941warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6942or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6943Instead of these attributes, it is also possible to add a fallthrough comment
6944to silence the warning. The whole body of the C or C++ style comment should
6945match the given regular expressions listed below. The option argument @var{n}
6946specifies what kind of comments are accepted:
6947
6948@itemize @bullet
6949
6950@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6951
6952@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6953expression, any comment is used as fallthrough comment.
6954
6955@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6956@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6957
6958@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6959following regular expressions:
6960
6961@itemize @bullet
6962
6963@item @code{-fallthrough}
6964
6965@item @code{@@fallthrough@@}
6966
6967@item @code{lint -fallthrough[ \t]*}
6968
6969@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6970
6971@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6972
6973@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6974
6975@end itemize
6976
6977@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6978following regular expressions:
6979
6980@itemize @bullet
6981
6982@item @code{-fallthrough}
6983
6984@item @code{@@fallthrough@@}
6985
6986@item @code{lint -fallthrough[ \t]*}
6987
6988@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6989
6990@end itemize
6991
6992@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6993fallthrough comments, only attributes disable the warning.
6994
6995@end itemize
6996
6997The comment needs to be followed after optional whitespace and other comments
6998by @code{case} or @code{default} keywords or by a user label that precedes some
6999@code{case} or @code{default} label.
7000
7001@smallexample
7002@group
7003switch (cond)
7004 @{
7005 case 1:
7006 bar (0);
7007 /* FALLTHRU */
7008 default:
7009 @dots{}
7010 @}
7011@end group
7012@end smallexample
7013
7014The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7015
d77de738
ML
7016@opindex Wif-not-aligned
7017@opindex Wno-if-not-aligned
ddf6fe37 7018@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7019Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7020should be issued. These warnings are enabled by default.
7021
d77de738
ML
7022@opindex Wignored-qualifiers
7023@opindex Wno-ignored-qualifiers
ddf6fe37 7024@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
7025Warn if the return type of a function has a type qualifier
7026such as @code{const}. For ISO C such a type qualifier has no effect,
7027since the value returned by a function is not an lvalue.
7028For C++, the warning is only emitted for scalar types or @code{void}.
7029ISO C prohibits qualified @code{void} return types on function
7030definitions, so such return types always receive a warning
7031even without this option.
7032
7033This warning is also enabled by @option{-Wextra}.
7034
d77de738
ML
7035@opindex Wignored-attributes
7036@opindex Wno-ignored-attributes
ddf6fe37 7037@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
7038This option controls warnings when an attribute is ignored.
7039This is different from the
7040@option{-Wattributes} option in that it warns whenever the compiler decides
7041to drop an attribute, not that the attribute is either unknown, used in a
7042wrong place, etc. This warning is enabled by default.
7043
d77de738
ML
7044@opindex Wmain
7045@opindex Wno-main
ddf6fe37 7046@item -Wmain
d77de738
ML
7047Warn if the type of @code{main} is suspicious. @code{main} should be
7048a function with external linkage, returning int, taking either zero
7049arguments, two, or three arguments of appropriate types. This warning
7050is enabled by default in C++ and is enabled by either @option{-Wall}
7051or @option{-Wpedantic}.
7052
5fccebdb
JM
7053This warning is upgraded to an error by @option{-pedantic-errors}.
7054
d77de738
ML
7055@opindex Wmisleading-indentation
7056@opindex Wno-misleading-indentation
ddf6fe37 7057@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
7058Warn when the indentation of the code does not reflect the block structure.
7059Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7060@code{for} clauses with a guarded statement that does not use braces,
7061followed by an unguarded statement with the same indentation.
7062
7063In the following example, the call to ``bar'' is misleadingly indented as
7064if it were guarded by the ``if'' conditional.
7065
7066@smallexample
7067 if (some_condition ())
7068 foo ();
7069 bar (); /* Gotcha: this is not guarded by the "if". */
7070@end smallexample
7071
7072In the case of mixed tabs and spaces, the warning uses the
7073@option{-ftabstop=} option to determine if the statements line up
7074(defaulting to 8).
7075
7076The warning is not issued for code involving multiline preprocessor logic
7077such as the following example.
7078
7079@smallexample
7080 if (flagA)
7081 foo (0);
7082#if SOME_CONDITION_THAT_DOES_NOT_HOLD
7083 if (flagB)
7084#endif
7085 foo (1);
7086@end smallexample
7087
7088The warning is not issued after a @code{#line} directive, since this
7089typically indicates autogenerated code, and no assumptions can be made
7090about the layout of the file that the directive references.
7091
7092This warning is enabled by @option{-Wall} in C and C++.
7093
d77de738
ML
7094@opindex Wmissing-attributes
7095@opindex Wno-missing-attributes
ddf6fe37 7096@item -Wmissing-attributes
d77de738
ML
7097Warn when a declaration of a function is missing one or more attributes
7098that a related function is declared with and whose absence may adversely
7099affect the correctness or efficiency of generated code. For example,
7100the warning is issued for declarations of aliases that use attributes
7101to specify less restrictive requirements than those of their targets.
7102This typically represents a potential optimization opportunity.
7103By contrast, the @option{-Wattribute-alias=2} option controls warnings
7104issued when the alias is more restrictive than the target, which could
7105lead to incorrect code generation.
7106Attributes considered include @code{alloc_align}, @code{alloc_size},
7107@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7108@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7109@code{returns_nonnull}, and @code{returns_twice}.
7110
7111In C++, the warning is issued when an explicit specialization of a primary
7112template declared with attribute @code{alloc_align}, @code{alloc_size},
7113@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7114or @code{nonnull} is declared without it. Attributes @code{deprecated},
7115@code{error}, and @code{warning} suppress the warning.
7116(@pxref{Function Attributes}).
7117
7118You can use the @code{copy} attribute to apply the same
7119set of attributes to a declaration as that on another declaration without
7120explicitly enumerating the attributes. This attribute can be applied
7121to declarations of functions (@pxref{Common Function Attributes}),
7122variables (@pxref{Common Variable Attributes}), or types
7123(@pxref{Common Type Attributes}).
7124
7125@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7126
7127For example, since the declaration of the primary function template
7128below makes use of both attribute @code{malloc} and @code{alloc_size}
7129the declaration of the explicit specialization of the template is
7130diagnosed because it is missing one of the attributes.
7131
7132@smallexample
7133template <class T>
7134T* __attribute__ ((malloc, alloc_size (1)))
7135allocate (size_t);
7136
7137template <>
7138void* __attribute__ ((malloc)) // missing alloc_size
7139allocate<void> (size_t);
7140@end smallexample
7141
d77de738
ML
7142@opindex Wmissing-braces
7143@opindex Wno-missing-braces
ddf6fe37 7144@item -Wmissing-braces
d77de738
ML
7145Warn if an aggregate or union initializer is not fully bracketed. In
7146the following example, the initializer for @code{a} is not fully
7147bracketed, but that for @code{b} is fully bracketed.
7148
7149@smallexample
7150int a[2][2] = @{ 0, 1, 2, 3 @};
7151int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7152@end smallexample
7153
7154This warning is enabled by @option{-Wall}.
7155
d77de738
ML
7156@opindex Wmissing-include-dirs
7157@opindex Wno-missing-include-dirs
ddf6fe37 7158@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
72cfa0f7 7159Warn if a user-supplied include directory does not exist. This option is disabled
d77de738
ML
7160by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7161enabled by default by warning for -I and -J, only.
7162
d77de738
ML
7163@opindex Wmissing-profile
7164@opindex Wno-missing-profile
ddf6fe37 7165@item -Wno-missing-profile
d77de738
ML
7166This option controls warnings if feedback profiles are missing when using the
7167@option{-fprofile-use} option.
7168This option diagnoses those cases where a new function or a new file is added
7169between compiling with @option{-fprofile-generate} and with
7170@option{-fprofile-use}, without regenerating the profiles.
7171In these cases, the profile feedback data files do not contain any
7172profile feedback information for
7173the newly added function or file respectively. Also, in the case when profile
7174count data (.gcda) files are removed, GCC cannot use any profile feedback
7175information. In all these cases, warnings are issued to inform you that a
7176profile generation step is due.
7177Ignoring the warning can result in poorly optimized code.
7178@option{-Wno-missing-profile} can be used to
7179disable the warning, but this is not recommended and should be done only
7180when non-existent profile data is justified.
7181
d77de738
ML
7182@opindex Wmismatched-dealloc
7183@opindex Wno-mismatched-dealloc
ddf6fe37 7184@item -Wmismatched-dealloc
d77de738
ML
7185
7186Warn for calls to deallocation functions with pointer arguments returned
7187from from allocations functions for which the former isn't a suitable
7188deallocator. A pair of functions can be associated as matching allocators
7189and deallocators by use of attribute @code{malloc}. Unless disabled by
7190the @option{-fno-builtin} option the standard functions @code{calloc},
7191@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7192forms of C++ @code{operator new} and @code{operator delete} are implicitly
7193associated as matching allocators and deallocators. In the following
7194example @code{mydealloc} is the deallocator for pointers returned from
7195@code{myalloc}.
7196
7197@smallexample
7198void mydealloc (void*);
7199
7200__attribute__ ((malloc (mydealloc, 1))) void*
7201myalloc (size_t);
7202
7203void f (void)
7204@{
7205 void *p = myalloc (32);
7206 // @dots{}use p@dots{}
7207 free (p); // warning: not a matching deallocator for myalloc
7208 mydealloc (p); // ok
7209@}
7210@end smallexample
7211
7212In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7213mismatches involving either @code{operator new} or @code{operator delete}.
7214
7215Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7216
d77de738
ML
7217@opindex Wmultistatement-macros
7218@opindex Wno-multistatement-macros
ddf6fe37 7219@item -Wmultistatement-macros
d77de738
ML
7220Warn about unsafe multiple statement macros that appear to be guarded
7221by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7222@code{while}, in which only the first statement is actually guarded after
7223the macro is expanded.
7224
7225For example:
7226
7227@smallexample
7228#define DOIT x++; y++
7229if (c)
7230 DOIT;
7231@end smallexample
7232
7233will increment @code{y} unconditionally, not just when @code{c} holds.
7234The can usually be fixed by wrapping the macro in a do-while loop:
7235@smallexample
7236#define DOIT do @{ x++; y++; @} while (0)
7237if (c)
7238 DOIT;
7239@end smallexample
7240
7241This warning is enabled by @option{-Wall} in C and C++.
7242
d77de738
ML
7243@opindex Wparentheses
7244@opindex Wno-parentheses
ddf6fe37 7245@item -Wparentheses
d77de738
ML
7246Warn if parentheses are omitted in certain contexts, such
7247as when there is an assignment in a context where a truth value
7248is expected, or when operators are nested whose precedence people
7249often get confused about.
7250
7251Also warn if a comparison like @code{x<=y<=z} appears; this is
7252equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7253interpretation from that of ordinary mathematical notation.
7254
7255Also warn for dangerous uses of the GNU extension to
7256@code{?:} with omitted middle operand. When the condition
7257in the @code{?}: operator is a boolean expression, the omitted value is
7258always 1. Often programmers expect it to be a value computed
7259inside the conditional expression instead.
7260
7261For C++ this also warns for some cases of unnecessary parentheses in
7262declarations, which can indicate an attempt at a function call instead
7263of a declaration:
7264@smallexample
7265@{
7266 // Declares a local variable called mymutex.
7267 std::unique_lock<std::mutex> (mymutex);
7268 // User meant std::unique_lock<std::mutex> lock (mymutex);
7269@}
7270@end smallexample
7271
7272This warning is enabled by @option{-Wall}.
7273
d77de738
ML
7274@opindex Wself-move
7275@opindex Wno-self-move
ddf6fe37 7276@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7277This warning warns when a value is moved to itself with @code{std::move}.
7278Such a @code{std::move} typically has no effect.
7279
7280@smallexample
7281struct T @{
7282@dots{}
7283@};
7284void fn()
7285@{
7286 T t;
7287 @dots{}
7288 t = std::move (t);
7289@}
7290@end smallexample
7291
7292This warning is enabled by @option{-Wall}.
7293
d77de738
ML
7294@opindex Wsequence-point
7295@opindex Wno-sequence-point
ddf6fe37 7296@item -Wsequence-point
d77de738
ML
7297Warn about code that may have undefined semantics because of violations
7298of sequence point rules in the C and C++ standards.
7299
7300The C and C++ standards define the order in which expressions in a C/C++
7301program are evaluated in terms of @dfn{sequence points}, which represent
7302a partial ordering between the execution of parts of the program: those
7303executed before the sequence point, and those executed after it. These
7304occur after the evaluation of a full expression (one which is not part
7305of a larger expression), after the evaluation of the first operand of a
7306@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7307function is called (but after the evaluation of its arguments and the
7308expression denoting the called function), and in certain other places.
7309Other than as expressed by the sequence point rules, the order of
7310evaluation of subexpressions of an expression is not specified. All
7311these rules describe only a partial order rather than a total order,
7312since, for example, if two functions are called within one expression
7313with no sequence point between them, the order in which the functions
7314are called is not specified. However, the standards committee have
7315ruled that function calls do not overlap.
7316
7317It is not specified when between sequence points modifications to the
7318values of objects take effect. Programs whose behavior depends on this
7319have undefined behavior; the C and C++ standards specify that ``Between
7320the previous and next sequence point an object shall have its stored
7321value modified at most once by the evaluation of an expression.
7322Furthermore, the prior value shall be read only to determine the value
7323to be stored.''. If a program breaks these rules, the results on any
7324particular implementation are entirely unpredictable.
7325
7326Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7327= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7328diagnosed by this option, and it may give an occasional false positive
7329result, but in general it has been found fairly effective at detecting
7330this sort of problem in programs.
7331
7332The C++17 standard will define the order of evaluation of operands in
7333more cases: in particular it requires that the right-hand side of an
7334assignment be evaluated before the left-hand side, so the above
7335examples are no longer undefined. But this option will still warn
7336about them, to help people avoid writing code that is undefined in C
7337and earlier revisions of C++.
7338
7339The standard is worded confusingly, therefore there is some debate
7340over the precise meaning of the sequence point rules in subtle cases.
7341Links to discussions of the problem, including proposed formal
7342definitions, may be found on the GCC readings page, at
7343@uref{https://gcc.gnu.org/@/readings.html}.
7344
7345This warning is enabled by @option{-Wall} for C and C++.
7346
d77de738
ML
7347@opindex Wno-return-local-addr
7348@opindex Wreturn-local-addr
ddf6fe37 7349@item -Wno-return-local-addr
d77de738
ML
7350Do not warn about returning a pointer (or in C++, a reference) to a
7351variable that goes out of scope after the function returns.
7352
d77de738
ML
7353@opindex Wreturn-type
7354@opindex Wno-return-type
ddf6fe37 7355@item -Wreturn-type
d77de738
ML
7356Warn whenever a function is defined with a return type that defaults
7357to @code{int}. Also warn about any @code{return} statement with no
7358return value in a function whose return type is not @code{void}
7359(falling off the end of the function body is considered returning
7360without a value).
7361
7362For C only, warn about a @code{return} statement with an expression in a
7363function whose return type is @code{void}, unless the expression type is
7364also @code{void}. As a GNU extension, the latter case is accepted
7365without a warning unless @option{-Wpedantic} is used. Attempting
7366to use the return value of a non-@code{void} function other than @code{main}
7367that flows off the end by reaching the closing curly brace that terminates
7368the function is undefined.
7369
7370Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7371than @code{main} results in undefined behavior even when the value of
7372the function is not used.
7373
7374This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7375
d77de738
ML
7376@opindex Wshift-count-negative
7377@opindex Wno-shift-count-negative
ddf6fe37 7378@item -Wno-shift-count-negative
d77de738
ML
7379Controls warnings if a shift count is negative.
7380This warning is enabled by default.
7381
d77de738
ML
7382@opindex Wshift-count-overflow
7383@opindex Wno-shift-count-overflow
ddf6fe37 7384@item -Wno-shift-count-overflow
d77de738
ML
7385Controls warnings if a shift count is greater than or equal to the bit width
7386of the type. This warning is enabled by default.
7387
d77de738
ML
7388@opindex Wshift-negative-value
7389@opindex Wno-shift-negative-value
ddf6fe37 7390@item -Wshift-negative-value
d77de738
ML
7391Warn if left shifting a negative value. This warning is enabled by
7392@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7393
d77de738
ML
7394@opindex Wshift-overflow
7395@opindex Wno-shift-overflow
ddf6fe37
AA
7396@item -Wno-shift-overflow
7397@itemx -Wshift-overflow=@var{n}
d77de738
ML
7398These options control warnings about left shift overflows.
7399
7400@table @gcctabopt
7401@item -Wshift-overflow=1
7402This is the warning level of @option{-Wshift-overflow} and is enabled
7403by default in C99 and C++11 modes (and newer). This warning level does
7404not warn about left-shifting 1 into the sign bit. (However, in C, such
7405an overflow is still rejected in contexts where an integer constant expression
7406is required.) No warning is emitted in C++20 mode (and newer), as signed left
7407shifts always wrap.
7408
7409@item -Wshift-overflow=2
7410This warning level also warns about left-shifting 1 into the sign bit,
7411unless C++14 mode (or newer) is active.
7412@end table
7413
d77de738
ML
7414@opindex Wswitch
7415@opindex Wno-switch
ddf6fe37 7416@item -Wswitch
d77de738
ML
7417Warn whenever a @code{switch} statement has an index of enumerated type
7418and lacks a @code{case} for one or more of the named codes of that
7419enumeration. (The presence of a @code{default} label prevents this
7420warning.) @code{case} labels outside the enumeration range also
7421provoke warnings when this option is used (even if there is a
7422@code{default} label).
7423This warning is enabled by @option{-Wall}.
7424
d77de738
ML
7425@opindex Wswitch-default
7426@opindex Wno-switch-default
ddf6fe37 7427@item -Wswitch-default
d77de738
ML
7428Warn whenever a @code{switch} statement does not have a @code{default}
7429case.
7430
d77de738
ML
7431@opindex Wswitch-enum
7432@opindex Wno-switch-enum
ddf6fe37 7433@item -Wswitch-enum
d77de738
ML
7434Warn whenever a @code{switch} statement has an index of enumerated type
7435and lacks a @code{case} for one or more of the named codes of that
7436enumeration. @code{case} labels outside the enumeration range also
7437provoke warnings when this option is used. The only difference
7438between @option{-Wswitch} and this option is that this option gives a
7439warning about an omitted enumeration code even if there is a
7440@code{default} label.
7441
d77de738
ML
7442@opindex Wswitch-bool
7443@opindex Wno-switch-bool
ddf6fe37 7444@item -Wno-switch-bool
d77de738
ML
7445Do not warn when a @code{switch} statement has an index of boolean type
7446and the case values are outside the range of a boolean type.
7447It is possible to suppress this warning by casting the controlling
7448expression to a type other than @code{bool}. For example:
7449@smallexample
7450@group
7451switch ((int) (a == 4))
7452 @{
7453 @dots{}
7454 @}
7455@end group
7456@end smallexample
7457This warning is enabled by default for C and C++ programs.
7458
d77de738
ML
7459@opindex Wswitch-outside-range
7460@opindex Wno-switch-outside-range
ddf6fe37 7461@item -Wno-switch-outside-range
d77de738
ML
7462This option controls warnings when a @code{switch} case has a value
7463that is outside of its
7464respective type range. This warning is enabled by default for
7465C and C++ programs.
7466
d77de738
ML
7467@opindex Wswitch-unreachable
7468@opindex Wno-switch-unreachable
ddf6fe37 7469@item -Wno-switch-unreachable
d77de738
ML
7470Do not warn when a @code{switch} statement contains statements between the
7471controlling expression and the first case label, which will never be
7472executed. For example:
7473@smallexample
7474@group
7475switch (cond)
7476 @{
7477 i = 15;
7478 @dots{}
7479 case 5:
7480 @dots{}
7481 @}
7482@end group
7483@end smallexample
7484@option{-Wswitch-unreachable} does not warn if the statement between the
7485controlling expression and the first case label is just a declaration:
7486@smallexample
7487@group
7488switch (cond)
7489 @{
7490 int i;
7491 @dots{}
7492 case 5:
7493 i = 5;
7494 @dots{}
7495 @}
7496@end group
7497@end smallexample
7498This warning is enabled by default for C and C++ programs.
7499
d77de738
ML
7500@opindex Wsync-nand
7501@opindex Wno-sync-nand
ddf6fe37 7502@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7503Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7504built-in functions are used. These functions changed semantics in GCC 4.4.
7505
d77de738
ML
7506@opindex Wtrivial-auto-var-init
7507@opindex Wno-trivial-auto-var-init
ddf6fe37 7508@item -Wtrivial-auto-var-init
d77de738
ML
7509Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7510variable. A common situation is an automatic variable that is declared
7511between the controlling expression and the first case label of a @code{switch}
7512statement.
7513
d77de738
ML
7514@opindex Wunused-but-set-parameter
7515@opindex Wno-unused-but-set-parameter
ddf6fe37 7516@item -Wunused-but-set-parameter
d77de738
ML
7517Warn whenever a function parameter is assigned to, but otherwise unused
7518(aside from its declaration).
7519
7520To suppress this warning use the @code{unused} attribute
7521(@pxref{Variable Attributes}).
7522
7523This warning is also enabled by @option{-Wunused} together with
7524@option{-Wextra}.
7525
d77de738
ML
7526@opindex Wunused-but-set-variable
7527@opindex Wno-unused-but-set-variable
ddf6fe37 7528@item -Wunused-but-set-variable
d77de738
ML
7529Warn whenever a local variable is assigned to, but otherwise unused
7530(aside from its declaration).
7531This warning is enabled by @option{-Wall}.
7532
7533To suppress this warning use the @code{unused} attribute
7534(@pxref{Variable Attributes}).
7535
7536This warning is also enabled by @option{-Wunused}, which is enabled
7537by @option{-Wall}.
7538
d77de738
ML
7539@opindex Wunused-function
7540@opindex Wno-unused-function
ddf6fe37 7541@item -Wunused-function
d77de738
ML
7542Warn whenever a static function is declared but not defined or a
7543non-inline static function is unused.
7544This warning is enabled by @option{-Wall}.
7545
d77de738
ML
7546@opindex Wunused-label
7547@opindex Wno-unused-label
ddf6fe37 7548@item -Wunused-label
d77de738
ML
7549Warn whenever a label is declared but not used.
7550This warning is enabled by @option{-Wall}.
7551
7552To suppress this warning use the @code{unused} attribute
7553(@pxref{Variable Attributes}).
7554
d77de738
ML
7555@opindex Wunused-local-typedefs
7556@opindex Wno-unused-local-typedefs
ddf6fe37 7557@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7558Warn when a typedef locally defined in a function is not used.
7559This warning is enabled by @option{-Wall}.
7560
d77de738
ML
7561@opindex Wunused-parameter
7562@opindex Wno-unused-parameter
ddf6fe37 7563@item -Wunused-parameter
d77de738
ML
7564Warn whenever a function parameter is unused aside from its declaration.
7565
7566To suppress this warning use the @code{unused} attribute
7567(@pxref{Variable Attributes}).
7568
d77de738
ML
7569@opindex Wunused-result
7570@opindex Wno-unused-result
ddf6fe37 7571@item -Wno-unused-result
d77de738
ML
7572Do not warn if a caller of a function marked with attribute
7573@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7574its return value. The default is @option{-Wunused-result}.
7575
d77de738
ML
7576@opindex Wunused-variable
7577@opindex Wno-unused-variable
ddf6fe37 7578@item -Wunused-variable
d77de738
ML
7579Warn whenever a local or static variable is unused aside from its
7580declaration. This option implies @option{-Wunused-const-variable=1} for C,
7581but not for C++. This warning is enabled by @option{-Wall}.
7582
7583To suppress this warning use the @code{unused} attribute
7584(@pxref{Variable Attributes}).
7585
d77de738
ML
7586@opindex Wunused-const-variable
7587@opindex Wno-unused-const-variable
ddf6fe37
AA
7588@item -Wunused-const-variable
7589@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7590Warn whenever a constant static variable is unused aside from its declaration.
7591@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7592for C, but not for C++. In C this declares variable storage, but in C++ this
7593is not an error since const variables take the place of @code{#define}s.
7594
7595To suppress this warning use the @code{unused} attribute
7596(@pxref{Variable Attributes}).
7597
7598@table @gcctabopt
7599@item -Wunused-const-variable=1
7600This is the warning level that is enabled by @option{-Wunused-variable} for
7601C. It warns only about unused static const variables defined in the main
7602compilation unit, but not about static const variables declared in any
7603header included.
7604
7605@item -Wunused-const-variable=2
7606This warning level also warns for unused constant static variables in
7607headers (excluding system headers). This is the warning level of
7608@option{-Wunused-const-variable} and must be explicitly requested since
7609in C++ this isn't an error and in C it might be harder to clean up all
7610headers included.
7611@end table
7612
d77de738
ML
7613@opindex Wunused-value
7614@opindex Wno-unused-value
ddf6fe37 7615@item -Wunused-value
d77de738
ML
7616Warn whenever a statement computes a result that is explicitly not
7617used. To suppress this warning cast the unused expression to
7618@code{void}. This includes an expression-statement or the left-hand
7619side of a comma expression that contains no side effects. For example,
7620an expression such as @code{x[i,j]} causes a warning, while
7621@code{x[(void)i,j]} does not.
7622
7623This warning is enabled by @option{-Wall}.
7624
d77de738
ML
7625@opindex Wunused
7626@opindex Wno-unused
ddf6fe37 7627@item -Wunused
d77de738
ML
7628All the above @option{-Wunused} options combined.
7629
7630In order to get a warning about an unused function parameter, you must
7631either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7632@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7633
d77de738
ML
7634@opindex Wuninitialized
7635@opindex Wno-uninitialized
ddf6fe37 7636@item -Wuninitialized
d77de738
ML
7637Warn if an object with automatic or allocated storage duration is used
7638without having been initialized. In C++, also warn if a non-static
7639reference or non-static @code{const} member appears in a class without
7640constructors.
7641
7642In addition, passing a pointer (or in C++, a reference) to an uninitialized
7643object to a @code{const}-qualified argument of a built-in function known to
7644read the object is also diagnosed by this warning.
7645(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7646
7647If you want to warn about code that uses the uninitialized value of the
7648variable in its own initializer, use the @option{-Winit-self} option.
7649
7650These warnings occur for individual uninitialized elements of
7651structure, union or array variables as well as for variables that are
7652uninitialized as a whole. They do not occur for variables or elements
7653declared @code{volatile}. Because these warnings depend on
7654optimization, the exact variables or elements for which there are
7655warnings depend on the precise optimization options and version of GCC
7656used.
7657
7658Note that there may be no warning about a variable that is used only
7659to compute a value that itself is never used, because such
7660computations may be deleted by data flow analysis before the warnings
7661are printed.
7662
7663In C++, this warning also warns about using uninitialized objects in
7664member-initializer-lists. For example, GCC warns about @code{b} being
7665uninitialized in the following snippet:
7666
7667@smallexample
7668struct A @{
7669 int a;
7670 int b;
7671 A() : a(b) @{ @}
7672@};
7673@end smallexample
7674
d77de738
ML
7675@opindex Winvalid-memory-model
7676@opindex Wno-invalid-memory-model
ddf6fe37 7677@item -Wno-invalid-memory-model
d77de738
ML
7678This option controls warnings
7679for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7680and the C11 atomic generic functions with a memory consistency argument
7681that is either invalid for the operation or outside the range of values
7682of the @code{memory_order} enumeration. For example, since the
7683@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7684defined for the relaxed, release, and sequentially consistent memory
7685orders the following code is diagnosed:
7686
7687@smallexample
7688void store (int *i)
7689@{
7690 __atomic_store_n (i, 0, memory_order_consume);
7691@}
7692@end smallexample
7693
7694@option{-Winvalid-memory-model} is enabled by default.
7695
d77de738
ML
7696@opindex Wmaybe-uninitialized
7697@opindex Wno-maybe-uninitialized
ddf6fe37 7698@item -Wmaybe-uninitialized
d77de738
ML
7699For an object with automatic or allocated storage duration, if there exists
7700a path from the function entry to a use of the object that is initialized,
7701but there exist some other paths for which the object is not initialized,
7702the compiler emits a warning if it cannot prove the uninitialized paths
7703are not executed at run time.
7704
7705In addition, passing a pointer (or in C++, a reference) to an uninitialized
7706object to a @code{const}-qualified function argument is also diagnosed by
7707this warning. (@option{-Wuninitialized} is issued for built-in functions
7708known to read the object.) Annotating the function with attribute
7709@code{access (none)} indicates that the argument isn't used to access
7710the object and avoids the warning (@pxref{Common Function Attributes}).
7711
7712These warnings are only possible in optimizing compilation, because otherwise
7713GCC does not keep track of the state of variables.
7714
7715These warnings are made optional because GCC may not be able to determine when
7716the code is correct in spite of appearing to have an error. Here is one
7717example of how this can happen:
7718
7719@smallexample
7720@group
7721@{
7722 int x;
7723 switch (y)
7724 @{
7725 case 1: x = 1;
7726 break;
7727 case 2: x = 4;
7728 break;
7729 case 3: x = 5;
7730 @}
7731 foo (x);
7732@}
7733@end group
7734@end smallexample
7735
7736@noindent
7737If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7738always initialized, but GCC doesn't know this. To suppress the
7739warning, you need to provide a default case with assert(0) or
7740similar code.
7741
7742@cindex @code{longjmp} warnings
7743This option also warns when a non-volatile automatic variable might be
7744changed by a call to @code{longjmp}.
7745The compiler sees only the calls to @code{setjmp}. It cannot know
7746where @code{longjmp} will be called; in fact, a signal handler could
7747call it at any point in the code. As a result, you may get a warning
7748even when there is in fact no problem because @code{longjmp} cannot
7749in fact be called at the place that would cause a problem.
7750
7751Some spurious warnings can be avoided if you declare all the functions
7752you use that never return as @code{noreturn}. @xref{Function
7753Attributes}.
7754
7755This warning is enabled by @option{-Wall} or @option{-Wextra}.
7756
d77de738
ML
7757@opindex Wunknown-pragmas
7758@opindex Wno-unknown-pragmas
7759@cindex warning for unknown pragmas
7760@cindex unknown pragmas, warning
7761@cindex pragmas, warning of unknown
f33d7a88 7762@item -Wunknown-pragmas
d77de738
ML
7763Warn when a @code{#pragma} directive is encountered that is not understood by
7764GCC@. If this command-line option is used, warnings are even issued
7765for unknown pragmas in system header files. This is not the case if
7766the warnings are only enabled by the @option{-Wall} command-line option.
7767
d77de738
ML
7768@opindex Wno-pragmas
7769@opindex Wpragmas
ddf6fe37 7770@item -Wno-pragmas
d77de738
ML
7771Do not warn about misuses of pragmas, such as incorrect parameters,
7772invalid syntax, or conflicts between pragmas. See also
7773@option{-Wunknown-pragmas}.
7774
d77de738
ML
7775@opindex Wno-prio-ctor-dtor
7776@opindex Wprio-ctor-dtor
ddf6fe37 7777@item -Wno-prio-ctor-dtor
d77de738
ML
7778Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7779The use of constructor and destructor attributes allow you to assign a
7780priority to the constructor/destructor to control its order of execution
7781before @code{main} is called or after it returns. The priority values must be
7782greater than 100 as the compiler reserves priority values between 0--100 for
7783the implementation.
7784
d77de738
ML
7785@opindex Wstrict-aliasing
7786@opindex Wno-strict-aliasing
ddf6fe37 7787@item -Wstrict-aliasing
d77de738
ML
7788This option is only active when @option{-fstrict-aliasing} is active.
7789It warns about code that might break the strict aliasing rules that the
7790compiler is using for optimization. The warning does not catch all
7791cases, but does attempt to catch the more common pitfalls. It is
7792included in @option{-Wall}.
7793It is equivalent to @option{-Wstrict-aliasing=3}
7794
d77de738 7795@opindex Wstrict-aliasing=n
ddf6fe37 7796@item -Wstrict-aliasing=n
d77de738
ML
7797This option is only active when @option{-fstrict-aliasing} is active.
7798It warns about code that might break the strict aliasing rules that the
7799compiler is using for optimization.
7800Higher levels correspond to higher accuracy (fewer false positives).
7801Higher levels also correspond to more effort, similar to the way @option{-O}
7802works.
7803@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7804
7805Level 1: Most aggressive, quick, least accurate.
7806Possibly useful when higher levels
7807do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7808false negatives. However, it has many false positives.
7809Warns for all pointer conversions between possibly incompatible types,
7810even if never dereferenced. Runs in the front end only.
7811
7812Level 2: Aggressive, quick, not too precise.
7813May still have many false positives (not as many as level 1 though),
7814and few false negatives (but possibly more than level 1).
7815Unlike level 1, it only warns when an address is taken. Warns about
7816incomplete types. Runs in the front end only.
7817
7818Level 3 (default for @option{-Wstrict-aliasing}):
7819Should have very few false positives and few false
7820negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7821Takes care of the common pun+dereference pattern in the front end:
7822@code{*(int*)&some_float}.
7823If optimization is enabled, it also runs in the back end, where it deals
7824with multiple statement cases using flow-sensitive points-to information.
7825Only warns when the converted pointer is dereferenced.
7826Does not warn about incomplete types.
7827
d77de738
ML
7828@opindex Wstrict-overflow
7829@opindex Wno-strict-overflow
ddf6fe37
AA
7830@item -Wstrict-overflow
7831@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7832This option is only active when signed overflow is undefined.
7833It warns about cases where the compiler optimizes based on the
7834assumption that signed overflow does not occur. Note that it does not
7835warn about all cases where the code might overflow: it only warns
7836about cases where the compiler implements some optimization. Thus
7837this warning depends on the optimization level.
7838
7839An optimization that assumes that signed overflow does not occur is
7840perfectly safe if the values of the variables involved are such that
7841overflow never does, in fact, occur. Therefore this warning can
7842easily give a false positive: a warning about code that is not
7843actually a problem. To help focus on important issues, several
7844warning levels are defined. No warnings are issued for the use of
7845undefined signed overflow when estimating how many iterations a loop
7846requires, in particular when determining whether a loop will be
7847executed at all.
7848
7849@table @gcctabopt
7850@item -Wstrict-overflow=1
7851Warn about cases that are both questionable and easy to avoid. For
7852example the compiler simplifies
7853@code{x + 1 > x} to @code{1}. This level of
7854@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7855are not, and must be explicitly requested.
7856
7857@item -Wstrict-overflow=2
7858Also warn about other cases where a comparison is simplified to a
7859constant. For example: @code{abs (x) >= 0}. This can only be
7860simplified when signed integer overflow is undefined, because
7861@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7862zero. @option{-Wstrict-overflow} (with no level) is the same as
7863@option{-Wstrict-overflow=2}.
7864
7865@item -Wstrict-overflow=3
7866Also warn about other cases where a comparison is simplified. For
7867example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7868
7869@item -Wstrict-overflow=4
7870Also warn about other simplifications not covered by the above cases.
7871For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7872
7873@item -Wstrict-overflow=5
7874Also warn about cases where the compiler reduces the magnitude of a
7875constant involved in a comparison. For example: @code{x + 2 > y} is
7876simplified to @code{x + 1 >= y}. This is reported only at the
7877highest warning level because this simplification applies to many
7878comparisons, so this warning level gives a very large number of
7879false positives.
7880@end table
7881
d77de738
ML
7882@opindex Wstring-compare
7883@opindex Wno-string-compare
ddf6fe37 7884@item -Wstring-compare
d77de738
ML
7885Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7886determined to be either zero or non-zero in tests for such equality
7887owing to the length of one argument being greater than the size of
7888the array the other argument is stored in (or the bound in the case
7889of @code{strncmp}). Such calls could be mistakes. For example,
7890the call to @code{strcmp} below is diagnosed because its result is
7891necessarily non-zero irrespective of the contents of the array @code{a}.
7892
7893@smallexample
7894extern char a[4];
7895void f (char *d)
7896@{
7897 strcpy (d, "string");
7898 @dots{}
7899 if (0 == strcmp (a, d)) // cannot be true
7900 puts ("a and d are the same");
7901@}
7902@end smallexample
7903
7904@option{-Wstring-compare} is enabled by @option{-Wextra}.
7905
ddf6fe37
AA
7906@opindex Wstringop-overflow
7907@opindex Wno-stringop-overflow
d77de738
ML
7908@item -Wno-stringop-overflow
7909@item -Wstringop-overflow
7910@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7911Warn for calls to string manipulation functions such as @code{memcpy} and
7912@code{strcpy} that are determined to overflow the destination buffer. The
7913optional argument is one greater than the type of Object Size Checking to
7914perform to determine the size of the destination. @xref{Object Size Checking}.
7915The argument is meaningful only for functions that operate on character arrays
7916but not for raw memory functions like @code{memcpy} which always make use
7917of Object Size type-0. The option also warns for calls that specify a size
7918in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7919The option produces the best results with optimization enabled but can detect
7920a small subset of simple buffer overflows even without optimization in
7921calls to the GCC built-in functions like @code{__builtin_memcpy} that
7922correspond to the standard functions. In any case, the option warns about
7923just a subset of buffer overflows detected by the corresponding overflow
7924checking built-ins. For example, the option issues a warning for
7925the @code{strcpy} call below because it copies at least 5 characters
7926(the string @code{"blue"} including the terminating NUL) into the buffer
7927of size 4.
7928
7929@smallexample
7930enum Color @{ blue, purple, yellow @};
7931const char* f (enum Color clr)
7932@{
7933 static char buf [4];
7934 const char *str;
7935 switch (clr)
7936 @{
7937 case blue: str = "blue"; break;
7938 case purple: str = "purple"; break;
7939 case yellow: str = "yellow"; break;
7940 @}
7941
7942 return strcpy (buf, str); // warning here
7943@}
7944@end smallexample
7945
7946Option @option{-Wstringop-overflow=2} is enabled by default.
7947
7948@table @gcctabopt
d77de738
ML
7949@opindex Wstringop-overflow
7950@opindex Wno-stringop-overflow
ddf6fe37
AA
7951@item -Wstringop-overflow
7952@itemx -Wstringop-overflow=1
d77de738
ML
7953The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7954to determine the sizes of destination objects. At this setting the option
7955does not warn for writes past the end of subobjects of larger objects accessed
7956by pointers unless the size of the largest surrounding object is known. When
7957the destination may be one of several objects it is assumed to be the largest
7958one of them. On Linux systems, when optimization is enabled at this setting
7959the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7960is defined to a non-zero value.
7961
7962@item -Wstringop-overflow=2
7963The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7964to determine the sizes of destination objects. At this setting the option
7965warns about overflows when writing to members of the largest complete
7966objects whose exact size is known. However, it does not warn for excessive
7967writes to the same members of unknown objects referenced by pointers since
7968they may point to arrays containing unknown numbers of elements. This is
7969the default setting of the option.
7970
7971@item -Wstringop-overflow=3
7972The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7973to determine the sizes of destination objects. At this setting the option
7974warns about overflowing the smallest object or data member. This is the
7975most restrictive setting of the option that may result in warnings for safe
7976code.
7977
7978@item -Wstringop-overflow=4
7979The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7980to determine the sizes of destination objects. At this setting the option
7981warns about overflowing any data members, and when the destination is
7982one of several objects it uses the size of the largest of them to decide
7983whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7984setting of the option may result in warnings for benign code.
7985@end table
7986
d77de738
ML
7987@opindex Wstringop-overread
7988@opindex Wno-stringop-overread
ddf6fe37 7989@item -Wno-stringop-overread
d77de738
ML
7990Warn for calls to string manipulation functions such as @code{memchr}, or
7991@code{strcpy} that are determined to read past the end of the source
7992sequence.
7993
7994Option @option{-Wstringop-overread} is enabled by default.
7995
d77de738
ML
7996@opindex Wstringop-truncation
7997@opindex Wno-stringop-truncation
ddf6fe37 7998@item -Wno-stringop-truncation
d77de738
ML
7999Do not warn for calls to bounded string manipulation functions
8000such as @code{strncat},
8001@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8002or leave the destination unchanged.
8003
8004In the following example, the call to @code{strncat} specifies a bound that
8005is less than the length of the source string. As a result, the copy of
8006the source will be truncated and so the call is diagnosed. To avoid the
8007warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8008
8009@smallexample
8010void append (char *buf, size_t bufsize)
8011@{
8012 strncat (buf, ".txt", 3);
8013@}
8014@end smallexample
8015
8016As another example, the following call to @code{strncpy} results in copying
8017to @code{d} just the characters preceding the terminating NUL, without
8018appending the NUL to the end. Assuming the result of @code{strncpy} is
8019necessarily a NUL-terminated string is a common mistake, and so the call
8020is diagnosed. To avoid the warning when the result is not expected to be
8021NUL-terminated, call @code{memcpy} instead.
8022
8023@smallexample
8024void copy (char *d, const char *s)
8025@{
8026 strncpy (d, s, strlen (s));
8027@}
8028@end smallexample
8029
8030In the following example, the call to @code{strncpy} specifies the size
8031of the destination buffer as the bound. If the length of the source
8032string is equal to or greater than this size the result of the copy will
8033not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8034the warning, specify @code{sizeof buf - 1} as the bound and set the last
8035element of the buffer to @code{NUL}.
8036
8037@smallexample
8038void copy (const char *s)
8039@{
8040 char buf[80];
8041 strncpy (buf, s, sizeof buf);
8042 @dots{}
8043@}
8044@end smallexample
8045
8046In situations where a character array is intended to store a sequence
8047of bytes with no terminating @code{NUL} such an array may be annotated
8048with attribute @code{nonstring} to avoid this warning. Such arrays,
8049however, are not suitable arguments to functions that expect
8050@code{NUL}-terminated strings. To help detect accidental misuses of
8051such arrays GCC issues warnings unless it can prove that the use is
8052safe. @xref{Common Variable Attributes}.
8053
2a27ae32
QZ
8054@opindex Wstrict-flex-arrays
8055@opindex Wno-strict-flex-arrays
ddf6fe37 8056@item -Wstrict-flex-arrays
2a27ae32
QZ
8057Warn about inproper usages of flexible array members
8058according to the @var{level} of the @code{strict_flex_array (@var{level})}
8059attribute attached to the trailing array field of a structure if it's
8060available, otherwise according to the @var{level} of the option
8061@option{-fstrict-flex-arrays=@var{level}}.
8062
8063This option is effective only when @var{level} is bigger than 0. Otherwise,
8064it will be ignored with a warning.
8065
8066when @var{level}=1, warnings will be issued for a trailing array reference
8067of a structure that have 2 or more elements if the trailing array is referenced
8068as a flexible array member.
8069
8070when @var{level}=2, in addition to @var{level}=1, additional warnings will be
8071issued for a trailing one-element array reference of a structure
8072if the array is referenced as a flexible array member.
8073
8074when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8075issued for a trailing zero-length array reference of a structure
8076if the array is referenced as a flexible array member.
8077
8078
d77de738
ML
8079@opindex Wsuggest-attribute=
8080@opindex Wno-suggest-attribute=
ddf6fe37 8081@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
d77de738
ML
8082Warn for cases where adding an attribute may be beneficial. The
8083attributes currently supported are listed below.
8084
8085@table @gcctabopt
d77de738
ML
8086@opindex Wsuggest-attribute=pure
8087@opindex Wno-suggest-attribute=pure
8088@opindex Wsuggest-attribute=const
8089@opindex Wno-suggest-attribute=const
8090@opindex Wsuggest-attribute=noreturn
8091@opindex Wno-suggest-attribute=noreturn
8092@opindex Wmissing-noreturn
8093@opindex Wno-missing-noreturn
8094@opindex Wsuggest-attribute=malloc
8095@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
8096@item -Wsuggest-attribute=pure
8097@itemx -Wsuggest-attribute=const
8098@itemx -Wsuggest-attribute=noreturn
8099@itemx -Wmissing-noreturn
8100@itemx -Wsuggest-attribute=malloc
d77de738
ML
8101
8102Warn about functions that might be candidates for attributes
8103@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
8104only warns for functions visible in other compilation units or (in the case of
8105@code{pure} and @code{const}) if it cannot prove that the function returns
8106normally. A function returns normally if it doesn't contain an infinite loop or
8107return abnormally by throwing, calling @code{abort} or trapping. This analysis
8108requires option @option{-fipa-pure-const}, which is enabled by default at
8109@option{-O} and higher. Higher optimization levels improve the accuracy
8110of the analysis.
8111
d77de738
ML
8112@opindex Wsuggest-attribute=format
8113@opindex Wmissing-format-attribute
8114@opindex Wno-suggest-attribute=format
8115@opindex Wno-missing-format-attribute
8116@opindex Wformat
8117@opindex Wno-format
ddf6fe37
AA
8118@item -Wsuggest-attribute=format
8119@itemx -Wmissing-format-attribute
d77de738
ML
8120
8121Warn about function pointers that might be candidates for @code{format}
8122attributes. Note these are only possible candidates, not absolute ones.
8123GCC guesses that function pointers with @code{format} attributes that
8124are used in assignment, initialization, parameter passing or return
8125statements should have a corresponding @code{format} attribute in the
8126resulting type. I.e.@: the left-hand side of the assignment or
8127initialization, the type of the parameter variable, or the return type
8128of the containing function respectively should also have a @code{format}
8129attribute to avoid the warning.
8130
8131GCC also warns about function definitions that might be
8132candidates for @code{format} attributes. Again, these are only
8133possible candidates. GCC guesses that @code{format} attributes
8134might be appropriate for any function that calls a function like
8135@code{vprintf} or @code{vscanf}, but this might not always be the
8136case, and some functions for which @code{format} attributes are
8137appropriate may not be detected.
8138
d77de738
ML
8139@opindex Wsuggest-attribute=cold
8140@opindex Wno-suggest-attribute=cold
ddf6fe37 8141@item -Wsuggest-attribute=cold
d77de738
ML
8142
8143Warn about functions that might be candidates for @code{cold} attribute. This
8144is based on static detection and generally only warns about functions which
8145always leads to a call to another @code{cold} function such as wrappers of
8146C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8147@end table
8148
d880e093
MU
8149@opindex Wno-alloc-size
8150@opindex Walloc-size
8151@item -Walloc-size
8152Warn about calls to allocation functions decorated with attribute
8153@code{alloc_size} that specify insufficient size for the target type of
8154the pointer the result is assigned to, including those to the built-in
8155forms of the functions @code{aligned_alloc}, @code{alloca},
8156@code{calloc},
8157@code{malloc}, and @code{realloc}.
8158
d77de738
ML
8159@opindex Wno-alloc-zero
8160@opindex Walloc-zero
ddf6fe37 8161@item -Walloc-zero
d77de738
ML
8162Warn about calls to allocation functions decorated with attribute
8163@code{alloc_size} that specify zero bytes, including those to the built-in
8164forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8165@code{malloc}, and @code{realloc}. Because the behavior of these functions
8166when called with a zero size differs among implementations (and in the case
8167of @code{realloc} has been deprecated) relying on it may result in subtle
8168portability bugs and should be avoided.
8169
d77de738
ML
8170@opindex Walloc-size-larger-than=
8171@opindex Wno-alloc-size-larger-than
ddf6fe37 8172@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8173Warn about calls to functions decorated with attribute @code{alloc_size}
8174that attempt to allocate objects larger than the specified number of bytes,
8175or where the result of the size computation in an integer type with infinite
8176precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8177@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8178Warnings controlled by the option can be disabled either by specifying
8179@var{byte-size} of @samp{SIZE_MAX} or more or by
8180@option{-Wno-alloc-size-larger-than}.
8181@xref{Function Attributes}.
8182
d77de738 8183@opindex Wno-alloc-size-larger-than
ddf6fe37 8184@item -Wno-alloc-size-larger-than
d77de738
ML
8185Disable @option{-Walloc-size-larger-than=} warnings. The option is
8186equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8187larger.
8188
d77de738
ML
8189@opindex Wno-alloca
8190@opindex Walloca
ddf6fe37 8191@item -Walloca
d77de738
ML
8192This option warns on all uses of @code{alloca} in the source.
8193
d77de738
ML
8194@opindex Walloca-larger-than=
8195@opindex Wno-alloca-larger-than
ddf6fe37 8196@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8197This option warns on calls to @code{alloca} with an integer argument whose
8198value is either zero, or that is not bounded by a controlling predicate
8199that limits its value to at most @var{byte-size}. It also warns for calls
8200to @code{alloca} where the bound value is unknown. Arguments of non-integer
8201types are considered unbounded even if they appear to be constrained to
8202the expected range.
8203
8204For example, a bounded case of @code{alloca} could be:
8205
8206@smallexample
8207void func (size_t n)
8208@{
8209 void *p;
8210 if (n <= 1000)
8211 p = alloca (n);
8212 else
8213 p = malloc (n);
8214 f (p);
8215@}
8216@end smallexample
8217
8218In the above example, passing @code{-Walloca-larger-than=1000} would not
8219issue a warning because the call to @code{alloca} is known to be at most
82201000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8221the compiler would emit a warning.
8222
8223Unbounded uses, on the other hand, are uses of @code{alloca} with no
8224controlling predicate constraining its integer argument. For example:
8225
8226@smallexample
8227void func ()
8228@{
8229 void *p = alloca (n);
8230 f (p);
8231@}
8232@end smallexample
8233
8234If @code{-Walloca-larger-than=500} were passed, the above would trigger
8235a warning, but this time because of the lack of bounds checking.
8236
8237Note, that even seemingly correct code involving signed integers could
8238cause a warning:
8239
8240@smallexample
8241void func (signed int n)
8242@{
8243 if (n < 500)
8244 @{
8245 p = alloca (n);
8246 f (p);
8247 @}
8248@}
8249@end smallexample
8250
8251In the above example, @var{n} could be negative, causing a larger than
8252expected argument to be implicitly cast into the @code{alloca} call.
8253
8254This option also warns when @code{alloca} is used in a loop.
8255
8256@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8257but is usually only effective when @option{-ftree-vrp} is active (default
8258for @option{-O2} and above).
8259
8260See also @option{-Wvla-larger-than=}@samp{byte-size}.
8261
d77de738 8262@opindex Wno-alloca-larger-than
ddf6fe37 8263@item -Wno-alloca-larger-than
d77de738
ML
8264Disable @option{-Walloca-larger-than=} warnings. The option is
8265equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8266
d77de738
ML
8267@opindex Warith-conversion
8268@opindex Wno-arith-conversion
ddf6fe37 8269@item -Warith-conversion
d77de738
ML
8270Do warn about implicit conversions from arithmetic operations even
8271when conversion of the operands to the same type cannot change their
8272values. This affects warnings from @option{-Wconversion},
8273@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8274
8275@smallexample
8276@group
8277void f (char c, int i)
8278@{
8279 c = c + i; // warns with @option{-Wconversion}
8280 c = c + 1; // only warns with @option{-Warith-conversion}
8281@}
8282@end group
8283@end smallexample
8284
d77de738
ML
8285@opindex Wno-array-bounds
8286@opindex Warray-bounds
ddf6fe37
AA
8287@item -Warray-bounds
8288@itemx -Warray-bounds=@var{n}
d77de738
ML
8289Warn about out of bounds subscripts or offsets into arrays. This warning
8290is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8291is active (the default for @option{-O2} and above) but a subset of instances
8292are issued even without optimization.
8293
710c9676
QZ
8294By default, the trailing array of a structure will be treated as a flexible
8295array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8296if it is declared as either a flexible array member per C99 standard onwards
8297(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8298array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8299zero-length arrays or one-element arrays are not warned by default.
8300
8301You can add the option @option{-fstrict-flex-arrays} or
8302@option{-fstrict-flex-arrays=@var{level}} to control how this
8303option treat trailing array of a structure as a flexible array member:
8304
8305when @var{level}<=1, no change to the default behavior.
8306
8307when @var{level}=2, additional warnings will be issued for out of bounds
8308subscripts or offsets into one-element arrays;
8309
8310when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8311issued for out of bounds subscripts or offsets into zero-length arrays.
8312
d77de738
ML
8313@table @gcctabopt
8314@item -Warray-bounds=1
8315This is the default warning level of @option{-Warray-bounds} and is enabled
8316by @option{-Wall}; higher levels are not, and must be explicitly requested.
8317
8318@item -Warray-bounds=2
710c9676
QZ
8319This warning level also warns about the intermediate results of pointer
8320arithmetic that may yield out of bounds values. This warning level may
8321give a larger number of false positives and is deactivated by default.
d77de738
ML
8322@end table
8323
d77de738
ML
8324@opindex Warray-compare
8325@opindex Wno-array-compare
ddf6fe37 8326@item -Warray-compare
d77de738
ML
8327Warn about equality and relational comparisons between two operands of array
8328type. This comparison was deprecated in C++20. For example:
8329
8330@smallexample
8331int arr1[5];
8332int arr2[5];
8333bool same = arr1 == arr2;
8334@end smallexample
8335
8336@option{-Warray-compare} is enabled by @option{-Wall}.
8337
ddf6fe37 8338@opindex Wno-array-parameter
d77de738
ML
8339@item -Warray-parameter
8340@itemx -Warray-parameter=@var{n}
d77de738
ML
8341Warn about redeclarations of functions involving arguments of array or
8342pointer types of inconsistent kinds or forms, and enable the detection
8343of out-of-bounds accesses to such parameters by warnings such as
8344@option{-Warray-bounds}.
8345
8346If the first function declaration uses the array form the bound specified
8347in the array is assumed to be the minimum number of elements expected to
8348be provided in calls to the function and the maximum number of elements
8349accessed by it. Failing to provide arguments of sufficient size or accessing
8350more than the maximum number of elements may be diagnosed by warnings such
8351as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8352involving array parameters declared using the @code{T[static N]} form.
8353
8354For example, the warning triggers for the following redeclarations because
8355the first one allows an array of any size to be passed to @code{f} while
8356the second one with the keyword @code{static} specifies that the array
8357argument must have at least four elements.
8358
8359@smallexample
8360void f (int[static 4]);
8361void f (int[]); // warning (inconsistent array form)
8362
8363void g (void)
8364@{
8365 int *p = (int *)malloc (4);
8366 f (p); // warning (array too small)
8367 @dots{}
8368@}
8369@end smallexample
8370
8371At level 2 the warning also triggers for redeclarations involving any other
8372inconsistency in array or pointer argument forms denoting array sizes.
8373Pointers and arrays of unspecified bound are considered equivalent and do
8374not trigger a warning.
8375
8376@smallexample
8377void g (int*);
8378void g (int[]); // no warning
8379void g (int[8]); // warning (inconsistent array bound)
8380@end smallexample
8381
8382@option{-Warray-parameter=2} is included in @option{-Wall}. The
8383@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8384involving Variable Length Array arguments.
8385
d77de738
ML
8386@opindex Wattribute-alias
8387@opindex Wno-attribute-alias
ddf6fe37
AA
8388@item -Wattribute-alias=@var{n}
8389@itemx -Wno-attribute-alias
d77de738
ML
8390Warn about declarations using the @code{alias} and similar attributes whose
8391target is incompatible with the type of the alias.
8392@xref{Function Attributes,,Declaring Attributes of Functions}.
8393
8394@table @gcctabopt
8395@item -Wattribute-alias=1
8396The default warning level of the @option{-Wattribute-alias} option diagnoses
8397incompatibilities between the type of the alias declaration and that of its
8398target. Such incompatibilities are typically indicative of bugs.
8399
8400@item -Wattribute-alias=2
8401
8402At this level @option{-Wattribute-alias} also diagnoses cases where
8403the attributes of the alias declaration are more restrictive than the
8404attributes applied to its target. These mismatches can potentially
8405result in incorrect code generation. In other cases they may be
8406benign and could be resolved simply by adding the missing attribute to
8407the target. For comparison, see the @option{-Wmissing-attributes}
8408option, which controls diagnostics when the alias declaration is less
8409restrictive than the target, rather than more restrictive.
8410
8411Attributes considered include @code{alloc_align}, @code{alloc_size},
8412@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8413@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8414@code{returns_nonnull}, and @code{returns_twice}.
8415@end table
8416
8417@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8418This is the default. You can disable these warnings with either
8419@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8420
d77de738
ML
8421@opindex Wbidi-chars=
8422@opindex Wbidi-chars
8423@opindex Wno-bidi-chars
ddf6fe37 8424@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8425Warn about possibly misleading UTF-8 bidirectional control characters in
8426comments, string literals, character constants, and identifiers. Such
8427characters can change left-to-right writing direction into right-to-left
8428(and vice versa), which can cause confusion between the logical order and
8429visual order. This may be dangerous; for instance, it may seem that a piece
8430of code is not commented out, whereas it in fact is.
8431
8432There are three levels of warning supported by GCC@. The default is
8433@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8434bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8435@option{-Wbidi-chars=any} warns about any use of bidirectional control
8436characters.
8437
8438By default, this warning does not warn about UCNs. It is, however, possible
8439to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8440@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8441and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8442@option{-Wbidi-chars=any} was specified.
8443
d77de738
ML
8444@opindex Wno-bool-compare
8445@opindex Wbool-compare
ddf6fe37 8446@item -Wbool-compare
d77de738
ML
8447Warn about boolean expression compared with an integer value different from
8448@code{true}/@code{false}. For instance, the following comparison is
8449always false:
8450@smallexample
8451int n = 5;
8452@dots{}
8453if ((n > 1) == 2) @{ @dots{} @}
8454@end smallexample
8455This warning is enabled by @option{-Wall}.
8456
d77de738
ML
8457@opindex Wno-bool-operation
8458@opindex Wbool-operation
ddf6fe37 8459@item -Wbool-operation
d77de738
ML
8460Warn about suspicious operations on expressions of a boolean type. For
8461instance, bitwise negation of a boolean is very likely a bug in the program.
8462For C, this warning also warns about incrementing or decrementing a boolean,
8463which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8464Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8465
8466This warning is enabled by @option{-Wall}.
8467
d77de738
ML
8468@opindex Wno-duplicated-branches
8469@opindex Wduplicated-branches
ddf6fe37 8470@item -Wduplicated-branches
d77de738
ML
8471Warn when an if-else has identical branches. This warning detects cases like
8472@smallexample
8473if (p != NULL)
8474 return 0;
8475else
8476 return 0;
8477@end smallexample
8478It doesn't warn when both branches contain just a null statement. This warning
8479also warn for conditional operators:
8480@smallexample
8481 int i = x ? *p : *p;
8482@end smallexample
8483
d77de738
ML
8484@opindex Wno-duplicated-cond
8485@opindex Wduplicated-cond
ddf6fe37 8486@item -Wduplicated-cond
d77de738
ML
8487Warn about duplicated conditions in an if-else-if chain. For instance,
8488warn for the following code:
8489@smallexample
8490if (p->q != NULL) @{ @dots{} @}
8491else if (p->q != NULL) @{ @dots{} @}
8492@end smallexample
8493
d77de738
ML
8494@opindex Wno-frame-address
8495@opindex Wframe-address
ddf6fe37 8496@item -Wframe-address
d77de738
ML
8497Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8498is called with an argument greater than 0. Such calls may return indeterminate
8499values or crash the program. The warning is included in @option{-Wall}.
8500
d77de738
ML
8501@opindex Wno-discarded-qualifiers
8502@opindex Wdiscarded-qualifiers
ddf6fe37 8503@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8504Do not warn if type qualifiers on pointers are being discarded.
8505Typically, the compiler warns if a @code{const char *} variable is
8506passed to a function that takes a @code{char *} parameter. This option
8507can be used to suppress such a warning.
8508
d77de738
ML
8509@opindex Wno-discarded-array-qualifiers
8510@opindex Wdiscarded-array-qualifiers
ddf6fe37 8511@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8512Do not warn if type qualifiers on arrays which are pointer targets
8513are being discarded. Typically, the compiler warns if a
8514@code{const int (*)[]} variable is passed to a function that
8515takes a @code{int (*)[]} parameter. This option can be used to
8516suppress such a warning.
8517
d77de738
ML
8518@opindex Wno-incompatible-pointer-types
8519@opindex Wincompatible-pointer-types
ddf6fe37 8520@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8521Do not warn when there is a conversion between pointers that have incompatible
8522types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8523which warns for pointer argument passing or assignment with different
8524signedness.
8525
5fccebdb
JM
8526This warning is upgraded to an error by @option{-pedantic-errors}.
8527
d77de738
ML
8528@opindex Wno-int-conversion
8529@opindex Wint-conversion
ddf6fe37 8530@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8531Do not warn about incompatible integer to pointer and pointer to integer
8532conversions. This warning is about implicit conversions; for explicit
8533conversions the warnings @option{-Wno-int-to-pointer-cast} and
8534@option{-Wno-pointer-to-int-cast} may be used.
8535
5fccebdb
JM
8536This warning is upgraded to an error by @option{-pedantic-errors}.
8537
d77de738
ML
8538@opindex Wzero-length-bounds
8539@opindex Wzero-length-bounds
ddf6fe37 8540@item -Wzero-length-bounds
d77de738
ML
8541Warn about accesses to elements of zero-length array members that might
8542overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8543arrays is discouraged because accesses to them are undefined.
d77de738
ML
8544@xref{Zero Length}.
8545
8546For example, the first two stores in function @code{bad} are diagnosed
8547because the array elements overlap the subsequent members @code{b} and
8548@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8549because it is beyond the bounds of the enclosing object.
8550
8551@smallexample
8552struct X @{ int a[0]; int b, c; @};
8553struct X x;
8554
8555void bad (void)
8556@{
8557 x.a[0] = 0; // -Wzero-length-bounds
8558 x.a[1] = 1; // -Wzero-length-bounds
8559 x.a[2] = 2; // -Warray-bounds
8560@}
8561@end smallexample
8562
8563Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8564
d77de738
ML
8565@opindex Wno-div-by-zero
8566@opindex Wdiv-by-zero
ddf6fe37 8567@item -Wno-div-by-zero
d77de738
ML
8568Do not warn about compile-time integer division by zero. Floating-point
8569division by zero is not warned about, as it can be a legitimate way of
8570obtaining infinities and NaNs.
8571
d77de738
ML
8572@opindex Wsystem-headers
8573@opindex Wno-system-headers
8574@cindex warnings from system headers
8575@cindex system headers, warnings from
f33d7a88 8576@item -Wsystem-headers
d77de738
ML
8577Print warning messages for constructs found in system header files.
8578Warnings from system headers are normally suppressed, on the assumption
8579that they usually do not indicate real problems and would only make the
8580compiler output harder to read. Using this command-line option tells
8581GCC to emit warnings from system headers as if they occurred in user
8582code. However, note that using @option{-Wall} in conjunction with this
8583option does @emph{not} warn about unknown pragmas in system
8584headers---for that, @option{-Wunknown-pragmas} must also be used.
8585
d77de738
ML
8586@opindex Wtautological-compare
8587@opindex Wno-tautological-compare
ddf6fe37 8588@item -Wtautological-compare
d77de738
ML
8589Warn if a self-comparison always evaluates to true or false. This
8590warning detects various mistakes such as:
8591@smallexample
8592int i = 1;
8593@dots{}
8594if (i > i) @{ @dots{} @}
8595@end smallexample
8596
8597This warning also warns about bitwise comparisons that always evaluate
8598to true or false, for instance:
8599@smallexample
8600if ((a & 16) == 10) @{ @dots{} @}
8601@end smallexample
8602will always be false.
8603
8604This warning is enabled by @option{-Wall}.
8605
d77de738
ML
8606@opindex Wtrampolines
8607@opindex Wno-trampolines
ddf6fe37 8608@item -Wtrampolines
d77de738
ML
8609Warn about trampolines generated for pointers to nested functions.
8610A trampoline is a small piece of data or code that is created at run
8611time on the stack when the address of a nested function is taken, and is
8612used to call the nested function indirectly. For some targets, it is
8613made up of data only and thus requires no special treatment. But, for
8614most targets, it is made up of code and thus requires the stack to be
8615made executable in order for the program to work properly.
8616
d77de738
ML
8617@opindex Wfloat-equal
8618@opindex Wno-float-equal
ddf6fe37 8619@item -Wfloat-equal
d77de738
ML
8620Warn if floating-point values are used in equality comparisons.
8621
8622The idea behind this is that sometimes it is convenient (for the
8623programmer) to consider floating-point values as approximations to
8624infinitely precise real numbers. If you are doing this, then you need
8625to compute (by analyzing the code, or in some other way) the maximum or
8626likely maximum error that the computation introduces, and allow for it
8627when performing comparisons (and when producing output, but that's a
8628different problem). In particular, instead of testing for equality, you
8629should check to see whether the two values have ranges that overlap; and
8630this is done with the relational operators, so equality comparisons are
8631probably mistaken.
8632
d77de738
ML
8633@opindex Wtraditional
8634@opindex Wno-traditional
ddf6fe37 8635@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8636Warn about certain constructs that behave differently in traditional and
8637ISO C@. Also warn about ISO C constructs that have no traditional C
8638equivalent, and/or problematic constructs that should be avoided.
8639
8640@itemize @bullet
8641@item
8642Macro parameters that appear within string literals in the macro body.
8643In traditional C macro replacement takes place within string literals,
8644but in ISO C it does not.
8645
8646@item
8647In traditional C, some preprocessor directives did not exist.
8648Traditional preprocessors only considered a line to be a directive
8649if the @samp{#} appeared in column 1 on the line. Therefore
8650@option{-Wtraditional} warns about directives that traditional C
8651understands but ignores because the @samp{#} does not appear as the
8652first character on the line. It also suggests you hide directives like
8653@code{#pragma} not understood by traditional C by indenting them. Some
8654traditional implementations do not recognize @code{#elif}, so this option
8655suggests avoiding it altogether.
8656
8657@item
8658A function-like macro that appears without arguments.
8659
8660@item
8661The unary plus operator.
8662
8663@item
8664The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8665constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8666constants.) Note, these suffixes appear in macros defined in the system
8667headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8668Use of these macros in user code might normally lead to spurious
8669warnings, however GCC's integrated preprocessor has enough context to
8670avoid warning in these cases.
8671
8672@item
8673A function declared external in one block and then used after the end of
8674the block.
8675
8676@item
8677A @code{switch} statement has an operand of type @code{long}.
8678
8679@item
8680A non-@code{static} function declaration follows a @code{static} one.
8681This construct is not accepted by some traditional C compilers.
8682
8683@item
8684The ISO type of an integer constant has a different width or
8685signedness from its traditional type. This warning is only issued if
8686the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8687typically represent bit patterns, are not warned about.
8688
8689@item
8690Usage of ISO string concatenation is detected.
8691
8692@item
8693Initialization of automatic aggregates.
8694
8695@item
8696Identifier conflicts with labels. Traditional C lacks a separate
8697namespace for labels.
8698
8699@item
8700Initialization of unions. If the initializer is zero, the warning is
8701omitted. This is done under the assumption that the zero initializer in
8702user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8703initializer warnings and relies on default initialization to zero in the
8704traditional C case.
8705
8706@item
8707Conversions by prototypes between fixed/floating-point values and vice
8708versa. The absence of these prototypes when compiling with traditional
8709C causes serious problems. This is a subset of the possible
8710conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8711
8712@item
8713Use of ISO C style function definitions. This warning intentionally is
8714@emph{not} issued for prototype declarations or variadic functions
8715because these ISO C features appear in your code when using
8716libiberty's traditional C compatibility macros, @code{PARAMS} and
8717@code{VPARAMS}. This warning is also bypassed for nested functions
8718because that feature is already a GCC extension and thus not relevant to
8719traditional C compatibility.
8720@end itemize
8721
d77de738
ML
8722@opindex Wtraditional-conversion
8723@opindex Wno-traditional-conversion
ddf6fe37 8724@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8725Warn if a prototype causes a type conversion that is different from what
8726would happen to the same argument in the absence of a prototype. This
8727includes conversions of fixed point to floating and vice versa, and
8728conversions changing the width or signedness of a fixed-point argument
8729except when the same as the default promotion.
8730
d77de738
ML
8731@opindex Wdeclaration-after-statement
8732@opindex Wno-declaration-after-statement
ddf6fe37 8733@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8734Warn when a declaration is found after a statement in a block. This
8735construct, known from C++, was introduced with ISO C99 and is by default
8736allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8737
5fccebdb
JM
8738This warning is upgraded to an error by @option{-pedantic-errors}.
8739
d77de738
ML
8740@opindex Wshadow
8741@opindex Wno-shadow
ddf6fe37 8742@item -Wshadow
d77de738
ML
8743Warn whenever a local variable or type declaration shadows another
8744variable, parameter, type, class member (in C++), or instance variable
8745(in Objective-C) or whenever a built-in function is shadowed. Note
8746that in C++, the compiler warns if a local variable shadows an
8747explicit typedef, but not if it shadows a struct/class/enum.
8748If this warning is enabled, it includes also all instances of
8749local shadowing. This means that @option{-Wno-shadow=local}
8750and @option{-Wno-shadow=compatible-local} are ignored when
8751@option{-Wshadow} is used.
8752Same as @option{-Wshadow=global}.
8753
d77de738
ML
8754@opindex Wno-shadow-ivar
8755@opindex Wshadow-ivar
ddf6fe37 8756@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8757Do not warn whenever a local variable shadows an instance variable in an
8758Objective-C method.
8759
d77de738 8760@opindex Wshadow=global
ddf6fe37 8761@item -Wshadow=global
d77de738
ML
8762Warn for any shadowing.
8763Same as @option{-Wshadow}.
8764
d77de738 8765@opindex Wshadow=local
ddf6fe37 8766@item -Wshadow=local
d77de738
ML
8767Warn when a local variable shadows another local variable or parameter.
8768
d77de738 8769@opindex Wshadow=compatible-local
ddf6fe37 8770@item -Wshadow=compatible-local
d77de738
ML
8771Warn when a local variable shadows another local variable or parameter
8772whose type is compatible with that of the shadowing variable. In C++,
8773type compatibility here means the type of the shadowing variable can be
8774converted to that of the shadowed variable. The creation of this flag
8775(in addition to @option{-Wshadow=local}) is based on the idea that when
8776a local variable shadows another one of incompatible type, it is most
8777likely intentional, not a bug or typo, as shown in the following example:
8778
8779@smallexample
8780@group
8781for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8782@{
8783 for (int i = 0; i < N; ++i)
8784 @{
8785 ...
8786 @}
8787 ...
8788@}
8789@end group
8790@end smallexample
8791
8792Since the two variable @code{i} in the example above have incompatible types,
8793enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8794Because their types are incompatible, if a programmer accidentally uses one
8795in place of the other, type checking is expected to catch that and emit an
8796error or warning. Use of this flag instead of @option{-Wshadow=local} can
8797possibly reduce the number of warnings triggered by intentional shadowing.
8798Note that this also means that shadowing @code{const char *i} by
8799@code{char *i} does not emit a warning.
8800
8801This warning is also enabled by @option{-Wshadow=local}.
8802
d77de738
ML
8803@opindex Wlarger-than=
8804@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8805@item -Wlarger-than=@var{byte-size}
d77de738
ML
8806Warn whenever an object is defined whose size exceeds @var{byte-size}.
8807@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8808Warnings controlled by the option can be disabled either by specifying
8809@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8810
8811Also warn for calls to bounded functions such as @code{memchr} or
8812@code{strnlen} that specify a bound greater than the largest possible
8813object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8814can only be disabled by @option{-Wno-larger-than}.
8815
d77de738 8816@opindex Wno-larger-than
ddf6fe37 8817@item -Wno-larger-than
d77de738
ML
8818Disable @option{-Wlarger-than=} warnings. The option is equivalent
8819to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8820
d77de738
ML
8821@opindex Wframe-larger-than=
8822@opindex Wno-frame-larger-than
ddf6fe37 8823@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8824Warn if the size of a function frame exceeds @var{byte-size}.
8825The computation done to determine the stack frame size is approximate
8826and not conservative.
8827The actual requirements may be somewhat greater than @var{byte-size}
8828even if you do not get a warning. In addition, any space allocated
8829via @code{alloca}, variable-length arrays, or related constructs
8830is not included by the compiler when determining
8831whether or not to issue a warning.
8832@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8833Warnings controlled by the option can be disabled either by specifying
8834@var{byte-size} of @samp{SIZE_MAX} or more or by
8835@option{-Wno-frame-larger-than}.
8836
d77de738 8837@opindex Wno-frame-larger-than
ddf6fe37 8838@item -Wno-frame-larger-than
d77de738
ML
8839Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8840to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8841
d77de738
ML
8842@opindex Wfree-nonheap-object
8843@opindex Wno-free-nonheap-object
ddf6fe37 8844@item -Wfree-nonheap-object
d77de738
ML
8845Warn when attempting to deallocate an object that was either not allocated
8846on the heap, or by using a pointer that was not returned from a prior call
8847to the corresponding allocation function. For example, because the call
8848to @code{stpcpy} returns a pointer to the terminating nul character and
8849not to the beginning of the object, the call to @code{free} below is
8850diagnosed.
8851
8852@smallexample
8853void f (char *p)
8854@{
8855 p = stpcpy (p, "abc");
8856 // ...
8857 free (p); // warning
8858@}
8859@end smallexample
8860
8861@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8862
d77de738
ML
8863@opindex Wstack-usage
8864@opindex Wno-stack-usage
ddf6fe37 8865@item -Wstack-usage=@var{byte-size}
d77de738
ML
8866Warn if the stack usage of a function might exceed @var{byte-size}.
8867The computation done to determine the stack usage is conservative.
8868Any space allocated via @code{alloca}, variable-length arrays, or related
8869constructs is included by the compiler when determining whether or not to
8870issue a warning.
8871
8872The message is in keeping with the output of @option{-fstack-usage}.
8873
8874@itemize
8875@item
8876If the stack usage is fully static but exceeds the specified amount, it's:
8877
8878@smallexample
8879 warning: stack usage is 1120 bytes
8880@end smallexample
8881@item
8882If the stack usage is (partly) dynamic but bounded, it's:
8883
8884@smallexample
8885 warning: stack usage might be 1648 bytes
8886@end smallexample
8887@item
8888If the stack usage is (partly) dynamic and not bounded, it's:
8889
8890@smallexample
8891 warning: stack usage might be unbounded
8892@end smallexample
8893@end itemize
8894
8895@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8896Warnings controlled by the option can be disabled either by specifying
8897@var{byte-size} of @samp{SIZE_MAX} or more or by
8898@option{-Wno-stack-usage}.
8899
d77de738 8900@opindex Wno-stack-usage
ddf6fe37 8901@item -Wno-stack-usage
d77de738
ML
8902Disable @option{-Wstack-usage=} warnings. The option is equivalent
8903to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8904
d77de738
ML
8905@opindex Wunsafe-loop-optimizations
8906@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8907@item -Wunsafe-loop-optimizations
d77de738
ML
8908Warn if the loop cannot be optimized because the compiler cannot
8909assume anything on the bounds of the loop indices. With
8910@option{-funsafe-loop-optimizations} warn if the compiler makes
8911such assumptions.
8912
d77de738
ML
8913@opindex Wno-pedantic-ms-format
8914@opindex Wpedantic-ms-format
ddf6fe37 8915@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8916When used in combination with @option{-Wformat}
8917and @option{-pedantic} without GNU extensions, this option
8918disables the warnings about non-ISO @code{printf} / @code{scanf} format
8919width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8920which depend on the MS runtime.
8921
d77de738
ML
8922@opindex Wpointer-arith
8923@opindex Wno-pointer-arith
ddf6fe37 8924@item -Wpointer-arith
d77de738
ML
8925Warn about anything that depends on the ``size of'' a function type or
8926of @code{void}. GNU C assigns these types a size of 1, for
8927convenience in calculations with @code{void *} pointers and pointers
8928to functions. In C++, warn also when an arithmetic operation involves
8929@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8930
5fccebdb
JM
8931This warning is upgraded to an error by @option{-pedantic-errors}.
8932
d77de738
ML
8933@opindex Wpointer-compare
8934@opindex Wno-pointer-compare
ddf6fe37 8935@item -Wno-pointer-compare
d77de738
ML
8936Do not warn if a pointer is compared with a zero character constant.
8937This usually
8938means that the pointer was meant to be dereferenced. For example:
8939
8940@smallexample
8941const char *p = foo ();
8942if (p == '\0')
8943 return 42;
8944@end smallexample
8945
8946Note that the code above is invalid in C++11.
8947
8948This warning is enabled by default.
8949
d77de738
ML
8950@opindex Wtsan
8951@opindex Wno-tsan
ddf6fe37 8952@item -Wtsan
d77de738
ML
8953Warn about unsupported features in ThreadSanitizer.
8954
8955ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8956can report false positives.
8957
8958This warning is enabled by default.
8959
d77de738
ML
8960@opindex Wtype-limits
8961@opindex Wno-type-limits
ddf6fe37 8962@item -Wtype-limits
d77de738
ML
8963Warn if a comparison is always true or always false due to the limited
8964range of the data type, but do not warn for constant expressions. For
8965example, warn if an unsigned variable is compared against zero with
8966@code{<} or @code{>=}. This warning is also enabled by
8967@option{-Wextra}.
8968
d77de738
ML
8969@opindex Wabsolute-value
8970@opindex Wno-absolute-value
ddf6fe37 8971@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8972Warn for calls to standard functions that compute the absolute value
8973of an argument when a more appropriate standard function is available.
8974For example, calling @code{abs(3.14)} triggers the warning because the
8975appropriate function to call to compute the absolute value of a double
8976argument is @code{fabs}. The option also triggers warnings when the
8977argument in a call to such a function has an unsigned type. This
8978warning can be suppressed with an explicit type cast and it is also
8979enabled by @option{-Wextra}.
8980
8981@include cppwarnopts.texi
8982
d77de738
ML
8983@opindex Wbad-function-cast
8984@opindex Wno-bad-function-cast
ddf6fe37 8985@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
8986Warn when a function call is cast to a non-matching type.
8987For example, warn if a call to a function returning an integer type
8988is cast to a pointer type.
8989
d77de738
ML
8990@opindex Wc90-c99-compat
8991@opindex Wno-c90-c99-compat
ddf6fe37 8992@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
8993Warn about features not present in ISO C90, but present in ISO C99.
8994For instance, warn about use of variable length arrays, @code{long long}
8995type, @code{bool} type, compound literals, designated initializers, and so
8996on. This option is independent of the standards mode. Warnings are disabled
8997in the expression that follows @code{__extension__}.
8998
d77de738
ML
8999@opindex Wc99-c11-compat
9000@opindex Wno-c99-c11-compat
ddf6fe37 9001@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
9002Warn about features not present in ISO C99, but present in ISO C11.
9003For instance, warn about use of anonymous structures and unions,
9004@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9005@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9006and so on. This option is independent of the standards mode. Warnings are
9007disabled in the expression that follows @code{__extension__}.
9008
fad61bf7
JM
9009@opindex Wc11-c23-compat
9010@opindex Wno-c11-c23-compat
9011@item -Wc11-c23-compat @r{(C and Objective-C only)}
9012@itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9013Warn about features not present in ISO C11, but present in ISO C23.
d77de738
ML
9014For instance, warn about omitting the string in @code{_Static_assert},
9015use of @samp{[[]]} syntax for attributes, use of decimal
9016floating-point types, and so on. This option is independent of the
9017standards mode. Warnings are disabled in the expression that follows
fad61bf7
JM
9018@code{__extension__}. The name @option{-Wc11-c2x-compat} is
9019deprecated.
d77de738 9020
fad61bf7 9021When not compiling in C23 mode, these warnings are upgraded to errors
5fccebdb
JM
9022by @option{-pedantic-errors}.
9023
d77de738
ML
9024@opindex Wc++-compat
9025@opindex Wno-c++-compat
ddf6fe37 9026@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
9027Warn about ISO C constructs that are outside of the common subset of
9028ISO C and ISO C++, e.g.@: request for implicit conversion from
9029@code{void *} to a pointer to non-@code{void} type.
9030
d77de738
ML
9031@opindex Wc++11-compat
9032@opindex Wno-c++11-compat
ddf6fe37 9033@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9034Warn about C++ constructs whose meaning differs between ISO C++ 1998
9035and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9036in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9037enabled by @option{-Wall}.
9038
d77de738
ML
9039@opindex Wc++14-compat
9040@opindex Wno-c++14-compat
ddf6fe37 9041@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9042Warn about C++ constructs whose meaning differs between ISO C++ 2011
9043and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9044
d77de738
ML
9045@opindex Wc++17-compat
9046@opindex Wno-c++17-compat
ddf6fe37 9047@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9048Warn about C++ constructs whose meaning differs between ISO C++ 2014
9049and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9050
d77de738
ML
9051@opindex Wc++20-compat
9052@opindex Wno-c++20-compat
ddf6fe37 9053@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9054Warn about C++ constructs whose meaning differs between ISO C++ 2017
9055and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9056
d77de738
ML
9057@opindex Wc++11-extensions
9058@opindex Wno-c++11-extensions
ddf6fe37 9059@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9060Do not warn about C++11 constructs in code being compiled using
9061an older C++ standard. Even without this option, some C++11 constructs
9062will only be diagnosed if @option{-Wpedantic} is used.
9063
d77de738
ML
9064@opindex Wc++14-extensions
9065@opindex Wno-c++14-extensions
ddf6fe37 9066@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9067Do not warn about C++14 constructs in code being compiled using
9068an older C++ standard. Even without this option, some C++14 constructs
9069will only be diagnosed if @option{-Wpedantic} is used.
9070
d77de738
ML
9071@opindex Wc++17-extensions
9072@opindex Wno-c++17-extensions
ddf6fe37 9073@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9074Do not warn about C++17 constructs in code being compiled using
9075an older C++ standard. Even without this option, some C++17 constructs
9076will only be diagnosed if @option{-Wpedantic} is used.
9077
d77de738
ML
9078@opindex Wc++20-extensions
9079@opindex Wno-c++20-extensions
ddf6fe37 9080@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9081Do not warn about C++20 constructs in code being compiled using
9082an older C++ standard. Even without this option, some C++20 constructs
9083will only be diagnosed if @option{-Wpedantic} is used.
9084
d77de738
ML
9085@opindex Wc++23-extensions
9086@opindex Wno-c++23-extensions
ddf6fe37 9087@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9088Do not warn about C++23 constructs in code being compiled using
9089an older C++ standard. Even without this option, some C++23 constructs
9090will only be diagnosed if @option{-Wpedantic} is used.
9091
d77de738
ML
9092@opindex Wcast-qual
9093@opindex Wno-cast-qual
ddf6fe37 9094@item -Wcast-qual
d77de738
ML
9095Warn whenever a pointer is cast so as to remove a type qualifier from
9096the target type. For example, warn if a @code{const char *} is cast
9097to an ordinary @code{char *}.
9098
9099Also warn when making a cast that introduces a type qualifier in an
9100unsafe way. For example, casting @code{char **} to @code{const char **}
9101is unsafe, as in this example:
9102
9103@smallexample
9104 /* p is char ** value. */
9105 const char **q = (const char **) p;
9106 /* Assignment of readonly string to const char * is OK. */
9107 *q = "string";
9108 /* Now char** pointer points to read-only memory. */
9109 **p = 'b';
9110@end smallexample
9111
d77de738
ML
9112@opindex Wcast-align
9113@opindex Wno-cast-align
ddf6fe37 9114@item -Wcast-align
d77de738
ML
9115Warn whenever a pointer is cast such that the required alignment of the
9116target is increased. For example, warn if a @code{char *} is cast to
9117an @code{int *} on machines where integers can only be accessed at
9118two- or four-byte boundaries.
9119
d77de738 9120@opindex Wcast-align=strict
ddf6fe37 9121@item -Wcast-align=strict
d77de738
ML
9122Warn whenever a pointer is cast such that the required alignment of the
9123target is increased. For example, warn if a @code{char *} is cast to
9124an @code{int *} regardless of the target machine.
9125
d77de738
ML
9126@opindex Wcast-function-type
9127@opindex Wno-cast-function-type
ddf6fe37 9128@item -Wcast-function-type
d77de738
ML
9129Warn when a function pointer is cast to an incompatible function pointer.
9130In a cast involving function types with a variable argument list only
9131the types of initial arguments that are provided are considered.
9132Any parameter of pointer-type matches any other pointer-type. Any benign
9133differences in integral types are ignored, like @code{int} vs.@: @code{long}
9134on ILP32 targets. Likewise type qualifiers are ignored. The function
9135type @code{void (*) (void)} is special and matches everything, which can
9136be used to suppress this warning.
9137In a cast involving pointer to member types this warning warns whenever
9138the type cast is changing the pointer to member type.
9139This warning is enabled by @option{-Wextra}.
9140
d77de738
ML
9141@opindex Wwrite-strings
9142@opindex Wno-write-strings
ddf6fe37 9143@item -Wwrite-strings
d77de738
ML
9144When compiling C, give string constants the type @code{const
9145char[@var{length}]} so that copying the address of one into a
9146non-@code{const} @code{char *} pointer produces a warning. These
9147warnings help you find at compile time code that can try to write
9148into a string constant, but only if you have been very careful about
9149using @code{const} in declarations and prototypes. Otherwise, it is
9150just a nuisance. This is why we did not make @option{-Wall} request
9151these warnings.
9152
9153When compiling C++, warn about the deprecated conversion from string
9154literals to @code{char *}. This warning is enabled by default for C++
9155programs.
9156
5fccebdb
JM
9157This warning is upgraded to an error by @option{-pedantic-errors} in
9158C++11 mode or later.
9159
d77de738
ML
9160@opindex Wclobbered
9161@opindex Wno-clobbered
f33d7a88 9162@item -Wclobbered
d77de738
ML
9163Warn for variables that might be changed by @code{longjmp} or
9164@code{vfork}. This warning is also enabled by @option{-Wextra}.
9165
320dc51c
TS
9166@opindex Wcomplain-wrong-lang
9167@opindex Wno-complain-wrong-lang
f33d7a88 9168@item -Wno-complain-wrong-lang
320dc51c
TS
9169By default, language front ends complain when a command-line option is
9170valid, but not applicable to that front end.
9171This may be disabled with @option{-Wno-complain-wrong-lang},
9172which is mostly useful when invoking a single compiler driver for
9173multiple source files written in different languages, for example:
9174
9175@smallexample
9176$ g++ -fno-rtti a.cc b.f90
9177@end smallexample
9178
9179The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9180and the Fortran front end to compile @file{b.f90}.
9181The latter front end diagnoses
9182@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9183which may be disabled with @option{-Wno-complain-wrong-lang}.
9184
e1f45bea
JM
9185@opindex Wcompare-distinct-pointer-types
9186@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9187Warn if pointers of distinct types are compared without a cast. This
9188warning is enabled by default.
9189
d77de738
ML
9190@opindex Wconversion
9191@opindex Wno-conversion
f33d7a88 9192@item -Wconversion
d77de738
ML
9193Warn for implicit conversions that may alter a value. This includes
9194conversions between real and integer, like @code{abs (x)} when
9195@code{x} is @code{double}; conversions between signed and unsigned,
9196like @code{unsigned ui = -1}; and conversions to smaller types, like
9197@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9198((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9199changed by the conversion like in @code{abs (2.0)}. Warnings about
9200conversions between signed and unsigned integers can be disabled by
9201using @option{-Wno-sign-conversion}.
9202
9203For C++, also warn for confusing overload resolution for user-defined
9204conversions; and conversions that never use a type conversion
9205operator: conversions to @code{void}, the same type, a base class or a
9206reference to them. Warnings about conversions between signed and
9207unsigned integers are disabled by default in C++ unless
9208@option{-Wsign-conversion} is explicitly enabled.
9209
9210Warnings about conversion from arithmetic on a small type back to that
9211type are only given with @option{-Warith-conversion}.
9212
d77de738
ML
9213@opindex Wdangling-else
9214@opindex Wno-dangling-else
ddf6fe37 9215@item -Wdangling-else
d77de738
ML
9216Warn about constructions where there may be confusion to which
9217@code{if} statement an @code{else} branch belongs. Here is an example of
9218such a case:
9219
9220@smallexample
9221@group
9222@{
9223 if (a)
9224 if (b)
9225 foo ();
9226 else
9227 bar ();
9228@}
9229@end group
9230@end smallexample
9231
9232In C/C++, every @code{else} branch belongs to the innermost possible
9233@code{if} statement, which in this example is @code{if (b)}. This is
9234often not what the programmer expected, as illustrated in the above
9235example by indentation the programmer chose. When there is the
9236potential for this confusion, GCC issues a warning when this flag
9237is specified. To eliminate the warning, add explicit braces around
9238the innermost @code{if} statement so there is no way the @code{else}
9239can belong to the enclosing @code{if}. The resulting code
9240looks like this:
9241
9242@smallexample
9243@group
9244@{
9245 if (a)
9246 @{
9247 if (b)
9248 foo ();
9249 else
9250 bar ();
9251 @}
9252@}
9253@end group
9254@end smallexample
9255
9256This warning is enabled by @option{-Wparentheses}.
9257
d77de738
ML
9258@opindex Wdangling-pointer
9259@opindex Wno-dangling-pointer
ddf6fe37
AA
9260@item -Wdangling-pointer
9261@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9262Warn about uses of pointers (or C++ references) to objects with automatic
9263storage duration after their lifetime has ended. This includes local
9264variables declared in nested blocks, compound literals and other unnamed
9265temporary objects. In addition, warn about storing the address of such
9266objects in escaped pointers. The warning is enabled at all optimization
9267levels but may yield different results with optimization than without.
9268
9269@table @gcctabopt
9270@item -Wdangling-pointer=1
9271At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9272For example
9273@smallexample
9274int f (int c1, int c2, x)
9275@{
9276 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9277 // warning: dangling pointer to a compound literal
9278 return p ? *p : 'x';
d77de738
ML
9279@}
9280@end smallexample
9281In the following function the store of the address of the local variable
9282@code{x} in the escaped pointer @code{*p} also triggers the warning.
9283@smallexample
9284void g (int **p)
9285@{
9286 int x = 7;
4ace81b6
SL
9287 // warning: storing the address of a local variable in *p
9288 *p = &x;
d77de738
ML
9289@}
9290@end smallexample
9291
9292@item -Wdangling-pointer=2
9293At level 2, in addition to unconditional uses the warning also diagnoses
9294conditional uses of dangling pointers.
9295
9296For example, because the array @var{a} in the following function is out of
9297scope when the pointer @var{s} that was set to point is used, the warning
9298triggers at this level.
9299
9300@smallexample
9301void f (char *s)
9302@{
9303 if (!s)
9304 @{
9305 char a[12] = "tmpname";
9306 s = a;
9307 @}
4ace81b6
SL
9308 // warning: dangling pointer to a may be used
9309 strcat (s, ".tmp");
d77de738
ML
9310 ...
9311@}
9312@end smallexample
9313@end table
9314
9315@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9316
d77de738
ML
9317@opindex Wdate-time
9318@opindex Wno-date-time
ddf6fe37 9319@item -Wdate-time
d77de738
ML
9320Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9321are encountered as they might prevent bit-wise-identical reproducible
9322compilations.
9323
d77de738
ML
9324@opindex Wempty-body
9325@opindex Wno-empty-body
ddf6fe37 9326@item -Wempty-body
d77de738
ML
9327Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9328while} statement. This warning is also enabled by @option{-Wextra}.
9329
d77de738
ML
9330@opindex Wendif-labels
9331@opindex Wno-endif-labels
ddf6fe37 9332@item -Wno-endif-labels
d77de738
ML
9333Do not warn about stray tokens after @code{#else} and @code{#endif}.
9334
d77de738
ML
9335@opindex Wenum-compare
9336@opindex Wno-enum-compare
ddf6fe37 9337@item -Wenum-compare
d77de738
ML
9338Warn about a comparison between values of different enumerated types.
9339In C++ enumerated type mismatches in conditional expressions are also
9340diagnosed and the warning is enabled by default. In C this warning is
9341enabled by @option{-Wall}.
9342
d77de738
ML
9343@opindex Wenum-conversion
9344@opindex Wno-enum-conversion
ddf6fe37 9345@item -Wenum-conversion
d77de738
ML
9346Warn when a value of enumerated type is implicitly converted to a
9347different enumerated type. This warning is enabled by @option{-Wextra}
9348in C@.
9349
d77de738
ML
9350@opindex Wenum-int-mismatch
9351@opindex Wno-enum-int-mismatch
ddf6fe37 9352@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9353Warn about mismatches between an enumerated type and an integer type in
9354declarations. For example:
9355
9356@smallexample
9357enum E @{ l = -1, z = 0, g = 1 @};
9358int foo(void);
9359enum E foo(void);
9360@end smallexample
9361
9362In C, an enumerated type is compatible with @code{char}, a signed
9363integer type, or an unsigned integer type. However, since the choice
9364of the underlying type of an enumerated type is implementation-defined,
9365such mismatches may cause portability issues. In C++, such mismatches
9366are an error. In C, this warning is enabled by @option{-Wall} and
9367@option{-Wc++-compat}.
9368
d77de738
ML
9369@opindex Wjump-misses-init
9370@opindex Wno-jump-misses-init
ddf6fe37 9371@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9372Warn if a @code{goto} statement or a @code{switch} statement jumps
9373forward across the initialization of a variable, or jumps backward to a
9374label after the variable has been initialized. This only warns about
9375variables that are initialized when they are declared. This warning is
9376only supported for C and Objective-C; in C++ this sort of branch is an
9377error in any case.
9378
9379@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9380can be disabled with the @option{-Wno-jump-misses-init} option.
9381
d77de738
ML
9382@opindex Wsign-compare
9383@opindex Wno-sign-compare
9384@cindex warning for comparison of signed and unsigned values
9385@cindex comparison of signed and unsigned values, warning
9386@cindex signed and unsigned values, comparison warning
f33d7a88 9387@item -Wsign-compare
d77de738
ML
9388Warn when a comparison between signed and unsigned values could produce
9389an incorrect result when the signed value is converted to unsigned.
9390In C++, this warning is also enabled by @option{-Wall}. In C, it is
9391also enabled by @option{-Wextra}.
9392
d77de738
ML
9393@opindex Wsign-conversion
9394@opindex Wno-sign-conversion
ddf6fe37 9395@item -Wsign-conversion
d77de738
ML
9396Warn for implicit conversions that may change the sign of an integer
9397value, like assigning a signed integer expression to an unsigned
9398integer variable. An explicit cast silences the warning. In C, this
9399option is enabled also by @option{-Wconversion}.
9400
44e3f39a
QZ
9401@opindex Wflex-array-member-not-at-end
9402@opindex Wno-flex-array-member-not-at-end
9403@item -Wflex-array-member-not-at-end @r{(C and C++ only)}
9404Warn when a structure containing a C99 flexible array member as the last
9405field is not at the end of another structure.
9406This warning warns e.g. about
9407
9408@smallexample
9409struct flex @{ int length; char data[]; @};
9410struct mid_flex @{ int m; struct flex flex_data; int n; @};
9411@end smallexample
9412
d77de738
ML
9413@opindex Wfloat-conversion
9414@opindex Wno-float-conversion
ddf6fe37 9415@item -Wfloat-conversion
d77de738
ML
9416Warn for implicit conversions that reduce the precision of a real value.
9417This includes conversions from real to integer, and from higher precision
9418real to lower precision real values. This option is also enabled by
9419@option{-Wconversion}.
9420
d77de738
ML
9421@opindex Wno-scalar-storage-order
9422@opindex Wscalar-storage-order
ddf6fe37 9423@item -Wno-scalar-storage-order
d77de738
ML
9424Do not warn on suspicious constructs involving reverse scalar storage order.
9425
d77de738
ML
9426@opindex Wsizeof-array-div
9427@opindex Wno-sizeof-array-div
ddf6fe37 9428@item -Wsizeof-array-div
d77de738
ML
9429Warn about divisions of two sizeof operators when the first one is applied
9430to an array and the divisor does not equal the size of the array element.
9431In such a case, the computation will not yield the number of elements in the
9432array, which is likely what the user intended. This warning warns e.g. about
9433@smallexample
9434int fn ()
9435@{
9436 int arr[10];
9437 return sizeof (arr) / sizeof (short);
9438@}
9439@end smallexample
9440
9441This warning is enabled by @option{-Wall}.
9442
d77de738
ML
9443@opindex Wsizeof-pointer-div
9444@opindex Wno-sizeof-pointer-div
ddf6fe37 9445@item -Wsizeof-pointer-div
d77de738
ML
9446Warn for suspicious divisions of two sizeof expressions that divide
9447the pointer size by the element size, which is the usual way to compute
9448the array size but won't work out correctly with pointers. This warning
9449warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9450not an array, but a pointer. This warning is enabled by @option{-Wall}.
9451
d77de738
ML
9452@opindex Wsizeof-pointer-memaccess
9453@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9454@item -Wsizeof-pointer-memaccess
d77de738
ML
9455Warn for suspicious length parameters to certain string and memory built-in
9456functions if the argument uses @code{sizeof}. This warning triggers for
9457example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9458an array, but a pointer, and suggests a possible fix, or about
9459@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9460also warns about calls to bounded string copy functions like @code{strncat}
9461or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9462the source array. For example, in the following function the call to
9463@code{strncat} specifies the size of the source string as the bound. That
9464is almost certainly a mistake and so the call is diagnosed.
9465@smallexample
9466void make_file (const char *name)
9467@{
9468 char path[PATH_MAX];
9469 strncpy (path, name, sizeof path - 1);
9470 strncat (path, ".text", sizeof ".text");
9471 @dots{}
9472@}
9473@end smallexample
9474
9475The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9476
d77de738
ML
9477@opindex Wsizeof-array-argument
9478@opindex Wno-sizeof-array-argument
ddf6fe37 9479@item -Wno-sizeof-array-argument
d77de738
ML
9480Do not warn when the @code{sizeof} operator is applied to a parameter that is
9481declared as an array in a function definition. This warning is enabled by
9482default for C and C++ programs.
9483
d77de738
ML
9484@opindex Wmemset-elt-size
9485@opindex Wno-memset-elt-size
ddf6fe37 9486@item -Wmemset-elt-size
d77de738
ML
9487Warn for suspicious calls to the @code{memset} built-in function, if the
9488first argument references an array, and the third argument is a number
9489equal to the number of elements, but not equal to the size of the array
9490in memory. This indicates that the user has omitted a multiplication by
9491the element size. This warning is enabled by @option{-Wall}.
9492
d77de738
ML
9493@opindex Wmemset-transposed-args
9494@opindex Wno-memset-transposed-args
ddf6fe37 9495@item -Wmemset-transposed-args
d77de738
ML
9496Warn for suspicious calls to the @code{memset} built-in function where
9497the second argument is not zero and the third argument is zero. For
9498example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9499@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9500is only emitted if the third argument is a literal zero. Otherwise, if
9501it is an expression that is folded to zero, or a cast of zero to some
9502type, it is far less likely that the arguments have been mistakenly
9503transposed and no warning is emitted. This warning is enabled
9504by @option{-Wall}.
9505
d77de738
ML
9506@opindex Waddress
9507@opindex Wno-address
ddf6fe37 9508@item -Waddress
d77de738
ML
9509Warn about suspicious uses of address expressions. These include comparing
9510the address of a function or a declared object to the null pointer constant
9511such as in
9512@smallexample
9513void f (void);
9514void g (void)
9515@{
9516 if (!f) // warning: expression evaluates to false
9517 abort ();
9518@}
9519@end smallexample
9520comparisons of a pointer to a string literal, such as in
9521@smallexample
9522void f (const char *x)
9523@{
9524 if (x == "abc") // warning: expression evaluates to false
9525 puts ("equal");
9526@}
9527@end smallexample
9528and tests of the results of pointer addition or subtraction for equality
9529to null, such as in
9530@smallexample
9531void f (const int *p, int i)
9532@{
9533 return p + i == NULL;
9534@}
9535@end smallexample
9536Such uses typically indicate a programmer error: the address of most
9537functions and objects necessarily evaluates to true (the exception are
9538weak symbols), so their use in a conditional might indicate missing
9539parentheses in a function call or a missing dereference in an array
9540expression. The subset of the warning for object pointers can be
9541suppressed by casting the pointer operand to an integer type such
9542as @code{intptr_t} or @code{uintptr_t}.
9543Comparisons against string literals result in unspecified behavior
9544and are not portable, and suggest the intent was to call @code{strcmp}.
9545The warning is suppressed if the suspicious expression is the result
9546of macro expansion.
9547@option{-Waddress} warning is enabled by @option{-Wall}.
9548
d77de738
ML
9549@opindex Waddress-of-packed-member
9550@opindex Wno-address-of-packed-member
ddf6fe37 9551@item -Wno-address-of-packed-member
d77de738
ML
9552Do not warn when the address of packed member of struct or union is taken,
9553which usually results in an unaligned pointer value. This is
9554enabled by default.
9555
d77de738
ML
9556@opindex Wlogical-op
9557@opindex Wno-logical-op
ddf6fe37 9558@item -Wlogical-op
d77de738
ML
9559Warn about suspicious uses of logical operators in expressions.
9560This includes using logical operators in contexts where a
9561bit-wise operator is likely to be expected. Also warns when
9562the operands of a logical operator are the same:
9563@smallexample
9564extern int a;
9565if (a < 0 && a < 0) @{ @dots{} @}
9566@end smallexample
9567
d77de738
ML
9568@opindex Wlogical-not-parentheses
9569@opindex Wno-logical-not-parentheses
ddf6fe37 9570@item -Wlogical-not-parentheses
d77de738
ML
9571Warn about logical not used on the left hand side operand of a comparison.
9572This option does not warn if the right operand is considered to be a boolean
9573expression. Its purpose is to detect suspicious code like the following:
9574@smallexample
9575int a;
9576@dots{}
9577if (!a > 1) @{ @dots{} @}
9578@end smallexample
9579
9580It is possible to suppress the warning by wrapping the LHS into
9581parentheses:
9582@smallexample
9583if ((!a) > 1) @{ @dots{} @}
9584@end smallexample
9585
9586This warning is enabled by @option{-Wall}.
9587
d77de738
ML
9588@opindex Waggregate-return
9589@opindex Wno-aggregate-return
ddf6fe37 9590@item -Waggregate-return
d77de738
ML
9591Warn if any functions that return structures or unions are defined or
9592called. (In languages where you can return an array, this also elicits
9593a warning.)
9594
d77de738
ML
9595@opindex Wno-aggressive-loop-optimizations
9596@opindex Waggressive-loop-optimizations
ddf6fe37 9597@item -Wno-aggressive-loop-optimizations
d77de738
ML
9598Warn if in a loop with constant number of iterations the compiler detects
9599undefined behavior in some statement during one or more of the iterations.
9600
d77de738
ML
9601@opindex Wno-attributes
9602@opindex Wattributes
ddf6fe37 9603@item -Wno-attributes
d77de738
ML
9604Do not warn if an unexpected @code{__attribute__} is used, such as
9605unrecognized attributes, function attributes applied to variables,
9606etc. This does not stop errors for incorrect use of supported
9607attributes.
9608
5fccebdb
JM
9609Warnings about ill-formed uses of standard attributes are upgraded to
9610errors by @option{-pedantic-errors}.
9611
d77de738 9612Additionally, using @option{-Wno-attributes=}, it is possible to suppress
094a609c 9613warnings about unknown scoped attributes (in C++11 and C23). For example,
d77de738
ML
9614@option{-Wno-attributes=vendor::attr} disables warning about the following
9615declaration:
9616
9617@smallexample
9618[[vendor::attr]] void f();
9619@end smallexample
9620
9621It is also possible to disable warning about all attributes in a namespace
9622using @option{-Wno-attributes=vendor::} which prevents warning about both
9623of these declarations:
9624
9625@smallexample
9626[[vendor::safe]] void f();
9627[[vendor::unsafe]] void f2();
9628@end smallexample
9629
9630Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9631
d77de738
ML
9632@opindex Wno-builtin-declaration-mismatch
9633@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9634@item -Wno-builtin-declaration-mismatch
d77de738
ML
9635Warn if a built-in function is declared with an incompatible signature
9636or as a non-function, or when a built-in function declared with a type
9637that does not include a prototype is called with arguments whose promoted
9638types do not match those expected by the function. When @option{-Wextra}
9639is specified, also warn when a built-in function that takes arguments is
9640declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9641warning is enabled by default. To avoid the warning include the appropriate
9642header to bring the prototypes of built-in functions into scope.
9643
9644For example, the call to @code{memset} below is diagnosed by the warning
9645because the function expects a value of type @code{size_t} as its argument
9646but the type of @code{32} is @code{int}. With @option{-Wextra},
9647the declaration of the function is diagnosed as well.
9648@smallexample
9649extern void* memset ();
9650void f (void *d)
9651@{
9652 memset (d, '\0', 32);
9653@}
9654@end smallexample
9655
d77de738
ML
9656@opindex Wno-builtin-macro-redefined
9657@opindex Wbuiltin-macro-redefined
ddf6fe37 9658@item -Wno-builtin-macro-redefined
d77de738
ML
9659Do not warn if certain built-in macros are redefined. This suppresses
9660warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9661@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9662
d77de738
ML
9663@opindex Wstrict-prototypes
9664@opindex Wno-strict-prototypes
ddf6fe37 9665@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9666Warn if a function is declared or defined without specifying the
9667argument types. (An old-style function definition is permitted without
9668a warning if preceded by a declaration that specifies the argument
9669types.)
9670
d77de738
ML
9671@opindex Wold-style-declaration
9672@opindex Wno-old-style-declaration
ddf6fe37 9673@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9674Warn for obsolescent usages, according to the C Standard, in a
9675declaration. For example, warn if storage-class specifiers like
9676@code{static} are not the first things in a declaration. This warning
9677is also enabled by @option{-Wextra}.
9678
d77de738
ML
9679@opindex Wold-style-definition
9680@opindex Wno-old-style-definition
ddf6fe37 9681@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9682Warn if an old-style function definition is used. A warning is given
9683even if there is a previous prototype. A definition using @samp{()}
094a609c 9684is not considered an old-style definition in C23 mode, because it is
d77de738
ML
9685equivalent to @samp{(void)} in that case, but is considered an
9686old-style definition for older standards.
9687
d77de738
ML
9688@opindex Wmissing-parameter-type
9689@opindex Wno-missing-parameter-type
ddf6fe37 9690@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9691A function parameter is declared without a type specifier in K&R-style
9692functions:
9693
9694@smallexample
9695void foo(bar) @{ @}
9696@end smallexample
9697
9698This warning is also enabled by @option{-Wextra}.
9699
d77de738
ML
9700@opindex Wmissing-prototypes
9701@opindex Wno-missing-prototypes
ddf6fe37 9702@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9703Warn if a global function is defined without a previous prototype
9704declaration. This warning is issued even if the definition itself
9705provides a prototype. Use this option to detect global functions
9706that do not have a matching prototype declaration in a header file.
9707This option is not valid for C++ because all function declarations
9708provide prototypes and a non-matching declaration declares an
9709overload rather than conflict with an earlier declaration.
9710Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9711
ffc74822
HM
9712@opindex Wmissing-variable-declarations
9713@opindex Wno-missing-variable-declarations
9714@item -Wmissing-variable-declarations @r{(C and Objective-C only)}
9715Warn if a global variable is defined without a previous declaration.
9716Use this option to detect global variables that do not have a matching
9717extern declaration in a header file.
9718
d77de738
ML
9719@opindex Wmissing-declarations
9720@opindex Wno-missing-declarations
ddf6fe37 9721@item -Wmissing-declarations
d77de738
ML
9722Warn if a global function is defined without a previous declaration.
9723Do so even if the definition itself provides a prototype.
9724Use this option to detect global functions that are not declared in
9725header files. In C, no warnings are issued for functions with previous
9726non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9727missing prototypes. In C++, no warnings are issued for function templates,
9728or for inline functions, or for functions in anonymous namespaces.
9729
d77de738
ML
9730@opindex Wmissing-field-initializers
9731@opindex Wno-missing-field-initializers
9732@opindex W
9733@opindex Wextra
9734@opindex Wno-extra
ddf6fe37 9735@item -Wmissing-field-initializers
d77de738
ML
9736Warn if a structure's initializer has some fields missing. For
9737example, the following code causes such a warning, because
9738@code{x.h} is implicitly zero:
9739
9740@smallexample
9741struct s @{ int f, g, h; @};
9742struct s x = @{ 3, 4 @};
9743@end smallexample
9744
0f8f1dee
MP
9745@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
9746In C this option does not warn about designated initializers, so the
9747following modification does not trigger a warning:
d77de738
ML
9748
9749@smallexample
9750struct s @{ int f, g, h; @};
9751struct s x = @{ .f = 3, .g = 4 @};
9752@end smallexample
9753
9754In C this option does not warn about the universal zero initializer
9755@samp{@{ 0 @}}:
9756
9757@smallexample
9758struct s @{ int f, g, h; @};
9759struct s x = @{ 0 @};
9760@end smallexample
9761
9762Likewise, in C++ this option does not warn about the empty @{ @}
9763initializer, for example:
9764
9765@smallexample
9766struct s @{ int f, g, h; @};
9767s x = @{ @};
9768@end smallexample
9769
9770This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9771warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9772
d77de738
ML
9773@opindex Wmissing-requires
9774@opindex Wno-missing-requires
ddf6fe37 9775@item -Wno-missing-requires
d77de738
ML
9776
9777By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9778
9779@smallexample
9780bool satisfied = requires @{ C<T> @};
9781@end smallexample
9782
9783Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9784expression, which it is for all T. Presumably the user meant to write
9785
9786@smallexample
9787bool satisfied = requires @{ requires C<T> @};
9788@end smallexample
9789
9790so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9791type @samp{T}.
9792
9793This warning can be disabled with @option{-Wno-missing-requires}.
9794
d77de738
ML
9795@opindex Wmissing-template-keyword
9796@opindex Wno-missing-template-keyword
ddf6fe37 9797@item -Wno-missing-template-keyword
d77de738
ML
9798
9799The member access tokens ., -> and :: must be followed by the @code{template}
9800keyword if the parent object is dependent and the member being named is a
9801template.
9802
9803@smallexample
9804template <class X>
9805void DoStuff (X x)
9806@{
9807 x.template DoSomeOtherStuff<X>(); // Good.
9808 x.DoMoreStuff<X>(); // Warning, x is dependent.
9809@}
9810@end smallexample
9811
9812In rare cases it is possible to get false positives. To silence this, wrap
9813the expression in parentheses. For example, the following is treated as a
9814template, even where m and N are integers:
9815
9816@smallexample
9817void NotATemplate (my_class t)
9818@{
9819 int N = 5;
9820
9821 bool test = t.m < N > (0); // Treated as a template.
9822 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9823@}
9824@end smallexample
9825
9826This warning can be disabled with @option{-Wno-missing-template-keyword}.
9827
d77de738
ML
9828@opindex Wno-multichar
9829@opindex Wmultichar
ddf6fe37 9830@item -Wno-multichar
d77de738
ML
9831Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9832Usually they indicate a typo in the user's code, as they have
9833implementation-defined values, and should not be used in portable code.
9834
d77de738
ML
9835@opindex Wnormalized=
9836@opindex Wnormalized
9837@opindex Wno-normalized
9838@cindex NFC
9839@cindex NFKC
9840@cindex character set, input normalization
f33d7a88 9841@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9842In ISO C and ISO C++, two identifiers are different if they are
9843different sequences of characters. However, sometimes when characters
9844outside the basic ASCII character set are used, you can have two
9845different character sequences that look the same. To avoid confusion,
9846the ISO 10646 standard sets out some @dfn{normalization rules} which
9847when applied ensure that two sequences that look the same are turned into
9848the same sequence. GCC can warn you if you are using identifiers that
9849have not been normalized; this option controls that warning.
9850
9851There are four levels of warning supported by GCC@. The default is
9852@option{-Wnormalized=nfc}, which warns about any identifier that is
9853not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9854recommended form for most uses. It is equivalent to
9855@option{-Wnormalized}.
9856
9857Unfortunately, there are some characters allowed in identifiers by
9858ISO C and ISO C++ that, when turned into NFC, are not allowed in
9859identifiers. That is, there's no way to use these symbols in portable
9860ISO C or C++ and have all your identifiers in NFC@.
9861@option{-Wnormalized=id} suppresses the warning for these characters.
9862It is hoped that future versions of the standards involved will correct
9863this, which is why this option is not the default.
9864
9865You can switch the warning off for all characters by writing
9866@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9867only do this if you are using some other normalization scheme (like
9868``D''), because otherwise you can easily create bugs that are
9869literally impossible to see.
9870
9871Some characters in ISO 10646 have distinct meanings but look identical
9872in some fonts or display methodologies, especially once formatting has
9873been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9874LETTER N'', displays just like a regular @code{n} that has been
9875placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9876normalization scheme to convert all these into a standard form as
9877well, and GCC warns if your code is not in NFKC if you use
9878@option{-Wnormalized=nfkc}. This warning is comparable to warning
9879about every identifier that contains the letter O because it might be
9880confused with the digit 0, and so is not the default, but may be
9881useful as a local coding convention if the programming environment
9882cannot be fixed to display these characters distinctly.
9883
d77de738
ML
9884@opindex Wno-attribute-warning
9885@opindex Wattribute-warning
ddf6fe37 9886@item -Wno-attribute-warning
d77de738
ML
9887Do not warn about usage of functions (@pxref{Function Attributes})
9888declared with @code{warning} attribute. By default, this warning is
9889enabled. @option{-Wno-attribute-warning} can be used to disable the
9890warning or @option{-Wno-error=attribute-warning} can be used to
9891disable the error when compiled with @option{-Werror} flag.
9892
d77de738
ML
9893@opindex Wno-deprecated
9894@opindex Wdeprecated
ddf6fe37 9895@item -Wno-deprecated
d77de738
ML
9896Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9897
d77de738
ML
9898@opindex Wno-deprecated-declarations
9899@opindex Wdeprecated-declarations
ddf6fe37 9900@item -Wno-deprecated-declarations
d77de738
ML
9901Do not warn about uses of functions (@pxref{Function Attributes}),
9902variables (@pxref{Variable Attributes}), and types (@pxref{Type
9903Attributes}) marked as deprecated by using the @code{deprecated}
9904attribute.
9905
d77de738
ML
9906@opindex Wno-overflow
9907@opindex Woverflow
ddf6fe37 9908@item -Wno-overflow
d77de738
ML
9909Do not warn about compile-time overflow in constant expressions.
9910
d77de738
ML
9911@opindex Wno-odr
9912@opindex Wodr
ddf6fe37 9913@item -Wno-odr
d77de738
ML
9914Warn about One Definition Rule violations during link-time optimization.
9915Enabled by default.
9916
d77de738
ML
9917@opindex Wopenacc-parallelism
9918@opindex Wno-openacc-parallelism
9919@cindex OpenACC accelerator programming
f33d7a88 9920@item -Wopenacc-parallelism
d77de738
ML
9921Warn about potentially suboptimal choices related to OpenACC parallelism.
9922
d77de738
ML
9923@opindex Wopenmp-simd
9924@opindex Wno-openmp-simd
ddf6fe37 9925@item -Wopenmp-simd
d77de738
ML
9926Warn if the vectorizer cost model overrides the OpenMP
9927simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9928option can be used to relax the cost model.
9929
d77de738
ML
9930@opindex Woverride-init
9931@opindex Wno-override-init
9932@opindex W
9933@opindex Wextra
9934@opindex Wno-extra
ddf6fe37 9935@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9936Warn if an initialized field without side effects is overridden when
9937using designated initializers (@pxref{Designated Inits, , Designated
9938Initializers}).
9939
9940This warning is included in @option{-Wextra}. To get other
9941@option{-Wextra} warnings without this one, use @option{-Wextra
9942-Wno-override-init}.
9943
d77de738
ML
9944@opindex Woverride-init-side-effects
9945@opindex Wno-override-init-side-effects
ddf6fe37 9946@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9947Do not warn if an initialized field with side effects is overridden when
9948using designated initializers (@pxref{Designated Inits, , Designated
9949Initializers}). This warning is enabled by default.
9950
d77de738
ML
9951@opindex Wpacked
9952@opindex Wno-packed
ddf6fe37 9953@item -Wpacked
d77de738
ML
9954Warn if a structure is given the packed attribute, but the packed
9955attribute has no effect on the layout or size of the structure.
9956Such structures may be mis-aligned for little benefit. For
9957instance, in this code, the variable @code{f.x} in @code{struct bar}
9958is misaligned even though @code{struct bar} does not itself
9959have the packed attribute:
9960
9961@smallexample
9962@group
9963struct foo @{
9964 int x;
9965 char a, b, c, d;
9966@} __attribute__((packed));
9967struct bar @{
9968 char z;
9969 struct foo f;
9970@};
9971@end group
9972@end smallexample
9973
d77de738
ML
9974@opindex Wpacked-bitfield-compat
9975@opindex Wno-packed-bitfield-compat
ddf6fe37 9976@item -Wnopacked-bitfield-compat
d77de738
ML
9977The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9978on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9979the change can lead to differences in the structure layout. GCC
9980informs you when the offset of such a field has changed in GCC 4.4.
9981For example there is no longer a 4-bit padding between field @code{a}
9982and @code{b} in this structure:
9983
9984@smallexample
9985struct foo
9986@{
9987 char a:4;
9988 char b:8;
9989@} __attribute__ ((packed));
9990@end smallexample
9991
9992This warning is enabled by default. Use
9993@option{-Wno-packed-bitfield-compat} to disable this warning.
9994
d77de738
ML
9995@opindex Wpacked-not-aligned
9996@opindex Wno-packed-not-aligned
ddf6fe37 9997@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
9998Warn if a structure field with explicitly specified alignment in a
9999packed struct or union is misaligned. For example, a warning will
10000be issued on @code{struct S}, like, @code{warning: alignment 1 of
10001'struct S' is less than 8}, in this code:
10002
10003@smallexample
10004@group
10005struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10006struct __attribute__ ((packed)) S @{
10007 struct S8 s8;
10008@};
10009@end group
10010@end smallexample
10011
10012This warning is enabled by @option{-Wall}.
10013
d77de738
ML
10014@opindex Wpadded
10015@opindex Wno-padded
ddf6fe37 10016@item -Wpadded
d77de738
ML
10017Warn if padding is included in a structure, either to align an element
10018of the structure or to align the whole structure. Sometimes when this
10019happens it is possible to rearrange the fields of the structure to
10020reduce the padding and so make the structure smaller.
10021
d77de738
ML
10022@opindex Wredundant-decls
10023@opindex Wno-redundant-decls
ddf6fe37 10024@item -Wredundant-decls
d77de738
ML
10025Warn if anything is declared more than once in the same scope, even in
10026cases where multiple declaration is valid and changes nothing.
10027
d77de738
ML
10028@opindex Wrestrict
10029@opindex Wno-restrict
ddf6fe37 10030@item -Wrestrict
d77de738
ML
10031Warn when an object referenced by a @code{restrict}-qualified parameter
10032(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10033argument, or when copies between such objects overlap. For example,
10034the call to the @code{strcpy} function below attempts to truncate the string
10035by replacing its initial characters with the last four. However, because
10036the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10037the call is diagnosed.
10038
10039@smallexample
10040void foo (void)
10041@{
10042 char a[] = "abcd1234";
10043 strcpy (a, a + 4);
10044 @dots{}
10045@}
10046@end smallexample
10047The @option{-Wrestrict} option detects some instances of simple overlap
10048even without optimization but works best at @option{-O2} and above. It
10049is included in @option{-Wall}.
10050
d77de738
ML
10051@opindex Wnested-externs
10052@opindex Wno-nested-externs
ddf6fe37 10053@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
10054Warn if an @code{extern} declaration is encountered within a function.
10055
d77de738
ML
10056@opindex Winline
10057@opindex Wno-inline
ddf6fe37 10058@item -Winline
d77de738
ML
10059Warn if a function that is declared as inline cannot be inlined.
10060Even with this option, the compiler does not warn about failures to
10061inline functions declared in system headers.
10062
10063The compiler uses a variety of heuristics to determine whether or not
10064to inline a function. For example, the compiler takes into account
10065the size of the function being inlined and the amount of inlining
10066that has already been done in the current function. Therefore,
10067seemingly insignificant changes in the source program can cause the
10068warnings produced by @option{-Winline} to appear or disappear.
10069
d77de738 10070@opindex Winterference-size
ddf6fe37 10071@item -Winterference-size
d77de738
ML
10072Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10073without specifying its value with @option{--param destructive-interference-size}.
10074Also warn about questionable values for that option.
10075
10076This variable is intended to be used for controlling class layout, to
10077avoid false sharing in concurrent code:
10078
10079@smallexample
10080struct independent_fields @{
4ace81b6
SL
10081 alignas(std::hardware_destructive_interference_size)
10082 std::atomic<int> one;
10083 alignas(std::hardware_destructive_interference_size)
10084 std::atomic<int> two;
d77de738
ML
10085@};
10086@end smallexample
10087
10088Here @samp{one} and @samp{two} are intended to be far enough apart
10089that stores to one won't require accesses to the other to reload the
10090cache line.
10091
10092By default, @option{--param destructive-interference-size} and
10093@option{--param constructive-interference-size} are set based on the
10094current @option{-mtune} option, typically to the L1 cache line size
10095for the particular target CPU, sometimes to a range if tuning for a
10096generic target. So all translation units that depend on ABI
10097compatibility for the use of these variables must be compiled with
10098the same @option{-mtune} (or @option{-mcpu}).
10099
10100If ABI stability is important, such as if the use is in a header for a
10101library, you should probably not use the hardware interference size
10102variables at all. Alternatively, you can force a particular value
10103with @option{--param}.
10104
10105If you are confident that your use of the variable does not affect ABI
10106outside a single build of your project, you can turn off the warning
10107with @option{-Wno-interference-size}.
10108
d77de738
ML
10109@opindex Wint-in-bool-context
10110@opindex Wno-int-in-bool-context
ddf6fe37 10111@item -Wint-in-bool-context
d77de738
ML
10112Warn for suspicious use of integer values where boolean values are expected,
10113such as conditional expressions (?:) using non-boolean integer constants in
10114boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10115integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10116for all kinds of multiplications regardless of the data type.
10117This warning is enabled by @option{-Wall}.
10118
d77de738
ML
10119@opindex Wno-int-to-pointer-cast
10120@opindex Wint-to-pointer-cast
ddf6fe37 10121@item -Wno-int-to-pointer-cast
d77de738
ML
10122Suppress warnings from casts to pointer type of an integer of a
10123different size. In C++, casting to a pointer type of smaller size is
10124an error. @option{Wint-to-pointer-cast} is enabled by default.
10125
10126
d77de738
ML
10127@opindex Wno-pointer-to-int-cast
10128@opindex Wpointer-to-int-cast
ddf6fe37 10129@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
10130Suppress warnings from casts from a pointer to an integer type of a
10131different size.
10132
d77de738
ML
10133@opindex Winvalid-pch
10134@opindex Wno-invalid-pch
ddf6fe37 10135@item -Winvalid-pch
d77de738
ML
10136Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10137the search path but cannot be used.
10138
d77de738
ML
10139@opindex Winvalid-utf8
10140@opindex Wno-invalid-utf8
ddf6fe37 10141@item -Winvalid-utf8
d77de738
ML
10142Warn if an invalid UTF-8 character is found.
10143This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10144is used and turned into error with @option{-pedantic-errors}.
10145
d77de738
ML
10146@opindex Wunicode
10147@opindex Wno-unicode
ddf6fe37 10148@item -Wno-unicode
d77de738
ML
10149Don't diagnose invalid forms of delimited or named escape sequences which are
10150treated as separate tokens. @option{Wunicode} is enabled by default.
10151
d77de738
ML
10152@opindex Wlong-long
10153@opindex Wno-long-long
ddf6fe37 10154@item -Wlong-long
d77de738
ML
10155Warn if @code{long long} type is used. This is enabled by either
10156@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10157modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10158
5fccebdb
JM
10159This warning is upgraded to an error by @option{-pedantic-errors}.
10160
d77de738
ML
10161@opindex Wvariadic-macros
10162@opindex Wno-variadic-macros
ddf6fe37 10163@item -Wvariadic-macros
d77de738
ML
10164Warn if variadic macros are used in ISO C90 mode, or if the GNU
10165alternate syntax is used in ISO C99 mode. This is enabled by either
10166@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10167messages, use @option{-Wno-variadic-macros}.
10168
d77de738
ML
10169@opindex Wvarargs
10170@opindex Wno-varargs
ddf6fe37 10171@item -Wno-varargs
d77de738
ML
10172Do not warn upon questionable usage of the macros used to handle variable
10173arguments like @code{va_start}. These warnings are enabled by default.
10174
d77de738
ML
10175@opindex Wvector-operation-performance
10176@opindex Wno-vector-operation-performance
ddf6fe37 10177@item -Wvector-operation-performance
d77de738
ML
10178Warn if vector operation is not implemented via SIMD capabilities of the
10179architecture. Mainly useful for the performance tuning.
10180Vector operation can be implemented @code{piecewise}, which means that the
10181scalar operation is performed on every vector element;
10182@code{in parallel}, which means that the vector operation is implemented
10183using scalars of wider type, which normally is more performance efficient;
10184and @code{as a single scalar}, which means that vector fits into a
10185scalar type.
10186
d77de738
ML
10187@opindex Wvla
10188@opindex Wno-vla
ddf6fe37 10189@item -Wvla
d77de738
ML
10190Warn if a variable-length array is used in the code.
10191@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10192the variable-length array.
10193
5fccebdb
JM
10194This warning is upgraded to an error by @option{-pedantic-errors}.
10195
d77de738
ML
10196@opindex Wvla-larger-than=
10197@opindex Wno-vla-larger-than
ddf6fe37 10198@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10199If this option is used, the compiler warns for declarations of
10200variable-length arrays whose size is either unbounded, or bounded
10201by an argument that allows the array size to exceed @var{byte-size}
10202bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10203works, but with variable-length arrays.
10204
10205Note that GCC may optimize small variable-length arrays of a known
10206value into plain arrays, so this warning may not get triggered for
10207such arrays.
10208
10209@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10210is typically only effective when @option{-ftree-vrp} is active (default
10211for @option{-O2} and above).
10212
10213See also @option{-Walloca-larger-than=@var{byte-size}}.
10214
d77de738 10215@opindex Wno-vla-larger-than
ddf6fe37 10216@item -Wno-vla-larger-than
d77de738
ML
10217Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10218to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10219
d77de738 10220@opindex Wno-vla-parameter
ddf6fe37 10221@item -Wvla-parameter
d77de738
ML
10222Warn about redeclarations of functions involving arguments of Variable
10223Length Array types of inconsistent kinds or forms, and enable the detection
10224of out-of-bounds accesses to such parameters by warnings such as
10225@option{-Warray-bounds}.
10226
10227If the first function declaration uses the VLA form the bound specified
10228in the array is assumed to be the minimum number of elements expected to
10229be provided in calls to the function and the maximum number of elements
10230accessed by it. Failing to provide arguments of sufficient size or
10231accessing more than the maximum number of elements may be diagnosed.
10232
10233For example, the warning triggers for the following redeclarations because
10234the first one allows an array of any size to be passed to @code{f} while
10235the second one specifies that the array argument must have at least @code{n}
10236elements. In addition, calling @code{f} with the associated VLA bound
10237parameter in excess of the actual VLA bound triggers a warning as well.
10238
10239@smallexample
10240void f (int n, int[n]);
4ace81b6
SL
10241// warning: argument 2 previously declared as a VLA
10242void f (int, int[]);
d77de738
ML
10243
10244void g (int n)
10245@{
10246 if (n > 4)
10247 return;
10248 int a[n];
4ace81b6
SL
10249 // warning: access to a by f may be out of bounds
10250 f (sizeof a, a);
d77de738
ML
10251 @dots{}
10252@}
10253
10254@end smallexample
10255
10256@option{-Wvla-parameter} is included in @option{-Wall}. The
10257@option{-Warray-parameter} option triggers warnings for similar problems
10258involving ordinary array arguments.
10259
d77de738
ML
10260@opindex Wvolatile-register-var
10261@opindex Wno-volatile-register-var
ddf6fe37 10262@item -Wvolatile-register-var
d77de738
ML
10263Warn if a register variable is declared volatile. The volatile
10264modifier does not inhibit all optimizations that may eliminate reads
10265and/or writes to register variables. This warning is enabled by
10266@option{-Wall}.
10267
d77de738
ML
10268@opindex Wxor-used-as-pow
10269@opindex Wno-xor-used-as-pow
ddf6fe37 10270@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10271Warn about uses of @code{^}, the exclusive or operator, where it appears
10272the user meant exponentiation. Specifically, the warning occurs when the
10273left-hand side is the decimal constant 2 or 10 and the right-hand side
10274is also a decimal constant.
10275
10276In C and C++, @code{^} means exclusive or, whereas in some other languages
10277(e.g. TeX and some versions of BASIC) it means exponentiation.
10278
10279This warning is enabled by default. It can be silenced by converting one
10280of the operands to hexadecimal.
10281
d77de738
ML
10282@opindex Wdisabled-optimization
10283@opindex Wno-disabled-optimization
ddf6fe37 10284@item -Wdisabled-optimization
d77de738
ML
10285Warn if a requested optimization pass is disabled. This warning does
10286not generally indicate that there is anything wrong with your code; it
10287merely indicates that GCC's optimizers are unable to handle the code
10288effectively. Often, the problem is that your code is too big or too
10289complex; GCC refuses to optimize programs when the optimization
10290itself is likely to take inordinate amounts of time.
10291
d77de738
ML
10292@opindex Wpointer-sign
10293@opindex Wno-pointer-sign
ddf6fe37 10294@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10295Warn for pointer argument passing or assignment with different signedness.
10296This option is only supported for C and Objective-C@. It is implied by
10297@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10298@option{-Wno-pointer-sign}.
10299
5fccebdb
JM
10300This warning is upgraded to an error by @option{-pedantic-errors}.
10301
d77de738
ML
10302@opindex Wstack-protector
10303@opindex Wno-stack-protector
ddf6fe37 10304@item -Wstack-protector
d77de738
ML
10305This option is only active when @option{-fstack-protector} is active. It
10306warns about functions that are not protected against stack smashing.
10307
d77de738
ML
10308@opindex Woverlength-strings
10309@opindex Wno-overlength-strings
ddf6fe37 10310@item -Woverlength-strings
d77de738
ML
10311Warn about string constants that are longer than the ``minimum
10312maximum'' length specified in the C standard. Modern compilers
10313generally allow string constants that are much longer than the
10314standard's minimum limit, but very portable programs should avoid
10315using longer strings.
10316
10317The limit applies @emph{after} string constant concatenation, and does
10318not count the trailing NUL@. In C90, the limit was 509 characters; in
10319C99, it was raised to 4095. C++98 does not specify a normative
10320minimum maximum, so we do not diagnose overlength strings in C++@.
10321
10322This option is implied by @option{-Wpedantic}, and can be disabled with
10323@option{-Wno-overlength-strings}.
10324
d77de738
ML
10325@opindex Wunsuffixed-float-constants
10326@opindex Wno-unsuffixed-float-constants
ddf6fe37 10327@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10328
10329Issue a warning for any floating constant that does not have
10330a suffix. When used together with @option{-Wsystem-headers} it
10331warns about such constants in system header files. This can be useful
10332when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10333from the decimal floating-point extension to C99.
10334
d77de738
ML
10335@opindex Wlto-type-mismatch
10336@opindex Wno-lto-type-mismatch
ddf6fe37 10337@item -Wno-lto-type-mismatch
d77de738
ML
10338
10339During the link-time optimization, do not warn about type mismatches in
10340global declarations from different compilation units.
10341Requires @option{-flto} to be enabled. Enabled by default.
10342
d77de738
ML
10343@opindex Wdesignated-init
10344@opindex Wno-designated-init
ddf6fe37 10345@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10346Suppress warnings when a positional initializer is used to initialize
10347a structure that has been marked with the @code{designated_init}
10348attribute.
10349
10350@end table
10351
10352@node Static Analyzer Options
10353@section Options That Control Static Analysis
10354
10355@table @gcctabopt
d77de738
ML
10356@opindex analyzer
10357@opindex fanalyzer
10358@opindex fno-analyzer
ddf6fe37 10359@item -fanalyzer
d77de738
ML
10360This option enables an static analysis of program flow which looks
10361for ``interesting'' interprocedural paths through the
10362code, and issues warnings for problems found on them.
10363
10364This analysis is much more expensive than other GCC warnings.
10365
a90316c6
DM
10366In technical terms, it performs coverage-guided symbolic execution of
10367the code being compiled. It is neither sound nor complete: it can
10368have false positives and false negatives. It is a bug-finding tool,
10369rather than a tool for proving program correctness.
10370
10371The analyzer is only suitable for use on C code in this release.
10372
d77de738
ML
10373Enabling this option effectively enables the following warnings:
10374
43b72ede
AA
10375@gccoptlist{
10376-Wanalyzer-allocation-size
10377-Wanalyzer-deref-before-check
10378-Wanalyzer-double-fclose
10379-Wanalyzer-double-free
10380-Wanalyzer-exposure-through-output-file
10381-Wanalyzer-exposure-through-uninit-copy
10382-Wanalyzer-fd-access-mode-mismatch
10383-Wanalyzer-fd-double-close
10384-Wanalyzer-fd-leak
10385-Wanalyzer-fd-phase-mismatch
10386-Wanalyzer-fd-type-mismatch
10387-Wanalyzer-fd-use-after-close
10388-Wanalyzer-fd-use-without-check
10389-Wanalyzer-file-leak
10390-Wanalyzer-free-of-non-heap
10391-Wanalyzer-imprecise-fp-arithmetic
10392-Wanalyzer-infinite-recursion
10393-Wanalyzer-jump-through-null
10394-Wanalyzer-malloc-leak
10395-Wanalyzer-mismatching-deallocation
10396-Wanalyzer-null-argument
10397-Wanalyzer-null-dereference
10398-Wanalyzer-out-of-bounds
034d99e8 10399-Wanalyzer-overlapping-buffers
43b72ede
AA
10400-Wanalyzer-possible-null-argument
10401-Wanalyzer-possible-null-dereference
10402-Wanalyzer-putenv-of-auto-var
10403-Wanalyzer-shift-count-negative
10404-Wanalyzer-shift-count-overflow
10405-Wanalyzer-stale-setjmp-buffer
10406-Wanalyzer-unsafe-call-within-signal-handler
10407-Wanalyzer-use-after-free
10408-Wanalyzer-use-of-pointer-in-stale-stack-frame
10409-Wanalyzer-use-of-uninitialized-value
10410-Wanalyzer-va-arg-type-mismatch
10411-Wanalyzer-va-list-exhausted
10412-Wanalyzer-va-list-leak
10413-Wanalyzer-va-list-use-after-va-end
10414-Wanalyzer-write-to-const
10415-Wanalyzer-write-to-string-literal
d77de738
ML
10416}
10417@ignore
43b72ede
AA
10418-Wanalyzer-tainted-allocation-size
10419-Wanalyzer-tainted-array-index
10420-Wanalyzer-tainted-divisor
10421-Wanalyzer-tainted-offset
10422-Wanalyzer-tainted-size
d77de738
ML
10423@end ignore
10424
10425This option is only available if GCC was configured with analyzer
10426support enabled.
10427
d77de738
ML
10428@opindex Wanalyzer-too-complex
10429@opindex Wno-analyzer-too-complex
ddf6fe37 10430@item -Wanalyzer-too-complex
d77de738
ML
10431If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10432to attempt to explore the control flow and data flow in the program,
10433but these can be defeated by sufficiently complicated code.
10434
10435By default, the analysis silently stops if the code is too
10436complicated for the analyzer to fully explore and it reaches an internal
10437limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10438
d77de738
ML
10439@opindex Wanalyzer-allocation-size
10440@opindex Wno-analyzer-allocation-size
ddf6fe37 10441@item -Wno-analyzer-allocation-size
4ace81b6
SL
10442This warning requires @option{-fanalyzer}, which enables it;
10443to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10444
10445This diagnostic warns for paths through the code in which a pointer to
10446a buffer is assigned to point at a buffer with a size that is not a
10447multiple of @code{sizeof (*pointer)}.
10448
10449See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10450
ce51e843
ML
10451@opindex Wanalyzer-deref-before-check
10452@opindex Wno-analyzer-deref-before-check
ddf6fe37 10453@item -Wno-analyzer-deref-before-check
ce51e843
ML
10454This warning requires @option{-fanalyzer}, which enables it; use
10455@option{-Wno-analyzer-deref-before-check}
10456to disable it.
10457
10458This diagnostic warns for paths through the code in which a pointer
10459is checked for @code{NULL} *after* it has already been
10460dereferenced, suggesting that the pointer could have been NULL.
10461Such cases suggest that the check for NULL is either redundant,
10462or that it needs to be moved to before the pointer is dereferenced.
10463
10464This diagnostic also considers values passed to a function argument
10465marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10466value, and thus will complain if such values are checked for @code{NULL}
10467after returning from such a function call.
10468
10469This diagnostic is unlikely to be reported when any level of optimization
10470is enabled, as GCC's optimization logic will typically consider such
10471checks for NULL as being redundant, and optimize them away before the
10472analyzer "sees" them. Hence optimization should be disabled when
10473attempting to trigger this diagnostic.
10474
d77de738
ML
10475@opindex Wanalyzer-double-fclose
10476@opindex Wno-analyzer-double-fclose
ddf6fe37 10477@item -Wno-analyzer-double-fclose
d77de738
ML
10478This warning requires @option{-fanalyzer}, which enables it; use
10479@option{-Wno-analyzer-double-fclose} to disable it.
10480
10481This diagnostic warns for paths through the code in which a @code{FILE *}
10482can have @code{fclose} called on it more than once.
10483
10484See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10485
d77de738
ML
10486@opindex Wanalyzer-double-free
10487@opindex Wno-analyzer-double-free
ddf6fe37 10488@item -Wno-analyzer-double-free
d77de738
ML
10489This warning requires @option{-fanalyzer}, which enables it; use
10490@option{-Wno-analyzer-double-free} to disable it.
10491
10492This diagnostic warns for paths through the code in which a pointer
10493can have a deallocator called on it more than once, either @code{free},
10494or a deallocator referenced by attribute @code{malloc}.
10495
10496See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10497
d77de738
ML
10498@opindex Wanalyzer-exposure-through-output-file
10499@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10500@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10501This warning requires @option{-fanalyzer}, which enables it; use
10502@option{-Wno-analyzer-exposure-through-output-file}
10503to disable it.
10504
10505This diagnostic warns for paths through the code in which a
10506security-sensitive value is written to an output file
10507(such as writing a password to a log file).
10508
10509See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10510
d77de738
ML
10511@opindex Wanalyzer-exposure-through-uninit-copy
10512@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10513@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10514This warning requires both @option{-fanalyzer} and the use of a plugin
10515to specify a function that copies across a ``trust boundary''. Use
10516@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10517
10518This diagnostic warns for ``infoleaks'' - paths through the code in which
10519uninitialized values are copied across a security boundary
10520(such as code within an OS kernel that copies a partially-initialized
10521struct on the stack to user space).
10522
10523See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10524
d77de738
ML
10525@opindex Wanalyzer-fd-access-mode-mismatch
10526@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10527@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10528This warning requires @option{-fanalyzer}, which enables it; use
10529@option{-Wno-analyzer-fd-access-mode-mismatch}
10530to disable it.
10531
10532This diagnostic warns for paths through code in which a
10533@code{read} on a write-only file descriptor is attempted, or vice versa.
10534
10535This diagnostic also warns for code paths in a which a function with attribute
10536@code{fd_arg_read (N)} is called with a file descriptor opened with
10537@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10538@code{fd_arg_write (N)} is called with a file descriptor opened with
10539@code{O_RDONLY} at referenced argument @var{N}.
10540
d77de738
ML
10541@opindex Wanalyzer-fd-double-close
10542@opindex Wno-analyzer-fd-double-close
ddf6fe37 10543@item -Wno-analyzer-fd-double-close
d77de738
ML
10544This warning requires @option{-fanalyzer}, which enables it; use
10545@option{-Wno-analyzer-fd-double-close}
10546to disable it.
10547
10548This diagnostic warns for paths through code in which a
10549file descriptor can be closed more than once.
10550
10551See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10552
d77de738
ML
10553@opindex Wanalyzer-fd-leak
10554@opindex Wno-analyzer-fd-leak
ddf6fe37 10555@item -Wno-analyzer-fd-leak
d77de738
ML
10556This warning requires @option{-fanalyzer}, which enables it; use
10557@option{-Wno-analyzer-fd-leak}
10558to disable it.
10559
10560This diagnostic warns for paths through code in which an
10561open file descriptor is leaked.
10562
10563See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10564
86a90006
DM
10565@opindex Wanalyzer-fd-phase-mismatch
10566@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10567@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10568This warning requires @option{-fanalyzer}, which enables it; use
10569@option{-Wno-analyzer-fd-phase-mismatch}
10570to disable it.
10571
10572This diagnostic warns for paths through code in which an operation is
10573attempted in the wrong phase of a file descriptor's lifetime.
10574For example, it will warn on attempts to call @code{accept} on a stream
10575socket that has not yet had @code{listen} successfully called on it.
10576
10577See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10578
86a90006
DM
10579@opindex Wanalyzer-fd-type-mismatch
10580@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10581@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10582This warning requires @option{-fanalyzer}, which enables it; use
10583@option{-Wno-analyzer-fd-type-mismatch}
10584to disable it.
10585
10586This diagnostic warns for paths through code in which an
10587operation is attempted on the wrong type of file descriptor.
10588For example, it will warn on attempts to use socket operations
10589on a file descriptor obtained via @code{open}, or when attempting
10590to use a stream socket operation on a datagram socket.
10591
d77de738
ML
10592@opindex Wanalyzer-fd-use-after-close
10593@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10594@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10595This warning requires @option{-fanalyzer}, which enables it; use
10596@option{-Wno-analyzer-fd-use-after-close}
10597to disable it.
10598
10599This diagnostic warns for paths through code in which a
10600read or write is called on a closed file descriptor.
10601
10602This diagnostic also warns for paths through code in which
10603a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10604or @code{fd_arg_write (N)} is called with a closed file descriptor at
10605referenced argument @code{N}.
10606
d77de738
ML
10607@opindex Wanalyzer-fd-use-without-check
10608@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10609@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10610This warning requires @option{-fanalyzer}, which enables it; use
10611@option{-Wno-analyzer-fd-use-without-check}
10612to disable it.
10613
10614This diagnostic warns for paths through code in which a
10615file descriptor is used without being checked for validity.
10616
10617This diagnostic also warns for paths through code in which
10618a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10619or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10620argument @code{N}, without being checked for validity.
10621
d77de738
ML
10622@opindex Wanalyzer-file-leak
10623@opindex Wno-analyzer-file-leak
ddf6fe37 10624@item -Wno-analyzer-file-leak
d77de738
ML
10625This warning requires @option{-fanalyzer}, which enables it; use
10626@option{-Wno-analyzer-file-leak}
10627to disable it.
10628
10629This diagnostic warns for paths through the code in which a
10630@code{<stdio.h>} @code{FILE *} stream object is leaked.
10631
10632See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10633
d77de738
ML
10634@opindex Wanalyzer-free-of-non-heap
10635@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10636@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10637This warning requires @option{-fanalyzer}, which enables it; use
10638@option{-Wno-analyzer-free-of-non-heap}
10639to disable it.
10640
10641This diagnostic warns for paths through the code in which @code{free}
10642is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10643
10644See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10645
d77de738
ML
10646@opindex Wanalyzer-imprecise-fp-arithmetic
10647@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10648@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10649This warning requires @option{-fanalyzer}, which enables it; use
10650@option{-Wno-analyzer-imprecise-fp-arithmetic}
10651to disable it.
10652
10653This diagnostic warns for paths through the code in which floating-point
10654arithmetic is used in locations where precise computation is needed. This
10655diagnostic only warns on use of floating-point operands inside the
10656calculation of an allocation size at the moment.
10657
ce51e843
ML
10658@opindex Wanalyzer-infinite-recursion
10659@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10660@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10661This warning requires @option{-fanalyzer}, which enables it; use
10662@option{-Wno-analyzer-infinite-recursion} to disable it.
10663
10664This diagnostics warns for paths through the code which appear to
10665lead to infinite recursion.
10666
10667Specifically, when the analyzer "sees" a recursive call, it will compare
10668the state of memory at the entry to the new frame with that at the entry
10669to the previous frame of that function on the stack. The warning is
10670issued if nothing in memory appears to be changing; any changes observed
10671to parameters or globals are assumed to lead to termination of the
10672recursion and thus suppress the warning.
10673
10674This diagnostic is likely to miss cases of infinite recursion that
10675are convered to iteration by the optimizer before the analyzer "sees"
10676them. Hence optimization should be disabled when attempting to trigger
10677this diagnostic.
10678
10679Compare with @option{-Winfinite-recursion}, which provides a similar
10680diagnostic, but is implemented in a different way.
10681
d77de738
ML
10682@opindex Wanalyzer-jump-through-null
10683@opindex Wno-analyzer-jump-through-null
ddf6fe37 10684@item -Wno-analyzer-jump-through-null
d77de738
ML
10685This warning requires @option{-fanalyzer}, which enables it; use
10686@option{-Wno-analyzer-jump-through-null}
10687to disable it.
10688
10689This diagnostic warns for paths through the code in which a @code{NULL}
10690function pointer is called.
10691
d77de738
ML
10692@opindex Wanalyzer-malloc-leak
10693@opindex Wno-analyzer-malloc-leak
ddf6fe37 10694@item -Wno-analyzer-malloc-leak
d77de738
ML
10695This warning requires @option{-fanalyzer}, which enables it; use
10696@option{-Wno-analyzer-malloc-leak}
10697to disable it.
10698
10699This diagnostic warns for paths through the code in which a
10700pointer allocated via an allocator is leaked: either @code{malloc},
10701or a function marked with attribute @code{malloc}.
10702
10703See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10704
d77de738
ML
10705@opindex Wanalyzer-mismatching-deallocation
10706@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10707@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10708This warning requires @option{-fanalyzer}, which enables it; use
10709@option{-Wno-analyzer-mismatching-deallocation}
10710to disable it.
10711
10712This diagnostic warns for paths through the code in which the
10713wrong deallocation function is called on a pointer value, based on
10714which function was used to allocate the pointer value. The diagnostic
10715will warn about mismatches between @code{free}, scalar @code{delete}
10716and vector @code{delete[]}, and those marked as allocator/deallocator
10717pairs using attribute @code{malloc}.
10718
10719See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10720
d77de738
ML
10721@opindex Wanalyzer-out-of-bounds
10722@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10723@item -Wno-analyzer-out-of-bounds
4ace81b6 10724This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10725@option{-Wno-analyzer-out-of-bounds} to disable it.
10726
4ace81b6 10727This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10728definitely read or written out-of-bounds. The diagnostic applies for
10729cases where the analyzer is able to determine a constant offset and for
10730accesses past the end of a buffer, also a constant capacity. Further,
10731the diagnostic does limited checking for accesses past the end when the
10732offset as well as the capacity is symbolic.
10733
10734See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10735
0e466e97
DM
10736For cases where the analyzer is able, it will emit a text art diagram
10737visualizing the spatial relationship between the memory region that the
10738analyzer predicts would be accessed, versus the range of memory that is
10739valid to access: whether they overlap, are touching, are close or far
10740apart; which one is before or after in memory, the relative sizes
10741involved, the direction of the access (read vs write), and, in some
10742cases, the values of data involved. This diagram can be suppressed
10743using @option{-fdiagnostics-text-art-charset=none}.
10744
034d99e8
DM
10745@opindex Wanalyzer-overlapping-buffers
10746@opindex Wno-analyzer-overlapping-buffers
10747@item -Wno-analyzer-overlapping-buffers
10748This warning requires @option{-fanalyzer}, which enables it; use
10749@option{-Wno-analyzer-overlapping-buffers} to disable it.
10750
10751This diagnostic warns for paths through the code in which overlapping
10752buffers are passed to an API for which the behavior on such buffers
10753is undefined.
10754
10755Specifically, the diagnostic occurs on calls to the following functions
10756@itemize @bullet
10757@item @code{memcpy}
10758@item @code{strcat}
10759@item @code{strcpy}
10760@end itemize
10761for cases where the buffers are known to overlap.
10762
d77de738
ML
10763@opindex Wanalyzer-possible-null-argument
10764@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10765@item -Wno-analyzer-possible-null-argument
d77de738
ML
10766This warning requires @option{-fanalyzer}, which enables it; use
10767@option{-Wno-analyzer-possible-null-argument} to disable it.
10768
10769This diagnostic warns for paths through the code in which a
10770possibly-NULL value is passed to a function argument marked
10771with @code{__attribute__((nonnull))} as requiring a non-NULL
10772value.
10773
10774See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10775
d77de738
ML
10776@opindex Wanalyzer-possible-null-dereference
10777@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10778@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10779This warning requires @option{-fanalyzer}, which enables it; use
10780@option{-Wno-analyzer-possible-null-dereference} to disable it.
10781
10782This diagnostic warns for paths through the code in which a
10783possibly-NULL value is dereferenced.
10784
10785See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10786
d77de738
ML
10787@opindex Wanalyzer-null-argument
10788@opindex Wno-analyzer-null-argument
ddf6fe37 10789@item -Wno-analyzer-null-argument
d77de738
ML
10790This warning requires @option{-fanalyzer}, which enables it; use
10791@option{-Wno-analyzer-null-argument} to disable it.
10792
10793This diagnostic warns for paths through the code in which a
10794value known to be NULL is passed to a function argument marked
10795with @code{__attribute__((nonnull))} as requiring a non-NULL
10796value.
10797
10798See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10799
d77de738
ML
10800@opindex Wanalyzer-null-dereference
10801@opindex Wno-analyzer-null-dereference
ddf6fe37 10802@item -Wno-analyzer-null-dereference
d77de738
ML
10803This warning requires @option{-fanalyzer}, which enables it; use
10804@option{-Wno-analyzer-null-dereference} to disable it.
10805
10806This diagnostic warns for paths through the code in which a
10807value known to be NULL is dereferenced.
10808
10809See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10810
d77de738
ML
10811@opindex Wanalyzer-putenv-of-auto-var
10812@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10813@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10814This warning requires @option{-fanalyzer}, which enables it; use
10815@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10816
10817This diagnostic warns for paths through the code in which a
10818call to @code{putenv} is passed a pointer to an automatic variable
10819or an on-stack buffer.
10820
10821See @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}.
10822
d77de738
ML
10823@opindex Wanalyzer-shift-count-negative
10824@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10825@item -Wno-analyzer-shift-count-negative
d77de738
ML
10826This warning requires @option{-fanalyzer}, which enables it; use
10827@option{-Wno-analyzer-shift-count-negative} to disable it.
10828
10829This diagnostic warns for paths through the code in which a
10830shift is attempted with a negative count. It is analogous to
10831the @option{-Wshift-count-negative} diagnostic implemented in
10832the C/C++ front ends, but is implemented based on analyzing
10833interprocedural paths, rather than merely parsing the syntax tree.
10834However, the analyzer does not prioritize detection of such paths, so
10835false negatives are more likely relative to other warnings.
10836
d77de738
ML
10837@opindex Wanalyzer-shift-count-overflow
10838@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10839@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10840This warning requires @option{-fanalyzer}, which enables it; use
10841@option{-Wno-analyzer-shift-count-overflow} to disable it.
10842
10843This diagnostic warns for paths through the code in which a
10844shift is attempted with a count greater than or equal to the
10845precision of the operand's type. It is analogous to
10846the @option{-Wshift-count-overflow} diagnostic implemented in
10847the C/C++ front ends, but is implemented based on analyzing
10848interprocedural paths, rather than merely parsing the syntax tree.
10849However, the analyzer does not prioritize detection of such paths, so
10850false negatives are more likely relative to other warnings.
10851
d77de738
ML
10852@opindex Wanalyzer-stale-setjmp-buffer
10853@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10854@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10855This warning requires @option{-fanalyzer}, which enables it; use
10856@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10857
10858This diagnostic warns for paths through the code in which
10859@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10860to a @code{setjmp} call in a function that has returned.
10861
10862When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10863location, it records the stack frame. The stack frame becomes invalid
10864when the function containing the @code{setjmp} call returns. Attempting
10865to rewind to it via @code{longjmp} would reference a stack frame that
10866no longer exists, and likely lead to a crash (or worse).
10867
d77de738
ML
10868@opindex Wanalyzer-tainted-allocation-size
10869@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10870@item -Wno-analyzer-tainted-allocation-size
d77de738
ML
10871This warning requires both @option{-fanalyzer} and
10872@option{-fanalyzer-checker=taint} to enable it;
10873use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10874
10875This diagnostic warns for paths through the code in which a value
10876that could be under an attacker's control is used as the size
10877of an allocation without being sanitized, so that an attacker could
10878inject an excessively large allocation and potentially cause a denial
10879of service attack.
10880
10881See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10882
ce51e843
ML
10883@opindex Wanalyzer-tainted-assertion
10884@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10885@item -Wno-analyzer-tainted-assertion
ce51e843
ML
10886
10887This warning requires both @option{-fanalyzer} and
10888@option{-fanalyzer-checker=taint} to enable it;
10889use @option{-Wno-analyzer-tainted-assertion} to disable it.
10890
10891This diagnostic warns for paths through the code in which a value
10892that could be under an attacker's control is used as part of a
10893condition without being first sanitized, and that condition guards a
10894call to a function marked with attribute @code{noreturn}
10895(such as the function @code{__builtin_unreachable}). Such functions
10896typically indicate abnormal termination of the program, such as for
10897assertion failure handlers. For example:
10898
10899@smallexample
10900assert (some_tainted_value < SOME_LIMIT);
10901@end smallexample
10902
10903In such cases:
10904
10905@itemize
10906@item
10907when assertion-checking is enabled: an attacker could trigger
10908a denial of service by injecting an assertion failure
10909
10910@item
10911when assertion-checking is disabled, such as by defining @code{NDEBUG},
10912an attacker could inject data that subverts the process, since it
10913presumably violates a precondition that is being assumed by the code.
10914
10915@end itemize
10916
10917Note that when assertion-checking is disabled, the assertions are
10918typically removed by the preprocessor before the analyzer has a chance
10919to "see" them, so this diagnostic can only generate warnings on builds
10920in which assertion-checking is enabled.
10921
10922For the purpose of this warning, any function marked with attribute
10923@code{noreturn} is considered as a possible assertion failure
10924handler, including @code{__builtin_unreachable}. Note that these functions
10925are sometimes removed by the optimizer before the analyzer "sees" them.
10926Hence optimization should be disabled when attempting to trigger this
10927diagnostic.
10928
10929See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10930
10931The warning can also report problematic constructions such as
10932
10933@smallexample
10934switch (some_tainted_value) @{
10935case 0:
10936 /* [...etc; various valid cases omitted...] */
10937 break;
10938
10939default:
10940 __builtin_unreachable (); /* BUG: attacker can trigger this */
10941@}
10942@end smallexample
10943
10944despite the above not being an assertion failure, strictly speaking.
10945
d77de738
ML
10946@opindex Wanalyzer-tainted-array-index
10947@opindex Wno-analyzer-tainted-array-index
ddf6fe37 10948@item -Wno-analyzer-tainted-array-index
d77de738
ML
10949This warning requires both @option{-fanalyzer} and
10950@option{-fanalyzer-checker=taint} to enable it;
10951use @option{-Wno-analyzer-tainted-array-index} to disable it.
10952
10953This diagnostic warns for paths through the code in which a value
10954that could be under an attacker's control is used as the index
10955of an array access without being sanitized, so that an attacker
10956could inject an out-of-bounds access.
10957
10958See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10959
d77de738
ML
10960@opindex Wanalyzer-tainted-divisor
10961@opindex Wno-analyzer-tainted-divisor
ddf6fe37 10962@item -Wno-analyzer-tainted-divisor
d77de738
ML
10963This warning requires both @option{-fanalyzer} and
10964@option{-fanalyzer-checker=taint} to enable it;
10965use @option{-Wno-analyzer-tainted-divisor} to disable it.
10966
10967This diagnostic warns for paths through the code in which a value
10968that could be under an attacker's control is used as the divisor
10969in a division or modulus operation without being sanitized, so that
10970an attacker could inject a division-by-zero.
10971
10972See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10973
d77de738
ML
10974@opindex Wanalyzer-tainted-offset
10975@opindex Wno-analyzer-tainted-offset
ddf6fe37 10976@item -Wno-analyzer-tainted-offset
d77de738
ML
10977This warning requires both @option{-fanalyzer} and
10978@option{-fanalyzer-checker=taint} to enable it;
10979use @option{-Wno-analyzer-tainted-offset} to disable it.
10980
10981This diagnostic warns for paths through the code in which a value
10982that could be under an attacker's control is used as a pointer offset
10983without being sanitized, so that an attacker could inject an out-of-bounds
10984access.
10985
10986See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10987
d77de738
ML
10988@opindex Wanalyzer-tainted-size
10989@opindex Wno-analyzer-tainted-size
ddf6fe37 10990@item -Wno-analyzer-tainted-size
d77de738
ML
10991This warning requires both @option{-fanalyzer} and
10992@option{-fanalyzer-checker=taint} to enable it;
10993use @option{-Wno-analyzer-tainted-size} to disable it.
10994
10995This diagnostic warns for paths through the code in which a value
10996that could be under an attacker's control is used as the size of
10997an operation such as @code{memset} without being sanitized, so that an
10998attacker could inject an out-of-bounds access.
10999
11000See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11001
d77de738
ML
11002@opindex Wanalyzer-unsafe-call-within-signal-handler
11003@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 11004@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
11005This warning requires @option{-fanalyzer}, which enables it; use
11006@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11007
11008This diagnostic warns for paths through the code in which a
11009function known to be async-signal-unsafe (such as @code{fprintf}) is
11010called from a signal handler.
11011
11012See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11013
d77de738
ML
11014@opindex Wanalyzer-use-after-free
11015@opindex Wno-analyzer-use-after-free
ddf6fe37 11016@item -Wno-analyzer-use-after-free
d77de738
ML
11017This warning requires @option{-fanalyzer}, which enables it; use
11018@option{-Wno-analyzer-use-after-free} to disable it.
11019
11020This diagnostic warns for paths through the code in which a
11021pointer is used after a deallocator is called on it: either @code{free},
11022or a deallocator referenced by attribute @code{malloc}.
11023
11024See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11025
d77de738
ML
11026@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11027@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 11028@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
11029This warning requires @option{-fanalyzer}, which enables it; use
11030@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11031to disable it.
11032
11033This diagnostic warns for paths through the code in which a pointer
11034is dereferenced that points to a variable in a stale stack frame.
11035
d77de738
ML
11036@opindex Wanalyzer-va-arg-type-mismatch
11037@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 11038@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
11039This warning requires @option{-fanalyzer}, which enables it; use
11040@option{-Wno-analyzer-va-arg-type-mismatch}
11041to disable it.
11042
11043This diagnostic warns for interprocedural paths through the code for which
11044the analyzer detects an attempt to use @code{va_arg} to extract a value
11045passed to a variadic call, but uses a type that does not match that of
11046the expression passed to the call.
11047
11048See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11049
d77de738
ML
11050@opindex Wanalyzer-va-list-exhausted
11051@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 11052@item -Wno-analyzer-va-list-exhausted
d77de738
ML
11053This warning requires @option{-fanalyzer}, which enables it; use
11054@option{-Wno-analyzer-va-list-exhausted}
11055to disable it.
11056
11057This diagnostic warns for interprocedural paths through the code for which
11058the analyzer detects an attempt to use @code{va_arg} to access the next
11059value passed to a variadic call, but all of the values in the
11060@code{va_list} have already been consumed.
11061
11062See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11063
d77de738
ML
11064@opindex Wanalyzer-va-list-leak
11065@opindex Wno-analyzer-va-list-leak
ddf6fe37 11066@item -Wno-analyzer-va-list-leak
d77de738
ML
11067This warning requires @option{-fanalyzer}, which enables it; use
11068@option{-Wno-analyzer-va-list-leak}
11069to disable it.
11070
11071This diagnostic warns for interprocedural paths through the code for which
11072the analyzer detects that @code{va_start} or @code{va_copy} has been called
11073on a @code{va_list} without a corresponding call to @code{va_end}.
11074
d77de738
ML
11075@opindex Wanalyzer-va-list-use-after-va-end
11076@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 11077@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
11078This warning requires @option{-fanalyzer}, which enables it; use
11079@option{-Wno-analyzer-va-list-use-after-va-end}
11080to disable it.
11081
11082This diagnostic warns for interprocedural paths through the code for which
11083the analyzer detects an attempt to use a @code{va_list} after
11084@code{va_end} has been called on it.
11085@code{va_list}.
11086
d77de738
ML
11087@opindex Wanalyzer-write-to-const
11088@opindex Wno-analyzer-write-to-const
ddf6fe37 11089@item -Wno-analyzer-write-to-const
d77de738
ML
11090This warning requires @option{-fanalyzer}, which enables it; use
11091@option{-Wno-analyzer-write-to-const}
11092to disable it.
11093
11094This diagnostic warns for paths through the code in which the analyzer
11095detects an attempt to write through a pointer to a @code{const} object.
11096However, the analyzer does not prioritize detection of such paths, so
11097false negatives are more likely relative to other warnings.
11098
d77de738
ML
11099@opindex Wanalyzer-write-to-string-literal
11100@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 11101@item -Wno-analyzer-write-to-string-literal
d77de738
ML
11102This warning requires @option{-fanalyzer}, which enables it; use
11103@option{-Wno-analyzer-write-to-string-literal}
11104to disable it.
11105
11106This diagnostic warns for paths through the code in which the analyzer
11107detects an attempt to write through a pointer to a string literal.
11108However, the analyzer does not prioritize detection of such paths, so
11109false negatives are more likely relative to other warnings.
11110
d77de738
ML
11111@opindex Wanalyzer-use-of-uninitialized-value
11112@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 11113@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
11114This warning requires @option{-fanalyzer}, which enables it; use
11115@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11116
11117This diagnostic warns for paths through the code in which an uninitialized
11118value is used.
11119
11120See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11121
11122@end table
11123
11124The analyzer has hardcoded knowledge about the behavior of the following
11125memory-management functions:
11126
11127@itemize @bullet
11128@item @code{alloca}
11129@item The built-in functions @code{__builtin_alloc},
11130@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11131@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11132@code{__builtin_memcpy_chk}, @code{__builtin_memset},
11133@code{__builtin_memset_chk}, @code{__builtin_realloc},
11134@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11135@item @code{calloc}
11136@item @code{free}
11137@item @code{malloc}
11138@item @code{memset}
11139@item @code{operator delete}
11140@item @code{operator delete []}
11141@item @code{operator new}
11142@item @code{operator new []}
11143@item @code{realloc}
11144@item @code{strdup}
11145@item @code{strndup}
11146@end itemize
11147
4ace81b6 11148@noindent
d77de738
ML
11149of the following functions for working with file descriptors:
11150
11151@itemize @bullet
11152@item @code{open}
11153@item @code{close}
11154@item @code{creat}
11155@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 11156@item @code{isatty}
d77de738
ML
11157@item @code{pipe}, and @code{pipe2}
11158@item @code{read}
11159@item @code{write}
86a90006 11160@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
11161@end itemize
11162
4ace81b6 11163@noindent
d77de738
ML
11164of the following functions for working with @code{<stdio.h>} streams:
11165@itemize @bullet
11166@item The built-in functions @code{__builtin_fprintf},
11167@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11168@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11169@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11170@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11171@code{__builtin_printf_unlocked}, @code{__builtin_putc},
11172@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11173@code{__builtin_putc_unlocked}, @code{__builtin_puts},
11174@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
11175@code{__builtin_vprintf}
11176@item @code{fopen}
11177@item @code{fclose}
78a17f44 11178@item @code{ferror}
d77de738
ML
11179@item @code{fgets}
11180@item @code{fgets_unlocked}
78a17f44 11181@item @code{fileno}
d77de738 11182@item @code{fread}
78a17f44 11183@item @code{getc}
d77de738
ML
11184@item @code{getchar}
11185@item @code{fprintf}
11186@item @code{printf}
11187@item @code{fwrite}
11188@end itemize
11189
4ace81b6 11190@noindent
d77de738
ML
11191and of the following functions:
11192
11193@itemize @bullet
11194@item The built-in functions @code{__builtin_expect},
11195@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11196@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11197@code{__builtin_strlen}, @code{__builtin_va_copy}, and
11198@code{__builtin_va_start}
11199@item The GNU extensions @code{error} and @code{error_at_line}
11200@item @code{getpass}
11201@item @code{longjmp}
11202@item @code{putenv}
11203@item @code{setjmp}
11204@item @code{siglongjmp}
11205@item @code{signal}
11206@item @code{sigsetjmp}
bbdc0e0d 11207@item @code{strcat}
d77de738
ML
11208@item @code{strchr}
11209@item @code{strlen}
11210@end itemize
11211
11212In addition, various functions with an @code{__analyzer_} prefix have
11213special meaning to the analyzer, described in the GCC Internals manual.
11214
11215Pertinent parameters for controlling the exploration are:
4ace81b6
SL
11216@itemize @bullet
11217@item @option{--param analyzer-bb-explosion-factor=@var{value}}
11218@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11219@item @option{--param analyzer-max-recursion-depth=@var{value}}
11220@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11221@end itemize
d77de738
ML
11222
11223The following options control the analyzer.
11224
11225@table @gcctabopt
11226
d77de738
ML
11227@opindex fanalyzer-call-summaries
11228@opindex fno-analyzer-call-summaries
ddf6fe37 11229@item -fanalyzer-call-summaries
d77de738
ML
11230Simplify interprocedural analysis by computing the effect of certain calls,
11231rather than exploring all paths through the function from callsite to each
11232possible return.
11233
11234If enabled, call summaries are only used for functions with more than one
11235call site, and that are sufficiently complicated (as per
11236@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11237
d77de738 11238@opindex fanalyzer-checker
ddf6fe37 11239@item -fanalyzer-checker=@var{name}
d77de738
ML
11240Restrict the analyzer to run just the named checker, and enable it.
11241
11242Some checkers are disabled by default (even with @option{-fanalyzer}),
11243such as the @code{taint} checker that implements
11244@option{-Wanalyzer-tainted-array-index}, and this option is required
11245to enable them.
11246
11247@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
11248following warnings from @option{-fanalyzer}:
11249
43b72ede
AA
11250@gccoptlist{
11251-Wanalyzer-deref-before-check
11252-Wanalyzer-double-fclose
11253-Wanalyzer-double-free
11254-Wanalyzer-exposure-through-output-file
11255-Wanalyzer-fd-access-mode-mismatch
11256-Wanalyzer-fd-double-close
11257-Wanalyzer-fd-leak
11258-Wanalyzer-fd-use-after-close
11259-Wanalyzer-fd-use-without-check
11260-Wanalyzer-file-leak
11261-Wanalyzer-free-of-non-heap
11262-Wanalyzer-malloc-leak
11263-Wanalyzer-mismatching-deallocation
11264-Wanalyzer-null-argument
11265-Wanalyzer-null-dereference
11266-Wanalyzer-possible-null-argument
11267-Wanalyzer-possible-null-dereference
11268-Wanalyzer-unsafe-call-within-signal-handler
11269-Wanalyzer-use-after-free
11270-Wanalyzer-va-list-leak
11271-Wanalyzer-va-list-use-after-va-end
d77de738
ML
11272}
11273
0e466e97
DM
11274@opindex fanalyzer-debug-text-art
11275@opindex fno-analyzer-debug-text-art
11276@item -fanalyzer-debug-text-art-headings
11277This option is intended for analyzer developers. If enabled,
11278the analyzer will add extra annotations to any diagrams it generates.
11279
d77de738
ML
11280@opindex fanalyzer-feasibility
11281@opindex fno-analyzer-feasibility
ddf6fe37 11282@item -fno-analyzer-feasibility
d77de738
ML
11283This option is intended for analyzer developers.
11284
11285By default the analyzer verifies that there is a feasible control flow path
11286for each diagnostic it emits: that the conditions that hold are not mutually
11287exclusive. Diagnostics for which no feasible path can be found are rejected.
11288This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11289debugging issues in this code.
11290
d77de738
ML
11291@opindex fanalyzer-fine-grained
11292@opindex fno-analyzer-fine-grained
ddf6fe37 11293@item -fanalyzer-fine-grained
d77de738
ML
11294This option is intended for analyzer developers.
11295
11296Internally the analyzer builds an ``exploded graph'' that combines
11297control flow graphs with data flow information.
11298
11299By default, an edge in this graph can contain the effects of a run
11300of multiple statements within a basic block. With
11301@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11302
d77de738
ML
11303@opindex fanalyzer-show-duplicate-count
11304@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11305@item -fanalyzer-show-duplicate-count
d77de738
ML
11306This option is intended for analyzer developers: if multiple diagnostics
11307have been detected as being duplicates of each other, it emits a note when
11308reporting the best diagnostic, giving the number of additional diagnostics
11309that were suppressed by the deduplication logic.
11310
ce8cdf5b 11311@opindex fanalyzer-show-events-in-system-headers
11312@opindex fno-analyzer-show-events-in-system-headers
11313@item -fanalyzer-show-events-in-system-headers
11314By default the analyzer emits simplified diagnostics paths by hiding
11315events fully located within a system header.
11316With @option{-fanalyzer-show-events-in-system-headers} such
11317events are no longer suppressed.
11318
d77de738
ML
11319@opindex fanalyzer-state-merge
11320@opindex fno-analyzer-state-merge
ddf6fe37 11321@item -fno-analyzer-state-merge
d77de738
ML
11322This option is intended for analyzer developers.
11323
11324By default the analyzer attempts to simplify analysis by merging
11325sufficiently similar states at each program point as it builds its
11326``exploded graph''. With @option{-fno-analyzer-state-merge} this
11327merging can be suppressed, for debugging state-handling issues.
11328
d77de738
ML
11329@opindex fanalyzer-state-purge
11330@opindex fno-analyzer-state-purge
ddf6fe37 11331@item -fno-analyzer-state-purge
d77de738
ML
11332This option is intended for analyzer developers.
11333
11334By default the analyzer attempts to simplify analysis by purging
11335aspects of state at a program point that appear to no longer be relevant
11336e.g. the values of locals that aren't accessed later in the function
11337and which aren't relevant to leak analysis.
11338
11339With @option{-fno-analyzer-state-purge} this purging of state can
11340be suppressed, for debugging state-handling issues.
11341
8f636915
DM
11342@opindex fanalyzer-suppress-followups
11343@opindex fno-analyzer-suppress-followups
f33d7a88 11344@item -fno-analyzer-suppress-followups
8f636915
DM
11345This option is intended for analyzer developers.
11346
11347By default the analyzer will stop exploring an execution path after
11348encountering certain diagnostics, in order to avoid potentially issuing a
11349cascade of follow-up diagnostics.
11350
11351The diagnostics that terminate analysis along a path are:
11352
11353@itemize
11354@item @option{-Wanalyzer-null-argument}
11355@item @option{-Wanalyzer-null-dereference}
11356@item @option{-Wanalyzer-use-after-free}
11357@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11358@item @option{-Wanalyzer-use-of-uninitialized-value}
11359@end itemize
11360
11361With @option{-fno-analyzer-suppress-followups} the analyzer will
11362continue to explore such paths even after such diagnostics, which may
11363be helpful for debugging issues in the analyzer, or for microbenchmarks
11364for detecting undefined behavior.
11365
d77de738
ML
11366@opindex fanalyzer-transitivity
11367@opindex fno-analyzer-transitivity
ddf6fe37 11368@item -fanalyzer-transitivity
d77de738
ML
11369This option enables transitivity of constraints within the analyzer.
11370
d77de738
ML
11371@opindex fanalyzer-undo-inlining
11372@opindex fno-analyzer-undo-inlining
ddf6fe37 11373@item -fno-analyzer-undo-inlining
d77de738
ML
11374This option is intended for analyzer developers.
11375
11376@option{-fanalyzer} runs relatively late compared to other code analysis
11377tools, and some optimizations have already been applied to the code. In
11378particular function inlining may have occurred, leading to the
11379interprocedural execution paths emitted by the analyzer containing
11380function frames that don't correspond to those in the original source
11381code.
11382
11383By default the analyzer attempts to reconstruct the original function
11384frames, and to emit events showing the inlined calls.
11385
11386With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11387the original frame information can be be disabled, which may be of help
11388when debugging issues in the analyzer.
11389
11390@item -fanalyzer-verbose-edges
11391This option is intended for analyzer developers. It enables more
11392verbose, lower-level detail in the descriptions of control flow
11393within diagnostic paths.
11394
11395@item -fanalyzer-verbose-state-changes
11396This option is intended for analyzer developers. It enables more
11397verbose, lower-level detail in the descriptions of events relating
11398to state machines within diagnostic paths.
11399
11400@item -fanalyzer-verbosity=@var{level}
11401This option controls the complexity of the control flow paths that are
11402emitted for analyzer diagnostics.
11403
11404The @var{level} can be one of:
11405
11406@table @samp
11407@item 0
11408At this level, interprocedural call and return events are displayed,
11409along with the most pertinent state-change events relating to
11410a diagnostic. For example, for a double-@code{free} diagnostic,
11411both calls to @code{free} will be shown.
11412
11413@item 1
11414As per the previous level, but also show events for the entry
11415to each function.
11416
11417@item 2
11418As per the previous level, but also show events relating to
11419control flow that are significant to triggering the issue
11420(e.g. ``true path taken'' at a conditional).
11421
11422This level is the default.
11423
11424@item 3
11425As per the previous level, but show all control flow events, not
11426just significant ones.
11427
11428@item 4
11429This level is intended for analyzer developers; it adds various
11430other events intended for debugging the analyzer.
11431
11432@end table
11433
d77de738 11434@opindex fdump-analyzer
ddf6fe37 11435@item -fdump-analyzer
d77de738
ML
11436Dump internal details about what the analyzer is doing to
11437@file{@var{file}.analyzer.txt}.
4ace81b6 11438@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11439
d77de738 11440@opindex fdump-analyzer-stderr
ddf6fe37 11441@item -fdump-analyzer-stderr
d77de738
ML
11442Dump internal details about what the analyzer is doing to stderr.
11443This option overrides @option{-fdump-analyzer}.
11444
d77de738 11445@opindex fdump-analyzer-callgraph
ddf6fe37 11446@item -fdump-analyzer-callgraph
d77de738
ML
11447Dump a representation of the call graph suitable for viewing with
11448GraphViz to @file{@var{file}.callgraph.dot}.
11449
d77de738 11450@opindex fdump-analyzer-exploded-graph
ddf6fe37 11451@item -fdump-analyzer-exploded-graph
d77de738
ML
11452Dump a representation of the ``exploded graph'' suitable for viewing with
11453GraphViz to @file{@var{file}.eg.dot}.
11454Nodes are color-coded based on state-machine states to emphasize
11455state changes.
11456
d77de738 11457@opindex dump-analyzer-exploded-nodes
ddf6fe37 11458@item -fdump-analyzer-exploded-nodes
d77de738
ML
11459Emit diagnostics showing where nodes in the ``exploded graph'' are
11460in relation to the program source.
11461
d77de738 11462@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11463@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11464Dump a textual representation of the ``exploded graph'' to
11465@file{@var{file}.eg.txt}.
11466
d77de738 11467@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11468@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11469Dump a textual representation of the ``exploded graph'' to
11470one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11471This is typically a large number of dump files.
11472
d77de738 11473@opindex fdump-analyzer-exploded-paths
ddf6fe37 11474@item -fdump-analyzer-exploded-paths
d77de738
ML
11475Dump a textual representation of the ``exploded path'' for each
11476diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11477
d77de738 11478@opindex dump-analyzer-feasibility
ddf6fe37 11479@item -fdump-analyzer-feasibility
d77de738
ML
11480Dump internal details about the analyzer's search for feasible paths.
11481The details are written in a form suitable for viewing with GraphViz
11482to filenames of the form @file{@var{file}.*.fg.dot},
11483@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11484
d77de738 11485@opindex fdump-analyzer-json
ddf6fe37 11486@item -fdump-analyzer-json
d77de738
ML
11487Dump a compressed JSON representation of analyzer internals to
11488@file{@var{file}.analyzer.json.gz}. The precise format is subject
11489to change.
11490
d77de738 11491@opindex fdump-analyzer-state-purge
ddf6fe37 11492@item -fdump-analyzer-state-purge
d77de738
ML
11493As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11494``supergraph'' suitable for viewing with GraphViz, but annotate the
11495graph with information on what state will be purged at each node.
11496The graph is written to @file{@var{file}.state-purge.dot}.
11497
d77de738 11498@opindex fdump-analyzer-supergraph
ddf6fe37 11499@item -fdump-analyzer-supergraph
d77de738
ML
11500Dump representations of the ``supergraph'' suitable for viewing with
11501GraphViz to @file{@var{file}.supergraph.dot} and to
11502@file{@var{file}.supergraph-eg.dot}. These show all of the
11503control flow graphs in the program, with interprocedural edges for
11504calls and returns. The second dump contains annotations showing nodes
11505in the ``exploded graph'' and diagnostics associated with them.
11506
d77de738 11507@opindex fdump-analyzer-untracked
ddf6fe37 11508@item -fdump-analyzer-untracked
d77de738
ML
11509Emit custom warnings with internal details intended for analyzer developers.
11510
11511@end table
11512
11513@node Debugging Options
11514@section Options for Debugging Your Program
11515@cindex options, debugging
11516@cindex debugging information options
11517
11518To tell GCC to emit extra information for use by a debugger, in almost
11519all cases you need only to add @option{-g} to your other options. Some debug
11520formats can co-exist (like DWARF with CTF) when each of them is enabled
11521explicitly by adding the respective command line option to your other options.
11522
11523GCC allows you to use @option{-g} with
11524@option{-O}. The shortcuts taken by optimized code may occasionally
11525be surprising: some variables you declared may not exist
11526at all; flow of control may briefly move where you did not expect it;
11527some statements may not be executed because they compute constant
11528results or their values are already at hand; some statements may
11529execute in different places because they have been moved out of loops.
11530Nevertheless it is possible to debug optimized output. This makes
11531it reasonable to use the optimizer for programs that might have bugs.
11532
11533If you are not using some other optimization option, consider
11534using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11535With no @option{-O} option at all, some compiler passes that collect
11536information useful for debugging do not run at all, so that
11537@option{-Og} may result in a better debugging experience.
11538
11539@table @gcctabopt
d77de738 11540@opindex g
ddf6fe37 11541@item -g
d77de738
ML
11542Produce debugging information in the operating system's native format
11543(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11544information.
11545
11546On most systems that use stabs format, @option{-g} enables use of extra
11547debugging information that only GDB can use; this extra information
11548makes debugging work better in GDB but probably makes other debuggers
11549crash or refuse to read the program. If you want to control for certain whether
11550to generate the extra information, use @option{-gvms} (see below).
11551
d77de738 11552@opindex ggdb
ddf6fe37 11553@item -ggdb
d77de738
ML
11554Produce debugging information for use by GDB@. This means to use the
11555most expressive format available (DWARF, stabs, or the native format
11556if neither of those are supported), including GDB extensions if at all
11557possible.
11558
ddf6fe37 11559@opindex gdwarf
d77de738
ML
11560@item -gdwarf
11561@itemx -gdwarf-@var{version}
d77de738
ML
11562Produce debugging information in DWARF format (if that is supported).
11563The value of @var{version} may be either 2, 3, 4 or 5; the default
11564version for most targets is 5 (with the exception of VxWorks, TPF and
a335cf24 11565Darwin / macOS, which default to version 2, and AIX, which defaults
d77de738
ML
11566to version 4).
11567
11568Note that with DWARF Version 2, some ports require and always
11569use some non-conflicting DWARF 3 extensions in the unwind tables.
11570
11571Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11572for maximum benefit. Version 5 requires GDB 8.0 or higher.
11573
11574GCC no longer supports DWARF Version 1, which is substantially
11575different than Version 2 and later. For historical reasons, some
11576other DWARF-related options such as
11577@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11578in their names, but apply to all currently-supported versions of DWARF.
11579
d77de738 11580@opindex gbtf
ddf6fe37 11581@item -gbtf
d77de738
ML
11582Request BTF debug information. BTF is the default debugging format for the
11583eBPF target. On other targets, like x86, BTF debug information can be
11584generated along with DWARF debug information when both of the debug formats are
11585enabled explicitly via their respective command line options.
11586
ddf6fe37 11587@opindex gctf
d77de738
ML
11588@item -gctf
11589@itemx -gctf@var{level}
d77de738
ML
11590Request CTF debug information and use level to specify how much CTF debug
11591information should be produced. If @option{-gctf} is specified
11592without a value for level, the default level of CTF debug information is 2.
11593
11594CTF debug information can be generated along with DWARF debug information when
11595both of the debug formats are enabled explicitly via their respective command
11596line options.
11597
11598Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11599negates @option{-gctf}.
11600
11601Level 1 produces CTF information for tracebacks only. This includes callsite
11602information, but does not include type information.
11603
11604Level 2 produces type information for entities (functions, data objects etc.)
11605at file-scope or global-scope only.
11606
d77de738 11607@opindex gvms
ddf6fe37 11608@item -gvms
d77de738
ML
11609Produce debugging information in Alpha/VMS debug format (if that is
11610supported). This is the format used by DEBUG on Alpha/VMS systems.
11611
2f7e7bfa
MH
11612@item -gcodeview
11613@opindex gcodeview
11614Produce debugging information in CodeView debug format (if that is
11615supported). This is the format used by Microsoft Visual C++ on
11616Windows.
11617
d77de738
ML
11618@item -g@var{level}
11619@itemx -ggdb@var{level}
11620@itemx -gvms@var{level}
11621Request debugging information and also use @var{level} to specify how
11622much information. The default level is 2.
11623
11624Level 0 produces no debug information at all. Thus, @option{-g0} negates
11625@option{-g}.
11626
11627Level 1 produces minimal information, enough for making backtraces in
11628parts of the program that you don't plan to debug. This includes
11629descriptions of functions and external variables, and line number
11630tables, but no information about local variables.
11631
11632Level 3 includes extra information, such as all the macro definitions
11633present in the program. Some debuggers support macro expansion when
11634you use @option{-g3}.
11635
11636If you use multiple @option{-g} options, with or without level numbers,
11637the last such option is the one that is effective.
11638
11639@option{-gdwarf} does not accept a concatenated debug level, to avoid
11640confusion with @option{-gdwarf-@var{level}}.
11641Instead use an additional @option{-g@var{level}} option to change the
11642debug level for DWARF.
11643
d77de738
ML
11644@opindex feliminate-unused-debug-symbols
11645@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11646@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11647By default, no debug information is produced for symbols that are not actually
11648used. Use this option if you want debug information for all symbols.
11649
d77de738 11650@opindex femit-class-debug-always
ddf6fe37 11651@item -femit-class-debug-always
d77de738
ML
11652Instead of emitting debugging information for a C++ class in only one
11653object file, emit it in all object files using the class. This option
11654should be used only with debuggers that are unable to handle the way GCC
11655normally emits debugging information for classes because using this
11656option increases the size of debugging information by as much as a
11657factor of two.
11658
d77de738
ML
11659@opindex fmerge-debug-strings
11660@opindex fno-merge-debug-strings
ddf6fe37 11661@item -fno-merge-debug-strings
d77de738
ML
11662Direct the linker to not merge together strings in the debugging
11663information that are identical in different object files. Merging is
11664not supported by all assemblers or linkers. Merging decreases the size
11665of the debug information in the output file at the cost of increasing
11666link processing time. Merging is enabled by default.
11667
d77de738 11668@opindex fdebug-prefix-map
ddf6fe37 11669@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11670When compiling files residing in directory @file{@var{old}}, record
11671debugging information describing them as if the files resided in
11672directory @file{@var{new}} instead. This can be used to replace a
11673build-time path with an install-time path in the debug info. It can
11674also be used to change an absolute path to a relative path by using
11675@file{.} for @var{new}. This can give more reproducible builds, which
11676are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11677where to find the source files. See also @option{-ffile-prefix-map}
11678and @option{-fcanon-prefix-map}.
d77de738 11679
d77de738 11680@opindex fvar-tracking
ddf6fe37 11681@item -fvar-tracking
d77de738
ML
11682Run variable tracking pass. It computes where variables are stored at each
11683position in code. Better debugging information is then generated
11684(if the debugging information format supports this information).
11685
11686It is enabled by default when compiling with optimization (@option{-Os},
11687@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11688the debug info format supports it.
11689
d77de738
ML
11690@opindex fvar-tracking-assignments
11691@opindex fno-var-tracking-assignments
ddf6fe37 11692@item -fvar-tracking-assignments
d77de738
ML
11693Annotate assignments to user variables early in the compilation and
11694attempt to carry the annotations over throughout the compilation all the
11695way to the end, in an attempt to improve debug information while
11696optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11697
11698It can be enabled even if var-tracking is disabled, in which case
11699annotations are created and maintained, but discarded at the end.
11700By default, this flag is enabled together with @option{-fvar-tracking},
11701except when selective scheduling is enabled.
11702
d77de738 11703@opindex gsplit-dwarf
ddf6fe37 11704@item -gsplit-dwarf
d77de738
ML
11705If DWARF debugging information is enabled, separate as much debugging
11706information as possible into a separate output file with the extension
11707@file{.dwo}. This option allows the build system to avoid linking files with
11708debug information. To be useful, this option requires a debugger capable of
11709reading @file{.dwo} files.
11710
d77de738
ML
11711@opindex gdwarf32
11712@opindex gdwarf64
ddf6fe37
AA
11713@item -gdwarf32
11714@itemx -gdwarf64
d77de738
ML
11715If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11716the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11717DWARF format. The default is target specific, on most targets it is
11718@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11719can't support more than 2GiB of debug information in any of the DWARF
11720debug information sections. The 64-bit DWARF format allows larger debug
11721information and might not be well supported by all consumers yet.
11722
d77de738 11723@opindex gdescribe-dies
ddf6fe37 11724@item -gdescribe-dies
d77de738
ML
11725Add description attributes to some DWARF DIEs that have no name attribute,
11726such as artificial variables, external references and call site
11727parameter DIEs.
11728
d77de738 11729@opindex gpubnames
ddf6fe37 11730@item -gpubnames
d77de738
ML
11731Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11732
d77de738 11733@opindex ggnu-pubnames
ddf6fe37 11734@item -ggnu-pubnames
d77de738
ML
11735Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11736suitable for conversion into a GDB@ index. This option is only useful
11737with a linker that can produce GDB@ index version 7.
11738
d77de738
ML
11739@opindex fdebug-types-section
11740@opindex fno-debug-types-section
ddf6fe37 11741@item -fdebug-types-section
d77de738
ML
11742When using DWARF Version 4 or higher, type DIEs can be put into
11743their own @code{.debug_types} section instead of making them part of the
11744@code{.debug_info} section. It is more efficient to put them in a separate
11745comdat section since the linker can then remove duplicates.
11746But not all DWARF consumers support @code{.debug_types} sections yet
11747and on some objects @code{.debug_types} produces larger instead of smaller
11748debugging information.
11749
d77de738
ML
11750@opindex grecord-gcc-switches
11751@opindex gno-record-gcc-switches
ddf6fe37
AA
11752@item -grecord-gcc-switches
11753@itemx -gno-record-gcc-switches
d77de738
ML
11754This switch causes the command-line options used to invoke the
11755compiler that may affect code generation to be appended to the
11756DW_AT_producer attribute in DWARF debugging information. The options
11757are concatenated with spaces separating them from each other and from
11758the compiler version.
11759It is enabled by default.
11760See also @option{-frecord-gcc-switches} for another
11761way of storing compiler options into the object file.
11762
d77de738 11763@opindex gstrict-dwarf
ddf6fe37 11764@item -gstrict-dwarf
d77de738
ML
11765Disallow using extensions of later DWARF standard version than selected
11766with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11767DWARF extensions from later standard versions is allowed.
11768
d77de738 11769@opindex gno-strict-dwarf
ddf6fe37 11770@item -gno-strict-dwarf
d77de738
ML
11771Allow using extensions of later DWARF standard version than selected with
11772@option{-gdwarf-@var{version}}.
11773
d77de738 11774@opindex gas-loc-support
ddf6fe37 11775@item -gas-loc-support
d77de738
ML
11776Inform the compiler that the assembler supports @code{.loc} directives.
11777It may then use them for the assembler to generate DWARF2+ line number
11778tables.
11779
11780This is generally desirable, because assembler-generated line-number
11781tables are a lot more compact than those the compiler can generate
11782itself.
11783
11784This option will be enabled by default if, at GCC configure time, the
11785assembler was found to support such directives.
11786
d77de738 11787@opindex gno-as-loc-support
ddf6fe37 11788@item -gno-as-loc-support
d77de738
ML
11789Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11790line number tables are to be generated.
11791
d77de738 11792@opindex gas-locview-support
ddf6fe37 11793@item -gas-locview-support
d77de738
ML
11794Inform the compiler that the assembler supports @code{view} assignment
11795and reset assertion checking in @code{.loc} directives.
11796
11797This option will be enabled by default if, at GCC configure time, the
11798assembler was found to support them.
11799
11800@item -gno-as-locview-support
11801Force GCC to assign view numbers internally, if
11802@option{-gvariable-location-views} are explicitly requested.
11803
d77de738
ML
11804@opindex gcolumn-info
11805@opindex gno-column-info
ddf6fe37
AA
11806@item -gcolumn-info
11807@itemx -gno-column-info
d77de738
ML
11808Emit location column information into DWARF debugging information, rather
11809than just file and line.
11810This option is enabled by default.
11811
d77de738
ML
11812@opindex gstatement-frontiers
11813@opindex gno-statement-frontiers
ddf6fe37
AA
11814@item -gstatement-frontiers
11815@itemx -gno-statement-frontiers
d77de738
ML
11816This option causes GCC to create markers in the internal representation
11817at the beginning of statements, and to keep them roughly in place
11818throughout compilation, using them to guide the output of @code{is_stmt}
11819markers in the line number table. This is enabled by default when
11820compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11821@dots{}), and outputting DWARF 2 debug information at the normal level.
11822
d77de738
ML
11823@opindex gvariable-location-views
11824@opindex gvariable-location-views=incompat5
11825@opindex gno-variable-location-views
ddf6fe37
AA
11826@item -gvariable-location-views
11827@itemx -gvariable-location-views=incompat5
11828@itemx -gno-variable-location-views
d77de738
ML
11829Augment variable location lists with progressive view numbers implied
11830from the line number table. This enables debug information consumers to
11831inspect state at certain points of the program, even if no instructions
11832associated with the corresponding source locations are present at that
11833point. If the assembler lacks support for view numbers in line number
11834tables, this will cause the compiler to emit the line number table,
11835which generally makes them somewhat less compact. The augmented line
11836number tables and location lists are fully backward-compatible, so they
11837can be consumed by debug information consumers that are not aware of
11838these augmentations, but they won't derive any benefit from them either.
11839
11840This is enabled by default when outputting DWARF 2 debug information at
11841the normal level, as long as there is assembler support,
11842@option{-fvar-tracking-assignments} is enabled and
11843@option{-gstrict-dwarf} is not. When assembler support is not
11844available, this may still be enabled, but it will force GCC to output
11845internal line number tables, and if
11846@option{-ginternal-reset-location-views} is not enabled, that will most
11847certainly lead to silently mismatching location views.
11848
11849There is a proposed representation for view numbers that is not backward
11850compatible with the location list format introduced in DWARF 5, that can
11851be enabled with @option{-gvariable-location-views=incompat5}. This
11852option may be removed in the future, is only provided as a reference
11853implementation of the proposed representation. Debug information
11854consumers are not expected to support this extended format, and they
11855would be rendered unable to decode location lists using it.
11856
d77de738
ML
11857@opindex ginternal-reset-location-views
11858@opindex gno-internal-reset-location-views
ddf6fe37
AA
11859@item -ginternal-reset-location-views
11860@itemx -gno-internal-reset-location-views
d77de738
ML
11861Attempt to determine location views that can be omitted from location
11862view lists. This requires the compiler to have very accurate insn
11863length estimates, which isn't always the case, and it may cause
11864incorrect view lists to be generated silently when using an assembler
11865that does not support location view lists. The GNU assembler will flag
11866any such error as a @code{view number mismatch}. This is only enabled
11867on ports that define a reliable estimation function.
11868
d77de738
ML
11869@opindex ginline-points
11870@opindex gno-inline-points
ddf6fe37
AA
11871@item -ginline-points
11872@itemx -gno-inline-points
d77de738
ML
11873Generate extended debug information for inlined functions. Location
11874view tracking markers are inserted at inlined entry points, so that
11875address and view numbers can be computed and output in debug
11876information. This can be enabled independently of location views, in
11877which case the view numbers won't be output, but it can only be enabled
11878along with statement frontiers, and it is only enabled by default if
11879location views are enabled.
11880
d77de738 11881@opindex gz
ddf6fe37 11882@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11883Produce compressed debug sections in DWARF format, if that is supported.
11884If @var{type} is not given, the default type depends on the capabilities
11885of the assembler and linker used. @var{type} may be one of
11886@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11887compression in ELF gABI format). If the linker doesn't support writing
11888compressed debug sections, the option is rejected. Otherwise, if the
11889assembler does not support them, @option{-gz} is silently ignored when
11890producing object files.
11891
d77de738 11892@opindex femit-struct-debug-baseonly
ddf6fe37 11893@item -femit-struct-debug-baseonly
d77de738
ML
11894Emit debug information for struct-like types
11895only when the base name of the compilation source file
11896matches the base name of file in which the struct is defined.
11897
11898This option substantially reduces the size of debugging information,
11899but at significant potential loss in type information to the debugger.
11900See @option{-femit-struct-debug-reduced} for a less aggressive option.
11901See @option{-femit-struct-debug-detailed} for more detailed control.
11902
11903This option works only with DWARF debug output.
11904
d77de738 11905@opindex femit-struct-debug-reduced
ddf6fe37 11906@item -femit-struct-debug-reduced
d77de738
ML
11907Emit debug information for struct-like types
11908only when the base name of the compilation source file
11909matches the base name of file in which the type is defined,
11910unless the struct is a template or defined in a system header.
11911
11912This option significantly reduces the size of debugging information,
11913with some potential loss in type information to the debugger.
11914See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11915See @option{-femit-struct-debug-detailed} for more detailed control.
11916
11917This option works only with DWARF debug output.
11918
d77de738 11919@opindex femit-struct-debug-detailed
ddf6fe37 11920@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11921Specify the struct-like types
11922for which the compiler generates debug information.
11923The intent is to reduce duplicate struct debug information
11924between different object files within the same program.
11925
11926This option is a detailed version of
11927@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11928which serves for most needs.
11929
11930A specification has the syntax@*
11931[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11932
11933The optional first word limits the specification to
11934structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11935A struct type is used directly when it is the type of a variable, member.
11936Indirect uses arise through pointers to structs.
11937That is, when use of an incomplete struct is valid, the use is indirect.
11938An example is
11939@samp{struct one direct; struct two * indirect;}.
11940
11941The optional second word limits the specification to
11942ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11943Generic structs are a bit complicated to explain.
11944For C++, these are non-explicit specializations of template classes,
11945or non-template classes within the above.
11946Other programming languages have generics,
11947but @option{-femit-struct-debug-detailed} does not yet implement them.
11948
11949The third word specifies the source files for those
11950structs for which the compiler should emit debug information.
11951The values @samp{none} and @samp{any} have the normal meaning.
11952The value @samp{base} means that
11953the base of name of the file in which the type declaration appears
11954must match the base of the name of the main compilation file.
11955In practice, this means that when compiling @file{foo.c}, debug information
11956is generated for types declared in that file and @file{foo.h},
11957but not other header files.
11958The value @samp{sys} means those types satisfying @samp{base}
11959or declared in system or compiler headers.
11960
11961You may need to experiment to determine the best settings for your application.
11962
11963The default is @option{-femit-struct-debug-detailed=all}.
11964
11965This option works only with DWARF debug output.
11966
d77de738
ML
11967@opindex fdwarf2-cfi-asm
11968@opindex fno-dwarf2-cfi-asm
ddf6fe37 11969@item -fno-dwarf2-cfi-asm
d77de738
ML
11970Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11971instead of using GAS @code{.cfi_*} directives.
11972
d77de738
ML
11973@opindex feliminate-unused-debug-types
11974@opindex fno-eliminate-unused-debug-types
ddf6fe37 11975@item -fno-eliminate-unused-debug-types
d77de738
ML
11976Normally, when producing DWARF output, GCC avoids producing debug symbol
11977output for types that are nowhere used in the source file being compiled.
11978Sometimes it is useful to have GCC emit debugging
11979information for all types declared in a compilation
11980unit, regardless of whether or not they are actually used
11981in that compilation unit, for example
11982if, in the debugger, you want to cast a value to a type that is
11983not actually used in your program (but is declared). More often,
11984however, this results in a significant amount of wasted space.
11985@end table
11986
11987@node Optimize Options
11988@section Options That Control Optimization
11989@cindex optimize options
11990@cindex options, optimization
11991
11992These options control various sorts of optimizations.
11993
11994Without any optimization option, the compiler's goal is to reduce the
11995cost of compilation and to make debugging produce the expected
11996results. Statements are independent: if you stop the program with a
11997breakpoint between statements, you can then assign a new value to any
11998variable or change the program counter to any other statement in the
11999function and get exactly the results you expect from the source
12000code.
12001
12002Turning on optimization flags makes the compiler attempt to improve
12003the performance and/or code size at the expense of compilation time
12004and possibly the ability to debug the program.
12005
12006The compiler performs optimization based on the knowledge it has of the
12007program. Compiling multiple files at once to a single output file mode allows
12008the compiler to use information gained from all of the files when compiling
12009each of them.
12010
12011Not all optimizations are controlled directly by a flag. Only
12012optimizations that have a flag are listed in this section.
12013
12014Most optimizations are completely disabled at @option{-O0} or if an
12015@option{-O} level is not set on the command line, even if individual
12016optimization flags are specified. Similarly, @option{-Og} suppresses
12017many optimization passes.
12018
12019Depending on the target and how GCC was configured, a slightly different
12020set of optimizations may be enabled at each @option{-O} level than
12021those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12022to find out the exact set of optimizations that are enabled at each level.
12023@xref{Overall Options}, for examples.
12024
12025@table @gcctabopt
d77de738
ML
12026@opindex O
12027@opindex O1
ddf6fe37
AA
12028@item -O
12029@itemx -O1
d77de738
ML
12030Optimize. Optimizing compilation takes somewhat more time, and a lot
12031more memory for a large function.
12032
12033With @option{-O}, the compiler tries to reduce code size and execution
12034time, without performing any optimizations that take a great deal of
12035compilation time.
12036
12037@c Note that in addition to the default_options_table list in opts.cc,
12038@c several optimization flags default to true but control optimization
12039@c passes that are explicitly disabled at -O0.
12040
12041@option{-O} turns on the following optimization flags:
12042
12043@c Please keep the following list alphabetized.
43b72ede
AA
12044@gccoptlist{-fauto-inc-dec
12045-fbranch-count-reg
12046-fcombine-stack-adjustments
12047-fcompare-elim
12048-fcprop-registers
12049-fdce
12050-fdefer-pop
12051-fdelayed-branch
12052-fdse
12053-fforward-propagate
12054-fguess-branch-probability
12055-fif-conversion
12056-fif-conversion2
12057-finline-functions-called-once
12058-fipa-modref
12059-fipa-profile
12060-fipa-pure-const
12061-fipa-reference
12062-fipa-reference-addressable
12063-fmerge-constants
12064-fmove-loop-invariants
12065-fmove-loop-stores
12066-fomit-frame-pointer
12067-freorder-blocks
12068-fshrink-wrap
12069-fshrink-wrap-separate
12070-fsplit-wide-types
12071-fssa-backprop
12072-fssa-phiopt
12073-ftree-bit-ccp
12074-ftree-ccp
12075-ftree-ch
12076-ftree-coalesce-vars
12077-ftree-copy-prop
12078-ftree-dce
12079-ftree-dominator-opts
12080-ftree-dse
12081-ftree-forwprop
12082-ftree-fre
12083-ftree-phiprop
12084-ftree-pta
12085-ftree-scev-cprop
12086-ftree-sink
12087-ftree-slsr
12088-ftree-sra
12089-ftree-ter
d77de738
ML
12090-funit-at-a-time}
12091
d77de738 12092@opindex O2
ddf6fe37 12093@item -O2
d77de738
ML
12094Optimize even more. GCC performs nearly all supported optimizations
12095that do not involve a space-speed tradeoff.
12096As compared to @option{-O}, this option increases both compilation time
12097and the performance of the generated code.
12098
12099@option{-O2} turns on all optimization flags specified by @option{-O1}. It
12100also turns on the following optimization flags:
12101
12102@c Please keep the following list alphabetized!
43b72ede
AA
12103@gccoptlist{-falign-functions -falign-jumps
12104-falign-labels -falign-loops
12105-fcaller-saves
12106-fcode-hoisting
12107-fcrossjumping
12108-fcse-follow-jumps -fcse-skip-blocks
12109-fdelete-null-pointer-checks
12110-fdevirtualize -fdevirtualize-speculatively
12111-fexpensive-optimizations
12112-ffinite-loops
12113-fgcse -fgcse-lm
12114-fhoist-adjacent-loads
12115-finline-functions
12116-finline-small-functions
12117-findirect-inlining
12118-fipa-bit-cp -fipa-cp -fipa-icf
12119-fipa-ra -fipa-sra -fipa-vrp
12120-fisolate-erroneous-paths-dereference
12121-flra-remat
12122-foptimize-sibling-calls
12123-foptimize-strlen
12124-fpartial-inlining
12125-fpeephole2
12126-freorder-blocks-algorithm=stc
12127-freorder-blocks-and-partition -freorder-functions
12128-frerun-cse-after-loop
12129-fschedule-insns -fschedule-insns2
12130-fsched-interblock -fsched-spec
12131-fstore-merging
12132-fstrict-aliasing
12133-fthread-jumps
12134-ftree-builtin-call-dce
12135-ftree-loop-vectorize
12136-ftree-pre
12137-ftree-slp-vectorize
12138-ftree-switch-conversion -ftree-tail-merge
12139-ftree-vrp
d77de738
ML
12140-fvect-cost-model=very-cheap}
12141
12142Please note the warning under @option{-fgcse} about
12143invoking @option{-O2} on programs that use computed gotos.
12144
d77de738 12145@opindex O3
ddf6fe37 12146@item -O3
d77de738
ML
12147Optimize yet more. @option{-O3} turns on all optimizations specified
12148by @option{-O2} and also turns on the following optimization flags:
12149
12150@c Please keep the following list alphabetized!
43b72ede 12151@gccoptlist{-fgcse-after-reload
d77de738 12152-fipa-cp-clone
43b72ede
AA
12153-floop-interchange
12154-floop-unroll-and-jam
12155-fpeel-loops
12156-fpredictive-commoning
12157-fsplit-loops
12158-fsplit-paths
12159-ftree-loop-distribution
12160-ftree-partial-pre
12161-funswitch-loops
12162-fvect-cost-model=dynamic
d77de738
ML
12163-fversion-loops-for-strides}
12164
d77de738 12165@opindex O0
ddf6fe37 12166@item -O0
d77de738
ML
12167Reduce compilation time and make debugging produce the expected
12168results. This is the default.
12169
d77de738 12170@opindex Os
ddf6fe37 12171@item -Os
d77de738
ML
12172Optimize for size. @option{-Os} enables all @option{-O2} optimizations
12173except those that often increase code size:
12174
43b72ede
AA
12175@gccoptlist{-falign-functions -falign-jumps
12176-falign-labels -falign-loops
d77de738
ML
12177-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
12178
12179It also enables @option{-finline-functions}, causes the compiler to tune for
12180code size rather than execution speed, and performs further optimizations
12181designed to reduce code size.
12182
d77de738 12183@opindex Ofast
ddf6fe37 12184@item -Ofast
d77de738
ML
12185Disregard strict standards compliance. @option{-Ofast} enables all
12186@option{-O3} optimizations. It also enables optimizations that are not
12187valid for all standard-compliant programs.
12188It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
12189and the Fortran-specific @option{-fstack-arrays}, unless
12190@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
12191It turns off @option{-fsemantic-interposition}.
12192
d77de738 12193@opindex Og
ddf6fe37 12194@item -Og
d77de738
ML
12195Optimize debugging experience. @option{-Og} should be the optimization
12196level of choice for the standard edit-compile-debug cycle, offering
12197a reasonable level of optimization while maintaining fast compilation
12198and a good debugging experience. It is a better choice than @option{-O0}
12199for producing debuggable code because some compiler passes
12200that collect debug information are disabled at @option{-O0}.
12201
12202Like @option{-O0}, @option{-Og} completely disables a number of
12203optimization passes so that individual options controlling them have
12204no effect. Otherwise @option{-Og} enables all @option{-O1}
12205optimization flags except for those that may interfere with debugging:
12206
43b72ede
AA
12207@gccoptlist{-fbranch-count-reg -fdelayed-branch
12208-fdse -fif-conversion -fif-conversion2
12209-finline-functions-called-once
12210-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
12211-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12212
d77de738 12213@opindex Oz
ddf6fe37 12214@item -Oz
d77de738
ML
12215Optimize aggressively for size rather than speed. This may increase
12216the number of instructions executed if those instructions require
12217fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12218including enabling most @option{-O2} optimizations.
12219
12220@end table
12221
12222If you use multiple @option{-O} options, with or without level numbers,
12223the last such option is the one that is effective.
12224
12225Options of the form @option{-f@var{flag}} specify machine-independent
12226flags. Most flags have both positive and negative forms; the negative
12227form of @option{-ffoo} is @option{-fno-foo}. In the table
12228below, only one of the forms is listed---the one you typically
12229use. You can figure out the other form by either removing @samp{no-}
12230or adding it.
12231
12232The following options control specific optimizations. They are either
12233activated by @option{-O} options or are related to ones that are. You
12234can use the following flags in the rare cases when ``fine-tuning'' of
12235optimizations to be performed is desired.
12236
12237@table @gcctabopt
d77de738
ML
12238@opindex fno-defer-pop
12239@opindex fdefer-pop
ddf6fe37 12240@item -fno-defer-pop
d77de738
ML
12241For machines that must pop arguments after a function call, always pop
12242the arguments as soon as each function returns.
12243At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12244this allows the compiler to let arguments accumulate on the stack for several
12245function calls and pop them all at once.
12246
d77de738 12247@opindex fforward-propagate
ddf6fe37 12248@item -fforward-propagate
d77de738
ML
12249Perform a forward propagation pass on RTL@. The pass tries to combine two
12250instructions and checks if the result can be simplified. If loop unrolling
12251is active, two passes are performed and the second is scheduled after
12252loop unrolling.
12253
12254This option is enabled by default at optimization levels @option{-O1},
12255@option{-O2}, @option{-O3}, @option{-Os}.
12256
d77de738 12257@opindex ffp-contract
ddf6fe37 12258@item -ffp-contract=@var{style}
d77de738
ML
12259@option{-ffp-contract=off} disables floating-point expression contraction.
12260@option{-ffp-contract=fast} enables floating-point expression contraction
12261such as forming of fused multiply-add operations if the target has
12262native support for them.
12263@option{-ffp-contract=on} enables floating-point expression contraction
1c1dd396
AM
12264if allowed by the language standard. This is implemented for C and C++,
12265where it enables contraction within one expression, but not across
12266different statements.
d77de738 12267
1c1dd396
AM
12268The default is @option{-ffp-contract=off} for C in a standards compliant mode
12269(@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
d77de738 12270
d77de738 12271@opindex fomit-frame-pointer
ddf6fe37 12272@item -fomit-frame-pointer
d77de738
ML
12273Omit the frame pointer in functions that don't need one. This avoids the
12274instructions to save, set up and restore the frame pointer; on many targets
12275it also makes an extra register available.
12276
12277On some targets this flag has no effect because the standard calling sequence
12278always uses a frame pointer, so it cannot be omitted.
12279
12280Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12281is used in all functions. Several targets always omit the frame pointer in
12282leaf functions.
12283
12284Enabled by default at @option{-O1} and higher.
12285
d77de738 12286@opindex foptimize-sibling-calls
ddf6fe37 12287@item -foptimize-sibling-calls
d77de738
ML
12288Optimize sibling and tail recursive calls.
12289
12290Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12291
d77de738 12292@opindex foptimize-strlen
ddf6fe37 12293@item -foptimize-strlen
d77de738
ML
12294Optimize various standard C string functions (e.g.@: @code{strlen},
12295@code{strchr} or @code{strcpy}) and
12296their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12297
12298Enabled at levels @option{-O2}, @option{-O3}.
12299
d77de738
ML
12300@opindex fno-inline
12301@opindex finline
ddf6fe37 12302@item -fno-inline
d77de738
ML
12303Do not expand any functions inline apart from those marked with
12304the @code{always_inline} attribute. This is the default when not
12305optimizing.
12306
12307Single functions can be exempted from inlining by marking them
12308with the @code{noinline} attribute.
12309
d77de738 12310@opindex finline-small-functions
ddf6fe37 12311@item -finline-small-functions
d77de738
ML
12312Integrate functions into their callers when their body is smaller than expected
12313function call code (so overall size of program gets smaller). The compiler
12314heuristically decides which functions are simple enough to be worth integrating
12315in this way. This inlining applies to all functions, even those not declared
12316inline.
12317
12318Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12319
d77de738 12320@opindex findirect-inlining
ddf6fe37 12321@item -findirect-inlining
d77de738
ML
12322Inline also indirect calls that are discovered to be known at compile
12323time thanks to previous inlining. This option has any effect only
12324when inlining itself is turned on by the @option{-finline-functions}
12325or @option{-finline-small-functions} options.
12326
12327Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12328
d77de738 12329@opindex finline-functions
ddf6fe37 12330@item -finline-functions
d77de738
ML
12331Consider all functions for inlining, even if they are not declared inline.
12332The compiler heuristically decides which functions are worth integrating
12333in this way.
12334
12335If all calls to a given function are integrated, and the function is
12336declared @code{static}, then the function is normally not output as
12337assembler code in its own right.
12338
12339Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12340by @option{-fprofile-use} and @option{-fauto-profile}.
12341
d77de738 12342@opindex finline-functions-called-once
ddf6fe37 12343@item -finline-functions-called-once
d77de738
ML
12344Consider all @code{static} functions called once for inlining into their
12345caller even if they are not marked @code{inline}. If a call to a given
12346function is integrated, then the function is not output as assembler code
12347in its own right.
12348
12349Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12350but not @option{-Og}.
12351
d77de738 12352@opindex fearly-inlining
ddf6fe37 12353@item -fearly-inlining
d77de738
ML
12354Inline functions marked by @code{always_inline} and functions whose body seems
12355smaller than the function call overhead early before doing
12356@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12357makes profiling significantly cheaper and usually inlining faster on programs
12358having large chains of nested wrapper functions.
12359
12360Enabled by default.
12361
d77de738 12362@opindex fipa-sra
ddf6fe37 12363@item -fipa-sra
d77de738
ML
12364Perform interprocedural scalar replacement of aggregates, removal of
12365unused parameters and replacement of parameters passed by reference
12366by parameters passed by value.
12367
12368Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12369
d77de738 12370@opindex finline-limit
ddf6fe37 12371@item -finline-limit=@var{n}
d77de738
ML
12372By default, GCC limits the size of functions that can be inlined. This flag
12373allows coarse control of this limit. @var{n} is the size of functions that
12374can be inlined in number of pseudo instructions.
12375
12376Inlining is actually controlled by a number of parameters, which may be
12377specified individually by using @option{--param @var{name}=@var{value}}.
12378The @option{-finline-limit=@var{n}} option sets some of these parameters
12379as follows:
12380
12381@table @gcctabopt
12382@item max-inline-insns-single
12383is set to @var{n}/2.
12384@item max-inline-insns-auto
12385is set to @var{n}/2.
12386@end table
12387
12388See below for a documentation of the individual
12389parameters controlling inlining and for the defaults of these parameters.
12390
12391@emph{Note:} there may be no value to @option{-finline-limit} that results
12392in default behavior.
12393
12394@emph{Note:} pseudo instruction represents, in this particular context, an
12395abstract measurement of function's size. In no way does it represent a count
12396of assembly instructions and as such its exact meaning might change from one
12397release to an another.
12398
d77de738
ML
12399@opindex fno-keep-inline-dllexport
12400@opindex fkeep-inline-dllexport
ddf6fe37 12401@item -fno-keep-inline-dllexport
d77de738
ML
12402This is a more fine-grained version of @option{-fkeep-inline-functions},
12403which applies only to functions that are declared using the @code{dllexport}
12404attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12405Functions}.
12406
d77de738 12407@opindex fkeep-inline-functions
ddf6fe37 12408@item -fkeep-inline-functions
d77de738
ML
12409In C, emit @code{static} functions that are declared @code{inline}
12410into the object file, even if the function has been inlined into all
12411of its callers. This switch does not affect functions using the
12412@code{extern inline} extension in GNU C90@. In C++, emit any and all
12413inline functions into the object file.
12414
d77de738 12415@opindex fkeep-static-functions
ddf6fe37 12416@item -fkeep-static-functions
d77de738
ML
12417Emit @code{static} functions into the object file, even if the function
12418is never used.
12419
d77de738 12420@opindex fkeep-static-consts
ddf6fe37 12421@item -fkeep-static-consts
d77de738
ML
12422Emit variables declared @code{static const} when optimization isn't turned
12423on, even if the variables aren't referenced.
12424
12425GCC enables this option by default. If you want to force the compiler to
12426check if a variable is referenced, regardless of whether or not
12427optimization is turned on, use the @option{-fno-keep-static-consts} option.
12428
d77de738 12429@opindex fmerge-constants
ddf6fe37 12430@item -fmerge-constants
d77de738
ML
12431Attempt to merge identical constants (string constants and floating-point
12432constants) across compilation units.
12433
12434This option is the default for optimized compilation if the assembler and
12435linker support it. Use @option{-fno-merge-constants} to inhibit this
12436behavior.
12437
12438Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12439
d77de738 12440@opindex fmerge-all-constants
ddf6fe37 12441@item -fmerge-all-constants
d77de738
ML
12442Attempt to merge identical constants and identical variables.
12443
12444This option implies @option{-fmerge-constants}. In addition to
12445@option{-fmerge-constants} this considers e.g.@: even constant initialized
12446arrays or initialized constant variables with integral or floating-point
12447types. Languages like C or C++ require each variable, including multiple
12448instances of the same variable in recursive calls, to have distinct locations,
12449so using this option results in non-conforming
12450behavior.
12451
d77de738 12452@opindex fmodulo-sched
ddf6fe37 12453@item -fmodulo-sched
d77de738
ML
12454Perform swing modulo scheduling immediately before the first scheduling
12455pass. This pass looks at innermost loops and reorders their
12456instructions by overlapping different iterations.
12457
d77de738 12458@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12459@item -fmodulo-sched-allow-regmoves
d77de738
ML
12460Perform more aggressive SMS-based modulo scheduling with register moves
12461allowed. By setting this flag certain anti-dependences edges are
12462deleted, which triggers the generation of reg-moves based on the
12463life-range analysis. This option is effective only with
12464@option{-fmodulo-sched} enabled.
12465
d77de738
ML
12466@opindex fno-branch-count-reg
12467@opindex fbranch-count-reg
ddf6fe37 12468@item -fno-branch-count-reg
d77de738
ML
12469Disable the optimization pass that scans for opportunities to use
12470``decrement and branch'' instructions on a count register instead of
12471instruction sequences that decrement a register, compare it against zero, and
12472then branch based upon the result. This option is only meaningful on
12473architectures that support such instructions, which include x86, PowerPC,
12474IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12475doesn't remove the decrement and branch instructions from the generated
12476instruction stream introduced by other optimization passes.
12477
12478The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12479except for @option{-Og}.
12480
d77de738
ML
12481@opindex fno-function-cse
12482@opindex ffunction-cse
ddf6fe37 12483@item -fno-function-cse
d77de738
ML
12484Do not put function addresses in registers; make each instruction that
12485calls a constant function contain the function's address explicitly.
12486
12487This option results in less efficient code, but some strange hacks
12488that alter the assembler output may be confused by the optimizations
12489performed when this option is not used.
12490
12491The default is @option{-ffunction-cse}
12492
d77de738
ML
12493@opindex fno-zero-initialized-in-bss
12494@opindex fzero-initialized-in-bss
ddf6fe37 12495@item -fno-zero-initialized-in-bss
d77de738
ML
12496If the target supports a BSS section, GCC by default puts variables that
12497are initialized to zero into BSS@. This can save space in the resulting
12498code.
12499
12500This option turns off this behavior because some programs explicitly
12501rely on variables going to the data section---e.g., so that the
12502resulting executable can find the beginning of that section and/or make
12503assumptions based on that.
12504
12505The default is @option{-fzero-initialized-in-bss}.
12506
d77de738 12507@opindex fthread-jumps
ddf6fe37 12508@item -fthread-jumps
d77de738
ML
12509Perform optimizations that check to see if a jump branches to a
12510location where another comparison subsumed by the first is found. If
12511so, the first branch is redirected to either the destination of the
12512second branch or a point immediately following it, depending on whether
12513the condition is known to be true or false.
12514
12515Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12516
d77de738 12517@opindex fsplit-wide-types
ddf6fe37 12518@item -fsplit-wide-types
d77de738
ML
12519When using a type that occupies multiple registers, such as @code{long
12520long} on a 32-bit system, split the registers apart and allocate them
12521independently. This normally generates better code for those types,
12522but may make debugging more difficult.
12523
12524Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12525@option{-Os}.
12526
d77de738 12527@opindex fsplit-wide-types-early
ddf6fe37 12528@item -fsplit-wide-types-early
d77de738
ML
12529Fully split wide types early, instead of very late.
12530This option has no effect unless @option{-fsplit-wide-types} is turned on.
12531
12532This is the default on some targets.
12533
d77de738 12534@opindex fcse-follow-jumps
ddf6fe37 12535@item -fcse-follow-jumps
d77de738
ML
12536In common subexpression elimination (CSE), scan through jump instructions
12537when the target of the jump is not reached by any other path. For
12538example, when CSE encounters an @code{if} statement with an
12539@code{else} clause, CSE follows the jump when the condition
12540tested is false.
12541
12542Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12543
d77de738 12544@opindex fcse-skip-blocks
ddf6fe37 12545@item -fcse-skip-blocks
d77de738
ML
12546This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12547follow jumps that conditionally skip over blocks. When CSE
12548encounters a simple @code{if} statement with no else clause,
12549@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12550body of the @code{if}.
12551
12552Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12553
d77de738 12554@opindex frerun-cse-after-loop
ddf6fe37 12555@item -frerun-cse-after-loop
d77de738
ML
12556Re-run common subexpression elimination after loop optimizations are
12557performed.
12558
12559Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12560
d77de738 12561@opindex fgcse
ddf6fe37 12562@item -fgcse
d77de738
ML
12563Perform a global common subexpression elimination pass.
12564This pass also performs global constant and copy propagation.
12565
12566@emph{Note:} When compiling a program using computed gotos, a GCC
12567extension, you may get better run-time performance if you disable
12568the global common subexpression elimination pass by adding
12569@option{-fno-gcse} to the command line.
12570
12571Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12572
d77de738 12573@opindex fgcse-lm
ddf6fe37 12574@item -fgcse-lm
d77de738
ML
12575When @option{-fgcse-lm} is enabled, global common subexpression elimination
12576attempts to move loads that are only killed by stores into themselves. This
12577allows a loop containing a load/store sequence to be changed to a load outside
12578the loop, and a copy/store within the loop.
12579
12580Enabled by default when @option{-fgcse} is enabled.
12581
d77de738 12582@opindex fgcse-sm
ddf6fe37 12583@item -fgcse-sm
d77de738
ML
12584When @option{-fgcse-sm} is enabled, a store motion pass is run after
12585global common subexpression elimination. This pass attempts to move
12586stores out of loops. When used in conjunction with @option{-fgcse-lm},
12587loops containing a load/store sequence can be changed to a load before
12588the loop and a store after the loop.
12589
12590Not enabled at any optimization level.
12591
d77de738 12592@opindex fgcse-las
ddf6fe37 12593@item -fgcse-las
d77de738
ML
12594When @option{-fgcse-las} is enabled, the global common subexpression
12595elimination pass eliminates redundant loads that come after stores to the
12596same memory location (both partial and full redundancies).
12597
12598Not enabled at any optimization level.
12599
d77de738 12600@opindex fgcse-after-reload
ddf6fe37 12601@item -fgcse-after-reload
d77de738
ML
12602When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12603pass is performed after reload. The purpose of this pass is to clean up
12604redundant spilling.
12605
12606Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12607
d77de738 12608@opindex faggressive-loop-optimizations
ddf6fe37 12609@item -faggressive-loop-optimizations
d77de738
ML
12610This option tells the loop optimizer to use language constraints to
12611derive bounds for the number of iterations of a loop. This assumes that
12612loop code does not invoke undefined behavior by for example causing signed
12613integer overflows or out-of-bound array accesses. The bounds for the
12614number of iterations of a loop are used to guide loop unrolling and peeling
12615and loop exit test optimizations.
12616This option is enabled by default.
12617
d77de738 12618@opindex funconstrained-commons
ddf6fe37 12619@item -funconstrained-commons
d77de738
ML
12620This option tells the compiler that variables declared in common blocks
12621(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12622prevents certain optimizations that depend on knowing the array bounds.
12623
d77de738 12624@opindex fcrossjumping
ddf6fe37 12625@item -fcrossjumping
d77de738
ML
12626Perform cross-jumping transformation.
12627This transformation unifies equivalent code and saves code size. The
12628resulting code may or may not perform better than without cross-jumping.
12629
12630Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12631
d77de738 12632@opindex fauto-inc-dec
ddf6fe37 12633@item -fauto-inc-dec
d77de738
ML
12634Combine increments or decrements of addresses with memory accesses.
12635This pass is always skipped on architectures that do not have
12636instructions to support this. Enabled by default at @option{-O1} and
12637higher on architectures that support this.
12638
d77de738 12639@opindex fdce
ddf6fe37 12640@item -fdce
d77de738
ML
12641Perform dead code elimination (DCE) on RTL@.
12642Enabled by default at @option{-O1} and higher.
12643
d77de738 12644@opindex fdse
ddf6fe37 12645@item -fdse
d77de738
ML
12646Perform dead store elimination (DSE) on RTL@.
12647Enabled by default at @option{-O1} and higher.
12648
d77de738 12649@opindex fif-conversion
ddf6fe37 12650@item -fif-conversion
d77de738
ML
12651Attempt to transform conditional jumps into branch-less equivalents. This
12652includes use of conditional moves, min, max, set flags and abs instructions, and
12653some tricks doable by standard arithmetics. The use of conditional execution
12654on chips where it is available is controlled by @option{-fif-conversion2}.
12655
12656Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12657not with @option{-Og}.
12658
d77de738 12659@opindex fif-conversion2
ddf6fe37 12660@item -fif-conversion2
d77de738
ML
12661Use conditional execution (where available) to transform conditional jumps into
12662branch-less equivalents.
12663
12664Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12665not with @option{-Og}.
12666
d77de738 12667@opindex fdeclone-ctor-dtor
ddf6fe37 12668@item -fdeclone-ctor-dtor
d77de738
ML
12669The C++ ABI requires multiple entry points for constructors and
12670destructors: one for a base subobject, one for a complete object, and
12671one for a virtual destructor that calls operator delete afterwards.
12672For a hierarchy with virtual bases, the base and complete variants are
12673clones, which means two copies of the function. With this option, the
12674base and complete variants are changed to be thunks that call a common
12675implementation.
12676
12677Enabled by @option{-Os}.
12678
d77de738 12679@opindex fdelete-null-pointer-checks
ddf6fe37 12680@item -fdelete-null-pointer-checks
d77de738
ML
12681Assume that programs cannot safely dereference null pointers, and that
12682no code or data element resides at address zero.
12683This option enables simple constant
12684folding optimizations at all optimization levels. In addition, other
12685optimization passes in GCC use this flag to control global dataflow
12686analyses that eliminate useless checks for null pointers; these assume
12687that a memory access to address zero always results in a trap, so
12688that if a pointer is checked after it has already been dereferenced,
12689it cannot be null.
12690
12691Note however that in some environments this assumption is not true.
12692Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12693for programs that depend on that behavior.
12694
12695This option is enabled by default on most targets. On Nios II ELF, it
12696defaults to off. On AVR and MSP430, this option is completely disabled.
12697
12698Passes that use the dataflow information
12699are enabled independently at different optimization levels.
12700
d77de738 12701@opindex fdevirtualize
ddf6fe37 12702@item -fdevirtualize
d77de738
ML
12703Attempt to convert calls to virtual functions to direct calls. This
12704is done both within a procedure and interprocedurally as part of
12705indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12706propagation (@option{-fipa-cp}).
12707Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12708
d77de738 12709@opindex fdevirtualize-speculatively
ddf6fe37 12710@item -fdevirtualize-speculatively
d77de738
ML
12711Attempt to convert calls to virtual functions to speculative direct calls.
12712Based on the analysis of the type inheritance graph, determine for a given call
12713the set of likely targets. If the set is small, preferably of size 1, change
12714the call into a conditional deciding between direct and indirect calls. The
12715speculative calls enable more optimizations, such as inlining. When they seem
12716useless after further optimization, they are converted back into original form.
12717
d77de738 12718@opindex fdevirtualize-at-ltrans
ddf6fe37 12719@item -fdevirtualize-at-ltrans
d77de738
ML
12720Stream extra information needed for aggressive devirtualization when running
12721the link-time optimizer in local transformation mode.
12722This option enables more devirtualization but
12723significantly increases the size of streamed data. For this reason it is
12724disabled by default.
12725
d77de738 12726@opindex fexpensive-optimizations
ddf6fe37 12727@item -fexpensive-optimizations
d77de738
ML
12728Perform a number of minor optimizations that are relatively expensive.
12729
12730Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12731
d77de738 12732@opindex free
ddf6fe37 12733@item -free
d77de738
ML
12734Attempt to remove redundant extension instructions. This is especially
12735helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12736registers after writing to their lower 32-bit half.
12737
88ae53a3
LC
12738Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
12739levels @option{-O2}, @option{-O3}, @option{-Os}.
d77de738 12740
d77de738
ML
12741@opindex fno-lifetime-dse
12742@opindex flifetime-dse
ddf6fe37 12743@item -fno-lifetime-dse
d77de738
ML
12744In C++ the value of an object is only affected by changes within its
12745lifetime: when the constructor begins, the object has an indeterminate
12746value, and any changes during the lifetime of the object are dead when
12747the object is destroyed. Normally dead store elimination will take
12748advantage of this; if your code relies on the value of the object
12749storage persisting beyond the lifetime of the object, you can use this
12750flag to disable this optimization. To preserve stores before the
12751constructor starts (e.g.@: because your operator new clears the object
12752storage) but still treat the object as dead after the destructor, you
12753can use @option{-flifetime-dse=1}. The default behavior can be
12754explicitly selected with @option{-flifetime-dse=2}.
12755@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12756
d77de738 12757@opindex flive-range-shrinkage
ddf6fe37 12758@item -flive-range-shrinkage
d77de738
ML
12759Attempt to decrease register pressure through register live range
12760shrinkage. This is helpful for fast processors with small or moderate
12761size register sets.
12762
d77de738 12763@opindex fira-algorithm
ddf6fe37 12764@item -fira-algorithm=@var{algorithm}
d77de738
ML
12765Use the specified coloring algorithm for the integrated register
12766allocator. The @var{algorithm} argument can be @samp{priority}, which
12767specifies Chow's priority coloring, or @samp{CB}, which specifies
12768Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12769for all architectures, but for those targets that do support it, it is
12770the default because it generates better code.
12771
d77de738 12772@opindex fira-region
ddf6fe37 12773@item -fira-region=@var{region}
d77de738
ML
12774Use specified regions for the integrated register allocator. The
12775@var{region} argument should be one of the following:
12776
12777@table @samp
12778
12779@item all
12780Use all loops as register allocation regions.
12781This can give the best results for machines with a small and/or
12782irregular register set.
12783
12784@item mixed
12785Use all loops except for loops with small register pressure
12786as the regions. This value usually gives
12787the best results in most cases and for most architectures,
12788and is enabled by default when compiling with optimization for speed
12789(@option{-O}, @option{-O2}, @dots{}).
12790
12791@item one
12792Use all functions as a single region.
12793This typically results in the smallest code size, and is enabled by default for
12794@option{-Os} or @option{-O0}.
12795
12796@end table
12797
d77de738 12798@opindex fira-hoist-pressure
ddf6fe37 12799@item -fira-hoist-pressure
d77de738
ML
12800Use IRA to evaluate register pressure in the code hoisting pass for
12801decisions to hoist expressions. This option usually results in smaller
12802code, but it can slow the compiler down.
12803
12804This option is enabled at level @option{-Os} for all targets.
12805
d77de738 12806@opindex fira-loop-pressure
ddf6fe37 12807@item -fira-loop-pressure
d77de738
ML
12808Use IRA to evaluate register pressure in loops for decisions to move
12809loop invariants. This option usually results in generation
12810of faster and smaller code on machines with large register files (>= 32
12811registers), but it can slow the compiler down.
12812
12813This option is enabled at level @option{-O3} for some targets.
12814
d77de738
ML
12815@opindex fno-ira-share-save-slots
12816@opindex fira-share-save-slots
ddf6fe37 12817@item -fno-ira-share-save-slots
d77de738
ML
12818Disable sharing of stack slots used for saving call-used hard
12819registers living through a call. Each hard register gets a
12820separate stack slot, and as a result function stack frames are
12821larger.
12822
d77de738
ML
12823@opindex fno-ira-share-spill-slots
12824@opindex fira-share-spill-slots
ddf6fe37 12825@item -fno-ira-share-spill-slots
d77de738
ML
12826Disable sharing of stack slots allocated for pseudo-registers. Each
12827pseudo-register that does not get a hard register gets a separate
12828stack slot, and as a result function stack frames are larger.
12829
d77de738 12830@opindex flra-remat
ddf6fe37 12831@item -flra-remat
d77de738
ML
12832Enable CFG-sensitive rematerialization in LRA. Instead of loading
12833values of spilled pseudos, LRA tries to rematerialize (recalculate)
12834values if it is profitable.
12835
12836Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12837
d77de738 12838@opindex fdelayed-branch
ddf6fe37 12839@item -fdelayed-branch
d77de738
ML
12840If supported for the target machine, attempt to reorder instructions
12841to exploit instruction slots available after delayed branch
12842instructions.
12843
12844Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12845but not at @option{-Og}.
12846
d77de738 12847@opindex fschedule-insns
ddf6fe37 12848@item -fschedule-insns
d77de738
ML
12849If supported for the target machine, attempt to reorder instructions to
12850eliminate execution stalls due to required data being unavailable. This
12851helps machines that have slow floating point or memory load instructions
12852by allowing other instructions to be issued until the result of the load
12853or floating-point instruction is required.
12854
12855Enabled at levels @option{-O2}, @option{-O3}.
12856
d77de738 12857@opindex fschedule-insns2
ddf6fe37 12858@item -fschedule-insns2
d77de738
ML
12859Similar to @option{-fschedule-insns}, but requests an additional pass of
12860instruction scheduling after register allocation has been done. This is
12861especially useful on machines with a relatively small number of
12862registers and where memory load instructions take more than one cycle.
12863
12864Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12865
d77de738
ML
12866@opindex fno-sched-interblock
12867@opindex fsched-interblock
ddf6fe37 12868@item -fno-sched-interblock
d77de738
ML
12869Disable instruction scheduling across basic blocks, which
12870is normally enabled when scheduling before register allocation, i.e.@:
12871with @option{-fschedule-insns} or at @option{-O2} or higher.
12872
d77de738
ML
12873@opindex fno-sched-spec
12874@opindex fsched-spec
ddf6fe37 12875@item -fno-sched-spec
d77de738
ML
12876Disable speculative motion of non-load instructions, which
12877is normally enabled when scheduling before register allocation, i.e.@:
12878with @option{-fschedule-insns} or at @option{-O2} or higher.
12879
d77de738 12880@opindex fsched-pressure
ddf6fe37 12881@item -fsched-pressure
d77de738
ML
12882Enable register pressure sensitive insn scheduling before register
12883allocation. This only makes sense when scheduling before register
12884allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12885@option{-O2} or higher. Usage of this option can improve the
12886generated code and decrease its size by preventing register pressure
12887increase above the number of available hard registers and subsequent
12888spills in register allocation.
12889
d77de738 12890@opindex fsched-spec-load
ddf6fe37 12891@item -fsched-spec-load
d77de738
ML
12892Allow speculative motion of some load instructions. This only makes
12893sense when scheduling before register allocation, i.e.@: with
12894@option{-fschedule-insns} or at @option{-O2} or higher.
12895
d77de738 12896@opindex fsched-spec-load-dangerous
ddf6fe37 12897@item -fsched-spec-load-dangerous
d77de738
ML
12898Allow speculative motion of more load instructions. This only makes
12899sense when scheduling before register allocation, i.e.@: with
12900@option{-fschedule-insns} or at @option{-O2} or higher.
12901
ddf6fe37 12902@opindex fsched-stalled-insns
d77de738
ML
12903@item -fsched-stalled-insns
12904@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12905Define how many insns (if any) can be moved prematurely from the queue
12906of stalled insns into the ready list during the second scheduling pass.
12907@option{-fno-sched-stalled-insns} means that no insns are moved
12908prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12909on how many queued insns can be moved prematurely.
12910@option{-fsched-stalled-insns} without a value is equivalent to
12911@option{-fsched-stalled-insns=1}.
12912
ddf6fe37 12913@opindex fsched-stalled-insns-dep
d77de738
ML
12914@item -fsched-stalled-insns-dep
12915@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12916Define how many insn groups (cycles) are examined for a dependency
12917on a stalled insn that is a candidate for premature removal from the queue
12918of stalled insns. This has an effect only during the second scheduling pass,
12919and only if @option{-fsched-stalled-insns} is used.
12920@option{-fno-sched-stalled-insns-dep} is equivalent to
12921@option{-fsched-stalled-insns-dep=0}.
12922@option{-fsched-stalled-insns-dep} without a value is equivalent to
12923@option{-fsched-stalled-insns-dep=1}.
12924
d77de738 12925@opindex fsched2-use-superblocks
ddf6fe37 12926@item -fsched2-use-superblocks
d77de738
ML
12927When scheduling after register allocation, use superblock scheduling.
12928This allows motion across basic block boundaries,
12929resulting in faster schedules. This option is experimental, as not all machine
12930descriptions used by GCC model the CPU closely enough to avoid unreliable
12931results from the algorithm.
12932
12933This only makes sense when scheduling after register allocation, i.e.@: with
12934@option{-fschedule-insns2} or at @option{-O2} or higher.
12935
d77de738 12936@opindex fsched-group-heuristic
ddf6fe37 12937@item -fsched-group-heuristic
d77de738
ML
12938Enable the group heuristic in the scheduler. This heuristic favors
12939the instruction that belongs to a schedule group. This is enabled
12940by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12941or @option{-fschedule-insns2} or at @option{-O2} or higher.
12942
d77de738 12943@opindex fsched-critical-path-heuristic
ddf6fe37 12944@item -fsched-critical-path-heuristic
d77de738
ML
12945Enable the critical-path heuristic in the scheduler. This heuristic favors
12946instructions on the critical path. This is enabled by default when
12947scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12948or @option{-fschedule-insns2} or at @option{-O2} or higher.
12949
d77de738 12950@opindex fsched-spec-insn-heuristic
ddf6fe37 12951@item -fsched-spec-insn-heuristic
d77de738
ML
12952Enable the speculative instruction heuristic in the scheduler. This
12953heuristic favors speculative instructions with greater dependency weakness.
12954This is enabled by default when scheduling is enabled, i.e.@:
12955with @option{-fschedule-insns} or @option{-fschedule-insns2}
12956or at @option{-O2} or higher.
12957
d77de738 12958@opindex fsched-rank-heuristic
ddf6fe37 12959@item -fsched-rank-heuristic
d77de738
ML
12960Enable the rank heuristic in the scheduler. This heuristic favors
12961the instruction belonging to a basic block with greater size or frequency.
12962This is enabled by default when scheduling is enabled, i.e.@:
12963with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12964at @option{-O2} or higher.
12965
d77de738 12966@opindex fsched-last-insn-heuristic
ddf6fe37 12967@item -fsched-last-insn-heuristic
d77de738
ML
12968Enable the last-instruction heuristic in the scheduler. This heuristic
12969favors the instruction that is less dependent on the last instruction
12970scheduled. This is enabled by default when scheduling is enabled,
12971i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12972at @option{-O2} or higher.
12973
d77de738 12974@opindex fsched-dep-count-heuristic
ddf6fe37 12975@item -fsched-dep-count-heuristic
d77de738
ML
12976Enable the dependent-count heuristic in the scheduler. This heuristic
12977favors the instruction that has more instructions depending on it.
12978This is enabled by default when scheduling is enabled, i.e.@:
12979with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12980at @option{-O2} or higher.
12981
d77de738 12982@opindex freschedule-modulo-scheduled-loops
ddf6fe37 12983@item -freschedule-modulo-scheduled-loops
d77de738
ML
12984Modulo scheduling is performed before traditional scheduling. If a loop
12985is modulo scheduled, later scheduling passes may change its schedule.
12986Use this option to control that behavior.
12987
d77de738 12988@opindex fselective-scheduling
ddf6fe37 12989@item -fselective-scheduling
d77de738
ML
12990Schedule instructions using selective scheduling algorithm. Selective
12991scheduling runs instead of the first scheduler pass.
12992
d77de738 12993@opindex fselective-scheduling2
ddf6fe37 12994@item -fselective-scheduling2
d77de738
ML
12995Schedule instructions using selective scheduling algorithm. Selective
12996scheduling runs instead of the second scheduler pass.
12997
d77de738 12998@opindex fsel-sched-pipelining
ddf6fe37 12999@item -fsel-sched-pipelining
d77de738
ML
13000Enable software pipelining of innermost loops during selective scheduling.
13001This option has no effect unless one of @option{-fselective-scheduling} or
13002@option{-fselective-scheduling2} is turned on.
13003
d77de738 13004@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 13005@item -fsel-sched-pipelining-outer-loops
d77de738
ML
13006When pipelining loops during selective scheduling, also pipeline outer loops.
13007This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13008
d77de738 13009@opindex fsemantic-interposition
ddf6fe37 13010@item -fsemantic-interposition
d77de738
ML
13011Some object formats, like ELF, allow interposing of symbols by the
13012dynamic linker.
13013This means that for symbols exported from the DSO, the compiler cannot perform
13014interprocedural propagation, inlining and other optimizations in anticipation
13015that the function or variable in question may change. While this feature is
13016useful, for example, to rewrite memory allocation functions by a debugging
13017implementation, it is expensive in the terms of code quality.
13018With @option{-fno-semantic-interposition} the compiler assumes that
13019if interposition happens for functions the overwriting function will have
13020precisely the same semantics (and side effects).
13021Similarly if interposition happens
13022for variables, the constructor of the variable will be the same. The flag
13023has no effect for functions explicitly declared inline
13024(where it is never allowed for interposition to change semantics)
13025and for symbols explicitly declared weak.
13026
d77de738 13027@opindex fshrink-wrap
ddf6fe37 13028@item -fshrink-wrap
d77de738
ML
13029Emit function prologues only before parts of the function that need it,
13030rather than at the top of the function. This flag is enabled by default at
13031@option{-O} and higher.
13032
d77de738 13033@opindex fshrink-wrap-separate
ddf6fe37 13034@item -fshrink-wrap-separate
d77de738
ML
13035Shrink-wrap separate parts of the prologue and epilogue separately, so that
13036those parts are only executed when needed.
13037This option is on by default, but has no effect unless @option{-fshrink-wrap}
13038is also turned on and the target supports this.
13039
d77de738 13040@opindex fcaller-saves
ddf6fe37 13041@item -fcaller-saves
d77de738
ML
13042Enable allocation of values to registers that are clobbered by
13043function calls, by emitting extra instructions to save and restore the
13044registers around such calls. Such allocation is done only when it
13045seems to result in better code.
13046
13047This option is always enabled by default on certain machines, usually
13048those which have no call-preserved registers to use instead.
13049
13050Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13051
d77de738 13052@opindex fcombine-stack-adjustments
ddf6fe37 13053@item -fcombine-stack-adjustments
d77de738
ML
13054Tracks stack adjustments (pushes and pops) and stack memory references
13055and then tries to find ways to combine them.
13056
13057Enabled by default at @option{-O1} and higher.
13058
d77de738 13059@opindex fipa-ra
ddf6fe37 13060@item -fipa-ra
d77de738
ML
13061Use caller save registers for allocation if those registers are not used by
13062any called function. In that case it is not necessary to save and restore
13063them around calls. This is only possible if called functions are part of
13064same compilation unit as current function and they are compiled before it.
13065
13066Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13067is disabled if generated code will be instrumented for profiling
13068(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13069exactly (this happens on targets that do not expose prologues
13070and epilogues in RTL).
13071
d77de738 13072@opindex fconserve-stack
ddf6fe37 13073@item -fconserve-stack
d77de738
ML
13074Attempt to minimize stack usage. The compiler attempts to use less
13075stack space, even if that makes the program slower. This option
13076implies setting the @option{large-stack-frame} parameter to 100
13077and the @option{large-stack-frame-growth} parameter to 400.
13078
d77de738 13079@opindex ftree-reassoc
ddf6fe37 13080@item -ftree-reassoc
d77de738
ML
13081Perform reassociation on trees. This flag is enabled by default
13082at @option{-O1} and higher.
13083
d77de738 13084@opindex fcode-hoisting
ddf6fe37 13085@item -fcode-hoisting
d77de738
ML
13086Perform code hoisting. Code hoisting tries to move the
13087evaluation of expressions executed on all paths to the function exit
13088as early as possible. This is especially useful as a code size
13089optimization, but it often helps for code speed as well.
13090This flag is enabled by default at @option{-O2} and higher.
13091
d77de738 13092@opindex ftree-pre
ddf6fe37 13093@item -ftree-pre
d77de738
ML
13094Perform partial redundancy elimination (PRE) on trees. This flag is
13095enabled by default at @option{-O2} and @option{-O3}.
13096
d77de738 13097@opindex ftree-partial-pre
ddf6fe37 13098@item -ftree-partial-pre
d77de738
ML
13099Make partial redundancy elimination (PRE) more aggressive. This flag is
13100enabled by default at @option{-O3}.
13101
d77de738 13102@opindex ftree-forwprop
ddf6fe37 13103@item -ftree-forwprop
d77de738
ML
13104Perform forward propagation on trees. This flag is enabled by default
13105at @option{-O1} and higher.
13106
d77de738 13107@opindex ftree-fre
ddf6fe37 13108@item -ftree-fre
d77de738
ML
13109Perform full redundancy elimination (FRE) on trees. The difference
13110between FRE and PRE is that FRE only considers expressions
13111that are computed on all paths leading to the redundant computation.
13112This analysis is faster than PRE, though it exposes fewer redundancies.
13113This flag is enabled by default at @option{-O1} and higher.
13114
d77de738 13115@opindex ftree-phiprop
ddf6fe37 13116@item -ftree-phiprop
d77de738
ML
13117Perform hoisting of loads from conditional pointers on trees. This
13118pass is enabled by default at @option{-O1} and higher.
13119
d77de738 13120@opindex fhoist-adjacent-loads
ddf6fe37 13121@item -fhoist-adjacent-loads
d77de738
ML
13122Speculatively hoist loads from both branches of an if-then-else if the
13123loads are from adjacent locations in the same structure and the target
13124architecture has a conditional move instruction. This flag is enabled
13125by default at @option{-O2} and higher.
13126
d77de738 13127@opindex ftree-copy-prop
ddf6fe37 13128@item -ftree-copy-prop
d77de738
ML
13129Perform copy propagation on trees. This pass eliminates unnecessary
13130copy operations. This flag is enabled by default at @option{-O1} and
13131higher.
13132
d77de738 13133@opindex fipa-pure-const
ddf6fe37 13134@item -fipa-pure-const
d77de738
ML
13135Discover which functions are pure or constant.
13136Enabled by default at @option{-O1} and higher.
13137
d77de738 13138@opindex fipa-reference
ddf6fe37 13139@item -fipa-reference
d77de738
ML
13140Discover which static variables do not escape the
13141compilation unit.
13142Enabled by default at @option{-O1} and higher.
13143
d77de738 13144@opindex fipa-reference-addressable
ddf6fe37 13145@item -fipa-reference-addressable
d77de738
ML
13146Discover read-only, write-only and non-addressable static variables.
13147Enabled by default at @option{-O1} and higher.
13148
d77de738 13149@opindex fipa-stack-alignment
ddf6fe37 13150@item -fipa-stack-alignment
d77de738
ML
13151Reduce stack alignment on call sites if possible.
13152Enabled by default.
13153
d77de738 13154@opindex fipa-pta
ddf6fe37 13155@item -fipa-pta
d77de738
ML
13156Perform interprocedural pointer analysis and interprocedural modification
13157and reference analysis. This option can cause excessive memory and
13158compile-time usage on large compilation units. It is not enabled by
13159default at any optimization level.
13160
d77de738 13161@opindex fipa-profile
ddf6fe37 13162@item -fipa-profile
d77de738
ML
13163Perform interprocedural profile propagation. The functions called only from
13164cold functions are marked as cold. Also functions executed once (such as
13165@code{cold}, @code{noreturn}, static constructors or destructors) are
13166identified. Cold functions and loop less parts of functions executed once are
13167then optimized for size.
13168Enabled by default at @option{-O1} and higher.
13169
d77de738 13170@opindex fipa-modref
ddf6fe37 13171@item -fipa-modref
d77de738
ML
13172Perform interprocedural mod/ref analysis. This optimization analyzes the side
13173effects of functions (memory locations that are modified or referenced) and
13174enables better optimization across the function call boundary. This flag is
13175enabled by default at @option{-O1} and higher.
13176
d77de738 13177@opindex fipa-cp
ddf6fe37 13178@item -fipa-cp
d77de738
ML
13179Perform interprocedural constant propagation.
13180This optimization analyzes the program to determine when values passed
13181to functions are constants and then optimizes accordingly.
13182This optimization can substantially increase performance
13183if the application has constants passed to functions.
13184This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
13185It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13186
d77de738 13187@opindex fipa-cp-clone
ddf6fe37 13188@item -fipa-cp-clone
d77de738
ML
13189Perform function cloning to make interprocedural constant propagation stronger.
13190When enabled, interprocedural constant propagation performs function cloning
13191when externally visible function can be called with constant arguments.
13192Because this optimization can create multiple copies of functions,
13193it may significantly increase code size
13194(see @option{--param ipa-cp-unit-growth=@var{value}}).
13195This flag is enabled by default at @option{-O3}.
13196It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13197
d77de738 13198@opindex fipa-bit-cp
ddf6fe37 13199@item -fipa-bit-cp
d77de738
ML
13200When enabled, perform interprocedural bitwise constant
13201propagation. This flag is enabled by default at @option{-O2} and
13202by @option{-fprofile-use} and @option{-fauto-profile}.
13203It requires that @option{-fipa-cp} is enabled.
13204
d77de738 13205@opindex fipa-vrp
ddf6fe37 13206@item -fipa-vrp
d77de738
ML
13207When enabled, perform interprocedural propagation of value
13208ranges. This flag is enabled by default at @option{-O2}. It requires
13209that @option{-fipa-cp} is enabled.
13210
d77de738 13211@opindex fipa-icf
ddf6fe37 13212@item -fipa-icf
d77de738
ML
13213Perform Identical Code Folding for functions and read-only variables.
13214The optimization reduces code size and may disturb unwind stacks by replacing
13215a function by equivalent one with a different name. The optimization works
13216more effectively with link-time optimization enabled.
13217
13218Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13219works on different levels and thus the optimizations are not same - there are
13220equivalences that are found only by GCC and equivalences found only by Gold.
13221
13222This flag is enabled by default at @option{-O2} and @option{-Os}.
13223
d77de738 13224@opindex flive-patching
ddf6fe37 13225@item -flive-patching=@var{level}
d77de738
ML
13226Control GCC's optimizations to produce output suitable for live-patching.
13227
13228If the compiler's optimization uses a function's body or information extracted
13229from its body to optimize/change another function, the latter is called an
13230impacted function of the former. If a function is patched, its impacted
13231functions should be patched too.
13232
13233The impacted functions are determined by the compiler's interprocedural
13234optimizations. For example, a caller is impacted when inlining a function
13235into its caller,
13236cloning a function and changing its caller to call this new clone,
13237or extracting a function's pureness/constness information to optimize
13238its direct or indirect callers, etc.
13239
13240Usually, the more IPA optimizations enabled, the larger the number of
13241impacted functions for each function. In order to control the number of
13242impacted functions and more easily compute the list of impacted function,
13243IPA optimizations can be partially enabled at two different levels.
13244
13245The @var{level} argument should be one of the following:
13246
13247@table @samp
13248
13249@item inline-clone
13250
13251Only enable inlining and cloning optimizations, which includes inlining,
13252cloning, interprocedural scalar replacement of aggregates and partial inlining.
13253As a result, when patching a function, all its callers and its clones'
13254callers are impacted, therefore need to be patched as well.
13255
13256@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
13257@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13258-fipa-icf -fipa-icf-functions -fipa-icf-variables
13259-fipa-bit-cp -fipa-vrp -fipa-pure-const
13260-fipa-reference-addressable
d77de738
ML
13261-fipa-stack-alignment -fipa-modref}
13262
13263@item inline-only-static
13264
13265Only enable inlining of static functions.
13266As a result, when patching a static function, all its callers are impacted
13267and so need to be patched as well.
13268
13269In addition to all the flags that @option{-flive-patching=inline-clone}
13270disables,
13271@option{-flive-patching=inline-only-static} disables the following additional
13272optimization flags:
13273@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13274
13275@end table
13276
13277When @option{-flive-patching} is specified without any value, the default value
13278is @var{inline-clone}.
13279
13280This flag is disabled by default.
13281
13282Note that @option{-flive-patching} is not supported with link-time optimization
13283(@option{-flto}).
13284
d77de738 13285@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13286@item -fisolate-erroneous-paths-dereference
d77de738
ML
13287Detect paths that trigger erroneous or undefined behavior due to
13288dereferencing a null pointer. Isolate those paths from the main control
13289flow and turn the statement with erroneous or undefined behavior into a trap.
13290This flag is enabled by default at @option{-O2} and higher and depends on
13291@option{-fdelete-null-pointer-checks} also being enabled.
13292
d77de738 13293@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13294@item -fisolate-erroneous-paths-attribute
d77de738
ML
13295Detect paths that trigger erroneous or undefined behavior due to a null value
13296being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13297attribute. Isolate those paths from the main control flow and turn the
13298statement with erroneous or undefined behavior into a trap. This is not
13299currently enabled, but may be enabled by @option{-O2} in the future.
13300
d77de738 13301@opindex ftree-sink
ddf6fe37 13302@item -ftree-sink
d77de738
ML
13303Perform forward store motion on trees. This flag is
13304enabled by default at @option{-O1} and higher.
13305
d77de738 13306@opindex ftree-bit-ccp
ddf6fe37 13307@item -ftree-bit-ccp
d77de738
ML
13308Perform sparse conditional bit constant propagation on trees and propagate
13309pointer alignment information.
13310This pass only operates on local scalar variables and is enabled by default
13311at @option{-O1} and higher, except for @option{-Og}.
13312It requires that @option{-ftree-ccp} is enabled.
13313
d77de738 13314@opindex ftree-ccp
ddf6fe37 13315@item -ftree-ccp
d77de738
ML
13316Perform sparse conditional constant propagation (CCP) on trees. This
13317pass only operates on local scalar variables and is enabled by default
13318at @option{-O1} and higher.
13319
d77de738 13320@opindex fssa-backprop
ddf6fe37 13321@item -fssa-backprop
d77de738
ML
13322Propagate information about uses of a value up the definition chain
13323in order to simplify the definitions. For example, this pass strips
13324sign operations if the sign of a value never matters. The flag is
13325enabled by default at @option{-O1} and higher.
13326
d77de738 13327@opindex fssa-phiopt
ddf6fe37 13328@item -fssa-phiopt
d77de738
ML
13329Perform pattern matching on SSA PHI nodes to optimize conditional
13330code. This pass is enabled by default at @option{-O1} and higher,
13331except for @option{-Og}.
13332
d77de738 13333@opindex ftree-switch-conversion
ddf6fe37 13334@item -ftree-switch-conversion
d77de738
ML
13335Perform conversion of simple initializations in a switch to
13336initializations from a scalar array. This flag is enabled by default
13337at @option{-O2} and higher.
13338
d77de738 13339@opindex ftree-tail-merge
ddf6fe37 13340@item -ftree-tail-merge
d77de738
ML
13341Look for identical code sequences. When found, replace one with a jump to the
13342other. This optimization is known as tail merging or cross jumping. This flag
13343is enabled by default at @option{-O2} and higher. The compilation time
13344in this pass can
13345be limited using @option{max-tail-merge-comparisons} parameter and
13346@option{max-tail-merge-iterations} parameter.
13347
d77de738 13348@opindex ftree-dce
ddf6fe37 13349@item -ftree-dce
d77de738
ML
13350Perform dead code elimination (DCE) on trees. This flag is enabled by
13351default at @option{-O1} and higher.
13352
d77de738 13353@opindex ftree-builtin-call-dce
ddf6fe37 13354@item -ftree-builtin-call-dce
d77de738
ML
13355Perform conditional dead code elimination (DCE) for calls to built-in functions
13356that may set @code{errno} but are otherwise free of side effects. This flag is
13357enabled by default at @option{-O2} and higher if @option{-Os} is not also
13358specified.
13359
d77de738
ML
13360@opindex ffinite-loops
13361@opindex fno-finite-loops
ddf6fe37 13362@item -ffinite-loops
d77de738
ML
13363Assume that a loop with an exit will eventually take the exit and not loop
13364indefinitely. This allows the compiler to remove loops that otherwise have
13365no side-effects, not considering eventual endless looping as such.
13366
13367This option is enabled by default at @option{-O2} for C++ with -std=c++11
13368or higher.
13369
d77de738 13370@opindex ftree-dominator-opts
ddf6fe37 13371@item -ftree-dominator-opts
d77de738
ML
13372Perform a variety of simple scalar cleanups (constant/copy
13373propagation, redundancy elimination, range propagation and expression
13374simplification) based on a dominator tree traversal. This also
13375performs jump threading (to reduce jumps to jumps). This flag is
13376enabled by default at @option{-O1} and higher.
13377
d77de738 13378@opindex ftree-dse
ddf6fe37 13379@item -ftree-dse
d77de738
ML
13380Perform dead store elimination (DSE) on trees. A dead store is a store into
13381a memory location that is later overwritten by another store without
13382any intervening loads. In this case the earlier store can be deleted. This
13383flag is enabled by default at @option{-O1} and higher.
13384
d77de738 13385@opindex ftree-ch
ddf6fe37 13386@item -ftree-ch
d77de738
ML
13387Perform loop header copying on trees. This is beneficial since it increases
13388effectiveness of code motion optimizations. It also saves one jump. This flag
13389is enabled by default at @option{-O1} and higher. It is not enabled
13390for @option{-Os}, since it usually increases code size.
13391
d77de738 13392@opindex ftree-loop-optimize
ddf6fe37 13393@item -ftree-loop-optimize
d77de738
ML
13394Perform loop optimizations on trees. This flag is enabled by default
13395at @option{-O1} and higher.
13396
d77de738
ML
13397@opindex ftree-loop-linear
13398@opindex floop-strip-mine
13399@opindex floop-block
ddf6fe37
AA
13400@item -ftree-loop-linear
13401@itemx -floop-strip-mine
13402@itemx -floop-block
d77de738
ML
13403Perform loop nest optimizations. Same as
13404@option{-floop-nest-optimize}. To use this code transformation, GCC has
13405to be configured with @option{--with-isl} to enable the Graphite loop
13406transformation infrastructure.
13407
d77de738 13408@opindex fgraphite-identity
ddf6fe37 13409@item -fgraphite-identity
d77de738
ML
13410Enable the identity transformation for graphite. For every SCoP we generate
13411the polyhedral representation and transform it back to gimple. Using
13412@option{-fgraphite-identity} we can check the costs or benefits of the
13413GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13414are also performed by the code generator isl, like index splitting and
13415dead code elimination in loops.
13416
d77de738 13417@opindex floop-nest-optimize
ddf6fe37 13418@item -floop-nest-optimize
d77de738
ML
13419Enable the isl based loop nest optimizer. This is a generic loop nest
13420optimizer based on the Pluto optimization algorithms. It calculates a loop
13421structure optimized for data-locality and parallelism. This option
13422is experimental.
13423
d77de738 13424@opindex floop-parallelize-all
ddf6fe37 13425@item -floop-parallelize-all
d77de738
ML
13426Use the Graphite data dependence analysis to identify loops that can
13427be parallelized. Parallelize all the loops that can be analyzed to
13428not contain loop carried dependences without checking that it is
13429profitable to parallelize the loops.
13430
d77de738 13431@opindex ftree-coalesce-vars
ddf6fe37 13432@item -ftree-coalesce-vars
d77de738
ML
13433While transforming the program out of the SSA representation, attempt to
13434reduce copying by coalescing versions of different user-defined
13435variables, instead of just compiler temporaries. This may severely
13436limit the ability to debug an optimized program compiled with
13437@option{-fno-var-tracking-assignments}. In the negated form, this flag
13438prevents SSA coalescing of user variables. This option is enabled by
13439default if optimization is enabled, and it does very little otherwise.
13440
d77de738 13441@opindex ftree-loop-if-convert
ddf6fe37 13442@item -ftree-loop-if-convert
d77de738
ML
13443Attempt to transform conditional jumps in the innermost loops to
13444branch-less equivalents. The intent is to remove control-flow from
13445the innermost loops in order to improve the ability of the
13446vectorization pass to handle these loops. This is enabled by default
13447if vectorization is enabled.
13448
d77de738 13449@opindex ftree-loop-distribution
ddf6fe37 13450@item -ftree-loop-distribution
d77de738
ML
13451Perform loop distribution. This flag can improve cache performance on
13452big loop bodies and allow further loop optimizations, like
13453parallelization or vectorization, to take place. For example, the loop
13454@smallexample
13455DO I = 1, N
13456 A(I) = B(I) + C
13457 D(I) = E(I) * F
13458ENDDO
13459@end smallexample
13460is transformed to
13461@smallexample
13462DO I = 1, N
13463 A(I) = B(I) + C
13464ENDDO
13465DO I = 1, N
13466 D(I) = E(I) * F
13467ENDDO
13468@end smallexample
13469This flag is enabled by default at @option{-O3}.
13470It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13471
d77de738 13472@opindex ftree-loop-distribute-patterns
ddf6fe37 13473@item -ftree-loop-distribute-patterns
d77de738
ML
13474Perform loop distribution of patterns that can be code generated with
13475calls to a library. This flag is enabled by default at @option{-O2} and
13476higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13477
13478This pass distributes the initialization loops and generates a call to
13479memset zero. For example, the loop
13480@smallexample
13481DO I = 1, N
13482 A(I) = 0
13483 B(I) = A(I) + I
13484ENDDO
13485@end smallexample
13486is transformed to
13487@smallexample
13488DO I = 1, N
13489 A(I) = 0
13490ENDDO
13491DO I = 1, N
13492 B(I) = A(I) + I
13493ENDDO
13494@end smallexample
13495and the initialization loop is transformed into a call to memset zero.
13496This flag is enabled by default at @option{-O3}.
13497It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13498
d77de738 13499@opindex floop-interchange
ddf6fe37 13500@item -floop-interchange
d77de738
ML
13501Perform loop interchange outside of graphite. This flag can improve cache
13502performance on loop nest and allow further loop optimizations, like
13503vectorization, to take place. For example, the loop
13504@smallexample
13505for (int i = 0; i < N; i++)
13506 for (int j = 0; j < N; j++)
13507 for (int k = 0; k < N; k++)
13508 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13509@end smallexample
13510is transformed to
13511@smallexample
13512for (int i = 0; i < N; i++)
13513 for (int k = 0; k < N; k++)
13514 for (int j = 0; j < N; j++)
13515 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13516@end smallexample
13517This flag is enabled by default at @option{-O3}.
13518It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13519
d77de738 13520@opindex floop-unroll-and-jam
ddf6fe37 13521@item -floop-unroll-and-jam
d77de738
ML
13522Apply unroll and jam transformations on feasible loops. In a loop
13523nest this unrolls the outer loop by some factor and fuses the resulting
13524multiple inner loops. This flag is enabled by default at @option{-O3}.
13525It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13526
d77de738 13527@opindex ftree-loop-im
ddf6fe37 13528@item -ftree-loop-im
d77de738
ML
13529Perform loop invariant motion on trees. This pass moves only invariants that
13530are hard to handle at RTL level (function calls, operations that expand to
13531nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13532operands of conditions that are invariant out of the loop, so that we can use
13533just trivial invariantness analysis in loop unswitching. The pass also includes
13534store motion.
13535
d77de738 13536@opindex ftree-loop-ivcanon
ddf6fe37 13537@item -ftree-loop-ivcanon
d77de738
ML
13538Create a canonical counter for number of iterations in loops for which
13539determining number of iterations requires complicated analysis. Later
13540optimizations then may determine the number easily. Useful especially
13541in connection with unrolling.
13542
d77de738 13543@opindex ftree-scev-cprop
ddf6fe37 13544@item -ftree-scev-cprop
d77de738
ML
13545Perform final value replacement. If a variable is modified in a loop
13546in such a way that its value when exiting the loop can be determined using
13547only its initial value and the number of loop iterations, replace uses of
13548the final value by such a computation, provided it is sufficiently cheap.
13549This reduces data dependencies and may allow further simplifications.
13550Enabled by default at @option{-O1} and higher.
13551
d77de738 13552@opindex fivopts
ddf6fe37 13553@item -fivopts
d77de738
ML
13554Perform induction variable optimizations (strength reduction, induction
13555variable merging and induction variable elimination) on trees.
13556
d77de738 13557@opindex ftree-parallelize-loops
ddf6fe37 13558@item -ftree-parallelize-loops=n
d77de738
ML
13559Parallelize loops, i.e., split their iteration space to run in n threads.
13560This is only possible for loops whose iterations are independent
13561and can be arbitrarily reordered. The optimization is only
13562profitable on multiprocessor machines, for loops that are CPU-intensive,
13563rather than constrained e.g.@: by memory bandwidth. This option
13564implies @option{-pthread}, and thus is only supported on targets
13565that have support for @option{-pthread}.
13566
d77de738 13567@opindex ftree-pta
ddf6fe37 13568@item -ftree-pta
d77de738
ML
13569Perform function-local points-to analysis on trees. This flag is
13570enabled by default at @option{-O1} and higher, except for @option{-Og}.
13571
d77de738 13572@opindex ftree-sra
ddf6fe37 13573@item -ftree-sra
d77de738
ML
13574Perform scalar replacement of aggregates. This pass replaces structure
13575references with scalars to prevent committing structures to memory too
13576early. This flag is enabled by default at @option{-O1} and higher,
13577except for @option{-Og}.
13578
d77de738 13579@opindex fstore-merging
ddf6fe37 13580@item -fstore-merging
d77de738
ML
13581Perform merging of narrow stores to consecutive memory addresses. This pass
13582merges contiguous stores of immediate values narrower than a word into fewer
13583wider stores to reduce the number of instructions. This is enabled by default
13584at @option{-O2} and higher as well as @option{-Os}.
13585
d77de738 13586@opindex ftree-ter
ddf6fe37 13587@item -ftree-ter
d77de738
ML
13588Perform temporary expression replacement during the SSA->normal phase. Single
13589use/single def temporaries are replaced at their use location with their
13590defining expression. This results in non-GIMPLE code, but gives the expanders
13591much more complex trees to work on resulting in better RTL generation. This is
13592enabled by default at @option{-O1} and higher.
13593
d77de738 13594@opindex ftree-slsr
ddf6fe37 13595@item -ftree-slsr
d77de738
ML
13596Perform straight-line strength reduction on trees. This recognizes related
13597expressions involving multiplications and replaces them by less expensive
13598calculations when possible. This is enabled by default at @option{-O1} and
13599higher.
13600
d77de738 13601@opindex ftree-vectorize
ddf6fe37 13602@item -ftree-vectorize
d77de738
ML
13603Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13604and @option{-ftree-slp-vectorize} if not explicitly specified.
13605
d77de738 13606@opindex ftree-loop-vectorize
ddf6fe37 13607@item -ftree-loop-vectorize
d77de738
ML
13608Perform loop vectorization on trees. This flag is enabled by default at
13609@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13610and @option{-fauto-profile}.
13611
d77de738 13612@opindex ftree-slp-vectorize
ddf6fe37 13613@item -ftree-slp-vectorize
d77de738
ML
13614Perform basic block vectorization on trees. This flag is enabled by default at
13615@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13616and @option{-fauto-profile}.
13617
d77de738 13618@opindex ftrivial-auto-var-init
ddf6fe37 13619@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13620Initialize automatic variables with either a pattern or with zeroes to increase
13621the security and predictability of a program by preventing uninitialized memory
13622disclosure and use.
13623GCC still considers an automatic variable that doesn't have an explicit
13624initializer as uninitialized, @option{-Wuninitialized} and
13625@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13626warning messages on such automatic variables and the compiler will
13627perform optimization as if the variable were uninitialized.
d77de738
ML
13628With this option, GCC will also initialize any padding of automatic variables
13629that have structure or union types to zeroes.
13630However, the current implementation cannot initialize automatic variables that
13631are declared between the controlling expression and the first case of a
13632@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13633such cases.
13634
13635The three values of @var{choice} are:
13636
13637@itemize @bullet
13638@item
13639@samp{uninitialized} doesn't initialize any automatic variables.
13640This is C and C++'s default.
13641
13642@item
13643@samp{pattern} Initialize automatic variables with values which will likely
13644transform logic bugs into crashes down the line, are easily recognized in a
13645crash dump and without being values that programmers can rely on for useful
13646program semantics.
13647The current value is byte-repeatable pattern with byte "0xFE".
13648The values used for pattern initialization might be changed in the future.
13649
13650@item
13651@samp{zero} Initialize automatic variables with zeroes.
13652@end itemize
13653
13654The default is @samp{uninitialized}.
13655
13656You can control this behavior for a specific variable by using the variable
13657attribute @code{uninitialized} (@pxref{Variable Attributes}).
13658
d77de738 13659@opindex fvect-cost-model
ddf6fe37 13660@item -fvect-cost-model=@var{model}
d77de738
ML
13661Alter the cost model used for vectorization. The @var{model} argument
13662should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13663@samp{very-cheap}.
13664With the @samp{unlimited} model the vectorized code-path is assumed
13665to be profitable while with the @samp{dynamic} model a runtime check
13666guards the vectorized code-path to enable it only for iteration
13667counts that will likely execute faster than when executing the original
13668scalar loop. The @samp{cheap} model disables vectorization of
13669loops where doing so would be cost prohibitive for example due to
13670required runtime checks for data dependence or alignment but otherwise
13671is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13672allows vectorization if the vector code would entirely replace the
13673scalar code that is being vectorized. For example, if each iteration
13674of a vectorized loop would only be able to handle exactly four iterations
13675of the scalar loop, the @samp{very-cheap} model would only allow
13676vectorization if the scalar iteration count is known to be a multiple
13677of four.
13678
13679The default cost model depends on other optimization flags and is
13680either @samp{dynamic} or @samp{cheap}.
13681
d77de738 13682@opindex fsimd-cost-model
ddf6fe37 13683@item -fsimd-cost-model=@var{model}
d77de738
ML
13684Alter the cost model used for vectorization of loops marked with the OpenMP
13685simd directive. The @var{model} argument should be one of
13686@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13687have the same meaning as described in @option{-fvect-cost-model} and by
13688default a cost model defined with @option{-fvect-cost-model} is used.
13689
d77de738 13690@opindex ftree-vrp
ddf6fe37 13691@item -ftree-vrp
d77de738
ML
13692Perform Value Range Propagation on trees. This is similar to the
13693constant propagation pass, but instead of values, ranges of values are
13694propagated. This allows the optimizers to remove unnecessary range
13695checks like array bound checks and null pointer checks. This is
13696enabled by default at @option{-O2} and higher. Null pointer check
13697elimination is only done if @option{-fdelete-null-pointer-checks} is
13698enabled.
13699
d77de738 13700@opindex fsplit-paths
ddf6fe37 13701@item -fsplit-paths
d77de738
ML
13702Split paths leading to loop backedges. This can improve dead code
13703elimination and common subexpression elimination. This is enabled by
13704default at @option{-O3} and above.
13705
d77de738 13706@opindex fsplit-ivs-in-unroller
ddf6fe37 13707@item -fsplit-ivs-in-unroller
d77de738
ML
13708Enables expression of values of induction variables in later iterations
13709of the unrolled loop using the value in the first iteration. This breaks
13710long dependency chains, thus improving efficiency of the scheduling passes.
13711
13712A combination of @option{-fweb} and CSE is often sufficient to obtain the
13713same effect. However, that is not reliable in cases where the loop body
13714is more complicated than a single basic block. It also does not work at all
13715on some architectures due to restrictions in the CSE pass.
13716
13717This optimization is enabled by default.
13718
d77de738 13719@opindex fvariable-expansion-in-unroller
ddf6fe37 13720@item -fvariable-expansion-in-unroller
d77de738
ML
13721With this option, the compiler creates multiple copies of some
13722local variables when unrolling a loop, which can result in superior code.
13723
13724This optimization is enabled by default for PowerPC targets, but disabled
13725by default otherwise.
13726
d77de738 13727@opindex fpartial-inlining
ddf6fe37 13728@item -fpartial-inlining
d77de738
ML
13729Inline parts of functions. This option has any effect only
13730when inlining itself is turned on by the @option{-finline-functions}
13731or @option{-finline-small-functions} options.
13732
13733Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13734
d77de738 13735@opindex fpredictive-commoning
ddf6fe37 13736@item -fpredictive-commoning
d77de738
ML
13737Perform predictive commoning optimization, i.e., reusing computations
13738(especially memory loads and stores) performed in previous
13739iterations of loops.
13740
13741This option is enabled at level @option{-O3}.
13742It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13743
d77de738 13744@opindex fprefetch-loop-arrays
ddf6fe37 13745@item -fprefetch-loop-arrays
d77de738
ML
13746If supported by the target machine, generate instructions to prefetch
13747memory to improve the performance of loops that access large arrays.
13748
13749This option may generate better or worse code; results are highly
13750dependent on the structure of loops within the source code.
13751
13752Disabled at level @option{-Os}.
13753
d77de738
ML
13754@opindex fno-printf-return-value
13755@opindex fprintf-return-value
ddf6fe37 13756@item -fno-printf-return-value
d77de738
ML
13757Do not substitute constants for known return value of formatted output
13758functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13759@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13760transformation allows GCC to optimize or even eliminate branches based
13761on the known return value of these functions called with arguments that
13762are either constant, or whose values are known to be in a range that
13763makes determining the exact return value possible. For example, when
13764@option{-fprintf-return-value} is in effect, both the branch and the
13765body of the @code{if} statement (but not the call to @code{snprint})
13766can be optimized away when @code{i} is a 32-bit or smaller integer
13767because the return value is guaranteed to be at most 8.
13768
13769@smallexample
13770char buf[9];
13771if (snprintf (buf, "%08x", i) >= sizeof buf)
13772 @dots{}
13773@end smallexample
13774
13775The @option{-fprintf-return-value} option relies on other optimizations
13776and yields best results with @option{-O2} and above. It works in tandem
13777with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13778options. The @option{-fprintf-return-value} option is enabled by default.
13779
d77de738
ML
13780@opindex fno-peephole
13781@opindex fpeephole
13782@opindex fno-peephole2
13783@opindex fpeephole2
ddf6fe37
AA
13784@item -fno-peephole
13785@itemx -fno-peephole2
d77de738
ML
13786Disable any machine-specific peephole optimizations. The difference
13787between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13788are implemented in the compiler; some targets use one, some use the
13789other, a few use both.
13790
13791@option{-fpeephole} is enabled by default.
13792@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13793
d77de738
ML
13794@opindex fno-guess-branch-probability
13795@opindex fguess-branch-probability
ddf6fe37 13796@item -fno-guess-branch-probability
d77de738
ML
13797Do not guess branch probabilities using heuristics.
13798
13799GCC uses heuristics to guess branch probabilities if they are
13800not provided by profiling feedback (@option{-fprofile-arcs}). These
13801heuristics are based on the control flow graph. If some branch probabilities
13802are specified by @code{__builtin_expect}, then the heuristics are
13803used to guess branch probabilities for the rest of the control flow graph,
13804taking the @code{__builtin_expect} info into account. The interactions
13805between the heuristics and @code{__builtin_expect} can be complex, and in
13806some cases, it may be useful to disable the heuristics so that the effects
13807of @code{__builtin_expect} are easier to understand.
13808
13809It is also possible to specify expected probability of the expression
13810with @code{__builtin_expect_with_probability} built-in function.
13811
13812The default is @option{-fguess-branch-probability} at levels
13813@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13814
d77de738 13815@opindex freorder-blocks
ddf6fe37 13816@item -freorder-blocks
d77de738
ML
13817Reorder basic blocks in the compiled function in order to reduce number of
13818taken branches and improve code locality.
13819
13820Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13821
d77de738 13822@opindex freorder-blocks-algorithm
ddf6fe37 13823@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13824Use the specified algorithm for basic block reordering. The
13825@var{algorithm} argument can be @samp{simple}, which does not increase
13826code size (except sometimes due to secondary effects like alignment),
13827or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13828put all often executed code together, minimizing the number of branches
13829executed by making extra copies of code.
13830
13831The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13832@samp{stc} at levels @option{-O2}, @option{-O3}.
13833
d77de738 13834@opindex freorder-blocks-and-partition
ddf6fe37 13835@item -freorder-blocks-and-partition
d77de738
ML
13836In addition to reordering basic blocks in the compiled function, in order
13837to reduce number of taken branches, partitions hot and cold basic blocks
13838into separate sections of the assembly and @file{.o} files, to improve
13839paging and cache locality performance.
13840
13841This optimization is automatically turned off in the presence of
13842exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13843section attribute and on any architecture that does not support named
13844sections. When @option{-fsplit-stack} is used this option is not
13845enabled by default (to avoid linker errors), but may be enabled
13846explicitly (if using a working linker).
13847
13848Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13849
d77de738 13850@opindex freorder-functions
ddf6fe37 13851@item -freorder-functions
d77de738
ML
13852Reorder functions in the object file in order to
13853improve code locality. This is implemented by using special
13854subsections @code{.text.hot} for most frequently executed functions and
13855@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13856the linker so object file format must support named sections and linker must
13857place them in a reasonable way.
13858
13859This option isn't effective unless you either provide profile feedback
13860(see @option{-fprofile-arcs} for details) or manually annotate functions with
13861@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13862
13863Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13864
d77de738 13865@opindex fstrict-aliasing
ddf6fe37 13866@item -fstrict-aliasing
d77de738
ML
13867Allow the compiler to assume the strictest aliasing rules applicable to
13868the language being compiled. For C (and C++), this activates
13869optimizations based on the type of expressions. In particular, an
13870object of one type is assumed never to reside at the same address as an
13871object of a different type, unless the types are almost the same. For
13872example, an @code{unsigned int} can alias an @code{int}, but not a
13873@code{void*} or a @code{double}. A character type may alias any other
13874type.
13875
13876@anchor{Type-punning}Pay special attention to code like this:
13877@smallexample
13878union a_union @{
13879 int i;
13880 double d;
13881@};
13882
13883int f() @{
13884 union a_union t;
13885 t.d = 3.0;
13886 return t.i;
13887@}
13888@end smallexample
13889The practice of reading from a different union member than the one most
13890recently written to (called ``type-punning'') is common. Even with
13891@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13892is accessed through the union type. So, the code above works as
13893expected. @xref{Structures unions enumerations and bit-fields
13894implementation}. However, this code might not:
13895@smallexample
13896int f() @{
13897 union a_union t;
13898 int* ip;
13899 t.d = 3.0;
13900 ip = &t.i;
13901 return *ip;
13902@}
13903@end smallexample
13904
13905Similarly, access by taking the address, casting the resulting pointer
13906and dereferencing the result has undefined behavior, even if the cast
13907uses a union type, e.g.:
13908@smallexample
13909int f() @{
13910 double d = 3.0;
13911 return ((union a_union *) &d)->i;
13912@}
13913@end smallexample
13914
13915The @option{-fstrict-aliasing} option is enabled at levels
13916@option{-O2}, @option{-O3}, @option{-Os}.
13917
d77de738 13918@opindex fipa-strict-aliasing
ddf6fe37 13919@item -fipa-strict-aliasing
d77de738
ML
13920Controls whether rules of @option{-fstrict-aliasing} are applied across
13921function boundaries. Note that if multiple functions gets inlined into a
13922single function the memory accesses are no longer considered to be crossing a
13923function boundary.
13924
13925The @option{-fipa-strict-aliasing} option is enabled by default and is
13926effective only in combination with @option{-fstrict-aliasing}.
13927
ddf6fe37 13928@opindex falign-functions
d77de738
ML
13929@item -falign-functions
13930@itemx -falign-functions=@var{n}
13931@itemx -falign-functions=@var{n}:@var{m}
13932@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13933@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13934Align the start of functions to the next power-of-two greater than or
13935equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13936least the first @var{m} bytes of the function can be fetched by the CPU
13937without crossing an @var{n}-byte alignment boundary.
13938
13939If @var{m} is not specified, it defaults to @var{n}.
13940
13941Examples: @option{-falign-functions=32} aligns functions to the next
1394232-byte boundary, @option{-falign-functions=24} aligns to the next
1394332-byte boundary only if this can be done by skipping 23 bytes or less,
13944@option{-falign-functions=32:7} aligns to the next
1394532-byte boundary only if this can be done by skipping 6 bytes or less.
13946
13947The second pair of @var{n2}:@var{m2} values allows you to specify
13948a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13949the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13950otherwise aligns to the next 32-byte boundary if this can be done
13951by skipping 2 bytes or less.
13952If @var{m2} is not specified, it defaults to @var{n2}.
13953
13954Some assemblers only support this flag when @var{n} is a power of two;
13955in that case, it is rounded up.
13956
13957@option{-fno-align-functions} and @option{-falign-functions=1} are
13958equivalent and mean that functions are not aligned.
13959
13960If @var{n} is not specified or is zero, use a machine-dependent default.
13961The maximum allowed @var{n} option value is 65536.
13962
13963Enabled at levels @option{-O2}, @option{-O3}.
13964
13965@item -flimit-function-alignment
13966If this option is enabled, the compiler tries to avoid unnecessarily
13967overaligning functions. It attempts to instruct the assembler to align
13968by the amount specified by @option{-falign-functions}, but not to
13969skip more bytes than the size of the function.
13970
ddf6fe37 13971@opindex falign-labels
d77de738
ML
13972@item -falign-labels
13973@itemx -falign-labels=@var{n}
13974@itemx -falign-labels=@var{n}:@var{m}
13975@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13976@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13977Align all branch targets to a power-of-two boundary.
13978
13979Parameters of this option are analogous to the @option{-falign-functions} option.
13980@option{-fno-align-labels} and @option{-falign-labels=1} are
13981equivalent and mean that labels are not aligned.
13982
13983If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13984are greater than this value, then their values are used instead.
13985
13986If @var{n} is not specified or is zero, use a machine-dependent default
13987which is very likely to be @samp{1}, meaning no alignment.
13988The maximum allowed @var{n} option value is 65536.
13989
13990Enabled at levels @option{-O2}, @option{-O3}.
13991
ddf6fe37 13992@opindex falign-loops
d77de738
ML
13993@item -falign-loops
13994@itemx -falign-loops=@var{n}
13995@itemx -falign-loops=@var{n}:@var{m}
13996@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13997@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13998Align loops to a power-of-two boundary. If the loops are executed
13999many times, this makes up for any execution of the dummy padding
14000instructions.
14001
14002If @option{-falign-labels} is greater than this value, then its value
14003is used instead.
14004
14005Parameters of this option are analogous to the @option{-falign-functions} option.
14006@option{-fno-align-loops} and @option{-falign-loops=1} are
14007equivalent and mean that loops are not aligned.
14008The maximum allowed @var{n} option value is 65536.
14009
14010If @var{n} is not specified or is zero, use a machine-dependent default.
14011
14012Enabled at levels @option{-O2}, @option{-O3}.
14013
ddf6fe37 14014@opindex falign-jumps
d77de738
ML
14015@item -falign-jumps
14016@itemx -falign-jumps=@var{n}
14017@itemx -falign-jumps=@var{n}:@var{m}
14018@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14019@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14020Align branch targets to a power-of-two boundary, for branch targets
14021where the targets can only be reached by jumping. In this case,
14022no dummy operations need be executed.
14023
14024If @option{-falign-labels} is greater than this value, then its value
14025is used instead.
14026
14027Parameters of this option are analogous to the @option{-falign-functions} option.
14028@option{-fno-align-jumps} and @option{-falign-jumps=1} are
14029equivalent and mean that loops are not aligned.
14030
14031If @var{n} is not specified or is zero, use a machine-dependent default.
14032The maximum allowed @var{n} option value is 65536.
14033
14034Enabled at levels @option{-O2}, @option{-O3}.
14035
d77de738 14036@opindex fno-allocation-dce
ddf6fe37 14037@item -fno-allocation-dce
d77de738
ML
14038Do not remove unused C++ allocations in dead code elimination.
14039
d77de738 14040@opindex fallow-store-data-races
ddf6fe37 14041@item -fallow-store-data-races
d77de738
ML
14042Allow the compiler to perform optimizations that may introduce new data races
14043on stores, without proving that the variable cannot be concurrently accessed
14044by other threads. Does not affect optimization of local data. It is safe to
14045use this option if it is known that global data will not be accessed by
14046multiple threads.
14047
14048Examples of optimizations enabled by @option{-fallow-store-data-races} include
14049hoisting or if-conversions that may cause a value that was already in memory
14050to be re-written with that same value. Such re-writing is safe in a single
14051threaded context but may be unsafe in a multi-threaded context. Note that on
14052some processors, if-conversions may be required in order to enable
14053vectorization.
14054
14055Enabled at level @option{-Ofast}.
14056
d77de738 14057@opindex funit-at-a-time
ddf6fe37 14058@item -funit-at-a-time
d77de738
ML
14059This option is left for compatibility reasons. @option{-funit-at-a-time}
14060has no effect, while @option{-fno-unit-at-a-time} implies
14061@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
14062
14063Enabled by default.
14064
d77de738
ML
14065@opindex fno-toplevel-reorder
14066@opindex ftoplevel-reorder
ddf6fe37 14067@item -fno-toplevel-reorder
d77de738
ML
14068Do not reorder top-level functions, variables, and @code{asm}
14069statements. Output them in the same order that they appear in the
14070input file. When this option is used, unreferenced static variables
14071are not removed. This option is intended to support existing code
14072that relies on a particular ordering. For new code, it is better to
14073use attributes when possible.
14074
14075@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
14076also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
14077Additionally @option{-fno-toplevel-reorder} implies
14078@option{-fno-section-anchors}.
14079
d77de738 14080@opindex funreachable-traps
ddf6fe37 14081@item -funreachable-traps
d77de738
ML
14082With this option, the compiler turns calls to
14083@code{__builtin_unreachable} into traps, instead of using them for
14084optimization. This also affects any such calls implicitly generated
14085by the compiler.
14086
14087This option has the same effect as @option{-fsanitize=unreachable
14088-fsanitize-trap=unreachable}, but does not affect the values of those
14089options. If @option{-fsanitize=unreachable} is enabled, that option
14090takes priority over this one.
14091
14092This option is enabled by default at @option{-O0} and @option{-Og}.
14093
d77de738 14094@opindex fweb
ddf6fe37 14095@item -fweb
d77de738
ML
14096Constructs webs as commonly used for register allocation purposes and assign
14097each web individual pseudo register. This allows the register allocation pass
14098to operate on pseudos directly, but also strengthens several other optimization
14099passes, such as CSE, loop optimizer and trivial dead code remover. It can,
14100however, make debugging impossible, since variables no longer stay in a
14101``home register''.
14102
14103Enabled by default with @option{-funroll-loops}.
14104
d77de738 14105@opindex fwhole-program
ddf6fe37 14106@item -fwhole-program
d77de738
ML
14107Assume that the current compilation unit represents the whole program being
14108compiled. All public functions and variables with the exception of @code{main}
14109and those merged by attribute @code{externally_visible} become static functions
14110and in effect are optimized more aggressively by interprocedural optimizers.
14111
39ebd3a9
JH
14112With @option{-flto} this option has a limited use. In most cases the
14113precise list of symbols used or exported from the binary is known the
14114resolution info passed to the link-time optimizer by the linker plugin. It is
14115still useful if no linker plugin is used or during incremental link step when
14116final code is produced (with @option{-flto}
14117@option{-flinker-output=nolto-rel}).
d77de738 14118
d77de738 14119@opindex flto
ddf6fe37 14120@item -flto[=@var{n}]
d77de738
ML
14121This option runs the standard link-time optimizer. When invoked
14122with source code, it generates GIMPLE (one of GCC's internal
14123representations) and writes it to special ELF sections in the object
14124file. When the object files are linked together, all the function
14125bodies are read from these ELF sections and instantiated as if they
14126had been part of the same translation unit.
14127
14128To use the link-time optimizer, @option{-flto} and optimization
14129options should be specified at compile time and during the final link.
14130It is recommended that you compile all the files participating in the
14131same link with the same options and also specify those options at
14132link time.
14133For example:
14134
14135@smallexample
14136gcc -c -O2 -flto foo.c
14137gcc -c -O2 -flto bar.c
14138gcc -o myprog -flto -O2 foo.o bar.o
14139@end smallexample
14140
14141The first two invocations to GCC save a bytecode representation
14142of GIMPLE into special ELF sections inside @file{foo.o} and
14143@file{bar.o}. The final invocation reads the GIMPLE bytecode from
14144@file{foo.o} and @file{bar.o}, merges the two files into a single
14145internal image, and compiles the result as usual. Since both
14146@file{foo.o} and @file{bar.o} are merged into a single image, this
14147causes all the interprocedural analyses and optimizations in GCC to
14148work across the two files as if they were a single one. This means,
14149for example, that the inliner is able to inline functions in
14150@file{bar.o} into functions in @file{foo.o} and vice-versa.
14151
14152Another (simpler) way to enable link-time optimization is:
14153
14154@smallexample
14155gcc -o myprog -flto -O2 foo.c bar.c
14156@end smallexample
14157
14158The above generates bytecode for @file{foo.c} and @file{bar.c},
14159merges them together into a single GIMPLE representation and optimizes
14160them as usual to produce @file{myprog}.
14161
14162The important thing to keep in mind is that to enable link-time
14163optimizations you need to use the GCC driver to perform the link step.
14164GCC automatically performs link-time optimization if any of the
14165objects involved were compiled with the @option{-flto} command-line option.
14166You can always override
14167the automatic decision to do link-time optimization
14168by passing @option{-fno-lto} to the link command.
14169
14170To make whole program optimization effective, it is necessary to make
14171certain whole program assumptions. The compiler needs to know
14172what functions and variables can be accessed by libraries and runtime
14173outside of the link-time optimized unit. When supported by the linker,
14174the linker plugin (see @option{-fuse-linker-plugin}) passes information
14175to the compiler about used and externally visible symbols. When
14176the linker plugin is not available, @option{-fwhole-program} should be
14177used to allow the compiler to make these assumptions, which leads
14178to more aggressive optimization decisions.
14179
14180When a file is compiled with @option{-flto} without
14181@option{-fuse-linker-plugin}, the generated object file is larger than
14182a regular object file because it contains GIMPLE bytecodes and the usual
14183final code (see @option{-ffat-lto-objects}). This means that
14184object files with LTO information can be linked as normal object
14185files; if @option{-fno-lto} is passed to the linker, no
14186interprocedural optimizations are applied. Note that when
14187@option{-fno-fat-lto-objects} is enabled the compile stage is faster
14188but you cannot perform a regular, non-LTO link on them.
14189
14190When producing the final binary, GCC only
14191applies link-time optimizations to those files that contain bytecode.
14192Therefore, you can mix and match object files and libraries with
14193GIMPLE bytecodes and final object code. GCC automatically selects
14194which files to optimize in LTO mode and which files to link without
14195further processing.
14196
14197Generally, options specified at link time override those
14198specified at compile time, although in some cases GCC attempts to infer
14199link-time options from the settings used to compile the input files.
14200
14201If you do not specify an optimization level option @option{-O} at
14202link time, then GCC uses the highest optimization level
14203used when compiling the object files. Note that it is generally
14204ineffective to specify an optimization level option only at link time and
14205not at compile time, for two reasons. First, compiling without
14206optimization suppresses compiler passes that gather information
14207needed for effective optimization at link time. Second, some early
14208optimization passes can be performed only at compile time and
14209not at link time.
14210
14211There are some code generation flags preserved by GCC when
14212generating bytecodes, as they need to be used during the final link.
14213Currently, the following options and their settings are taken from
14214the first object file that explicitly specifies them:
14215@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14216@option{-fgnu-tm} and all the @option{-m} target flags.
14217
14218The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14219@option{-fPIE} are combined based on the following scheme:
14220
14221@smallexample
14222@option{-fPIC} + @option{-fpic} = @option{-fpic}
14223@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14224@option{-fpic/-fPIC} + (no option) = (no option)
14225@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14226@option{-fpic} + @option{-fPIE} = @option{-fpie}
14227@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14228@end smallexample
14229
14230Certain ABI-changing flags are required to match in all compilation units,
14231and trying to override this at link time with a conflicting value
14232is ignored. This includes options such as @option{-freg-struct-return}
14233and @option{-fpcc-struct-return}.
14234
14235Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14236@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14237are passed through to the link stage and merged conservatively for
14238conflicting translation units. Specifically
14239@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14240precedence; and for example @option{-ffp-contract=off} takes precedence
14241over @option{-ffp-contract=fast}. You can override them at link time.
14242
14243Diagnostic options such as @option{-Wstringop-overflow} are passed
14244through to the link stage and their setting matches that of the
14245compile-step at function granularity. Note that this matters only
14246for diagnostics emitted during optimization. Note that code
14247transforms such as inlining can lead to warnings being enabled
14248or disabled for regions if code not consistent with the setting
14249at compile time.
14250
14251When you need to pass options to the assembler via @option{-Wa} or
14252@option{-Xassembler} make sure to either compile such translation
14253units with @option{-fno-lto} or consistently use the same assembler
14254options on all translation units. You can alternatively also
14255specify assembler options at LTO link time.
14256
14257To enable debug info generation you need to supply @option{-g} at
14258compile time. If any of the input files at link time were built
14259with debug info generation enabled the link will enable debug info
14260generation as well. Any elaborate debug info settings
14261like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14262at the linker command line and mixing different settings in different
14263translation units is discouraged.
14264
14265If LTO encounters objects with C linkage declared with incompatible
14266types in separate translation units to be linked together (undefined
14267behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14268issued. The behavior is still undefined at run time. Similar
14269diagnostics may be raised for other languages.
14270
14271Another feature of LTO is that it is possible to apply interprocedural
14272optimizations on files written in different languages:
14273
14274@smallexample
14275gcc -c -flto foo.c
14276g++ -c -flto bar.cc
14277gfortran -c -flto baz.f90
14278g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14279@end smallexample
14280
14281Notice that the final link is done with @command{g++} to get the C++
14282runtime libraries and @option{-lgfortran} is added to get the Fortran
14283runtime libraries. In general, when mixing languages in LTO mode, you
14284should use the same link command options as when mixing languages in a
14285regular (non-LTO) compilation.
14286
14287If object files containing GIMPLE bytecode are stored in a library archive, say
14288@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14289are using a linker with plugin support. To create static libraries suitable
14290for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14291and @command{ranlib};
14292to show the symbols of object files with GIMPLE bytecode, use
14293@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14294and @command{nm} have been compiled with plugin support. At link time, use the
14295flag @option{-fuse-linker-plugin} to ensure that the library participates in
14296the LTO optimization process:
14297
14298@smallexample
14299gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14300@end smallexample
14301
14302With the linker plugin enabled, the linker extracts the needed
14303GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14304to make them part of the aggregated GIMPLE image to be optimized.
14305
14306If you are not using a linker with plugin support and/or do not
14307enable the linker plugin, then the objects inside @file{libfoo.a}
14308are extracted and linked as usual, but they do not participate
14309in the LTO optimization process. In order to make a static library suitable
14310for both LTO optimization and usual linkage, compile its object files with
14311@option{-flto} @option{-ffat-lto-objects}.
14312
14313Link-time optimizations do not require the presence of the whole program to
14314operate. If the program does not require any symbols to be exported, it is
14315possible to combine @option{-flto} and @option{-fwhole-program} to allow
14316the interprocedural optimizers to use more aggressive assumptions which may
14317lead to improved optimization opportunities.
14318Use of @option{-fwhole-program} is not needed when linker plugin is
14319active (see @option{-fuse-linker-plugin}).
14320
14321The current implementation of LTO makes no
14322attempt to generate bytecode that is portable between different
14323types of hosts. The bytecode files are versioned and there is a
14324strict version check, so bytecode files generated in one version of
14325GCC do not work with an older or newer version of GCC.
14326
14327Link-time optimization does not work well with generation of debugging
14328information on systems other than those using a combination of ELF and
14329DWARF.
14330
14331If you specify the optional @var{n}, the optimization and code
14332generation done at link time is executed in parallel using @var{n}
14333parallel jobs by utilizing an installed @command{make} program. The
14334environment variable @env{MAKE} may be used to override the program
14335used.
14336
14337You can also specify @option{-flto=jobserver} to use GNU make's
14338job server mode to determine the number of parallel jobs. This
14339is useful when the Makefile calling GCC is already executing in parallel.
14340You must prepend a @samp{+} to the command recipe in the parent Makefile
14341for this to work. This option likely only works if @env{MAKE} is
14342GNU make. Even without the option value, GCC tries to automatically
14343detect a running GNU make's job server.
14344
14345Use @option{-flto=auto} to use GNU make's job server, if available,
14346or otherwise fall back to autodetection of the number of CPU threads
14347present in your system.
14348
d77de738 14349@opindex flto-partition
ddf6fe37 14350@item -flto-partition=@var{alg}
d77de738
ML
14351Specify the partitioning algorithm used by the link-time optimizer.
14352The value is either @samp{1to1} to specify a partitioning mirroring
14353the original source files or @samp{balanced} to specify partitioning
14354into equally sized chunks (whenever possible) or @samp{max} to create
14355new partition for every symbol where possible. Specifying @samp{none}
14356as an algorithm disables partitioning and streaming completely.
14357The default value is @samp{balanced}. While @samp{1to1} can be used
14358as an workaround for various code ordering issues, the @samp{max}
14359partitioning is intended for internal testing only.
14360The value @samp{one} specifies that exactly one partition should be
14361used while the value @samp{none} bypasses partitioning and executes
14362the link-time optimization step directly from the WPA phase.
14363
d77de738 14364@opindex flto-compression-level
ddf6fe37 14365@item -flto-compression-level=@var{n}
d77de738
ML
14366This option specifies the level of compression used for intermediate
14367language written to LTO object files, and is only meaningful in
14368conjunction with LTO mode (@option{-flto}). GCC currently supports two
14369LTO compression algorithms. For zstd, valid values are 0 (no compression)
14370to 19 (maximum compression), while zlib supports values from 0 to 9.
14371Values outside this range are clamped to either minimum or maximum
14372of the supported values. If the option is not given,
14373a default balanced compression setting is used.
14374
d77de738 14375@opindex fuse-linker-plugin
ddf6fe37 14376@item -fuse-linker-plugin
d77de738
ML
14377Enables the use of a linker plugin during link-time optimization. This
14378option relies on plugin support in the linker, which is available in gold
14379or in GNU ld 2.21 or newer.
14380
14381This option enables the extraction of object files with GIMPLE bytecode out
14382of library archives. This improves the quality of optimization by exposing
14383more code to the link-time optimizer. This information specifies what
14384symbols can be accessed externally (by non-LTO object or during dynamic
14385linking). Resulting code quality improvements on binaries (and shared
14386libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14387See @option{-flto} for a description of the effect of this flag and how to
14388use it.
14389
14390This option is enabled by default when LTO support in GCC is enabled
14391and GCC was configured for use with
14392a linker supporting plugins (GNU ld 2.21 or newer or gold).
14393
d77de738 14394@opindex ffat-lto-objects
ddf6fe37 14395@item -ffat-lto-objects
d77de738
ML
14396Fat LTO objects are object files that contain both the intermediate language
14397and the object code. This makes them usable for both LTO linking and normal
14398linking. This option is effective only when compiling with @option{-flto}
14399and is ignored at link time.
14400
14401@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14402requires the complete toolchain to be aware of LTO. It requires a linker with
14403linker plugin support for basic functionality. Additionally,
14404@command{nm}, @command{ar} and @command{ranlib}
14405need to support linker plugins to allow a full-featured build environment
14406(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14407@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14408to these tools. With non fat LTO makefiles need to be modified to use them.
14409
14410Note that modern binutils provide plugin auto-load mechanism.
14411Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14412effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14413@command{gcc-ranlib}).
14414
14415The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14416support.
14417
d77de738 14418@opindex fcompare-elim
ddf6fe37 14419@item -fcompare-elim
d77de738
ML
14420After register allocation and post-register allocation instruction splitting,
14421identify arithmetic instructions that compute processor flags similar to a
14422comparison operation based on that arithmetic. If possible, eliminate the
14423explicit comparison operation.
14424
14425This pass only applies to certain targets that cannot explicitly represent
14426the comparison operation before register allocation is complete.
14427
14428Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14429
04c9cf5c
MT
14430@opindex ffold-mem-offsets
14431@item -ffold-mem-offsets
14432@itemx -fno-fold-mem-offsets
14433Try to eliminate add instructions by folding them in memory loads/stores.
14434
14435Enabled at levels @option{-O2}, @option{-O3}.
14436
d77de738 14437@opindex fcprop-registers
ddf6fe37 14438@item -fcprop-registers
d77de738
ML
14439After register allocation and post-register allocation instruction splitting,
14440perform a copy-propagation pass to try to reduce scheduling dependencies
14441and occasionally eliminate the copy.
14442
14443Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14444
d77de738 14445@opindex fprofile-correction
ddf6fe37 14446@item -fprofile-correction
d77de738
ML
14447Profiles collected using an instrumented binary for multi-threaded programs may
14448be inconsistent due to missed counter updates. When this option is specified,
14449GCC uses heuristics to correct or smooth out such inconsistencies. By
14450default, GCC emits an error message when an inconsistent profile is detected.
14451
14452This option is enabled by @option{-fauto-profile}.
14453
d77de738 14454@opindex fprofile-partial-training
ddf6fe37 14455@item -fprofile-partial-training
d77de738
ML
14456With @code{-fprofile-use} all portions of programs not executed during train
14457run are optimized agressively for size rather than speed. In some cases it is
14458not practical to train all possible hot paths in the program. (For
14459example, program may contain functions specific for a given hardware and
14460trianing may not cover all hardware configurations program is run on.) With
14461@code{-fprofile-partial-training} profile feedback will be ignored for all
14462functions not executed during the train run leading them to be optimized as if
14463they were compiled without profile feedback. This leads to better performance
14464when train run is not representative but also leads to significantly bigger
14465code.
14466
ddf6fe37 14467@opindex fprofile-use
d77de738
ML
14468@item -fprofile-use
14469@itemx -fprofile-use=@var{path}
d77de738
ML
14470Enable profile feedback-directed optimizations,
14471and the following optimizations, many of which
14472are generally profitable only with profile feedback available:
14473
43b72ede
AA
14474@gccoptlist{-fbranch-probabilities -fprofile-values
14475-funroll-loops -fpeel-loops -ftracer -fvpt
14476-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14477-fpredictive-commoning -fsplit-loops -funswitch-loops
14478-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14479-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14480-fprofile-reorder-functions}
14481
14482Before you can use this option, you must first generate profiling information.
14483@xref{Instrumentation Options}, for information about the
14484@option{-fprofile-generate} option.
14485
14486By default, GCC emits an error message if the feedback profiles do not
14487match the source code. This error can be turned into a warning by using
14488@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14489optimized code. Additionally, by default, GCC also emits a warning message if
14490the feedback profiles do not exist (see @option{-Wmissing-profile}).
14491
14492If @var{path} is specified, GCC looks at the @var{path} to find
14493the profile feedback data files. See @option{-fprofile-dir}.
14494
ddf6fe37 14495@opindex fauto-profile
d77de738
ML
14496@item -fauto-profile
14497@itemx -fauto-profile=@var{path}
d77de738
ML
14498Enable sampling-based feedback-directed optimizations,
14499and the following optimizations,
14500many of which are generally profitable only with profile feedback available:
14501
43b72ede
AA
14502@gccoptlist{-fbranch-probabilities -fprofile-values
14503-funroll-loops -fpeel-loops -ftracer -fvpt
14504-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14505-fpredictive-commoning -fsplit-loops -funswitch-loops
14506-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14507-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14508-fprofile-correction}
14509
14510@var{path} is the name of a file containing AutoFDO profile information.
14511If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14512
14513Producing an AutoFDO profile data file requires running your program
14514with the @command{perf} utility on a supported GNU/Linux target system.
14515For more information, see @uref{https://perf.wiki.kernel.org/}.
14516
14517E.g.
14518@smallexample
14519perf record -e br_inst_retired:near_taken -b -o perf.data \
14520 -- your_program
14521@end smallexample
14522
14523Then use the @command{create_gcov} tool to convert the raw profile data
14524to a format that can be used by GCC.@ You must also supply the
14525unstripped binary for your program to this tool.
14526See @uref{https://github.com/google/autofdo}.
14527
14528E.g.
14529@smallexample
14530create_gcov --binary=your_program.unstripped --profile=perf.data \
14531 --gcov=profile.afdo
14532@end smallexample
14533@end table
14534
14535The following options control compiler behavior regarding floating-point
14536arithmetic. These options trade off between speed and
14537correctness. All must be specifically enabled.
14538
14539@table @gcctabopt
d77de738 14540@opindex ffloat-store
ddf6fe37 14541@item -ffloat-store
d77de738
ML
14542Do not store floating-point variables in registers, and inhibit other
14543options that might change whether a floating-point value is taken from a
14544register or memory.
14545
14546@cindex floating-point precision
14547This option prevents undesirable excess precision on machines such as
14548the 68000 where the floating registers (of the 68881) keep more
14549precision than a @code{double} is supposed to have. Similarly for the
14550x86 architecture. For most programs, the excess precision does only
14551good, but a few programs rely on the precise definition of IEEE floating
14552point. Use @option{-ffloat-store} for such programs, after modifying
14553them to store all pertinent intermediate computations into variables.
14554
d77de738 14555@opindex fexcess-precision
ddf6fe37 14556@item -fexcess-precision=@var{style}
d77de738
ML
14557This option allows further control over excess precision on machines
14558where floating-point operations occur in a format with more precision or
14559range than the IEEE standard and interchange floating-point types. By
14560default, @option{-fexcess-precision=fast} is in effect; this means that
14561operations may be carried out in a wider precision than the types specified
14562in the source if that would result in faster code, and it is unpredictable
14563when rounding to the types specified in the source code takes place.
14564When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14565then excess precision follows the rules specified in ISO C99 or C++; in particular,
14566both casts and assignments cause values to be rounded to their
14567semantic types (whereas @option{-ffloat-store} only affects
14568assignments). This option is enabled by default for C or C++ if a strict
14569conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14570@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14571regardless of whether a strict conformance option is used.
14572
14573@opindex mfpmath
14574@option{-fexcess-precision=standard} is not implemented for languages
14575other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14576or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14577semantics apply without excess precision, and in the latter, rounding
14578is unpredictable.
14579
d77de738 14580@opindex ffast-math
ddf6fe37 14581@item -ffast-math
d77de738
ML
14582Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14583@option{-ffinite-math-only}, @option{-fno-rounding-math},
14584@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14585@option{-fexcess-precision=fast}.
14586
14587This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14588
14589This option is not turned on by any @option{-O} option besides
14590@option{-Ofast} since it can result in incorrect output for programs
14591that depend on an exact implementation of IEEE or ISO rules/specifications
14592for math functions. It may, however, yield faster code for programs
14593that do not require the guarantees of these specifications.
14594
d77de738
ML
14595@opindex fno-math-errno
14596@opindex fmath-errno
ddf6fe37 14597@item -fno-math-errno
d77de738
ML
14598Do not set @code{errno} after calling math functions that are executed
14599with a single instruction, e.g., @code{sqrt}. A program that relies on
14600IEEE exceptions for math error handling may want to use this flag
14601for speed while maintaining IEEE arithmetic compatibility.
14602
14603This option is not turned on by any @option{-O} option since
14604it can result in incorrect output for programs that depend on
14605an exact implementation of IEEE or ISO rules/specifications for
14606math functions. It may, however, yield faster code for programs
14607that do not require the guarantees of these specifications.
14608
14609The default is @option{-fmath-errno}.
14610
14611On Darwin systems, the math library never sets @code{errno}. There is
14612therefore no reason for the compiler to consider the possibility that
14613it might, and @option{-fno-math-errno} is the default.
14614
d77de738 14615@opindex funsafe-math-optimizations
ddf6fe37 14616@item -funsafe-math-optimizations
d77de738
ML
14617
14618Allow optimizations for floating-point arithmetic that (a) assume
14619that arguments and results are valid and (b) may violate IEEE or
14620ANSI standards. When used at link time, it may include libraries
14621or startup files that change the default FPU control word or other
14622similar optimizations.
14623
14624This option is not turned on by any @option{-O} option since
14625it can result in incorrect output for programs that depend on
14626an exact implementation of IEEE or ISO rules/specifications for
14627math functions. It may, however, yield faster code for programs
14628that do not require the guarantees of these specifications.
14629Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14630@option{-fassociative-math} and @option{-freciprocal-math}.
14631
14632The default is @option{-fno-unsafe-math-optimizations}.
14633
d77de738 14634@opindex fassociative-math
ddf6fe37 14635@item -fassociative-math
d77de738
ML
14636
14637Allow re-association of operands in series of floating-point operations.
14638This violates the ISO C and C++ language standard by possibly changing
14639computation result. NOTE: re-ordering may change the sign of zero as
14640well as ignore NaNs and inhibit or create underflow or overflow (and
14641thus cannot be used on code that relies on rounding behavior like
14642@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14643and thus may not be used when ordered comparisons are required.
14644This option requires that both @option{-fno-signed-zeros} and
14645@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14646much sense with @option{-frounding-math}. For Fortran the option
14647is automatically enabled when both @option{-fno-signed-zeros} and
14648@option{-fno-trapping-math} are in effect.
14649
14650The default is @option{-fno-associative-math}.
14651
d77de738 14652@opindex freciprocal-math
ddf6fe37 14653@item -freciprocal-math
d77de738
ML
14654
14655Allow the reciprocal of a value to be used instead of dividing by
14656the value if this enables optimizations. For example @code{x / y}
14657can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14658is subject to common subexpression elimination. Note that this loses
14659precision and increases the number of flops operating on the value.
14660
14661The default is @option{-fno-reciprocal-math}.
14662
d77de738 14663@opindex ffinite-math-only
ddf6fe37 14664@item -ffinite-math-only
d77de738
ML
14665Allow optimizations for floating-point arithmetic that assume
14666that arguments and results are not NaNs or +-Infs.
14667
14668This option is not turned on by any @option{-O} option since
14669it can result in incorrect output for programs that depend on
14670an exact implementation of IEEE or ISO rules/specifications for
14671math functions. It may, however, yield faster code for programs
14672that do not require the guarantees of these specifications.
14673
14674The default is @option{-fno-finite-math-only}.
14675
d77de738
ML
14676@opindex fno-signed-zeros
14677@opindex fsigned-zeros
ddf6fe37 14678@item -fno-signed-zeros
d77de738
ML
14679Allow optimizations for floating-point arithmetic that ignore the
14680signedness of zero. IEEE arithmetic specifies the behavior of
14681distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14682of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14683This option implies that the sign of a zero result isn't significant.
14684
14685The default is @option{-fsigned-zeros}.
14686
d77de738
ML
14687@opindex fno-trapping-math
14688@opindex ftrapping-math
ddf6fe37 14689@item -fno-trapping-math
d77de738
ML
14690Compile code assuming that floating-point operations cannot generate
14691user-visible traps. These traps include division by zero, overflow,
14692underflow, inexact result and invalid operation. This option requires
14693that @option{-fno-signaling-nans} be in effect. Setting this option may
14694allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14695
14696This option should never be turned on by any @option{-O} option since
14697it can result in incorrect output for programs that depend on
14698an exact implementation of IEEE or ISO rules/specifications for
14699math functions.
14700
14701The default is @option{-ftrapping-math}.
14702
14703Future versions of GCC may provide finer control of this setting
14704using C99's @code{FENV_ACCESS} pragma. This command-line option
14705will be used along with @option{-frounding-math} to specify the
14706default state for @code{FENV_ACCESS}.
14707
d77de738 14708@opindex frounding-math
ddf6fe37 14709@item -frounding-math
d77de738
ML
14710Disable transformations and optimizations that assume default floating-point
14711rounding behavior. This is round-to-zero for all floating point
14712to integer conversions, and round-to-nearest for all other arithmetic
14713truncations. This option should be specified for programs that change
14714the FP rounding mode dynamically, or that may be executed with a
14715non-default rounding mode. This option disables constant folding of
14716floating-point expressions at compile time (which may be affected by
14717rounding mode) and arithmetic transformations that are unsafe in the
14718presence of sign-dependent rounding modes.
14719
14720The default is @option{-fno-rounding-math}.
14721
14722This option is experimental and does not currently guarantee to
14723disable all GCC optimizations that are affected by rounding mode.
14724Future versions of GCC may provide finer control of this setting
14725using C99's @code{FENV_ACCESS} pragma. This command-line option
14726will be used along with @option{-ftrapping-math} to specify the
14727default state for @code{FENV_ACCESS}.
14728
d77de738 14729@opindex fsignaling-nans
ddf6fe37 14730@item -fsignaling-nans
d77de738
ML
14731Compile code assuming that IEEE signaling NaNs may generate user-visible
14732traps during floating-point operations. Setting this option disables
14733optimizations that may change the number of exceptions visible with
14734signaling NaNs. This option implies @option{-ftrapping-math}.
14735
14736This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14737be defined.
14738
14739The default is @option{-fno-signaling-nans}.
14740
14741This option is experimental and does not currently guarantee to
14742disable all GCC optimizations that affect signaling NaN behavior.
14743
d77de738
ML
14744@opindex fno-fp-int-builtin-inexact
14745@opindex ffp-int-builtin-inexact
ddf6fe37 14746@item -fno-fp-int-builtin-inexact
d77de738
ML
14747Do not allow the built-in functions @code{ceil}, @code{floor},
14748@code{round} and @code{trunc}, and their @code{float} and @code{long
14749double} variants, to generate code that raises the ``inexact''
14750floating-point exception for noninteger arguments. ISO C99 and C11
14751allow these functions to raise the ``inexact'' exception, but ISO/IEC
14752TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
094a609c 14753ISO C23, does not allow these functions to do so.
d77de738
ML
14754
14755The default is @option{-ffp-int-builtin-inexact}, allowing the
094a609c 14756exception to be raised, unless C23 or a later C standard is selected.
d77de738
ML
14757This option does nothing unless @option{-ftrapping-math} is in effect.
14758
14759Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14760generate a call to a library function then the ``inexact'' exception
14761may be raised if the library implementation does not follow TS 18661.
14762
d77de738 14763@opindex fsingle-precision-constant
ddf6fe37 14764@item -fsingle-precision-constant
d77de738
ML
14765Treat floating-point constants as single precision instead of
14766implicitly converting them to double-precision constants.
14767
d77de738 14768@opindex fcx-limited-range
ddf6fe37 14769@item -fcx-limited-range
d77de738
ML
14770When enabled, this option states that a range reduction step is not
14771needed when performing complex division. Also, there is no checking
14772whether the result of a complex multiplication or division is @code{NaN
14773+ I*NaN}, with an attempt to rescue the situation in that case. The
14774default is @option{-fno-cx-limited-range}, but is enabled by
14775@option{-ffast-math}.
14776
14777This option controls the default setting of the ISO C99
14778@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14779all languages.
14780
d77de738 14781@opindex fcx-fortran-rules
ddf6fe37 14782@item -fcx-fortran-rules
d77de738
ML
14783Complex multiplication and division follow Fortran rules. Range
14784reduction is done as part of complex division, but there is no checking
14785whether the result of a complex multiplication or division is @code{NaN
14786+ I*NaN}, with an attempt to rescue the situation in that case.
14787
14788The default is @option{-fno-cx-fortran-rules}.
14789
14790@end table
14791
14792The following options control optimizations that may improve
14793performance, but are not enabled by any @option{-O} options. This
14794section includes experimental options that may produce broken code.
14795
14796@table @gcctabopt
d77de738 14797@opindex fbranch-probabilities
ddf6fe37 14798@item -fbranch-probabilities
d77de738
ML
14799After running a program compiled with @option{-fprofile-arcs}
14800(@pxref{Instrumentation Options}),
14801you can compile it a second time using
14802@option{-fbranch-probabilities}, to improve optimizations based on
14803the number of times each branch was taken. When a program
14804compiled with @option{-fprofile-arcs} exits, it saves arc execution
14805counts to a file called @file{@var{sourcename}.gcda} for each source
14806file. The information in this data file is very dependent on the
14807structure of the generated code, so you must use the same source code
14808and the same optimization options for both compilations.
14809See details about the file naming in @option{-fprofile-arcs}.
14810
14811With @option{-fbranch-probabilities}, GCC puts a
14812@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14813These can be used to improve optimization. Currently, they are only
14814used in one place: in @file{reorg.cc}, instead of guessing which path a
14815branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14816exactly determine which path is taken more often.
14817
14818Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14819
d77de738 14820@opindex fprofile-values
ddf6fe37 14821@item -fprofile-values
d77de738
ML
14822If combined with @option{-fprofile-arcs}, it adds code so that some
14823data about values of expressions in the program is gathered.
14824
14825With @option{-fbranch-probabilities}, it reads back the data gathered
14826from profiling values of expressions for usage in optimizations.
14827
14828Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14829@option{-fauto-profile}.
14830
d77de738 14831@opindex fprofile-reorder-functions
ddf6fe37 14832@item -fprofile-reorder-functions
d77de738
ML
14833Function reordering based on profile instrumentation collects
14834first time of execution of a function and orders these functions
14835in ascending order.
14836
14837Enabled with @option{-fprofile-use}.
14838
d77de738 14839@opindex fvpt
ddf6fe37 14840@item -fvpt
d77de738
ML
14841If combined with @option{-fprofile-arcs}, this option instructs the compiler
14842to add code to gather information about values of expressions.
14843
14844With @option{-fbranch-probabilities}, it reads back the data gathered
14845and actually performs the optimizations based on them.
14846Currently the optimizations include specialization of division operations
14847using the knowledge about the value of the denominator.
14848
14849Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14850
d77de738 14851@opindex frename-registers
ddf6fe37 14852@item -frename-registers
d77de738
ML
14853Attempt to avoid false dependencies in scheduled code by making use
14854of registers left over after register allocation. This optimization
14855most benefits processors with lots of registers. Depending on the
14856debug information format adopted by the target, however, it can
14857make debugging impossible, since variables no longer stay in
14858a ``home register''.
14859
14860Enabled by default with @option{-funroll-loops}.
14861
d77de738 14862@opindex fschedule-fusion
ddf6fe37 14863@item -fschedule-fusion
d77de738
ML
14864Performs a target dependent pass over the instruction stream to schedule
14865instructions of same type together because target machine can execute them
14866more efficiently if they are adjacent to each other in the instruction flow.
14867
14868Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14869
d77de738 14870@opindex ftracer
ddf6fe37 14871@item -ftracer
d77de738
ML
14872Perform tail duplication to enlarge superblock size. This transformation
14873simplifies the control flow of the function allowing other optimizations to do
14874a better job.
14875
14876Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14877
d77de738 14878@opindex funroll-loops
ddf6fe37 14879@item -funroll-loops
d77de738
ML
14880Unroll loops whose number of iterations can be determined at compile time or
14881upon entry to the loop. @option{-funroll-loops} implies
14882@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14883It also turns on complete loop peeling (i.e.@: complete removal of loops with
14884a small constant number of iterations). This option makes code larger, and may
14885or may not make it run faster.
14886
14887Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14888
d77de738 14889@opindex funroll-all-loops
ddf6fe37 14890@item -funroll-all-loops
d77de738
ML
14891Unroll all loops, even if their number of iterations is uncertain when
14892the loop is entered. This usually makes programs run more slowly.
14893@option{-funroll-all-loops} implies the same options as
14894@option{-funroll-loops}.
14895
d77de738 14896@opindex fpeel-loops
ddf6fe37 14897@item -fpeel-loops
d77de738
ML
14898Peels loops for which there is enough information that they do not
14899roll much (from profile feedback or static analysis). It also turns on
14900complete loop peeling (i.e.@: complete removal of loops with small constant
14901number of iterations).
14902
14903Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14904
d77de738 14905@opindex fmove-loop-invariants
ddf6fe37 14906@item -fmove-loop-invariants
d77de738
ML
14907Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14908at level @option{-O1} and higher, except for @option{-Og}.
14909
d77de738 14910@opindex fmove-loop-stores
ddf6fe37 14911@item -fmove-loop-stores
d77de738
ML
14912Enables the loop store motion pass in the GIMPLE loop optimizer. This
14913moves invariant stores to after the end of the loop in exchange for
14914carrying the stored value in a register across the iteration.
14915Note for this option to have an effect @option{-ftree-loop-im} has to
14916be enabled as well. Enabled at level @option{-O1} and higher, except
14917for @option{-Og}.
14918
d77de738 14919@opindex fsplit-loops
ddf6fe37 14920@item -fsplit-loops
d77de738
ML
14921Split a loop into two if it contains a condition that's always true
14922for one side of the iteration space and false for the other.
14923
14924Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14925
d77de738 14926@opindex funswitch-loops
ddf6fe37 14927@item -funswitch-loops
d77de738
ML
14928Move branches with loop invariant conditions out of the loop, with duplicates
14929of the loop on both branches (modified according to result of the condition).
14930
14931Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14932
d77de738 14933@opindex fversion-loops-for-strides
ddf6fe37 14934@item -fversion-loops-for-strides
d77de738
ML
14935If a loop iterates over an array with a variable stride, create another
14936version of the loop that assumes the stride is always one. For example:
14937
14938@smallexample
14939for (int i = 0; i < n; ++i)
14940 x[i * stride] = @dots{};
14941@end smallexample
14942
14943becomes:
14944
14945@smallexample
14946if (stride == 1)
14947 for (int i = 0; i < n; ++i)
14948 x[i] = @dots{};
14949else
14950 for (int i = 0; i < n; ++i)
14951 x[i * stride] = @dots{};
14952@end smallexample
14953
14954This is particularly useful for assumed-shape arrays in Fortran where
14955(for example) it allows better vectorization assuming contiguous accesses.
14956This flag is enabled by default at @option{-O3}.
14957It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14958
d77de738
ML
14959@opindex ffunction-sections
14960@opindex fdata-sections
ddf6fe37
AA
14961@item -ffunction-sections
14962@itemx -fdata-sections
d77de738
ML
14963Place each function or data item into its own section in the output
14964file if the target supports arbitrary sections. The name of the
14965function or the name of the data item determines the section's name
14966in the output file.
14967
14968Use these options on systems where the linker can perform optimizations to
14969improve locality of reference in the instruction space. Most systems using the
14970ELF object format have linkers with such optimizations. On AIX, the linker
14971rearranges sections (CSECTs) based on the call graph. The performance impact
14972varies.
14973
14974Together with a linker garbage collection (linker @option{--gc-sections}
14975option) these options may lead to smaller statically-linked executables (after
14976stripping).
14977
14978On ELF/DWARF systems these options do not degenerate the quality of the debug
14979information. There could be issues with other object files/debug info formats.
14980
14981Only use these options when there are significant benefits from doing so. When
14982you specify these options, the assembler and linker create larger object and
14983executable files and are also slower. These options affect code generation.
14984They prevent optimizations by the compiler and assembler using relative
14985locations inside a translation unit since the locations are unknown until
14986link time. An example of such an optimization is relaxing calls to short call
14987instructions.
14988
d77de738 14989@opindex fstdarg-opt
ddf6fe37 14990@item -fstdarg-opt
d77de738
ML
14991Optimize the prologue of variadic argument functions with respect to usage of
14992those arguments.
14993
d77de738 14994@opindex fsection-anchors
ddf6fe37 14995@item -fsection-anchors
d77de738
ML
14996Try to reduce the number of symbolic address calculations by using
14997shared ``anchor'' symbols to address nearby objects. This transformation
14998can help to reduce the number of GOT entries and GOT accesses on some
14999targets.
15000
15001For example, the implementation of the following function @code{foo}:
15002
15003@smallexample
15004static int a, b, c;
15005int foo (void) @{ return a + b + c; @}
15006@end smallexample
15007
15008@noindent
15009usually calculates the addresses of all three variables, but if you
15010compile it with @option{-fsection-anchors}, it accesses the variables
15011from a common anchor point instead. The effect is similar to the
15012following pseudocode (which isn't valid C):
15013
15014@smallexample
15015int foo (void)
15016@{
15017 register int *xr = &x;
15018 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
15019@}
15020@end smallexample
15021
15022Not all targets support this option.
15023
d77de738 15024@opindex fzero-call-used-regs
ddf6fe37 15025@item -fzero-call-used-regs=@var{choice}
d77de738
ML
15026Zero call-used registers at function return to increase program
15027security by either mitigating Return-Oriented Programming (ROP)
15028attacks or preventing information leakage through registers.
15029
15030The possible values of @var{choice} are the same as for the
15031@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
15032The default is @samp{skip}.
15033
15034You can control this behavior for a specific function by using the function
15035attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
15036
d77de738 15037@opindex param
ddf6fe37 15038@item --param @var{name}=@var{value}
d77de738
ML
15039In some places, GCC uses various constants to control the amount of
15040optimization that is done. For example, GCC does not inline functions
15041that contain more than a certain number of instructions. You can
15042control some of these constants on the command line using the
15043@option{--param} option.
15044
15045The names of specific parameters, and the meaning of the values, are
15046tied to the internals of the compiler, and are subject to change
15047without notice in future releases.
15048
c381327d
GP
15049In order to get the minimal, maximal and default values of a parameter,
15050use the @option{--help=param -Q} options.
d77de738
ML
15051
15052In each case, the @var{value} is an integer. The following choices
15053of @var{name} are recognized for all targets:
15054
15055@table @gcctabopt
15056@item predictable-branch-outcome
15057When branch is predicted to be taken with probability lower than this threshold
15058(in percent), then it is considered well predictable.
15059
15060@item max-rtl-if-conversion-insns
15061RTL if-conversion tries to remove conditional branches around a block and
15062replace them with conditionally executed instructions. This parameter
15063gives the maximum number of instructions in a block which should be
15064considered for if-conversion. The compiler will
15065also use other heuristics to decide whether if-conversion is likely to be
15066profitable.
15067
15068@item max-rtl-if-conversion-predictable-cost
15069RTL if-conversion will try to remove conditional branches around a block
15070and replace them with conditionally executed instructions. These parameters
15071give the maximum permissible cost for the sequence that would be generated
15072by if-conversion depending on whether the branch is statically determined
15073to be predictable or not. The units for this parameter are the same as
15074those for the GCC internal seq_cost metric. The compiler will try to
15075provide a reasonable default for this parameter using the BRANCH_COST
15076target macro.
15077
15078@item max-crossjump-edges
15079The maximum number of incoming edges to consider for cross-jumping.
15080The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
15081the number of edges incoming to each block. Increasing values mean
15082more aggressive optimization, making the compilation time increase with
15083probably small improvement in executable size.
15084
15085@item min-crossjump-insns
15086The minimum number of instructions that must be matched at the end
15087of two blocks before cross-jumping is performed on them. This
15088value is ignored in the case where all instructions in the block being
15089cross-jumped from are matched.
15090
15091@item max-grow-copy-bb-insns
15092The maximum code size expansion factor when copying basic blocks
15093instead of jumping. The expansion is relative to a jump instruction.
15094
15095@item max-goto-duplication-insns
15096The maximum number of instructions to duplicate to a block that jumps
15097to a computed goto. To avoid @math{O(N^2)} behavior in a number of
15098passes, GCC factors computed gotos early in the compilation process,
15099and unfactors them as late as possible. Only computed jumps at the
15100end of a basic blocks with no more than max-goto-duplication-insns are
15101unfactored.
15102
15103@item max-delay-slot-insn-search
15104The maximum number of instructions to consider when looking for an
15105instruction to fill a delay slot. If more than this arbitrary number of
15106instructions are searched, the time savings from filling the delay slot
15107are minimal, so stop searching. Increasing values mean more
15108aggressive optimization, making the compilation time increase with probably
15109small improvement in execution time.
15110
15111@item max-delay-slot-live-search
15112When trying to fill delay slots, the maximum number of instructions to
15113consider when searching for a block with valid live register
15114information. Increasing this arbitrarily chosen value means more
15115aggressive optimization, increasing the compilation time. This parameter
15116should be removed when the delay slot code is rewritten to maintain the
15117control-flow graph.
15118
15119@item max-gcse-memory
15120The approximate maximum amount of memory in @code{kB} that can be allocated in
15121order to perform the global common subexpression elimination
15122optimization. If more memory than specified is required, the
15123optimization is not done.
15124
15125@item max-gcse-insertion-ratio
15126If the ratio of expression insertions to deletions is larger than this value
15127for any expression, then RTL PRE inserts or removes the expression and thus
15128leaves partially redundant computations in the instruction stream.
15129
15130@item max-pending-list-length
15131The maximum number of pending dependencies scheduling allows
15132before flushing the current state and starting over. Large functions
15133with few branches or calls can create excessively large lists which
15134needlessly consume memory and resources.
15135
15136@item max-modulo-backtrack-attempts
15137The maximum number of backtrack attempts the scheduler should make
15138when modulo scheduling a loop. Larger values can exponentially increase
15139compilation time.
15140
15141@item max-inline-functions-called-once-loop-depth
15142Maximal loop depth of a call considered by inline heuristics that tries to
15143inline all functions called once.
15144
15145@item max-inline-functions-called-once-insns
15146Maximal estimated size of functions produced while inlining functions called
15147once.
15148
15149@item max-inline-insns-single
15150Several parameters control the tree inliner used in GCC@. This number sets the
15151maximum number of instructions (counted in GCC's internal representation) in a
15152single function that the tree inliner considers for inlining. This only
15153affects functions declared inline and methods implemented in a class
15154declaration (C++).
15155
15156
15157@item max-inline-insns-auto
15158When you use @option{-finline-functions} (included in @option{-O3}),
15159a lot of functions that would otherwise not be considered for inlining
15160by the compiler are investigated. To those functions, a different
15161(more restrictive) limit compared to functions declared inline can
15162be applied (@option{--param max-inline-insns-auto}).
15163
15164@item max-inline-insns-small
15165This is bound applied to calls which are considered relevant with
15166@option{-finline-small-functions}.
15167
15168@item max-inline-insns-size
15169This is bound applied to calls which are optimized for size. Small growth
15170may be desirable to anticipate optimization oppurtunities exposed by inlining.
15171
15172@item uninlined-function-insns
15173Number of instructions accounted by inliner for function overhead such as
15174function prologue and epilogue.
15175
15176@item uninlined-function-time
15177Extra time accounted by inliner for function overhead such as time needed to
15178execute function prologue and epilogue.
15179
15180@item inline-heuristics-hint-percent
15181The scale (in percents) applied to @option{inline-insns-single},
15182@option{inline-insns-single-O2}, @option{inline-insns-auto}
15183when inline heuristics hints that inlining is
15184very profitable (will enable later optimizations).
15185
15186@item uninlined-thunk-insns
15187@item uninlined-thunk-time
15188Same as @option{--param uninlined-function-insns} and
15189@option{--param uninlined-function-time} but applied to function thunks.
15190
15191@item inline-min-speedup
15192When estimated performance improvement of caller + callee runtime exceeds this
15193threshold (in percent), the function can be inlined regardless of the limit on
15194@option{--param max-inline-insns-single} and @option{--param
15195max-inline-insns-auto}.
15196
15197@item large-function-insns
15198The limit specifying really large functions. For functions larger than this
15199limit after inlining, inlining is constrained by
15200@option{--param large-function-growth}. This parameter is useful primarily
15201to avoid extreme compilation time caused by non-linear algorithms used by the
15202back end.
15203
15204@item large-function-growth
15205Specifies maximal growth of large function caused by inlining in percents.
15206For example, parameter value 100 limits large function growth to 2.0 times
15207the original size.
15208
15209@item large-unit-insns
15210The limit specifying large translation unit. Growth caused by inlining of
15211units larger than this limit is limited by @option{--param inline-unit-growth}.
15212For small units this might be too tight.
15213For example, consider a unit consisting of function A
15214that is inline and B that just calls A three times. If B is small relative to
15215A, the growth of unit is 300\% and yet such inlining is very sane. For very
15216large units consisting of small inlineable functions, however, the overall unit
15217growth limit is needed to avoid exponential explosion of code size. Thus for
15218smaller units, the size is increased to @option{--param large-unit-insns}
15219before applying @option{--param inline-unit-growth}.
15220
15221@item lazy-modules
15222Maximum number of concurrently open C++ module files when lazy loading.
15223
15224@item inline-unit-growth
15225Specifies maximal overall growth of the compilation unit caused by inlining.
15226For example, parameter value 20 limits unit growth to 1.2 times the original
15227size. Cold functions (either marked cold via an attribute or by profile
15228feedback) are not accounted into the unit size.
15229
15230@item ipa-cp-unit-growth
15231Specifies maximal overall growth of the compilation unit caused by
15232interprocedural constant propagation. For example, parameter value 10 limits
15233unit growth to 1.1 times the original size.
15234
15235@item ipa-cp-large-unit-insns
15236The size of translation unit that IPA-CP pass considers large.
15237
15238@item large-stack-frame
15239The limit specifying large stack frames. While inlining the algorithm is trying
15240to not grow past this limit too much.
15241
15242@item large-stack-frame-growth
15243Specifies maximal growth of large stack frames caused by inlining in percents.
15244For example, parameter value 1000 limits large stack frame growth to 11 times
15245the original size.
15246
15247@item max-inline-insns-recursive
15248@itemx max-inline-insns-recursive-auto
15249Specifies the maximum number of instructions an out-of-line copy of a
15250self-recursive inline
15251function can grow into by performing recursive inlining.
15252
15253@option{--param max-inline-insns-recursive} applies to functions
15254declared inline.
15255For functions not declared inline, recursive inlining
15256happens only when @option{-finline-functions} (included in @option{-O3}) is
15257enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15258
15259@item max-inline-recursive-depth
15260@itemx max-inline-recursive-depth-auto
15261Specifies the maximum recursion depth used for recursive inlining.
15262
15263@option{--param max-inline-recursive-depth} applies to functions
15264declared inline. For functions not declared inline, recursive inlining
15265happens only when @option{-finline-functions} (included in @option{-O3}) is
15266enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15267
15268@item min-inline-recursive-probability
15269Recursive inlining is profitable only for function having deep recursion
15270in average and can hurt for function having little recursion depth by
15271increasing the prologue size or complexity of function body to other
15272optimizers.
15273
15274When profile feedback is available (see @option{-fprofile-generate}) the actual
15275recursion depth can be guessed from the probability that function recurses
15276via a given call expression. This parameter limits inlining only to call
15277expressions whose probability exceeds the given threshold (in percents).
15278
15279@item early-inlining-insns
15280Specify growth that the early inliner can make. In effect it increases
15281the amount of inlining for code having a large abstraction penalty.
15282
15283@item max-early-inliner-iterations
15284Limit of iterations of the early inliner. This basically bounds
15285the number of nested indirect calls the early inliner can resolve.
15286Deeper chains are still handled by late inlining.
15287
15288@item comdat-sharing-probability
15289Probability (in percent) that C++ inline function with comdat visibility
15290are shared across multiple compilation units.
15291
15292@item modref-max-bases
15293@item modref-max-refs
15294@item modref-max-accesses
15295Specifies the maximal number of base pointers, references and accesses stored
15296for a single function by mod/ref analysis.
15297
15298@item modref-max-tests
15299Specifies the maxmal number of tests alias oracle can perform to disambiguate
15300memory locations using the mod/ref information. This parameter ought to be
15301bigger than @option{--param modref-max-bases} and @option{--param
15302modref-max-refs}.
15303
15304@item modref-max-depth
15305Specifies the maximum depth of DFS walk used by modref escape analysis.
15306Setting to 0 disables the analysis completely.
15307
15308@item modref-max-escape-points
15309Specifies the maximum number of escape points tracked by modref per SSA-name.
15310
15311@item modref-max-adjustments
15312Specifies the maximum number the access range is enlarged during modref dataflow
15313analysis.
15314
15315@item profile-func-internal-id
15316A parameter to control whether to use function internal id in profile
15317database lookup. If the value is 0, the compiler uses an id that
15318is based on function assembler name and filename, which makes old profile
15319data more tolerant to source changes such as function reordering etc.
15320
15321@item min-vect-loop-bound
15322The minimum number of iterations under which loops are not vectorized
15323when @option{-ftree-vectorize} is used. The number of iterations after
15324vectorization needs to be greater than the value specified by this option
15325to allow vectorization.
15326
15327@item gcse-cost-distance-ratio
15328Scaling factor in calculation of maximum distance an expression
15329can be moved by GCSE optimizations. This is currently supported only in the
15330code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15331is with simple expressions, i.e., the expressions that have cost
15332less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15333hoisting of simple expressions.
15334
15335@item gcse-unrestricted-cost
15336Cost, roughly measured as the cost of a single typical machine
15337instruction, at which GCSE optimizations do not constrain
15338the distance an expression can travel. This is currently
15339supported only in the code hoisting pass. The lesser the cost,
15340the more aggressive code hoisting is. Specifying 0
15341allows all expressions to travel unrestricted distances.
15342
15343@item max-hoist-depth
15344The depth of search in the dominator tree for expressions to hoist.
15345This is used to avoid quadratic behavior in hoisting algorithm.
15346The value of 0 does not limit on the search, but may slow down compilation
15347of huge functions.
15348
15349@item max-tail-merge-comparisons
15350The maximum amount of similar bbs to compare a bb with. This is used to
15351avoid quadratic behavior in tree tail merging.
15352
15353@item max-tail-merge-iterations
15354The maximum amount of iterations of the pass over the function. This is used to
15355limit compilation time in tree tail merging.
15356
15357@item store-merging-allow-unaligned
15358Allow the store merging pass to introduce unaligned stores if it is legal to
15359do so.
15360
15361@item max-stores-to-merge
15362The maximum number of stores to attempt to merge into wider stores in the store
15363merging pass.
15364
15365@item max-store-chains-to-track
15366The maximum number of store chains to track at the same time in the attempt
15367to merge them into wider stores in the store merging pass.
15368
15369@item max-stores-to-track
15370The maximum number of stores to track at the same time in the attemt to
15371to merge them into wider stores in the store merging pass.
15372
15373@item max-unrolled-insns
15374The maximum number of instructions that a loop may have to be unrolled.
15375If a loop is unrolled, this parameter also determines how many times
15376the loop code is unrolled.
15377
15378@item max-average-unrolled-insns
15379The maximum number of instructions biased by probabilities of their execution
15380that a loop may have to be unrolled. If a loop is unrolled,
15381this parameter also determines how many times the loop code is unrolled.
15382
15383@item max-unroll-times
15384The maximum number of unrollings of a single loop.
15385
15386@item max-peeled-insns
15387The maximum number of instructions that a loop may have to be peeled.
15388If a loop is peeled, this parameter also determines how many times
15389the loop code is peeled.
15390
15391@item max-peel-times
15392The maximum number of peelings of a single loop.
15393
15394@item max-peel-branches
15395The maximum number of branches on the hot path through the peeled sequence.
15396
15397@item max-completely-peeled-insns
15398The maximum number of insns of a completely peeled loop.
15399
15400@item max-completely-peel-times
15401The maximum number of iterations of a loop to be suitable for complete peeling.
15402
15403@item max-completely-peel-loop-nest-depth
15404The maximum depth of a loop nest suitable for complete peeling.
15405
15406@item max-unswitch-insns
15407The maximum number of insns of an unswitched loop.
15408
5b50850c
RB
15409@item max-unswitch-depth
15410The maximum depth of a loop nest to be unswitched.
15411
d77de738
ML
15412@item lim-expensive
15413The minimum cost of an expensive expression in the loop invariant motion.
15414
15415@item min-loop-cond-split-prob
15416When FDO profile information is available, @option{min-loop-cond-split-prob}
15417specifies minimum threshold for probability of semi-invariant condition
15418statement to trigger loop split.
15419
15420@item iv-consider-all-candidates-bound
15421Bound on number of candidates for induction variables, below which
15422all candidates are considered for each use in induction variable
15423optimizations. If there are more candidates than this,
15424only the most relevant ones are considered to avoid quadratic time complexity.
15425
15426@item iv-max-considered-uses
15427The induction variable optimizations give up on loops that contain more
15428induction variable uses.
15429
15430@item iv-always-prune-cand-set-bound
15431If the number of candidates in the set is smaller than this value,
15432always try to remove unnecessary ivs from the set
15433when adding a new one.
15434
15435@item avg-loop-niter
15436Average number of iterations of a loop.
15437
15438@item dse-max-object-size
15439Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15440Larger values may result in larger compilation times.
15441
15442@item dse-max-alias-queries-per-store
15443Maximum number of queries into the alias oracle per store.
15444Larger values result in larger compilation times and may result in more
15445removed dead stores.
15446
15447@item scev-max-expr-size
15448Bound on size of expressions used in the scalar evolutions analyzer.
15449Large expressions slow the analyzer.
15450
15451@item scev-max-expr-complexity
15452Bound on the complexity of the expressions in the scalar evolutions analyzer.
15453Complex expressions slow the analyzer.
15454
15455@item max-tree-if-conversion-phi-args
15456Maximum number of arguments in a PHI supported by TREE if conversion
15457unless the loop is marked with simd pragma.
15458
15459@item vect-max-layout-candidates
15460The maximum number of possible vector layouts (such as permutations)
15461to consider when optimizing to-be-vectorized code.
15462
15463@item vect-max-version-for-alignment-checks
15464The maximum number of run-time checks that can be performed when
15465doing loop versioning for alignment in the vectorizer.
15466
15467@item vect-max-version-for-alias-checks
15468The maximum number of run-time checks that can be performed when
15469doing loop versioning for alias in the vectorizer.
15470
15471@item vect-max-peeling-for-alignment
15472The maximum number of loop peels to enhance access alignment
15473for vectorizer. Value -1 means no limit.
15474
15475@item max-iterations-to-track
15476The maximum number of iterations of a loop the brute-force algorithm
15477for analysis of the number of iterations of the loop tries to evaluate.
15478
15479@item hot-bb-count-fraction
15480The denominator n of fraction 1/n of the maximal execution count of a
15481basic block in the entire program that a basic block needs to at least
15482have in order to be considered hot. The default is 10000, which means
15483that a basic block is considered hot if its execution count is greater
15484than 1/10000 of the maximal execution count. 0 means that it is never
15485considered hot. Used in non-LTO mode.
15486
15487@item hot-bb-count-ws-permille
15488The number of most executed permilles, ranging from 0 to 1000, of the
15489profiled execution of the entire program to which the execution count
15490of a basic block must be part of in order to be considered hot. The
15491default is 990, which means that a basic block is considered hot if
15492its execution count contributes to the upper 990 permilles, or 99.0%,
15493of the profiled execution of the entire program. 0 means that it is
15494never considered hot. Used in LTO mode.
15495
15496@item hot-bb-frequency-fraction
15497The denominator n of fraction 1/n of the execution frequency of the
15498entry block of a function that a basic block of this function needs
15499to at least have in order to be considered hot. The default is 1000,
15500which means that a basic block is considered hot in a function if it
15501is executed more frequently than 1/1000 of the frequency of the entry
15502block of the function. 0 means that it is never considered hot.
15503
15504@item unlikely-bb-count-fraction
15505The denominator n of fraction 1/n of the number of profiled runs of
15506the entire program below which the execution count of a basic block
15507must be in order for the basic block to be considered unlikely executed.
15508The default is 20, which means that a basic block is considered unlikely
15509executed if it is executed in fewer than 1/20, or 5%, of the runs of
15510the program. 0 means that it is always considered unlikely executed.
15511
15512@item max-predicted-iterations
15513The maximum number of loop iterations we predict statically. This is useful
15514in cases where a function contains a single loop with known bound and
15515another loop with unknown bound.
15516The known number of iterations is predicted correctly, while
15517the unknown number of iterations average to roughly 10. This means that the
15518loop without bounds appears artificially cold relative to the other one.
15519
15520@item builtin-expect-probability
15521Control the probability of the expression having the specified value. This
15522parameter takes a percentage (i.e.@: 0 ... 100) as input.
15523
15524@item builtin-string-cmp-inline-length
15525The maximum length of a constant string for a builtin string cmp call
15526eligible for inlining.
15527
15528@item align-threshold
15529
15530Select fraction of the maximal frequency of executions of a basic block in
15531a function to align the basic block.
15532
15533@item align-loop-iterations
15534
15535A loop expected to iterate at least the selected number of iterations is
15536aligned.
15537
15538@item tracer-dynamic-coverage
15539@itemx tracer-dynamic-coverage-feedback
15540
15541This value is used to limit superblock formation once the given percentage of
15542executed instructions is covered. This limits unnecessary code size
15543expansion.
15544
15545The @option{tracer-dynamic-coverage-feedback} parameter
15546is used only when profile
15547feedback is available. The real profiles (as opposed to statically estimated
15548ones) are much less balanced allowing the threshold to be larger value.
15549
15550@item tracer-max-code-growth
15551Stop tail duplication once code growth has reached given percentage. This is
15552a rather artificial limit, as most of the duplicates are eliminated later in
15553cross jumping, so it may be set to much higher values than is the desired code
15554growth.
15555
15556@item tracer-min-branch-ratio
15557
15558Stop reverse growth when the reverse probability of best edge is less than this
15559threshold (in percent).
15560
15561@item tracer-min-branch-probability
15562@itemx tracer-min-branch-probability-feedback
15563
15564Stop forward growth if the best edge has probability lower than this
15565threshold.
15566
15567Similarly to @option{tracer-dynamic-coverage} two parameters are
15568provided. @option{tracer-min-branch-probability-feedback} is used for
15569compilation with profile feedback and @option{tracer-min-branch-probability}
15570compilation without. The value for compilation with profile feedback
15571needs to be more conservative (higher) in order to make tracer
15572effective.
15573
15574@item stack-clash-protection-guard-size
15575Specify the size of the operating system provided stack guard as
155762 raised to @var{num} bytes. Higher values may reduce the
15577number of explicit probes, but a value larger than the operating system
15578provided guard will leave code vulnerable to stack clash style attacks.
15579
15580@item stack-clash-protection-probe-interval
15581Stack clash protection involves probing stack space as it is allocated. This
15582param controls the maximum distance between probes into the stack as 2 raised
15583to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15584larger than the operating system provided guard will leave code vulnerable to
15585stack clash style attacks.
15586
15587@item max-cse-path-length
15588
15589The maximum number of basic blocks on path that CSE considers.
15590
15591@item max-cse-insns
15592The maximum number of instructions CSE processes before flushing.
15593
15594@item ggc-min-expand
15595
15596GCC uses a garbage collector to manage its own memory allocation. This
15597parameter specifies the minimum percentage by which the garbage
15598collector's heap should be allowed to expand between collections.
15599Tuning this may improve compilation speed; it has no effect on code
15600generation.
15601
15602The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15603RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15604the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15605GCC is not able to calculate RAM on a particular platform, the lower
15606bound of 30% is used. Setting this parameter and
15607@option{ggc-min-heapsize} to zero causes a full collection to occur at
15608every opportunity. This is extremely slow, but can be useful for
15609debugging.
15610
15611@item ggc-min-heapsize
15612
15613Minimum size of the garbage collector's heap before it begins bothering
15614to collect garbage. The first collection occurs after the heap expands
15615by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15616tuning this may improve compilation speed, and has no effect on code
15617generation.
15618
15619The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15620tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15621with a lower bound of 4096 (four megabytes) and an upper bound of
15622131072 (128 megabytes). If GCC is not able to calculate RAM on a
15623particular platform, the lower bound is used. Setting this parameter
15624very large effectively disables garbage collection. Setting this
15625parameter and @option{ggc-min-expand} to zero causes a full collection
15626to occur at every opportunity.
15627
15628@item max-reload-search-insns
15629The maximum number of instruction reload should look backward for equivalent
15630register. Increasing values mean more aggressive optimization, making the
15631compilation time increase with probably slightly better performance.
15632
15633@item max-cselib-memory-locations
15634The maximum number of memory locations cselib should take into account.
15635Increasing values mean more aggressive optimization, making the compilation time
15636increase with probably slightly better performance.
15637
15638@item max-sched-ready-insns
15639The maximum number of instructions ready to be issued the scheduler should
15640consider at any given time during the first scheduling pass. Increasing
15641values mean more thorough searches, making the compilation time increase
15642with probably little benefit.
15643
15644@item max-sched-region-blocks
15645The maximum number of blocks in a region to be considered for
15646interblock scheduling.
15647
15648@item max-pipeline-region-blocks
15649The maximum number of blocks in a region to be considered for
15650pipelining in the selective scheduler.
15651
15652@item max-sched-region-insns
15653The maximum number of insns in a region to be considered for
15654interblock scheduling.
15655
15656@item max-pipeline-region-insns
15657The maximum number of insns in a region to be considered for
15658pipelining in the selective scheduler.
15659
15660@item min-spec-prob
15661The minimum probability (in percents) of reaching a source block
15662for interblock speculative scheduling.
15663
15664@item max-sched-extend-regions-iters
15665The maximum number of iterations through CFG to extend regions.
15666A value of 0 disables region extensions.
15667
15668@item max-sched-insn-conflict-delay
15669The maximum conflict delay for an insn to be considered for speculative motion.
15670
15671@item sched-spec-prob-cutoff
15672The minimal probability of speculation success (in percents), so that
15673speculative insns are scheduled.
15674
15675@item sched-state-edge-prob-cutoff
15676The minimum probability an edge must have for the scheduler to save its
15677state across it.
15678
15679@item sched-mem-true-dep-cost
15680Minimal distance (in CPU cycles) between store and load targeting same
15681memory locations.
15682
15683@item selsched-max-lookahead
15684The maximum size of the lookahead window of selective scheduling. It is a
15685depth of search for available instructions.
15686
15687@item selsched-max-sched-times
15688The maximum number of times that an instruction is scheduled during
15689selective scheduling. This is the limit on the number of iterations
15690through which the instruction may be pipelined.
15691
15692@item selsched-insns-to-rename
15693The maximum number of best instructions in the ready list that are considered
15694for renaming in the selective scheduler.
15695
15696@item sms-min-sc
15697The minimum value of stage count that swing modulo scheduler
15698generates.
15699
15700@item max-last-value-rtl
15701The maximum size measured as number of RTLs that can be recorded in an expression
15702in combiner for a pseudo register as last known value of that register.
15703
15704@item max-combine-insns
15705The maximum number of instructions the RTL combiner tries to combine.
15706
15707@item integer-share-limit
15708Small integer constants can use a shared data structure, reducing the
15709compiler's memory usage and increasing its speed. This sets the maximum
15710value of a shared integer constant.
15711
15712@item ssp-buffer-size
15713The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15714protection when @option{-fstack-protector} is used.
15715
15716@item min-size-for-stack-sharing
15717The minimum size of variables taking part in stack slot sharing when not
15718optimizing.
15719
15720@item max-jump-thread-duplication-stmts
15721Maximum number of statements allowed in a block that needs to be
15722duplicated when threading jumps.
15723
15724@item max-jump-thread-paths
15725The maximum number of paths to consider when searching for jump threading
15726opportunities. When arriving at a block, incoming edges are only considered
15727if the number of paths to be searched so far multiplied by the number of
15728incoming edges does not exhaust the specified maximum number of paths to
15729consider.
15730
15731@item max-fields-for-field-sensitive
15732Maximum number of fields in a structure treated in
15733a field sensitive manner during pointer analysis.
15734
15735@item prefetch-latency
15736Estimate on average number of instructions that are executed before
15737prefetch finishes. The distance prefetched ahead is proportional
15738to this constant. Increasing this number may also lead to less
15739streams being prefetched (see @option{simultaneous-prefetches}).
15740
15741@item simultaneous-prefetches
15742Maximum number of prefetches that can run at the same time.
15743
15744@item l1-cache-line-size
15745The size of cache line in L1 data cache, in bytes.
15746
15747@item l1-cache-size
15748The size of L1 data cache, in kilobytes.
15749
15750@item l2-cache-size
15751The size of L2 data cache, in kilobytes.
15752
15753@item prefetch-dynamic-strides
15754Whether the loop array prefetch pass should issue software prefetch hints
15755for strides that are non-constant. In some cases this may be
15756beneficial, though the fact the stride is non-constant may make it
15757hard to predict when there is clear benefit to issuing these hints.
15758
15759Set to 1 if the prefetch hints should be issued for non-constant
15760strides. Set to 0 if prefetch hints should be issued only for strides that
15761are known to be constant and below @option{prefetch-minimum-stride}.
15762
15763@item prefetch-minimum-stride
15764Minimum constant stride, in bytes, to start using prefetch hints for. If
15765the stride is less than this threshold, prefetch hints will not be issued.
15766
15767This setting is useful for processors that have hardware prefetchers, in
15768which case there may be conflicts between the hardware prefetchers and
15769the software prefetchers. If the hardware prefetchers have a maximum
15770stride they can handle, it should be used here to improve the use of
15771software prefetchers.
15772
15773A value of -1 means we don't have a threshold and therefore
15774prefetch hints can be issued for any constant stride.
15775
15776This setting is only useful for strides that are known and constant.
15777
15778@item destructive-interference-size
15779@item constructive-interference-size
15780The values for the C++17 variables
15781@code{std::hardware_destructive_interference_size} and
15782@code{std::hardware_constructive_interference_size}. The destructive
15783interference size is the minimum recommended offset between two
15784independent concurrently-accessed objects; the constructive
15785interference size is the maximum recommended size of contiguous memory
15786accessed together. Typically both will be the size of an L1 cache
15787line for the target, in bytes. For a generic target covering a range of L1
15788cache line sizes, typically the constructive interference size will be
15789the small end of the range and the destructive size will be the large
15790end.
15791
15792The destructive interference size is intended to be used for layout,
15793and thus has ABI impact. The default value is not expected to be
15794stable, and on some targets varies with @option{-mtune}, so use of
15795this variable in a context where ABI stability is important, such as
15796the public interface of a library, is strongly discouraged; if it is
15797used in that context, users can stabilize the value using this
15798option.
15799
15800The constructive interference size is less sensitive, as it is
15801typically only used in a @samp{static_assert} to make sure that a type
15802fits within a cache line.
15803
15804See also @option{-Winterference-size}.
15805
15806@item loop-interchange-max-num-stmts
15807The maximum number of stmts in a loop to be interchanged.
15808
15809@item loop-interchange-stride-ratio
15810The minimum ratio between stride of two loops for interchange to be profitable.
15811
15812@item min-insn-to-prefetch-ratio
15813The minimum ratio between the number of instructions and the
15814number of prefetches to enable prefetching in a loop.
15815
15816@item prefetch-min-insn-to-mem-ratio
15817The minimum ratio between the number of instructions and the
15818number of memory references to enable prefetching in a loop.
15819
15820@item use-canonical-types
15821Whether the compiler should use the ``canonical'' type system.
15822Should always be 1, which uses a more efficient internal
15823mechanism for comparing types in C++ and Objective-C++. However, if
15824bugs in the canonical type system are causing compilation failures,
15825set this value to 0 to disable canonical types.
15826
15827@item switch-conversion-max-branch-ratio
15828Switch initialization conversion refuses to create arrays that are
15829bigger than @option{switch-conversion-max-branch-ratio} times the number of
15830branches in the switch.
15831
15832@item max-partial-antic-length
15833Maximum length of the partial antic set computed during the tree
15834partial redundancy elimination optimization (@option{-ftree-pre}) when
15835optimizing at @option{-O3} and above. For some sorts of source code
15836the enhanced partial redundancy elimination optimization can run away,
15837consuming all of the memory available on the host machine. This
15838parameter sets a limit on the length of the sets that are computed,
15839which prevents the runaway behavior. Setting a value of 0 for
15840this parameter allows an unlimited set length.
15841
15842@item rpo-vn-max-loop-depth
15843Maximum loop depth that is value-numbered optimistically.
15844When the limit hits the innermost
15845@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15846loop nest are value-numbered optimistically and the remaining ones not.
15847
15848@item sccvn-max-alias-queries-per-access
15849Maximum number of alias-oracle queries we perform when looking for
15850redundancies for loads and stores. If this limit is hit the search
15851is aborted and the load or store is not considered redundant. The
15852number of queries is algorithmically limited to the number of
15853stores on all paths from the load to the function entry.
15854
15855@item ira-max-loops-num
15856IRA uses regional register allocation by default. If a function
15857contains more loops than the number given by this parameter, only at most
15858the given number of the most frequently-executed loops form regions
15859for regional register allocation.
15860
15861@item ira-max-conflict-table-size
15862Although IRA uses a sophisticated algorithm to compress the conflict
15863table, the table can still require excessive amounts of memory for
15864huge functions. If the conflict table for a function could be more
15865than the size in MB given by this parameter, the register allocator
15866instead uses a faster, simpler, and lower-quality
15867algorithm that does not require building a pseudo-register conflict table.
15868
15869@item ira-loop-reserved-regs
15870IRA can be used to evaluate more accurate register pressure in loops
15871for decisions to move loop invariants (see @option{-O3}). The number
15872of available registers reserved for some other purposes is given
15873by this parameter. Default of the parameter
15874is the best found from numerous experiments.
15875
15876@item ira-consider-dup-in-all-alts
15877Make IRA to consider matching constraint (duplicated operand number)
15878heavily in all available alternatives for preferred register class.
15879If it is set as zero, it means IRA only respects the matching
15880constraint when it's in the only available alternative with an
15881appropriate register class. Otherwise, it means IRA will check all
15882available alternatives for preferred register class even if it has
15883found some choice with an appropriate register class and respect the
15884found qualified matching constraint.
15885
9847c753
ML
15886@item ira-simple-lra-insn-threshold
15887Approximate function insn number in 1K units triggering simple local RA.
15888
d77de738
ML
15889@item lra-inheritance-ebb-probability-cutoff
15890LRA tries to reuse values reloaded in registers in subsequent insns.
15891This optimization is called inheritance. EBB is used as a region to
15892do this optimization. The parameter defines a minimal fall-through
15893edge probability in percentage used to add BB to inheritance EBB in
15894LRA. The default value was chosen
15895from numerous runs of SPEC2000 on x86-64.
15896
15897@item loop-invariant-max-bbs-in-loop
15898Loop invariant motion can be very expensive, both in compilation time and
15899in amount of needed compile-time memory, with very large loops. Loops
15900with more basic blocks than this parameter won't have loop invariant
15901motion optimization performed on them.
15902
15903@item loop-max-datarefs-for-datadeps
15904Building data dependencies is expensive for very large loops. This
15905parameter limits the number of data references in loops that are
15906considered for data dependence analysis. These large loops are no
15907handled by the optimizations using loop data dependencies.
15908
15909@item max-vartrack-size
15910Sets a maximum number of hash table slots to use during variable
15911tracking dataflow analysis of any function. If this limit is exceeded
15912with variable tracking at assignments enabled, analysis for that
15913function is retried without it, after removing all debug insns from
15914the function. If the limit is exceeded even without debug insns, var
15915tracking analysis is completely disabled for the function. Setting
15916the parameter to zero makes it unlimited.
15917
15918@item max-vartrack-expr-depth
15919Sets a maximum number of recursion levels when attempting to map
15920variable names or debug temporaries to value expressions. This trades
15921compilation time for more complete debug information. If this is set too
15922low, value expressions that are available and could be represented in
15923debug information may end up not being used; setting this higher may
15924enable the compiler to find more complex debug expressions, but compile
15925time and memory use may grow.
15926
15927@item max-debug-marker-count
15928Sets a threshold on the number of debug markers (e.g.@: begin stmt
15929markers) to avoid complexity explosion at inlining or expanding to RTL.
15930If a function has more such gimple stmts than the set limit, such stmts
15931will be dropped from the inlined copy of a function, and from its RTL
15932expansion.
15933
15934@item min-nondebug-insn-uid
15935Use uids starting at this parameter for nondebug insns. The range below
15936the parameter is reserved exclusively for debug insns created by
15937@option{-fvar-tracking-assignments}, but debug insns may get
15938(non-overlapping) uids above it if the reserved range is exhausted.
15939
10478270
MJ
15940@item ipa-sra-deref-prob-threshold
15941IPA-SRA replaces a pointer which is known not be NULL with one or more
15942new parameters only when the probability (in percent, relative to
15943function entry) of it being dereferenced is higher than this parameter.
15944
d77de738
ML
15945@item ipa-sra-ptr-growth-factor
15946IPA-SRA replaces a pointer to an aggregate with one or more new
15947parameters only when their cumulative size is less or equal to
15948@option{ipa-sra-ptr-growth-factor} times the size of the original
15949pointer parameter.
15950
69363825
ML
15951@item ipa-sra-ptrwrap-growth-factor
15952Additional maximum allowed growth of total size of new parameters
15953that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15954if it points to a local variable that the caller only writes to and
15955passes it as an argument to other functions.
69363825 15956
d77de738
ML
15957@item ipa-sra-max-replacements
15958Maximum pieces of an aggregate that IPA-SRA tracks. As a
15959consequence, it is also the maximum number of replacements of a formal
15960parameter.
15961
15962@item sra-max-scalarization-size-Ospeed
15963@itemx sra-max-scalarization-size-Osize
15964The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15965replace scalar parts of aggregates with uses of independent scalar
15966variables. These parameters control the maximum size, in storage units,
15967of aggregate which is considered for replacement when compiling for
15968speed
15969(@option{sra-max-scalarization-size-Ospeed}) or size
15970(@option{sra-max-scalarization-size-Osize}) respectively.
15971
15972@item sra-max-propagations
15973The maximum number of artificial accesses that Scalar Replacement of
15974Aggregates (SRA) will track, per one local variable, in order to
15975facilitate copy propagation.
15976
15977@item tm-max-aggregate-size
15978When making copies of thread-local variables in a transaction, this
15979parameter specifies the size in bytes after which variables are
15980saved with the logging functions as opposed to save/restore code
15981sequence pairs. This option only applies when using
15982@option{-fgnu-tm}.
15983
15984@item graphite-max-nb-scop-params
15985To avoid exponential effects in the Graphite loop transforms, the
15986number of parameters in a Static Control Part (SCoP) is bounded.
15987A value of zero can be used to lift
15988the bound. A variable whose value is unknown at compilation time and
15989defined outside a SCoP is a parameter of the SCoP.
15990
551935d1
AO
15991@item hardcfr-max-blocks
15992Disable @option{-fharden-control-flow-redundancy} for functions with a
15993larger number of blocks than the specified value. Zero removes any
15994limit.
15995
15996@item hardcfr-max-inline-blocks
15997Force @option{-fharden-control-flow-redundancy} to use out-of-line
15998checking for functions with a larger number of basic blocks than the
15999specified value.
16000
d77de738
ML
16001@item loop-block-tile-size
16002Loop blocking or strip mining transforms, enabled with
16003@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
16004loop in the loop nest by a given number of iterations. The strip
16005length can be changed using the @option{loop-block-tile-size}
16006parameter.
16007
16008@item ipa-jump-function-lookups
16009Specifies number of statements visited during jump function offset discovery.
16010
16011@item ipa-cp-value-list-size
16012IPA-CP attempts to track all possible values and types passed to a function's
16013parameter in order to propagate them and perform devirtualization.
16014@option{ipa-cp-value-list-size} is the maximum number of values and types it
16015stores per one formal parameter of a function.
16016
16017@item ipa-cp-eval-threshold
16018IPA-CP calculates its own score of cloning profitability heuristics
16019and performs those cloning opportunities with scores that exceed
16020@option{ipa-cp-eval-threshold}.
16021
16022@item ipa-cp-max-recursive-depth
16023Maximum depth of recursive cloning for self-recursive function.
16024
16025@item ipa-cp-min-recursive-probability
16026Recursive cloning only when the probability of call being executed exceeds
16027the parameter.
16028
16029@item ipa-cp-profile-count-base
16030When using @option{-fprofile-use} option, IPA-CP will consider the measured
16031execution count of a call graph edge at this percentage position in their
16032histogram as the basis for its heuristics calculation.
16033
16034@item ipa-cp-recursive-freq-factor
16035The number of times interprocedural copy propagation expects recursive
16036functions to call themselves.
16037
16038@item ipa-cp-recursion-penalty
16039Percentage penalty the recursive functions will receive when they
16040are evaluated for cloning.
16041
16042@item ipa-cp-single-call-penalty
16043Percentage penalty functions containing a single call to another
16044function will receive when they are evaluated for cloning.
16045
16046@item ipa-max-agg-items
16047IPA-CP is also capable to propagate a number of scalar values passed
16048in an aggregate. @option{ipa-max-agg-items} controls the maximum
16049number of such values per one parameter.
16050
16051@item ipa-cp-loop-hint-bonus
16052When IPA-CP determines that a cloning candidate would make the number
16053of iterations of a loop known, it adds a bonus of
16054@option{ipa-cp-loop-hint-bonus} to the profitability score of
16055the candidate.
16056
16057@item ipa-max-loop-predicates
16058The maximum number of different predicates IPA will use to describe when
16059loops in a function have known properties.
16060
16061@item ipa-max-aa-steps
16062During its analysis of function bodies, IPA-CP employs alias analysis
16063in order to track values pointed to by function parameters. In order
16064not spend too much time analyzing huge functions, it gives up and
16065consider all memory clobbered after examining
16066@option{ipa-max-aa-steps} statements modifying memory.
16067
16068@item ipa-max-switch-predicate-bounds
16069Maximal number of boundary endpoints of case ranges of switch statement.
16070For switch exceeding this limit, IPA-CP will not construct cloning cost
16071predicate, which is used to estimate cloning benefit, for default case
16072of the switch statement.
16073
16074@item ipa-max-param-expr-ops
16075IPA-CP will analyze conditional statement that references some function
16076parameter to estimate benefit for cloning upon certain constant value.
16077But if number of operations in a parameter expression exceeds
16078@option{ipa-max-param-expr-ops}, the expression is treated as complicated
16079one, and is not handled by IPA analysis.
16080
16081@item lto-partitions
16082Specify desired number of partitions produced during WHOPR compilation.
16083The number of partitions should exceed the number of CPUs used for compilation.
16084
16085@item lto-min-partition
16086Size of minimal partition for WHOPR (in estimated instructions).
16087This prevents expenses of splitting very small programs into too many
16088partitions.
16089
16090@item lto-max-partition
16091Size of max partition for WHOPR (in estimated instructions).
16092to provide an upper bound for individual size of partition.
16093Meant to be used only with balanced partitioning.
16094
16095@item lto-max-streaming-parallelism
16096Maximal number of parallel processes used for LTO streaming.
16097
16098@item cxx-max-namespaces-for-diagnostic-help
16099The maximum number of namespaces to consult for suggestions when C++
16100name lookup fails for an identifier.
16101
16102@item sink-frequency-threshold
16103The maximum relative execution frequency (in percents) of the target block
16104relative to a statement's original block to allow statement sinking of a
16105statement. Larger numbers result in more aggressive statement sinking.
16106A small positive adjustment is applied for
16107statements with memory operands as those are even more profitable so sink.
16108
16109@item max-stores-to-sink
16110The maximum number of conditional store pairs that can be sunk. Set to 0
16111if either vectorization (@option{-ftree-vectorize}) or if-conversion
16112(@option{-ftree-loop-if-convert}) is disabled.
16113
16114@item case-values-threshold
16115The smallest number of different values for which it is best to use a
16116jump-table instead of a tree of conditional branches. If the value is
161170, use the default for the machine.
16118
16119@item jump-table-max-growth-ratio-for-size
16120The maximum code size growth ratio when expanding
16121into a jump table (in percent). The parameter is used when
16122optimizing for size.
16123
16124@item jump-table-max-growth-ratio-for-speed
16125The maximum code size growth ratio when expanding
16126into a jump table (in percent). The parameter is used when
16127optimizing for speed.
16128
16129@item tree-reassoc-width
16130Set the maximum number of instructions executed in parallel in
16131reassociated tree. This parameter overrides target dependent
16132heuristics used by default if has non zero value.
16133
16134@item sched-pressure-algorithm
16135Choose between the two available implementations of
16136@option{-fsched-pressure}. Algorithm 1 is the original implementation
16137and is the more likely to prevent instructions from being reordered.
16138Algorithm 2 was designed to be a compromise between the relatively
16139conservative approach taken by algorithm 1 and the rather aggressive
16140approach taken by the default scheduler. It relies more heavily on
16141having a regular register file and accurate register pressure classes.
16142See @file{haifa-sched.cc} in the GCC sources for more details.
16143
16144The default choice depends on the target.
16145
16146@item max-slsr-cand-scan
16147Set the maximum number of existing candidates that are considered when
16148seeking a basis for a new straight-line strength reduction candidate.
16149
16150@item asan-globals
16151Enable buffer overflow detection for global objects. This kind
16152of protection is enabled by default if you are using
16153@option{-fsanitize=address} option.
16154To disable global objects protection use @option{--param asan-globals=0}.
16155
16156@item asan-stack
16157Enable buffer overflow detection for stack objects. This kind of
16158protection is enabled by default when using @option{-fsanitize=address}.
16159To disable stack protection use @option{--param asan-stack=0} option.
16160
16161@item asan-instrument-reads
16162Enable buffer overflow detection for memory reads. This kind of
16163protection is enabled by default when using @option{-fsanitize=address}.
16164To disable memory reads protection use
16165@option{--param asan-instrument-reads=0}.
16166
16167@item asan-instrument-writes
16168Enable buffer overflow detection for memory writes. This kind of
16169protection is enabled by default when using @option{-fsanitize=address}.
16170To disable memory writes protection use
16171@option{--param asan-instrument-writes=0} option.
16172
16173@item asan-memintrin
16174Enable detection for built-in functions. This kind of protection
16175is enabled by default when using @option{-fsanitize=address}.
16176To disable built-in functions protection use
16177@option{--param asan-memintrin=0}.
16178
16179@item asan-use-after-return
16180Enable detection of use-after-return. This kind of protection
16181is enabled by default when using the @option{-fsanitize=address} option.
16182To disable it use @option{--param asan-use-after-return=0}.
16183
16184Note: By default the check is disabled at run time. To enable it,
16185add @code{detect_stack_use_after_return=1} to the environment variable
16186@env{ASAN_OPTIONS}.
16187
16188@item asan-instrumentation-with-call-threshold
16189If number of memory accesses in function being instrumented
16190is greater or equal to this number, use callbacks instead of inline checks.
16191E.g. to disable inline code use
16192@option{--param asan-instrumentation-with-call-threshold=0}.
16193
545c9f8b 16194@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
16195If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
16196with @samp{__asan_} or @samp{__hwasan_}
16197for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
16198respectively.
545c9f8b 16199
d77de738
ML
16200@item hwasan-instrument-stack
16201Enable hwasan instrumentation of statically sized stack-allocated variables.
16202This kind of instrumentation is enabled by default when using
16203@option{-fsanitize=hwaddress} and disabled by default when using
16204@option{-fsanitize=kernel-hwaddress}.
16205To disable stack instrumentation use
16206@option{--param hwasan-instrument-stack=0}, and to enable it use
16207@option{--param hwasan-instrument-stack=1}.
16208
16209@item hwasan-random-frame-tag
16210When using stack instrumentation, decide tags for stack variables using a
16211deterministic sequence beginning at a random tag for each frame. With this
16212parameter unset tags are chosen using the same sequence but beginning from 1.
16213This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16214for @option{-fsanitize=kernel-hwaddress}.
16215To disable it use @option{--param hwasan-random-frame-tag=0}.
16216
16217@item hwasan-instrument-allocas
16218Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16219This kind of instrumentation is enabled by default when using
16220@option{-fsanitize=hwaddress} and disabled by default when using
16221@option{-fsanitize=kernel-hwaddress}.
16222To disable instrumentation of such variables use
16223@option{--param hwasan-instrument-allocas=0}, and to enable it use
16224@option{--param hwasan-instrument-allocas=1}.
16225
16226@item hwasan-instrument-reads
16227Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16228default for both @option{-fsanitize=hwaddress} and
16229@option{-fsanitize=kernel-hwaddress}.
16230To disable checking memory reads use
16231@option{--param hwasan-instrument-reads=0}.
16232
16233@item hwasan-instrument-writes
16234Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16235default for both @option{-fsanitize=hwaddress} and
16236@option{-fsanitize=kernel-hwaddress}.
16237To disable checking memory writes use
16238@option{--param hwasan-instrument-writes=0}.
16239
16240@item hwasan-instrument-mem-intrinsics
16241Enable hwasan instrumentation of builtin functions. Instrumentation of these
16242builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16243and @option{-fsanitize=kernel-hwaddress}.
16244To disable instrumentation of builtin functions use
16245@option{--param hwasan-instrument-mem-intrinsics=0}.
16246
16247@item use-after-scope-direct-emission-threshold
16248If the size of a local variable in bytes is smaller or equal to this
16249number, directly poison (or unpoison) shadow memory instead of using
16250run-time callbacks.
16251
16252@item tsan-distinguish-volatile
16253Emit special instrumentation for accesses to volatiles.
16254
16255@item tsan-instrument-func-entry-exit
16256Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16257
16258@item max-fsm-thread-path-insns
16259Maximum number of instructions to copy when duplicating blocks on a
16260finite state automaton jump thread path.
16261
16262@item threader-debug
16263threader-debug=[none|all] Enables verbose dumping of the threader solver.
16264
16265@item parloops-chunk-size
16266Chunk size of omp schedule for loops parallelized by parloops.
16267
16268@item parloops-schedule
16269Schedule type of omp schedule for loops parallelized by parloops (static,
16270dynamic, guided, auto, runtime).
16271
16272@item parloops-min-per-thread
16273The minimum number of iterations per thread of an innermost parallelized
16274loop for which the parallelized variant is preferred over the single threaded
16275one. Note that for a parallelized loop nest the
16276minimum number of iterations of the outermost loop per thread is two.
16277
16278@item max-ssa-name-query-depth
16279Maximum depth of recursion when querying properties of SSA names in things
16280like fold routines. One level of recursion corresponds to following a
16281use-def chain.
16282
16283@item max-speculative-devirt-maydefs
16284The maximum number of may-defs we analyze when looking for a must-def
16285specifying the dynamic type of an object that invokes a virtual call
16286we may be able to devirtualize speculatively.
16287
d77de738
ML
16288@item ranger-debug
16289Specifies the type of debug output to be issued for ranges.
16290
d77de738
ML
16291@item unroll-jam-min-percent
16292The minimum percentage of memory references that must be optimized
16293away for the unroll-and-jam transformation to be considered profitable.
16294
16295@item unroll-jam-max-unroll
16296The maximum number of times the outer loop should be unrolled by
16297the unroll-and-jam transformation.
16298
16299@item max-rtl-if-conversion-unpredictable-cost
16300Maximum permissible cost for the sequence that would be generated
16301by the RTL if-conversion pass for a branch that is considered unpredictable.
16302
16303@item max-variable-expansions-in-unroller
16304If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16305of times that an individual variable will be expanded during loop unrolling.
16306
16307@item partial-inlining-entry-probability
16308Maximum probability of the entry BB of split region
16309(in percent relative to entry BB of the function)
16310to make partial inlining happen.
16311
16312@item max-tracked-strlens
16313Maximum number of strings for which strlen optimization pass will
16314track string lengths.
16315
16316@item gcse-after-reload-partial-fraction
16317The threshold ratio for performing partial redundancy
16318elimination after reload.
16319
16320@item gcse-after-reload-critical-fraction
16321The threshold ratio of critical edges execution count that
16322permit performing redundancy elimination after reload.
16323
16324@item max-loop-header-insns
16325The maximum number of insns in loop header duplicated
16326by the copy loop headers pass.
16327
16328@item vect-epilogues-nomask
16329Enable loop epilogue vectorization using smaller vector size.
16330
16331@item vect-partial-vector-usage
16332Controls when the loop vectorizer considers using partial vector loads
16333and stores as an alternative to falling back to scalar code. 0 stops
16334the vectorizer from ever using partial vector loads and stores. 1 allows
16335partial vector loads and stores if vectorization removes the need for the
16336code to iterate. 2 allows partial vector loads and stores in all loops.
16337The parameter only has an effect on targets that support partial
16338vector loads and stores.
16339
16340@item vect-inner-loop-cost-factor
16341The maximum factor which the loop vectorizer applies to the cost of statements
16342in an inner loop relative to the loop being vectorized. The factor applied
16343is the maximum of the estimated number of iterations of the inner loop and
16344this parameter. The default value of this parameter is 50.
16345
16346@item vect-induction-float
16347Enable loop vectorization of floating point inductions.
16348
cbe32d38
ML
16349@item vrp-sparse-threshold
16350Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16351
16352@item vrp-switch-limit
16353Maximum number of outgoing edges in a switch before VRP will not process it.
16354
16355@item vrp-vector-threshold
16356Maximum number of basic blocks for VRP to use a basic cache vector.
16357
d77de738
ML
16358@item avoid-fma-max-bits
16359Maximum number of bits for which we avoid creating FMAs.
16360
16361@item sms-loop-average-count-threshold
16362A threshold on the average loop count considered by the swing modulo scheduler.
16363
16364@item sms-dfa-history
16365The number of cycles the swing modulo scheduler considers when checking
16366conflicts using DFA.
16367
16368@item graphite-allow-codegen-errors
16369Whether codegen errors should be ICEs when @option{-fchecking}.
16370
16371@item sms-max-ii-factor
16372A factor for tuning the upper bound that swing modulo scheduler
16373uses for scheduling a loop.
16374
16375@item lra-max-considered-reload-pseudos
16376The max number of reload pseudos which are considered during
16377spilling a non-reload pseudo.
16378
16379@item max-pow-sqrt-depth
16380Maximum depth of sqrt chains to use when synthesizing exponentiation
16381by a real constant.
16382
16383@item max-dse-active-local-stores
16384Maximum number of active local stores in RTL dead store elimination.
16385
16386@item asan-instrument-allocas
16387Enable asan allocas/VLAs protection.
16388
16389@item max-iterations-computation-cost
16390Bound on the cost of an expression to compute the number of iterations.
16391
16392@item max-isl-operations
16393Maximum number of isl operations, 0 means unlimited.
16394
16395@item graphite-max-arrays-per-scop
16396Maximum number of arrays per scop.
16397
16398@item max-vartrack-reverse-op-size
16399Max. size of loc list for which reverse ops should be added.
16400
16401@item fsm-scale-path-stmts
16402Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16403crossing a loop backedge when comparing to
16404@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16405
16406@item uninit-control-dep-attempts
16407Maximum number of nested calls to search for control dependencies
16408during uninitialized variable analysis.
16409
b8a2a124
RB
16410@item uninit-max-chain-len
16411Maximum number of predicates anded for each predicate ored in the normalized
16412predicate chain.
16413
16414@item uninit-max-num-chains
16415Maximum number of predicates ored in the normalized predicate chain.
16416
d77de738
ML
16417@item sched-autopref-queue-depth
16418Hardware autoprefetcher scheduler model control flag.
16419Number of lookahead cycles the model looks into; at '
16420' only enable instruction sorting heuristic.
16421
16422@item loop-versioning-max-inner-insns
16423The maximum number of instructions that an inner loop can have
16424before the loop versioning pass considers it too big to copy.
16425
16426@item loop-versioning-max-outer-insns
16427The maximum number of instructions that an outer loop can have
16428before the loop versioning pass considers it too big to copy,
16429discounting any instructions in inner loops that directly benefit
16430from versioning.
16431
16432@item ssa-name-def-chain-limit
16433The maximum number of SSA_NAME assignments to follow in determining
16434a property of a variable such as its value. This limits the number
16435of iterations or recursive calls GCC performs when optimizing certain
16436statements or when determining their validity prior to issuing
16437diagnostics.
16438
16439@item store-merging-max-size
16440Maximum size of a single store merging region in bytes.
16441
16442@item hash-table-verification-limit
16443The number of elements for which hash table verification is done
16444for each searched element.
16445
16446@item max-find-base-term-values
16447Maximum number of VALUEs handled during a single find_base_term call.
16448
16449@item analyzer-max-enodes-per-program-point
16450The maximum number of exploded nodes per program point within
16451the analyzer, before terminating analysis of that point.
16452
16453@item analyzer-max-constraints
16454The maximum number of constraints per state.
16455
16456@item analyzer-min-snodes-for-call-summary
16457The minimum number of supernodes within a function for the
16458analyzer to consider summarizing its effects at call sites.
16459
16460@item analyzer-max-enodes-for-full-dump
16461The maximum depth of exploded nodes that should appear in a dot dump
16462before switching to a less verbose format.
16463
16464@item analyzer-max-recursion-depth
16465The maximum number of times a callsite can appear in a call stack
16466within the analyzer, before terminating analysis of a call that would
16467recurse deeper.
16468
16469@item analyzer-max-svalue-depth
16470The maximum depth of a symbolic value, before approximating
16471the value as unknown.
16472
16473@item analyzer-max-infeasible-edges
16474The maximum number of infeasible edges to reject before declaring
16475a diagnostic as infeasible.
16476
16477@item gimple-fe-computed-hot-bb-threshold
16478The number of executions of a basic block which is considered hot.
16479The parameter is used only in GIMPLE FE.
16480
16481@item analyzer-bb-explosion-factor
16482The maximum number of 'after supernode' exploded nodes within the analyzer
16483per supernode, before terminating analysis.
16484
c0c5a57b
MJ
16485@item analyzer-text-art-string-ellipsis-threshold
16486The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
16487
16488@item analyzer-text-art-ideal-canvas-width
16489The ideal width in characters of text art diagrams generated by the analyzer.
16490
16491@item analyzer-text-art-string-ellipsis-head-len
16492The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
16493
16494@item analyzer-text-art-string-ellipsis-tail-len
16495The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
16496
d77de738
ML
16497@item ranger-logical-depth
16498Maximum depth of logical expression evaluation ranger will look through
16499when evaluating outgoing edge ranges.
16500
9fd6d83a
ML
16501@item ranger-recompute-depth
16502Maximum depth of instruction chains to consider for recomputation
16503in the outgoing range calculator.
16504
d77de738
ML
16505@item relation-block-limit
16506Maximum number of relations the oracle will register in a basic block.
16507
16508@item min-pagesize
16509Minimum page size for warning purposes.
16510
16511@item openacc-kernels
16512Specify mode of OpenACC `kernels' constructs handling.
16513With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16514constructs are decomposed into parts, a sequence of compute
16515constructs, each then handled individually.
16516This is work in progress.
16517With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16518constructs are handled by the @samp{parloops} pass, en bloc.
16519This is the current default.
16520
16521@item openacc-privatization
4ace81b6
SL
16522Control whether the @option{-fopt-info-omp-note} and applicable
16523@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16524With @option{--param=openacc-privatization=quiet}, don't diagnose.
16525This is the current default.
16526With @option{--param=openacc-privatization=noisy}, do diagnose.
16527
16528@end table
16529
16530The following choices of @var{name} are available on AArch64 targets:
16531
16532@table @gcctabopt
16533@item aarch64-sve-compare-costs
16534When vectorizing for SVE, consider using ``unpacked'' vectors for
16535smaller elements and use the cost model to pick the cheapest approach.
16536Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16537
16538Using unpacked vectors includes storing smaller elements in larger
16539containers and accessing elements with extending loads and truncating
16540stores.
16541
16542@item aarch64-float-recp-precision
16543The number of Newton iterations for calculating the reciprocal for float type.
16544The precision of division is proportional to this param when division
16545approximation is enabled. The default value is 1.
16546
16547@item aarch64-double-recp-precision
16548The number of Newton iterations for calculating the reciprocal for double type.
16549The precision of division is propotional to this param when division
16550approximation is enabled. The default value is 2.
16551
16552@item aarch64-autovec-preference
16553Force an ISA selection strategy for auto-vectorization. Accepts values from
165540 to 4, inclusive.
16555@table @samp
16556@item 0
16557Use the default heuristics.
16558@item 1
16559Use only Advanced SIMD for auto-vectorization.
16560@item 2
16561Use only SVE for auto-vectorization.
16562@item 3
16563Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16564deemed equal.
16565@item 4
16566Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16567@end table
16568The default value is 0.
16569
834fc2bf
MA
16570@item aarch64-ldp-policy
16571Fine-grained policy for load pairs.
16572With @option{--param=aarch64-ldp-policy=default}, use the policy of the
16573tuning structure. This is the current default.
16574With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
16575of alignment.
16576With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
16577With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
16578source pointer is aligned to at least double the alignment of the type.
16579
16580@item aarch64-stp-policy
16581Fine-grained policy for store pairs.
16582With @option{--param=aarch64-stp-policy=default}, use the policy of the
16583tuning structure. This is the current default.
16584With @option{--param=aarch64-stp-policy=always}, emit stp regardless
16585of alignment.
16586With @option{--param=aarch64-stp-policy=never}, do not emit stp.
16587With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
16588source pointer is aligned to at least double the alignment of the type.
16589
d77de738
ML
16590@item aarch64-loop-vect-issue-rate-niters
16591The tuning for some AArch64 CPUs tries to take both latencies and issue
16592rates into account when deciding whether a loop should be vectorized
16593using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16594If this parameter is set to @var{n}, GCC will not use this heuristic
16595for loops that are known to execute in fewer than @var{n} Advanced
16596SIMD iterations.
16597
16598@item aarch64-vect-unroll-limit
16599The vectorizer will use available tuning information to determine whether it
16600would be beneficial to unroll the main vectorized loop and by how much. This
16601parameter set's the upper bound of how much the vectorizer will unroll the main
16602loop. The default value is four.
16603
16604@end table
16605
16606The following choices of @var{name} are available on i386 and x86_64 targets:
16607
16608@table @gcctabopt
16609@item x86-stlf-window-ninsns
16610Instructions number above which STFL stall penalty can be compensated.
16611
60101899
RB
16612@item x86-stv-max-visits
16613The maximum number of use and def visits when discovering a STV chain before
16614the discovery is aborted.
16615
d77de738
ML
16616@end table
16617
16618@end table
16619
16620@node Instrumentation Options
16621@section Program Instrumentation Options
16622@cindex instrumentation options
16623@cindex program instrumentation options
16624@cindex run-time error checking options
16625@cindex profiling options
16626@cindex options, program instrumentation
16627@cindex options, run-time error checking
16628@cindex options, profiling
16629
16630GCC supports a number of command-line options that control adding
16631run-time instrumentation to the code it normally generates.
16632For example, one purpose of instrumentation is collect profiling
16633statistics for use in finding program hot spots, code coverage
16634analysis, or profile-guided optimizations.
16635Another class of program instrumentation is adding run-time checking
16636to detect programming errors like invalid pointer
16637dereferences or out-of-bounds array accesses, as well as deliberately
16638hostile attacks such as stack smashing or C++ vtable hijacking.
16639There is also a general hook which can be used to implement other
16640forms of tracing or function-level instrumentation for debug or
16641program analysis purposes.
16642
16643@table @gcctabopt
16644@cindex @command{prof}
16645@cindex @command{gprof}
d77de738
ML
16646@opindex p
16647@opindex pg
ddf6fe37
AA
16648@item -p
16649@itemx -pg
d77de738
ML
16650Generate extra code to write profile information suitable for the
16651analysis program @command{prof} (for @option{-p}) or @command{gprof}
16652(for @option{-pg}). You must use this option when compiling
16653the source files you want data about, and you must also use it when
16654linking.
16655
16656You can use the function attribute @code{no_instrument_function} to
16657suppress profiling of individual functions when compiling with these options.
16658@xref{Common Function Attributes}.
16659
d77de738 16660@opindex fprofile-arcs
ddf6fe37 16661@item -fprofile-arcs
d77de738
ML
16662Add code so that program flow @dfn{arcs} are instrumented. During
16663execution the program records how many times each branch and call is
16664executed and how many times it is taken or returns. On targets that support
16665constructors with priority support, profiling properly handles constructors,
16666destructors and C++ constructors (and destructors) of classes which are used
16667as a type of a global variable.
16668
16669When the compiled
16670program exits it saves this data to a file called
16671@file{@var{auxname}.gcda} for each source file. The data may be used for
16672profile-directed optimizations (@option{-fbranch-probabilities}), or for
16673test coverage analysis (@option{-ftest-coverage}). Each object file's
16674@var{auxname} is generated from the name of the output file, if
16675explicitly specified and it is not the final executable, otherwise it is
16676the basename of the source file. In both cases any suffix is removed
16677(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16678@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16679
16680Note that if a command line directly links source files, the corresponding
16681@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16682E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16683@file{binary-b.gcda} files.
16684
16685@xref{Cross-profiling}.
16686
16687@cindex @command{gcov}
d77de738 16688@opindex coverage
ddf6fe37 16689@item --coverage
d77de738
ML
16690
16691This option is used to compile and link code instrumented for coverage
16692analysis. The option is a synonym for @option{-fprofile-arcs}
16693@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16694linking). See the documentation for those options for more details.
16695
16696@itemize
16697
16698@item
16699Compile the source files with @option{-fprofile-arcs} plus optimization
16700and code generation options. For test coverage analysis, use the
16701additional @option{-ftest-coverage} option. You do not need to profile
16702every source file in a program.
16703
16704@item
16705Compile the source files additionally with @option{-fprofile-abs-path}
16706to create absolute path names in the @file{.gcno} files. This allows
16707@command{gcov} to find the correct sources in projects where compilations
16708occur with different working directories.
16709
16710@item
16711Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16712(the latter implies the former).
16713
16714@item
16715Run the program on a representative workload to generate the arc profile
16716information. This may be repeated any number of times. You can run
16717concurrent instances of your program, and provided that the file system
16718supports locking, the data files will be correctly updated. Unless
16719a strict ISO C dialect option is in effect, @code{fork} calls are
16720detected and correctly handled without double counting.
16721
16722Moreover, an object file can be recompiled multiple times
16723and the corresponding @file{.gcda} file merges as long as
16724the source file and the compiler options are unchanged.
16725
16726@item
16727For profile-directed optimizations, compile the source files again with
16728the same optimization and code generation options plus
16729@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16730Control Optimization}).
16731
16732@item
16733For test coverage analysis, use @command{gcov} to produce human readable
16734information from the @file{.gcno} and @file{.gcda} files. Refer to the
16735@command{gcov} documentation for further information.
16736
16737@end itemize
16738
16739With @option{-fprofile-arcs}, for each function of your program GCC
16740creates a program flow graph, then finds a spanning tree for the graph.
16741Only arcs that are not on the spanning tree have to be instrumented: the
16742compiler adds code to count the number of times that these arcs are
16743executed. When an arc is the only exit or only entrance to a block, the
16744instrumentation code can be added to the block; otherwise, a new basic
16745block must be created to hold the instrumentation code.
16746
16747@need 2000
d77de738 16748@opindex ftest-coverage
ddf6fe37 16749@item -ftest-coverage
d77de738
ML
16750Produce a notes file that the @command{gcov} code-coverage utility
16751(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16752show program coverage. Each source file's note file is called
16753@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16754above for a description of @var{auxname} and instructions on how to
16755generate test coverage data. Coverage data matches the source files
16756more closely if you do not optimize.
16757
d77de738 16758@opindex fprofile-abs-path
ddf6fe37 16759@item -fprofile-abs-path
d77de738
ML
16760Automatically convert relative source file names to absolute path names
16761in the @file{.gcno} files. This allows @command{gcov} to find the correct
16762sources in projects where compilations occur with different working
16763directories.
16764
d77de738 16765@opindex fprofile-dir
ddf6fe37 16766@item -fprofile-dir=@var{path}
d77de738
ML
16767
16768Set the directory to search for the profile data files in to @var{path}.
16769This option affects only the profile data generated by
16770@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16771and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16772and its related options. Both absolute and relative paths can be used.
16773By default, GCC uses the current directory as @var{path}, thus the
16774profile data file appears in the same directory as the object file.
16775In order to prevent the file name clashing, if the object file name is
16776not an absolute path, we mangle the absolute path of the
16777@file{@var{sourcename}.gcda} file and use it as the file name of a
16778@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16779See similar option @option{-fprofile-note}.
16780
16781When an executable is run in a massive parallel environment, it is recommended
16782to save profile to different folders. That can be done with variables
16783in @var{path} that are exported during run-time:
16784
16785@table @gcctabopt
16786
16787@item %p
16788process ID.
16789
16790@item %q@{VAR@}
16791value of environment variable @var{VAR}
16792
16793@end table
16794
ddf6fe37 16795@opindex fprofile-generate
d77de738
ML
16796@item -fprofile-generate
16797@itemx -fprofile-generate=@var{path}
d77de738
ML
16798
16799Enable options usually used for instrumenting application to produce
16800profile useful for later recompilation with profile feedback based
16801optimization. You must use @option{-fprofile-generate} both when
16802compiling and when linking your program.
16803
16804The following options are enabled:
16805@option{-fprofile-arcs}, @option{-fprofile-values},
16806@option{-finline-functions}, and @option{-fipa-bit-cp}.
16807
16808If @var{path} is specified, GCC looks at the @var{path} to find
16809the profile feedback data files. See @option{-fprofile-dir}.
16810
16811To optimize the program based on the collected profile information, use
16812@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16813
ddf6fe37 16814@opindex fprofile-info-section
d77de738
ML
16815@item -fprofile-info-section
16816@itemx -fprofile-info-section=@var{name}
d77de738
ML
16817
16818Register the profile information in the specified section instead of using a
16819constructor/destructor. The section name is @var{name} if it is specified,
16820otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16821profile information generated by @option{-fprofile-arcs} is placed in the
16822specified section for each translation unit. This option disables the profile
16823information registration through a constructor and it disables the profile
16824information processing through a destructor. This option is not intended to be
16825used in hosted environments such as GNU/Linux. It targets freestanding
16826environments (for example embedded systems) with limited resources which do not
16827support constructors/destructors or the C library file I/O.
16828
16829The linker could collect the input sections in a continuous memory block and
16830define start and end symbols. A GNU linker script example which defines a
16831linker output section follows:
16832
16833@smallexample
16834 .gcov_info :
16835 @{
16836 PROVIDE (__gcov_info_start = .);
16837 KEEP (*(.gcov_info))
16838 PROVIDE (__gcov_info_end = .);
16839 @}
16840@end smallexample
16841
16842The program could dump the profiling information registered in this linker set
16843for example like this:
16844
16845@smallexample
16846#include <gcov.h>
16847#include <stdio.h>
16848#include <stdlib.h>
16849
16850extern const struct gcov_info *const __gcov_info_start[];
16851extern const struct gcov_info *const __gcov_info_end[];
16852
16853static void
16854dump (const void *d, unsigned n, void *arg)
16855@{
16856 const unsigned char *c = d;
16857
16858 for (unsigned i = 0; i < n; ++i)
16859 printf ("%02x", c[i]);
16860@}
16861
16862static void
16863filename (const char *f, void *arg)
16864@{
16865 __gcov_filename_to_gcfn (f, dump, arg );
16866@}
16867
16868static void *
16869allocate (unsigned length, void *arg)
16870@{
16871 return malloc (length);
16872@}
16873
16874static void
16875dump_gcov_info (void)
16876@{
16877 const struct gcov_info *const *info = __gcov_info_start;
16878 const struct gcov_info *const *end = __gcov_info_end;
16879
16880 /* Obfuscate variable to prevent compiler optimizations. */
16881 __asm__ ("" : "+r" (info));
16882
16883 while (info != end)
16884 @{
16885 void *arg = NULL;
16886 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16887 putchar ('\n');
16888 ++info;
16889 @}
16890@}
16891
16892int
16893main (void)
16894@{
16895 dump_gcov_info ();
16896 return 0;
16897@}
16898@end smallexample
16899
16900The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16901deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16902@code{__gcov_info_to_gcda} functions and merge the profile information into
16903@file{.gcda} files on the host filesystem.
16904
d77de738 16905@opindex fprofile-note
ddf6fe37 16906@item -fprofile-note=@var{path}
d77de738
ML
16907
16908If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16909location. If you combine the option with multiple source files,
16910the @file{.gcno} file will be overwritten.
16911
d77de738 16912@opindex fprofile-prefix-path
ddf6fe37 16913@item -fprofile-prefix-path=@var{path}
d77de738
ML
16914
16915This option can be used in combination with
16916@option{profile-generate=}@var{profile_dir} and
16917@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16918directory of built source tree. By default @var{profile_dir} will contain
16919files with mangled absolute paths of all object files in the built project.
16920This is not desirable when directory used to build the instrumented binary
16921differs from the directory used to build the binary optimized with profile
16922feedback because the profile data will not be found during the optimized build.
16923In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16924pointing to the base directory of the build can be used to strip the irrelevant
16925part of the path and keep all file names relative to the main build directory.
16926
d77de738 16927@opindex fprofile-prefix-map
ddf6fe37 16928@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16929When compiling files residing in directory @file{@var{old}}, record
16930profiling information (with @option{--coverage})
16931describing them as if the files resided in
16932directory @file{@var{new}} instead.
2eb0191a 16933See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16934
d77de738 16935@opindex fprofile-update
ddf6fe37 16936@item -fprofile-update=@var{method}
d77de738
ML
16937
16938Alter the update method for an application instrumented for profile
16939feedback based optimization. The @var{method} argument should be one of
16940@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16941The first one is useful for single-threaded applications,
16942while the second one prevents profile corruption by emitting thread-safe code.
16943
16944@strong{Warning:} When an application does not properly join all threads
16945(or creates an detached thread), a profile file can be still corrupted.
16946
16947Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16948when supported by a target, or to @samp{single} otherwise. The GCC driver
16949automatically selects @samp{prefer-atomic} when @option{-pthread}
16950is present in the command line.
16951
d77de738 16952@opindex fprofile-filter-files
ddf6fe37 16953@item -fprofile-filter-files=@var{regex}
d77de738
ML
16954
16955Instrument only functions from files whose name matches
16956any of the regular expressions (separated by semi-colons).
16957
16958For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16959only @file{main.c} and all C files starting with 'module'.
16960
d77de738 16961@opindex fprofile-exclude-files
ddf6fe37 16962@item -fprofile-exclude-files=@var{regex}
d77de738
ML
16963
16964Instrument only functions from files whose name does not match
16965any of the regular expressions (separated by semi-colons).
16966
16967For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16968of all files that are located in the @file{/usr/} folder.
16969
d77de738 16970@opindex fprofile-reproducible
ddf6fe37 16971@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
16972Control level of reproducibility of profile gathered by
16973@code{-fprofile-generate}. This makes it possible to rebuild program
16974with same outcome which is useful, for example, for distribution
16975packages.
16976
16977With @option{-fprofile-reproducible=serial} the profile gathered by
16978@option{-fprofile-generate} is reproducible provided the trained program
16979behaves the same at each invocation of the train run, it is not
16980multi-threaded and profile data streaming is always done in the same
16981order. Note that profile streaming happens at the end of program run but
16982also before @code{fork} function is invoked.
16983
16984Note that it is quite common that execution counts of some part of
16985programs depends, for example, on length of temporary file names or
16986memory space randomization (that may affect hash-table collision rate).
16987Such non-reproducible part of programs may be annotated by
16988@code{no_instrument_function} function attribute. @command{gcov-dump} with
16989@option{-l} can be used to dump gathered data and verify that they are
16990indeed reproducible.
16991
16992With @option{-fprofile-reproducible=parallel-runs} collected profile
16993stays reproducible regardless the order of streaming of the data into
16994gcda files. This setting makes it possible to run multiple instances of
16995instrumented program in parallel (such as with @code{make -j}). This
16996reduces quality of gathered data, in particular of indirect call
16997profiling.
16998
d77de738 16999@opindex fsanitize=address
ddf6fe37 17000@item -fsanitize=address
d77de738
ML
17001Enable AddressSanitizer, a fast memory error detector.
17002Memory access instructions are instrumented to detect
17003out-of-bounds and use-after-free bugs.
17004The option enables @option{-fsanitize-address-use-after-scope}.
17005See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
17006more details. The run-time behavior can be influenced using the
17007@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
17008the available options are shown at startup of the instrumented program. See
17009@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
17010for a list of supported options.
17011The option cannot be combined with @option{-fsanitize=thread} or
17012@option{-fsanitize=hwaddress}. Note that the only target
17013@option{-fsanitize=hwaddress} is currently supported on is AArch64.
17014
6a07798c
MP
17015To get more accurate stack traces, it is possible to use options such as
17016@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
17017most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
17018optimizing sibling and tail recursive calls; this option is implicit for
17019@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
17020disables Identical Code Folding for functions). Since multiple runs of the
17021program may yield backtraces with different addresses due to ASLR (Address
17022Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
17023this can be achieved with @samp{setarch `uname -m` -R ./prog}.
17024
d77de738 17025@opindex fsanitize=kernel-address
f33d7a88 17026@item -fsanitize=kernel-address
d77de738 17027Enable AddressSanitizer for Linux kernel.
a0bf71be 17028See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 17029
d77de738 17030@opindex fsanitize=hwaddress
f33d7a88 17031@item -fsanitize=hwaddress
d77de738
ML
17032Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
17033ignore the top byte of a pointer to allow the detection of memory errors with
17034a low memory overhead.
17035Memory access instructions are instrumented to detect out-of-bounds and
17036use-after-free bugs.
17037The option enables @option{-fsanitize-address-use-after-scope}.
17038See
17039@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
17040for more details. The run-time behavior can be influenced using the
17041@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
17042the available options are shown at startup of the instrumented program.
17043The option cannot be combined with @option{-fsanitize=thread} or
17044@option{-fsanitize=address}, and is currently only available on AArch64.
17045
d77de738 17046@opindex fsanitize=kernel-hwaddress
ddf6fe37 17047@item -fsanitize=kernel-hwaddress
d77de738
ML
17048Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
17049Similar to @option{-fsanitize=kernel-address} but using an alternate
17050instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
17051instrumentation differences necessary for compiling the Linux kernel.
17052These differences are to avoid hwasan library initialization calls and to
17053account for the stack pointer having a different value in its top byte.
17054
17055@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
17056Instrumenting the stack and alloca calls are not on by default but are still
17057possible by specifying the command-line options
17058@option{--param hwasan-instrument-stack=1} and
17059@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
17060tag is not implemented for kernel instrumentation.
17061
d77de738 17062@opindex fsanitize=pointer-compare
ddf6fe37 17063@item -fsanitize=pointer-compare
d77de738
ML
17064Instrument comparison operation (<, <=, >, >=) with pointer operands.
17065The option must be combined with either @option{-fsanitize=kernel-address} or
17066@option{-fsanitize=address}
17067The option cannot be combined with @option{-fsanitize=thread}.
17068Note: By default the check is disabled at run time. To enable it,
17069add @code{detect_invalid_pointer_pairs=2} to the environment variable
17070@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17071invalid operation only when both pointers are non-null.
17072
d77de738 17073@opindex fsanitize=pointer-subtract
ddf6fe37 17074@item -fsanitize=pointer-subtract
d77de738
ML
17075Instrument subtraction with pointer operands.
17076The option must be combined with either @option{-fsanitize=kernel-address} or
17077@option{-fsanitize=address}
17078The option cannot be combined with @option{-fsanitize=thread}.
17079Note: By default the check is disabled at run time. To enable it,
17080add @code{detect_invalid_pointer_pairs=2} to the environment variable
17081@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17082invalid operation only when both pointers are non-null.
17083
d77de738 17084@opindex fsanitize=shadow-call-stack
ddf6fe37 17085@item -fsanitize=shadow-call-stack
d77de738
ML
17086Enable ShadowCallStack, a security enhancement mechanism used to protect
17087programs against return address overwrites (e.g. stack buffer overflows.)
17088It works by saving a function's return address to a separately allocated
17089shadow call stack in the function prologue and restoring the return address
17090from the shadow call stack in the function epilogue. Instrumentation only
17091occurs in functions that need to save the return address to the stack.
17092
17093Currently it only supports the aarch64 platform. It is specifically
17094designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
17095For the user space programs, runtime support is not currently provided
17096in libc and libgcc. Users who want to use this feature in user space need
17097to provide their own support for the runtime. It should be noted that
17098this may cause the ABI rules to be broken.
17099
17100On aarch64, the instrumentation makes use of the platform register @code{x18}.
17101This generally means that any code that may run on the same thread as code
17102compiled with ShadowCallStack must be compiled with the flag
17103@option{-ffixed-x18}, otherwise functions compiled without
17104@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
17105stack pointer.
17106
17107Also, because there is no userspace runtime support, code compiled with
17108ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
17109to turn off exceptions.
17110
17111See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
17112details.
17113
d77de738 17114@opindex fsanitize=thread
ddf6fe37 17115@item -fsanitize=thread
d77de738
ML
17116Enable ThreadSanitizer, a fast data race detector.
17117Memory access instructions are instrumented to detect
17118data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
17119details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
17120environment variable; see
17121@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
17122supported options.
17123The option cannot be combined with @option{-fsanitize=address},
17124@option{-fsanitize=leak}.
17125
17126Note that sanitized atomic builtins cannot throw exceptions when
17127operating on invalid memory addresses with non-call exceptions
17128(@option{-fnon-call-exceptions}).
17129
d77de738 17130@opindex fsanitize=leak
ddf6fe37 17131@item -fsanitize=leak
d77de738 17132Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
17133This option only matters for linking of executables.
17134The executable is linked against a library that overrides @code{malloc}
d77de738
ML
17135and other allocator functions. See
17136@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
17137details. The run-time behavior can be influenced using the
17138@env{LSAN_OPTIONS} environment variable.
17139The option cannot be combined with @option{-fsanitize=thread}.
17140
d77de738 17141@opindex fsanitize=undefined
ddf6fe37 17142@item -fsanitize=undefined
d77de738
ML
17143Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
17144Various computations are instrumented to detect undefined behavior
17145at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
17146@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
17147
17148@table @gcctabopt
17149
d77de738 17150@opindex fsanitize=shift
ddf6fe37 17151@item -fsanitize=shift
d77de738
ML
17152This option enables checking that the result of a shift operation is
17153not undefined. Note that what exactly is considered undefined differs
17154slightly between C and C++, as well as between ISO C90 and C99, etc.
17155This option has two suboptions, @option{-fsanitize=shift-base} and
17156@option{-fsanitize=shift-exponent}.
17157
d77de738 17158@opindex fsanitize=shift-exponent
ddf6fe37 17159@item -fsanitize=shift-exponent
d77de738
ML
17160This option enables checking that the second argument of a shift operation
17161is not negative and is smaller than the precision of the promoted first
17162argument.
17163
d77de738 17164@opindex fsanitize=shift-base
ddf6fe37 17165@item -fsanitize=shift-base
d77de738
ML
17166If the second argument of a shift operation is within range, check that the
17167result of a shift operation is not undefined. Note that what exactly is
17168considered undefined differs slightly between C and C++, as well as between
17169ISO C90 and C99, etc.
17170
d77de738 17171@opindex fsanitize=integer-divide-by-zero
ddf6fe37 17172@item -fsanitize=integer-divide-by-zero
d77de738
ML
17173Detect integer division by zero.
17174
d77de738 17175@opindex fsanitize=unreachable
ddf6fe37 17176@item -fsanitize=unreachable
d77de738
ML
17177With this option, the compiler turns the @code{__builtin_unreachable}
17178call into a diagnostics message call instead. When reaching the
17179@code{__builtin_unreachable} call, the behavior is undefined.
17180
d77de738 17181@opindex fsanitize=vla-bound
ddf6fe37 17182@item -fsanitize=vla-bound
d77de738
ML
17183This option instructs the compiler to check that the size of a variable
17184length array is positive.
17185
d77de738 17186@opindex fsanitize=null
ddf6fe37 17187@item -fsanitize=null
d77de738
ML
17188This option enables pointer checking. Particularly, the application
17189built with this option turned on will issue an error message when it
17190tries to dereference a NULL pointer, or if a reference (possibly an
17191rvalue reference) is bound to a NULL pointer, or if a method is invoked
17192on an object pointed by a NULL pointer.
17193
d77de738 17194@opindex fsanitize=return
ddf6fe37 17195@item -fsanitize=return
d77de738
ML
17196This option enables return statement checking. Programs
17197built with this option turned on will issue an error message
17198when the end of a non-void function is reached without actually
17199returning a value. This option works in C++ only.
17200
d77de738 17201@opindex fsanitize=signed-integer-overflow
ddf6fe37 17202@item -fsanitize=signed-integer-overflow
d77de738
ML
17203This option enables signed integer overflow checking. We check that
17204the result of @code{+}, @code{*}, and both unary and binary @code{-}
17205does not overflow in the signed arithmetics. This also detects
17206@code{INT_MIN / -1} signed division. Note, integer promotion
17207rules must be taken into account. That is, the following is not an
17208overflow:
17209@smallexample
17210signed char a = SCHAR_MAX;
17211a++;
17212@end smallexample
17213
d77de738 17214@opindex fsanitize=bounds
ddf6fe37 17215@item -fsanitize=bounds
d77de738
ML
17216This option enables instrumentation of array bounds. Various out of bounds
17217accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
17218arrays, and initializers of variables with static storage are not
17219instrumented, with the exception of flexible array member-like arrays
17220for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
17221options or @code{strict_flex_array} attributes say they shouldn't be treated
17222like flexible array member-like arrays.
d77de738 17223
d77de738 17224@opindex fsanitize=bounds-strict
ddf6fe37 17225@item -fsanitize=bounds-strict
d77de738 17226This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
17227accesses are detected, including flexible array member-like arrays.
17228Initializers of variables with static storage are not instrumented.
d77de738 17229
d77de738 17230@opindex fsanitize=alignment
ddf6fe37 17231@item -fsanitize=alignment
d77de738
ML
17232
17233This option enables checking of alignment of pointers when they are
17234dereferenced, or when a reference is bound to insufficiently aligned target,
17235or when a method or constructor is invoked on insufficiently aligned object.
17236
d77de738 17237@opindex fsanitize=object-size
ddf6fe37 17238@item -fsanitize=object-size
d77de738 17239This option enables instrumentation of memory references using the
7283380a
SP
17240@code{__builtin_dynamic_object_size} function. Various out of bounds
17241pointer accesses are detected.
d77de738 17242
d77de738 17243@opindex fsanitize=float-divide-by-zero
ddf6fe37 17244@item -fsanitize=float-divide-by-zero
d77de738
ML
17245Detect floating-point division by zero. Unlike other similar options,
17246@option{-fsanitize=float-divide-by-zero} is not enabled by
17247@option{-fsanitize=undefined}, since floating-point division by zero can
17248be a legitimate way of obtaining infinities and NaNs.
17249
d77de738 17250@opindex fsanitize=float-cast-overflow
ddf6fe37 17251@item -fsanitize=float-cast-overflow
d77de738
ML
17252This option enables floating-point type to integer conversion checking.
17253We check that the result of the conversion does not overflow.
17254Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17255not enabled by @option{-fsanitize=undefined}.
17256This option does not work well with @code{FE_INVALID} exceptions enabled.
17257
d77de738 17258@opindex fsanitize=nonnull-attribute
ddf6fe37 17259@item -fsanitize=nonnull-attribute
d77de738
ML
17260
17261This option enables instrumentation of calls, checking whether null values
17262are not passed to arguments marked as requiring a non-null value by the
17263@code{nonnull} function attribute.
17264
d77de738 17265@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 17266@item -fsanitize=returns-nonnull-attribute
d77de738
ML
17267
17268This option enables instrumentation of return statements in functions
17269marked with @code{returns_nonnull} function attribute, to detect returning
17270of null values from such functions.
17271
d77de738 17272@opindex fsanitize=bool
ddf6fe37 17273@item -fsanitize=bool
d77de738
ML
17274
17275This option enables instrumentation of loads from bool. If a value other
17276than 0/1 is loaded, a run-time error is issued.
17277
d77de738 17278@opindex fsanitize=enum
ddf6fe37 17279@item -fsanitize=enum
d77de738
ML
17280
17281This option enables instrumentation of loads from an enum type. If
17282a value outside the range of values for the enum type is loaded,
17283a run-time error is issued.
17284
d77de738 17285@opindex fsanitize=vptr
ddf6fe37 17286@item -fsanitize=vptr
d77de738
ML
17287
17288This option enables instrumentation of C++ member function calls, member
17289accesses and some conversions between pointers to base and derived classes,
17290to verify the referenced object has the correct dynamic type.
17291
d77de738 17292@opindex fsanitize=pointer-overflow
ddf6fe37 17293@item -fsanitize=pointer-overflow
d77de738
ML
17294
17295This option enables instrumentation of pointer arithmetics. If the pointer
17296arithmetics overflows, a run-time error is issued.
17297
d77de738 17298@opindex fsanitize=builtin
ddf6fe37 17299@item -fsanitize=builtin
d77de738
ML
17300
17301This option enables instrumentation of arguments to selected builtin
17302functions. If an invalid value is passed to such arguments, a run-time
17303error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17304or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17305by this option.
17306
17307@end table
17308
17309Note that sanitizers tend to increase the rate of false positive
17310warnings, most notably those around @option{-Wmaybe-uninitialized}.
17311We recommend against combining @option{-Werror} and [the use of]
17312sanitizers.
17313
17314While @option{-ftrapv} causes traps for signed overflows to be emitted,
17315@option{-fsanitize=undefined} gives a diagnostic message.
17316This currently works only for the C family of languages.
17317
d77de738 17318@opindex fno-sanitize=all
ddf6fe37 17319@item -fno-sanitize=all
d77de738
ML
17320
17321This option disables all previously enabled sanitizers.
17322@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17323together.
17324
d77de738 17325@opindex fasan-shadow-offset
ddf6fe37 17326@item -fasan-shadow-offset=@var{number}
d77de738
ML
17327This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17328It is useful for experimenting with different shadow memory layouts in
17329Kernel AddressSanitizer.
17330
d77de738 17331@opindex fsanitize-sections
ddf6fe37 17332@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
17333Sanitize global variables in selected user-defined sections. @var{si} may
17334contain wildcards.
17335
d77de738
ML
17336@opindex fsanitize-recover
17337@opindex fno-sanitize-recover
ddf6fe37 17338@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17339@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17340mentioned in comma-separated list of @var{opts}. Enabling this option
17341for a sanitizer component causes it to attempt to continue
17342running the program as if no error happened. This means multiple
17343runtime errors can be reported in a single program run, and the exit
17344code of the program may indicate success even when errors
17345have been reported. The @option{-fno-sanitize-recover=} option
17346can be used to alter
17347this behavior: only the first detected error is reported
17348and program then exits with a non-zero exit code.
17349
17350Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17351except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17352@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17353@option{-fsanitize=bounds-strict},
17354@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17355For these sanitizers error recovery is turned on by default,
17356except @option{-fsanitize=address}, for which this feature is experimental.
17357@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17358accepted, the former enables recovery for all sanitizers that support it,
17359the latter disables recovery for all sanitizers that support it.
17360
17361Even if a recovery mode is turned on the compiler side, it needs to be also
17362enabled on the runtime library side, otherwise the failures are still fatal.
17363The runtime library defaults to @code{halt_on_error=0} for
17364ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17365AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17366setting the @code{halt_on_error} flag in the corresponding environment variable.
17367
17368Syntax without an explicit @var{opts} parameter is deprecated. It is
17369equivalent to specifying an @var{opts} list of:
17370
17371@smallexample
17372undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17373@end smallexample
17374
d77de738 17375@opindex fsanitize-address-use-after-scope
ddf6fe37 17376@item -fsanitize-address-use-after-scope
d77de738
ML
17377Enable sanitization of local variables to detect use-after-scope bugs.
17378The option sets @option{-fstack-reuse} to @samp{none}.
17379
d77de738
ML
17380@opindex fsanitize-trap
17381@opindex fno-sanitize-trap
ddf6fe37 17382@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17383The @option{-fsanitize-trap=} option instructs the compiler to
17384report for sanitizers mentioned in comma-separated list of @var{opts}
17385undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17386library routine. If this option is enabled for certain sanitizer,
17387it takes precedence over the @option{-fsanitizer-recover=} for that
17388sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17389of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17390
17391The advantage of this is that the @code{libubsan} library is not needed
17392and is not linked in, so this is usable even in freestanding environments.
17393
17394Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17395except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17396@option{-fsanitize=float-divide-by-zero} and
17397@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17398specified, which enables it for @code{undefined} suboptions,
17399@option{-fsanitize=float-cast-overflow},
17400@option{-fsanitize=float-divide-by-zero} and
17401@option{-fsanitize=bounds-strict}.
17402If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17403and @code{-fsanitize=vptr} is enabled on the command line, the
17404instrumentation is silently ignored as the instrumentation always needs
17405@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17406
d77de738 17407@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17408@item -fsanitize-undefined-trap-on-error
d77de738
ML
17409The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17410equivalent of @option{-fsanitize-trap=all}.
17411
d77de738 17412@opindex fsanitize-coverage=trace-pc
ddf6fe37 17413@item -fsanitize-coverage=trace-pc
d77de738
ML
17414Enable coverage-guided fuzzing code instrumentation.
17415Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17416
d77de738 17417@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17418@item -fsanitize-coverage=trace-cmp
d77de738
ML
17419Enable dataflow guided fuzzing code instrumentation.
17420Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17421@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17422@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17423variable or @code{__sanitizer_cov_trace_const_cmp1},
17424@code{__sanitizer_cov_trace_const_cmp2},
17425@code{__sanitizer_cov_trace_const_cmp4} or
17426@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17427operand constant, @code{__sanitizer_cov_trace_cmpf} or
17428@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17429@code{__sanitizer_cov_trace_switch} for switch statements.
17430
d77de738 17431@opindex fcf-protection
ddf6fe37 17432@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17433Enable code instrumentation of control-flow transfers to increase
17434program security by checking that target addresses of control-flow
17435transfer instructions (such as indirect function call, function return,
17436indirect jump) are valid. This prevents diverting the flow of control
17437to an unexpected target. This is intended to protect against such
17438threats as Return-oriented Programming (ROP), and similarly
17439call/jmp-oriented programming (COP/JOP).
17440
17441The value @code{branch} tells the compiler to implement checking of
17442validity of control-flow transfer at the point of indirect branch
17443instructions, i.e.@: call/jmp instructions. The value @code{return}
17444implements checking of validity at the point of returning from a
17445function. The value @code{full} is an alias for specifying both
17446@code{branch} and @code{return}. The value @code{none} turns off
17447instrumentation.
17448
17449The value @code{check} is used for the final link with link-time
17450optimization (LTO). An error is issued if LTO object files are
17451compiled with different @option{-fcf-protection} values. The
17452value @code{check} is ignored at the compile time.
17453
17454The macro @code{__CET__} is defined when @option{-fcf-protection} is
17455used. The first bit of @code{__CET__} is set to 1 for the value
17456@code{branch} and the second bit of @code{__CET__} is set to 1 for
17457the @code{return}.
17458
17459You can also use the @code{nocf_check} attribute to identify
17460which functions and calls should be skipped from instrumentation
17461(@pxref{Function Attributes}).
17462
17463Currently the x86 GNU/Linux target provides an implementation based
17464on Intel Control-flow Enforcement Technology (CET) which works for
17465i686 processor or newer.
17466
d77de738 17467@opindex fharden-compares
ddf6fe37 17468@item -fharden-compares
d77de738
ML
17469For every logical test that survives gimple optimizations and is
17470@emph{not} the condition in a conditional branch (for example,
17471conditions tested for conditional moves, or to store in boolean
17472variables), emit extra code to compute and verify the reversed
17473condition, and to call @code{__builtin_trap} if the results do not
17474match. Use with @samp{-fharden-conditional-branches} to cover all
17475conditionals.
17476
d77de738 17477@opindex fharden-conditional-branches
ddf6fe37 17478@item -fharden-conditional-branches
d77de738
ML
17479For every non-vectorized conditional branch that survives gimple
17480optimizations, emit extra code to compute and verify the reversed
17481condition, and to call @code{__builtin_trap} if the result is
17482unexpected. Use with @samp{-fharden-compares} to cover all
17483conditionals.
17484
551935d1
AO
17485@opindex fharden-control-flow-redundancy
17486@item -fharden-control-flow-redundancy
17487Emit extra code to set booleans when entering basic blocks, and to
17488verify and trap, at function exits, when the booleans do not form an
17489execution path that is compatible with the control flow graph.
17490
17491Verification takes place before returns, before mandatory tail calls
17492(see below) and, optionally, before escaping exceptions with
17493@option{-fhardcfr-check-exceptions}, before returning calls with
17494@option{-fhardcfr-check-returning-calls}, and before noreturn calls with
17495@option{-fhardcfr-check-noreturn-calls}). Tuning options
17496@option{--param hardcfr-max-blocks} and @option{--param
17497hardcfr-max-inline-blocks} are available.
17498
17499Tail call optimization takes place too late to affect control flow
17500redundancy, but calls annotated as mandatory tail calls by language
17501front-ends, and any calls marked early enough as potential tail calls
17502would also have verification issued before the call, but these
17503possibilities are merely theoretical, as these conditions can only be
17504met when using custom compiler plugins.
17505
17506@opindex fhardcfr-skip-leaf
17507@item -fhardcfr-skip-leaf
17508Disable @option{-fharden-control-flow-redundancy} in leaf functions.
17509
17510@opindex fhardcfr-check-exceptions
17511@opindex fno-hardcfr-check-exceptions
17512@item -fhardcfr-check-exceptions
17513When @option{-fharden-control-flow-redundancy} is active, check the
17514recorded execution path against the control flow graph at exception
17515escape points, as if the function body was wrapped with a cleanup
17516handler that performed the check and reraised. This option is enabled
17517by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
17518
17519@opindex fhardcfr-check-returning-calls
17520@opindex fno-hardcfr-check-returning-calls
17521@item -fhardcfr-check-returning-calls
17522When @option{-fharden-control-flow-redundancy} is active, check the
17523recorded execution path against the control flow graph before any
17524function call immediately followed by a return of its result, if any, so
17525as to not prevent tail-call optimization, whether or not it is
17526ultimately optimized to a tail call.
17527
17528This option is enabled by default whenever sibling call optimizations
17529are enabled (see @option{-foptimize-sibling-calls}), but it can be
17530enabled (or disabled, using its negated form) explicitly, regardless of
17531the optimizations.
17532
17533@opindex fhardcfr-check-noreturn-calls
17534@item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
17535When @option{-fharden-control-flow-redundancy} is active, check the
17536recorded execution path against the control flow graph before
17537@code{noreturn} calls, either all of them (@option{always}), those that
17538aren't expected to return control to the caller through an exception
17539(@option{no-xthrow}, the default), those that may not return control to
17540the caller through an exception either (@option{nothrow}), or none of
17541them (@option{never}).
17542
17543Checking before a @code{noreturn} function that may return control to
17544the caller through an exception may cause checking to be performed more
17545than once, if the exception is caught in the caller, whether by a
17546handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
17547enabled, the compiler will avoid associating a @code{noreturn} call with
17548the implicitly-added cleanup handler, since it would be redundant with
17549the check performed before the call, but other handlers or cleanups in
17550the function, if activated, will modify the recorded execution path and
17551check it again when another checkpoint is hit. The checkpoint may even
17552be another @code{noreturn} call, so checking may end up performed
17553multiple times.
17554
17555Various optimizers may cause calls to be marked as @code{noreturn}
17556and/or @code{nothrow}, even in the absence of the corresponding
17557attributes, which may affect the placement of checks before calls, as
17558well as the addition of implicit cleanup handlers for them. This
17559unpredictability, and the fact that raising and reraising exceptions
17560frequently amounts to implicitly calling @code{noreturn} functions, have
17561made @option{no-xthrow} the default setting for this option: it excludes
17562from the @code{noreturn} treatment only internal functions used to
17563(re)raise exceptions, that are not affected by these optimizations.
17564
d77de738 17565@opindex fstack-protector
ddf6fe37 17566@item -fstack-protector
d77de738
ML
17567Emit extra code to check for buffer overflows, such as stack smashing
17568attacks. This is done by adding a guard variable to functions with
17569vulnerable objects. This includes functions that call @code{alloca}, and
17570functions with buffers larger than or equal to 8 bytes. The guards are
17571initialized when a function is entered and then checked when the function
17572exits. If a guard check fails, an error message is printed and the program
17573exits. Only variables that are actually allocated on the stack are
17574considered, optimized away variables or variables allocated in registers
17575don't count.
17576
d77de738 17577@opindex fstack-protector-all
ddf6fe37 17578@item -fstack-protector-all
d77de738
ML
17579Like @option{-fstack-protector} except that all functions are protected.
17580
d77de738 17581@opindex fstack-protector-strong
ddf6fe37 17582@item -fstack-protector-strong
d77de738
ML
17583Like @option{-fstack-protector} but includes additional functions to
17584be protected --- those that have local array definitions, or have
17585references to local frame addresses. Only variables that are actually
17586allocated on the stack are considered, optimized away variables or variables
17587allocated in registers don't count.
17588
d77de738 17589@opindex fstack-protector-explicit
ddf6fe37 17590@item -fstack-protector-explicit
d77de738
ML
17591Like @option{-fstack-protector} but only protects those functions which
17592have the @code{stack_protect} attribute.
17593
d77de738 17594@opindex fstack-check
ddf6fe37 17595@item -fstack-check
d77de738
ML
17596Generate code to verify that you do not go beyond the boundary of the
17597stack. You should specify this flag if you are running in an
17598environment with multiple threads, but you only rarely need to specify it in
17599a single-threaded environment since stack overflow is automatically
17600detected on nearly all systems if there is only one stack.
17601
17602Note that this switch does not actually cause checking to be done; the
17603operating system or the language runtime must do that. The switch causes
17604generation of code to ensure that they see the stack being extended.
17605
17606You can additionally specify a string parameter: @samp{no} means no
17607checking, @samp{generic} means force the use of old-style checking,
17608@samp{specific} means use the best checking method and is equivalent
17609to bare @option{-fstack-check}.
17610
17611Old-style checking is a generic mechanism that requires no specific
17612target support in the compiler but comes with the following drawbacks:
17613
17614@enumerate
17615@item
17616Modified allocation strategy for large objects: they are always
17617allocated dynamically if their size exceeds a fixed threshold. Note this
17618may change the semantics of some code.
17619
17620@item
17621Fixed limit on the size of the static frame of functions: when it is
17622topped by a particular function, stack checking is not reliable and
17623a warning is issued by the compiler.
17624
17625@item
17626Inefficiency: because of both the modified allocation strategy and the
17627generic implementation, code performance is hampered.
17628@end enumerate
17629
17630Note that old-style stack checking is also the fallback method for
17631@samp{specific} if no target support has been added in the compiler.
17632
17633@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17634and stack overflows. @samp{specific} is an excellent choice when compiling
17635Ada code. It is not generally sufficient to protect against stack-clash
17636attacks. To protect against those you want @samp{-fstack-clash-protection}.
17637
d77de738 17638@opindex fstack-clash-protection
ddf6fe37 17639@item -fstack-clash-protection
d77de738
ML
17640Generate code to prevent stack clash style attacks. When this option is
17641enabled, the compiler will only allocate one page of stack space at a time
17642and each page is accessed immediately after allocation. Thus, it prevents
17643allocations from jumping over any stack guard page provided by the
17644operating system.
17645
17646Most targets do not fully support stack clash protection. However, on
17647those targets @option{-fstack-clash-protection} will protect dynamic stack
17648allocations. @option{-fstack-clash-protection} may also provide limited
17649protection for static stack allocations if the target supports
17650@option{-fstack-check=specific}.
17651
d77de738
ML
17652@opindex fstack-limit-register
17653@opindex fstack-limit-symbol
17654@opindex fno-stack-limit
ddf6fe37
AA
17655@item -fstack-limit-register=@var{reg}
17656@itemx -fstack-limit-symbol=@var{sym}
17657@itemx -fno-stack-limit
d77de738
ML
17658Generate code to ensure that the stack does not grow beyond a certain value,
17659either the value of a register or the address of a symbol. If a larger
17660stack is required, a signal is raised at run time. For most targets,
17661the signal is raised before the stack overruns the boundary, so
17662it is possible to catch the signal without taking special precautions.
17663
17664For instance, if the stack starts at absolute address @samp{0x80000000}
17665and grows downwards, you can use the flags
17666@option{-fstack-limit-symbol=__stack_limit} and
17667@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17668of 128KB@. Note that this may only work with the GNU linker.
17669
17670You can locally override stack limit checking by using the
17671@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17672
d77de738 17673@opindex fsplit-stack
ddf6fe37 17674@item -fsplit-stack
d77de738
ML
17675Generate code to automatically split the stack before it overflows.
17676The resulting program has a discontiguous stack which can only
17677overflow if the program is unable to allocate any more memory. This
17678is most useful when running threaded programs, as it is no longer
17679necessary to calculate a good stack size to use for each thread. This
17680is currently only implemented for the x86 targets running
17681GNU/Linux.
17682
17683When code compiled with @option{-fsplit-stack} calls code compiled
17684without @option{-fsplit-stack}, there may not be much stack space
17685available for the latter code to run. If compiling all code,
17686including library code, with @option{-fsplit-stack} is not an option,
17687then the linker can fix up these calls so that the code compiled
17688without @option{-fsplit-stack} always has a large stack. Support for
17689this is implemented in the gold linker in GNU binutils release 2.21
17690and later.
17691
d77de738 17692@opindex fvtable-verify
ddf6fe37 17693@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17694This option is only available when compiling C++ code.
17695It turns on (or off, if using @option{-fvtable-verify=none}) the security
17696feature that verifies at run time, for every virtual call, that
17697the vtable pointer through which the call is made is valid for the type of
17698the object, and has not been corrupted or overwritten. If an invalid vtable
17699pointer is detected at run time, an error is reported and execution of the
17700program is immediately halted.
17701
17702This option causes run-time data structures to be built at program startup,
17703which are used for verifying the vtable pointers.
17704The options @samp{std} and @samp{preinit}
17705control the timing of when these data structures are built. In both cases the
17706data structures are built before execution reaches @code{main}. Using
17707@option{-fvtable-verify=std} causes the data structures to be built after
17708shared libraries have been loaded and initialized.
17709@option{-fvtable-verify=preinit} causes them to be built before shared
17710libraries have been loaded and initialized.
17711
17712If this option appears multiple times in the command line with different
17713values specified, @samp{none} takes highest priority over both @samp{std} and
17714@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17715
d77de738 17716@opindex fvtv-debug
ddf6fe37 17717@item -fvtv-debug
d77de738
ML
17718When used in conjunction with @option{-fvtable-verify=std} or
17719@option{-fvtable-verify=preinit}, causes debug versions of the
17720runtime functions for the vtable verification feature to be called.
17721This flag also causes the compiler to log information about which
17722vtable pointers it finds for each class.
17723This information is written to a file named @file{vtv_set_ptr_data.log}
17724in the directory named by the environment variable @env{VTV_LOGS_DIR}
17725if that is defined or the current working directory otherwise.
17726
17727Note: This feature @emph{appends} data to the log file. If you want a fresh log
17728file, be sure to delete any existing one.
17729
d77de738 17730@opindex fvtv-counts
ddf6fe37 17731@item -fvtv-counts
d77de738
ML
17732This is a debugging flag. When used in conjunction with
17733@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17734causes the compiler to keep track of the total number of virtual calls
17735it encounters and the number of verifications it inserts. It also
17736counts the number of calls to certain run-time library functions
17737that it inserts and logs this information for each compilation unit.
17738The compiler writes this information to a file named
17739@file{vtv_count_data.log} in the directory named by the environment
17740variable @env{VTV_LOGS_DIR} if that is defined or the current working
17741directory otherwise. It also counts the size of the vtable pointer sets
17742for each class, and writes this information to @file{vtv_class_set_sizes.log}
17743in the same directory.
17744
17745Note: This feature @emph{appends} data to the log files. To get fresh log
17746files, be sure to delete any existing ones.
17747
d77de738 17748@opindex finstrument-functions
ddf6fe37 17749@item -finstrument-functions
d77de738
ML
17750Generate instrumentation calls for entry and exit to functions. Just
17751after function entry and just before function exit, the following
17752profiling functions are called with the address of the current
17753function and its call site. (On some platforms,
17754@code{__builtin_return_address} does not work beyond the current
17755function, so the call site information may not be available to the
17756profiling functions otherwise.)
17757
17758@smallexample
17759void __cyg_profile_func_enter (void *this_fn,
17760 void *call_site);
17761void __cyg_profile_func_exit (void *this_fn,
17762 void *call_site);
17763@end smallexample
17764
17765The first argument is the address of the start of the current function,
17766which may be looked up exactly in the symbol table.
17767
17768This instrumentation is also done for functions expanded inline in other
17769functions. The profiling calls indicate where, conceptually, the
17770inline function is entered and exited. This means that addressable
17771versions of such functions must be available. If all your uses of a
17772function are expanded inline, this may mean an additional expansion of
17773code size. If you use @code{extern inline} in your C code, an
17774addressable version of such functions must be provided. (This is
17775normally the case anyway, but if you get lucky and the optimizer always
17776expands the functions inline, you might have gotten away without
17777providing static copies.)
17778
17779A function may be given the attribute @code{no_instrument_function}, in
17780which case this instrumentation is not done. This can be used, for
17781example, for the profiling functions listed above, high-priority
17782interrupt routines, and any functions from which the profiling functions
17783cannot safely be called (perhaps signal handlers, if the profiling
17784routines generate output or allocate memory).
17785@xref{Common Function Attributes}.
17786
9c19597c 17787@opindex finstrument-functions-once
ddf6fe37 17788@item -finstrument-functions-once
d77de738
ML
17789This is similar to @option{-finstrument-functions}, but the profiling
17790functions are called only once per instrumented function, i.e. the first
17791profiling function is called after the first entry into the instrumented
17792function and the second profiling function is called before the exit
17793corresponding to this first entry.
17794
17795The definition of @code{once} for the purpose of this option is a little
17796vague because the implementation is not protected against data races.
17797As a result, the implementation only guarantees that the profiling
17798functions are called at @emph{least} once per process and at @emph{most}
17799once per thread, but the calls are always paired, that is to say, if a
17800thread calls the first function, then it will call the second function,
17801unless it never reaches the exit of the instrumented function.
17802
d77de738 17803@opindex finstrument-functions-exclude-file-list
ddf6fe37 17804@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17805
17806Set the list of functions that are excluded from instrumentation (see
17807the description of @option{-finstrument-functions}). If the file that
17808contains a function definition matches with one of @var{file}, then
17809that function is not instrumented. The match is done on substrings:
17810if the @var{file} parameter is a substring of the file name, it is
17811considered to be a match.
17812
17813For example:
17814
17815@smallexample
17816-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17817@end smallexample
17818
17819@noindent
17820excludes any inline function defined in files whose pathnames
17821contain @file{/bits/stl} or @file{include/sys}.
17822
17823If, for some reason, you want to include letter @samp{,} in one of
17824@var{sym}, write @samp{\,}. For example,
17825@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17826(note the single quote surrounding the option).
17827
d77de738 17828@opindex finstrument-functions-exclude-function-list
ddf6fe37 17829@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17830
17831This is similar to @option{-finstrument-functions-exclude-file-list},
17832but this option sets the list of function names to be excluded from
17833instrumentation. The function name to be matched is its user-visible
17834name, such as @code{vector<int> blah(const vector<int> &)}, not the
17835internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17836match is done on substrings: if the @var{sym} parameter is a substring
17837of the function name, it is considered to be a match. For C99 and C++
17838extended identifiers, the function name must be given in UTF-8, not
17839using universal character names.
17840
d77de738 17841@opindex fpatchable-function-entry
ddf6fe37 17842@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17843Generate @var{N} NOPs right at the beginning
17844of each function, with the function entry point before the @var{M}th NOP.
17845If @var{M} is omitted, it defaults to @code{0} so the
17846function entry points to the address just at the first NOP.
17847The NOP instructions reserve extra space which can be used to patch in
17848any desired instrumentation at run time, provided that the code segment
17849is writable. The amount of space is controllable indirectly via
17850the number of NOPs; the NOP instruction used corresponds to the instruction
17851emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17852is target-specific and may also depend on the architecture variant and/or
17853other compilation options.
17854
17855For run-time identification, the starting addresses of these areas,
17856which correspond to their respective function entries minus @var{M},
17857are additionally collected in the @code{__patchable_function_entries}
17858section of the resulting binary.
17859
17860Note that the value of @code{__attribute__ ((patchable_function_entry
17861(N,M)))} takes precedence over command-line option
17862@option{-fpatchable-function-entry=N,M}. This can be used to increase
17863the area size or to remove it completely on a single function.
17864If @code{N=0}, no pad location is recorded.
17865
17866The NOP instructions are inserted at---and maybe before, depending on
17867@var{M}---the function entry address, even before the prologue. On
17868PowerPC with the ELFv2 ABI, for a function with dual entry points,
17869the local entry point is this function entry address.
17870
17871The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17872ELFv2 ABI, for a function with dual entry points, the supported values
17873for @var{M} are 0, 2, 6 and 14.
17874@end table
17875
17876
17877@node Preprocessor Options
17878@section Options Controlling the Preprocessor
17879@cindex preprocessor options
17880@cindex options, preprocessor
17881
17882These options control the C preprocessor, which is run on each C source
17883file before actual compilation.
17884
17885If you use the @option{-E} option, nothing is done except preprocessing.
17886Some of these options make sense only together with @option{-E} because
17887they cause the preprocessor output to be unsuitable for actual
17888compilation.
17889
17890In addition to the options listed here, there are a number of options
17891to control search paths for include files documented in
17892@ref{Directory Options}.
17893Options to control preprocessor diagnostics are listed in
17894@ref{Warning Options}.
17895
17896@table @gcctabopt
17897@include cppopts.texi
17898
d77de738 17899@opindex Wp
ddf6fe37 17900@item -Wp,@var{option}
d77de738
ML
17901You can use @option{-Wp,@var{option}} to bypass the compiler driver
17902and pass @var{option} directly through to the preprocessor. If
17903@var{option} contains commas, it is split into multiple options at the
17904commas. However, many options are modified, translated or interpreted
17905by the compiler driver before being passed to the preprocessor, and
17906@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17907interface is undocumented and subject to change, so whenever possible
17908you should avoid using @option{-Wp} and let the driver handle the
17909options instead.
17910
d77de738 17911@opindex Xpreprocessor
ddf6fe37 17912@item -Xpreprocessor @var{option}
d77de738
ML
17913Pass @var{option} as an option to the preprocessor. You can use this to
17914supply system-specific preprocessor options that GCC does not
17915recognize.
17916
17917If you want to pass an option that takes an argument, you must use
17918@option{-Xpreprocessor} twice, once for the option and once for the argument.
17919
d77de738 17920@opindex no-integrated-cpp
ddf6fe37 17921@item -no-integrated-cpp
d77de738
ML
17922Perform preprocessing as a separate pass before compilation.
17923By default, GCC performs preprocessing as an integrated part of
17924input tokenization and parsing.
17925If this option is provided, the appropriate language front end
17926(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17927and Objective-C, respectively) is instead invoked twice,
17928once for preprocessing only and once for actual compilation
17929of the preprocessed input.
17930This option may be useful in conjunction with the @option{-B} or
17931@option{-wrapper} options to specify an alternate preprocessor or
17932perform additional processing of the program source between
17933normal preprocessing and compilation.
17934
d77de738 17935@opindex flarge-source-files
ddf6fe37 17936@item -flarge-source-files
d77de738
ML
17937Adjust GCC to expect large source files, at the expense of slower
17938compilation and higher memory usage.
17939
17940Specifically, GCC normally tracks both column numbers and line numbers
17941within source files and it normally prints both of these numbers in
17942diagnostics. However, once it has processed a certain number of source
17943lines, it stops tracking column numbers and only tracks line numbers.
17944This means that diagnostics for later lines do not include column numbers.
17945It also means that options like @option{-Wmisleading-indentation} cease to work
17946at that point, although the compiler prints a note if this happens.
17947Passing @option{-flarge-source-files} significantly increases the number
17948of source lines that GCC can process before it stops tracking columns.
17949
17950@end table
17951
17952@node Assembler Options
17953@section Passing Options to the Assembler
17954
17955@c prevent bad page break with this line
17956You can pass options to the assembler.
17957
17958@table @gcctabopt
d77de738 17959@opindex Wa
ddf6fe37 17960@item -Wa,@var{option}
d77de738
ML
17961Pass @var{option} as an option to the assembler. If @var{option}
17962contains commas, it is split into multiple options at the commas.
17963
d77de738 17964@opindex Xassembler
ddf6fe37 17965@item -Xassembler @var{option}
d77de738
ML
17966Pass @var{option} as an option to the assembler. You can use this to
17967supply system-specific assembler options that GCC does not
17968recognize.
17969
17970If you want to pass an option that takes an argument, you must use
17971@option{-Xassembler} twice, once for the option and once for the argument.
17972
17973@end table
17974
17975@node Link Options
17976@section Options for Linking
17977@cindex link options
17978@cindex options, linking
17979
17980These options come into play when the compiler links object files into
17981an executable output file. They are meaningless if the compiler is
17982not doing a link step.
17983
17984@table @gcctabopt
17985@cindex file names
17986@item @var{object-file-name}
17987A file name that does not end in a special recognized suffix is
17988considered to name an object file or library. (Object files are
17989distinguished from libraries by the linker according to the file
17990contents.) If linking is done, these object files are used as input
17991to the linker.
17992
d77de738
ML
17993@opindex c
17994@opindex S
17995@opindex E
ddf6fe37
AA
17996@item -c
17997@itemx -S
17998@itemx -E
d77de738
ML
17999If any of these options is used, then the linker is not run, and
18000object file names should not be used as arguments. @xref{Overall
18001Options}.
18002
d77de738 18003@opindex flinker-output
ddf6fe37 18004@item -flinker-output=@var{type}
d77de738
ML
18005This option controls code generation of the link-time optimizer. By
18006default the linker output is automatically determined by the linker
18007plugin. For debugging the compiler and if incremental linking with a
18008non-LTO object file is desired, it may be useful to control the type
18009manually.
18010
18011If @var{type} is @samp{exec}, code generation produces a static
18012binary. In this case @option{-fpic} and @option{-fpie} are both
18013disabled.
18014
18015If @var{type} is @samp{dyn}, code generation produces a shared
18016library. In this case @option{-fpic} or @option{-fPIC} is preserved,
18017but not enabled automatically. This allows to build shared libraries
18018without position-independent code on architectures where this is
18019possible, i.e.@: on x86.
18020
18021If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
18022executable. This results in similar optimizations as @samp{exec}
18023except that @option{-fpie} is not disabled if specified at compilation
18024time.
18025
18026If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
18027done. The sections containing intermediate code for link-time optimization are
18028merged, pre-optimized, and output to the resulting object file. In addition, if
18029@option{-ffat-lto-objects} is specified, binary code is produced for future
18030non-LTO linking. The object file produced by incremental linking is smaller
18031than a static library produced from the same object files. At link time the
18032result of incremental linking also loads faster than a static
18033library assuming that the majority of objects in the library are used.
18034
18035Finally @samp{nolto-rel} configures the compiler for incremental linking where
18036code generation is forced, a final binary is produced, and the intermediate
18037code for later link-time optimization is stripped. When multiple object files
18038are linked together the resulting code is better optimized than with
18039link-time optimizations disabled (for example, cross-module inlining
18040happens), but most of benefits of whole program optimizations are lost.
18041
18042During the incremental link (by @option{-r}) the linker plugin defaults to
18043@option{rel}. With current interfaces to GNU Binutils it is however not
18044possible to incrementally link LTO objects and non-LTO objects into a single
18045mixed object file. If any of object files in incremental link cannot
18046be used for link-time optimization, the linker plugin issues a warning and
18047uses @samp{nolto-rel}. To maintain whole program optimization, it is
18048recommended to link such objects into static library instead. Alternatively it
18049is possible to use H.J. Lu's binutils with support for mixed objects.
18050
d77de738 18051@opindex fuse-ld=bfd
ddf6fe37 18052@item -fuse-ld=bfd
d77de738
ML
18053Use the @command{bfd} linker instead of the default linker.
18054
d77de738 18055@opindex fuse-ld=gold
ddf6fe37 18056@item -fuse-ld=gold
d77de738
ML
18057Use the @command{gold} linker instead of the default linker.
18058
d77de738 18059@opindex fuse-ld=lld
ddf6fe37 18060@item -fuse-ld=lld
d77de738
ML
18061Use the LLVM @command{lld} linker instead of the default linker.
18062
d77de738 18063@opindex fuse-ld=mold
ddf6fe37 18064@item -fuse-ld=mold
d77de738
ML
18065Use the Modern Linker (@command{mold}) instead of the default linker.
18066
18067@cindex Libraries
ddf6fe37 18068@opindex l
d77de738
ML
18069@item -l@var{library}
18070@itemx -l @var{library}
d77de738
ML
18071Search the library named @var{library} when linking. (The second
18072alternative with the library as a separate argument is only for
18073POSIX compliance and is not recommended.)
18074
18075The @option{-l} option is passed directly to the linker by GCC. Refer
18076to your linker documentation for exact details. The general
18077description below applies to the GNU linker.
18078
18079The linker searches a standard list of directories for the library.
18080The directories searched include several standard system directories
18081plus any that you specify with @option{-L}.
18082
18083Static libraries are archives of object files, and have file names
18084like @file{lib@var{library}.a}. Some targets also support shared
18085libraries, which typically have names like @file{lib@var{library}.so}.
18086If both static and shared libraries are found, the linker gives
18087preference to linking with the shared library unless the
18088@option{-static} option is used.
18089
18090It makes a difference where in the command you write this option; the
18091linker searches and processes libraries and object files in the order they
18092are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
18093after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
18094to functions in @samp{z}, those functions may not be loaded.
18095
d77de738 18096@opindex lobjc
ddf6fe37 18097@item -lobjc
d77de738
ML
18098You need this special case of the @option{-l} option in order to
18099link an Objective-C or Objective-C++ program.
18100
d77de738 18101@opindex nostartfiles
ddf6fe37 18102@item -nostartfiles
d77de738
ML
18103Do not use the standard system startup files when linking.
18104The standard system libraries are used normally, unless @option{-nostdlib},
18105@option{-nolibc}, or @option{-nodefaultlibs} is used.
18106
d77de738 18107@opindex nodefaultlibs
ddf6fe37 18108@item -nodefaultlibs
d77de738
ML
18109Do not use the standard system libraries when linking.
18110Only the libraries you specify are passed to the linker, and options
18111specifying linkage of the system libraries, such as @option{-static-libgcc}
18112or @option{-shared-libgcc}, are ignored.
18113The standard startup files are used normally, unless @option{-nostartfiles}
18114is used.
18115
18116The compiler may generate calls to @code{memcmp},
18117@code{memset}, @code{memcpy} and @code{memmove}.
18118These entries are usually resolved by entries in
18119libc. These entry points should be supplied through some other
18120mechanism when this option is specified.
18121
d77de738 18122@opindex nolibc
ddf6fe37 18123@item -nolibc
d77de738
ML
18124Do not use the C library or system libraries tightly coupled with it when
18125linking. Still link with the startup files, @file{libgcc} or toolchain
18126provided language support libraries such as @file{libgnat}, @file{libgfortran}
18127or @file{libstdc++} unless options preventing their inclusion are used as
18128well. This typically removes @option{-lc} from the link command line, as well
18129as system libraries that normally go with it and become meaningless when
18130absence of a C library is assumed, for example @option{-lpthread} or
18131@option{-lm} in some configurations. This is intended for bare-board
18132targets when there is indeed no C library available.
18133
d77de738 18134@opindex nostdlib
ddf6fe37 18135@item -nostdlib
d77de738
ML
18136Do not use the standard system startup files or libraries when linking.
18137No startup files and only the libraries you specify are passed to
18138the linker, and options specifying linkage of the system libraries, such as
18139@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
18140
18141The compiler may generate calls to @code{memcmp}, @code{memset},
18142@code{memcpy} and @code{memmove}.
18143These entries are usually resolved by entries in
18144libc. These entry points should be supplied through some other
18145mechanism when this option is specified.
18146
18147@cindex @option{-lgcc}, use with @option{-nostdlib}
18148@cindex @option{-nostdlib} and unresolved references
18149@cindex unresolved references and @option{-nostdlib}
18150@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
18151@cindex @option{-nodefaultlibs} and unresolved references
18152@cindex unresolved references and @option{-nodefaultlibs}
18153One of the standard libraries bypassed by @option{-nostdlib} and
18154@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
18155which GCC uses to overcome shortcomings of particular machines, or special
18156needs for some languages.
18157(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
18158Collection (GCC) Internals},
18159for more discussion of @file{libgcc.a}.)
18160In most cases, you need @file{libgcc.a} even when you want to avoid
18161other standard libraries. In other words, when you specify @option{-nostdlib}
18162or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
18163This ensures that you have no unresolved references to internal GCC
18164library subroutines.
18165(An example of such an internal subroutine is @code{__main}, used to ensure C++
18166constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
18167GNU Compiler Collection (GCC) Internals}.)
18168
d77de738 18169@opindex nostdlib++
ddf6fe37 18170@item -nostdlib++
d77de738
ML
18171Do not implicitly link with standard C++ libraries.
18172
d77de738
ML
18173@opindex e
18174@opindex entry
ddf6fe37
AA
18175@item -e @var{entry}
18176@itemx --entry=@var{entry}
d77de738
ML
18177
18178Specify that the program entry point is @var{entry}. The argument is
18179interpreted by the linker; the GNU linker accepts either a symbol name
18180or an address.
18181
d77de738 18182@opindex pie
ddf6fe37 18183@item -pie
d77de738
ML
18184Produce a dynamically linked position independent executable on targets
18185that support it. For predictable results, you must also specify the same
18186set of options used for compilation (@option{-fpie}, @option{-fPIE},
18187or model suboptions) when you specify this linker option.
18188
d77de738 18189@opindex no-pie
ddf6fe37 18190@item -no-pie
d77de738
ML
18191Don't produce a dynamically linked position independent executable.
18192
d77de738 18193@opindex static-pie
ddf6fe37 18194@item -static-pie
d77de738
ML
18195Produce a static position independent executable on targets that support
18196it. A static position independent executable is similar to a static
18197executable, but can be loaded at any address without a dynamic linker.
18198For predictable results, you must also specify the same set of options
18199used for compilation (@option{-fpie}, @option{-fPIE}, or model
18200suboptions) when you specify this linker option.
18201
d77de738 18202@opindex pthread
ddf6fe37 18203@item -pthread
d77de738
ML
18204Link with the POSIX threads library. This option is supported on
18205GNU/Linux targets, most other Unix derivatives, and also on
18206x86 Cygwin and MinGW targets. On some targets this option also sets
18207flags for the preprocessor, so it should be used consistently for both
18208compilation and linking.
18209
d77de738 18210@opindex r
ddf6fe37 18211@item -r
d77de738
ML
18212Produce a relocatable object as output. This is also known as partial
18213linking.
18214
d77de738 18215@opindex rdynamic
ddf6fe37 18216@item -rdynamic
d77de738
ML
18217Pass the flag @option{-export-dynamic} to the ELF linker, on targets
18218that support it. This instructs the linker to add all symbols, not
18219only used ones, to the dynamic symbol table. This option is needed
18220for some uses of @code{dlopen} or to allow obtaining backtraces
18221from within a program.
18222
d77de738 18223@opindex s
ddf6fe37 18224@item -s
d77de738
ML
18225Remove all symbol table and relocation information from the executable.
18226
d77de738 18227@opindex static
ddf6fe37 18228@item -static
d77de738
ML
18229On systems that support dynamic linking, this overrides @option{-pie}
18230and prevents linking with the shared libraries. On other systems, this
18231option has no effect.
18232
d77de738 18233@opindex shared
ddf6fe37 18234@item -shared
d77de738
ML
18235Produce a shared object which can then be linked with other objects to
18236form an executable. Not all systems support this option. For predictable
18237results, you must also specify the same set of options used for compilation
18238(@option{-fpic}, @option{-fPIC}, or model suboptions) when
18239you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
18240needs to build supplementary stub code for constructors to work. On
18241multi-libbed systems, @samp{gcc -shared} must select the correct support
18242libraries to link against. Failing to supply the correct flags may lead
18243to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
18244is innocuous. @option{-shared} suppresses the addition of startup code
18245to alter the floating-point environment as done with @option{-ffast-math},
18246@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 18247
d77de738
ML
18248@opindex shared-libgcc
18249@opindex static-libgcc
ddf6fe37
AA
18250@item -shared-libgcc
18251@itemx -static-libgcc
d77de738
ML
18252On systems that provide @file{libgcc} as a shared library, these options
18253force the use of either the shared or static version, respectively.
18254If no shared version of @file{libgcc} was built when the compiler was
18255configured, these options have no effect.
18256
18257There are several situations in which an application should use the
18258shared @file{libgcc} instead of the static version. The most common
18259of these is when the application wishes to throw and catch exceptions
18260across different shared libraries. In that case, each of the libraries
18261as well as the application itself should use the shared @file{libgcc}.
18262
18263Therefore, the G++ driver automatically adds @option{-shared-libgcc}
18264whenever you build a shared library or a main executable, because C++
18265programs typically use exceptions, so this is the right thing to do.
18266
18267If, instead, you use the GCC driver to create shared libraries, you may
18268find that they are not always linked with the shared @file{libgcc}.
18269If GCC finds, at its configuration time, that you have a non-GNU linker
18270or a GNU linker that does not support option @option{--eh-frame-hdr},
18271it links the shared version of @file{libgcc} into shared libraries
18272by default. Otherwise, it takes advantage of the linker and optimizes
18273away the linking with the shared version of @file{libgcc}, linking with
18274the static version of libgcc by default. This allows exceptions to
18275propagate through such shared libraries, without incurring relocation
18276costs at library load time.
18277
18278However, if a library or main executable is supposed to throw or catch
18279exceptions, you must link it using the G++ driver, or using the option
18280@option{-shared-libgcc}, such that it is linked with the shared
18281@file{libgcc}.
18282
d77de738 18283@opindex static-libasan
ddf6fe37 18284@item -static-libasan
d77de738
ML
18285When the @option{-fsanitize=address} option is used to link a program,
18286the GCC driver automatically links against @option{libasan}. If
18287@file{libasan} is available as a shared library, and the @option{-static}
18288option is not used, then this links against the shared version of
18289@file{libasan}. The @option{-static-libasan} option directs the GCC
18290driver to link @file{libasan} statically, without necessarily linking
18291other libraries statically.
18292
d77de738 18293@opindex static-libtsan
ddf6fe37 18294@item -static-libtsan
d77de738
ML
18295When the @option{-fsanitize=thread} option is used to link a program,
18296the GCC driver automatically links against @option{libtsan}. If
18297@file{libtsan} is available as a shared library, and the @option{-static}
18298option is not used, then this links against the shared version of
18299@file{libtsan}. The @option{-static-libtsan} option directs the GCC
18300driver to link @file{libtsan} statically, without necessarily linking
18301other libraries statically.
18302
d77de738 18303@opindex static-liblsan
ddf6fe37 18304@item -static-liblsan
d77de738
ML
18305When the @option{-fsanitize=leak} option is used to link a program,
18306the GCC driver automatically links against @option{liblsan}. If
18307@file{liblsan} is available as a shared library, and the @option{-static}
18308option is not used, then this links against the shared version of
18309@file{liblsan}. The @option{-static-liblsan} option directs the GCC
18310driver to link @file{liblsan} statically, without necessarily linking
18311other libraries statically.
18312
d77de738 18313@opindex static-libubsan
ddf6fe37 18314@item -static-libubsan
d77de738
ML
18315When the @option{-fsanitize=undefined} option is used to link a program,
18316the GCC driver automatically links against @option{libubsan}. If
18317@file{libubsan} is available as a shared library, and the @option{-static}
18318option is not used, then this links against the shared version of
18319@file{libubsan}. The @option{-static-libubsan} option directs the GCC
18320driver to link @file{libubsan} statically, without necessarily linking
18321other libraries statically.
18322
d77de738 18323@opindex static-libstdc++
ddf6fe37 18324@item -static-libstdc++
d77de738
ML
18325When the @command{g++} program is used to link a C++ program, it
18326normally automatically links against @option{libstdc++}. If
18327@file{libstdc++} is available as a shared library, and the
18328@option{-static} option is not used, then this links against the
18329shared version of @file{libstdc++}. That is normally fine. However, it
18330is sometimes useful to freeze the version of @file{libstdc++} used by
18331the program without going all the way to a fully static link. The
18332@option{-static-libstdc++} option directs the @command{g++} driver to
18333link @file{libstdc++} statically, without necessarily linking other
18334libraries statically.
18335
d77de738 18336@opindex symbolic
ddf6fe37 18337@item -symbolic
d77de738
ML
18338Bind references to global symbols when building a shared object. Warn
18339about any unresolved references (unless overridden by the link editor
18340option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18341this option.
18342
d77de738
ML
18343@opindex T
18344@cindex linker script
f33d7a88 18345@item -T @var{script}
d77de738
ML
18346Use @var{script} as the linker script. This option is supported by most
18347systems using the GNU linker. On some targets, such as bare-board
18348targets without an operating system, the @option{-T} option may be required
18349when linking to avoid references to undefined symbols.
18350
d77de738 18351@opindex Xlinker
ddf6fe37 18352@item -Xlinker @var{option}
d77de738
ML
18353Pass @var{option} as an option to the linker. You can use this to
18354supply system-specific linker options that GCC does not recognize.
18355
18356If you want to pass an option that takes a separate argument, you must use
18357@option{-Xlinker} twice, once for the option and once for the argument.
18358For example, to pass @option{-assert definitions}, you must write
18359@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18360@option{-Xlinker "-assert definitions"}, because this passes the entire
18361string as a single argument, which is not what the linker expects.
18362
18363When using the GNU linker, it is usually more convenient to pass
18364arguments to linker options using the @option{@var{option}=@var{value}}
18365syntax than as separate arguments. For example, you can specify
18366@option{-Xlinker -Map=output.map} rather than
18367@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18368this syntax for command-line options.
18369
d77de738 18370@opindex Wl
ddf6fe37 18371@item -Wl,@var{option}
d77de738
ML
18372Pass @var{option} as an option to the linker. If @var{option} contains
18373commas, it is split into multiple options at the commas. You can use this
18374syntax to pass an argument to the option.
18375For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18376linker. When using the GNU linker, you can also get the same effect with
18377@option{-Wl,-Map=output.map}.
18378
d77de738 18379@opindex u
ddf6fe37 18380@item -u @var{symbol}
d77de738
ML
18381Pretend the symbol @var{symbol} is undefined, to force linking of
18382library modules to define it. You can use @option{-u} multiple times with
18383different symbols to force loading of additional library modules.
18384
d77de738 18385@opindex z
ddf6fe37 18386@item -z @var{keyword}
d77de738
ML
18387@option{-z} is passed directly on to the linker along with the keyword
18388@var{keyword}. See the section in the documentation of your linker for
18389permitted values and their meanings.
18390@end table
18391
18392@node Directory Options
18393@section Options for Directory Search
18394@cindex directory options
18395@cindex options, directory search
18396@cindex search path
18397
18398These options specify directories to search for header files, for
18399libraries and for parts of the compiler:
18400
18401@table @gcctabopt
18402@include cppdiropts.texi
18403
d77de738 18404@opindex iplugindir=
ddf6fe37 18405@item -iplugindir=@var{dir}
d77de738
ML
18406Set the directory to search for plugins that are passed
18407by @option{-fplugin=@var{name}} instead of
18408@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18409to be used by the user, but only passed by the driver.
18410
d77de738 18411@opindex L
ddf6fe37 18412@item -L@var{dir}
d77de738
ML
18413Add directory @var{dir} to the list of directories to be searched
18414for @option{-l}.
18415
d77de738 18416@opindex B
ddf6fe37 18417@item -B@var{prefix}
d77de738
ML
18418This option specifies where to find the executables, libraries,
18419include files, and data files of the compiler itself.
18420
18421The compiler driver program runs one or more of the subprograms
18422@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18423@var{prefix} as a prefix for each program it tries to run, both with and
18424without @samp{@var{machine}/@var{version}/} for the corresponding target
18425machine and compiler version.
18426
18427For each subprogram to be run, the compiler driver first tries the
18428@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18429is not specified, the driver tries two standard prefixes,
18430@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18431those results in a file name that is found, the unmodified program
18432name is searched for using the directories specified in your
18433@env{PATH} environment variable.
18434
18435The compiler checks to see if the path provided by @option{-B}
18436refers to a directory, and if necessary it adds a directory
18437separator character at the end of the path.
18438
18439@option{-B} prefixes that effectively specify directory names also apply
18440to libraries in the linker, because the compiler translates these
18441options into @option{-L} options for the linker. They also apply to
18442include files in the preprocessor, because the compiler translates these
18443options into @option{-isystem} options for the preprocessor. In this case,
18444the compiler appends @samp{include} to the prefix.
18445
18446The runtime support file @file{libgcc.a} can also be searched for using
18447the @option{-B} prefix, if needed. If it is not found there, the two
18448standard prefixes above are tried, and that is all. The file is left
18449out of the link if it is not found by those means.
18450
18451Another way to specify a prefix much like the @option{-B} prefix is to use
18452the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18453Variables}.
18454
18455As a special kludge, if the path provided by @option{-B} is
18456@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
184579, then it is replaced by @file{[dir/]include}. This is to help
18458with boot-strapping the compiler.
18459
d77de738 18460@opindex no-canonical-prefixes
ddf6fe37 18461@item -no-canonical-prefixes
d77de738
ML
18462Do not expand any symbolic links, resolve references to @samp{/../}
18463or @samp{/./}, or make the path absolute when generating a relative
18464prefix.
18465
d77de738 18466@opindex sysroot
ddf6fe37 18467@item --sysroot=@var{dir}
d77de738
ML
18468Use @var{dir} as the logical root directory for headers and libraries.
18469For example, if the compiler normally searches for headers in
18470@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18471searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18472
18473If you use both this option and the @option{-isysroot} option, then
18474the @option{--sysroot} option applies to libraries, but the
18475@option{-isysroot} option applies to header files.
18476
18477The GNU linker (beginning with version 2.16) has the necessary support
18478for this option. If your linker does not support this option, the
18479header file aspect of @option{--sysroot} still works, but the
18480library aspect does not.
18481
d77de738 18482@opindex no-sysroot-suffix
ddf6fe37 18483@item --no-sysroot-suffix
d77de738
ML
18484For some targets, a suffix is added to the root directory specified
18485with @option{--sysroot}, depending on the other options used, so that
18486headers may for example be found in
18487@file{@var{dir}/@var{suffix}/usr/include} instead of
18488@file{@var{dir}/usr/include}. This option disables the addition of
18489such a suffix.
18490
18491@end table
18492
18493@node Code Gen Options
18494@section Options for Code Generation Conventions
18495@cindex code generation conventions
18496@cindex options, code generation
18497@cindex run-time options
18498
18499These machine-independent options control the interface conventions
18500used in code generation.
18501
18502Most of them have both positive and negative forms; the negative form
18503of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18504one of the forms is listed---the one that is not the default. You
18505can figure out the other form by either removing @samp{no-} or adding
18506it.
18507
18508@table @gcctabopt
d77de738 18509@opindex fstack_reuse
ddf6fe37 18510@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18511This option controls stack space reuse for user declared local/auto variables
18512and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18513@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18514local variables and temporaries, @samp{named_vars} enables the reuse only for
18515user defined local variables with names, and @samp{none} disables stack reuse
18516completely. The default value is @samp{all}. The option is needed when the
18517program extends the lifetime of a scoped local variable or a compiler generated
18518temporary beyond the end point defined by the language. When a lifetime of
18519a variable ends, and if the variable lives in memory, the optimizing compiler
18520has the freedom to reuse its stack space with other temporaries or scoped
18521local variables whose live range does not overlap with it. Legacy code extending
18522local lifetime is likely to break with the stack reuse optimization.
18523
18524For example,
18525
18526@smallexample
18527 int *p;
18528 @{
18529 int local1;
18530
18531 p = &local1;
18532 local1 = 10;
18533 ....
18534 @}
18535 @{
18536 int local2;
18537 local2 = 20;
18538 ...
18539 @}
18540
18541 if (*p == 10) // out of scope use of local1
18542 @{
18543
18544 @}
18545@end smallexample
18546
18547Another example:
18548@smallexample
18549
18550 struct A
18551 @{
18552 A(int k) : i(k), j(k) @{ @}
18553 int i;
18554 int j;
18555 @};
18556
18557 A *ap;
18558
18559 void foo(const A& ar)
18560 @{
18561 ap = &ar;
18562 @}
18563
18564 void bar()
18565 @{
18566 foo(A(10)); // temp object's lifetime ends when foo returns
18567
18568 @{
18569 A a(20);
18570 ....
18571 @}
18572 ap->i+= 10; // ap references out of scope temp whose space
18573 // is reused with a. What is the value of ap->i?
18574 @}
18575
18576@end smallexample
18577
18578The lifetime of a compiler generated temporary is well defined by the C++
18579standard. When a lifetime of a temporary ends, and if the temporary lives
18580in memory, the optimizing compiler has the freedom to reuse its stack
18581space with other temporaries or scoped local variables whose live range
18582does not overlap with it. However some of the legacy code relies on
18583the behavior of older compilers in which temporaries' stack space is
18584not reused, the aggressive stack reuse can lead to runtime errors. This
18585option is used to control the temporary stack reuse optimization.
18586
d77de738 18587@opindex ftrapv
ddf6fe37 18588@item -ftrapv
d77de738
ML
18589This option generates traps for signed overflow on addition, subtraction,
18590multiplication operations.
18591The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18592@option{-ftrapv} @option{-fwrapv} on the command-line results in
18593@option{-fwrapv} being effective. Note that only active options override, so
18594using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18595results in @option{-ftrapv} being effective.
18596
d77de738 18597@opindex fwrapv
ddf6fe37 18598@item -fwrapv
d77de738
ML
18599This option instructs the compiler to assume that signed arithmetic
18600overflow of addition, subtraction and multiplication wraps around
18601using twos-complement representation. This flag enables some optimizations
18602and disables others.
18603The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18604@option{-ftrapv} @option{-fwrapv} on the command-line results in
18605@option{-fwrapv} being effective. Note that only active options override, so
18606using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18607results in @option{-ftrapv} being effective.
18608
d77de738 18609@opindex fwrapv-pointer
ddf6fe37 18610@item -fwrapv-pointer
d77de738
ML
18611This option instructs the compiler to assume that pointer arithmetic
18612overflow on addition and subtraction wraps around using twos-complement
18613representation. This flag disables some optimizations which assume
18614pointer overflow is invalid.
18615
d77de738 18616@opindex fstrict-overflow
ddf6fe37 18617@item -fstrict-overflow
d77de738
ML
18618This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18619negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18620
d77de738 18621@opindex fexceptions
ddf6fe37 18622@item -fexceptions
d77de738
ML
18623Enable exception handling. Generates extra code needed to propagate
18624exceptions. For some targets, this implies GCC generates frame
18625unwind information for all functions, which can produce significant data
18626size overhead, although it does not affect execution. If you do not
18627specify this option, GCC enables it by default for languages like
18628C++ that normally require exception handling, and disables it for
18629languages like C that do not normally require it. However, you may need
18630to enable this option when compiling C code that needs to interoperate
18631properly with exception handlers written in C++. You may also wish to
18632disable this option if you are compiling older C++ programs that don't
18633use exception handling.
18634
d77de738 18635@opindex fnon-call-exceptions
ddf6fe37 18636@item -fnon-call-exceptions
d77de738
ML
18637Generate code that allows trapping instructions to throw exceptions.
18638Note that this requires platform-specific runtime support that does
18639not exist everywhere. Moreover, it only allows @emph{trapping}
18640instructions to throw exceptions, i.e.@: memory references or floating-point
18641instructions. It does not allow exceptions to be thrown from
18642arbitrary signal handlers such as @code{SIGALRM}. This enables
18643@option{-fexceptions}.
18644
d77de738 18645@opindex fdelete-dead-exceptions
ddf6fe37 18646@item -fdelete-dead-exceptions
d77de738
ML
18647Consider that instructions that may throw exceptions but don't otherwise
18648contribute to the execution of the program can be optimized away.
18649This does not affect calls to functions except those with the
18650@code{pure} or @code{const} attributes.
18651This option is enabled by default for the Ada and C++ compilers, as permitted by
18652the language specifications.
18653Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18654
d77de738 18655@opindex funwind-tables
ddf6fe37 18656@item -funwind-tables
d77de738
ML
18657Similar to @option{-fexceptions}, except that it just generates any needed
18658static data, but does not affect the generated code in any other way.
18659You normally do not need to enable this option; instead, a language processor
18660that needs this handling enables it on your behalf.
18661
d77de738 18662@opindex fasynchronous-unwind-tables
ddf6fe37 18663@item -fasynchronous-unwind-tables
d77de738
ML
18664Generate unwind table in DWARF format, if supported by target machine. The
18665table is exact at each instruction boundary, so it can be used for stack
18666unwinding from asynchronous events (such as debugger or garbage collector).
18667
d77de738
ML
18668@opindex fno-gnu-unique
18669@opindex fgnu-unique
ddf6fe37 18670@item -fno-gnu-unique
d77de738
ML
18671On systems with recent GNU assembler and C library, the C++ compiler
18672uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18673of template static data members and static local variables in inline
18674functions are unique even in the presence of @code{RTLD_LOCAL}; this
18675is necessary to avoid problems with a library used by two different
18676@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18677therefore disagreeing with the other one about the binding of the
18678symbol. But this causes @code{dlclose} to be ignored for affected
18679DSOs; if your program relies on reinitialization of a DSO via
18680@code{dlclose} and @code{dlopen}, you can use
18681@option{-fno-gnu-unique}.
18682
d77de738 18683@opindex fpcc-struct-return
ddf6fe37 18684@item -fpcc-struct-return
d77de738
ML
18685Return ``short'' @code{struct} and @code{union} values in memory like
18686longer ones, rather than in registers. This convention is less
18687efficient, but it has the advantage of allowing intercallability between
18688GCC-compiled files and files compiled with other compilers, particularly
18689the Portable C Compiler (pcc).
18690
18691The precise convention for returning structures in memory depends
18692on the target configuration macros.
18693
18694Short structures and unions are those whose size and alignment match
18695that of some integer type.
18696
18697@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18698switch is not binary compatible with code compiled with the
18699@option{-freg-struct-return} switch.
18700Use it to conform to a non-default application binary interface.
18701
d77de738 18702@opindex freg-struct-return
ddf6fe37 18703@item -freg-struct-return
d77de738
ML
18704Return @code{struct} and @code{union} values in registers when possible.
18705This is more efficient for small structures than
18706@option{-fpcc-struct-return}.
18707
18708If you specify neither @option{-fpcc-struct-return} nor
18709@option{-freg-struct-return}, GCC defaults to whichever convention is
18710standard for the target. If there is no standard convention, GCC
18711defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18712the principal compiler. In those cases, we can choose the standard, and
18713we chose the more efficient register return alternative.
18714
18715@strong{Warning:} code compiled with the @option{-freg-struct-return}
18716switch is not binary compatible with code compiled with the
18717@option{-fpcc-struct-return} switch.
18718Use it to conform to a non-default application binary interface.
18719
d77de738 18720@opindex fshort-enums
ddf6fe37 18721@item -fshort-enums
d77de738
ML
18722Allocate to an @code{enum} type only as many bytes as it needs for the
18723declared range of possible values. Specifically, the @code{enum} type
18724is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
18725This option has no effect for an enumeration type with a fixed underlying
18726type.
d77de738
ML
18727
18728@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18729code that is not binary compatible with code generated without that switch.
18730Use it to conform to a non-default application binary interface.
18731
d77de738 18732@opindex fshort-wchar
ddf6fe37 18733@item -fshort-wchar
d77de738
ML
18734Override the underlying type for @code{wchar_t} to be @code{short
18735unsigned int} instead of the default for the target. This option is
18736useful for building programs to run under WINE@.
18737
18738@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18739code that is not binary compatible with code generated without that switch.
18740Use it to conform to a non-default application binary interface.
18741
d77de738
ML
18742@opindex fcommon
18743@opindex fno-common
18744@cindex tentative definitions
f33d7a88 18745@item -fcommon
d77de738
ML
18746In C code, this option controls the placement of global variables
18747defined without an initializer, known as @dfn{tentative definitions}
18748in the C standard. Tentative definitions are distinct from declarations
18749of a variable with the @code{extern} keyword, which do not allocate storage.
18750
18751The default is @option{-fno-common}, which specifies that the compiler places
18752uninitialized global variables in the BSS section of the object file.
18753This inhibits the merging of tentative definitions by the linker so you get a
18754multiple-definition error if the same variable is accidentally defined in more
18755than one compilation unit.
18756
18757The @option{-fcommon} places uninitialized global variables in a common block.
18758This allows the linker to resolve all tentative definitions of the same variable
18759in different compilation units to the same object, or to a non-tentative
18760definition. This behavior is inconsistent with C++, and on many targets implies
18761a speed and code size penalty on global variable references. It is mainly
18762useful to enable legacy code to link without errors.
18763
d77de738
ML
18764@opindex fno-ident
18765@opindex fident
ddf6fe37 18766@item -fno-ident
d77de738
ML
18767Ignore the @code{#ident} directive.
18768
d77de738 18769@opindex finhibit-size-directive
ddf6fe37 18770@item -finhibit-size-directive
d77de738
ML
18771Don't output a @code{.size} assembler directive, or anything else that
18772would cause trouble if the function is split in the middle, and the
18773two halves are placed at locations far apart in memory. This option is
18774used when compiling @file{crtstuff.c}; you should not need to use it
18775for anything else.
18776
d77de738 18777@opindex fverbose-asm
ddf6fe37 18778@item -fverbose-asm
d77de738
ML
18779Put extra commentary information in the generated assembly code to
18780make it more readable. This option is generally only of use to those
18781who actually need to read the generated assembly code (perhaps while
18782debugging the compiler itself).
18783
18784@option{-fno-verbose-asm}, the default, causes the
18785extra information to be omitted and is useful when comparing two assembler
18786files.
18787
18788The added comments include:
18789
18790@itemize @bullet
18791
18792@item
18793information on the compiler version and command-line options,
18794
18795@item
18796the source code lines associated with the assembly instructions,
18797in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18798
18799@item
18800hints on which high-level expressions correspond to
18801the various assembly instruction operands.
18802
18803@end itemize
18804
18805For example, given this C source file:
18806
18807@smallexample
18808int test (int n)
18809@{
18810 int i;
18811 int total = 0;
18812
18813 for (i = 0; i < n; i++)
18814 total += i * i;
18815
18816 return total;
18817@}
18818@end smallexample
18819
18820compiling to (x86_64) assembly via @option{-S} and emitting the result
18821direct to stdout via @option{-o} @option{-}
18822
18823@smallexample
18824gcc -S test.c -fverbose-asm -Os -o -
18825@end smallexample
18826
18827gives output similar to this:
18828
18829@smallexample
18830 .file "test.c"
18831# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18832 [...snip...]
18833# options passed:
18834 [...snip...]
18835
18836 .text
18837 .globl test
18838 .type test, @@function
18839test:
18840.LFB0:
18841 .cfi_startproc
18842# test.c:4: int total = 0;
18843 xorl %eax, %eax # <retval>
18844# test.c:6: for (i = 0; i < n; i++)
18845 xorl %edx, %edx # i
18846.L2:
18847# test.c:6: for (i = 0; i < n; i++)
18848 cmpl %edi, %edx # n, i
18849 jge .L5 #,
18850# test.c:7: total += i * i;
18851 movl %edx, %ecx # i, tmp92
18852 imull %edx, %ecx # i, tmp92
18853# test.c:6: for (i = 0; i < n; i++)
18854 incl %edx # i
18855# test.c:7: total += i * i;
18856 addl %ecx, %eax # tmp92, <retval>
18857 jmp .L2 #
18858.L5:
18859# test.c:10: @}
18860 ret
18861 .cfi_endproc
18862.LFE0:
18863 .size test, .-test
18864 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18865 .section .note.GNU-stack,"",@@progbits
18866@end smallexample
18867
18868The comments are intended for humans rather than machines and hence the
18869precise format of the comments is subject to change.
18870
d77de738 18871@opindex frecord-gcc-switches
ddf6fe37 18872@item -frecord-gcc-switches
d77de738
ML
18873This switch causes the command line used to invoke the
18874compiler to be recorded into the object file that is being created.
18875This switch is only implemented on some targets and the exact format
18876of the recording is target and binary file format dependent, but it
18877usually takes the form of a section containing ASCII text. This
18878switch is related to the @option{-fverbose-asm} switch, but that
18879switch only records information in the assembler output file as
18880comments, so it never reaches the object file.
18881See also @option{-grecord-gcc-switches} for another
18882way of storing compiler options into the object file.
18883
d77de738
ML
18884@opindex fpic
18885@cindex global offset table
18886@cindex PIC
f33d7a88 18887@item -fpic
d77de738
ML
18888Generate position-independent code (PIC) suitable for use in a shared
18889library, if supported for the target machine. Such code accesses all
18890constant addresses through a global offset table (GOT)@. The dynamic
18891loader resolves the GOT entries when the program starts (the dynamic
18892loader is not part of GCC; it is part of the operating system). If
18893the GOT size for the linked executable exceeds a machine-specific
18894maximum size, you get an error message from the linker indicating that
18895@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18896instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18897on the m68k and RS/6000. The x86 has no such limit.)
18898
18899Position-independent code requires special support, and therefore works
18900only on certain machines. For the x86, GCC supports PIC for System V
18901but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18902position-independent.
18903
18904When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18905are defined to 1.
18906
d77de738 18907@opindex fPIC
ddf6fe37 18908@item -fPIC
d77de738
ML
18909If supported for the target machine, emit position-independent code,
18910suitable for dynamic linking and avoiding any limit on the size of the
18911global offset table. This option makes a difference on AArch64, m68k,
18912PowerPC and SPARC@.
18913
18914Position-independent code requires special support, and therefore works
18915only on certain machines.
18916
18917When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18918are defined to 2.
18919
d77de738
ML
18920@opindex fpie
18921@opindex fPIE
ddf6fe37
AA
18922@item -fpie
18923@itemx -fPIE
d77de738
ML
18924These options are similar to @option{-fpic} and @option{-fPIC}, but the
18925generated position-independent code can be only linked into executables.
18926Usually these options are used to compile code that will be linked using
18927the @option{-pie} GCC option.
18928
18929@option{-fpie} and @option{-fPIE} both define the macros
18930@code{__pie__} and @code{__PIE__}. The macros have the value 1
18931for @option{-fpie} and 2 for @option{-fPIE}.
18932
d77de738
ML
18933@opindex fno-plt
18934@opindex fplt
ddf6fe37 18935@item -fno-plt
d77de738
ML
18936Do not use the PLT for external function calls in position-independent code.
18937Instead, load the callee address at call sites from the GOT and branch to it.
18938This leads to more efficient code by eliminating PLT stubs and exposing
18939GOT loads to optimizations. On architectures such as 32-bit x86 where
18940PLT stubs expect the GOT pointer in a specific register, this gives more
18941register allocation freedom to the compiler.
18942Lazy binding requires use of the PLT;
18943with @option{-fno-plt} all external symbols are resolved at load time.
18944
18945Alternatively, the function attribute @code{noplt} can be used to avoid calls
18946through the PLT for specific external functions.
18947
18948In position-dependent code, a few targets also convert calls to
18949functions that are marked to not use the PLT to use the GOT instead.
18950
d77de738
ML
18951@opindex fno-jump-tables
18952@opindex fjump-tables
ddf6fe37 18953@item -fno-jump-tables
d77de738
ML
18954Do not use jump tables for switch statements even where it would be
18955more efficient than other code generation strategies. This option is
18956of use in conjunction with @option{-fpic} or @option{-fPIC} for
18957building code that forms part of a dynamic linker and cannot
18958reference the address of a jump table. On some targets, jump tables
18959do not require a GOT and this option is not needed.
18960
d77de738
ML
18961@opindex fno-bit-tests
18962@opindex fbit-tests
ddf6fe37 18963@item -fno-bit-tests
d77de738
ML
18964Do not use bit tests for switch statements even where it would be
18965more efficient than other code generation strategies.
18966
d77de738 18967@opindex ffixed
ddf6fe37 18968@item -ffixed-@var{reg}
d77de738
ML
18969Treat the register named @var{reg} as a fixed register; generated code
18970should never refer to it (except perhaps as a stack pointer, frame
18971pointer or in some other fixed role).
18972
18973@var{reg} must be the name of a register. The register names accepted
18974are machine-specific and are defined in the @code{REGISTER_NAMES}
18975macro in the machine description macro file.
18976
18977This flag does not have a negative form, because it specifies a
18978three-way choice.
18979
d77de738 18980@opindex fcall-used
ddf6fe37 18981@item -fcall-used-@var{reg}
d77de738
ML
18982Treat the register named @var{reg} as an allocable register that is
18983clobbered by function calls. It may be allocated for temporaries or
18984variables that do not live across a call. Functions compiled this way
18985do not save and restore the register @var{reg}.
18986
18987It is an error to use this flag with the frame pointer or stack pointer.
18988Use of this flag for other registers that have fixed pervasive roles in
18989the machine's execution model produces disastrous results.
18990
18991This flag does not have a negative form, because it specifies a
18992three-way choice.
18993
d77de738 18994@opindex fcall-saved
ddf6fe37 18995@item -fcall-saved-@var{reg}
d77de738
ML
18996Treat the register named @var{reg} as an allocable register saved by
18997functions. It may be allocated even for temporaries or variables that
18998live across a call. Functions compiled this way save and restore
18999the register @var{reg} if they use it.
19000
19001It is an error to use this flag with the frame pointer or stack pointer.
19002Use of this flag for other registers that have fixed pervasive roles in
19003the machine's execution model produces disastrous results.
19004
19005A different sort of disaster results from the use of this flag for
19006a register in which function values may be returned.
19007
19008This flag does not have a negative form, because it specifies a
19009three-way choice.
19010
d77de738 19011@opindex fpack-struct
ddf6fe37 19012@item -fpack-struct[=@var{n}]
d77de738
ML
19013Without a value specified, pack all structure members together without
19014holes. When a value is specified (which must be a small power of two), pack
19015structure members according to this value, representing the maximum
19016alignment (that is, objects with default alignment requirements larger than
19017this are output potentially unaligned at the next fitting location.
19018
19019@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
19020code that is not binary compatible with code generated without that switch.
19021Additionally, it makes the code suboptimal.
19022Use it to conform to a non-default application binary interface.
19023
d77de738 19024@opindex fleading-underscore
ddf6fe37 19025@item -fleading-underscore
d77de738
ML
19026This option and its counterpart, @option{-fno-leading-underscore}, forcibly
19027change the way C symbols are represented in the object file. One use
19028is to help link with legacy assembly code.
19029
19030@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
19031generate code that is not binary compatible with code generated without that
19032switch. Use it to conform to a non-default application binary interface.
19033Not all targets provide complete support for this switch.
19034
d77de738 19035@opindex ftls-model
ddf6fe37 19036@item -ftls-model=@var{model}
d77de738
ML
19037Alter the thread-local storage model to be used (@pxref{Thread-Local}).
19038The @var{model} argument should be one of @samp{global-dynamic},
19039@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
19040Note that the choice is subject to optimization: the compiler may use
19041a more efficient model for symbols not visible outside of the translation
19042unit, or if @option{-fpic} is not given on the command line.
19043
19044The default without @option{-fpic} is @samp{initial-exec}; with
19045@option{-fpic} the default is @samp{global-dynamic}.
19046
d77de738 19047@opindex ftrampolines
ddf6fe37 19048@item -ftrampolines
d77de738
ML
19049For targets that normally need trampolines for nested functions, always
19050generate them instead of using descriptors. Otherwise, for targets that
19051do not need them, like for example HP-PA or IA-64, do nothing.
19052
19053A trampoline is a small piece of code that is created at run time on the
19054stack when the address of a nested function is taken, and is used to call
19055the nested function indirectly. Therefore, it requires the stack to be
19056made executable in order for the program to work properly.
19057
19058@option{-fno-trampolines} is enabled by default on a language by language
19059basis to let the compiler avoid generating them, if it computes that this
19060is safe, and replace them with descriptors. Descriptors are made up of data
19061only, but the generated code must be prepared to deal with them. As of this
19062writing, @option{-fno-trampolines} is enabled by default only for Ada.
19063
19064Moreover, code compiled with @option{-ftrampolines} and code compiled with
19065@option{-fno-trampolines} are not binary compatible if nested functions are
19066present. This option must therefore be used on a program-wide basis and be
19067manipulated with extreme care.
19068
19069For languages other than Ada, the @code{-ftrampolines} and
19070@code{-fno-trampolines} options currently have no effect, and
19071trampolines are always generated on platforms that need them
19072for nested functions.
19073
28d8c680
AB
19074@opindex ftrampoline-impl
19075@item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
19076By default, trampolines are generated on stack. However, certain platforms
19077(such as the Apple M1) do not permit an executable stack. Compiling with
19078@option{-ftrampoline-impl=heap} generate calls to
19079@code{__builtin_nested_func_ptr_created} and
19080@code{__builtin_nested_func_ptr_deleted} in order to allocate and
19081deallocate trampoline space on the executable heap. These functions are
19082implemented in libgcc, and will only be provided on specific targets:
19083x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
19084trampolines are @emph{not} guaranteed to be correctly deallocated if you
19085@code{setjmp}, instantiate nested functions, and then @code{longjmp} back
19086to a state prior to having allocated those nested functions.
19087
d77de738 19088@opindex fvisibility
ddf6fe37 19089@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
19090Set the default ELF image symbol visibility to the specified option---all
19091symbols are marked with this unless overridden within the code.
19092Using this feature can very substantially improve linking and
19093load times of shared object libraries, produce more optimized
19094code, provide near-perfect API export and prevent symbol clashes.
19095It is @strong{strongly} recommended that you use this in any shared objects
19096you distribute.
19097
19098Despite the nomenclature, @samp{default} always means public; i.e.,
19099available to be linked against from outside the shared object.
19100@samp{protected} and @samp{internal} are pretty useless in real-world
19101usage so the only other commonly used option is @samp{hidden}.
19102The default if @option{-fvisibility} isn't specified is
19103@samp{default}, i.e., make every symbol public.
19104
19105A good explanation of the benefits offered by ensuring ELF
19106symbols have the correct visibility is given by ``How To Write
19107Shared Libraries'' by Ulrich Drepper (which can be found at
19108@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
19109solution made possible by this option to marking things hidden when
19110the default is public is to make the default hidden and mark things
19111public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
19112and @code{__attribute__ ((visibility("default")))} instead of
19113@code{__declspec(dllexport)} you get almost identical semantics with
19114identical syntax. This is a great boon to those working with
19115cross-platform projects.
19116
19117For those adding visibility support to existing code, you may find
19118@code{#pragma GCC visibility} of use. This works by you enclosing
19119the declarations you wish to set visibility for with (for example)
19120@code{#pragma GCC visibility push(hidden)} and
19121@code{#pragma GCC visibility pop}.
19122Bear in mind that symbol visibility should be viewed @strong{as
19123part of the API interface contract} and thus all new code should
19124always specify visibility when it is not the default; i.e., declarations
19125only for use within the local DSO should @strong{always} be marked explicitly
19126as hidden as so to avoid PLT indirection overheads---making this
19127abundantly clear also aids readability and self-documentation of the code.
19128Note that due to ISO C++ specification requirements, @code{operator new} and
19129@code{operator delete} must always be of default visibility.
19130
19131Be aware that headers from outside your project, in particular system
19132headers and headers from any other library you use, may not be
19133expecting to be compiled with visibility other than the default. You
19134may need to explicitly say @code{#pragma GCC visibility push(default)}
19135before including any such headers.
19136
19137@code{extern} declarations are not affected by @option{-fvisibility}, so
19138a lot of code can be recompiled with @option{-fvisibility=hidden} with
19139no modifications. However, this means that calls to @code{extern}
19140functions with no explicit visibility use the PLT, so it is more
19141effective to use @code{__attribute ((visibility))} and/or
19142@code{#pragma GCC visibility} to tell the compiler which @code{extern}
19143declarations should be treated as hidden.
19144
19145Note that @option{-fvisibility} does affect C++ vague linkage
19146entities. This means that, for instance, an exception class that is
19147be thrown between DSOs must be explicitly marked with default
19148visibility so that the @samp{type_info} nodes are unified between
19149the DSOs.
19150
19151An overview of these techniques, their benefits and how to use them
19152is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
19153
d77de738 19154@opindex fstrict-volatile-bitfields
ddf6fe37 19155@item -fstrict-volatile-bitfields
d77de738
ML
19156This option should be used if accesses to volatile bit-fields (or other
19157structure fields, although the compiler usually honors those types
19158anyway) should use a single access of the width of the
19159field's type, aligned to a natural alignment if possible. For
19160example, targets with memory-mapped peripheral registers might require
19161all such accesses to be 16 bits wide; with this flag you can
19162declare all peripheral bit-fields as @code{unsigned short} (assuming short
19163is 16 bits on these targets) to force GCC to use 16-bit accesses
19164instead of, perhaps, a more efficient 32-bit access.
19165
19166If this option is disabled, the compiler uses the most efficient
19167instruction. In the previous example, that might be a 32-bit load
19168instruction, even though that accesses bytes that do not contain
19169any portion of the bit-field, or memory-mapped registers unrelated to
19170the one being updated.
19171
19172In some cases, such as when the @code{packed} attribute is applied to a
19173structure field, it may not be possible to access the field with a single
19174read or write that is correctly aligned for the target machine. In this
19175case GCC falls back to generating multiple accesses rather than code that
19176will fault or truncate the result at run time.
19177
19178Note: Due to restrictions of the C/C++11 memory model, write accesses are
19179not allowed to touch non bit-field members. It is therefore recommended
19180to define all bits of the field's type as bit-field members.
19181
19182The default value of this option is determined by the application binary
19183interface for the target processor.
19184
d77de738 19185@opindex fsync-libcalls
ddf6fe37 19186@item -fsync-libcalls
d77de738
ML
19187This option controls whether any out-of-line instance of the @code{__sync}
19188family of functions may be used to implement the C++11 @code{__atomic}
19189family of functions.
19190
19191The default value of this option is enabled, thus the only useful form
19192of the option is @option{-fno-sync-libcalls}. This option is used in
19193the implementation of the @file{libatomic} runtime library.
19194
19195@end table
19196
19197@node Developer Options
19198@section GCC Developer Options
19199@cindex developer options
19200@cindex debugging GCC
19201@cindex debug dump options
19202@cindex dump options
19203@cindex compilation statistics
19204
19205This section describes command-line options that are primarily of
19206interest to GCC developers, including options to support compiler
19207testing and investigation of compiler bugs and compile-time
19208performance problems. This includes options that produce debug dumps
19209at various points in the compilation; that print statistics such as
19210memory use and execution time; and that print information about GCC's
19211configuration, such as where it searches for libraries. You should
19212rarely need to use any of these options for ordinary compilation and
19213linking tasks.
19214
19215Many developer options that cause GCC to dump output to a file take an
19216optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
19217or @samp{-} to dump to standard output, and @samp{stderr} for standard
19218error.
19219
19220If @samp{=@var{filename}} is omitted, a default dump file name is
19221constructed by concatenating the base dump file name, a pass number,
19222phase letter, and pass name. The base dump file name is the name of
19223output file produced by the compiler if explicitly specified and not
19224an executable; otherwise it is the source file name.
19225The pass number is determined by the order passes are registered with
19226the compiler's pass manager.
19227This is generally the same as the order of execution, but passes
19228registered by plugins, target-specific passes, or passes that are
19229otherwise registered late are numbered higher than the pass named
19230@samp{final}, even if they are executed earlier. The phase letter is
19231one of @samp{i} (inter-procedural analysis), @samp{l}
19232(language-specific), @samp{r} (RTL), or @samp{t} (tree).
19233The files are created in the directory of the output file.
19234
19235@table @gcctabopt
19236
ddf6fe37 19237@opindex fcallgraph-info
d77de738
ML
19238@item -fcallgraph-info
19239@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
19240Makes the compiler output callgraph information for the program, on a
19241per-object-file basis. The information is generated in the common VCG
19242format. It can be decorated with additional, per-node and/or per-edge
19243information, if a list of comma-separated markers is additionally
19244specified. When the @code{su} marker is specified, the callgraph is
19245decorated with stack usage information; it is equivalent to
19246@option{-fstack-usage}. When the @code{da} marker is specified, the
19247callgraph is decorated with information about dynamically allocated
19248objects.
19249
19250When compiling with @option{-flto}, no callgraph information is output
19251along with the object file. At LTO link time, @option{-fcallgraph-info}
19252may generate multiple callgraph information files next to intermediate
19253LTO output files.
19254
ddf6fe37
AA
19255@opindex d
19256@opindex fdump-rtl-@var{pass}
d77de738
ML
19257@item -d@var{letters}
19258@itemx -fdump-rtl-@var{pass}
19259@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
19260Says to make debugging dumps during compilation at times specified by
19261@var{letters}. This is used for debugging the RTL-based passes of the
19262compiler.
19263
19264Some @option{-d@var{letters}} switches have different meaning when
19265@option{-E} is used for preprocessing. @xref{Preprocessor Options},
19266for information about preprocessor-specific dump options.
19267
19268Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
19269@option{-d} option @var{letters}. Here are the possible
19270letters for use in @var{pass} and @var{letters}, and their meanings:
19271
19272@table @gcctabopt
19273
d77de738 19274@opindex fdump-rtl-alignments
ddf6fe37 19275@item -fdump-rtl-alignments
d77de738
ML
19276Dump after branch alignments have been computed.
19277
d77de738 19278@opindex fdump-rtl-asmcons
ddf6fe37 19279@item -fdump-rtl-asmcons
d77de738
ML
19280Dump after fixing rtl statements that have unsatisfied in/out constraints.
19281
d77de738 19282@opindex fdump-rtl-auto_inc_dec
ddf6fe37 19283@item -fdump-rtl-auto_inc_dec
d77de738
ML
19284Dump after auto-inc-dec discovery. This pass is only run on
19285architectures that have auto inc or auto dec instructions.
19286
d77de738 19287@opindex fdump-rtl-barriers
ddf6fe37 19288@item -fdump-rtl-barriers
d77de738
ML
19289Dump after cleaning up the barrier instructions.
19290
d77de738 19291@opindex fdump-rtl-bbpart
ddf6fe37 19292@item -fdump-rtl-bbpart
d77de738
ML
19293Dump after partitioning hot and cold basic blocks.
19294
d77de738 19295@opindex fdump-rtl-bbro
ddf6fe37 19296@item -fdump-rtl-bbro
d77de738
ML
19297Dump after block reordering.
19298
d77de738
ML
19299@opindex fdump-rtl-btl2
19300@opindex fdump-rtl-btl2
ddf6fe37
AA
19301@item -fdump-rtl-btl1
19302@itemx -fdump-rtl-btl2
d77de738
ML
19303@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
19304after the two branch
19305target load optimization passes.
19306
d77de738 19307@opindex fdump-rtl-bypass
ddf6fe37 19308@item -fdump-rtl-bypass
d77de738
ML
19309Dump after jump bypassing and control flow optimizations.
19310
d77de738 19311@opindex fdump-rtl-combine
ddf6fe37 19312@item -fdump-rtl-combine
d77de738
ML
19313Dump after the RTL instruction combination pass.
19314
d77de738 19315@opindex fdump-rtl-compgotos
ddf6fe37 19316@item -fdump-rtl-compgotos
d77de738
ML
19317Dump after duplicating the computed gotos.
19318
d77de738
ML
19319@opindex fdump-rtl-ce1
19320@opindex fdump-rtl-ce2
19321@opindex fdump-rtl-ce3
ddf6fe37
AA
19322@item -fdump-rtl-ce1
19323@itemx -fdump-rtl-ce2
19324@itemx -fdump-rtl-ce3
d77de738
ML
19325@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
19326@option{-fdump-rtl-ce3} enable dumping after the three
19327if conversion passes.
19328
d77de738 19329@opindex fdump-rtl-cprop_hardreg
ddf6fe37 19330@item -fdump-rtl-cprop_hardreg
d77de738
ML
19331Dump after hard register copy propagation.
19332
d77de738 19333@opindex fdump-rtl-csa
ddf6fe37 19334@item -fdump-rtl-csa
d77de738
ML
19335Dump after combining stack adjustments.
19336
d77de738
ML
19337@opindex fdump-rtl-cse1
19338@opindex fdump-rtl-cse2
ddf6fe37
AA
19339@item -fdump-rtl-cse1
19340@itemx -fdump-rtl-cse2
d77de738
ML
19341@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
19342the two common subexpression elimination passes.
19343
d77de738 19344@opindex fdump-rtl-dce
ddf6fe37 19345@item -fdump-rtl-dce
d77de738
ML
19346Dump after the standalone dead code elimination passes.
19347
d77de738 19348@opindex fdump-rtl-dbr
ddf6fe37 19349@item -fdump-rtl-dbr
d77de738
ML
19350Dump after delayed branch scheduling.
19351
d77de738
ML
19352@opindex fdump-rtl-dce1
19353@opindex fdump-rtl-dce2
ddf6fe37
AA
19354@item -fdump-rtl-dce1
19355@itemx -fdump-rtl-dce2
d77de738
ML
19356@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19357the two dead store elimination passes.
19358
d77de738 19359@opindex fdump-rtl-eh
ddf6fe37 19360@item -fdump-rtl-eh
d77de738
ML
19361Dump after finalization of EH handling code.
19362
d77de738 19363@opindex fdump-rtl-eh_ranges
ddf6fe37 19364@item -fdump-rtl-eh_ranges
d77de738
ML
19365Dump after conversion of EH handling range regions.
19366
d77de738 19367@opindex fdump-rtl-expand
ddf6fe37 19368@item -fdump-rtl-expand
d77de738
ML
19369Dump after RTL generation.
19370
d77de738
ML
19371@opindex fdump-rtl-fwprop1
19372@opindex fdump-rtl-fwprop2
ddf6fe37
AA
19373@item -fdump-rtl-fwprop1
19374@itemx -fdump-rtl-fwprop2
d77de738
ML
19375@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19376dumping after the two forward propagation passes.
19377
d77de738
ML
19378@opindex fdump-rtl-gcse1
19379@opindex fdump-rtl-gcse2
ddf6fe37
AA
19380@item -fdump-rtl-gcse1
19381@itemx -fdump-rtl-gcse2
d77de738
ML
19382@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19383after global common subexpression elimination.
19384
d77de738 19385@opindex fdump-rtl-init-regs
ddf6fe37 19386@item -fdump-rtl-init-regs
d77de738
ML
19387Dump after the initialization of the registers.
19388
d77de738 19389@opindex fdump-rtl-initvals
ddf6fe37 19390@item -fdump-rtl-initvals
d77de738
ML
19391Dump after the computation of the initial value sets.
19392
d77de738 19393@opindex fdump-rtl-into_cfglayout
ddf6fe37 19394@item -fdump-rtl-into_cfglayout
d77de738
ML
19395Dump after converting to cfglayout mode.
19396
d77de738 19397@opindex fdump-rtl-ira
ddf6fe37 19398@item -fdump-rtl-ira
d77de738
ML
19399Dump after iterated register allocation.
19400
d77de738 19401@opindex fdump-rtl-jump
ddf6fe37 19402@item -fdump-rtl-jump
d77de738
ML
19403Dump after the second jump optimization.
19404
d77de738 19405@opindex fdump-rtl-loop2
ddf6fe37 19406@item -fdump-rtl-loop2
d77de738
ML
19407@option{-fdump-rtl-loop2} enables dumping after the rtl
19408loop optimization passes.
19409
d77de738 19410@opindex fdump-rtl-mach
ddf6fe37 19411@item -fdump-rtl-mach
d77de738
ML
19412Dump after performing the machine dependent reorganization pass, if that
19413pass exists.
19414
d77de738 19415@opindex fdump-rtl-mode_sw
ddf6fe37 19416@item -fdump-rtl-mode_sw
d77de738
ML
19417Dump after removing redundant mode switches.
19418
d77de738 19419@opindex fdump-rtl-rnreg
ddf6fe37 19420@item -fdump-rtl-rnreg
d77de738
ML
19421Dump after register renumbering.
19422
d77de738 19423@opindex fdump-rtl-outof_cfglayout
ddf6fe37 19424@item -fdump-rtl-outof_cfglayout
d77de738
ML
19425Dump after converting from cfglayout mode.
19426
d77de738 19427@opindex fdump-rtl-peephole2
ddf6fe37 19428@item -fdump-rtl-peephole2
d77de738
ML
19429Dump after the peephole pass.
19430
d77de738 19431@opindex fdump-rtl-postreload
ddf6fe37 19432@item -fdump-rtl-postreload
d77de738
ML
19433Dump after post-reload optimizations.
19434
d77de738 19435@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19436@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19437Dump after generating the function prologues and epilogues.
19438
d77de738
ML
19439@opindex fdump-rtl-sched1
19440@opindex fdump-rtl-sched2
ddf6fe37
AA
19441@item -fdump-rtl-sched1
19442@itemx -fdump-rtl-sched2
d77de738
ML
19443@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19444after the basic block scheduling passes.
19445
d77de738 19446@opindex fdump-rtl-ree
ddf6fe37 19447@item -fdump-rtl-ree
d77de738
ML
19448Dump after sign/zero extension elimination.
19449
d77de738 19450@opindex fdump-rtl-seqabstr
ddf6fe37 19451@item -fdump-rtl-seqabstr
d77de738
ML
19452Dump after common sequence discovery.
19453
d77de738 19454@opindex fdump-rtl-shorten
ddf6fe37 19455@item -fdump-rtl-shorten
d77de738
ML
19456Dump after shortening branches.
19457
d77de738 19458@opindex fdump-rtl-sibling
ddf6fe37 19459@item -fdump-rtl-sibling
d77de738
ML
19460Dump after sibling call optimizations.
19461
d77de738
ML
19462@opindex fdump-rtl-split1
19463@opindex fdump-rtl-split2
19464@opindex fdump-rtl-split3
19465@opindex fdump-rtl-split4
19466@opindex fdump-rtl-split5
ddf6fe37
AA
19467@item -fdump-rtl-split1
19468@itemx -fdump-rtl-split2
19469@itemx -fdump-rtl-split3
19470@itemx -fdump-rtl-split4
19471@itemx -fdump-rtl-split5
d77de738
ML
19472These options enable dumping after five rounds of
19473instruction splitting.
19474
d77de738 19475@opindex fdump-rtl-sms
ddf6fe37 19476@item -fdump-rtl-sms
d77de738
ML
19477Dump after modulo scheduling. This pass is only run on some
19478architectures.
19479
d77de738 19480@opindex fdump-rtl-stack
ddf6fe37 19481@item -fdump-rtl-stack
d77de738
ML
19482Dump after conversion from GCC's ``flat register file'' registers to the
19483x87's stack-like registers. This pass is only run on x86 variants.
19484
d77de738
ML
19485@opindex fdump-rtl-subreg1
19486@opindex fdump-rtl-subreg2
ddf6fe37
AA
19487@item -fdump-rtl-subreg1
19488@itemx -fdump-rtl-subreg2
d77de738
ML
19489@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19490the two subreg expansion passes.
19491
d77de738 19492@opindex fdump-rtl-unshare
ddf6fe37 19493@item -fdump-rtl-unshare
d77de738
ML
19494Dump after all rtl has been unshared.
19495
d77de738 19496@opindex fdump-rtl-vartrack
ddf6fe37 19497@item -fdump-rtl-vartrack
d77de738
ML
19498Dump after variable tracking.
19499
d77de738 19500@opindex fdump-rtl-vregs
ddf6fe37 19501@item -fdump-rtl-vregs
d77de738
ML
19502Dump after converting virtual registers to hard registers.
19503
d77de738 19504@opindex fdump-rtl-web
ddf6fe37 19505@item -fdump-rtl-web
d77de738
ML
19506Dump after live range splitting.
19507
d77de738
ML
19508@opindex fdump-rtl-regclass
19509@opindex fdump-rtl-subregs_of_mode_init
19510@opindex fdump-rtl-subregs_of_mode_finish
19511@opindex fdump-rtl-dfinit
19512@opindex fdump-rtl-dfinish
ddf6fe37
AA
19513@item -fdump-rtl-regclass
19514@itemx -fdump-rtl-subregs_of_mode_init
19515@itemx -fdump-rtl-subregs_of_mode_finish
19516@itemx -fdump-rtl-dfinit
19517@itemx -fdump-rtl-dfinish
d77de738
ML
19518These dumps are defined but always produce empty files.
19519
d77de738
ML
19520@opindex da
19521@opindex fdump-rtl-all
ddf6fe37
AA
19522@item -da
19523@itemx -fdump-rtl-all
d77de738
ML
19524Produce all the dumps listed above.
19525
d77de738 19526@opindex dA
ddf6fe37 19527@item -dA
d77de738
ML
19528Annotate the assembler output with miscellaneous debugging information.
19529
d77de738 19530@opindex dD
ddf6fe37 19531@item -dD
d77de738
ML
19532Dump all macro definitions, at the end of preprocessing, in addition to
19533normal output.
19534
d77de738 19535@opindex dH
ddf6fe37 19536@item -dH
d77de738
ML
19537Produce a core dump whenever an error occurs.
19538
d77de738 19539@opindex dp
ddf6fe37 19540@item -dp
d77de738
ML
19541Annotate the assembler output with a comment indicating which
19542pattern and alternative is used. The length and cost of each instruction are
19543also printed.
19544
d77de738 19545@opindex dP
ddf6fe37 19546@item -dP
d77de738
ML
19547Dump the RTL in the assembler output as a comment before each instruction.
19548Also turns on @option{-dp} annotation.
19549
d77de738 19550@opindex dx
ddf6fe37 19551@item -dx
d77de738
ML
19552Just generate RTL for a function instead of compiling it. Usually used
19553with @option{-fdump-rtl-expand}.
19554@end table
19555
d77de738 19556@opindex fdump-debug
ddf6fe37 19557@item -fdump-debug
d77de738
ML
19558Dump debugging information generated during the debug
19559generation phase.
19560
d77de738 19561@opindex fdump-earlydebug
ddf6fe37 19562@item -fdump-earlydebug
d77de738
ML
19563Dump debugging information generated during the early debug
19564generation phase.
19565
d77de738 19566@opindex fdump-noaddr
ddf6fe37 19567@item -fdump-noaddr
d77de738
ML
19568When doing debugging dumps, suppress address output. This makes it more
19569feasible to use diff on debugging dumps for compiler invocations with
19570different compiler binaries and/or different
19571text / bss / data / heap / stack / dso start locations.
19572
d77de738 19573@opindex freport-bug
ddf6fe37 19574@item -freport-bug
d77de738
ML
19575Collect and dump debug information into a temporary file if an
19576internal compiler error (ICE) occurs.
19577
d77de738 19578@opindex fdump-unnumbered
ddf6fe37 19579@item -fdump-unnumbered
d77de738
ML
19580When doing debugging dumps, suppress instruction numbers and address output.
19581This makes it more feasible to use diff on debugging dumps for compiler
19582invocations with different options, in particular with and without
19583@option{-g}.
19584
d77de738 19585@opindex fdump-unnumbered-links
ddf6fe37 19586@item -fdump-unnumbered-links
d77de738
ML
19587When doing debugging dumps (see @option{-d} option above), suppress
19588instruction numbers for the links to the previous and next instructions
19589in a sequence.
19590
ddf6fe37 19591@opindex fdump-ipa
d77de738
ML
19592@item -fdump-ipa-@var{switch}
19593@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19594Control the dumping at various stages of inter-procedural analysis
19595language tree to a file. The file name is generated by appending a
19596switch specific suffix to the source file name, and the file is created
19597in the same directory as the output file. The following dumps are
19598possible:
19599
19600@table @samp
19601@item all
19602Enables all inter-procedural analysis dumps.
19603
19604@item cgraph
19605Dumps information about call-graph optimization, unused function removal,
19606and inlining decisions.
19607
19608@item inline
19609Dump after function inlining.
19610
19611@end table
19612
19613Additionally, the options @option{-optimized}, @option{-missed},
19614@option{-note}, and @option{-all} can be provided, with the same meaning
19615as for @option{-fopt-info}, defaulting to @option{-optimized}.
19616
19617For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19618information on callsites that were inlined, along with callsites
19619that were not inlined.
19620
19621By default, the dump will contain messages about successful
19622optimizations (equivalent to @option{-optimized}) together with
19623low-level details about the analysis.
19624
d77de738 19625@opindex fdump-lang
ddf6fe37 19626@item -fdump-lang
d77de738
ML
19627Dump language-specific information. The file name is made by appending
19628@file{.lang} to the source file name.
19629
ddf6fe37
AA
19630@opindex fdump-lang-all
19631@opindex fdump-lang
d77de738
ML
19632@item -fdump-lang-all
19633@itemx -fdump-lang-@var{switch}
19634@itemx -fdump-lang-@var{switch}-@var{options}
19635@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19636Control the dumping of language-specific information. The @var{options}
19637and @var{filename} portions behave as described in the
19638@option{-fdump-tree} option. The following @var{switch} values are
19639accepted:
19640
19641@table @samp
19642@item all
19643
19644Enable all language-specific dumps.
19645
19646@item class
19647Dump class hierarchy information. Virtual table information is emitted
19648unless '@option{slim}' is specified. This option is applicable to C++ only.
19649
19650@item module
19651Dump module information. Options @option{lineno} (locations),
19652@option{graph} (reachability), @option{blocks} (clusters),
19653@option{uid} (serialization), @option{alias} (mergeable),
19654@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19655(macros) may provide additional information. This option is
19656applicable to C++ only.
19657
19658@item raw
19659Dump the raw internal tree data. This option is applicable to C++ only.
19660
19661@end table
19662
d77de738 19663@opindex fdump-passes
ddf6fe37 19664@item -fdump-passes
d77de738
ML
19665Print on @file{stderr} the list of optimization passes that are turned
19666on and off by the current command-line options.
19667
d77de738 19668@opindex fdump-statistics
ddf6fe37 19669@item -fdump-statistics-@var{option}
d77de738
ML
19670Enable and control dumping of pass statistics in a separate file. The
19671file name is generated by appending a suffix ending in
19672@samp{.statistics} to the source file name, and the file is created in
19673the same directory as the output file. If the @samp{-@var{option}}
19674form is used, @samp{-stats} causes counters to be summed over the
19675whole compilation unit while @samp{-details} dumps every event as
19676the passes generate them. The default with no option is to sum
19677counters for each function compiled.
19678
ddf6fe37
AA
19679@opindex fdump-tree-all
19680@opindex fdump-tree
d77de738
ML
19681@item -fdump-tree-all
19682@itemx -fdump-tree-@var{switch}
19683@itemx -fdump-tree-@var{switch}-@var{options}
19684@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19685Control the dumping at various stages of processing the intermediate
19686language tree to a file. If the @samp{-@var{options}}
19687form is used, @var{options} is a list of @samp{-} separated options
19688which control the details of the dump. Not all options are applicable
19689to all dumps; those that are not meaningful are ignored. The
19690following options are available
19691
19692@table @samp
19693@item address
19694Print the address of each node. Usually this is not meaningful as it
19695changes according to the environment and source file. Its primary use
19696is for tying up a dump file with a debug environment.
19697@item asmname
19698If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19699in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19700use working backward from mangled names in the assembly file.
19701@item slim
19702When dumping front-end intermediate representations, inhibit dumping
19703of members of a scope or body of a function merely because that scope
19704has been reached. Only dump such items when they are directly reachable
19705by some other path.
19706
19707When dumping pretty-printed trees, this option inhibits dumping the
19708bodies of control structures.
19709
19710When dumping RTL, print the RTL in slim (condensed) form instead of
19711the default LISP-like representation.
19712@item raw
19713Print a raw representation of the tree. By default, trees are
19714pretty-printed into a C-like representation.
19715@item details
19716Enable more detailed dumps (not honored by every dump option). Also
19717include information from the optimization passes.
19718@item stats
19719Enable dumping various statistics about the pass (not honored by every dump
19720option).
19721@item blocks
19722Enable showing basic block boundaries (disabled in raw dumps).
19723@item graph
19724For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19725dump a representation of the control flow graph suitable for viewing with
19726GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19727the file is pretty-printed as a subgraph, so that GraphViz can render them
19728all in a single plot.
19729
19730This option currently only works for RTL dumps, and the RTL is always
19731dumped in slim form.
19732@item vops
19733Enable showing virtual operands for every statement.
19734@item lineno
19735Enable showing line numbers for statements.
19736@item uid
19737Enable showing the unique ID (@code{DECL_UID}) for each variable.
19738@item verbose
19739Enable showing the tree dump for each statement.
19740@item eh
19741Enable showing the EH region number holding each statement.
19742@item scev
19743Enable showing scalar evolution analysis details.
19744@item optimized
19745Enable showing optimization information (only available in certain
19746passes).
19747@item missed
19748Enable showing missed optimization information (only available in certain
19749passes).
19750@item note
19751Enable other detailed optimization information (only available in
19752certain passes).
19753@item all
19754Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19755and @option{lineno}.
19756@item optall
19757Turn on all optimization options, i.e., @option{optimized},
19758@option{missed}, and @option{note}.
19759@end table
19760
19761To determine what tree dumps are available or find the dump for a pass
19762of interest follow the steps below.
19763
19764@enumerate
19765@item
19766Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19767look for a code that corresponds to the pass you are interested in.
19768For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19769@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19770The number at the end distinguishes distinct invocations of the same pass.
19771@item
19772To enable the creation of the dump file, append the pass code to
19773the @option{-fdump-} option prefix and invoke GCC with it. For example,
19774to enable the dump from the Early Value Range Propagation pass, invoke
19775GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19776specify the name of the dump file. If you don't specify one, GCC
19777creates as described below.
19778@item
19779Find the pass dump in a file whose name is composed of three components
19780separated by a period: the name of the source file GCC was invoked to
19781compile, a numeric suffix indicating the pass number followed by the
19782letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19783and finally the pass code. For example, the Early VRP pass dump might
19784be in a file named @file{myfile.c.038t.evrp} in the current working
19785directory. Note that the numeric codes are not stable and may change
19786from one version of GCC to another.
19787@end enumerate
19788
ddf6fe37 19789@opindex fopt-info
d77de738
ML
19790@item -fopt-info
19791@itemx -fopt-info-@var{options}
19792@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19793Controls optimization dumps from various optimization passes. If the
19794@samp{-@var{options}} form is used, @var{options} is a list of
19795@samp{-} separated option keywords to select the dump details and
19796optimizations.
19797
19798The @var{options} can be divided into three groups:
19799@enumerate
19800@item
19801options describing what kinds of messages should be emitted,
19802@item
19803options describing the verbosity of the dump, and
19804@item
19805options describing which optimizations should be included.
19806@end enumerate
19807The options from each group can be freely mixed as they are
19808non-overlapping. However, in case of any conflicts,
19809the later options override the earlier options on the command
19810line.
19811
19812The following options control which kinds of messages should be emitted:
19813
19814@table @samp
19815@item optimized
19816Print information when an optimization is successfully applied. It is
19817up to a pass to decide which information is relevant. For example, the
19818vectorizer passes print the source location of loops which are
19819successfully vectorized.
19820@item missed
19821Print information about missed optimizations. Individual passes
19822control which information to include in the output.
19823@item note
19824Print verbose information about optimizations, such as certain
19825transformations, more detailed messages about decisions etc.
19826@item all
19827Print detailed optimization information. This includes
19828@samp{optimized}, @samp{missed}, and @samp{note}.
19829@end table
19830
19831The following option controls the dump verbosity:
19832
19833@table @samp
19834@item internals
19835By default, only ``high-level'' messages are emitted. This option enables
19836additional, more detailed, messages, which are likely to only be of interest
19837to GCC developers.
19838@end table
19839
19840One or more of the following option keywords can be used to describe a
19841group of optimizations:
19842
19843@table @samp
19844@item ipa
19845Enable dumps from all interprocedural optimizations.
19846@item loop
19847Enable dumps from all loop optimizations.
19848@item inline
19849Enable dumps from all inlining optimizations.
19850@item omp
19851Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19852@item vec
19853Enable dumps from all vectorization optimizations.
19854@item optall
19855Enable dumps from all optimizations. This is a superset of
19856the optimization groups listed above.
19857@end table
19858
19859If @var{options} is
19860omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19861about successful optimizations from all the passes, omitting messages
19862that are treated as ``internals''.
19863
19864If the @var{filename} is provided, then the dumps from all the
19865applicable optimizations are concatenated into the @var{filename}.
19866Otherwise the dump is output onto @file{stderr}. Though multiple
19867@option{-fopt-info} options are accepted, only one of them can include
19868a @var{filename}. If other filenames are provided then all but the
19869first such option are ignored.
19870
19871Note that the output @var{filename} is overwritten
19872in case of multiple translation units. If a combined output from
19873multiple translation units is desired, @file{stderr} should be used
19874instead.
19875
19876In the following example, the optimization info is output to
19877@file{stderr}:
19878
19879@smallexample
19880gcc -O3 -fopt-info
19881@end smallexample
19882
19883This example:
19884@smallexample
19885gcc -O3 -fopt-info-missed=missed.all
19886@end smallexample
19887
19888@noindent
19889outputs missed optimization report from all the passes into
19890@file{missed.all}, and this one:
19891
19892@smallexample
19893gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19894@end smallexample
19895
19896@noindent
19897prints information about missed optimization opportunities from
19898vectorization passes on @file{stderr}.
19899Note that @option{-fopt-info-vec-missed} is equivalent to
19900@option{-fopt-info-missed-vec}. The order of the optimization group
19901names and message types listed after @option{-fopt-info} does not matter.
19902
19903As another example,
19904@smallexample
19905gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19906@end smallexample
19907
19908@noindent
19909outputs information about missed optimizations as well as
19910optimized locations from all the inlining passes into
19911@file{inline.txt}.
19912
19913Finally, consider:
19914
19915@smallexample
19916gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19917@end smallexample
19918
19919@noindent
19920Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19921in conflict since only one output file is allowed. In this case, only
19922the first option takes effect and the subsequent options are
19923ignored. Thus only @file{vec.miss} is produced which contains
19924dumps from the vectorizer about missed opportunities.
19925
d77de738 19926@opindex fsave-optimization-record
ddf6fe37 19927@item -fsave-optimization-record
d77de738
ML
19928Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19929were performed, for those optimizations that support @option{-fopt-info}.
19930
19931This option is experimental and the format of the data within the
19932compressed JSON file is subject to change.
19933
19934It is roughly equivalent to a machine-readable version of
19935@option{-fopt-info-all}, as a collection of messages with source file,
19936line number and column number, with the following additional data for
19937each message:
19938
19939@itemize @bullet
19940
19941@item
19942the execution count of the code being optimized, along with metadata about
19943whether this was from actual profile data, or just an estimate, allowing
19944consumers to prioritize messages by code hotness,
19945
19946@item
19947the function name of the code being optimized, where applicable,
19948
19949@item
19950the ``inlining chain'' for the code being optimized, so that when
19951a function is inlined into several different places (which might
19952themselves be inlined), the reader can distinguish between the copies,
19953
19954@item
19955objects identifying those parts of the message that refer to expressions,
19956statements or symbol-table nodes, which of these categories they are, and,
19957when available, their source code location,
19958
19959@item
19960the GCC pass that emitted the message, and
19961
19962@item
19963the location in GCC's own code from which the message was emitted
19964
19965@end itemize
19966
19967Additionally, some messages are logically nested within other
19968messages, reflecting implementation details of the optimization
19969passes.
19970
d77de738 19971@opindex fsched-verbose
ddf6fe37 19972@item -fsched-verbose=@var{n}
d77de738
ML
19973On targets that use instruction scheduling, this option controls the
19974amount of debugging output the scheduler prints to the dump files.
19975
19976For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19977same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19978For @var{n} greater than one, it also output basic block probabilities,
19979detailed ready list information and unit/insn info. For @var{n} greater
19980than two, it includes RTL at abort point, control-flow and regions info.
19981And for @var{n} over four, @option{-fsched-verbose} also includes
19982dependence info.
19983
19984
19985
d77de738
ML
19986@opindex fdisable-
19987@opindex fenable-
ddf6fe37
AA
19988@item -fenable-@var{kind}-@var{pass}
19989@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
19990
19991This is a set of options that are used to explicitly disable/enable
19992optimization passes. These options are intended for use for debugging GCC.
19993Compiler users should use regular options for enabling/disabling
19994passes instead.
19995
19996@table @gcctabopt
19997
19998@item -fdisable-ipa-@var{pass}
19999Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20000statically invoked in the compiler multiple times, the pass name should be
20001appended with a sequential number starting from 1.
20002
20003@item -fdisable-rtl-@var{pass}
20004@itemx -fdisable-rtl-@var{pass}=@var{range-list}
20005Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
20006statically invoked in the compiler multiple times, the pass name should be
20007appended with a sequential number starting from 1. @var{range-list} is a
20008comma-separated list of function ranges or assembler names. Each range is a number
20009pair separated by a colon. The range is inclusive in both ends. If the range
20010is trivial, the number pair can be simplified as a single number. If the
20011function's call graph node's @var{uid} falls within one of the specified ranges,
20012the @var{pass} is disabled for that function. The @var{uid} is shown in the
20013function header of a dump file, and the pass names can be dumped by using
20014option @option{-fdump-passes}.
20015
20016@item -fdisable-tree-@var{pass}
20017@itemx -fdisable-tree-@var{pass}=@var{range-list}
20018Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
20019option arguments.
20020
20021@item -fenable-ipa-@var{pass}
20022Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20023statically invoked in the compiler multiple times, the pass name should be
20024appended with a sequential number starting from 1.
20025
20026@item -fenable-rtl-@var{pass}
20027@itemx -fenable-rtl-@var{pass}=@var{range-list}
20028Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
20029description and examples.
20030
20031@item -fenable-tree-@var{pass}
20032@itemx -fenable-tree-@var{pass}=@var{range-list}
20033Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
20034of option arguments.
20035
20036@end table
20037
20038Here are some examples showing uses of these options.
20039
20040@smallexample
20041
20042# disable ccp1 for all functions
20043 -fdisable-tree-ccp1
20044# disable complete unroll for function whose cgraph node uid is 1
20045 -fenable-tree-cunroll=1
20046# disable gcse2 for functions at the following ranges [1,1],
20047# [300,400], and [400,1000]
20048# disable gcse2 for functions foo and foo2
20049 -fdisable-rtl-gcse2=foo,foo2
20050# disable early inlining
20051 -fdisable-tree-einline
20052# disable ipa inlining
20053 -fdisable-ipa-inline
20054# enable tree full unroll
20055 -fenable-tree-unroll
20056
20057@end smallexample
20058
d77de738
ML
20059@opindex fchecking
20060@opindex fno-checking
ddf6fe37
AA
20061@item -fchecking
20062@itemx -fchecking=@var{n}
d77de738
ML
20063Enable internal consistency checking. The default depends on
20064the compiler configuration. @option{-fchecking=2} enables further
20065internal consistency checking that might affect code generation.
20066
d77de738 20067@opindex frandom-seed
ddf6fe37 20068@item -frandom-seed=@var{string}
d77de738
ML
20069This option provides a seed that GCC uses in place of
20070random numbers in generating certain symbol names
20071that have to be different in every compiled file. It is also used to
20072place unique stamps in coverage data files and the object files that
20073produce them. You can use the @option{-frandom-seed} option to produce
20074reproducibly identical object files.
20075
20076The @var{string} can either be a number (decimal, octal or hex) or an
20077arbitrary string (in which case it's converted to a number by
20078computing CRC32).
20079
20080The @var{string} should be different for every file you compile.
20081
d77de738 20082@opindex save-temps
ddf6fe37 20083@item -save-temps
d77de738
ML
20084Store the usual ``temporary'' intermediate files permanently; name them
20085as auxiliary output files, as specified described under
20086@option{-dumpbase} and @option{-dumpdir}.
20087
20088When used in combination with the @option{-x} command-line option,
20089@option{-save-temps} is sensible enough to avoid overwriting an
20090input source file with the same extension as an intermediate file.
20091The corresponding intermediate file may be obtained by renaming the
20092source file before using @option{-save-temps}.
20093
d77de738 20094@opindex save-temps=cwd
ddf6fe37 20095@item -save-temps=cwd
d77de738
ML
20096Equivalent to @option{-save-temps -dumpdir ./}.
20097
d77de738 20098@opindex save-temps=obj
ddf6fe37 20099@item -save-temps=obj
d77de738
ML
20100Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
20101@file{outdir/} is the directory of the output file specified after the
20102@option{-o} option, including any directory separators. If the
20103@option{-o} option is not used, the @option{-save-temps=obj} switch
20104behaves like @option{-save-temps=cwd}.
20105
d77de738 20106@opindex time
ddf6fe37 20107@item -time@r{[}=@var{file}@r{]}
d77de738
ML
20108Report the CPU time taken by each subprocess in the compilation
20109sequence. For C source files, this is the compiler proper and assembler
20110(plus the linker if linking is done).
20111
20112Without the specification of an output file, the output looks like this:
20113
20114@smallexample
20115# cc1 0.12 0.01
20116# as 0.00 0.01
20117@end smallexample
20118
20119The first number on each line is the ``user time'', that is time spent
20120executing the program itself. The second number is ``system time'',
20121time spent executing operating system routines on behalf of the program.
20122Both numbers are in seconds.
20123
20124With the specification of an output file, the output is appended to the
20125named file, and it looks like this:
20126
20127@smallexample
201280.12 0.01 cc1 @var{options}
201290.00 0.01 as @var{options}
20130@end smallexample
20131
20132The ``user time'' and the ``system time'' are moved before the program
20133name, and the options passed to the program are displayed, so that one
20134can later tell what file was being compiled, and with which options.
20135
d77de738 20136@opindex fdump-final-insns
ddf6fe37 20137@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
20138Dump the final internal representation (RTL) to @var{file}. If the
20139optional argument is omitted (or if @var{file} is @code{.}), the name
20140of the dump file is determined by appending @code{.gkd} to the
20141dump base name, see @option{-dumpbase}.
20142
d77de738
ML
20143@opindex fcompare-debug
20144@opindex fno-compare-debug
ddf6fe37 20145@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
20146If no error occurs during compilation, run the compiler a second time,
20147adding @var{opts} and @option{-fcompare-debug-second} to the arguments
20148passed to the second compilation. Dump the final internal
20149representation in both compilations, and print an error if they differ.
20150
20151If the equal sign is omitted, the default @option{-gtoggle} is used.
20152
20153The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
20154and nonzero, implicitly enables @option{-fcompare-debug}. If
20155@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
20156then it is used for @var{opts}, otherwise the default @option{-gtoggle}
20157is used.
20158
20159@option{-fcompare-debug=}, with the equal sign but without @var{opts},
20160is equivalent to @option{-fno-compare-debug}, which disables the dumping
20161of the final representation and the second compilation, preventing even
20162@env{GCC_COMPARE_DEBUG} from taking effect.
20163
20164To verify full coverage during @option{-fcompare-debug} testing, set
20165@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
20166which GCC rejects as an invalid option in any actual compilation
20167(rather than preprocessing, assembly or linking). To get just a
20168warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
20169not overridden} will do.
20170
d77de738 20171@opindex fcompare-debug-second
ddf6fe37 20172@item -fcompare-debug-second
d77de738
ML
20173This option is implicitly passed to the compiler for the second
20174compilation requested by @option{-fcompare-debug}, along with options to
20175silence warnings, and omitting other options that would cause the compiler
20176to produce output to files or to standard output as a side effect. Dump
20177files and preserved temporary files are renamed so as to contain the
20178@code{.gk} additional extension during the second compilation, to avoid
20179overwriting those generated by the first.
20180
20181When this option is passed to the compiler driver, it causes the
20182@emph{first} compilation to be skipped, which makes it useful for little
20183other than debugging the compiler proper.
20184
d77de738 20185@opindex gtoggle
ddf6fe37 20186@item -gtoggle
d77de738
ML
20187Turn off generation of debug info, if leaving out this option
20188generates it, or turn it on at level 2 otherwise. The position of this
20189argument in the command line does not matter; it takes effect after all
20190other options are processed, and it does so only once, no matter how
20191many times it is given. This is mainly intended to be used with
20192@option{-fcompare-debug}.
20193
d77de738
ML
20194@opindex fvar-tracking-assignments-toggle
20195@opindex fno-var-tracking-assignments-toggle
ddf6fe37 20196@item -fvar-tracking-assignments-toggle
d77de738
ML
20197Toggle @option{-fvar-tracking-assignments}, in the same way that
20198@option{-gtoggle} toggles @option{-g}.
20199
d77de738 20200@opindex Q
ddf6fe37 20201@item -Q
d77de738
ML
20202Makes the compiler print out each function name as it is compiled, and
20203print some statistics about each pass when it finishes.
20204
d77de738 20205@opindex ftime-report
ddf6fe37 20206@item -ftime-report
75d62394
DM
20207Makes the compiler print some statistics to stderr about the time consumed
20208by each pass when it finishes.
20209
20210If SARIF output of diagnostics was requested via
20211@option{-fdiagnostics-format=sarif-file} or
20212@option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
20213information is instead emitted in JSON form as part of SARIF output. The
20214precise format of this JSON data is subject to change, and the values may
20215not exactly match those emitted to stderr due to being written out at a
20216slightly different place within the compiler.
d77de738 20217
d77de738 20218@opindex ftime-report-details
ddf6fe37 20219@item -ftime-report-details
d77de738
ML
20220Record the time consumed by infrastructure parts separately for each pass.
20221
d77de738 20222@opindex fira-verbose
ddf6fe37 20223@item -fira-verbose=@var{n}
d77de738
ML
20224Control the verbosity of the dump file for the integrated register allocator.
20225The default value is 5. If the value @var{n} is greater or equal to 10,
20226the dump output is sent to stderr using the same format as @var{n} minus 10.
20227
d77de738 20228@opindex flto-report
ddf6fe37 20229@item -flto-report
d77de738
ML
20230Prints a report with internal details on the workings of the link-time
20231optimizer. The contents of this report vary from version to version.
20232It is meant to be useful to GCC developers when processing object
20233files in LTO mode (via @option{-flto}).
20234
20235Disabled by default.
20236
d77de738 20237@opindex flto-report-wpa
ddf6fe37 20238@item -flto-report-wpa
d77de738
ML
20239Like @option{-flto-report}, but only print for the WPA phase of link-time
20240optimization.
20241
d77de738 20242@opindex fmem-report
ddf6fe37 20243@item -fmem-report
d77de738
ML
20244Makes the compiler print some statistics about permanent memory
20245allocation when it finishes.
20246
d77de738 20247@opindex fmem-report-wpa
ddf6fe37 20248@item -fmem-report-wpa
d77de738
ML
20249Makes the compiler print some statistics about permanent memory
20250allocation for the WPA phase only.
20251
d77de738 20252@opindex fpre-ipa-mem-report
d77de738 20253@opindex fpost-ipa-mem-report
ddf6fe37
AA
20254@item -fpre-ipa-mem-report
20255@item -fpost-ipa-mem-report
d77de738
ML
20256Makes the compiler print some statistics about permanent memory
20257allocation before or after interprocedural optimization.
20258
d77de738 20259@opindex fmultiflags
ddf6fe37 20260@item -fmultiflags
d77de738
ML
20261This option enables multilib-aware @code{TFLAGS} to be used to build
20262target libraries with options different from those the compiler is
20263configured to use by default, through the use of specs (@xref{Spec
20264Files}) set up by compiler internals, by the target, or by builders at
20265configure time.
20266
20267Like @code{TFLAGS}, this allows the target libraries to be built for
20268portable baseline environments, while the compiler defaults to more
20269demanding ones. That's useful because users can easily override the
20270defaults the compiler is configured to use to build their own programs,
20271if the defaults are not ideal for their target environment, whereas
20272rebuilding the runtime libraries is usually not as easy or desirable.
20273
20274Unlike @code{TFLAGS}, the use of specs enables different flags to be
20275selected for different multilibs. The way to accomplish that is to
20276build with @samp{make TFLAGS=-fmultiflags}, after configuring
20277@samp{--with-specs=%@{fmultiflags:...@}}.
20278
20279This option is discarded by the driver once it's done processing driver
20280self spec.
20281
20282It is also useful to check that @code{TFLAGS} are being used to build
20283all target libraries, by configuring a non-bootstrap compiler
20284@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
20285the compiler and target libraries.
20286
d77de738 20287@opindex fprofile-report
ddf6fe37 20288@item -fprofile-report
d77de738
ML
20289Makes the compiler print some statistics about consistency of the
20290(estimated) profile and effect of individual passes.
20291
d77de738 20292@opindex fstack-usage
ddf6fe37 20293@item -fstack-usage
d77de738
ML
20294Makes the compiler output stack usage information for the program, on a
20295per-function basis. The filename for the dump is made by appending
20296@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
20297the output file, if explicitly specified and it is not an executable,
20298otherwise it is the basename of the source file. An entry is made up
20299of three fields:
20300
20301@itemize
20302@item
20303The name of the function.
20304@item
20305A number of bytes.
20306@item
20307One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
20308@end itemize
20309
20310The qualifier @code{static} means that the function manipulates the stack
20311statically: a fixed number of bytes are allocated for the frame on function
20312entry and released on function exit; no stack adjustments are otherwise made
20313in the function. The second field is this fixed number of bytes.
20314
20315The qualifier @code{dynamic} means that the function manipulates the stack
20316dynamically: in addition to the static allocation described above, stack
20317adjustments are made in the body of the function, for example to push/pop
20318arguments around function calls. If the qualifier @code{bounded} is also
20319present, the amount of these adjustments is bounded at compile time and
20320the second field is an upper bound of the total amount of stack used by
20321the function. If it is not present, the amount of these adjustments is
20322not bounded at compile time and the second field only represents the
20323bounded part.
20324
d77de738 20325@opindex fstats
ddf6fe37 20326@item -fstats
d77de738
ML
20327Emit statistics about front-end processing at the end of the compilation.
20328This option is supported only by the C++ front end, and
20329the information is generally only useful to the G++ development team.
20330
d77de738 20331@opindex fdbg-cnt-list
ddf6fe37 20332@item -fdbg-cnt-list
d77de738
ML
20333Print the name and the counter upper bound for all debug counters.
20334
20335
d77de738 20336@opindex fdbg-cnt
ddf6fe37 20337@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
20338Set the internal debug counter lower and upper bound. @var{counter-value-list}
20339is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
20340[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
20341the name of the counter and list of closed intervals.
20342The @var{lower_bound} is optional and is zero
20343initialized if not set.
20344For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
20345@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
20346eleventh invocation.
20347For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
20348
d77de738 20349@opindex print-file-name
ddf6fe37 20350@item -print-file-name=@var{library}
d77de738
ML
20351Print the full absolute name of the library file @var{library} that
20352would be used when linking---and don't do anything else. With this
20353option, GCC does not compile or link anything; it just prints the
20354file name.
20355
d77de738 20356@opindex print-multi-directory
ddf6fe37 20357@item -print-multi-directory
d77de738
ML
20358Print the directory name corresponding to the multilib selected by any
20359other switches present in the command line. This directory is supposed
20360to exist in @env{GCC_EXEC_PREFIX}.
20361
d77de738 20362@opindex print-multi-lib
ddf6fe37 20363@item -print-multi-lib
d77de738
ML
20364Print the mapping from multilib directory names to compiler switches
20365that enable them. The directory name is separated from the switches by
20366@samp{;}, and each switch starts with an @samp{@@} instead of the
20367@samp{-}, without spaces between multiple switches. This is supposed to
20368ease shell processing.
20369
d77de738 20370@opindex print-multi-os-directory
ddf6fe37 20371@item -print-multi-os-directory
d77de738
ML
20372Print the path to OS libraries for the selected
20373multilib, relative to some @file{lib} subdirectory. If OS libraries are
20374present in the @file{lib} subdirectory and no multilibs are used, this is
20375usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20376sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20377@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20378subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20379
d77de738 20380@opindex print-multiarch
ddf6fe37 20381@item -print-multiarch
d77de738
ML
20382Print the path to OS libraries for the selected multiarch,
20383relative to some @file{lib} subdirectory.
20384
d77de738 20385@opindex print-prog-name
ddf6fe37 20386@item -print-prog-name=@var{program}
d77de738
ML
20387Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20388
d77de738 20389@opindex print-libgcc-file-name
ddf6fe37 20390@item -print-libgcc-file-name
d77de738
ML
20391Same as @option{-print-file-name=libgcc.a}.
20392
20393This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20394but you do want to link with @file{libgcc.a}. You can do:
20395
20396@smallexample
20397gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20398@end smallexample
20399
d77de738 20400@opindex print-search-dirs
ddf6fe37 20401@item -print-search-dirs
d77de738
ML
20402Print the name of the configured installation directory and a list of
20403program and library directories @command{gcc} searches---and don't do anything else.
20404
20405This is useful when @command{gcc} prints the error message
20406@samp{installation problem, cannot exec cpp0: No such file or directory}.
20407To resolve this you either need to put @file{cpp0} and the other compiler
20408components where @command{gcc} expects to find them, or you can set the environment
20409variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20410Don't forget the trailing @samp{/}.
20411@xref{Environment Variables}.
20412
d77de738 20413@opindex print-sysroot
ddf6fe37 20414@item -print-sysroot
d77de738
ML
20415Print the target sysroot directory that is used during
20416compilation. This is the target sysroot specified either at configure
20417time or using the @option{--sysroot} option, possibly with an extra
20418suffix that depends on compilation options. If no target sysroot is
20419specified, the option prints nothing.
20420
d77de738 20421@opindex print-sysroot-headers-suffix
ddf6fe37 20422@item -print-sysroot-headers-suffix
d77de738
ML
20423Print the suffix added to the target sysroot when searching for
20424headers, or give an error if the compiler is not configured with such
20425a suffix---and don't do anything else.
20426
d77de738 20427@opindex dumpmachine
ddf6fe37 20428@item -dumpmachine
d77de738
ML
20429Print the compiler's target machine (for example,
20430@samp{i686-pc-linux-gnu})---and don't do anything else.
20431
d77de738 20432@opindex dumpversion
ddf6fe37 20433@item -dumpversion
d77de738
ML
20434Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20435anything else. This is the compiler version used in filesystem paths and
20436specs. Depending on how the compiler has been configured it can be just
20437a single number (major version), two numbers separated by a dot (major and
20438minor version) or three numbers separated by dots (major, minor and patchlevel
20439version).
20440
d77de738 20441@opindex dumpfullversion
ddf6fe37 20442@item -dumpfullversion
d77de738
ML
20443Print the full compiler version---and don't do anything else. The output is
20444always three numbers separated by dots, major, minor and patchlevel version.
20445
d77de738 20446@opindex dumpspecs
ddf6fe37 20447@item -dumpspecs
d77de738
ML
20448Print the compiler's built-in specs---and don't do anything else. (This
20449is used when GCC itself is being built.) @xref{Spec Files}.
20450@end table
20451
20452@node Submodel Options
20453@section Machine-Dependent Options
20454@cindex submodel options
20455@cindex specifying hardware config
20456@cindex hardware models and configurations, specifying
20457@cindex target-dependent options
20458@cindex machine-dependent options
20459
20460Each target machine supported by GCC can have its own options---for
20461example, to allow you to compile for a particular processor variant or
20462ABI, or to control optimizations specific to that machine. By
20463convention, the names of machine-specific options start with
20464@samp{-m}.
20465
20466Some configurations of the compiler also support additional target-specific
20467options, usually for compatibility with other compilers on the same
20468platform.
20469
20470@c This list is ordered alphanumerically by subsection name.
20471@c It should be the same order and spelling as these options are listed
20472@c in Machine Dependent Options
20473
20474@menu
20475* AArch64 Options::
20476* Adapteva Epiphany Options::
20477* AMD GCN Options::
20478* ARC Options::
20479* ARM Options::
20480* AVR Options::
20481* Blackfin Options::
20482* C6X Options::
20483* CRIS Options::
20484* C-SKY Options::
20485* Darwin Options::
20486* DEC Alpha Options::
20487* eBPF Options::
20488* FR30 Options::
20489* FT32 Options::
20490* FRV Options::
20491* GNU/Linux Options::
20492* H8/300 Options::
20493* HPPA Options::
20494* IA-64 Options::
20495* LM32 Options::
20496* LoongArch Options::
20497* M32C Options::
20498* M32R/D Options::
20499* M680x0 Options::
20500* MCore Options::
d77de738
ML
20501* MicroBlaze Options::
20502* MIPS Options::
20503* MMIX Options::
20504* MN10300 Options::
20505* Moxie Options::
20506* MSP430 Options::
20507* NDS32 Options::
20508* Nios II Options::
20509* Nvidia PTX Options::
20510* OpenRISC Options::
20511* PDP-11 Options::
d77de738
ML
20512* PowerPC Options::
20513* PRU Options::
20514* RISC-V Options::
20515* RL78 Options::
20516* RS/6000 and PowerPC Options::
20517* RX Options::
20518* S/390 and zSeries Options::
d77de738
ML
20519* SH Options::
20520* Solaris 2 Options::
20521* SPARC Options::
20522* System V Options::
20523* V850 Options::
20524* VAX Options::
20525* Visium Options::
20526* VMS Options::
20527* VxWorks Options::
20528* x86 Options::
20529* x86 Windows Options::
20530* Xstormy16 Options::
20531* Xtensa Options::
20532* zSeries Options::
20533@end menu
20534
20535@node AArch64 Options
20536@subsection AArch64 Options
20537@cindex AArch64 Options
20538
20539These options are defined for AArch64 implementations:
20540
20541@table @gcctabopt
20542
d77de738 20543@opindex mabi
ddf6fe37 20544@item -mabi=@var{name}
d77de738
ML
20545Generate code for the specified data model. Permissible values
20546are @samp{ilp32} for SysV-like data model where int, long int and pointers
20547are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20548but long int and pointers are 64 bits.
20549
20550The default depends on the specific target configuration. Note that
20551the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20552entire program with the same ABI, and link with a compatible set of libraries.
20553
d77de738 20554@opindex mbig-endian
ddf6fe37 20555@item -mbig-endian
d77de738
ML
20556Generate big-endian code. This is the default when GCC is configured for an
20557@samp{aarch64_be-*-*} target.
20558
d77de738 20559@opindex mgeneral-regs-only
ddf6fe37 20560@item -mgeneral-regs-only
d77de738
ML
20561Generate code which uses only the general-purpose registers. This will prevent
20562the compiler from using floating-point and Advanced SIMD registers but will not
20563impose any restrictions on the assembler.
20564
d77de738 20565@opindex mlittle-endian
ddf6fe37 20566@item -mlittle-endian
d77de738
ML
20567Generate little-endian code. This is the default when GCC is configured for an
20568@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20569
d77de738 20570@opindex mcmodel=tiny
ddf6fe37 20571@item -mcmodel=tiny
d77de738
ML
20572Generate code for the tiny code model. The program and its statically defined
20573symbols must be within 1MB of each other. Programs can be statically or
20574dynamically linked.
20575
d77de738 20576@opindex mcmodel=small
ddf6fe37 20577@item -mcmodel=small
d77de738
ML
20578Generate code for the small code model. The program and its statically defined
20579symbols must be within 4GB of each other. Programs can be statically or
20580dynamically linked. This is the default code model.
20581
d77de738 20582@opindex mcmodel=large
ddf6fe37 20583@item -mcmodel=large
d77de738
ML
20584Generate code for the large code model. This makes no assumptions about
20585addresses and sizes of sections. Programs can be statically linked only. The
20586@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20587@option{-fpic} and @option{-fPIC}.
20588
573624ec
KT
20589@item -mtp=@var{name}
20590@opindex mtp
20591Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
20592are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
20593@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
20594@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
20595The default setting is @samp{tpidr_el0}. It is recommended to compile all
20596code intended to interoperate with the same value of this option to avoid
20597accessing a different thread pointer from the wrong exception level.
573624ec 20598
d77de738
ML
20599@opindex mstrict-align
20600@opindex mno-strict-align
ddf6fe37
AA
20601@item -mstrict-align
20602@itemx -mno-strict-align
d77de738
ML
20603Avoid or allow generating memory accesses that may not be aligned on a natural
20604object boundary as described in the architecture specification.
20605
d77de738
ML
20606@opindex momit-leaf-frame-pointer
20607@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20608@item -momit-leaf-frame-pointer
20609@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20610Omit or keep the frame pointer in leaf functions. The former behavior is the
20611default.
20612
d77de738
ML
20613@opindex mstack-protector-guard
20614@opindex mstack-protector-guard-reg
20615@opindex mstack-protector-guard-offset
ddf6fe37
AA
20616@item -mstack-protector-guard=@var{guard}
20617@itemx -mstack-protector-guard-reg=@var{reg}
20618@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20619Generate stack protection code using canary at @var{guard}. Supported
20620locations are @samp{global} for a global canary or @samp{sysreg} for a
20621canary in an appropriate system register.
20622
20623With the latter choice the options
20624@option{-mstack-protector-guard-reg=@var{reg}} and
20625@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20626which system register to use as base register for reading the canary,
20627and from what offset from that base register. There is no default
20628register or offset as this is entirely for use within the Linux
20629kernel.
20630
d77de738 20631@opindex mtls-dialect=desc
ddf6fe37 20632@item -mtls-dialect=desc
d77de738
ML
20633Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20634of TLS variables. This is the default.
20635
d77de738 20636@opindex mtls-dialect=traditional
ddf6fe37 20637@item -mtls-dialect=traditional
d77de738
ML
20638Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20639of TLS variables.
20640
d77de738 20641@opindex mtls-size
ddf6fe37 20642@item -mtls-size=@var{size}
d77de738
ML
20643Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20644This option requires binutils 2.26 or newer.
20645
d77de738
ML
20646@opindex mfix-cortex-a53-835769
20647@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20648@item -mfix-cortex-a53-835769
20649@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20650Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20651This involves inserting a NOP instruction between memory instructions and
2065264-bit integer multiply-accumulate instructions.
20653
d77de738
ML
20654@opindex mfix-cortex-a53-843419
20655@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20656@item -mfix-cortex-a53-843419
20657@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20658Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20659This erratum workaround is made at link time and this will only pass the
20660corresponding flag to the linker.
20661
d77de738
ML
20662@opindex mlow-precision-recip-sqrt
20663@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20664@item -mlow-precision-recip-sqrt
20665@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20666Enable or disable the reciprocal square root approximation.
20667This option only has an effect if @option{-ffast-math} or
20668@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20669precision of reciprocal square root results to about 16 bits for
20670single precision and to 32 bits for double precision.
20671
d77de738
ML
20672@opindex mlow-precision-sqrt
20673@opindex mno-low-precision-sqrt
ddf6fe37
AA
20674@item -mlow-precision-sqrt
20675@itemx -mno-low-precision-sqrt
d77de738
ML
20676Enable or disable the square root approximation.
20677This option only has an effect if @option{-ffast-math} or
20678@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20679precision of square root results to about 16 bits for
20680single precision and to 32 bits for double precision.
20681If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20682
d77de738
ML
20683@opindex mlow-precision-div
20684@opindex mno-low-precision-div
ddf6fe37
AA
20685@item -mlow-precision-div
20686@itemx -mno-low-precision-div
d77de738
ML
20687Enable or disable the division approximation.
20688This option only has an effect if @option{-ffast-math} or
20689@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20690precision of division results to about 16 bits for
20691single precision and to 32 bits for double precision.
20692
20693@item -mtrack-speculation
20694@itemx -mno-track-speculation
20695Enable or disable generation of additional code to track speculative
20696execution through conditional branches. The tracking state can then
20697be used by the compiler when expanding calls to
20698@code{__builtin_speculation_safe_copy} to permit a more efficient code
20699sequence to be generated.
20700
20701@item -moutline-atomics
20702@itemx -mno-outline-atomics
20703Enable or disable calls to out-of-line helpers to implement atomic operations.
20704These helpers will, at runtime, determine if the LSE instructions from
20705ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20706instructions that are present in the base ARMv8.0 ISA.
20707
20708This option is only applicable when compiling for the base ARMv8.0
20709instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20710or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20711used directly. The same applies when using @option{-mcpu=} when the
20712selected cpu supports the @samp{lse} feature.
20713This option is on by default.
20714
d77de738 20715@opindex march
ddf6fe37 20716@item -march=@var{name}
d77de738
ML
20717Specify the name of the target architecture and, optionally, one or
20718more feature modifiers. This option has the form
20719@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20720
20721The table below summarizes the permissible values for @var{arch}
20722and the features that they enable by default:
20723
20724@multitable @columnfractions 0.20 0.20 0.60
20725@headitem @var{arch} value @tab Architecture @tab Includes by default
20726@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20727@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20728@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20729@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20730@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20731@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20732@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20733@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20734@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20735@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20736@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20737@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20738@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20739@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20740@end multitable
20741
20742The value @samp{native} is available on native AArch64 GNU/Linux and
20743causes the compiler to pick the architecture of the host system. This
20744option has no effect if the compiler is unable to recognize the
20745architecture of the host system,
20746
20747The permissible values for @var{feature} are listed in the sub-section
20748on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20749Feature Modifiers}. Where conflicting feature modifiers are
20750specified, the right-most feature is used.
20751
20752GCC uses @var{name} to determine what kind of instructions it can emit
20753when generating assembly code. If @option{-march} is specified
20754without either of @option{-mtune} or @option{-mcpu} also being
20755specified, the code is tuned to perform well across a range of target
20756processors implementing the target architecture.
20757
d77de738 20758@opindex mtune
ddf6fe37 20759@item -mtune=@var{name}
d77de738
ML
20760Specify the name of the target processor for which GCC should tune the
20761performance of the code. Permissible values for this option are:
20762@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20763@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20764@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20765@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20766@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20767@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20768@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20769@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20770@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20771@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20772@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20773@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20774@samp{octeontx2f95mm},
20775@samp{a64fx},
20776@samp{thunderx}, @samp{thunderxt88},
20777@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20778@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20779@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20780@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20781@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20782@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
3bfde22c
SJ
20783@samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520},
20784@samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1},
20785@samp{ampere1a}, and @samp{native}.
d77de738
ML
20786
20787The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20788@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20789@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20790should tune for a big.LITTLE system.
20791
20792The value @samp{neoverse-512tvb} specifies that GCC should tune
20793for Neoverse cores that (a) implement SVE and (b) have a total vector
20794bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20795tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20796instructions a cycle and that can execute an equivalent number of SVE
20797arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20798This is more general than tuning for a specific core like Neoverse V1
20799but is more specific than the default tuning described below.
20800
20801Additionally on native AArch64 GNU/Linux systems the value
20802@samp{native} tunes performance to the host system. This option has no effect
20803if the compiler is unable to recognize the processor of the host system.
20804
20805Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20806are specified, the code is tuned to perform well across a range
20807of target processors.
20808
20809This option cannot be suffixed by feature modifiers.
20810
d77de738 20811@opindex mcpu
ddf6fe37 20812@item -mcpu=@var{name}
d77de738
ML
20813Specify the name of the target processor, optionally suffixed by one
20814or more feature modifiers. This option has the form
20815@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20816the permissible values for @var{cpu} are the same as those available
20817for @option{-mtune}. The permissible values for @var{feature} are
20818documented in the sub-section on
20819@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20820Feature Modifiers}. Where conflicting feature modifiers are
20821specified, the right-most feature is used.
20822
20823GCC uses @var{name} to determine what kind of instructions it can emit when
20824generating assembly code (as if by @option{-march}) and to determine
20825the target processor for which to tune for performance (as if
20826by @option{-mtune}). Where this option is used in conjunction
20827with @option{-march} or @option{-mtune}, those options take precedence
20828over the appropriate part of this option.
20829
20830@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20831to a specific core, but instead refers to all Neoverse cores that
20832(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20833a cycle. Unless overridden by @option{-march},
20834@option{-mcpu=neoverse-512tvb} generates code that can run on a
20835Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20836these properties. Unless overridden by @option{-mtune},
20837@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20838@option{-mtune=neoverse-512tvb}.
20839
d77de738 20840@opindex moverride
ddf6fe37 20841@item -moverride=@var{string}
d77de738
ML
20842Override tuning decisions made by the back-end in response to a
20843@option{-mtune=} switch. The syntax, semantics, and accepted values
20844for @var{string} in this option are not guaranteed to be consistent
20845across releases.
20846
20847This option is only intended to be useful when developing GCC.
20848
d77de738 20849@opindex mverbose-cost-dump
ddf6fe37 20850@item -mverbose-cost-dump
d77de738
ML
20851Enable verbose cost model dumping in the debug dump files. This option is
20852provided for use in debugging the compiler.
20853
d77de738
ML
20854@opindex mpc-relative-literal-loads
20855@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20856@item -mpc-relative-literal-loads
20857@itemx -mno-pc-relative-literal-loads
d77de738
ML
20858Enable or disable PC-relative literal loads. With this option literal pools are
20859accessed using a single instruction and emitted after each function. This
20860limits the maximum size of functions to 1MB. This is enabled by default for
20861@option{-mcmodel=tiny}.
20862
d77de738 20863@opindex msign-return-address
ddf6fe37 20864@item -msign-return-address=@var{scope}
d77de738
ML
20865Select the function scope on which return address signing will be applied.
20866Permissible values are @samp{none}, which disables return address signing,
20867@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20868functions, and @samp{all}, which enables pointer signing for all functions. The
20869default value is @samp{none}. This option has been deprecated by
20870-mbranch-protection.
20871
d77de738 20872@opindex mbranch-protection
ddf6fe37 20873@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20874Select the branch protection features to use.
20875@samp{none} is the default and turns off all types of branch protection.
20876@samp{standard} turns on all types of branch protection features. If a feature
20877has additional tuning options, then @samp{standard} sets it to its standard
20878level.
20879@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20880level: signing functions that save the return address to memory (non-leaf
20881functions will practically always do this) using the a-key. The optional
20882argument @samp{leaf} can be used to extend the signing to include leaf
20883functions. The optional argument @samp{b-key} can be used to sign the functions
20884with the B-key instead of the A-key.
20885@samp{bti} turns on branch target identification mechanism.
20886
d77de738 20887@opindex mharden-sls
ddf6fe37 20888@item -mharden-sls=@var{opts}
d77de738
ML
20889Enable compiler hardening against straight line speculation (SLS).
20890@var{opts} is a comma-separated list of the following options:
20891@table @samp
20892@item retbr
20893@item blr
20894@end table
20895In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20896@samp{-mharden-sls=none} disables all SLS hardening.
20897
d77de738 20898@opindex msve-vector-bits
ddf6fe37 20899@item -msve-vector-bits=@var{bits}
d77de738
ML
20900Specify the number of bits in an SVE vector register. This option only has
20901an effect when SVE is enabled.
20902
20903GCC supports two forms of SVE code generation: ``vector-length
20904agnostic'' output that works with any size of vector register and
20905``vector-length specific'' output that allows GCC to make assumptions
20906about the vector length when it is useful for optimization reasons.
20907The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20908@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20909Specifying @samp{scalable} selects vector-length agnostic
20910output. At present @samp{-msve-vector-bits=128} also generates vector-length
20911agnostic output for big-endian targets. All other values generate
20912vector-length specific code. The behavior of these values may change
20913in future releases and no value except @samp{scalable} should be
20914relied on for producing code that is portable across different
20915hardware SVE vector lengths.
20916
20917The default is @samp{-msve-vector-bits=scalable}, which produces
20918vector-length agnostic code.
20919@end table
20920
20921@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20922@anchor{aarch64-feature-modifiers}
20923@cindex @option{-march} feature modifiers
20924@cindex @option{-mcpu} feature modifiers
20925Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20926the following and their inverses @option{no@var{feature}}:
20927
20928@table @samp
20929@item crc
20930Enable CRC extension. This is on by default for
20931@option{-march=armv8.1-a}.
20932@item crypto
20933Enable Crypto extension. This also enables Advanced SIMD and floating-point
20934instructions.
20935@item fp
20936Enable floating-point instructions. This is on by default for all possible
20937values for options @option{-march} and @option{-mcpu}.
20938@item simd
20939Enable Advanced SIMD instructions. This also enables floating-point
20940instructions. This is on by default for all possible values for options
20941@option{-march} and @option{-mcpu}.
20942@item sve
20943Enable Scalable Vector Extension instructions. This also enables Advanced
20944SIMD and floating-point instructions.
20945@item lse
20946Enable Large System Extension instructions. This is on by default for
20947@option{-march=armv8.1-a}.
20948@item rdma
20949Enable Round Double Multiply Accumulate instructions. This is on by default
20950for @option{-march=armv8.1-a}.
20951@item fp16
20952Enable FP16 extension. This also enables floating-point instructions.
20953@item fp16fml
20954Enable FP16 fmla extension. This also enables FP16 extensions and
20955floating-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.
20956
20957@item rcpc
0431e8ae
AV
20958Enable the RCpc extension. This enables the use of the LDAPR instructions for
20959load-acquire atomic semantics, and passes it on to the assembler, enabling
20960inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20961@item dotprod
20962Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20963@item aes
20964Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20965SIMD instructions.
20966@item sha2
20967Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20968@item sha3
20969Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20970instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20971@item sm4
20972Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20973Use of this option with architectures prior to Armv8.2-A is not supported.
20974@item profile
20975Enable the Statistical Profiling extension. This option is only to enable the
20976extension at the assembler level and does not affect code generation.
20977@item rng
20978Enable the Armv8.5-a Random Number instructions. This option is only to
20979enable the extension at the assembler level and does not affect code
20980generation.
20981@item memtag
20982Enable the Armv8.5-a Memory Tagging Extensions.
20983Use of this option with architectures prior to Armv8.5-A is not supported.
20984@item sb
20985Enable the Armv8-a Speculation Barrier instruction. This option is only to
20986enable the extension at the assembler level and does not affect code
20987generation. This option is enabled by default for @option{-march=armv8.5-a}.
20988@item ssbs
20989Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20990is only to enable the extension at the assembler level and does not affect code
20991generation. This option is enabled by default for @option{-march=armv8.5-a}.
20992@item predres
20993Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20994This option is only to enable the extension at the assembler level and does
20995not affect code generation. This option is enabled by default for
20996@option{-march=armv8.5-a}.
20997@item sve2
20998Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20999instructions.
21000@item sve2-bitperm
21001Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
21002@item sve2-sm4
21003Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
21004@item sve2-aes
21005Enable SVE2 aes instructions. This also enables SVE2 instructions.
21006@item sve2-sha3
21007Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
21008@item tme
21009Enable the Transactional Memory Extension.
21010@item i8mm
21011Enable 8-bit Integer Matrix Multiply instructions. This also enables
21012Advanced SIMD and floating-point instructions. This option is enabled by
21013default for @option{-march=armv8.6-a}. Use of this option with architectures
21014prior to Armv8.2-A is not supported.
21015@item f32mm
21016Enable 32-bit Floating point Matrix Multiply instructions. This also enables
21017SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21018not supported.
21019@item f64mm
21020Enable 64-bit Floating point Matrix Multiply instructions. This also enables
21021SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21022not supported.
21023@item bf16
21024Enable brain half-precision floating-point instructions. This also enables
21025Advanced SIMD and floating-point instructions. This option is enabled by
21026default for @option{-march=armv8.6-a}. Use of this option with architectures
21027prior to Armv8.2-A is not supported.
21028@item ls64
21029Enable the 64-byte atomic load and store instructions for accelerators.
21030This option is enabled by default for @option{-march=armv8.7-a}.
21031@item mops
21032Enable the instructions to accelerate memory operations like @code{memcpy},
21033@code{memmove}, @code{memset}. This option is enabled by default for
21034@option{-march=armv8.8-a}
21035@item flagm
21036Enable the Flag Manipulation instructions Extension.
21037@item pauth
21038Enable the Pointer Authentication Extension.
d758d190
KT
21039@item cssc
21040Enable the Common Short Sequence Compression instructions.
d77de738
ML
21041
21042@end table
21043
21044Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
21045which implies @option{fp}.
21046Conversely, @option{nofp} implies @option{nosimd}, which implies
21047@option{nocrypto}, @option{noaes} and @option{nosha2}.
21048
21049@node Adapteva Epiphany Options
21050@subsection Adapteva Epiphany Options
21051
21052These @samp{-m} options are defined for Adapteva Epiphany:
21053
21054@table @gcctabopt
d77de738 21055@opindex mhalf-reg-file
ddf6fe37 21056@item -mhalf-reg-file
d77de738
ML
21057Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
21058That allows code to run on hardware variants that lack these registers.
21059
d77de738 21060@opindex mprefer-short-insn-regs
ddf6fe37 21061@item -mprefer-short-insn-regs
d77de738
ML
21062Preferentially allocate registers that allow short instruction generation.
21063This can result in increased instruction count, so this may either reduce or
21064increase overall code size.
21065
d77de738 21066@opindex mbranch-cost
ddf6fe37 21067@item -mbranch-cost=@var{num}
d77de738
ML
21068Set the cost of branches to roughly @var{num} ``simple'' instructions.
21069This cost is only a heuristic and is not guaranteed to produce
21070consistent results across releases.
21071
d77de738 21072@opindex mcmove
ddf6fe37 21073@item -mcmove
d77de738
ML
21074Enable the generation of conditional moves.
21075
d77de738 21076@opindex mnops
ddf6fe37 21077@item -mnops=@var{num}
d77de738
ML
21078Emit @var{num} NOPs before every other generated instruction.
21079
d77de738
ML
21080@opindex mno-soft-cmpsf
21081@opindex msoft-cmpsf
ddf6fe37 21082@item -mno-soft-cmpsf
d77de738
ML
21083For single-precision floating-point comparisons, emit an @code{fsub} instruction
21084and test the flags. This is faster than a software comparison, but can
21085get incorrect results in the presence of NaNs, or when two different small
21086numbers are compared such that their difference is calculated as zero.
21087The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
21088software comparisons.
21089
d77de738 21090@opindex mstack-offset
ddf6fe37 21091@item -mstack-offset=@var{num}
d77de738
ML
21092Set the offset between the top of the stack and the stack pointer.
21093E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
21094can be used by leaf functions without stack allocation.
21095Values other than @samp{8} or @samp{16} are untested and unlikely to work.
21096Note also that this option changes the ABI; compiling a program with a
21097different stack offset than the libraries have been compiled with
21098generally does not work.
21099This option can be useful if you want to evaluate if a different stack
21100offset would give you better code, but to actually use a different stack
21101offset to build working programs, it is recommended to configure the
21102toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
21103
d77de738
ML
21104@opindex mno-round-nearest
21105@opindex mround-nearest
ddf6fe37 21106@item -mno-round-nearest
d77de738
ML
21107Make the scheduler assume that the rounding mode has been set to
21108truncating. The default is @option{-mround-nearest}.
21109
d77de738 21110@opindex mlong-calls
ddf6fe37 21111@item -mlong-calls
d77de738
ML
21112If not otherwise specified by an attribute, assume all calls might be beyond
21113the offset range of the @code{b} / @code{bl} instructions, and therefore load the
21114function address into a register before performing a (otherwise direct) call.
21115This is the default.
21116
d77de738 21117@opindex short-calls
ddf6fe37 21118@item -mshort-calls
d77de738
ML
21119If not otherwise specified by an attribute, assume all direct calls are
21120in the range of the @code{b} / @code{bl} instructions, so use these instructions
21121for direct calls. The default is @option{-mlong-calls}.
21122
d77de738 21123@opindex msmall16
ddf6fe37 21124@item -msmall16
d77de738
ML
21125Assume addresses can be loaded as 16-bit unsigned values. This does not
21126apply to function addresses for which @option{-mlong-calls} semantics
21127are in effect.
21128
d77de738 21129@opindex mfp-mode
ddf6fe37 21130@item -mfp-mode=@var{mode}
d77de738
ML
21131Set the prevailing mode of the floating-point unit.
21132This determines the floating-point mode that is provided and expected
21133at function call and return time. Making this mode match the mode you
21134predominantly need at function start can make your programs smaller and
21135faster by avoiding unnecessary mode switches.
21136
21137@var{mode} can be set to one the following values:
21138
21139@table @samp
21140@item caller
21141Any mode at function entry is valid, and retained or restored when
21142the function returns, and when it calls other functions.
21143This mode is useful for compiling libraries or other compilation units
21144you might want to incorporate into different programs with different
21145prevailing FPU modes, and the convenience of being able to use a single
21146object file outweighs the size and speed overhead for any extra
21147mode switching that might be needed, compared with what would be needed
21148with a more specific choice of prevailing FPU mode.
21149
21150@item truncate
21151This is the mode used for floating-point calculations with
21152truncating (i.e.@: round towards zero) rounding mode. That includes
21153conversion from floating point to integer.
21154
21155@item round-nearest
21156This is the mode used for floating-point calculations with
21157round-to-nearest-or-even rounding mode.
21158
21159@item int
21160This is the mode used to perform integer calculations in the FPU, e.g.@:
21161integer multiply, or integer multiply-and-accumulate.
21162@end table
21163
21164The default is @option{-mfp-mode=caller}
21165
d77de738
ML
21166@opindex mno-split-lohi
21167@opindex msplit-lohi
21168@opindex mno-postinc
21169@opindex mpostinc
21170@opindex mno-postmodify
21171@opindex mpostmodify
ddf6fe37
AA
21172@item -mno-split-lohi
21173@itemx -mno-postinc
21174@itemx -mno-postmodify
d77de738
ML
21175Code generation tweaks that disable, respectively, splitting of 32-bit
21176loads, generation of post-increment addresses, and generation of
21177post-modify addresses. The defaults are @option{msplit-lohi},
21178@option{-mpost-inc}, and @option{-mpost-modify}.
21179
d77de738
ML
21180@opindex mno-vect-double
21181@opindex mvect-double
ddf6fe37 21182@item -mnovect-double
d77de738
ML
21183Change the preferred SIMD mode to SImode. The default is
21184@option{-mvect-double}, which uses DImode as preferred SIMD mode.
21185
d77de738 21186@opindex max-vect-align
ddf6fe37 21187@item -max-vect-align=@var{num}
d77de738
ML
21188The maximum alignment for SIMD vector mode types.
21189@var{num} may be 4 or 8. The default is 8.
21190Note that this is an ABI change, even though many library function
21191interfaces are unaffected if they don't use SIMD vector modes
21192in places that affect size and/or alignment of relevant types.
21193
d77de738 21194@opindex msplit-vecmove-early
ddf6fe37 21195@item -msplit-vecmove-early
d77de738
ML
21196Split vector moves into single word moves before reload. In theory this
21197can give better register allocation, but so far the reverse seems to be
21198generally the case.
21199
d77de738 21200@opindex m1reg-
ddf6fe37 21201@item -m1reg-@var{reg}
d77de738
ML
21202Specify a register to hold the constant @minus{}1, which makes loading small negative
21203constants and certain bitmasks faster.
21204Allowable values for @var{reg} are @samp{r43} and @samp{r63},
21205which specify use of that register as a fixed register,
21206and @samp{none}, which means that no register is used for this
21207purpose. The default is @option{-m1reg-none}.
21208
21209@end table
21210
21211@node AMD GCN Options
21212@subsection AMD GCN Options
21213@cindex AMD GCN Options
21214
21215These options are defined specifically for the AMD GCN port.
21216
21217@table @gcctabopt
21218
d77de738 21219@opindex march
d77de738 21220@opindex mtune
ddf6fe37
AA
21221@item -march=@var{gpu}
21222@itemx -mtune=@var{gpu}
d77de738
ML
21223Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
21224are
21225
21226@table @samp
21227@item fiji
56ed1055
AS
21228Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility
21229depends on how GCC has been configured, see @option{--with-arch} and
21230@option{--with-multilib-list}.
d77de738
ML
21231
21232@item gfx900
21233Compile for GCN5 Vega 10 devices (gfx900).
21234
21235@item gfx906
21236Compile for GCN5 Vega 20 devices (gfx906).
21237
21238@item gfx908
21239Compile for CDNA1 Instinct MI100 series devices (gfx908).
21240
21241@item gfx90a
21242Compile for CDNA2 Instinct MI200 series devices (gfx90a).
21243
21244@end table
21245
ddf6fe37 21246@opindex msram-ecc
d77de738
ML
21247@item -msram-ecc=on
21248@itemx -msram-ecc=off
21249@itemx -msram-ecc=any
d77de738
ML
21250Compile binaries suitable for devices with the SRAM-ECC feature enabled,
21251disabled, or either mode. This feature can be enabled per-process on some
21252devices. The compiled code must match the device mode. The default is
21253@samp{any}, for devices that support it.
21254
d77de738 21255@opindex mstack-size
ddf6fe37 21256@item -mstack-size=@var{bytes}
d77de738
ML
21257Specify how many @var{bytes} of stack space will be requested for each GPU
21258thread (wave-front). Beware that there may be many threads and limited memory
21259available. The size of the stack allocation may also have an impact on
21260run-time performance. The default is 32KB when using OpenACC or OpenMP, and
212611MB otherwise.
21262
d77de738 21263@opindex mxnack
366e3d30
TB
21264@item -mxnack=on
21265@itemx -mxnack=off
21266@itemx -mxnack=any
21267Compile binaries suitable for devices with the XNACK feature enabled, disabled,
21268or either mode. Some devices always require XNACK and some allow the user to
21269configure XNACK. The compiled code must match the device mode.
21270@c The default is @samp{-mxnack=any}.
21271At present this option is a placeholder for support that is not yet implemented.
d77de738
ML
21272
21273@end table
21274
21275@node ARC Options
21276@subsection ARC Options
21277@cindex ARC options
21278
21279The following options control the architecture variant for which code
21280is being compiled:
21281
21282@c architecture variants
21283@table @gcctabopt
21284
d77de738 21285@opindex mbarrel-shifter
ddf6fe37 21286@item -mbarrel-shifter
d77de738
ML
21287Generate instructions supported by barrel shifter. This is the default
21288unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
21289
d77de738 21290@opindex mjli-always
ddf6fe37 21291@item -mjli-always
d77de738
ML
21292Force to call a function using jli_s instruction. This option is
21293valid only for ARCv2 architecture.
21294
d77de738 21295@opindex mcpu
ddf6fe37 21296@item -mcpu=@var{cpu}
d77de738
ML
21297Set architecture type, register usage, and instruction scheduling
21298parameters for @var{cpu}. There are also shortcut alias options
21299available for backward compatibility and convenience. Supported
21300values for @var{cpu} are
21301
21302@table @samp
21303@opindex mA6
21304@opindex mARC600
21305@item arc600
21306Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
21307
d77de738 21308@opindex mARC601
ddf6fe37 21309@item arc601
d77de738
ML
21310Compile for ARC601. Alias: @option{-mARC601}.
21311
d77de738
ML
21312@opindex mA7
21313@opindex mARC700
ddf6fe37 21314@item arc700
d77de738
ML
21315Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
21316This is the default when configured with @option{--with-cpu=arc700}@.
21317
21318@item arcem
21319Compile for ARC EM.
21320
21321@item archs
21322Compile for ARC HS.
21323
21324@item em
21325Compile for ARC EM CPU with no hardware extensions.
21326
21327@item em4
21328Compile for ARC EM4 CPU.
21329
21330@item em4_dmips
21331Compile for ARC EM4 DMIPS CPU.
21332
21333@item em4_fpus
21334Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
21335extension.
21336
21337@item em4_fpuda
21338Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
21339double assist instructions.
21340
21341@item hs
21342Compile for ARC HS CPU with no hardware extensions except the atomic
21343instructions.
21344
21345@item hs34
21346Compile for ARC HS34 CPU.
21347
21348@item hs38
21349Compile for ARC HS38 CPU.
21350
21351@item hs38_linux
21352Compile for ARC HS38 CPU with all hardware extensions on.
21353
21354@item hs4x
21355Compile for ARC HS4x CPU.
21356
21357@item hs4xd
21358Compile for ARC HS4xD CPU.
21359
21360@item hs4x_rel31
21361Compile for ARC HS4x CPU release 3.10a.
21362
21363@item arc600_norm
21364Compile for ARC 600 CPU with @code{norm} instructions enabled.
21365
21366@item arc600_mul32x16
21367Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21368instructions enabled.
21369
21370@item arc600_mul64
21371Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21372instructions enabled.
21373
21374@item arc601_norm
21375Compile for ARC 601 CPU with @code{norm} instructions enabled.
21376
21377@item arc601_mul32x16
21378Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21379instructions enabled.
21380
21381@item arc601_mul64
21382Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21383instructions enabled.
21384
21385@item nps400
21386Compile for ARC 700 on NPS400 chip.
21387
21388@item em_mini
21389Compile for ARC EM minimalist configuration featuring reduced register
21390set.
21391
21392@end table
21393
d77de738 21394@opindex mdpfp
d77de738 21395@opindex mdpfp-compact
ddf6fe37
AA
21396@item -mdpfp
21397@itemx -mdpfp-compact
d77de738
ML
21398Generate double-precision FPX instructions, tuned for the compact
21399implementation.
21400
d77de738 21401@opindex mdpfp-fast
ddf6fe37 21402@item -mdpfp-fast
d77de738
ML
21403Generate double-precision FPX instructions, tuned for the fast
21404implementation.
21405
d77de738 21406@opindex mno-dpfp-lrsr
ddf6fe37 21407@item -mno-dpfp-lrsr
d77de738
ML
21408Disable @code{lr} and @code{sr} instructions from using FPX extension
21409aux registers.
21410
d77de738 21411@opindex mea
ddf6fe37 21412@item -mea
d77de738
ML
21413Generate extended arithmetic instructions. Currently only
21414@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21415supported. Only valid for @option{-mcpu=ARC700}.
21416
d77de738
ML
21417@opindex mno-mpy
21418@opindex mmpy
ddf6fe37 21419@item -mno-mpy
d77de738
ML
21420Do not generate @code{mpy}-family instructions for ARC700. This option is
21421deprecated.
21422
d77de738 21423@opindex mmul32x16
ddf6fe37 21424@item -mmul32x16
d77de738
ML
21425Generate 32x16-bit multiply and multiply-accumulate instructions.
21426
d77de738 21427@opindex mmul64
ddf6fe37 21428@item -mmul64
d77de738
ML
21429Generate @code{mul64} and @code{mulu64} instructions.
21430Only valid for @option{-mcpu=ARC600}.
21431
d77de738 21432@opindex mnorm
ddf6fe37 21433@item -mnorm
d77de738
ML
21434Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21435is in effect.
21436
d77de738 21437@opindex mspfp
d77de738 21438@opindex mspfp-compact
ddf6fe37
AA
21439@item -mspfp
21440@itemx -mspfp-compact
d77de738
ML
21441Generate single-precision FPX instructions, tuned for the compact
21442implementation.
21443
d77de738 21444@opindex mspfp-fast
ddf6fe37 21445@item -mspfp-fast
d77de738
ML
21446Generate single-precision FPX instructions, tuned for the fast
21447implementation.
21448
d77de738 21449@opindex msimd
ddf6fe37 21450@item -msimd
d77de738
ML
21451Enable generation of ARC SIMD instructions via target-specific
21452builtins. Only valid for @option{-mcpu=ARC700}.
21453
d77de738 21454@opindex msoft-float
ddf6fe37 21455@item -msoft-float
d77de738
ML
21456This option ignored; it is provided for compatibility purposes only.
21457Software floating-point code is emitted by default, and this default
21458can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
21459@option{-mspfp-fast} for single precision, and @option{-mdpfp},
21460@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
21461
d77de738 21462@opindex mswap
ddf6fe37 21463@item -mswap
d77de738
ML
21464Generate @code{swap} instructions.
21465
d77de738 21466@opindex matomic
ddf6fe37 21467@item -matomic
d77de738
ML
21468This enables use of the locked load/store conditional extension to implement
21469atomic memory built-in functions. Not available for ARC 6xx or ARC
21470EM cores.
21471
d77de738 21472@opindex mdiv-rem
ddf6fe37 21473@item -mdiv-rem
d77de738
ML
21474Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21475
d77de738 21476@opindex mcode-density
ddf6fe37 21477@item -mcode-density
d77de738
ML
21478Enable code density instructions for ARC EM.
21479This option is on by default for ARC HS.
21480
d77de738 21481@opindex mll64
ddf6fe37 21482@item -mll64
d77de738
ML
21483Enable double load/store operations for ARC HS cores.
21484
d77de738 21485@opindex mtp-regno
ddf6fe37 21486@item -mtp-regno=@var{regno}
d77de738
ML
21487Specify thread pointer register number.
21488
d77de738 21489@opindex mmpy-option
ddf6fe37 21490@item -mmpy-option=@var{multo}
d77de738
ML
21491Compile ARCv2 code with a multiplier design option. You can specify
21492the option using either a string or numeric value for @var{multo}.
21493@samp{wlh1} is the default value. The recognized values are:
21494
21495@table @samp
21496@item 0
21497@itemx none
21498No multiplier available.
21499
21500@item 1
21501@itemx w
2150216x16 multiplier, fully pipelined.
21503The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21504
21505@item 2
21506@itemx wlh1
2150732x32 multiplier, fully
21508pipelined (1 stage). The following instructions are additionally
21509enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21510
21511@item 3
21512@itemx wlh2
2151332x32 multiplier, fully pipelined
21514(2 stages). The following instructions are additionally enabled: @code{mpy},
21515@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21516
21517@item 4
21518@itemx wlh3
21519Two 16x16 multipliers, blocking,
21520sequential. The following instructions are additionally enabled: @code{mpy},
21521@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21522
21523@item 5
21524@itemx wlh4
21525One 16x16 multiplier, blocking,
21526sequential. The following instructions are additionally enabled: @code{mpy},
21527@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21528
21529@item 6
21530@itemx wlh5
21531One 32x4 multiplier, blocking,
21532sequential. The following instructions are additionally enabled: @code{mpy},
21533@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21534
21535@item 7
21536@itemx plus_dmpy
21537ARC HS SIMD support.
21538
21539@item 8
21540@itemx plus_macd
21541ARC HS SIMD support.
21542
21543@item 9
21544@itemx plus_qmacw
21545ARC HS SIMD support.
21546
21547@end table
21548
21549This option is only available for ARCv2 cores@.
21550
d77de738 21551@opindex mfpu
ddf6fe37 21552@item -mfpu=@var{fpu}
d77de738
ML
21553Enables support for specific floating-point hardware extensions for ARCv2
21554cores. Supported values for @var{fpu} are:
21555
21556@table @samp
21557
21558@item fpus
21559Enables support for single-precision floating-point hardware
21560extensions@.
21561
21562@item fpud
21563Enables support for double-precision floating-point hardware
21564extensions. The single-precision floating-point extension is also
21565enabled. Not available for ARC EM@.
21566
21567@item fpuda
21568Enables support for double-precision floating-point hardware
21569extensions using double-precision assist instructions. The single-precision
21570floating-point extension is also enabled. This option is
21571only available for ARC EM@.
21572
21573@item fpuda_div
21574Enables support for double-precision floating-point hardware
21575extensions using double-precision assist instructions.
21576The single-precision floating-point, square-root, and divide
21577extensions are also enabled. This option is
21578only available for ARC EM@.
21579
21580@item fpuda_fma
21581Enables support for double-precision floating-point hardware
21582extensions using double-precision assist instructions.
21583The single-precision floating-point and fused multiply and add
21584hardware extensions are also enabled. This option is
21585only available for ARC EM@.
21586
21587@item fpuda_all
21588Enables support for double-precision floating-point hardware
21589extensions using double-precision assist instructions.
21590All single-precision floating-point hardware extensions are also
21591enabled. This option is only available for ARC EM@.
21592
21593@item fpus_div
21594Enables support for single-precision floating-point, square-root and divide
21595hardware extensions@.
21596
21597@item fpud_div
21598Enables support for double-precision floating-point, square-root and divide
21599hardware extensions. This option
21600includes option @samp{fpus_div}. Not available for ARC EM@.
21601
21602@item fpus_fma
21603Enables support for single-precision floating-point and
21604fused multiply and add hardware extensions@.
21605
21606@item fpud_fma
21607Enables support for double-precision floating-point and
21608fused multiply and add hardware extensions. This option
21609includes option @samp{fpus_fma}. Not available for ARC EM@.
21610
21611@item fpus_all
21612Enables support for all single-precision floating-point hardware
21613extensions@.
21614
21615@item fpud_all
21616Enables support for all single- and double-precision floating-point
21617hardware extensions. Not available for ARC EM@.
21618
21619@end table
21620
d77de738 21621@opindex mirq-ctrl-saved
ddf6fe37 21622@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21623Specifies general-purposes registers that the processor automatically
21624saves/restores on interrupt entry and exit. @var{register-range} is
21625specified as two registers separated by a dash. The register range
21626always starts with @code{r0}, the upper limit is @code{fp} register.
21627@var{blink} and @var{lp_count} are optional. This option is only
21628valid for ARC EM and ARC HS cores.
21629
d77de738 21630@opindex mrgf-banked-regs
ddf6fe37 21631@item -mrgf-banked-regs=@var{number}
d77de738
ML
21632Specifies the number of registers replicated in second register bank
21633on entry to fast interrupt. Fast interrupts are interrupts with the
21634highest priority level P0. These interrupts save only PC and STATUS32
21635registers to avoid memory transactions during interrupt entry and exit
21636sequences. Use this option when you are using fast interrupts in an
21637ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21638
d77de738 21639@opindex mlpc-width
ddf6fe37 21640@item -mlpc-width=@var{width}
d77de738
ML
21641Specify the width of the @code{lp_count} register. Valid values for
21642@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21643fixed to 32 bits. If the width is less than 32, the compiler does not
21644attempt to transform loops in your program to use the zero-delay loop
21645mechanism unless it is known that the @code{lp_count} register can
21646hold the required loop-counter value. Depending on the width
21647specified, the compiler and run-time library might continue to use the
21648loop mechanism for various needs. This option defines macro
21649@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21650
d77de738 21651@opindex mrf16
ddf6fe37 21652@item -mrf16
d77de738
ML
21653This option instructs the compiler to generate code for a 16-entry
21654register file. This option defines the @code{__ARC_RF16__}
21655preprocessor macro.
21656
d77de738 21657@opindex mbranch-index
ddf6fe37 21658@item -mbranch-index
d77de738
ML
21659Enable use of @code{bi} or @code{bih} instructions to implement jump
21660tables.
21661
21662@end table
21663
21664The following options are passed through to the assembler, and also
21665define preprocessor macro symbols.
21666
21667@c Flags used by the assembler, but for which we define preprocessor
21668@c macro symbols as well.
21669@table @gcctabopt
d77de738 21670@opindex mdsp-packa
ddf6fe37 21671@item -mdsp-packa
d77de738
ML
21672Passed down to the assembler to enable the DSP Pack A extensions.
21673Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21674deprecated.
21675
d77de738 21676@opindex mdvbf
ddf6fe37 21677@item -mdvbf
d77de738
ML
21678Passed down to the assembler to enable the dual Viterbi butterfly
21679extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21680option is deprecated.
21681
21682@c ARC700 4.10 extension instruction
d77de738 21683@opindex mlock
ddf6fe37 21684@item -mlock
d77de738
ML
21685Passed down to the assembler to enable the locked load/store
21686conditional extension. Also sets the preprocessor symbol
21687@code{__Xlock}.
21688
d77de738 21689@opindex mmac-d16
ddf6fe37 21690@item -mmac-d16
d77de738
ML
21691Passed down to the assembler. Also sets the preprocessor symbol
21692@code{__Xxmac_d16}. This option is deprecated.
21693
d77de738 21694@opindex mmac-24
ddf6fe37 21695@item -mmac-24
d77de738
ML
21696Passed down to the assembler. Also sets the preprocessor symbol
21697@code{__Xxmac_24}. This option is deprecated.
21698
21699@c ARC700 4.10 extension instruction
d77de738 21700@opindex mrtsc
ddf6fe37 21701@item -mrtsc
d77de738
ML
21702Passed down to the assembler to enable the 64-bit time-stamp counter
21703extension instruction. Also sets the preprocessor symbol
21704@code{__Xrtsc}. This option is deprecated.
21705
21706@c ARC700 4.10 extension instruction
d77de738 21707@opindex mswape
ddf6fe37 21708@item -mswape
d77de738
ML
21709Passed down to the assembler to enable the swap byte ordering
21710extension instruction. Also sets the preprocessor symbol
21711@code{__Xswape}.
21712
d77de738 21713@opindex mtelephony
ddf6fe37 21714@item -mtelephony
d77de738
ML
21715Passed down to the assembler to enable dual- and single-operand
21716instructions for telephony. Also sets the preprocessor symbol
21717@code{__Xtelephony}. This option is deprecated.
21718
d77de738 21719@opindex mxy
ddf6fe37 21720@item -mxy
d77de738
ML
21721Passed down to the assembler to enable the XY memory extension. Also
21722sets the preprocessor symbol @code{__Xxy}.
21723
21724@end table
21725
21726The following options control how the assembly code is annotated:
21727
21728@c Assembly annotation options
21729@table @gcctabopt
d77de738 21730@opindex misize
ddf6fe37 21731@item -misize
d77de738
ML
21732Annotate assembler instructions with estimated addresses.
21733
d77de738 21734@opindex mannotate-align
ddf6fe37 21735@item -mannotate-align
e4b19406 21736Does nothing. Preserved for backward compatibility.
d77de738
ML
21737
21738@end table
21739
21740The following options are passed through to the linker:
21741
21742@c options passed through to the linker
21743@table @gcctabopt
d77de738 21744@opindex marclinux
ddf6fe37 21745@item -marclinux
d77de738
ML
21746Passed through to the linker, to specify use of the @code{arclinux} emulation.
21747This option is enabled by default in tool chains built for
21748@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21749when profiling is not requested.
21750
d77de738 21751@opindex marclinux_prof
ddf6fe37 21752@item -marclinux_prof
d77de738
ML
21753Passed through to the linker, to specify use of the
21754@code{arclinux_prof} emulation. This option is enabled by default in
21755tool chains built for @w{@code{arc-linux-uclibc}} and
21756@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21757
21758@end table
21759
21760The following options control the semantics of generated code:
21761
21762@c semantically relevant code generation options
21763@table @gcctabopt
d77de738 21764@opindex mlong-calls
ddf6fe37 21765@item -mlong-calls
d77de738
ML
21766Generate calls as register indirect calls, thus providing access
21767to the full 32-bit address range.
21768
d77de738 21769@opindex mmedium-calls
ddf6fe37 21770@item -mmedium-calls
d77de738
ML
21771Don't use less than 25-bit addressing range for calls, which is the
21772offset available for an unconditional branch-and-link
21773instruction. Conditional execution of function calls is suppressed, to
21774allow use of the 25-bit range, rather than the 21-bit range with
21775conditional branch-and-link. This is the default for tool chains built
21776for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21777
d77de738 21778@opindex G
ddf6fe37 21779@item -G @var{num}
d77de738
ML
21780Put definitions of externally-visible data in a small data section if
21781that data is no bigger than @var{num} bytes. The default value of
21782@var{num} is 4 for any ARC configuration, or 8 when we have double
21783load/store operations.
21784
d77de738
ML
21785@opindex mno-sdata
21786@opindex msdata
ddf6fe37 21787@item -mno-sdata
d77de738
ML
21788Do not generate sdata references. This is the default for tool chains
21789built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21790targets.
21791
d77de738 21792@opindex mvolatile-cache
ddf6fe37 21793@item -mvolatile-cache
d77de738
ML
21794Use ordinarily cached memory accesses for volatile references. This is the
21795default.
21796
d77de738
ML
21797@opindex mno-volatile-cache
21798@opindex mvolatile-cache
ddf6fe37 21799@item -mno-volatile-cache
d77de738
ML
21800Enable cache bypass for volatile references.
21801
21802@end table
21803
21804The following options fine tune code generation:
21805@c code generation tuning options
21806@table @gcctabopt
d77de738 21807@opindex malign-call
ddf6fe37 21808@item -malign-call
d77de738
ML
21809Does nothing. Preserved for backward compatibility.
21810
d77de738 21811@opindex mauto-modify-reg
ddf6fe37 21812@item -mauto-modify-reg
d77de738
ML
21813Enable the use of pre/post modify with register displacement.
21814
d77de738 21815@opindex mbbit-peephole
ddf6fe37 21816@item -mbbit-peephole
07f7615c 21817Does nothing. Preserved for backward compatibility.
d77de738 21818
d77de738 21819@opindex mno-brcc
ddf6fe37 21820@item -mno-brcc
d77de738
ML
21821This option disables a target-specific pass in @file{arc_reorg} to
21822generate compare-and-branch (@code{br@var{cc}}) instructions.
21823It has no effect on
21824generation of these instructions driven by the combiner pass.
21825
d77de738 21826@opindex mcase-vector-pcrel
ddf6fe37 21827@item -mcase-vector-pcrel
d77de738
ML
21828Use PC-relative switch case tables to enable case table shortening.
21829This is the default for @option{-Os}.
21830
d77de738 21831@opindex mcompact-casesi
ddf6fe37 21832@item -mcompact-casesi
d77de738
ML
21833Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21834and only available for ARCv1 cores. This option is deprecated.
21835
d77de738 21836@opindex mno-cond-exec
ddf6fe37 21837@item -mno-cond-exec
d77de738
ML
21838Disable the ARCompact-specific pass to generate conditional
21839execution instructions.
21840
21841Due to delay slot scheduling and interactions between operand numbers,
21842literal sizes, instruction lengths, and the support for conditional execution,
21843the target-independent pass to generate conditional execution is often lacking,
21844so the ARC port has kept a special pass around that tries to find more
21845conditional execution generation opportunities after register allocation,
21846branch shortening, and delay slot scheduling have been done. This pass
21847generally, but not always, improves performance and code size, at the cost of
21848extra compilation time, which is why there is an option to switch it off.
21849If you have a problem with call instructions exceeding their allowable
21850offset range because they are conditionalized, you should consider using
21851@option{-mmedium-calls} instead.
21852
d77de738 21853@opindex mearly-cbranchsi
ddf6fe37 21854@item -mearly-cbranchsi
d77de738
ML
21855Enable pre-reload use of the @code{cbranchsi} pattern.
21856
d77de738 21857@opindex mexpand-adddi
ddf6fe37 21858@item -mexpand-adddi
d77de738
ML
21859Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21860@code{add.f}, @code{adc} etc. This option is deprecated.
21861
d77de738 21862@opindex mindexed-loads
ddf6fe37 21863@item -mindexed-loads
d77de738
ML
21864Enable the use of indexed loads. This can be problematic because some
21865optimizers then assume that indexed stores exist, which is not
21866the case.
21867
d77de738 21868@opindex mlra
ddf6fe37 21869@item -mlra
d77de738
ML
21870Enable Local Register Allocation. This is still experimental for ARC,
21871so by default the compiler uses standard reload
21872(i.e.@: @option{-mno-lra}).
21873
d77de738 21874@opindex mlra-priority-none
ddf6fe37 21875@item -mlra-priority-none
d77de738
ML
21876Don't indicate any priority for target registers.
21877
d77de738 21878@opindex mlra-priority-compact
ddf6fe37 21879@item -mlra-priority-compact
d77de738
ML
21880Indicate target register priority for r0..r3 / r12..r15.
21881
d77de738 21882@opindex mlra-priority-noncompact
ddf6fe37 21883@item -mlra-priority-noncompact
d77de738
ML
21884Reduce target register priority for r0..r3 / r12..r15.
21885
d77de738 21886@opindex mmillicode
ddf6fe37 21887@item -mmillicode
d77de738
ML
21888When optimizing for size (using @option{-Os}), prologues and epilogues
21889that have to save or restore a large number of registers are often
21890shortened by using call to a special function in libgcc; this is
21891referred to as a @emph{millicode} call. As these calls can pose
21892performance issues, and/or cause linking issues when linking in a
21893nonstandard way, this option is provided to turn on or off millicode
21894call generation.
21895
d77de738 21896@opindex mcode-density-frame
ddf6fe37 21897@item -mcode-density-frame
d77de738
ML
21898This option enable the compiler to emit @code{enter} and @code{leave}
21899instructions. These instructions are only valid for CPUs with
21900code-density feature.
21901
d77de738 21902@opindex mmixed-code
ddf6fe37 21903@item -mmixed-code
d77de738
ML
21904Does nothing. Preserved for backward compatibility.
21905
d77de738 21906@opindex mq-class
ddf6fe37 21907@item -mq-class
d77de738
ML
21908Ths option is deprecated. Enable @samp{q} instruction alternatives.
21909This is the default for @option{-Os}.
21910
d77de738 21911@opindex mRcq
ddf6fe37 21912@item -mRcq
d77de738
ML
21913Does nothing. Preserved for backward compatibility.
21914
d77de738 21915@opindex mRcw
ddf6fe37 21916@item -mRcw
d77de738
ML
21917Does nothing. Preserved for backward compatibility.
21918
d77de738 21919@opindex msize-level
ddf6fe37 21920@item -msize-level=@var{level}
d77de738
ML
21921Fine-tune size optimization with regards to instruction lengths and alignment.
21922The recognized values for @var{level} are:
21923@table @samp
21924@item 0
21925No size optimization. This level is deprecated and treated like @samp{1}.
21926
21927@item 1
21928Short instructions are used opportunistically.
21929
21930@item 2
21931In addition, alignment of loops and of code after barriers are dropped.
21932
21933@item 3
21934In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21935
21936@end table
21937
21938This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21939the behavior when this is not set is equivalent to level @samp{1}.
21940
d77de738 21941@opindex mtune
ddf6fe37 21942@item -mtune=@var{cpu}
d77de738
ML
21943Set instruction scheduling parameters for @var{cpu}, overriding any implied
21944by @option{-mcpu=}.
21945
21946Supported values for @var{cpu} are
21947
21948@table @samp
21949@item ARC600
21950Tune for ARC600 CPU.
21951
21952@item ARC601
21953Tune for ARC601 CPU.
21954
21955@item ARC700
21956Tune for ARC700 CPU with standard multiplier block.
21957
21958@item ARC700-xmac
21959Tune for ARC700 CPU with XMAC block.
21960
21961@item ARC725D
21962Tune for ARC725D CPU.
21963
21964@item ARC750D
21965Tune for ARC750D CPU.
21966
21967@item core3
21968Tune for ARCv2 core3 type CPU. This option enable usage of
21969@code{dbnz} instruction.
21970
21971@item release31a
21972Tune for ARC4x release 3.10a.
21973
21974@end table
21975
d77de738 21976@opindex mmultcost
ddf6fe37 21977@item -mmultcost=@var{num}
d77de738
ML
21978Cost to assume for a multiply instruction, with @samp{4} being equal to a
21979normal instruction.
21980
d77de738 21981@opindex munalign-prob-threshold
ddf6fe37 21982@item -munalign-prob-threshold=@var{probability}
d77de738
ML
21983Does nothing. Preserved for backward compatibility.
21984
21985@end table
21986
21987The following options are maintained for backward compatibility, but
21988are now deprecated and will be removed in a future release:
21989
21990@c Deprecated options
21991@table @gcctabopt
21992
d77de738 21993@opindex margonaut
ddf6fe37 21994@item -margonaut
d77de738
ML
21995Obsolete FPX.
21996
d77de738 21997@opindex mbig-endian
d77de738 21998@opindex EB
ddf6fe37
AA
21999@item -mbig-endian
22000@itemx -EB
d77de738
ML
22001Compile code for big-endian targets. Use of these options is now
22002deprecated. Big-endian code is supported by configuring GCC to build
22003@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
22004for which big endian is the default.
22005
d77de738 22006@opindex mlittle-endian
d77de738 22007@opindex EL
ddf6fe37
AA
22008@item -mlittle-endian
22009@itemx -EL
d77de738
ML
22010Compile code for little-endian targets. Use of these options is now
22011deprecated. Little-endian code is supported by configuring GCC to build
22012@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
22013for which little endian is the default.
22014
d77de738 22015@opindex mbarrel_shifter
ddf6fe37 22016@item -mbarrel_shifter
d77de738
ML
22017Replaced by @option{-mbarrel-shifter}.
22018
d77de738 22019@opindex mdpfp_compact
ddf6fe37 22020@item -mdpfp_compact
d77de738
ML
22021Replaced by @option{-mdpfp-compact}.
22022
d77de738 22023@opindex mdpfp_fast
ddf6fe37 22024@item -mdpfp_fast
d77de738
ML
22025Replaced by @option{-mdpfp-fast}.
22026
d77de738 22027@opindex mdsp_packa
ddf6fe37 22028@item -mdsp_packa
d77de738
ML
22029Replaced by @option{-mdsp-packa}.
22030
d77de738 22031@opindex mEA
ddf6fe37 22032@item -mEA
d77de738
ML
22033Replaced by @option{-mea}.
22034
d77de738 22035@opindex mmac_24
ddf6fe37 22036@item -mmac_24
d77de738
ML
22037Replaced by @option{-mmac-24}.
22038
d77de738 22039@opindex mmac_d16
ddf6fe37 22040@item -mmac_d16
d77de738
ML
22041Replaced by @option{-mmac-d16}.
22042
d77de738 22043@opindex mspfp_compact
ddf6fe37 22044@item -mspfp_compact
d77de738
ML
22045Replaced by @option{-mspfp-compact}.
22046
d77de738 22047@opindex mspfp_fast
ddf6fe37 22048@item -mspfp_fast
d77de738
ML
22049Replaced by @option{-mspfp-fast}.
22050
d77de738 22051@opindex mtune
ddf6fe37 22052@item -mtune=@var{cpu}
d77de738
ML
22053Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
22054@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
22055@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
22056
d77de738 22057@opindex multcost
ddf6fe37 22058@item -multcost=@var{num}
d77de738
ML
22059Replaced by @option{-mmultcost}.
22060
22061@end table
22062
22063@node ARM Options
22064@subsection ARM Options
22065@cindex ARM options
22066
22067These @samp{-m} options are defined for the ARM port:
22068
22069@table @gcctabopt
d77de738 22070@opindex mabi
ddf6fe37 22071@item -mabi=@var{name}
d77de738
ML
22072Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
22073@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
22074
d77de738 22075@opindex mapcs-frame
ddf6fe37 22076@item -mapcs-frame
d77de738
ML
22077Generate a stack frame that is compliant with the ARM Procedure Call
22078Standard for all functions, even if this is not strictly necessary for
22079correct execution of the code. Specifying @option{-fomit-frame-pointer}
22080with this option causes the stack frames not to be generated for
22081leaf functions. The default is @option{-mno-apcs-frame}.
22082This option is deprecated.
22083
d77de738 22084@opindex mapcs
ddf6fe37 22085@item -mapcs
d77de738
ML
22086This is a synonym for @option{-mapcs-frame} and is deprecated.
22087
22088@ignore
22089@c not currently implemented
d77de738 22090@opindex mapcs-stack-check
ddf6fe37 22091@item -mapcs-stack-check
d77de738
ML
22092Generate code to check the amount of stack space available upon entry to
22093every function (that actually uses some stack space). If there is
22094insufficient space available then either the function
22095@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
22096called, depending upon the amount of stack space required. The runtime
22097system is required to provide these functions. The default is
22098@option{-mno-apcs-stack-check}, since this produces smaller code.
22099
22100@c not currently implemented
d77de738 22101@opindex mapcs-reentrant
ddf6fe37 22102@item -mapcs-reentrant
d77de738
ML
22103Generate reentrant, position-independent code. The default is
22104@option{-mno-apcs-reentrant}.
22105@end ignore
22106
d77de738 22107@opindex mthumb-interwork
ddf6fe37 22108@item -mthumb-interwork
d77de738
ML
22109Generate code that supports calling between the ARM and Thumb
22110instruction sets. Without this option, on pre-v5 architectures, the
22111two instruction sets cannot be reliably used inside one program. The
22112default is @option{-mno-thumb-interwork}, since slightly larger code
22113is generated when @option{-mthumb-interwork} is specified. In AAPCS
22114configurations this option is meaningless.
22115
d77de738
ML
22116@opindex mno-sched-prolog
22117@opindex msched-prolog
ddf6fe37 22118@item -mno-sched-prolog
d77de738
ML
22119Prevent the reordering of instructions in the function prologue, or the
22120merging of those instruction with the instructions in the function's
22121body. This means that all functions start with a recognizable set
22122of instructions (or in fact one of a choice from a small set of
22123different function prologues), and this information can be used to
22124locate the start of functions inside an executable piece of code. The
22125default is @option{-msched-prolog}.
22126
d77de738 22127@opindex mfloat-abi
ddf6fe37 22128@item -mfloat-abi=@var{name}
d77de738
ML
22129Specifies which floating-point ABI to use. Permissible values
22130are: @samp{soft}, @samp{softfp} and @samp{hard}.
22131
22132Specifying @samp{soft} causes GCC to generate output containing
22133library calls for floating-point operations.
22134@samp{softfp} allows the generation of code using hardware floating-point
22135instructions, but still uses the soft-float calling conventions.
22136@samp{hard} allows generation of floating-point instructions
22137and uses FPU-specific calling conventions.
22138
22139The default depends on the specific target configuration. Note that
22140the hard-float and soft-float ABIs are not link-compatible; you must
22141compile your entire program with the same ABI, and link with a
22142compatible set of libraries.
22143
d77de738 22144@opindex mgeneral-regs-only
ddf6fe37 22145@item -mgeneral-regs-only
d77de738
ML
22146Generate code which uses only the general-purpose registers. This will prevent
22147the compiler from using floating-point and Advanced SIMD registers but will not
22148impose any restrictions on the assembler.
22149
d77de738 22150@opindex mlittle-endian
ddf6fe37 22151@item -mlittle-endian
d77de738
ML
22152Generate code for a processor running in little-endian mode. This is
22153the default for all standard configurations.
22154
d77de738 22155@opindex mbig-endian
ddf6fe37 22156@item -mbig-endian
d77de738
ML
22157Generate code for a processor running in big-endian mode; the default is
22158to compile code for a little-endian processor.
22159
ddf6fe37 22160@opindex mbe8
d77de738
ML
22161@item -mbe8
22162@itemx -mbe32
d77de738
ML
22163When linking a big-endian image select between BE8 and BE32 formats.
22164The option has no effect for little-endian images and is ignored. The
22165default is dependent on the selected target architecture. For ARMv6
22166and later architectures the default is BE8, for older architectures
22167the default is BE32. BE32 format has been deprecated by ARM.
22168
d77de738 22169@opindex march
ddf6fe37 22170@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22171This specifies the name of the target ARM architecture. GCC uses this
22172name to determine what kind of instructions it can emit when generating
22173assembly code. This option can be used in conjunction with or instead
22174of the @option{-mcpu=} option.
22175
22176Permissible names are:
22177@samp{armv4t},
22178@samp{armv5t}, @samp{armv5te},
22179@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
22180@samp{armv6z}, @samp{armv6zk},
22181@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
22182@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
22183@samp{armv8.4-a},
22184@samp{armv8.5-a},
22185@samp{armv8.6-a},
22186@samp{armv9-a},
22187@samp{armv7-r},
22188@samp{armv8-r},
22189@samp{armv6-m}, @samp{armv6s-m},
22190@samp{armv7-m}, @samp{armv7e-m},
22191@samp{armv8-m.base}, @samp{armv8-m.main},
22192@samp{armv8.1-m.main},
22193@samp{armv9-a},
22194@samp{iwmmxt} and @samp{iwmmxt2}.
22195
22196Additionally, the following architectures, which lack support for the
22197Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
22198
22199Many of the architectures support extensions. These can be added by
22200appending @samp{+@var{extension}} to the architecture name. Extension
22201options are processed in order and capabilities accumulate. An extension
22202will also enable any necessary base extensions
22203upon which it depends. For example, the @samp{+crypto} extension
22204will always enable the @samp{+simd} extension. The exception to the
22205additive construction is for extensions that are prefixed with
22206@samp{+no@dots{}}: these extensions disable the specified option and
22207any other extensions that may depend on the presence of that
22208extension.
22209
22210For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
22211writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
22212entirely disabled by the @samp{+nofp} option that follows it.
22213
22214Most extension names are generically named, but have an effect that is
22215dependent upon the architecture to which it is applied. For example,
22216the @samp{+simd} option can be applied to both @samp{armv7-a} and
22217@samp{armv8-a} architectures, but will enable the original ARMv7-A
22218Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
22219variant for @samp{armv8-a}.
22220
22221The table below lists the supported extensions for each architecture.
22222Architectures not mentioned do not support any extensions.
22223
22224@table @samp
22225@item armv5te
22226@itemx armv6
22227@itemx armv6j
22228@itemx armv6k
22229@itemx armv6kz
22230@itemx armv6t2
22231@itemx armv6z
22232@itemx armv6zk
22233@table @samp
22234@item +fp
22235The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
22236used as an alias for this extension.
22237
22238@item +nofp
22239Disable the floating-point instructions.
22240@end table
22241
22242@item armv7
22243The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
22244@table @samp
22245@item +fp
22246The VFPv3 floating-point instructions, with 16 double-precision
22247registers. The extension @samp{+vfpv3-d16} can be used as an alias
22248for this extension. Note that floating-point is not supported by the
22249base ARMv7-M architecture, but is compatible with both the ARMv7-A and
22250ARMv7-R architectures.
22251
22252@item +nofp
22253Disable the floating-point instructions.
22254@end table
22255
22256@item armv7-a
22257@table @samp
22258@item +mp
22259The multiprocessing extension.
22260
22261@item +sec
22262The security extension.
22263
22264@item +fp
22265The VFPv3 floating-point instructions, with 16 double-precision
22266registers. The extension @samp{+vfpv3-d16} can be used as an alias
22267for this extension.
22268
22269@item +simd
22270The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22271The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
22272for this extension.
22273
22274@item +vfpv3
22275The VFPv3 floating-point instructions, with 32 double-precision
22276registers.
22277
22278@item +vfpv3-d16-fp16
22279The VFPv3 floating-point instructions, with 16 double-precision
22280registers and the half-precision floating-point conversion operations.
22281
22282@item +vfpv3-fp16
22283The VFPv3 floating-point instructions, with 32 double-precision
22284registers and the half-precision floating-point conversion operations.
22285
22286@item +vfpv4-d16
22287The VFPv4 floating-point instructions, with 16 double-precision
22288registers.
22289
22290@item +vfpv4
22291The VFPv4 floating-point instructions, with 32 double-precision
22292registers.
22293
22294@item +neon-fp16
22295The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22296the half-precision floating-point conversion operations.
22297
22298@item +neon-vfpv4
22299The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
22300
22301@item +nosimd
22302Disable the Advanced SIMD instructions (does not disable floating point).
22303
22304@item +nofp
22305Disable the floating-point and Advanced SIMD instructions.
22306@end table
22307
22308@item armv7ve
22309The extended version of the ARMv7-A architecture with support for
22310virtualization.
22311@table @samp
22312@item +fp
22313The VFPv4 floating-point instructions, with 16 double-precision registers.
22314The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
22315
22316@item +simd
22317The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
22318extension @samp{+neon-vfpv4} can be used as an alias for this extension.
22319
22320@item +vfpv3-d16
22321The VFPv3 floating-point instructions, with 16 double-precision
22322registers.
22323
22324@item +vfpv3
22325The VFPv3 floating-point instructions, with 32 double-precision
22326registers.
22327
22328@item +vfpv3-d16-fp16
22329The VFPv3 floating-point instructions, with 16 double-precision
22330registers and the half-precision floating-point conversion operations.
22331
22332@item +vfpv3-fp16
22333The VFPv3 floating-point instructions, with 32 double-precision
22334registers and the half-precision floating-point conversion operations.
22335
22336@item +vfpv4-d16
22337The VFPv4 floating-point instructions, with 16 double-precision
22338registers.
22339
22340@item +vfpv4
22341The VFPv4 floating-point instructions, with 32 double-precision
22342registers.
22343
22344@item +neon
22345The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22346The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
22347
22348@item +neon-fp16
22349The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22350the half-precision floating-point conversion operations.
22351
22352@item +nosimd
22353Disable the Advanced SIMD instructions (does not disable floating point).
22354
22355@item +nofp
22356Disable the floating-point and Advanced SIMD instructions.
22357@end table
22358
22359@item armv8-a
22360@table @samp
22361@item +crc
22362The Cyclic Redundancy Check (CRC) instructions.
22363@item +simd
22364The ARMv8-A Advanced SIMD and floating-point instructions.
22365@item +crypto
22366The cryptographic instructions.
22367@item +nocrypto
22368Disable the cryptographic instructions.
22369@item +nofp
22370Disable the floating-point, Advanced SIMD and cryptographic instructions.
22371@item +sb
22372Speculation Barrier Instruction.
22373@item +predres
22374Execution and Data Prediction Restriction Instructions.
22375@end table
22376
22377@item armv8.1-a
22378@table @samp
22379@item +simd
22380The ARMv8.1-A Advanced SIMD and floating-point instructions.
22381
22382@item +crypto
22383The cryptographic instructions. This also enables the Advanced SIMD and
22384floating-point instructions.
22385
22386@item +nocrypto
22387Disable the cryptographic instructions.
22388
22389@item +nofp
22390Disable the floating-point, Advanced SIMD and cryptographic instructions.
22391
22392@item +sb
22393Speculation Barrier Instruction.
22394
22395@item +predres
22396Execution and Data Prediction Restriction Instructions.
22397@end table
22398
22399@item armv8.2-a
22400@itemx armv8.3-a
22401@table @samp
22402@item +fp16
22403The half-precision floating-point data processing instructions.
22404This also enables the Advanced SIMD and floating-point instructions.
22405
22406@item +fp16fml
22407The half-precision floating-point fmla extension. This also enables
22408the half-precision floating-point extension and Advanced SIMD and
22409floating-point instructions.
22410
22411@item +simd
22412The ARMv8.1-A Advanced SIMD and floating-point instructions.
22413
22414@item +crypto
22415The cryptographic instructions. This also enables the Advanced SIMD and
22416floating-point instructions.
22417
22418@item +dotprod
22419Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22420
22421@item +nocrypto
22422Disable the cryptographic extension.
22423
22424@item +nofp
22425Disable the floating-point, Advanced SIMD and cryptographic instructions.
22426
22427@item +sb
22428Speculation Barrier Instruction.
22429
22430@item +predres
22431Execution and Data Prediction Restriction Instructions.
22432
22433@item +i8mm
224348-bit Integer Matrix Multiply instructions.
22435This also enables Advanced SIMD and floating-point instructions.
22436
22437@item +bf16
22438Brain half-precision floating-point instructions.
22439This also enables Advanced SIMD and floating-point instructions.
22440@end table
22441
22442@item armv8.4-a
22443@table @samp
22444@item +fp16
22445The half-precision floating-point data processing instructions.
22446This also enables the Advanced SIMD and floating-point instructions as well
22447as the Dot Product extension and the half-precision floating-point fmla
22448extension.
22449
22450@item +simd
22451The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22452Dot Product extension.
22453
22454@item +crypto
22455The cryptographic instructions. This also enables the Advanced SIMD and
22456floating-point instructions as well as the Dot Product extension.
22457
22458@item +nocrypto
22459Disable the cryptographic extension.
22460
22461@item +nofp
22462Disable the floating-point, Advanced SIMD and cryptographic instructions.
22463
22464@item +sb
22465Speculation Barrier Instruction.
22466
22467@item +predres
22468Execution and Data Prediction Restriction Instructions.
22469
22470@item +i8mm
224718-bit Integer Matrix Multiply instructions.
22472This also enables Advanced SIMD and floating-point instructions.
22473
22474@item +bf16
22475Brain half-precision floating-point instructions.
22476This also enables Advanced SIMD and floating-point instructions.
22477@end table
22478
22479@item armv8.5-a
22480@table @samp
22481@item +fp16
22482The half-precision floating-point data processing instructions.
22483This also enables the Advanced SIMD and floating-point instructions as well
22484as the Dot Product extension and the half-precision floating-point fmla
22485extension.
22486
22487@item +simd
22488The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22489Dot Product extension.
22490
22491@item +crypto
22492The cryptographic instructions. This also enables the Advanced SIMD and
22493floating-point instructions as well as the Dot Product extension.
22494
22495@item +nocrypto
22496Disable the cryptographic extension.
22497
22498@item +nofp
22499Disable the floating-point, Advanced SIMD and cryptographic 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.6-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 +i8mm
225338-bit Integer Matrix Multiply instructions.
22534This also enables Advanced SIMD and floating-point instructions.
22535
22536@item +bf16
22537Brain half-precision floating-point instructions.
22538This also enables Advanced SIMD and floating-point instructions.
22539@end table
22540
22541@item armv7-r
22542@table @samp
22543@item +fp.sp
22544The single-precision VFPv3 floating-point instructions. The extension
22545@samp{+vfpv3xd} can be used as an alias for this extension.
22546
22547@item +fp
22548The VFPv3 floating-point instructions with 16 double-precision registers.
22549The extension +vfpv3-d16 can be used as an alias for this extension.
22550
22551@item +vfpv3xd-d16-fp16
22552The single-precision VFPv3 floating-point instructions with 16 double-precision
22553registers and the half-precision floating-point conversion operations.
22554
22555@item +vfpv3-d16-fp16
22556The VFPv3 floating-point instructions with 16 double-precision
22557registers and the half-precision floating-point conversion operations.
22558
22559@item +nofp
22560Disable the floating-point extension.
22561
22562@item +idiv
22563The ARM-state integer division instructions.
22564
22565@item +noidiv
22566Disable the ARM-state integer division extension.
22567@end table
22568
22569@item armv7e-m
22570@table @samp
22571@item +fp
22572The single-precision VFPv4 floating-point instructions.
22573
22574@item +fpv5
22575The single-precision FPv5 floating-point instructions.
22576
22577@item +fp.dp
22578The single- and double-precision FPv5 floating-point instructions.
22579
22580@item +nofp
22581Disable the floating-point extensions.
22582@end table
22583
22584@item armv8.1-m.main
22585@table @samp
22586
22587@item +dsp
22588The DSP instructions.
22589
22590@item +mve
22591The M-Profile Vector Extension (MVE) integer instructions.
22592
22593@item +mve.fp
22594The M-Profile Vector Extension (MVE) integer and single precision
22595floating-point instructions.
22596
22597@item +fp
22598The single-precision floating-point instructions.
22599
22600@item +fp.dp
22601The single- and double-precision floating-point instructions.
22602
22603@item +nofp
22604Disable the floating-point extension.
22605
22606@item +cdecp0, +cdecp1, ... , +cdecp7
22607Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22608to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22609
22610@item +pacbti
22611Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22612@end table
22613
22614@item armv8-m.main
22615@table @samp
22616@item +dsp
22617The DSP instructions.
22618
22619@item +nodsp
22620Disable the DSP extension.
22621
22622@item +fp
22623The single-precision floating-point instructions.
22624
22625@item +fp.dp
22626The single- and double-precision floating-point instructions.
22627
22628@item +nofp
22629Disable the floating-point extension.
22630
22631@item +cdecp0, +cdecp1, ... , +cdecp7
22632Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22633to the numbers given in the options in the range 0 to 7.
22634@end table
22635
22636@item armv8-r
22637@table @samp
22638@item +crc
22639The Cyclic Redundancy Check (CRC) instructions.
22640@item +fp.sp
22641The single-precision FPv5 floating-point instructions.
22642@item +simd
22643The ARMv8-A Advanced SIMD and floating-point instructions.
22644@item +crypto
22645The cryptographic instructions.
22646@item +nocrypto
22647Disable the cryptographic instructions.
22648@item +nofp
22649Disable the floating-point, Advanced SIMD and cryptographic instructions.
22650@end table
22651
22652@end table
22653
22654@option{-march=native} causes the compiler to auto-detect the architecture
22655of the build computer. At present, this feature is only supported on
22656GNU/Linux, and not all architectures are recognized. If the auto-detect
22657is unsuccessful the option has no effect.
22658
d77de738 22659@opindex mtune
ddf6fe37 22660@item -mtune=@var{name}
d77de738
ML
22661This option specifies the name of the target ARM processor for
22662which GCC should tune the performance of the code.
22663For some ARM implementations better performance can be obtained by using
22664this option.
22665Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22666@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22667@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22668@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22669@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22670@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22671@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22672@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22673@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22674@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22675@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22676@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22677@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22678@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22679@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22680@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22681@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22682@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22683@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22684@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22685@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22686@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22687@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22688@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22689@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22690@samp{xgene1}.
22691
22692Additionally, this option can specify that GCC should tune the performance
22693of the code for a big.LITTLE system. Permissible names are:
22694@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22695@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22696@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22697@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22698
22699@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22700performance for a blend of processors within architecture @var{arch}.
22701The aim is to generate code that run well on the current most popular
22702processors, balancing between optimizations that benefit some CPUs in the
22703range, and avoiding performance pitfalls of other CPUs. The effects of
22704this option may change in future GCC versions as CPU models come and go.
22705
22706@option{-mtune} permits the same extension options as @option{-mcpu}, but
22707the extension options do not affect the tuning of the generated code.
22708
22709@option{-mtune=native} causes the compiler to auto-detect the CPU
22710of the build computer. At present, this feature is only supported on
22711GNU/Linux, and not all architectures are recognized. If the auto-detect is
22712unsuccessful the option has no effect.
22713
d77de738 22714@opindex mcpu
ddf6fe37 22715@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22716This specifies the name of the target ARM processor. GCC uses this name
22717to derive the name of the target ARM architecture (as if specified
22718by @option{-march}) and the ARM processor type for which to tune for
22719performance (as if specified by @option{-mtune}). Where this option
22720is used in conjunction with @option{-march} or @option{-mtune},
22721those options take precedence over the appropriate part of this option.
22722
22723Many of the supported CPUs implement optional architectural
22724extensions. Where this is so the architectural extensions are
22725normally enabled by default. If implementations that lack the
22726extension exist, then the extension syntax can be used to disable
22727those extensions that have been omitted. For floating-point and
22728Advanced SIMD (Neon) instructions, the settings of the options
22729@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22730floating-point and Advanced SIMD instructions will only be used if
22731@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22732@option{-mfpu} other than @samp{auto} will override the available
22733floating-point and SIMD extension instructions.
22734
22735For example, @samp{cortex-a9} can be found in three major
22736configurations: integer only, with just a floating-point unit or with
22737floating-point and Advanced SIMD. The default is to enable all the
22738instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22739be used to disable just the SIMD or both the SIMD and floating-point
22740instructions respectively.
22741
22742Permissible names for this option are the same as those for
22743@option{-mtune}.
22744
22745The following extension options are common to the listed CPUs:
22746
22747@table @samp
22748@item +nodsp
ccfd1e7f
SP
22749Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22750@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22751Extension (MVE) integer and single precision floating-point instructions on
22752@samp{cortex-m55} and @samp{cortex-m85}.
22753
22754@item +nopacbti
22755Disable the Pointer Authentication and Branch Target Identification Extension
22756on @samp{cortex-m85}.
d77de738
ML
22757
22758@item +nomve
22759Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22760floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22761
22762@item +nomve.fp
22763Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22764instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22765
798a0d05
SP
22766@item +cdecp0, +cdecp1, ... , +cdecp7
22767Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22768to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22769
d77de738
ML
22770@item +nofp
22771Disables the floating-point instructions on @samp{arm9e},
22772@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22773@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22774@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22775@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22776@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22777@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22778Disables the floating-point and SIMD instructions on
22779@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22780@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22781@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22782@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22783@samp{cortex-a53} and @samp{cortex-a55}.
22784
22785@item +nofp.dp
22786Disables the double-precision component of the floating-point instructions
22787on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22788@samp{cortex-r52plus} and @samp{cortex-m7}.
22789
22790@item +nosimd
22791Disables the SIMD (but not floating-point) instructions on
22792@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22793and @samp{cortex-a9}.
22794
22795@item +crypto
22796Enables the cryptographic instructions on @samp{cortex-a32},
22797@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22798@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22799@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22800@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22801@samp{cortex-a75.cortex-a55}.
22802@end table
22803
22804Additionally the @samp{generic-armv7-a} pseudo target defaults to
22805VFPv3 with 16 double-precision registers. It supports the following
22806extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22807@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22808@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22809@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22810the extensions to @option{-march=armv7-a}.
22811
22812@option{-mcpu=generic-@var{arch}} is also permissible, and is
22813equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22814See @option{-mtune} for more information.
22815
22816@option{-mcpu=native} causes the compiler to auto-detect the CPU
22817of the build computer. At present, this feature is only supported on
22818GNU/Linux, and not all architectures are recognized. If the auto-detect
22819is unsuccessful the option has no effect.
22820
d77de738 22821@opindex mfpu
ddf6fe37 22822@item -mfpu=@var{name}
d77de738
ML
22823This specifies what floating-point hardware (or hardware emulation) is
22824available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22825@samp{vfpv3},
22826@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22827@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22828@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22829@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22830@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22831Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22832is an alias for @samp{vfpv2}.
22833
22834The setting @samp{auto} is the default and is special. It causes the
22835compiler to select the floating-point and Advanced SIMD instructions
22836based on the settings of @option{-mcpu} and @option{-march}.
22837
22838If the selected floating-point hardware includes the NEON extension
22839(e.g.@: @option{-mfpu=neon}), note that floating-point
22840operations are not generated by GCC's auto-vectorization pass unless
22841@option{-funsafe-math-optimizations} is also specified. This is
22842because NEON hardware does not fully implement the IEEE 754 standard for
22843floating-point arithmetic (in particular denormal values are treated as
22844zero), so the use of NEON instructions may lead to a loss of precision.
22845
22846You 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}).
22847
d77de738 22848@opindex mfp16-format
ddf6fe37 22849@item -mfp16-format=@var{name}
d77de738
ML
22850Specify the format of the @code{__fp16} half-precision floating-point type.
22851Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22852the default is @samp{none}, in which case the @code{__fp16} type is not
22853defined. @xref{Half-Precision}, for more information.
22854
d77de738 22855@opindex mstructure-size-boundary
ddf6fe37 22856@item -mstructure-size-boundary=@var{n}
d77de738
ML
22857The sizes of all structures and unions are rounded up to a multiple
22858of the number of bits set by this option. Permissible values are 8, 32
22859and 64. The default value varies for different toolchains. For the COFF
22860targeted toolchain the default value is 8. A value of 64 is only allowed
22861if the underlying ABI supports it.
22862
22863Specifying a larger number can produce faster, more efficient code, but
22864can also increase the size of the program. Different values are potentially
22865incompatible. Code compiled with one value cannot necessarily expect to
22866work with code or libraries compiled with another value, if they exchange
22867information using structures or unions.
22868
22869This option is deprecated.
22870
d77de738 22871@opindex mabort-on-noreturn
ddf6fe37 22872@item -mabort-on-noreturn
d77de738
ML
22873Generate a call to the function @code{abort} at the end of a
22874@code{noreturn} function. It is executed if the function tries to
22875return.
22876
d77de738
ML
22877@opindex mlong-calls
22878@opindex mno-long-calls
ddf6fe37
AA
22879@item -mlong-calls
22880@itemx -mno-long-calls
d77de738
ML
22881Tells the compiler to perform function calls by first loading the
22882address of the function into a register and then performing a subroutine
22883call on this register. This switch is needed if the target function
22884lies outside of the 64-megabyte addressing range of the offset-based
22885version of subroutine call instruction.
22886
22887Even if this switch is enabled, not all function calls are turned
22888into long calls. The heuristic is that static functions, functions
22889that have the @code{short_call} attribute, functions that are inside
22890the scope of a @code{#pragma no_long_calls} directive, and functions whose
22891definitions have already been compiled within the current compilation
22892unit are not turned into long calls. The exceptions to this rule are
22893that weak function definitions, functions with the @code{long_call}
22894attribute or the @code{section} attribute, and functions that are within
22895the scope of a @code{#pragma long_calls} directive are always
22896turned into long calls.
22897
22898This feature is not enabled by default. Specifying
22899@option{-mno-long-calls} restores the default behavior, as does
22900placing the function calls within the scope of a @code{#pragma
22901long_calls_off} directive. Note these switches have no effect on how
22902the compiler generates code to handle function calls via function
22903pointers.
22904
d77de738 22905@opindex msingle-pic-base
ddf6fe37 22906@item -msingle-pic-base
d77de738
ML
22907Treat the register used for PIC addressing as read-only, rather than
22908loading it in the prologue for each function. The runtime system is
22909responsible for initializing this register with an appropriate value
22910before execution begins.
22911
d77de738 22912@opindex mpic-register
ddf6fe37 22913@item -mpic-register=@var{reg}
d77de738
ML
22914Specify the register to be used for PIC addressing.
22915For standard PIC base case, the default is any suitable register
22916determined by compiler. For single PIC base case, the default is
22917@samp{R9} if target is EABI based or stack-checking is enabled,
22918otherwise the default is @samp{R10}.
22919
d77de738 22920@opindex mpic-data-is-text-relative
ddf6fe37 22921@item -mpic-data-is-text-relative
d77de738
ML
22922Assume that the displacement between the text and data segments is fixed
22923at static link time. This permits using PC-relative addressing
22924operations to access data known to be in the data segment. For
22925non-VxWorks RTP targets, this option is enabled by default. When
22926disabled on such targets, it will enable @option{-msingle-pic-base} by
22927default.
22928
d77de738 22929@opindex mpoke-function-name
ddf6fe37 22930@item -mpoke-function-name
d77de738
ML
22931Write the name of each function into the text section, directly
22932preceding the function prologue. The generated code is similar to this:
22933
22934@smallexample
22935 t0
22936 .ascii "arm_poke_function_name", 0
22937 .align
22938 t1
22939 .word 0xff000000 + (t1 - t0)
22940 arm_poke_function_name
22941 mov ip, sp
22942 stmfd sp!, @{fp, ip, lr, pc@}
22943 sub fp, ip, #4
22944@end smallexample
22945
22946When performing a stack backtrace, code can inspect the value of
22947@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22948location @code{pc - 12} and the top 8 bits are set, then we know that
22949there is a function name embedded immediately preceding this location
22950and has length @code{((pc[-3]) & 0xff000000)}.
22951
d77de738
ML
22952@opindex marm
22953@opindex mthumb
ddf6fe37
AA
22954@item -mthumb
22955@itemx -marm
d77de738
ML
22956
22957Select between generating code that executes in ARM and Thumb
22958states. The default for most configurations is to generate code
22959that executes in ARM state, but the default can be changed by
22960configuring GCC with the @option{--with-mode=}@var{state}
22961configure option.
22962
22963You can also override the ARM and Thumb mode for each function
22964by using the @code{target("thumb")} and @code{target("arm")} function attributes
22965(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22966
d77de738 22967@opindex mflip-thumb
ddf6fe37 22968@item -mflip-thumb
d77de738
ML
22969Switch ARM/Thumb modes on alternating functions.
22970This option is provided for regression testing of mixed Thumb/ARM code
22971generation, and is not intended for ordinary use in compiling code.
22972
d77de738 22973@opindex mtpcs-frame
ddf6fe37 22974@item -mtpcs-frame
d77de738
ML
22975Generate a stack frame that is compliant with the Thumb Procedure Call
22976Standard for all non-leaf functions. (A leaf function is one that does
22977not call any other functions.) The default is @option{-mno-tpcs-frame}.
22978
d77de738 22979@opindex mtpcs-leaf-frame
ddf6fe37 22980@item -mtpcs-leaf-frame
d77de738
ML
22981Generate a stack frame that is compliant with the Thumb Procedure Call
22982Standard for all leaf functions. (A leaf function is one that does
22983not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22984
d77de738 22985@opindex mcallee-super-interworking
ddf6fe37 22986@item -mcallee-super-interworking
d77de738
ML
22987Gives all externally visible functions in the file being compiled an ARM
22988instruction set header which switches to Thumb mode before executing the
22989rest of the function. This allows these functions to be called from
22990non-interworking code. This option is not valid in AAPCS configurations
22991because interworking is enabled by default.
22992
d77de738 22993@opindex mcaller-super-interworking
ddf6fe37 22994@item -mcaller-super-interworking
d77de738
ML
22995Allows calls via function pointers (including virtual functions) to
22996execute correctly regardless of whether the target code has been
22997compiled for interworking or not. There is a small overhead in the cost
22998of executing a function pointer if this option is enabled. This option
22999is not valid in AAPCS configurations because interworking is enabled
23000by default.
23001
d77de738 23002@opindex mtp
ddf6fe37 23003@item -mtp=@var{name}
cca8d9e5
KT
23004Specify the access model for the thread local storage pointer. The model
23005@samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
23006models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
23007the thread pointer from the corresponding system register directly
23008(supported from the arm6k architecture and later). These system registers
23009are accessed through the CP15 co-processor interface and the argument
23010@samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
23011The argument @samp{auto} uses the best available method for the selected
23012processor. The default setting is @samp{auto}.
d77de738 23013
d77de738 23014@opindex mtls-dialect
ddf6fe37 23015@item -mtls-dialect=@var{dialect}
d77de738
ML
23016Specify the dialect to use for accessing thread local storage. Two
23017@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
23018@samp{gnu} dialect selects the original GNU scheme for supporting
23019local and global dynamic TLS models. The @samp{gnu2} dialect
23020selects the GNU descriptor scheme, which provides better performance
23021for shared libraries. The GNU descriptor scheme is compatible with
23022the original scheme, but does require new assembler, linker and
23023library support. Initial and local exec TLS models are unaffected by
23024this option and always use the original scheme.
23025
d77de738 23026@opindex mword-relocations
ddf6fe37 23027@item -mword-relocations
d77de738
ML
23028Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
23029This is enabled by default on targets (uClinux, SymbianOS) where the runtime
23030loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
23031is specified. This option conflicts with @option{-mslow-flash-data}.
23032
d77de738 23033@opindex mfix-cortex-m3-ldrd
ddf6fe37 23034@item -mfix-cortex-m3-ldrd
d77de738
ML
23035Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
23036with overlapping destination and base registers are used. This option avoids
23037generating these instructions. This option is enabled by default when
23038@option{-mcpu=cortex-m3} is specified.
23039
23040@item -mfix-cortex-a57-aes-1742098
23041@itemx -mno-fix-cortex-a57-aes-1742098
23042@itemx -mfix-cortex-a72-aes-1655431
23043@itemx -mno-fix-cortex-a72-aes-1655431
23044Enable (disable) mitigation for an erratum on Cortex-A57 and
23045Cortex-A72 that affects the AES cryptographic instructions. This
23046option is enabled by default when either @option{-mcpu=cortex-a57} or
23047@option{-mcpu=cortex-a72} is specified.
23048
d77de738
ML
23049@opindex munaligned-access
23050@opindex mno-unaligned-access
ddf6fe37
AA
23051@item -munaligned-access
23052@itemx -mno-unaligned-access
d77de738
ML
23053Enables (or disables) reading and writing of 16- and 32- bit values
23054from addresses that are not 16- or 32- bit aligned. By default
23055unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
23056ARMv8-M Baseline architectures, and enabled for all other
23057architectures. If unaligned access is not enabled then words in packed
23058data structures are accessed a byte at a time.
23059
23060The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
23061generated object file to either true or false, depending upon the
23062setting of this option. If unaligned access is enabled then the
23063preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
23064defined.
23065
d77de738 23066@opindex mneon-for-64bits
ddf6fe37 23067@item -mneon-for-64bits
d77de738
ML
23068This option is deprecated and has no effect.
23069
d77de738 23070@opindex mslow-flash-data
ddf6fe37 23071@item -mslow-flash-data
d77de738
ML
23072Assume loading data from flash is slower than fetching instruction.
23073Therefore literal load is minimized for better performance.
23074This option is only supported when compiling for ARMv7 M-profile and
23075off by default. It conflicts with @option{-mword-relocations}.
23076
d77de738 23077@opindex masm-syntax-unified
ddf6fe37 23078@item -masm-syntax-unified
d77de738
ML
23079Assume inline assembler is using unified asm syntax. The default is
23080currently off which implies divided syntax. This option has no impact
23081on Thumb2. However, this may change in future releases of GCC.
23082Divided syntax should be considered deprecated.
23083
d77de738 23084@opindex mrestrict-it
ddf6fe37 23085@item -mrestrict-it
d77de738
ML
23086Restricts generation of IT blocks to conform to the rules of ARMv8-A.
23087IT blocks can only contain a single 16-bit instruction from a select
23088set of instructions. This option is on by default for ARMv8-A Thumb mode.
23089
d77de738 23090@opindex mprint-tune-info
ddf6fe37 23091@item -mprint-tune-info
d77de738
ML
23092Print CPU tuning information as comment in assembler file. This is
23093an option used only for regression testing of the compiler and not
23094intended for ordinary use in compiling code. This option is disabled
23095by default.
23096
d77de738 23097@opindex mverbose-cost-dump
ddf6fe37 23098@item -mverbose-cost-dump
d77de738
ML
23099Enable verbose cost model dumping in the debug dump files. This option is
23100provided for use in debugging the compiler.
23101
d77de738 23102@opindex mpure-code
ddf6fe37 23103@item -mpure-code
d77de738
ML
23104Do not allow constant data to be placed in code sections.
23105Additionally, when compiling for ELF object format give all text sections the
23106ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
23107is only available when generating non-pic code for M-profile targets.
23108
d77de738 23109@opindex mcmse
ddf6fe37 23110@item -mcmse
d77de738
ML
23111Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
23112Development Tools Engineering Specification", which can be found on
23113@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
23114
d77de738 23115@opindex mfix-cmse-cve-2021-35465
ddf6fe37 23116@item -mfix-cmse-cve-2021-35465
d77de738
ML
23117Mitigate against a potential security issue with the @code{VLLDM} instruction
23118in some M-profile devices when using CMSE (CVE-2021-365465). This option is
23119enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
23120@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
23121or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
23122to disable the mitigation.
d77de738 23123
d77de738
ML
23124@opindex mstack-protector-guard
23125@opindex mstack-protector-guard-offset
ddf6fe37
AA
23126@item -mstack-protector-guard=@var{guard}
23127@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
23128Generate stack protection code using canary at @var{guard}. Supported
23129locations are @samp{global} for a global canary or @samp{tls} for a
23130canary accessible via the TLS register. The option
23131@option{-mstack-protector-guard-offset=} is for use with
23132@option{-fstack-protector-guard=tls} and not for use in user-land code.
23133
d77de738
ML
23134@opindex mfdpic
23135@opindex mno-fdpic
ddf6fe37
AA
23136@item -mfdpic
23137@itemx -mno-fdpic
d77de738
ML
23138Select the FDPIC ABI, which uses 64-bit function descriptors to
23139represent pointers to functions. When the compiler is configured for
23140@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
23141and implies @option{-fPIE} if none of the PIC/PIE-related options is
23142provided. On other targets, it only enables the FDPIC-specific code
23143generation features, and the user should explicitly provide the
23144PIC/PIE-related options as needed.
23145
23146Note that static linking is not supported because it would still
23147involve the dynamic linker when the program self-relocates. If such
23148behavior is acceptable, use -static and -Wl,-dynamic-linker options.
23149
23150The opposite @option{-mno-fdpic} option is useful (and required) to
23151build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
23152toolchain as the one used to build the userland programs.
23153
14fab5fb 23154@opindex mbranch-protection
ddf6fe37 23155@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
23156Enable branch protection features (armv8.1-m.main only).
23157@samp{none} generate code without branch protection or return address
23158signing.
23159@samp{standard[+@var{leaf}]} generate code with all branch protection
23160features enabled at their standard level.
23161@samp{pac-ret[+@var{leaf}]} generate code with return address signing
23162set to its standard level, which is to sign all functions that save
23163the return address to memory.
23164@samp{leaf} When return address signing is enabled, also sign leaf
23165functions even if they do not write the return address to memory.
23166+@samp{bti} Add landing-pad instructions at the permitted targets of
23167indirect branch instructions.
23168
23169If the @samp{+pacbti} architecture extension is not enabled, then all
23170branch protection and return address signing operations are
23171constrained to use only the instructions defined in the
23172architectural-NOP space. The generated code will remain
23173backwards-compatible with earlier versions of the architecture, but
23174the additional security can be enabled at run time on processors that
23175support the @samp{PACBTI} extension.
23176
23177Branch target enforcement using BTI can only be enabled at runtime if
23178all code in the application has been compiled with at least
23179@samp{-mbranch-protection=bti}.
23180
23181Any setting other than @samp{none} is supported only on armv8-m.main
23182or later.
23183
23184The default is to generate code without branch protection or return
23185address signing.
23186
d77de738
ML
23187@end table
23188
23189@node AVR Options
23190@subsection AVR Options
23191@cindex AVR Options
23192
23193These options are defined for AVR implementations:
23194
23195@table @gcctabopt
d77de738 23196@opindex mmcu
ddf6fe37 23197@item -mmcu=@var{mcu}
d77de738
ML
23198Specify Atmel AVR instruction set architectures (ISA) or MCU type.
23199
23200The default for this option is@tie{}@samp{avr2}.
23201
23202GCC supports the following AVR devices and ISAs:
23203
23204@include avr-mmcu.texi
23205
d77de738 23206@opindex mabsdata
ddf6fe37 23207@item -mabsdata
d77de738
ML
23208
23209Assume that all data in static storage can be accessed by LDS / STS
23210instructions. This option has only an effect on reduced Tiny devices like
23211ATtiny40. See also the @code{absdata}
23212@ref{AVR Variable Attributes,variable attribute}.
23213
d77de738 23214@opindex maccumulate-args
ddf6fe37 23215@item -maccumulate-args
d77de738
ML
23216Accumulate outgoing function arguments and acquire/release the needed
23217stack space for outgoing function arguments once in function
23218prologue/epilogue. Without this option, outgoing arguments are pushed
23219before calling a function and popped afterwards.
23220
23221Popping the arguments after the function call can be expensive on
23222AVR so that accumulating the stack space might lead to smaller
23223executables because arguments need not be removed from the
23224stack after such a function call.
23225
23226This option can lead to reduced code size for functions that perform
23227several calls to functions that get their arguments on the stack like
23228calls to printf-like functions.
23229
d77de738 23230@opindex mbranch-cost
ddf6fe37 23231@item -mbranch-cost=@var{cost}
d77de738
ML
23232Set the branch costs for conditional branch instructions to
23233@var{cost}. Reasonable values for @var{cost} are small, non-negative
23234integers. The default branch cost is 0.
23235
d77de738 23236@opindex mcall-prologues
ddf6fe37 23237@item -mcall-prologues
d77de738
ML
23238Functions prologues/epilogues are expanded as calls to appropriate
23239subroutines. Code size is smaller.
23240
d77de738
ML
23241@opindex mdouble
23242@opindex mlong-double
ddf6fe37
AA
23243@item -mdouble=@var{bits}
23244@itemx -mlong-double=@var{bits}
d77de738
ML
23245Set the size (in bits) of the @code{double} or @code{long double} type,
23246respectively. Possible values for @var{bits} are 32 and 64.
23247Whether or not a specific value for @var{bits} is allowed depends on
23248the @code{--with-double=} and @code{--with-long-double=}
23249@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
23250and the same applies for the default values of the options.
23251
d77de738 23252@opindex mgas-isr-prologues
ddf6fe37 23253@item -mgas-isr-prologues
d77de738
ML
23254Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
23255instruction supported by GNU Binutils.
23256If this option is on, the feature can still be disabled for individual
23257ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
23258function attribute. This feature is activated per default
23259if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
23260and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
23261
d77de738 23262@opindex mint8
ddf6fe37 23263@item -mint8
d77de738
ML
23264Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
23265@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
23266and @code{long long} is 4 bytes. Please note that this option does not
23267conform to the C standards, but it results in smaller code
23268size.
23269
d77de738 23270@opindex mmain-is-OS_task
ddf6fe37 23271@item -mmain-is-OS_task
d77de738
ML
23272Do not save registers in @code{main}. The effect is the same like
23273attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
23274to @code{main}. It is activated per default if optimization is on.
23275
d77de738 23276@opindex mn-flash
ddf6fe37 23277@item -mn-flash=@var{num}
d77de738
ML
23278Assume that the flash memory has a size of
23279@var{num} times 64@tie{}KiB.
23280
d77de738 23281@opindex mno-interrupts
ddf6fe37 23282@item -mno-interrupts
d77de738
ML
23283Generated code is not compatible with hardware interrupts.
23284Code size is smaller.
23285
d77de738 23286@opindex mrelax
ddf6fe37 23287@item -mrelax
d77de738
ML
23288Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
23289@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
23290Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
23291the assembler's command line and the @option{--relax} option to the
23292linker's command line.
23293
23294Jump relaxing is performed by the linker because jump offsets are not
23295known before code is located. Therefore, the assembler code generated by the
23296compiler is the same, but the instructions in the executable may
23297differ from instructions in the assembler code.
23298
23299Relaxing must be turned on if linker stubs are needed, see the
23300section on @code{EIND} and linker stubs below.
23301
d77de738 23302@opindex mrmw
ddf6fe37 23303@item -mrmw
d77de738
ML
23304Assume that the device supports the Read-Modify-Write
23305instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
23306
d77de738 23307@opindex mshort-calls
ddf6fe37 23308@item -mshort-calls
d77de738
ML
23309
23310Assume that @code{RJMP} and @code{RCALL} can target the whole
23311program memory.
23312
23313This option is used internally for multilib selection. It is
23314not an optimization option, and you don't need to set it by hand.
23315
d77de738 23316@opindex msp8
ddf6fe37 23317@item -msp8
d77de738
ML
23318Treat the stack pointer register as an 8-bit register,
23319i.e.@: assume the high byte of the stack pointer is zero.
23320In general, you don't need to set this option by hand.
23321
23322This option is used internally by the compiler to select and
23323build multilibs for architectures @code{avr2} and @code{avr25}.
23324These architectures mix devices with and without @code{SPH}.
23325For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
23326the compiler driver adds or removes this option from the compiler
23327proper's command line, because the compiler then knows if the device
23328or architecture has an 8-bit stack pointer and thus no @code{SPH}
23329register or not.
23330
d77de738 23331@opindex mstrict-X
ddf6fe37 23332@item -mstrict-X
d77de738
ML
23333Use address register @code{X} in a way proposed by the hardware. This means
23334that @code{X} is only used in indirect, post-increment or
23335pre-decrement addressing.
23336
23337Without this option, the @code{X} register may be used in the same way
23338as @code{Y} or @code{Z} which then is emulated by additional
23339instructions.
23340For example, loading a value with @code{X+const} addressing with a
23341small non-negative @code{const < 64} to a register @var{Rn} is
23342performed as
23343
23344@example
23345adiw r26, const ; X += const
23346ld @var{Rn}, X ; @var{Rn} = *X
23347sbiw r26, const ; X -= const
23348@end example
23349
d77de738 23350@opindex mtiny-stack
ddf6fe37 23351@item -mtiny-stack
d77de738
ML
23352Only change the lower 8@tie{}bits of the stack pointer.
23353
d77de738 23354@opindex mfract-convert-truncate
ddf6fe37 23355@item -mfract-convert-truncate
d77de738
ML
23356Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
23357
d77de738 23358@opindex nodevicelib
ddf6fe37 23359@item -nodevicelib
d77de738
ML
23360Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23361
d77de738 23362@opindex nodevicespecs
ddf6fe37 23363@item -nodevicespecs
d77de738
ML
23364Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23365command line. The user takes responsibility for supplying the sub-processes
23366like compiler proper, assembler and linker with appropriate command line
23367options. This means that the user has to supply her private device specs
23368file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23369more need for option @option{-mmcu=@var{mcu}}.
23370
23371This option can also serve as a replacement for the older way of
23372specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23373which contains a folder named @code{device-specs} which contains a specs file named
23374@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23375
d77de738
ML
23376@opindex Waddr-space-convert
23377@opindex Wno-addr-space-convert
ddf6fe37 23378@item -Waddr-space-convert
d77de738
ML
23379Warn about conversions between address spaces in the case where the
23380resulting address space is not contained in the incoming address space.
23381
d77de738
ML
23382@opindex Wmisspelled-isr
23383@opindex Wno-misspelled-isr
ddf6fe37 23384@item -Wmisspelled-isr
d77de738
ML
23385Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23386Enabled by default.
23387@end table
23388
23389@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23390@cindex @code{EIND}
23391Pointers in the implementation are 16@tie{}bits wide.
23392The address of a function or label is represented as word address so
23393that indirect jumps and calls can target any code address in the
23394range of 64@tie{}Ki words.
23395
23396In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23397bytes of program memory space, there is a special function register called
23398@code{EIND} that serves as most significant part of the target address
23399when @code{EICALL} or @code{EIJMP} instructions are used.
23400
23401Indirect jumps and calls on these devices are handled as follows by
23402the compiler and are subject to some limitations:
23403
23404@itemize @bullet
23405
23406@item
23407The compiler never sets @code{EIND}.
23408
23409@item
23410The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23411instructions or might read @code{EIND} directly in order to emulate an
23412indirect call/jump by means of a @code{RET} instruction.
23413
23414@item
23415The compiler assumes that @code{EIND} never changes during the startup
23416code or during the application. In particular, @code{EIND} is not
23417saved/restored in function or interrupt service routine
23418prologue/epilogue.
23419
23420@item
23421For indirect calls to functions and computed goto, the linker
23422generates @emph{stubs}. Stubs are jump pads sometimes also called
23423@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23424The stub contains a direct jump to the desired address.
23425
23426@item
23427Linker relaxation must be turned on so that the linker generates
23428the stubs correctly in all situations. See the compiler option
23429@option{-mrelax} and the linker option @option{--relax}.
23430There are corner cases where the linker is supposed to generate stubs
23431but aborts without relaxation and without a helpful error message.
23432
23433@item
23434The default linker script is arranged for code with @code{EIND = 0}.
23435If code is supposed to work for a setup with @code{EIND != 0}, a custom
23436linker script has to be used in order to place the sections whose
23437name start with @code{.trampolines} into the segment where @code{EIND}
23438points to.
23439
23440@item
23441The startup code from libgcc never sets @code{EIND}.
23442Notice that startup code is a blend of code from libgcc and AVR-LibC.
23443For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23444@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23445
23446@item
23447It is legitimate for user-specific startup code to set up @code{EIND}
23448early, for example by means of initialization code located in
23449section @code{.init3}. Such code runs prior to general startup code
23450that initializes RAM and calls constructors, but after the bit
23451of startup code from AVR-LibC that sets @code{EIND} to the segment
23452where the vector table is located.
23453@example
23454#include <avr/io.h>
23455
23456static void
23457__attribute__((section(".init3"),naked,used,no_instrument_function))
23458init3_set_eind (void)
23459@{
23460 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
23461 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
23462@}
23463@end example
23464
23465@noindent
23466The @code{__trampolines_start} symbol is defined in the linker script.
23467
23468@item
23469Stubs are generated automatically by the linker if
23470the following two conditions are met:
23471@itemize @minus
23472
23473@item The address of a label is taken by means of the @code{gs} modifier
23474(short for @emph{generate stubs}) like so:
23475@example
23476LDI r24, lo8(gs(@var{func}))
23477LDI r25, hi8(gs(@var{func}))
23478@end example
23479@item The final location of that label is in a code segment
23480@emph{outside} the segment where the stubs are located.
23481@end itemize
23482
23483@item
23484The compiler emits such @code{gs} modifiers for code labels in the
23485following situations:
23486@itemize @minus
23487@item Taking address of a function or code label.
23488@item Computed goto.
23489@item If prologue-save function is used, see @option{-mcall-prologues}
23490command-line option.
23491@item Switch/case dispatch tables. If you do not want such dispatch
23492tables you can specify the @option{-fno-jump-tables} command-line option.
23493@item C and C++ constructors/destructors called during startup/shutdown.
23494@item If the tools hit a @code{gs()} modifier explained above.
23495@end itemize
23496
23497@item
23498Jumping to non-symbolic addresses like so is @emph{not} supported:
23499
23500@example
23501int main (void)
23502@{
23503 /* Call function at word address 0x2 */
23504 return ((int(*)(void)) 0x2)();
23505@}
23506@end example
23507
23508Instead, a stub has to be set up, i.e.@: the function has to be called
23509through a symbol (@code{func_4} in the example):
23510
23511@example
23512int main (void)
23513@{
23514 extern int func_4 (void);
23515
23516 /* Call function at byte address 0x4 */
23517 return func_4();
23518@}
23519@end example
23520
23521and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23522Alternatively, @code{func_4} can be defined in the linker script.
23523@end itemize
23524
23525@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23526@cindex @code{RAMPD}
23527@cindex @code{RAMPX}
23528@cindex @code{RAMPY}
23529@cindex @code{RAMPZ}
23530Some AVR devices support memories larger than the 64@tie{}KiB range
23531that can be accessed with 16-bit pointers. To access memory locations
23532outside this 64@tie{}KiB range, the content of a @code{RAMP}
23533register is used as high part of the address:
23534The @code{X}, @code{Y}, @code{Z} address register is concatenated
23535with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23536register, respectively, to get a wide address. Similarly,
23537@code{RAMPD} is used together with direct addressing.
23538
23539@itemize
23540@item
23541The startup code initializes the @code{RAMP} special function
23542registers with zero.
23543
23544@item
23545If a @ref{AVR Named Address Spaces,named address space} other than
23546generic or @code{__flash} is used, then @code{RAMPZ} is set
23547as needed before the operation.
23548
23549@item
23550If the device supports RAM larger than 64@tie{}KiB and the compiler
23551needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23552is reset to zero after the operation.
23553
23554@item
23555If the device comes with a specific @code{RAMP} register, the ISR
23556prologue/epilogue saves/restores that SFR and initializes it with
23557zero in case the ISR code might (implicitly) use it.
23558
23559@item
23560RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23561If you use inline assembler to read from locations outside the
2356216-bit address range and change one of the @code{RAMP} registers,
23563you must reset it to zero after the access.
23564
23565@end itemize
23566
23567@subsubsection AVR Built-in Macros
23568
23569GCC defines several built-in macros so that the user code can test
23570for the presence or absence of features. Almost any of the following
23571built-in macros are deduced from device capabilities and thus
23572triggered by the @option{-mmcu=} command-line option.
23573
23574For even more AVR-specific built-in macros see
23575@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23576
23577@table @code
23578
23579@item __AVR_ARCH__
23580Build-in macro that resolves to a decimal number that identifies the
23581architecture and depends on the @option{-mmcu=@var{mcu}} option.
23582Possible values are:
23583
23584@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23585@code{4}, @code{5}, @code{51}, @code{6}
23586
23587for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23588@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23589
23590respectively and
23591
23592@code{100},
23593@code{102}, @code{103}, @code{104},
23594@code{105}, @code{106}, @code{107}
23595
23596for @var{mcu}=@code{avrtiny},
23597@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23598@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23599If @var{mcu} specifies a device, this built-in macro is set
23600accordingly. For example, with @option{-mmcu=atmega8} the macro is
23601defined to @code{4}.
23602
23603@item __AVR_@var{Device}__
23604Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23605the device's name. For example, @option{-mmcu=atmega8} defines the
23606built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23607@code{__AVR_ATtiny261A__}, etc.
23608
23609The built-in macros' names follow
23610the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23611the device name as from the AVR user manual. The difference between
23612@var{Device} in the built-in macro and @var{device} in
23613@option{-mmcu=@var{device}} is that the latter is always lowercase.
23614
23615If @var{device} is not a device but only a core architecture like
23616@samp{avr51}, this macro is not defined.
23617
23618@item __AVR_DEVICE_NAME__
23619Setting @option{-mmcu=@var{device}} defines this built-in macro to
23620the device's name. For example, with @option{-mmcu=atmega8} the macro
23621is defined to @code{atmega8}.
23622
23623If @var{device} is not a device but only a core architecture like
23624@samp{avr51}, this macro is not defined.
23625
23626@item __AVR_XMEGA__
23627The device / architecture belongs to the XMEGA family of devices.
23628
23629@item __AVR_HAVE_ELPM__
23630The device has the @code{ELPM} instruction.
23631
23632@item __AVR_HAVE_ELPMX__
23633The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23634R@var{n},Z+} instructions.
23635
23636@item __AVR_HAVE_MOVW__
23637The device has the @code{MOVW} instruction to perform 16-bit
23638register-register moves.
23639
23640@item __AVR_HAVE_LPMX__
23641The device has the @code{LPM R@var{n},Z} and
23642@code{LPM R@var{n},Z+} instructions.
23643
23644@item __AVR_HAVE_MUL__
23645The device has a hardware multiplier.
23646
23647@item __AVR_HAVE_JMP_CALL__
23648The device has the @code{JMP} and @code{CALL} instructions.
23649This is the case for devices with more than 8@tie{}KiB of program
23650memory.
23651
23652@item __AVR_HAVE_EIJMP_EICALL__
23653@itemx __AVR_3_BYTE_PC__
23654The device has the @code{EIJMP} and @code{EICALL} instructions.
23655This is the case for devices with more than 128@tie{}KiB of program memory.
23656This also means that the program counter
23657(PC) is 3@tie{}bytes wide.
23658
23659@item __AVR_2_BYTE_PC__
23660The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23661with up to 128@tie{}KiB of program memory.
23662
23663@item __AVR_HAVE_8BIT_SP__
23664@itemx __AVR_HAVE_16BIT_SP__
23665The stack pointer (SP) register is treated as 8-bit respectively
2366616-bit register by the compiler.
23667The definition of these macros is affected by @option{-mtiny-stack}.
23668
23669@item __AVR_HAVE_SPH__
23670@itemx __AVR_SP8__
23671The device has the SPH (high part of stack pointer) special function
23672register or has an 8-bit stack pointer, respectively.
23673The definition of these macros is affected by @option{-mmcu=} and
23674in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23675by @option{-msp8}.
23676
23677@item __AVR_HAVE_RAMPD__
23678@itemx __AVR_HAVE_RAMPX__
23679@itemx __AVR_HAVE_RAMPY__
23680@itemx __AVR_HAVE_RAMPZ__
23681The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23682@code{RAMPZ} special function register, respectively.
23683
23684@item __NO_INTERRUPTS__
23685This macro reflects the @option{-mno-interrupts} command-line option.
23686
23687@item __AVR_ERRATA_SKIP__
23688@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23689Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23690instructions because of a hardware erratum. Skip instructions are
23691@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23692The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23693set.
23694
23695@item __AVR_ISA_RMW__
23696The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23697
23698@item __AVR_SFR_OFFSET__=@var{offset}
23699Instructions that can address I/O special function registers directly
23700like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23701address as if addressed by an instruction to access RAM like @code{LD}
23702or @code{STS}. This offset depends on the device architecture and has
23703to be subtracted from the RAM address in order to get the
23704respective I/O@tie{}address.
23705
23706@item __AVR_SHORT_CALLS__
23707The @option{-mshort-calls} command line option is set.
23708
23709@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23710Some devices support reading from flash memory by means of @code{LD*}
23711instructions. The flash memory is seen in the data address space
23712at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23713is not defined, this feature is not available. If defined,
23714the address space is linear and there is no need to put
23715@code{.rodata} into RAM. This is handled by the default linker
23716description file, and is currently available for
23717@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23718there is no need to use address spaces like @code{__flash} or
23719features like attribute @code{progmem} and @code{pgm_read_*}.
23720
23721@item __WITH_AVRLIBC__
23722The compiler is configured to be used together with AVR-Libc.
23723See the @option{--with-avrlibc} configure option.
23724
23725@item __HAVE_DOUBLE_MULTILIB__
23726Defined if @option{-mdouble=} acts as a multilib option.
23727
23728@item __HAVE_DOUBLE32__
23729@itemx __HAVE_DOUBLE64__
23730Defined if the compiler supports 32-bit double resp. 64-bit double.
23731The actual layout is specified by option @option{-mdouble=}.
23732
23733@item __DEFAULT_DOUBLE__
23734The size in bits of @code{double} if @option{-mdouble=} is not set.
23735To test the layout of @code{double} in a program, use the built-in
23736macro @code{__SIZEOF_DOUBLE__}.
23737
23738@item __HAVE_LONG_DOUBLE32__
23739@itemx __HAVE_LONG_DOUBLE64__
23740@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23741@itemx __DEFAULT_LONG_DOUBLE__
23742Same as above, but for @code{long double} instead of @code{double}.
23743
23744@item __WITH_DOUBLE_COMPARISON__
23745Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23746@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23747and is defined to @code{2} or @code{3}.
23748
23749@item __WITH_LIBF7_LIBGCC__
23750@itemx __WITH_LIBF7_MATH__
23751@itemx __WITH_LIBF7_MATH_SYMBOLS__
23752Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23753@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23754
23755@end table
23756
23757@node Blackfin Options
23758@subsection Blackfin Options
23759@cindex Blackfin Options
23760
23761@table @gcctabopt
d77de738 23762@opindex mcpu=
ddf6fe37 23763@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23764Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23765can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23766@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23767@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23768@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23769@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23770@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23771@samp{bf561}, @samp{bf592}.
23772
23773The optional @var{sirevision} specifies the silicon revision of the target
23774Blackfin processor. Any workarounds available for the targeted silicon revision
23775are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23776If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23777are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23778hexadecimal digits representing the major and minor numbers in the silicon
23779revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23780is not defined. If @var{sirevision} is @samp{any}, the
23781@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23782If this optional @var{sirevision} is not used, GCC assumes the latest known
23783silicon revision of the targeted Blackfin processor.
23784
23785GCC defines a preprocessor macro for the specified @var{cpu}.
23786For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23787provided by libgloss to be linked in if @option{-msim} is not given.
23788
23789Without this option, @samp{bf532} is used as the processor by default.
23790
23791Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23792only the preprocessor macro is defined.
23793
d77de738 23794@opindex msim
ddf6fe37 23795@item -msim
d77de738
ML
23796Specifies that the program will be run on the simulator. This causes
23797the simulator BSP provided by libgloss to be linked in. This option
23798has effect only for @samp{bfin-elf} toolchain.
23799Certain other options, such as @option{-mid-shared-library} and
23800@option{-mfdpic}, imply @option{-msim}.
23801
d77de738 23802@opindex momit-leaf-frame-pointer
ddf6fe37 23803@item -momit-leaf-frame-pointer
d77de738
ML
23804Don't keep the frame pointer in a register for leaf functions. This
23805avoids the instructions to save, set up and restore frame pointers and
23806makes an extra register available in leaf functions.
23807
d77de738 23808@opindex mspecld-anomaly
ddf6fe37 23809@item -mspecld-anomaly
d77de738
ML
23810When enabled, the compiler ensures that the generated code does not
23811contain speculative loads after jump instructions. If this option is used,
23812@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23813
d77de738
ML
23814@opindex mno-specld-anomaly
23815@opindex mspecld-anomaly
ddf6fe37 23816@item -mno-specld-anomaly
d77de738
ML
23817Don't generate extra code to prevent speculative loads from occurring.
23818
d77de738 23819@opindex mcsync-anomaly
ddf6fe37 23820@item -mcsync-anomaly
d77de738
ML
23821When enabled, the compiler ensures that the generated code does not
23822contain CSYNC or SSYNC instructions too soon after conditional branches.
23823If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23824
d77de738
ML
23825@opindex mno-csync-anomaly
23826@opindex mcsync-anomaly
ddf6fe37 23827@item -mno-csync-anomaly
d77de738
ML
23828Don't generate extra code to prevent CSYNC or SSYNC instructions from
23829occurring too soon after a conditional branch.
23830
d77de738 23831@opindex mlow64k
ddf6fe37 23832@item -mlow64k
d77de738
ML
23833When enabled, the compiler is free to take advantage of the knowledge that
23834the entire program fits into the low 64k of memory.
23835
d77de738 23836@opindex mno-low64k
ddf6fe37 23837@item -mno-low64k
d77de738
ML
23838Assume that the program is arbitrarily large. This is the default.
23839
d77de738 23840@opindex mstack-check-l1
ddf6fe37 23841@item -mstack-check-l1
d77de738
ML
23842Do stack checking using information placed into L1 scratchpad memory by the
23843uClinux kernel.
23844
d77de738 23845@opindex mid-shared-library
ddf6fe37 23846@item -mid-shared-library
d77de738
ML
23847Generate code that supports shared libraries via the library ID method.
23848This allows for execute in place and shared libraries in an environment
23849without virtual memory management. This option implies @option{-fPIC}.
23850With a @samp{bfin-elf} target, this option implies @option{-msim}.
23851
d77de738
ML
23852@opindex mno-id-shared-library
23853@opindex mid-shared-library
ddf6fe37 23854@item -mno-id-shared-library
d77de738
ML
23855Generate code that doesn't assume ID-based shared libraries are being used.
23856This is the default.
23857
d77de738 23858@opindex mleaf-id-shared-library
ddf6fe37 23859@item -mleaf-id-shared-library
d77de738
ML
23860Generate code that supports shared libraries via the library ID method,
23861but assumes that this library or executable won't link against any other
23862ID shared libraries. That allows the compiler to use faster code for jumps
23863and calls.
23864
d77de738
ML
23865@opindex mno-leaf-id-shared-library
23866@opindex mleaf-id-shared-library
ddf6fe37 23867@item -mno-leaf-id-shared-library
d77de738
ML
23868Do not assume that the code being compiled won't link against any ID shared
23869libraries. Slower code is generated for jump and call insns.
23870
d77de738 23871@opindex mshared-library-id
ddf6fe37 23872@item -mshared-library-id=n
d77de738
ML
23873Specifies the identification number of the ID-based shared library being
23874compiled. Specifying a value of 0 generates more compact code; specifying
23875other values forces the allocation of that number to the current
23876library but is no more space- or time-efficient than omitting this option.
23877
d77de738 23878@opindex msep-data
ddf6fe37 23879@item -msep-data
d77de738
ML
23880Generate code that allows the data segment to be located in a different
23881area of memory from the text segment. This allows for execute in place in
23882an environment without virtual memory management by eliminating relocations
23883against the text section.
23884
d77de738
ML
23885@opindex mno-sep-data
23886@opindex msep-data
ddf6fe37 23887@item -mno-sep-data
d77de738
ML
23888Generate code that assumes that the data segment follows the text segment.
23889This is the default.
23890
d77de738
ML
23891@opindex mlong-calls
23892@opindex mno-long-calls
ddf6fe37
AA
23893@item -mlong-calls
23894@itemx -mno-long-calls
d77de738
ML
23895Tells the compiler to perform function calls by first loading the
23896address of the function into a register and then performing a subroutine
23897call on this register. This switch is needed if the target function
23898lies outside of the 24-bit addressing range of the offset-based
23899version of subroutine call instruction.
23900
23901This feature is not enabled by default. Specifying
23902@option{-mno-long-calls} restores the default behavior. Note these
23903switches have no effect on how the compiler generates code to handle
23904function calls via function pointers.
23905
d77de738 23906@opindex mfast-fp
ddf6fe37 23907@item -mfast-fp
d77de738
ML
23908Link with the fast floating-point library. This library relaxes some of
23909the IEEE floating-point standard's rules for checking inputs against
23910Not-a-Number (NAN), in the interest of performance.
23911
d77de738 23912@opindex minline-plt
ddf6fe37 23913@item -minline-plt
d77de738
ML
23914Enable inlining of PLT entries in function calls to functions that are
23915not known to bind locally. It has no effect without @option{-mfdpic}.
23916
d77de738 23917@opindex mmulticore
ddf6fe37 23918@item -mmulticore
d77de738
ML
23919Build a standalone application for multicore Blackfin processors.
23920This option causes proper start files and link scripts supporting
23921multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23922It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23923
23924This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23925selects the one-application-per-core programming model. Without
23926@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23927programming model is used. In this model, the main function of Core B
23928should be named as @code{coreb_main}.
23929
23930If this option is not used, the single-core application programming
23931model is used.
23932
d77de738 23933@opindex mcorea
ddf6fe37 23934@item -mcorea
d77de738
ML
23935Build a standalone application for Core A of BF561 when using
23936the one-application-per-core programming model. Proper start files
23937and link scripts are used to support Core A, and the macro
23938@code{__BFIN_COREA} is defined.
23939This option can only be used in conjunction with @option{-mmulticore}.
23940
d77de738 23941@opindex mcoreb
ddf6fe37 23942@item -mcoreb
d77de738
ML
23943Build a standalone application for Core B of BF561 when using
23944the one-application-per-core programming model. Proper start files
23945and link scripts are used to support Core B, and the macro
23946@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23947should be used instead of @code{main}.
23948This option can only be used in conjunction with @option{-mmulticore}.
23949
d77de738 23950@opindex msdram
ddf6fe37 23951@item -msdram
d77de738
ML
23952Build a standalone application for SDRAM. Proper start files and
23953link scripts are used to put the application into SDRAM, and the macro
23954@code{__BFIN_SDRAM} is defined.
23955The loader should initialize SDRAM before loading the application.
23956
d77de738 23957@opindex micplb
ddf6fe37 23958@item -micplb
d77de738
ML
23959Assume that ICPLBs are enabled at run time. This has an effect on certain
23960anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23961are enabled; for standalone applications the default is off.
23962@end table
23963
23964@node C6X Options
23965@subsection C6X Options
23966@cindex C6X Options
23967
23968@table @gcctabopt
d77de738 23969@opindex march
ddf6fe37 23970@item -march=@var{name}
d77de738
ML
23971This specifies the name of the target architecture. GCC uses this
23972name to determine what kind of instructions it can emit when generating
23973assembly code. Permissible names are: @samp{c62x},
23974@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23975
d77de738 23976@opindex mbig-endian
ddf6fe37 23977@item -mbig-endian
d77de738
ML
23978Generate code for a big-endian target.
23979
d77de738 23980@opindex mlittle-endian
ddf6fe37 23981@item -mlittle-endian
d77de738
ML
23982Generate code for a little-endian target. This is the default.
23983
d77de738 23984@opindex msim
ddf6fe37 23985@item -msim
d77de738
ML
23986Choose startup files and linker script suitable for the simulator.
23987
d77de738 23988@opindex msdata=default
ddf6fe37 23989@item -msdata=default
d77de738
ML
23990Put small global and static data in the @code{.neardata} section,
23991which is pointed to by register @code{B14}. Put small uninitialized
23992global and static data in the @code{.bss} section, which is adjacent
23993to the @code{.neardata} section. Put small read-only data into the
23994@code{.rodata} section. The corresponding sections used for large
23995pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23996
d77de738 23997@opindex msdata=all
ddf6fe37 23998@item -msdata=all
d77de738
ML
23999Put all data, not just small objects, into the sections reserved for
24000small data, and use addressing relative to the @code{B14} register to
24001access them.
24002
d77de738 24003@opindex msdata=none
ddf6fe37 24004@item -msdata=none
d77de738
ML
24005Make no use of the sections reserved for small data, and use absolute
24006addresses to access all data. Put all initialized global and static
24007data in the @code{.fardata} section, and all uninitialized data in the
24008@code{.far} section. Put all constant data into the @code{.const}
24009section.
24010@end table
24011
24012@node CRIS Options
24013@subsection CRIS Options
24014@cindex CRIS Options
24015
24016These options are defined specifically for the CRIS ports.
24017
24018@table @gcctabopt
d77de738
ML
24019@opindex march
24020@opindex mcpu
ddf6fe37
AA
24021@item -march=@var{architecture-type}
24022@itemx -mcpu=@var{architecture-type}
d77de738
ML
24023Generate code for the specified architecture. The choices for
24024@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
24025respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
24026Default is @samp{v0}.
24027
d77de738 24028@opindex mtune
ddf6fe37 24029@item -mtune=@var{architecture-type}
d77de738
ML
24030Tune to @var{architecture-type} everything applicable about the generated
24031code, except for the ABI and the set of available instructions. The
24032choices for @var{architecture-type} are the same as for
24033@option{-march=@var{architecture-type}}.
24034
d77de738 24035@opindex mmax-stack-frame
ddf6fe37 24036@item -mmax-stack-frame=@var{n}
d77de738
ML
24037Warn when the stack frame of a function exceeds @var{n} bytes.
24038
d77de738
ML
24039@opindex metrax4
24040@opindex metrax100
ddf6fe37
AA
24041@item -metrax4
24042@itemx -metrax100
d77de738
ML
24043The options @option{-metrax4} and @option{-metrax100} are synonyms for
24044@option{-march=v3} and @option{-march=v8} respectively.
24045
d77de738
ML
24046@opindex mmul-bug-workaround
24047@opindex mno-mul-bug-workaround
ddf6fe37
AA
24048@item -mmul-bug-workaround
24049@itemx -mno-mul-bug-workaround
d77de738
ML
24050Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
24051models where it applies. This option is disabled by default.
24052
d77de738 24053@opindex mpdebug
ddf6fe37 24054@item -mpdebug
d77de738
ML
24055Enable CRIS-specific verbose debug-related information in the assembly
24056code. This option also has the effect of turning off the @samp{#NO_APP}
24057formatted-code indicator to the assembler at the beginning of the
24058assembly file.
24059
d77de738 24060@opindex mcc-init
ddf6fe37 24061@item -mcc-init
d77de738
ML
24062Do not use condition-code results from previous instruction; always emit
24063compare and test instructions before use of condition codes.
24064
d77de738
ML
24065@opindex mno-side-effects
24066@opindex mside-effects
ddf6fe37 24067@item -mno-side-effects
d77de738
ML
24068Do not emit instructions with side effects in addressing modes other than
24069post-increment.
24070
d77de738
ML
24071@opindex mstack-align
24072@opindex mno-stack-align
24073@opindex mdata-align
24074@opindex mno-data-align
24075@opindex mconst-align
24076@opindex mno-const-align
ddf6fe37
AA
24077@item -mstack-align
24078@itemx -mno-stack-align
24079@itemx -mdata-align
24080@itemx -mno-data-align
24081@itemx -mconst-align
24082@itemx -mno-const-align
d77de738
ML
24083These options (@samp{no-} options) arrange (eliminate arrangements) for the
24084stack frame, individual data and constants to be aligned for the maximum
24085single data access size for the chosen CPU model. The default is to
24086arrange for 32-bit alignment. ABI details such as structure layout are
24087not affected by these options.
24088
d77de738
ML
24089@opindex m32-bit
24090@opindex m16-bit
24091@opindex m8-bit
ddf6fe37
AA
24092@item -m32-bit
24093@itemx -m16-bit
24094@itemx -m8-bit
d77de738
ML
24095Similar to the stack- data- and const-align options above, these options
24096arrange for stack frame, writable data and constants to all be 32-bit,
2409716-bit or 8-bit aligned. The default is 32-bit alignment.
24098
d77de738
ML
24099@opindex mno-prologue-epilogue
24100@opindex mprologue-epilogue
ddf6fe37
AA
24101@item -mno-prologue-epilogue
24102@itemx -mprologue-epilogue
d77de738
ML
24103With @option{-mno-prologue-epilogue}, the normal function prologue and
24104epilogue which set up the stack frame are omitted and no return
24105instructions or return sequences are generated in the code. Use this
24106option only together with visual inspection of the compiled code: no
24107warnings or errors are generated when call-saved registers must be saved,
24108or storage for local variables needs to be allocated.
24109
d77de738 24110@opindex melf
ddf6fe37 24111@item -melf
d77de738
ML
24112Legacy no-op option.
24113
d77de738 24114@opindex sim
ddf6fe37 24115@item -sim
d77de738
ML
24116This option arranges
24117to link with input-output functions from a simulator library. Code,
24118initialized data and zero-initialized data are allocated consecutively.
24119
d77de738 24120@opindex sim2
ddf6fe37 24121@item -sim2
d77de738
ML
24122Like @option{-sim}, but pass linker options to locate initialized data at
241230x40000000 and zero-initialized data at 0x80000000.
24124@end table
24125
24126@node C-SKY Options
24127@subsection C-SKY Options
24128@cindex C-SKY Options
24129
24130GCC supports these options when compiling for C-SKY V2 processors.
24131
24132@table @gcctabopt
24133
d77de738 24134@opindex march=
ddf6fe37 24135@item -march=@var{arch}
d77de738
ML
24136Specify the C-SKY target architecture. Valid values for @var{arch} are:
24137@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
24138The default is @samp{ck810}.
24139
d77de738 24140@opindex mcpu=
ddf6fe37 24141@item -mcpu=@var{cpu}
d77de738
ML
24142Specify the C-SKY target processor. Valid values for @var{cpu} are:
24143@samp{ck801}, @samp{ck801t},
24144@samp{ck802}, @samp{ck802t}, @samp{ck802j},
24145@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
24146@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
24147@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
24148@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
24149@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
24150@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
24151@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
24152@samp{ck803eftr1}, @samp{ck803efhtr1},
24153@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
24154@samp{ck803sef}, @samp{ck803seft},
24155@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
24156@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
24157@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
24158@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
24159
d77de738 24160@opindex mbig-endian
d77de738 24161@opindex EB
d77de738 24162@opindex mlittle-endian
d77de738 24163@opindex EL
ddf6fe37
AA
24164@item -mbig-endian
24165@itemx -EB
24166@itemx -mlittle-endian
24167@itemx -EL
d77de738
ML
24168
24169Select big- or little-endian code. The default is little-endian.
24170
d77de738 24171@opindex mfloat-abi
ddf6fe37 24172@item -mfloat-abi=@var{name}
d77de738
ML
24173Specifies which floating-point ABI to use. Permissible values
24174are: @samp{soft}, @samp{softfp} and @samp{hard}.
24175
24176Specifying @samp{soft} causes GCC to generate output containing
24177library calls for floating-point operations.
24178@samp{softfp} allows the generation of code using hardware floating-point
24179instructions, but still uses the soft-float calling conventions.
24180@samp{hard} allows generation of floating-point instructions
24181and uses FPU-specific calling conventions.
24182
24183The default depends on the specific target configuration. Note that
24184the hard-float and soft-float ABIs are not link-compatible; you must
24185compile your entire program with the same ABI, and link with a
24186compatible set of libraries.
24187
d77de738 24188@opindex mhard-float
d77de738 24189@opindex msoft-float
ddf6fe37
AA
24190@item -mhard-float
24191@itemx -msoft-float
d77de738
ML
24192
24193Select hardware or software floating-point implementations.
24194The default is soft float.
24195
ddf6fe37 24196@opindex mdouble-float
d77de738
ML
24197@item -mdouble-float
24198@itemx -mno-double-float
d77de738
ML
24199When @option{-mhard-float} is in effect, enable generation of
24200double-precision float instructions. This is the default except
24201when compiling for CK803.
24202
ddf6fe37 24203@opindex mfdivdu
d77de738
ML
24204@item -mfdivdu
24205@itemx -mno-fdivdu
d77de738
ML
24206When @option{-mhard-float} is in effect, enable generation of
24207@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
24208This is the default except when compiling for CK803.
24209
d77de738 24210@opindex mfpu=
ddf6fe37 24211@item -mfpu=@var{fpu}
d77de738
ML
24212Select the floating-point processor. This option can only be used with
24213@option{-mhard-float}.
24214Values for @var{fpu} are
24215@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
24216@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
24217@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
24218
ddf6fe37 24219@opindex melrw
d77de738
ML
24220@item -melrw
24221@itemx -mno-elrw
d77de738
ML
24222Enable the extended @code{lrw} instruction. This option defaults to on
24223for CK801 and off otherwise.
24224
ddf6fe37 24225@opindex mistack
d77de738
ML
24226@item -mistack
24227@itemx -mno-istack
d77de738
ML
24228Enable interrupt stack instructions; the default is off.
24229
24230The @option{-mistack} option is required to handle the
24231@code{interrupt} and @code{isr} function attributes
24232(@pxref{C-SKY Function Attributes}).
24233
d77de738 24234@opindex mmp
ddf6fe37 24235@item -mmp
d77de738
ML
24236Enable multiprocessor instructions; the default is off.
24237
d77de738 24238@opindex mcp
ddf6fe37 24239@item -mcp
d77de738
ML
24240Enable coprocessor instructions; the default is off.
24241
d77de738 24242@opindex mcache
ddf6fe37 24243@item -mcache
d77de738
ML
24244Enable coprocessor instructions; the default is off.
24245
d77de738 24246@opindex msecurity
ddf6fe37 24247@item -msecurity
d77de738
ML
24248Enable C-SKY security instructions; the default is off.
24249
d77de738 24250@opindex mtrust
ddf6fe37 24251@item -mtrust
d77de738
ML
24252Enable C-SKY trust instructions; the default is off.
24253
d77de738 24254@opindex mdsp
d77de738 24255@opindex medsp
d77de738 24256@opindex mvdsp
ddf6fe37
AA
24257@item -mdsp
24258@itemx -medsp
24259@itemx -mvdsp
d77de738
ML
24260Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
24261All of these options default to off.
24262
ddf6fe37 24263@opindex mdiv
d77de738
ML
24264@item -mdiv
24265@itemx -mno-div
d77de738
ML
24266Generate divide instructions. Default is off.
24267
ddf6fe37 24268@opindex msmart
d77de738
ML
24269@item -msmart
24270@itemx -mno-smart
d77de738
ML
24271Generate code for Smart Mode, using only registers numbered 0-7 to allow
24272use of 16-bit instructions. This option is ignored for CK801 where this
24273is the required behavior, and it defaults to on for CK802.
24274For other targets, the default is off.
24275
ddf6fe37 24276@opindex mhigh-registers
d77de738
ML
24277@item -mhigh-registers
24278@itemx -mno-high-registers
d77de738
ML
24279Generate code using the high registers numbered 16-31. This option
24280is not supported on CK801, CK802, or CK803, and is enabled by default
24281for other processors.
24282
ddf6fe37 24283@opindex manchor
d77de738
ML
24284@item -manchor
24285@itemx -mno-anchor
d77de738
ML
24286Generate code using global anchor symbol addresses.
24287
ddf6fe37 24288@opindex mpushpop
d77de738
ML
24289@item -mpushpop
24290@itemx -mno-pushpop
d77de738
ML
24291Generate code using @code{push} and @code{pop} instructions. This option
24292defaults to on.
24293
ddf6fe37 24294@opindex mmultiple-stld
d77de738
ML
24295@item -mmultiple-stld
24296@itemx -mstm
24297@itemx -mno-multiple-stld
24298@itemx -mno-stm
d77de738
ML
24299Generate code using @code{stm} and @code{ldm} instructions. This option
24300isn't supported on CK801 but is enabled by default on other processors.
24301
ddf6fe37 24302@opindex mconstpool
d77de738
ML
24303@item -mconstpool
24304@itemx -mno-constpool
d77de738
ML
24305Create constant pools in the compiler instead of deferring it to the
24306assembler. This option is the default and required for correct code
24307generation on CK801 and CK802, and is optional on other processors.
24308
ddf6fe37 24309@opindex mstack-size
d77de738
ML
24310@item -mstack-size
24311@item -mno-stack-size
d77de738
ML
24312Emit @code{.stack_size} directives for each function in the assembly
24313output. This option defaults to off.
24314
ddf6fe37 24315@opindex mccrt
d77de738
ML
24316@item -mccrt
24317@itemx -mno-ccrt
d77de738
ML
24318Generate code for the C-SKY compiler runtime instead of libgcc. This
24319option defaults to off.
24320
d77de738 24321@opindex mbranch-cost=
ddf6fe37 24322@item -mbranch-cost=@var{n}
d77de738
ML
24323Set the branch costs to roughly @code{n} instructions. The default is 1.
24324
ddf6fe37 24325@opindex msched-prolog
d77de738
ML
24326@item -msched-prolog
24327@itemx -mno-sched-prolog
d77de738
ML
24328Permit scheduling of function prologue and epilogue sequences. Using
24329this option can result in code that is not compliant with the C-SKY V2 ABI
24330prologue requirements and that cannot be debugged or backtraced.
24331It is disabled by default.
24332
d77de738 24333@opindex msim
ddf6fe37 24334@item -msim
d77de738
ML
24335Links the library libsemi.a which is in compatible with simulator. Applicable
24336to ELF compiler only.
24337
24338@end table
24339
24340@node Darwin Options
24341@subsection Darwin Options
24342@cindex Darwin options
24343
24344These options are defined for all architectures running the Darwin operating
24345system.
24346
24347FSF GCC on Darwin does not create ``fat'' object files; it creates
24348an object file for the single architecture that GCC was built to
24349target. Apple's GCC on Darwin does create ``fat'' files if multiple
24350@option{-arch} options are used; it does so by running the compiler or
24351linker multiple times and joining the results together with
24352@file{lipo}.
24353
24354The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
24355@samp{i686}) is determined by the flags that specify the ISA
24356that GCC is targeting, like @option{-mcpu} or @option{-march}. The
24357@option{-force_cpusubtype_ALL} option can be used to override this.
24358
24359The Darwin tools vary in their behavior when presented with an ISA
24360mismatch. The assembler, @file{as}, only permits instructions to
24361be used that are valid for the subtype of the file it is generating,
24362so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24363The linker for shared libraries, @file{/usr/bin/libtool}, fails
24364and prints an error if asked to create a shared library with a less
24365restrictive subtype than its input files (for instance, trying to put
24366a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24367for executables, @command{ld}, quietly gives the executable the most
24368restrictive subtype of any of its input files.
24369
24370@table @gcctabopt
d77de738 24371@opindex F
ddf6fe37 24372@item -F@var{dir}
d77de738
ML
24373Add the framework directory @var{dir} to the head of the list of
24374directories to be searched for header files. These directories are
24375interleaved with those specified by @option{-I} options and are
24376scanned in a left-to-right order.
24377
24378A framework directory is a directory with frameworks in it. A
24379framework is a directory with a @file{Headers} and/or
24380@file{PrivateHeaders} directory contained directly in it that ends
24381in @file{.framework}. The name of a framework is the name of this
24382directory excluding the @file{.framework}. Headers associated with
24383the framework are found in one of those two directories, with
24384@file{Headers} being searched first. A subframework is a framework
24385directory that is in a framework's @file{Frameworks} directory.
24386Includes of subframework headers can only appear in a header of a
24387framework that contains the subframework, or in a sibling subframework
24388header. Two subframeworks are siblings if they occur in the same
24389framework. A subframework should not have the same name as a
24390framework; a warning is issued if this is violated. Currently a
24391subframework cannot have subframeworks; in the future, the mechanism
24392may be extended to support this. The standard frameworks can be found
24393in @file{/System/Library/Frameworks} and
24394@file{/Library/Frameworks}. An example include looks like
24395@code{#include <Framework/header.h>}, where @file{Framework} denotes
24396the name of the framework and @file{header.h} is found in the
24397@file{PrivateHeaders} or @file{Headers} directory.
24398
d77de738 24399@opindex iframework
ddf6fe37 24400@item -iframework@var{dir}
d77de738
ML
24401Like @option{-F} except the directory is a treated as a system
24402directory. The main difference between this @option{-iframework} and
24403@option{-F} is that with @option{-iframework} the compiler does not
24404warn about constructs contained within header files found via
24405@var{dir}. This option is valid only for the C family of languages.
24406
d77de738 24407@opindex gused
ddf6fe37 24408@item -gused
d77de738
ML
24409Emit debugging information for symbols that are used. For stabs
24410debugging format, this enables @option{-feliminate-unused-debug-symbols}.
24411This is by default ON@.
24412
d77de738 24413@opindex gfull
ddf6fe37 24414@item -gfull
d77de738
ML
24415Emit debugging information for all symbols and types.
24416
cdd4b3c0
IS
24417@opindex fconstant-cfstrings
24418@item -fconstant-cfstrings
24419The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
24420
24421@opindex mconstant-cfstrings
24422@item -mconstant-cfstrings
24423When the NeXT runtime is being used (the default on these systems), override
24424any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
24425literals to be laid out as constant CoreFoundation strings.
24426
24427@opindex mmacosx-version-min
d77de738 24428@item -mmacosx-version-min=@var{version}
cdd4b3c0
IS
24429The earliest version of MacOS X that this executable will run on is
24430@var{version}. Typical values supported for @var{version} include @code{12},
24431@code{10.12}, and @code{10.5.8}.
d77de738
ML
24432
24433If the compiler was built to use the system's headers by default,
24434then the default for this option is the system version on which the
24435compiler is running, otherwise the default is to make choices that
24436are compatible with as many systems and code bases as possible.
24437
d77de738 24438@opindex mkernel
ddf6fe37 24439@item -mkernel
d77de738
ML
24440Enable kernel development mode. The @option{-mkernel} option sets
24441@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
24442@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
24443@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
24444applicable. This mode also sets @option{-mno-altivec},
24445@option{-msoft-float}, @option{-fno-builtin} and
24446@option{-mlong-branch} for PowerPC targets.
24447
d77de738 24448@opindex mone-byte-bool
ddf6fe37 24449@item -mone-byte-bool
d77de738
ML
24450Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
24451By default @code{sizeof(bool)} is @code{4} when compiling for
24452Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
24453option has no effect on x86.
24454
24455@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
24456to generate code that is not binary compatible with code generated
24457without that switch. Using this switch may require recompiling all
24458other modules in a program, including system libraries. Use this
24459switch to conform to a non-default data model.
24460
d77de738
ML
24461@opindex mfix-and-continue
24462@opindex ffix-and-continue
24463@opindex findirect-data
ddf6fe37
AA
24464@item -mfix-and-continue
24465@itemx -ffix-and-continue
24466@itemx -findirect-data
d77de738
ML
24467Generate code suitable for fast turnaround development, such as to
24468allow GDB to dynamically load @file{.o} files into already-running
24469programs. @option{-findirect-data} and @option{-ffix-and-continue}
24470are provided for backwards compatibility.
24471
d77de738 24472@opindex all_load
ddf6fe37 24473@item -all_load
d77de738
ML
24474Loads all members of static archive libraries.
24475See man ld(1) for more information.
24476
d77de738 24477@opindex arch_errors_fatal
ddf6fe37 24478@item -arch_errors_fatal
d77de738
ML
24479Cause the errors having to do with files that have the wrong architecture
24480to be fatal.
24481
d77de738 24482@opindex bind_at_load
ddf6fe37 24483@item -bind_at_load
d77de738
ML
24484Causes the output file to be marked such that the dynamic linker will
24485bind all undefined references when the file is loaded or launched.
24486
d77de738 24487@opindex bundle
ddf6fe37 24488@item -bundle
d77de738
ML
24489Produce a Mach-o bundle format file.
24490See man ld(1) for more information.
24491
d77de738 24492@opindex bundle_loader
ddf6fe37 24493@item -bundle_loader @var{executable}
d77de738
ML
24494This option specifies the @var{executable} that will load the build
24495output file being linked. See man ld(1) for more information.
24496
d77de738 24497@opindex dynamiclib
ddf6fe37 24498@item -dynamiclib
d77de738
ML
24499When passed this option, GCC produces a dynamic library instead of
24500an executable when linking, using the Darwin @file{libtool} command.
24501
d77de738 24502@opindex force_cpusubtype_ALL
ddf6fe37 24503@item -force_cpusubtype_ALL
d77de738
ML
24504This causes GCC's output file to have the @samp{ALL} subtype, instead of
24505one controlled by the @option{-mcpu} or @option{-march} option.
24506
47b634a3
FXC
24507@opindex nodefaultrpaths
24508@item -nodefaultrpaths
24509Do not add default run paths for the compiler library directories to
24510executables, modules or dynamic libraries. On macOS 10.5 and later,
24511the embedded runpath is added by default unless the user adds
24512@option{-nodefaultrpaths} to the link line. Run paths are needed
24513(and therefore enforced) to build on macOS version 10.11 or later.
24514
d77de738
ML
24515@item -allowable_client @var{client_name}
24516@itemx -client_name
24517@itemx -compatibility_version
24518@itemx -current_version
24519@itemx -dead_strip
24520@itemx -dependency-file
24521@itemx -dylib_file
24522@itemx -dylinker_install_name
24523@itemx -dynamic
24524@itemx -exported_symbols_list
24525@itemx -filelist
24526@need 800
24527@itemx -flat_namespace
24528@itemx -force_flat_namespace
24529@itemx -headerpad_max_install_names
24530@itemx -image_base
24531@itemx -init
24532@itemx -install_name
24533@itemx -keep_private_externs
24534@itemx -multi_module
24535@itemx -multiply_defined
24536@itemx -multiply_defined_unused
24537@need 800
24538@itemx -noall_load
24539@itemx -no_dead_strip_inits_and_terms
24540@itemx -nofixprebinding
24541@itemx -nomultidefs
24542@itemx -noprebind
24543@itemx -noseglinkedit
24544@itemx -pagezero_size
24545@itemx -prebind
24546@itemx -prebind_all_twolevel_modules
24547@itemx -private_bundle
24548@need 800
24549@itemx -read_only_relocs
24550@itemx -sectalign
24551@itemx -sectobjectsymbols
24552@itemx -whyload
24553@itemx -seg1addr
24554@itemx -sectcreate
24555@itemx -sectobjectsymbols
24556@itemx -sectorder
24557@itemx -segaddr
24558@itemx -segs_read_only_addr
24559@need 800
24560@itemx -segs_read_write_addr
24561@itemx -seg_addr_table
24562@itemx -seg_addr_table_filename
24563@itemx -seglinkedit
24564@itemx -segprot
24565@itemx -segs_read_only_addr
24566@itemx -segs_read_write_addr
24567@itemx -single_module
24568@itemx -static
24569@itemx -sub_library
24570@need 800
d77de738
ML
24571@opindex allowable_client
24572@opindex client_name
24573@opindex compatibility_version
24574@opindex current_version
24575@opindex dead_strip
24576@opindex dependency-file
24577@opindex dylib_file
24578@opindex dylinker_install_name
24579@opindex dynamic
24580@opindex exported_symbols_list
24581@opindex filelist
24582@opindex flat_namespace
24583@opindex force_flat_namespace
24584@opindex headerpad_max_install_names
24585@opindex image_base
24586@opindex init
24587@opindex install_name
24588@opindex keep_private_externs
24589@opindex multi_module
24590@opindex multiply_defined
24591@opindex multiply_defined_unused
24592@opindex noall_load
24593@opindex no_dead_strip_inits_and_terms
24594@opindex nofixprebinding
24595@opindex nomultidefs
24596@opindex noprebind
24597@opindex noseglinkedit
24598@opindex pagezero_size
24599@opindex prebind
24600@opindex prebind_all_twolevel_modules
24601@opindex private_bundle
24602@opindex read_only_relocs
24603@opindex sectalign
24604@opindex sectobjectsymbols
24605@opindex whyload
24606@opindex seg1addr
24607@opindex sectcreate
24608@opindex sectobjectsymbols
24609@opindex sectorder
24610@opindex segaddr
24611@opindex segs_read_only_addr
24612@opindex segs_read_write_addr
24613@opindex seg_addr_table
24614@opindex seg_addr_table_filename
24615@opindex seglinkedit
24616@opindex segprot
24617@opindex segs_read_only_addr
24618@opindex segs_read_write_addr
24619@opindex single_module
24620@opindex static
24621@opindex sub_library
24622@opindex sub_umbrella
24623@opindex twolevel_namespace
24624@opindex umbrella
24625@opindex undefined
24626@opindex unexported_symbols_list
24627@opindex weak_reference_mismatches
24628@opindex whatsloaded
ddf6fe37
AA
24629@itemx -sub_umbrella
24630@itemx -twolevel_namespace
24631@itemx -umbrella
24632@itemx -undefined
24633@itemx -unexported_symbols_list
24634@itemx -weak_reference_mismatches
24635@itemx -whatsloaded
d77de738
ML
24636These options are passed to the Darwin linker. The Darwin linker man page
24637describes them in detail.
24638@end table
24639
24640@node DEC Alpha Options
24641@subsection DEC Alpha Options
24642
24643These @samp{-m} options are defined for the DEC Alpha implementations:
24644
24645@table @gcctabopt
d77de738
ML
24646@opindex mno-soft-float
24647@opindex msoft-float
ddf6fe37
AA
24648@item -mno-soft-float
24649@itemx -msoft-float
d77de738
ML
24650Use (do not use) the hardware floating-point instructions for
24651floating-point operations. When @option{-msoft-float} is specified,
24652functions in @file{libgcc.a} are used to perform floating-point
24653operations. Unless they are replaced by routines that emulate the
24654floating-point operations, or compiled in such a way as to call such
24655emulations routines, these routines issue floating-point
24656operations. If you are compiling for an Alpha without floating-point
24657operations, you must ensure that the library is built so as not to call
24658them.
24659
24660Note that Alpha implementations without floating-point operations are
24661required to have floating-point registers.
24662
d77de738
ML
24663@opindex mfp-reg
24664@opindex mno-fp-regs
ddf6fe37
AA
24665@item -mfp-reg
24666@itemx -mno-fp-regs
d77de738
ML
24667Generate code that uses (does not use) the floating-point register set.
24668@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24669register set is not used, floating-point operands are passed in integer
24670registers as if they were integers and floating-point results are passed
24671in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24672so any function with a floating-point argument or return value called by code
24673compiled with @option{-mno-fp-regs} must also be compiled with that
24674option.
24675
24676A typical use of this option is building a kernel that does not use,
24677and hence need not save and restore, any floating-point registers.
24678
d77de738 24679@opindex mieee
ddf6fe37 24680@item -mieee
d77de738
ML
24681The Alpha architecture implements floating-point hardware optimized for
24682maximum performance. It is mostly compliant with the IEEE floating-point
24683standard. However, for full compliance, software assistance is
24684required. This option generates code fully IEEE-compliant code
24685@emph{except} that the @var{inexact-flag} is not maintained (see below).
24686If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24687defined during compilation. The resulting code is less efficient but is
24688able to correctly support denormalized numbers and exceptional IEEE
24689values such as not-a-number and plus/minus infinity. Other Alpha
24690compilers call this option @option{-ieee_with_no_inexact}.
24691
d77de738 24692@opindex mieee-with-inexact
ddf6fe37 24693@item -mieee-with-inexact
d77de738
ML
24694This is like @option{-mieee} except the generated code also maintains
24695the IEEE @var{inexact-flag}. Turning on this option causes the
24696generated code to implement fully-compliant IEEE math. In addition to
24697@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24698macro. On some Alpha implementations the resulting code may execute
24699significantly slower than the code generated by default. Since there is
24700very little code that depends on the @var{inexact-flag}, you should
24701normally not specify this option. Other Alpha compilers call this
24702option @option{-ieee_with_inexact}.
24703
d77de738 24704@opindex mfp-trap-mode
ddf6fe37 24705@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24706This option controls what floating-point related traps are enabled.
24707Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24708The trap mode can be set to one of four values:
24709
24710@table @samp
24711@item n
24712This is the default (normal) setting. The only traps that are enabled
24713are the ones that cannot be disabled in software (e.g., division by zero
24714trap).
24715
24716@item u
24717In addition to the traps enabled by @samp{n}, underflow traps are enabled
24718as well.
24719
24720@item su
24721Like @samp{u}, but the instructions are marked to be safe for software
24722completion (see Alpha architecture manual for details).
24723
24724@item sui
24725Like @samp{su}, but inexact traps are enabled as well.
24726@end table
24727
d77de738 24728@opindex mfp-rounding-mode
ddf6fe37 24729@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24730Selects the IEEE rounding mode. Other Alpha compilers call this option
24731@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24732of:
24733
24734@table @samp
24735@item n
24736Normal IEEE rounding mode. Floating-point numbers are rounded towards
24737the nearest machine number or towards the even machine number in case
24738of a tie.
24739
24740@item m
24741Round towards minus infinity.
24742
24743@item c
24744Chopped rounding mode. Floating-point numbers are rounded towards zero.
24745
24746@item d
24747Dynamic rounding mode. A field in the floating-point control register
24748(@var{fpcr}, see Alpha architecture reference manual) controls the
24749rounding mode in effect. The C library initializes this register for
24750rounding towards plus infinity. Thus, unless your program modifies the
24751@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24752@end table
24753
d77de738 24754@opindex mtrap-precision
ddf6fe37 24755@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24756In the Alpha architecture, floating-point traps are imprecise. This
24757means without software assistance it is impossible to recover from a
24758floating trap and program execution normally needs to be terminated.
24759GCC can generate code that can assist operating system trap handlers
24760in determining the exact location that caused a floating-point trap.
24761Depending on the requirements of an application, different levels of
24762precisions can be selected:
24763
24764@table @samp
24765@item p
24766Program precision. This option is the default and means a trap handler
24767can only identify which program caused a floating-point exception.
24768
24769@item f
24770Function precision. The trap handler can determine the function that
24771caused a floating-point exception.
24772
24773@item i
24774Instruction precision. The trap handler can determine the exact
24775instruction that caused a floating-point exception.
24776@end table
24777
24778Other Alpha compilers provide the equivalent options called
24779@option{-scope_safe} and @option{-resumption_safe}.
24780
d77de738 24781@opindex mieee-conformant
ddf6fe37 24782@item -mieee-conformant
d77de738
ML
24783This option marks the generated code as IEEE conformant. You must not
24784use this option unless you also specify @option{-mtrap-precision=i} and either
24785@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24786is to emit the line @samp{.eflag 48} in the function prologue of the
24787generated assembly file.
24788
d77de738 24789@opindex mbuild-constants
ddf6fe37 24790@item -mbuild-constants
d77de738
ML
24791Normally GCC examines a 32- or 64-bit integer constant to
24792see if it can construct it from smaller constants in two or three
24793instructions. If it cannot, it outputs the constant as a literal and
24794generates code to load it from the data segment at run time.
24795
24796Use this option to require GCC to construct @emph{all} integer constants
24797using code, even if it takes more instructions (the maximum is six).
24798
24799You typically use this option to build a shared library dynamic
24800loader. Itself a shared library, it must relocate itself in memory
24801before it can find the variables and constants in its own data segment.
24802
d77de738
ML
24803@opindex mbwx
24804@opindex mno-bwx
24805@opindex mcix
24806@opindex mno-cix
24807@opindex mfix
24808@opindex mno-fix
24809@opindex mmax
24810@opindex mno-max
ddf6fe37
AA
24811@item -mbwx
24812@itemx -mno-bwx
24813@itemx -mcix
24814@itemx -mno-cix
24815@itemx -mfix
24816@itemx -mno-fix
24817@itemx -mmax
24818@itemx -mno-max
d77de738
ML
24819Indicate whether GCC should generate code to use the optional BWX,
24820CIX, FIX and MAX instruction sets. The default is to use the instruction
24821sets supported by the CPU type specified via @option{-mcpu=} option or that
24822of the CPU on which GCC was built if none is specified.
24823
d77de738
ML
24824@opindex mfloat-vax
24825@opindex mfloat-ieee
ddf6fe37
AA
24826@item -mfloat-vax
24827@itemx -mfloat-ieee
d77de738
ML
24828Generate code that uses (does not use) VAX F and G floating-point
24829arithmetic instead of IEEE single and double precision.
24830
d77de738
ML
24831@opindex mexplicit-relocs
24832@opindex mno-explicit-relocs
ddf6fe37
AA
24833@item -mexplicit-relocs
24834@itemx -mno-explicit-relocs
d77de738
ML
24835Older Alpha assemblers provided no way to generate symbol relocations
24836except via assembler macros. Use of these macros does not allow
24837optimal instruction scheduling. GNU binutils as of version 2.12
24838supports a new syntax that allows the compiler to explicitly mark
24839which relocations should apply to which instructions. This option
24840is mostly useful for debugging, as GCC detects the capabilities of
24841the assembler when it is built and sets the default accordingly.
24842
d77de738
ML
24843@opindex msmall-data
24844@opindex mlarge-data
ddf6fe37
AA
24845@item -msmall-data
24846@itemx -mlarge-data
d77de738
ML
24847When @option{-mexplicit-relocs} is in effect, static data is
24848accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24849is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24850(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2485116-bit relocations off of the @code{$gp} register. This limits the
24852size of the small data area to 64KB, but allows the variables to be
24853directly accessed via a single instruction.
24854
24855The default is @option{-mlarge-data}. With this option the data area
24856is limited to just below 2GB@. Programs that require more than 2GB of
24857data must use @code{malloc} or @code{mmap} to allocate the data in the
24858heap instead of in the program's data segment.
24859
24860When generating code for shared libraries, @option{-fpic} implies
24861@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24862
d77de738
ML
24863@opindex msmall-text
24864@opindex mlarge-text
ddf6fe37
AA
24865@item -msmall-text
24866@itemx -mlarge-text
d77de738
ML
24867When @option{-msmall-text} is used, the compiler assumes that the
24868code of the entire program (or shared library) fits in 4MB, and is
24869thus reachable with a branch instruction. When @option{-msmall-data}
24870is used, the compiler can assume that all local symbols share the
24871same @code{$gp} value, and thus reduce the number of instructions
24872required for a function call from 4 to 1.
24873
24874The default is @option{-mlarge-text}.
24875
d77de738 24876@opindex mcpu
ddf6fe37 24877@item -mcpu=@var{cpu_type}
d77de738
ML
24878Set the instruction set and instruction scheduling parameters for
24879machine type @var{cpu_type}. You can specify either the @samp{EV}
24880style name or the corresponding chip number. GCC supports scheduling
24881parameters for the EV4, EV5 and EV6 family of processors and
24882chooses the default values for the instruction set from the processor
24883you specify. If you do not specify a processor type, GCC defaults
24884to the processor on which the compiler was built.
24885
24886Supported values for @var{cpu_type} are
24887
24888@table @samp
24889@item ev4
24890@itemx ev45
24891@itemx 21064
24892Schedules as an EV4 and has no instruction set extensions.
24893
24894@item ev5
24895@itemx 21164
24896Schedules as an EV5 and has no instruction set extensions.
24897
24898@item ev56
24899@itemx 21164a
24900Schedules as an EV5 and supports the BWX extension.
24901
24902@item pca56
24903@itemx 21164pc
24904@itemx 21164PC
24905Schedules as an EV5 and supports the BWX and MAX extensions.
24906
24907@item ev6
24908@itemx 21264
24909Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24910
24911@item ev67
24912@itemx 21264a
24913Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24914@end table
24915
24916Native toolchains also support the value @samp{native},
24917which selects the best architecture option for the host processor.
24918@option{-mcpu=native} has no effect if GCC does not recognize
24919the processor.
24920
d77de738 24921@opindex mtune
ddf6fe37 24922@item -mtune=@var{cpu_type}
d77de738
ML
24923Set only the instruction scheduling parameters for machine type
24924@var{cpu_type}. The instruction set is not changed.
24925
24926Native toolchains also support the value @samp{native},
24927which selects the best architecture option for the host processor.
24928@option{-mtune=native} has no effect if GCC does not recognize
24929the processor.
24930
d77de738 24931@opindex mmemory-latency
ddf6fe37 24932@item -mmemory-latency=@var{time}
d77de738
ML
24933Sets the latency the scheduler should assume for typical memory
24934references as seen by the application. This number is highly
24935dependent on the memory access patterns used by the application
24936and the size of the external cache on the machine.
24937
24938Valid options for @var{time} are
24939
24940@table @samp
24941@item @var{number}
24942A decimal number representing clock cycles.
24943
24944@item L1
24945@itemx L2
24946@itemx L3
24947@itemx main
24948The compiler contains estimates of the number of clock cycles for
24949``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24950(also called Dcache, Scache, and Bcache), as well as to main memory.
24951Note that L3 is only valid for EV5.
24952
24953@end table
24954@end table
24955
24956@node eBPF Options
24957@subsection eBPF Options
24958@cindex eBPF Options
24959
24960@table @gcctabopt
24961@item -mframe-limit=@var{bytes}
24962This specifies the hard limit for frame sizes, in bytes. Currently,
24963the value that can be specified should be less than or equal to
24964@samp{32767}. Defaults to whatever limit is imposed by the version of
24965the Linux kernel targeted.
24966
d77de738 24967@opindex mbig-endian
ddf6fe37 24968@item -mbig-endian
d77de738
ML
24969Generate code for a big-endian target.
24970
d77de738 24971@opindex mlittle-endian
ddf6fe37 24972@item -mlittle-endian
d77de738
ML
24973Generate code for a little-endian target. This is the default.
24974
d77de738 24975@opindex mjmpext
ddf6fe37 24976@item -mjmpext
9cbf4286
DF
24977@itemx -mno-jmpext
24978Enable or disable generation of extra conditional-branch instructions.
d77de738
ML
24979Enabled for CPU v2 and above.
24980
d77de738 24981@opindex mjmp32
ddf6fe37 24982@item -mjmp32
9cbf4286
DF
24983@itemx -mno-jmp32
24984Enable or disable generation of 32-bit jump instructions.
24985Enabled for CPU v3 and above.
d77de738 24986
d77de738 24987@opindex malu32
ddf6fe37 24988@item -malu32
9cbf4286
DF
24989@itemx -mno-alu32
24990Enable or disable generation of 32-bit ALU instructions.
24991Enabled for CPU v3 and above.
24992
24993@opindex mv3-atomics
24994@item -mv3-atomics
24995@itemx -mno-v3-atomics
24996Enable or disable instructions for general atomic operations introduced
24997in CPU v3. Enabled for CPU v3 and above.
d77de738 24998
f1e34551
JM
24999@opindex mbswap
25000@item -mbswap
9cbf4286
DF
25001@itemx -mno-bswap
25002Enable or disable byte swap instructions. Enabled for CPU v4 and above.
f1e34551 25003
4be3919f
JM
25004@opindex msdiv
25005@item -msdiv
9cbf4286
DF
25006@itemx -mno-sdiv
25007Enable or disable signed division and modulus instructions. Enabled for
25008CPU v4 and above.
db189d02 25009
14dab1a1
DF
25010@opindex msmov
25011@item -msmov
25012@itemx -mno-smov
25013Enable or disable sign-extending move and memory load instructions.
25014Enabled for CPU v4 and above.
25015
d77de738 25016@opindex mcpu
ddf6fe37 25017@item -mcpu=@var{version}
d77de738 25018This specifies which version of the eBPF ISA to target. Newer versions
f1e34551 25019may not be supported by all kernels. The default is @samp{v4}.
d77de738
ML
25020
25021Supported values for @var{version} are:
25022
25023@table @samp
25024@item v1
25025The first stable eBPF ISA with no special features or extensions.
25026
25027@item v2
25028Supports the jump extensions, as in @option{-mjmpext}.
25029
25030@item v3
25031All features of v2, plus:
25032@itemize @minus
25033@item 32-bit jump operations, as in @option{-mjmp32}
25034@item 32-bit ALU operations, as in @option{-malu32}
db189d02 25035@item general atomic operations, as in @option{-mv3-atomics}
d77de738
ML
25036@end itemize
25037
f1e34551
JM
25038@item v4
25039All features of v3, plus:
25040@itemize @minus
25041@item Byte swap instructions, as in @option{-mbswap}
9cbf4286 25042@item Signed division and modulus instructions, as in @option{-msdiv}
14dab1a1 25043@item Sign-extending move and memory load instructions, as in @option{-msmov}
f1e34551 25044@end itemize
d77de738
ML
25045@end table
25046
d77de738 25047@opindex mco-re
ddf6fe37 25048@item -mco-re
d77de738
ML
25049Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
25050is implied by @option{-gbtf}.
25051
d77de738 25052@opindex mno-co-re
ddf6fe37 25053@item -mno-co-re
d77de738
ML
25054Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
25055support is enabled by default when generating BTF debug information for
25056the BPF target.
25057
25058@item -mxbpf
25059Generate code for an expanded version of BPF, which relaxes some of
25060the restrictions imposed by the BPF architecture:
25061@itemize @minus
25062@item Save and restore callee-saved registers at function entry and
25063exit, respectively.
25064@end itemize
77d0f9ec
CM
25065
25066@opindex masm=@var{dialect}
25067@item -masm=@var{dialect}
25068Outputs assembly instructions using eBPF selected @var{dialect}. The default
25069is @samp{normal}.
25070
25071Supported values for @var{dialect} are:
25072
25073@table @samp
25074@item normal
25075Outputs normal assembly dialect.
25076
25077@item pseudoc
25078Outputs pseudo-c assembly dialect.
25079
25080@end table
25081
d77de738
ML
25082@end table
25083
25084@node FR30 Options
25085@subsection FR30 Options
25086@cindex FR30 Options
25087
25088These options are defined specifically for the FR30 port.
25089
25090@table @gcctabopt
25091
d77de738 25092@opindex msmall-model
ddf6fe37 25093@item -msmall-model
d77de738
ML
25094Use the small address space model. This can produce smaller code, but
25095it does assume that all symbolic values and addresses fit into a
2509620-bit range.
25097
d77de738 25098@opindex mno-lsim
ddf6fe37 25099@item -mno-lsim
d77de738
ML
25100Assume that runtime support has been provided and so there is no need
25101to include the simulator library (@file{libsim.a}) on the linker
25102command line.
25103
25104@end table
25105
25106@node FT32 Options
25107@subsection FT32 Options
25108@cindex FT32 Options
25109
25110These options are defined specifically for the FT32 port.
25111
25112@table @gcctabopt
25113
d77de738 25114@opindex msim
ddf6fe37 25115@item -msim
d77de738
ML
25116Specifies that the program will be run on the simulator. This causes
25117an alternate runtime startup and library to be linked.
25118You must not use this option when generating programs that will run on
25119real hardware; you must provide your own runtime library for whatever
25120I/O functions are needed.
25121
d77de738 25122@opindex mlra
ddf6fe37 25123@item -mlra
d77de738
ML
25124Enable Local Register Allocation. This is still experimental for FT32,
25125so by default the compiler uses standard reload.
25126
d77de738 25127@opindex mnodiv
ddf6fe37 25128@item -mnodiv
d77de738
ML
25129Do not use div and mod instructions.
25130
d77de738 25131@opindex mft32b
ddf6fe37 25132@item -mft32b
d77de738
ML
25133Enable use of the extended instructions of the FT32B processor.
25134
d77de738 25135@opindex mcompress
ddf6fe37 25136@item -mcompress
d77de738
ML
25137Compress all code using the Ft32B code compression scheme.
25138
d77de738 25139@opindex mnopm
ddf6fe37 25140@item -mnopm
d77de738
ML
25141Do not generate code that reads program memory.
25142
25143@end table
25144
25145@node FRV Options
25146@subsection FRV Options
25147@cindex FRV Options
25148
25149@table @gcctabopt
d77de738 25150@opindex mgpr-32
ddf6fe37 25151@item -mgpr-32
d77de738
ML
25152
25153Only use the first 32 general-purpose registers.
25154
d77de738 25155@opindex mgpr-64
ddf6fe37 25156@item -mgpr-64
d77de738
ML
25157
25158Use all 64 general-purpose registers.
25159
d77de738 25160@opindex mfpr-32
ddf6fe37 25161@item -mfpr-32
d77de738
ML
25162
25163Use only the first 32 floating-point registers.
25164
d77de738 25165@opindex mfpr-64
ddf6fe37 25166@item -mfpr-64
d77de738
ML
25167
25168Use all 64 floating-point registers.
25169
d77de738 25170@opindex mhard-float
ddf6fe37 25171@item -mhard-float
d77de738
ML
25172
25173Use hardware instructions for floating-point operations.
25174
d77de738 25175@opindex msoft-float
ddf6fe37 25176@item -msoft-float
d77de738
ML
25177
25178Use library routines for floating-point operations.
25179
d77de738 25180@opindex malloc-cc
ddf6fe37 25181@item -malloc-cc
d77de738
ML
25182
25183Dynamically allocate condition code registers.
25184
d77de738 25185@opindex mfixed-cc
ddf6fe37 25186@item -mfixed-cc
d77de738
ML
25187
25188Do not try to dynamically allocate condition code registers, only
25189use @code{icc0} and @code{fcc0}.
25190
d77de738 25191@opindex mdword
ddf6fe37 25192@item -mdword
d77de738
ML
25193
25194Change ABI to use double word insns.
25195
d77de738
ML
25196@opindex mno-dword
25197@opindex mdword
ddf6fe37 25198@item -mno-dword
d77de738
ML
25199
25200Do not use double word instructions.
25201
d77de738 25202@opindex mdouble
ddf6fe37 25203@item -mdouble
d77de738
ML
25204
25205Use floating-point double instructions.
25206
d77de738 25207@opindex mno-double
ddf6fe37 25208@item -mno-double
d77de738
ML
25209
25210Do not use floating-point double instructions.
25211
d77de738 25212@opindex mmedia
ddf6fe37 25213@item -mmedia
d77de738
ML
25214
25215Use media instructions.
25216
d77de738 25217@opindex mno-media
ddf6fe37 25218@item -mno-media
d77de738
ML
25219
25220Do not use media instructions.
25221
d77de738 25222@opindex mmuladd
ddf6fe37 25223@item -mmuladd
d77de738
ML
25224
25225Use multiply and add/subtract instructions.
25226
d77de738 25227@opindex mno-muladd
ddf6fe37 25228@item -mno-muladd
d77de738
ML
25229
25230Do not use multiply and add/subtract instructions.
25231
d77de738 25232@opindex mfdpic
ddf6fe37 25233@item -mfdpic
d77de738
ML
25234
25235Select the FDPIC ABI, which uses function descriptors to represent
25236pointers to functions. Without any PIC/PIE-related options, it
25237implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
25238assumes GOT entries and small data are within a 12-bit range from the
25239GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
25240are computed with 32 bits.
25241With a @samp{bfin-elf} target, this option implies @option{-msim}.
25242
d77de738 25243@opindex minline-plt
ddf6fe37 25244@item -minline-plt
d77de738
ML
25245
25246Enable inlining of PLT entries in function calls to functions that are
25247not known to bind locally. It has no effect without @option{-mfdpic}.
25248It's enabled by default if optimizing for speed and compiling for
25249shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
25250optimization option such as @option{-O3} or above is present in the
25251command line.
25252
d77de738 25253@opindex mTLS
ddf6fe37 25254@item -mTLS
d77de738
ML
25255
25256Assume a large TLS segment when generating thread-local code.
25257
d77de738 25258@opindex mtls
ddf6fe37 25259@item -mtls
d77de738
ML
25260
25261Do not assume a large TLS segment when generating thread-local code.
25262
d77de738 25263@opindex mgprel-ro
ddf6fe37 25264@item -mgprel-ro
d77de738
ML
25265
25266Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
25267that is known to be in read-only sections. It's enabled by default,
25268except for @option{-fpic} or @option{-fpie}: even though it may help
25269make the global offset table smaller, it trades 1 instruction for 4.
25270With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
25271one of which may be shared by multiple symbols, and it avoids the need
25272for a GOT entry for the referenced symbol, so it's more likely to be a
25273win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
25274
d77de738 25275@opindex multilib-library-pic
ddf6fe37 25276@item -multilib-library-pic
d77de738
ML
25277
25278Link with the (library, not FD) pic libraries. It's implied by
25279@option{-mlibrary-pic}, as well as by @option{-fPIC} and
25280@option{-fpic} without @option{-mfdpic}. You should never have to use
25281it explicitly.
25282
d77de738 25283@opindex mlinked-fp
ddf6fe37 25284@item -mlinked-fp
d77de738
ML
25285
25286Follow the EABI requirement of always creating a frame pointer whenever
25287a stack frame is allocated. This option is enabled by default and can
25288be disabled with @option{-mno-linked-fp}.
25289
d77de738 25290@opindex mlong-calls
ddf6fe37 25291@item -mlong-calls
d77de738
ML
25292
25293Use indirect addressing to call functions outside the current
25294compilation unit. This allows the functions to be placed anywhere
25295within the 32-bit address space.
25296
d77de738 25297@opindex malign-labels
ddf6fe37 25298@item -malign-labels
d77de738
ML
25299
25300Try to align labels to an 8-byte boundary by inserting NOPs into the
25301previous packet. This option only has an effect when VLIW packing
25302is enabled. It doesn't create new packets; it merely adds NOPs to
25303existing ones.
25304
d77de738 25305@opindex mlibrary-pic
ddf6fe37 25306@item -mlibrary-pic
d77de738
ML
25307
25308Generate position-independent EABI code.
25309
d77de738 25310@opindex macc-4
ddf6fe37 25311@item -macc-4
d77de738
ML
25312
25313Use only the first four media accumulator registers.
25314
d77de738 25315@opindex macc-8
ddf6fe37 25316@item -macc-8
d77de738
ML
25317
25318Use all eight media accumulator registers.
25319
d77de738 25320@opindex mpack
ddf6fe37 25321@item -mpack
d77de738
ML
25322
25323Pack VLIW instructions.
25324
d77de738 25325@opindex mno-pack
ddf6fe37 25326@item -mno-pack
d77de738
ML
25327
25328Do not pack VLIW instructions.
25329
d77de738 25330@opindex mno-eflags
ddf6fe37 25331@item -mno-eflags
d77de738
ML
25332
25333Do not mark ABI switches in e_flags.
25334
d77de738 25335@opindex mcond-move
ddf6fe37 25336@item -mcond-move
d77de738
ML
25337
25338Enable the use of conditional-move instructions (default).
25339
25340This switch is mainly for debugging the compiler and will likely be removed
25341in a future version.
25342
d77de738 25343@opindex mno-cond-move
ddf6fe37 25344@item -mno-cond-move
d77de738
ML
25345
25346Disable the use of conditional-move instructions.
25347
25348This switch is mainly for debugging the compiler and will likely be removed
25349in a future version.
25350
d77de738 25351@opindex mscc
ddf6fe37 25352@item -mscc
d77de738
ML
25353
25354Enable the use of conditional set instructions (default).
25355
25356This switch is mainly for debugging the compiler and will likely be removed
25357in a future version.
25358
d77de738 25359@opindex mno-scc
ddf6fe37 25360@item -mno-scc
d77de738
ML
25361
25362Disable the use of conditional set instructions.
25363
25364This switch is mainly for debugging the compiler and will likely be removed
25365in a future version.
25366
d77de738 25367@opindex mcond-exec
ddf6fe37 25368@item -mcond-exec
d77de738
ML
25369
25370Enable the use of conditional execution (default).
25371
25372This switch is mainly for debugging the compiler and will likely be removed
25373in a future version.
25374
d77de738 25375@opindex mno-cond-exec
ddf6fe37 25376@item -mno-cond-exec
d77de738
ML
25377
25378Disable the use of conditional execution.
25379
25380This switch is mainly for debugging the compiler and will likely be removed
25381in a future version.
25382
d77de738 25383@opindex mvliw-branch
ddf6fe37 25384@item -mvliw-branch
d77de738
ML
25385
25386Run a pass to pack branches into VLIW instructions (default).
25387
25388This switch is mainly for debugging the compiler and will likely be removed
25389in a future version.
25390
d77de738 25391@opindex mno-vliw-branch
ddf6fe37 25392@item -mno-vliw-branch
d77de738
ML
25393
25394Do not run a pass to pack branches into VLIW instructions.
25395
25396This switch is mainly for debugging the compiler and will likely be removed
25397in a future version.
25398
d77de738 25399@opindex mmulti-cond-exec
ddf6fe37 25400@item -mmulti-cond-exec
d77de738
ML
25401
25402Enable optimization of @code{&&} and @code{||} in conditional execution
25403(default).
25404
25405This switch is mainly for debugging the compiler and will likely be removed
25406in a future version.
25407
d77de738 25408@opindex mno-multi-cond-exec
ddf6fe37 25409@item -mno-multi-cond-exec
d77de738
ML
25410
25411Disable optimization of @code{&&} and @code{||} in conditional execution.
25412
25413This switch is mainly for debugging the compiler and will likely be removed
25414in a future version.
25415
d77de738 25416@opindex mnested-cond-exec
ddf6fe37 25417@item -mnested-cond-exec
d77de738
ML
25418
25419Enable nested conditional execution optimizations (default).
25420
25421This switch is mainly for debugging the compiler and will likely be removed
25422in a future version.
25423
d77de738 25424@opindex mno-nested-cond-exec
ddf6fe37 25425@item -mno-nested-cond-exec
d77de738
ML
25426
25427Disable nested conditional execution optimizations.
25428
25429This switch is mainly for debugging the compiler and will likely be removed
25430in a future version.
25431
d77de738 25432@opindex moptimize-membar
ddf6fe37 25433@item -moptimize-membar
d77de738
ML
25434
25435This switch removes redundant @code{membar} instructions from the
25436compiler-generated code. It is enabled by default.
25437
d77de738
ML
25438@opindex mno-optimize-membar
25439@opindex moptimize-membar
ddf6fe37 25440@item -mno-optimize-membar
d77de738
ML
25441
25442This switch disables the automatic removal of redundant @code{membar}
25443instructions from the generated code.
25444
d77de738 25445@opindex mtomcat-stats
ddf6fe37 25446@item -mtomcat-stats
d77de738
ML
25447
25448Cause gas to print out tomcat statistics.
25449
d77de738 25450@opindex mcpu
ddf6fe37 25451@item -mcpu=@var{cpu}
d77de738
ML
25452
25453Select the processor type for which to generate code. Possible values are
25454@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
25455@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
25456
25457@end table
25458
25459@node GNU/Linux Options
25460@subsection GNU/Linux Options
25461
25462These @samp{-m} options are defined for GNU/Linux targets:
25463
25464@table @gcctabopt
d77de738 25465@opindex mglibc
ddf6fe37 25466@item -mglibc
d77de738
ML
25467Use the GNU C library. This is the default except
25468on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
25469@samp{*-*-linux-*android*} targets.
25470
d77de738 25471@opindex muclibc
ddf6fe37 25472@item -muclibc
d77de738
ML
25473Use uClibc C library. This is the default on
25474@samp{*-*-linux-*uclibc*} targets.
25475
d77de738 25476@opindex mmusl
ddf6fe37 25477@item -mmusl
d77de738
ML
25478Use the musl C library. This is the default on
25479@samp{*-*-linux-*musl*} targets.
25480
d77de738 25481@opindex mbionic
ddf6fe37 25482@item -mbionic
d77de738
ML
25483Use Bionic C library. This is the default on
25484@samp{*-*-linux-*android*} targets.
25485
d77de738 25486@opindex mandroid
ddf6fe37 25487@item -mandroid
d77de738
ML
25488Compile code compatible with Android platform. This is the default on
25489@samp{*-*-linux-*android*} targets.
25490
25491When compiling, this option enables @option{-mbionic}, @option{-fPIC},
25492@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
25493this option makes the GCC driver pass Android-specific options to the linker.
25494Finally, this option causes the preprocessor macro @code{__ANDROID__}
25495to be defined.
25496
d77de738 25497@opindex tno-android-cc
ddf6fe37 25498@item -tno-android-cc
d77de738
ML
25499Disable compilation effects of @option{-mandroid}, i.e., do not enable
25500@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
25501@option{-fno-rtti} by default.
25502
d77de738 25503@opindex tno-android-ld
ddf6fe37 25504@item -tno-android-ld
d77de738
ML
25505Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
25506linking options to the linker.
25507
25508@end table
25509
25510@node H8/300 Options
25511@subsection H8/300 Options
25512
25513These @samp{-m} options are defined for the H8/300 implementations:
25514
25515@table @gcctabopt
d77de738 25516@opindex mrelax
ddf6fe37 25517@item -mrelax
d77de738
ML
25518Shorten some address references at link time, when possible; uses the
25519linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
25520ld, Using ld}, for a fuller description.
25521
d77de738 25522@opindex mh
ddf6fe37 25523@item -mh
d77de738
ML
25524Generate code for the H8/300H@.
25525
d77de738 25526@opindex ms
ddf6fe37 25527@item -ms
d77de738
ML
25528Generate code for the H8S@.
25529
d77de738 25530@opindex mn
ddf6fe37 25531@item -mn
d77de738
ML
25532Generate code for the H8S and H8/300H in the normal mode. This switch
25533must be used either with @option{-mh} or @option{-ms}.
25534
d77de738 25535@opindex ms2600
ddf6fe37 25536@item -ms2600
d77de738
ML
25537Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25538
d77de738 25539@opindex mexr
ddf6fe37 25540@item -mexr
d77de738
ML
25541Extended registers are stored on stack before execution of function
25542with monitor attribute. Default option is @option{-mexr}.
25543This option is valid only for H8S targets.
25544
d77de738
ML
25545@opindex mno-exr
25546@opindex mexr
ddf6fe37 25547@item -mno-exr
d77de738
ML
25548Extended registers are not stored on stack before execution of function
25549with monitor attribute. Default option is @option{-mno-exr}.
25550This option is valid only for H8S targets.
25551
d77de738 25552@opindex mint32
ddf6fe37 25553@item -mint32
d77de738
ML
25554Make @code{int} data 32 bits by default.
25555
d77de738 25556@opindex malign-300
ddf6fe37 25557@item -malign-300
d77de738
ML
25558On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25559The default for the H8/300H and H8S is to align longs and floats on
255604-byte boundaries.
25561@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25562This option has no effect on the H8/300.
25563@end table
25564
25565@node HPPA Options
25566@subsection HPPA Options
25567@cindex HPPA Options
25568
25569These @samp{-m} options are defined for the HPPA family of computers:
25570
25571@table @gcctabopt
d77de738 25572@opindex march
ddf6fe37 25573@item -march=@var{architecture-type}
d77de738
ML
25574Generate code for the specified architecture. The choices for
25575@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
255761.1, and @samp{2.0} for PA 2.0 processors. Refer to
25577@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25578architecture option for your machine. Code compiled for lower numbered
25579architectures runs on higher numbered architectures, but not the
25580other way around.
25581
d77de738
ML
25582@opindex mpa-risc-1-0
25583@opindex mpa-risc-1-1
25584@opindex mpa-risc-2-0
ddf6fe37
AA
25585@item -mpa-risc-1-0
25586@itemx -mpa-risc-1-1
25587@itemx -mpa-risc-2-0
d77de738
ML
25588Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25589
cf467fb9
JDA
25590@opindex matomic-libcalls
25591@opindex mno-atomic-libcalls
ddf6fe37 25592@item -matomic-libcalls
cf467fb9
JDA
25593Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25594This option is enabled by default. It only affects the generation of
25595atomic libcalls by the HPPA backend.
25596
25597Both the sync and @file{libatomic} libcall implementations use locking.
25598As a result, processor stores are not atomic with respect to other
25599atomic operations. Processor loads up to DImode are atomic with
25600respect to other atomic operations provided they are implemented as
25601a single access.
25602
25603The PA-RISC architecture does not support any atomic operations in
25604hardware except for the @code{ldcw} instruction. Thus, all atomic
25605support is implemented using sync and atomic libcalls. Sync libcall
25606support is in @file{libgcc.a}. Atomic libcall support is in
25607@file{libatomic}.
25608
25609This option generates @code{__atomic_exchange} calls for atomic stores.
25610It also provides special handling for atomic DImode accesses on 32-bit
25611targets.
25612
cf467fb9 25613@opindex mbig-switch
ddf6fe37 25614@item -mbig-switch
cf467fb9
JDA
25615Does nothing. Preserved for backward compatibility.
25616
d77de738 25617@opindex mcaller-copies
ddf6fe37 25618@item -mcaller-copies
d77de738
ML
25619The caller copies function arguments passed by hidden reference. This
25620option should be used with care as it is not compatible with the default
2562132-bit runtime. However, only aggregates larger than eight bytes are
25622passed by hidden reference and the option provides better compatibility
25623with OpenMP.
25624
cf467fb9 25625@opindex mcoherent-ldcw
ddf6fe37 25626@item -mcoherent-ldcw
cf467fb9 25627Use ldcw/ldcd coherent cache-control hint.
d77de738 25628
d77de738 25629@opindex mdisable-fpregs
ddf6fe37 25630@item -mdisable-fpregs
cf467fb9 25631Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25632
d77de738 25633@opindex mdisable-indexing
ddf6fe37 25634@item -mdisable-indexing
d77de738
ML
25635Prevent the compiler from using indexing address modes. This avoids some
25636rather obscure problems when compiling MIG generated code under MACH@.
25637
d77de738 25638@opindex mfast-indirect-calls
ddf6fe37 25639@item -mfast-indirect-calls
d77de738
ML
25640Generate code that assumes calls never cross space boundaries. This
25641allows GCC to emit code that performs faster indirect calls.
25642
25643This option does not work in the presence of shared libraries or nested
25644functions.
25645
d77de738 25646@opindex mfixed-range
ddf6fe37 25647@item -mfixed-range=@var{register-range}
d77de738
ML
25648Generate code treating the given register range as fixed registers.
25649A fixed register is one that the register allocator cannot use. This is
25650useful when compiling kernel code. A register range is specified as
25651two registers separated by a dash. Multiple register ranges can be
25652specified separated by a comma.
25653
d77de738 25654@opindex mgas
ddf6fe37 25655@item -mgas
d77de738
ML
25656Enable the use of assembler directives only GAS understands.
25657
d77de738 25658@opindex mgnu-ld
ddf6fe37 25659@item -mgnu-ld
d77de738
ML
25660Use options specific to GNU @command{ld}.
25661This passes @option{-shared} to @command{ld} when
25662building a shared library. It is the default when GCC is configured,
25663explicitly or implicitly, with the GNU linker. This option does not
25664affect which @command{ld} is called; it only changes what parameters
25665are passed to that @command{ld}.
25666The @command{ld} that is called is determined by the
25667@option{--with-ld} configure option, GCC's program search path, and
25668finally by the user's @env{PATH}. The linker used by GCC can be printed
25669using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25670on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25671
d77de738 25672@opindex mhp-ld
ddf6fe37 25673@item -mhp-ld
d77de738
ML
25674Use options specific to HP @command{ld}.
25675This passes @option{-b} to @command{ld} when building
25676a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25677links. It is the default when GCC is configured, explicitly or
25678implicitly, with the HP linker. This option does not affect
25679which @command{ld} is called; it only changes what parameters are passed to that
25680@command{ld}.
25681The @command{ld} that is called is determined by the @option{--with-ld}
25682configure option, GCC's program search path, and finally by the user's
25683@env{PATH}. The linker used by GCC can be printed using @samp{which
25684`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25685HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25686
cf467fb9 25687@opindex mlinker-opt
ddf6fe37 25688@item -mlinker-opt
cf467fb9
JDA
25689Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25690debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25691linkers in which they give bogus error messages when linking some programs.
25692
d77de738
ML
25693@opindex mno-long-calls
25694@opindex mlong-calls
ddf6fe37 25695@item -mlong-calls
d77de738
ML
25696Generate code that uses long call sequences. This ensures that a call
25697is always able to reach linker generated stubs. The default is to generate
25698long calls only when the distance from the call site to the beginning
25699of the function or translation unit, as the case may be, exceeds a
25700predefined limit set by the branch type being used. The limits for
25701normal calls are 7,600,000 and 240,000 bytes, respectively for the
25702PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25703240,000 bytes.
25704
25705Distances are measured from the beginning of functions when using the
25706@option{-ffunction-sections} option, or when using the @option{-mgas}
25707and @option{-mno-portable-runtime} options together under HP-UX with
25708the SOM linker.
25709
25710It is normally not desirable to use this option as it degrades
25711performance. However, it may be useful in large applications,
25712particularly when partial linking is used to build the application.
25713
25714The types of long calls used depends on the capabilities of the
25715assembler and linker, and the type of code being generated. The
25716impact on systems that support long absolute calls, and long pic
25717symbol-difference or pc-relative calls should be relatively small.
25718However, an indirect call is used on 32-bit ELF systems in pic code
25719and it is quite long.
25720
cf467fb9 25721@opindex mlong-load-store
ddf6fe37 25722@item -mlong-load-store
cf467fb9
JDA
25723Generate 3-instruction load and store sequences as sometimes required by
25724the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25725the HP compilers.
25726
cf467fb9 25727@opindex mjump-in-delay
ddf6fe37 25728@item -mjump-in-delay
cf467fb9
JDA
25729This option is ignored and provided for compatibility purposes only.
25730
cf467fb9
JDA
25731@opindex mno-space-regs
25732@opindex mspace-regs
ddf6fe37 25733@item -mno-space-regs
cf467fb9
JDA
25734Generate code that assumes the target has no space registers. This allows
25735GCC to generate faster indirect calls and use unscaled index address modes.
25736
25737Such code is suitable for level 0 PA systems and kernels.
25738
cf467fb9 25739@opindex mordered
ddf6fe37 25740@item -mordered
cf467fb9
JDA
25741Assume memory references are ordered and barriers are not needed.
25742
cf467fb9 25743@opindex mportable-runtime
ddf6fe37 25744@item -mportable-runtime
cf467fb9
JDA
25745Use the portable calling conventions proposed by HP for ELF systems.
25746
cf467fb9 25747@opindex mschedule
ddf6fe37 25748@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25749Schedule code according to the constraints for the machine type
25750@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25751@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25752to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25753proper scheduling option for your machine. The default scheduling is
25754@samp{8000}.
25755
cf467fb9 25756@opindex msio
ddf6fe37 25757@item -msio
cf467fb9
JDA
25758Generate the predefine, @code{_SIO}, for server IO@. The default is
25759@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25760@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25761options are available under HP-UX and HI-UX@.
25762
cf467fb9 25763@opindex msoft-float
ddf6fe37 25764@item -msoft-float
cf467fb9
JDA
25765Generate output containing library calls for floating point.
25766@strong{Warning:} the requisite libraries are not available for all HPPA
25767targets. Normally the facilities of the machine's usual C compiler are
25768used, but this cannot be done directly in cross-compilation. You must make
25769your own arrangements to provide suitable library functions for
25770cross-compilation.
25771
25772@option{-msoft-float} changes the calling convention in the output file;
25773therefore, it is only useful if you compile @emph{all} of a program with
25774this option. In particular, you need to compile @file{libgcc.a}, the
25775library that comes with GCC, with @option{-msoft-float} in order for
25776this to work.
25777
cf467fb9 25778@opindex msoft-mult
ddf6fe37 25779@item -msoft-mult
cf467fb9
JDA
25780Use software integer multiplication.
25781
25782This disables the use of the @code{xmpyu} instruction.
25783
d77de738 25784@opindex march
ddf6fe37 25785@item -munix=@var{unix-std}
d77de738
ML
25786Generate compiler predefines and select a startfile for the specified
25787UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25788and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25789is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2579011.11 and later. The default values are @samp{93} for HP-UX 10.00,
25791@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25792and later.
25793
25794@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25795@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25796and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25797@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25798@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25799@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25800
25801It is @emph{important} to note that this option changes the interfaces
25802for various library routines. It also affects the operational behavior
25803of the C library. Thus, @emph{extreme} care is needed in using this
25804option.
25805
25806Library code that is intended to operate with more than one UNIX
25807standard must test, set and restore the variable @code{__xpg4_extended_mask}
25808as appropriate. Most GNU software doesn't provide this capability.
25809
d77de738 25810@opindex nolibdld
ddf6fe37 25811@item -nolibdld
d77de738
ML
25812Suppress the generation of link options to search libdld.sl when the
25813@option{-static} option is specified on HP-UX 10 and later.
25814
d77de738 25815@opindex static
ddf6fe37 25816@item -static
d77de738
ML
25817The HP-UX implementation of setlocale in libc has a dependency on
25818libdld.sl. There isn't an archive version of libdld.sl. Thus,
25819when the @option{-static} option is specified, special link options
25820are needed to resolve this dependency.
25821
25822On HP-UX 10 and later, the GCC driver adds the necessary options to
25823link with libdld.sl when the @option{-static} option is specified.
25824This causes the resulting binary to be dynamic. On the 64-bit port,
25825the linkers generate dynamic binaries by default in any case. The
25826@option{-nolibdld} option can be used to prevent the GCC driver from
25827adding these link options.
25828
d77de738 25829@opindex threads
ddf6fe37 25830@item -threads
d77de738
ML
25831Add support for multithreading with the @dfn{dce thread} library
25832under HP-UX@. This option sets flags for both the preprocessor and
25833linker.
25834@end table
25835
25836@node IA-64 Options
25837@subsection IA-64 Options
25838@cindex IA-64 Options
25839
25840These are the @samp{-m} options defined for the Intel IA-64 architecture.
25841
25842@table @gcctabopt
d77de738 25843@opindex mbig-endian
ddf6fe37 25844@item -mbig-endian
d77de738
ML
25845Generate code for a big-endian target. This is the default for HP-UX@.
25846
d77de738 25847@opindex mlittle-endian
ddf6fe37 25848@item -mlittle-endian
d77de738
ML
25849Generate code for a little-endian target. This is the default for AIX5
25850and GNU/Linux.
25851
d77de738
ML
25852@opindex mgnu-as
25853@opindex mno-gnu-as
ddf6fe37
AA
25854@item -mgnu-as
25855@itemx -mno-gnu-as
d77de738
ML
25856Generate (or don't) code for the GNU assembler. This is the default.
25857@c Also, this is the default if the configure option @option{--with-gnu-as}
25858@c is used.
25859
d77de738
ML
25860@opindex mgnu-ld
25861@opindex mno-gnu-ld
ddf6fe37
AA
25862@item -mgnu-ld
25863@itemx -mno-gnu-ld
d77de738
ML
25864Generate (or don't) code for the GNU linker. This is the default.
25865@c Also, this is the default if the configure option @option{--with-gnu-ld}
25866@c is used.
25867
d77de738 25868@opindex mno-pic
ddf6fe37 25869@item -mno-pic
d77de738
ML
25870Generate code that does not use a global pointer register. The result
25871is not position independent code, and violates the IA-64 ABI@.
25872
d77de738
ML
25873@opindex mvolatile-asm-stop
25874@opindex mno-volatile-asm-stop
ddf6fe37
AA
25875@item -mvolatile-asm-stop
25876@itemx -mno-volatile-asm-stop
d77de738
ML
25877Generate (or don't) a stop bit immediately before and after volatile asm
25878statements.
25879
d77de738
ML
25880@opindex mregister-names
25881@opindex mno-register-names
ddf6fe37
AA
25882@item -mregister-names
25883@itemx -mno-register-names
d77de738
ML
25884Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25885the stacked registers. This may make assembler output more readable.
25886
d77de738
ML
25887@opindex mno-sdata
25888@opindex msdata
ddf6fe37
AA
25889@item -mno-sdata
25890@itemx -msdata
d77de738
ML
25891Disable (or enable) optimizations that use the small data section. This may
25892be useful for working around optimizer bugs.
25893
d77de738 25894@opindex mconstant-gp
ddf6fe37 25895@item -mconstant-gp
d77de738
ML
25896Generate code that uses a single constant global pointer value. This is
25897useful when compiling kernel code.
25898
d77de738 25899@opindex mauto-pic
ddf6fe37 25900@item -mauto-pic
d77de738
ML
25901Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25902This is useful when compiling firmware code.
25903
d77de738 25904@opindex minline-float-divide-min-latency
ddf6fe37 25905@item -minline-float-divide-min-latency
d77de738
ML
25906Generate code for inline divides of floating-point values
25907using the minimum latency algorithm.
25908
d77de738 25909@opindex minline-float-divide-max-throughput
ddf6fe37 25910@item -minline-float-divide-max-throughput
d77de738
ML
25911Generate code for inline divides of floating-point values
25912using the maximum throughput algorithm.
25913
d77de738 25914@opindex mno-inline-float-divide
ddf6fe37 25915@item -mno-inline-float-divide
d77de738
ML
25916Do not generate inline code for divides of floating-point values.
25917
d77de738 25918@opindex minline-int-divide-min-latency
ddf6fe37 25919@item -minline-int-divide-min-latency
d77de738
ML
25920Generate code for inline divides of integer values
25921using the minimum latency algorithm.
25922
d77de738 25923@opindex minline-int-divide-max-throughput
ddf6fe37 25924@item -minline-int-divide-max-throughput
d77de738
ML
25925Generate code for inline divides of integer values
25926using the maximum throughput algorithm.
25927
d77de738
ML
25928@opindex mno-inline-int-divide
25929@opindex minline-int-divide
ddf6fe37 25930@item -mno-inline-int-divide
d77de738
ML
25931Do not generate inline code for divides of integer values.
25932
d77de738 25933@opindex minline-sqrt-min-latency
ddf6fe37 25934@item -minline-sqrt-min-latency
d77de738
ML
25935Generate code for inline square roots
25936using the minimum latency algorithm.
25937
d77de738 25938@opindex minline-sqrt-max-throughput
ddf6fe37 25939@item -minline-sqrt-max-throughput
d77de738
ML
25940Generate code for inline square roots
25941using the maximum throughput algorithm.
25942
d77de738 25943@opindex mno-inline-sqrt
ddf6fe37 25944@item -mno-inline-sqrt
d77de738
ML
25945Do not generate inline code for @code{sqrt}.
25946
d77de738
ML
25947@opindex mfused-madd
25948@opindex mno-fused-madd
ddf6fe37
AA
25949@item -mfused-madd
25950@itemx -mno-fused-madd
d77de738
ML
25951Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25952instructions. The default is to use these instructions.
25953
d77de738
ML
25954@opindex mno-dwarf2-asm
25955@opindex mdwarf2-asm
ddf6fe37
AA
25956@item -mno-dwarf2-asm
25957@itemx -mdwarf2-asm
d77de738
ML
25958Don't (or do) generate assembler code for the DWARF line number debugging
25959info. This may be useful when not using the GNU assembler.
25960
d77de738
ML
25961@opindex mearly-stop-bits
25962@opindex mno-early-stop-bits
ddf6fe37
AA
25963@item -mearly-stop-bits
25964@itemx -mno-early-stop-bits
d77de738
ML
25965Allow stop bits to be placed earlier than immediately preceding the
25966instruction that triggered the stop bit. This can improve instruction
25967scheduling, but does not always do so.
25968
d77de738 25969@opindex mfixed-range
ddf6fe37 25970@item -mfixed-range=@var{register-range}
d77de738
ML
25971Generate code treating the given register range as fixed registers.
25972A fixed register is one that the register allocator cannot use. This is
25973useful when compiling kernel code. A register range is specified as
25974two registers separated by a dash. Multiple register ranges can be
25975specified separated by a comma.
25976
d77de738 25977@opindex mtls-size
ddf6fe37 25978@item -mtls-size=@var{tls-size}
d77de738
ML
25979Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2598064.
25981
d77de738 25982@opindex mtune
ddf6fe37 25983@item -mtune=@var{cpu-type}
d77de738
ML
25984Tune the instruction scheduling for a particular CPU, Valid values are
25985@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25986and @samp{mckinley}.
25987
d77de738
ML
25988@opindex milp32
25989@opindex mlp64
ddf6fe37
AA
25990@item -milp32
25991@itemx -mlp64
d77de738
ML
25992Generate code for a 32-bit or 64-bit environment.
25993The 32-bit environment sets int, long and pointer to 32 bits.
25994The 64-bit environment sets int to 32 bits and long and pointer
25995to 64 bits. These are HP-UX specific flags.
25996
d77de738
ML
25997@opindex mno-sched-br-data-spec
25998@opindex msched-br-data-spec
ddf6fe37
AA
25999@item -mno-sched-br-data-spec
26000@itemx -msched-br-data-spec
d77de738
ML
26001(Dis/En)able data speculative scheduling before reload.
26002This results in generation of @code{ld.a} instructions and
26003the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26004The default setting is disabled.
26005
d77de738
ML
26006@opindex msched-ar-data-spec
26007@opindex mno-sched-ar-data-spec
ddf6fe37
AA
26008@item -msched-ar-data-spec
26009@itemx -mno-sched-ar-data-spec
d77de738
ML
26010(En/Dis)able data speculative scheduling after reload.
26011This results in generation of @code{ld.a} instructions and
26012the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26013The default setting is enabled.
26014
d77de738
ML
26015@opindex mno-sched-control-spec
26016@opindex msched-control-spec
ddf6fe37
AA
26017@item -mno-sched-control-spec
26018@itemx -msched-control-spec
d77de738
ML
26019(Dis/En)able control speculative scheduling. This feature is
26020available only during region scheduling (i.e.@: before reload).
26021This results in generation of the @code{ld.s} instructions and
26022the corresponding check instructions @code{chk.s}.
26023The default setting is disabled.
26024
d77de738
ML
26025@opindex msched-br-in-data-spec
26026@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
26027@item -msched-br-in-data-spec
26028@itemx -mno-sched-br-in-data-spec
d77de738
ML
26029(En/Dis)able speculative scheduling of the instructions that
26030are dependent on the data speculative loads before reload.
26031This is effective only with @option{-msched-br-data-spec} enabled.
26032The default setting is enabled.
26033
d77de738
ML
26034@opindex msched-ar-in-data-spec
26035@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
26036@item -msched-ar-in-data-spec
26037@itemx -mno-sched-ar-in-data-spec
d77de738
ML
26038(En/Dis)able speculative scheduling of the instructions that
26039are dependent on the data speculative loads after reload.
26040This is effective only with @option{-msched-ar-data-spec} enabled.
26041The default setting is enabled.
26042
d77de738
ML
26043@opindex msched-in-control-spec
26044@opindex mno-sched-in-control-spec
ddf6fe37
AA
26045@item -msched-in-control-spec
26046@itemx -mno-sched-in-control-spec
d77de738
ML
26047(En/Dis)able speculative scheduling of the instructions that
26048are dependent on the control speculative loads.
26049This is effective only with @option{-msched-control-spec} enabled.
26050The default setting is enabled.
26051
d77de738
ML
26052@opindex mno-sched-prefer-non-data-spec-insns
26053@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
26054@item -mno-sched-prefer-non-data-spec-insns
26055@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
26056If enabled, data-speculative instructions are chosen for schedule
26057only if there are no other choices at the moment. This makes
26058the use of the data speculation much more conservative.
26059The default setting is disabled.
26060
d77de738
ML
26061@opindex mno-sched-prefer-non-control-spec-insns
26062@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
26063@item -mno-sched-prefer-non-control-spec-insns
26064@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
26065If enabled, control-speculative instructions are chosen for schedule
26066only if there are no other choices at the moment. This makes
26067the use of the control speculation much more conservative.
26068The default setting is disabled.
26069
d77de738
ML
26070@opindex mno-sched-count-spec-in-critical-path
26071@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
26072@item -mno-sched-count-spec-in-critical-path
26073@itemx -msched-count-spec-in-critical-path
d77de738
ML
26074If enabled, speculative dependencies are considered during
26075computation of the instructions priorities. This makes the use of the
26076speculation a bit more conservative.
26077The default setting is disabled.
26078
d77de738 26079@opindex msched-spec-ldc
ddf6fe37 26080@item -msched-spec-ldc
d77de738
ML
26081Use a simple data speculation check. This option is on by default.
26082
d77de738 26083@opindex msched-spec-ldc
ddf6fe37 26084@item -msched-control-spec-ldc
d77de738
ML
26085Use a simple check for control speculation. This option is on by default.
26086
d77de738 26087@opindex msched-stop-bits-after-every-cycle
ddf6fe37 26088@item -msched-stop-bits-after-every-cycle
d77de738
ML
26089Place a stop bit after every cycle when scheduling. This option is on
26090by default.
26091
d77de738 26092@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 26093@item -msched-fp-mem-deps-zero-cost
d77de738
ML
26094Assume that floating-point stores and loads are not likely to cause a conflict
26095when placed into the same instruction group. This option is disabled by
26096default.
26097
d77de738 26098@opindex msel-sched-dont-check-control-spec
ddf6fe37 26099@item -msel-sched-dont-check-control-spec
d77de738
ML
26100Generate checks for control speculation in selective scheduling.
26101This flag is disabled by default.
26102
d77de738 26103@opindex msched-max-memory-insns
ddf6fe37 26104@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
26105Limit on the number of memory insns per instruction group, giving lower
26106priority to subsequent memory insns attempting to schedule in the same
26107instruction group. Frequently useful to prevent cache bank conflicts.
26108The default value is 1.
26109
d77de738 26110@opindex msched-max-memory-insns-hard-limit
ddf6fe37 26111@item -msched-max-memory-insns-hard-limit
d77de738
ML
26112Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
26113disallowing more than that number in an instruction group.
26114Otherwise, the limit is ``soft'', meaning that non-memory operations
26115are preferred when the limit is reached, but memory operations may still
26116be scheduled.
26117
26118@end table
26119
26120@node LM32 Options
26121@subsection LM32 Options
26122@cindex LM32 options
26123
26124These @option{-m} options are defined for the LatticeMico32 architecture:
26125
26126@table @gcctabopt
d77de738 26127@opindex mbarrel-shift-enabled
ddf6fe37 26128@item -mbarrel-shift-enabled
d77de738
ML
26129Enable barrel-shift instructions.
26130
d77de738 26131@opindex mdivide-enabled
ddf6fe37 26132@item -mdivide-enabled
d77de738
ML
26133Enable divide and modulus instructions.
26134
d77de738 26135@opindex multiply-enabled
ddf6fe37 26136@item -mmultiply-enabled
d77de738
ML
26137Enable multiply instructions.
26138
d77de738 26139@opindex msign-extend-enabled
ddf6fe37 26140@item -msign-extend-enabled
d77de738
ML
26141Enable sign extend instructions.
26142
d77de738 26143@opindex muser-enabled
ddf6fe37 26144@item -muser-enabled
d77de738
ML
26145Enable user-defined instructions.
26146
26147@end table
26148
26149@node LoongArch Options
26150@subsection LoongArch Options
26151@cindex LoongArch Options
26152
26153These command-line options are defined for LoongArch targets:
26154
26155@table @gcctabopt
9c19597c 26156@opindex march
ddf6fe37 26157@item -march=@var{cpu-type}
d77de738
ML
26158Generate instructions for the machine type @var{cpu-type}. In contrast to
26159@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
26160for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
26161to generate code that may not run at all on processors other than the one
26162indicated. Specifying @option{-march=@var{cpu-type}} implies
26163@option{-mtune=@var{cpu-type}}, except where noted otherwise.
26164
26165The choices for @var{cpu-type} are:
26166
26167@table @samp
26168@item native
26169This selects the CPU to generate code for at compilation time by determining
26170the processor type of the compiling machine. Using @option{-march=native}
26171enables all instruction subsets supported by the local machine (hence
26172the result might not run on different machines). Using @option{-mtune=native}
26173produces code optimized for the local machine under the constraints
26174of the selected instruction set.
26175@item loongarch64
26176A generic CPU with 64-bit extensions.
26177@item la464
26178LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
26179@end table
26180
d77de738 26181@opindex mtune
ddf6fe37 26182@item -mtune=@var{cpu-type}
d77de738
ML
26183Optimize the output for the given processor, specified by microarchitecture
26184name.
26185
d77de738 26186@opindex mabi
ddf6fe37 26187@item -mabi=@var{base-abi-type}
d77de738
ML
26188Generate code for the specified calling convention.
26189@var{base-abi-type} can be one of:
26190@table @samp
26191@item lp64d
26192Uses 64-bit general purpose registers and 32/64-bit floating-point
26193registers for parameter passing. Data model is LP64, where @samp{int}
26194is 32 bits, while @samp{long int} and pointers are 64 bits.
26195@item lp64f
26196Uses 64-bit general purpose registers and 32-bit floating-point
26197registers for parameter passing. Data model is LP64, where @samp{int}
26198is 32 bits, while @samp{long int} and pointers are 64 bits.
26199@item lp64s
26200Uses 64-bit general purpose registers and no floating-point
26201registers for parameter passing. Data model is LP64, where @samp{int}
26202is 32 bits, while @samp{long int} and pointers are 64 bits.
26203@end table
26204
d77de738 26205@opindex mfpu
ddf6fe37 26206@item -mfpu=@var{fpu-type}
d77de738
ML
26207Generate code for the specified FPU type, which can be one of:
26208@table @samp
26209@item 64
26210Allow the use of hardware floating-point instructions for 32-bit
26211and 64-bit operations.
26212@item 32
26213Allow the use of hardware floating-point instructions for 32-bit
26214operations.
26215@item none
26216@item 0
26217Prevent the use of hardware floating-point instructions.
26218@end table
26219
bb4a8198
YY
26220@opindex msimd
26221@item -msimd=@var{simd-type}
26222Enable generation of LoongArch SIMD instructions for vectorization
26223and via builtin functions. The value can be one of:
26224@table @samp
26225@item lasx
26226Enable generating instructions from the 256-bit LoongArch Advanced
26227SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
26228@item lsx
26229Enable generating instructions from the 128-bit LoongArch SIMD
26230Extension (LSX).
26231@item none
26232No LoongArch SIMD instruction may be generated.
26233@end table
26234
d77de738 26235@opindex msoft-float
ddf6fe37 26236@item -msoft-float
d77de738
ML
26237Force @option{-mfpu=none} and prevents the use of floating-point
26238registers for parameter passing. This option may change the target
26239ABI.
26240
9c19597c 26241@opindex msingle-float
ddf6fe37 26242@item -msingle-float
d77de738
ML
26243Force @option{-mfpu=32} and allow the use of 32-bit floating-point
26244registers for parameter passing. This option may change the target
26245ABI.
26246
9c19597c 26247@opindex mdouble-float
ddf6fe37 26248@item -mdouble-float
d77de738
ML
26249Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
26250registers for parameter passing. This option may change the target
26251ABI.
26252
bb4a8198
YY
26253@opindex ml[a]sx
26254@item -mlasx
26255@itemx -mno-lasx
26256@item -mlsx
26257@itemx -mno-lsx
26258Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
26259that can be used by the compiler for code generation. Enabling LASX with
26260@option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
26261automatically disables LASX. These driver-only options act upon the final
26262@option{msimd} configuration state and make incremental chagnes in the order
26263they appear on the GCC driver's command line, deriving the final / canonicalized
26264@option{msimd} option that is passed to the compiler proper.
26265
9c19597c 26266@opindex mbranch-cost
ddf6fe37 26267@item -mbranch-cost=@var{n}
d77de738
ML
26268Set the cost of branches to roughly @var{n} instructions.
26269
ddf6fe37 26270@opindex mcheck-zero-division
d77de738
ML
26271@item -mcheck-zero-division
26272@itemx -mno-check-zero-divison
d77de738
ML
26273Trap (do not trap) on integer division by zero. The default is
26274@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
26275@option{-mno-check-zero-division} for other optimization levels.
26276
ddf6fe37 26277@opindex mcond-move-int
d77de738
ML
26278@item -mcond-move-int
26279@itemx -mno-cond-move-int
d77de738
ML
26280Conditional moves for integral data in general-purpose registers
26281are enabled (disabled). The default is @option{-mcond-move-int}.
26282
ddf6fe37 26283@opindex mcond-move-float
d77de738
ML
26284@item -mcond-move-float
26285@itemx -mno-cond-move-float
d77de738
ML
26286Conditional moves for floating-point registers are enabled (disabled).
26287The default is @option{-mcond-move-float}.
26288
ddf6fe37 26289@opindex mmemcpy
d77de738
ML
26290@item -mmemcpy
26291@itemx -mno-memcpy
d77de738
ML
26292Force (do not force) the use of @code{memcpy} for non-trivial block moves.
26293The default is @option{-mno-memcpy}, which allows GCC to inline most
26294constant-sized copies. Setting optimization level to @option{-Os} also
26295forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
26296behavior if explicitly specified, regardless of the order these options on
26297the command line.
26298
ddf6fe37 26299@opindex mstrict-align
d77de738
ML
26300@item -mstrict-align
26301@itemx -mno-strict-align
d77de738
ML
26302Avoid or allow generating memory accesses that may not be aligned on a natural
26303object boundary as described in the architecture specification. The default is
26304@option{-mno-strict-align}.
26305
9c19597c 26306@opindex msmall-data-limit
ddf6fe37 26307@item -msmall-data-limit=@var{number}
d77de738
ML
26308Put global and static data smaller than @var{number} bytes into a special
26309section (on some targets). The default value is 0.
26310
9c19597c 26311@opindex mmax-inline-memcpy-size
ddf6fe37 26312@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
26313Inline all block moves (such as calls to @code{memcpy} or structure copies)
26314less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
26315
26316@item -mcmodel=@var{code-model}
26317Set the code model to one of:
26318@table @samp
26319@item tiny-static (Not implemented yet)
26320@item tiny (Not implemented yet)
26321
26322@item normal
26323The text segment must be within 128MB addressing space. The data segment must
26324be within 2GB addressing space.
26325
26326@item medium
26327The text segment and data segment must be within 2GB addressing space.
26328
26329@item large (Not implemented yet)
26330
26331@item extreme
26332This mode does not limit the size of the code segment and data segment.
e1b1cba1
XR
26333The @option{-mcmodel=extreme} option is incompatible with @option{-fplt},
26334and it requires @option{-mexplicit-relocs=always}.
d77de738
ML
26335@end table
26336The default code model is @code{normal}.
26337
e1b1cba1
XR
26338@item -mexplicit-relocs=@var{style}
26339Set when to use assembler relocation operators when dealing with symbolic
d77de738 26340addresses. The alternative is to use assembler macros instead, which may
e1b1cba1
XR
26341limit instruction scheduling but allow linker relaxation.
26342with @option{-mexplicit-relocs=none} the assembler macros are always used,
26343with @option{-mexplicit-relocs=always} the assembler relocation operators
26344are always used, with @option{-mexplicit-relocs=auto} the compiler will
26345use the relocation operators where the linker relaxation is impossible to
26346improve the code quality, and macros elsewhere. The default
c25d6f15
XR
26347value for the option is determined during GCC build-time by detecting
26348corresponding assembler support:
e1b1cba1
XR
26349@option{-mexplicit-relocs=none} if the assembler does not support
26350relocation operators at all,
26351@option{-mexplicit-relocs=always} if the assembler supports relocation
26352operators but does not support relaxation,
26353@option{-mexplicit-relocs=auto} if the assembler supports both relocation
26354operators and relaxation. This option is mostly useful for
d77de738
ML
26355debugging, or interoperation with assemblers different from the build-time
26356one.
26357
e1b1cba1
XR
26358@opindex mexplicit-relocs
26359@item -mexplicit-relocs
26360An alias of @option{-mexplicit-relocs=always} for backward compatibility.
26361
26362@opindex mno-explicit-relocs
26363@item -mno-explicit-relocs
26364An alias of @option{-mexplicit-relocs=none} for backward compatibility.
26365
ddf6fe37 26366@opindex mdirect-extern-access
d77de738
ML
26367@item -mdirect-extern-access
26368@itemx -mno-direct-extern-access
d77de738
ML
26369Do not use or use GOT to access external symbols. The default is
26370@option{-mno-direct-extern-access}: GOT is used for external symbols with
26371default visibility, but not used for other external symbols.
26372
26373With @option{-mdirect-extern-access}, GOT is not used and all external
26374symbols are PC-relatively addressed. It is @strong{only} suitable for
26375environments where no dynamic link is performed, like firmwares, OS
26376kernels, executables linked with @option{-static} or @option{-static-pie}.
26377@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
26378@option{-fpic}.
8f4bbdc2
JX
26379
26380@item loongarch-vect-unroll-limit
26381The vectorizer will use available tuning information to determine whether it
26382would be beneficial to unroll the main vectorized loop and by how much. This
26383parameter set's the upper bound of how much the vectorizer will unroll the main
26384loop. The default value is six.
26385
d77de738
ML
26386@end table
26387
bb4a8198 26388
d77de738
ML
26389@node M32C Options
26390@subsection M32C Options
26391@cindex M32C options
26392
26393@table @gcctabopt
d77de738 26394@opindex mcpu=
ddf6fe37 26395@item -mcpu=@var{name}
d77de738
ML
26396Select the CPU for which code is generated. @var{name} may be one of
26397@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
26398/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
26399the M32C/80 series.
26400
d77de738 26401@opindex msim
ddf6fe37 26402@item -msim
d77de738
ML
26403Specifies that the program will be run on the simulator. This causes
26404an alternate runtime library to be linked in which supports, for
26405example, file I/O@. You must not use this option when generating
26406programs that will run on real hardware; you must provide your own
26407runtime library for whatever I/O functions are needed.
26408
d77de738 26409@opindex memregs=
ddf6fe37 26410@item -memregs=@var{number}
d77de738
ML
26411Specifies the number of memory-based pseudo-registers GCC uses
26412during code generation. These pseudo-registers are used like real
26413registers, so there is a tradeoff between GCC's ability to fit the
26414code into available registers, and the performance penalty of using
26415memory instead of registers. Note that all modules in a program must
26416be compiled with the same value for this option. Because of that, you
26417must not use this option with GCC's default runtime libraries.
26418
26419@end table
26420
26421@node M32R/D Options
26422@subsection M32R/D Options
26423@cindex M32R/D options
26424
26425These @option{-m} options are defined for Renesas M32R/D architectures:
26426
26427@table @gcctabopt
d77de738 26428@opindex m32r2
ddf6fe37 26429@item -m32r2
d77de738
ML
26430Generate code for the M32R/2@.
26431
d77de738 26432@opindex m32rx
ddf6fe37 26433@item -m32rx
d77de738
ML
26434Generate code for the M32R/X@.
26435
d77de738 26436@opindex m32r
ddf6fe37 26437@item -m32r
d77de738
ML
26438Generate code for the M32R@. This is the default.
26439
d77de738 26440@opindex mmodel=small
ddf6fe37 26441@item -mmodel=small
d77de738
ML
26442Assume all objects live in the lower 16MB of memory (so that their addresses
26443can be loaded with the @code{ld24} instruction), and assume all subroutines
26444are reachable with the @code{bl} instruction.
26445This is the default.
26446
26447The addressability of a particular object can be set with the
26448@code{model} attribute.
26449
d77de738 26450@opindex mmodel=medium
ddf6fe37 26451@item -mmodel=medium
d77de738
ML
26452Assume objects may be anywhere in the 32-bit address space (the compiler
26453generates @code{seth/add3} instructions to load their addresses), and
26454assume all subroutines are reachable with the @code{bl} instruction.
26455
d77de738 26456@opindex mmodel=large
ddf6fe37 26457@item -mmodel=large
d77de738
ML
26458Assume objects may be anywhere in the 32-bit address space (the compiler
26459generates @code{seth/add3} instructions to load their addresses), and
26460assume subroutines may not be reachable with the @code{bl} instruction
26461(the compiler generates the much slower @code{seth/add3/jl}
26462instruction sequence).
26463
d77de738 26464@opindex msdata=none
ddf6fe37 26465@item -msdata=none
d77de738
ML
26466Disable use of the small data area. Variables are put into
26467one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
26468@code{section} attribute has been specified).
26469This is the default.
26470
26471The small data area consists of sections @code{.sdata} and @code{.sbss}.
26472Objects may be explicitly put in the small data area with the
26473@code{section} attribute using one of these sections.
26474
d77de738 26475@opindex msdata=sdata
ddf6fe37 26476@item -msdata=sdata
d77de738
ML
26477Put small global and static data in the small data area, but do not
26478generate special code to reference them.
26479
d77de738 26480@opindex msdata=use
ddf6fe37 26481@item -msdata=use
d77de738
ML
26482Put small global and static data in the small data area, and generate
26483special instructions to reference them.
26484
d77de738
ML
26485@opindex G
26486@cindex smaller data references
f33d7a88 26487@item -G @var{num}
d77de738
ML
26488Put global and static objects less than or equal to @var{num} bytes
26489into the small data or BSS sections instead of the normal data or BSS
26490sections. The default value of @var{num} is 8.
26491The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
26492for this option to have any effect.
26493
26494All modules should be compiled with the same @option{-G @var{num}} value.
26495Compiling with different values of @var{num} may or may not work; if it
26496doesn't the linker gives an error message---incorrect code is not
26497generated.
26498
d77de738 26499@opindex mdebug
ddf6fe37 26500@item -mdebug
d77de738
ML
26501Makes the M32R-specific code in the compiler display some statistics
26502that might help in debugging programs.
26503
d77de738 26504@opindex malign-loops
ddf6fe37 26505@item -malign-loops
d77de738
ML
26506Align all loops to a 32-byte boundary.
26507
d77de738 26508@opindex mno-align-loops
ddf6fe37 26509@item -mno-align-loops
d77de738
ML
26510Do not enforce a 32-byte alignment for loops. This is the default.
26511
d77de738 26512@opindex missue-rate=@var{number}
ddf6fe37 26513@item -missue-rate=@var{number}
d77de738
ML
26514Issue @var{number} instructions per cycle. @var{number} can only be 1
26515or 2.
26516
d77de738 26517@opindex mbranch-cost=@var{number}
ddf6fe37 26518@item -mbranch-cost=@var{number}
d77de738
ML
26519@var{number} can only be 1 or 2. If it is 1 then branches are
26520preferred over conditional code, if it is 2, then the opposite applies.
26521
d77de738 26522@opindex mflush-trap=@var{number}
ddf6fe37 26523@item -mflush-trap=@var{number}
d77de738
ML
26524Specifies the trap number to use to flush the cache. The default is
2652512. Valid numbers are between 0 and 15 inclusive.
26526
d77de738 26527@opindex mno-flush-trap
ddf6fe37 26528@item -mno-flush-trap
d77de738
ML
26529Specifies that the cache cannot be flushed by using a trap.
26530
d77de738 26531@opindex mflush-func=@var{name}
ddf6fe37 26532@item -mflush-func=@var{name}
d77de738
ML
26533Specifies the name of the operating system function to call to flush
26534the cache. The default is @samp{_flush_cache}, but a function call
26535is only used if a trap is not available.
26536
d77de738 26537@opindex mno-flush-func
ddf6fe37 26538@item -mno-flush-func
d77de738
ML
26539Indicates that there is no OS function for flushing the cache.
26540
26541@end table
26542
26543@node M680x0 Options
26544@subsection M680x0 Options
26545@cindex M680x0 options
26546
26547These are the @samp{-m} options defined for M680x0 and ColdFire processors.
26548The default settings depend on which architecture was selected when
26549the compiler was configured; the defaults for the most common choices
26550are given below.
26551
26552@table @gcctabopt
d77de738 26553@opindex march
ddf6fe37 26554@item -march=@var{arch}
d77de738
ML
26555Generate code for a specific M680x0 or ColdFire instruction set
26556architecture. Permissible values of @var{arch} for M680x0
26557architectures are: @samp{68000}, @samp{68010}, @samp{68020},
26558@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
26559architectures are selected according to Freescale's ISA classification
26560and the permissible values are: @samp{isaa}, @samp{isaaplus},
26561@samp{isab} and @samp{isac}.
26562
26563GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
26564code for a ColdFire target. The @var{arch} in this macro is one of the
26565@option{-march} arguments given above.
26566
26567When used together, @option{-march} and @option{-mtune} select code
26568that runs on a family of similar processors but that is optimized
26569for a particular microarchitecture.
26570
d77de738 26571@opindex mcpu
ddf6fe37 26572@item -mcpu=@var{cpu}
d77de738
ML
26573Generate code for a specific M680x0 or ColdFire processor.
26574The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
26575@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
26576and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
26577below, which also classifies the CPUs into families:
26578
26579@multitable @columnfractions 0.20 0.80
26580@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
26581@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}
26582@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
26583@item @samp{5206e} @tab @samp{5206e}
26584@item @samp{5208} @tab @samp{5207} @samp{5208}
26585@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26586@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26587@item @samp{5216} @tab @samp{5214} @samp{5216}
26588@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26589@item @samp{5225} @tab @samp{5224} @samp{5225}
26590@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26591@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26592@item @samp{5249} @tab @samp{5249}
26593@item @samp{5250} @tab @samp{5250}
26594@item @samp{5271} @tab @samp{5270} @samp{5271}
26595@item @samp{5272} @tab @samp{5272}
26596@item @samp{5275} @tab @samp{5274} @samp{5275}
26597@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26598@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26599@item @samp{5307} @tab @samp{5307}
26600@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26601@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26602@item @samp{5407} @tab @samp{5407}
26603@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}
26604@end multitable
26605
26606@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26607@var{arch} is compatible with @var{cpu}. Other combinations of
26608@option{-mcpu} and @option{-march} are rejected.
26609
26610GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26611@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26612where the value of @var{family} is given by the table above.
26613
d77de738 26614@opindex mtune
ddf6fe37 26615@item -mtune=@var{tune}
d77de738
ML
26616Tune the code for a particular microarchitecture within the
26617constraints set by @option{-march} and @option{-mcpu}.
26618The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26619@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26620and @samp{cpu32}. The ColdFire microarchitectures
26621are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26622
26623You can also use @option{-mtune=68020-40} for code that needs
26624to run relatively well on 68020, 68030 and 68040 targets.
26625@option{-mtune=68020-60} is similar but includes 68060 targets
26626as well. These two options select the same tuning decisions as
26627@option{-m68020-40} and @option{-m68020-60} respectively.
26628
26629GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26630when tuning for 680x0 architecture @var{arch}. It also defines
26631@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26632option is used. If GCC is tuning for a range of architectures,
26633as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26634it defines the macros for every architecture in the range.
26635
26636GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26637ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26638of the arguments given above.
26639
d77de738
ML
26640@opindex m68000
26641@opindex mc68000
ddf6fe37
AA
26642@item -m68000
26643@itemx -mc68000
d77de738
ML
26644Generate output for a 68000. This is the default
26645when the compiler is configured for 68000-based systems.
26646It is equivalent to @option{-march=68000}.
26647
26648Use this option for microcontrollers with a 68000 or EC000 core,
26649including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26650
d77de738 26651@opindex m68010
ddf6fe37 26652@item -m68010
d77de738
ML
26653Generate output for a 68010. This is the default
26654when the compiler is configured for 68010-based systems.
26655It is equivalent to @option{-march=68010}.
26656
d77de738
ML
26657@opindex m68020
26658@opindex mc68020
ddf6fe37
AA
26659@item -m68020
26660@itemx -mc68020
d77de738
ML
26661Generate output for a 68020. This is the default
26662when the compiler is configured for 68020-based systems.
26663It is equivalent to @option{-march=68020}.
26664
d77de738 26665@opindex m68030
ddf6fe37 26666@item -m68030
d77de738
ML
26667Generate output for a 68030. This is the default when the compiler is
26668configured for 68030-based systems. It is equivalent to
26669@option{-march=68030}.
26670
d77de738 26671@opindex m68040
ddf6fe37 26672@item -m68040
d77de738
ML
26673Generate output for a 68040. This is the default when the compiler is
26674configured for 68040-based systems. It is equivalent to
26675@option{-march=68040}.
26676
26677This option inhibits the use of 68881/68882 instructions that have to be
26678emulated by software on the 68040. Use this option if your 68040 does not
26679have code to emulate those instructions.
26680
d77de738 26681@opindex m68060
ddf6fe37 26682@item -m68060
d77de738
ML
26683Generate output for a 68060. This is the default when the compiler is
26684configured for 68060-based systems. It is equivalent to
26685@option{-march=68060}.
26686
26687This option inhibits the use of 68020 and 68881/68882 instructions that
26688have to be emulated by software on the 68060. Use this option if your 68060
26689does not have code to emulate those instructions.
26690
d77de738 26691@opindex mcpu32
ddf6fe37 26692@item -mcpu32
d77de738
ML
26693Generate output for a CPU32. This is the default
26694when the compiler is configured for CPU32-based systems.
26695It is equivalent to @option{-march=cpu32}.
26696
26697Use this option for microcontrollers with a
26698CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2669968336, 68340, 68341, 68349 and 68360.
26700
d77de738 26701@opindex m5200
ddf6fe37 26702@item -m5200
d77de738
ML
26703Generate output for a 520X ColdFire CPU@. This is the default
26704when the compiler is configured for 520X-based systems.
26705It is equivalent to @option{-mcpu=5206}, and is now deprecated
26706in favor of that option.
26707
26708Use this option for microcontroller with a 5200 core, including
26709the MCF5202, MCF5203, MCF5204 and MCF5206.
26710
d77de738 26711@opindex m5206e
ddf6fe37 26712@item -m5206e
d77de738
ML
26713Generate output for a 5206e ColdFire CPU@. The option is now
26714deprecated in favor of the equivalent @option{-mcpu=5206e}.
26715
d77de738 26716@opindex m528x
ddf6fe37 26717@item -m528x
d77de738
ML
26718Generate output for a member of the ColdFire 528X family.
26719The option is now deprecated in favor of the equivalent
26720@option{-mcpu=528x}.
26721
d77de738 26722@opindex m5307
ddf6fe37 26723@item -m5307
d77de738
ML
26724Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26725in favor of the equivalent @option{-mcpu=5307}.
26726
d77de738 26727@opindex m5407
ddf6fe37 26728@item -m5407
d77de738
ML
26729Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26730in favor of the equivalent @option{-mcpu=5407}.
26731
d77de738 26732@opindex mcfv4e
ddf6fe37 26733@item -mcfv4e
d77de738
ML
26734Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26735This includes use of hardware floating-point instructions.
26736The option is equivalent to @option{-mcpu=547x}, and is now
26737deprecated in favor of that option.
26738
d77de738 26739@opindex m68020-40
ddf6fe37 26740@item -m68020-40
d77de738
ML
26741Generate output for a 68040, without using any of the new instructions.
26742This results in code that can run relatively efficiently on either a
2674368020/68881 or a 68030 or a 68040. The generated code does use the
2674468881 instructions that are emulated on the 68040.
26745
26746The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26747
d77de738 26748@opindex m68020-60
ddf6fe37 26749@item -m68020-60
d77de738
ML
26750Generate output for a 68060, without using any of the new instructions.
26751This results in code that can run relatively efficiently on either a
2675268020/68881 or a 68030 or a 68040. The generated code does use the
2675368881 instructions that are emulated on the 68060.
26754
26755The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26756
d77de738
ML
26757@opindex mhard-float
26758@opindex m68881
ddf6fe37
AA
26759@item -mhard-float
26760@itemx -m68881
d77de738
ML
26761Generate floating-point instructions. This is the default for 68020
26762and above, and for ColdFire devices that have an FPU@. It defines the
26763macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26764on ColdFire targets.
26765
d77de738 26766@opindex msoft-float
ddf6fe37 26767@item -msoft-float
d77de738
ML
26768Do not generate floating-point instructions; use library calls instead.
26769This is the default for 68000, 68010, and 68832 targets. It is also
26770the default for ColdFire devices that have no FPU.
26771
d77de738
ML
26772@opindex mdiv
26773@opindex mno-div
ddf6fe37
AA
26774@item -mdiv
26775@itemx -mno-div
d77de738
ML
26776Generate (do not generate) ColdFire hardware divide and remainder
26777instructions. If @option{-march} is used without @option{-mcpu},
26778the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26779architectures. Otherwise, the default is taken from the target CPU
26780(either the default CPU, or the one specified by @option{-mcpu}). For
26781example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26782@option{-mcpu=5206e}.
26783
26784GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26785
d77de738 26786@opindex mshort
ddf6fe37 26787@item -mshort
d77de738
ML
26788Consider type @code{int} to be 16 bits wide, like @code{short int}.
26789Additionally, parameters passed on the stack are also aligned to a
2679016-bit boundary even on targets whose API mandates promotion to 32-bit.
26791
d77de738 26792@opindex mno-short
ddf6fe37 26793@item -mno-short
d77de738
ML
26794Do not consider type @code{int} to be 16 bits wide. This is the default.
26795
d77de738
ML
26796@opindex mnobitfield
26797@opindex mno-bitfield
ddf6fe37
AA
26798@item -mnobitfield
26799@itemx -mno-bitfield
d77de738
ML
26800Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26801and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26802
d77de738 26803@opindex mbitfield
ddf6fe37 26804@item -mbitfield
d77de738
ML
26805Do use the bit-field instructions. The @option{-m68020} option implies
26806@option{-mbitfield}. This is the default if you use a configuration
26807designed for a 68020.
26808
d77de738 26809@opindex mrtd
ddf6fe37 26810@item -mrtd
d77de738
ML
26811Use a different function-calling convention, in which functions
26812that take a fixed number of arguments return with the @code{rtd}
26813instruction, which pops their arguments while returning. This
26814saves one instruction in the caller since there is no need to pop
26815the arguments there.
26816
26817This calling convention is incompatible with the one normally
26818used on Unix, so you cannot use it if you need to call libraries
26819compiled with the Unix compiler.
26820
26821Also, you must provide function prototypes for all functions that
26822take variable numbers of arguments (including @code{printf});
26823otherwise incorrect code is generated for calls to those
26824functions.
26825
26826In addition, seriously incorrect code results if you call a
26827function with too many arguments. (Normally, extra arguments are
26828harmlessly ignored.)
26829
26830The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2683168040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26832
26833The default is @option{-mno-rtd}.
26834
d77de738
ML
26835@opindex malign-int
26836@opindex mno-align-int
ddf6fe37
AA
26837@item -malign-int
26838@itemx -mno-align-int
d77de738
ML
26839Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26840@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26841boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26842Aligning variables on 32-bit boundaries produces code that runs somewhat
26843faster on processors with 32-bit busses at the expense of more memory.
26844
26845@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26846aligns structures containing the above types differently than
26847most published application binary interface specifications for the m68k.
26848
26849@opindex mpcrel
26850Use the pc-relative addressing mode of the 68000 directly, instead of
26851using a global offset table. At present, this option implies @option{-fpic},
26852allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26853not presently supported with @option{-mpcrel}, though this could be supported for
2685468020 and higher processors.
26855
d77de738
ML
26856@opindex mno-strict-align
26857@opindex mstrict-align
ddf6fe37
AA
26858@item -mno-strict-align
26859@itemx -mstrict-align
d77de738
ML
26860Do not (do) assume that unaligned memory references are handled by
26861the system.
26862
26863@item -msep-data
26864Generate code that allows the data segment to be located in a different
26865area of memory from the text segment. This allows for execute-in-place in
26866an environment without virtual memory management. This option implies
26867@option{-fPIC}.
26868
26869@item -mno-sep-data
26870Generate code that assumes that the data segment follows the text segment.
26871This is the default.
26872
26873@item -mid-shared-library
26874Generate code that supports shared libraries via the library ID method.
26875This allows for execute-in-place and shared libraries in an environment
26876without virtual memory management. This option implies @option{-fPIC}.
26877
26878@item -mno-id-shared-library
26879Generate code that doesn't assume ID-based shared libraries are being used.
26880This is the default.
26881
26882@item -mshared-library-id=n
26883Specifies the identification number of the ID-based shared library being
26884compiled. Specifying a value of 0 generates more compact code; specifying
26885other values forces the allocation of that number to the current
26886library, but is no more space- or time-efficient than omitting this option.
26887
d77de738
ML
26888@opindex mxgot
26889@opindex mno-xgot
ddf6fe37
AA
26890@item -mxgot
26891@itemx -mno-xgot
d77de738
ML
26892When generating position-independent code for ColdFire, generate code
26893that works if the GOT has more than 8192 entries. This code is
26894larger and slower than code generated without this option. On M680x0
26895processors, this option is not needed; @option{-fPIC} suffices.
26896
26897GCC normally uses a single instruction to load values from the GOT@.
26898While this is relatively efficient, it only works if the GOT
26899is smaller than about 64k. Anything larger causes the linker
26900to report an error such as:
26901
26902@cindex relocation truncated to fit (ColdFire)
26903@smallexample
26904relocation truncated to fit: R_68K_GOT16O foobar
26905@end smallexample
26906
26907If this happens, you should recompile your code with @option{-mxgot}.
26908It should then work with very large GOTs. However, code generated with
26909@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26910the value of a global symbol.
26911
26912Note that some linkers, including newer versions of the GNU linker,
26913can create multiple GOTs and sort GOT entries. If you have such a linker,
26914you should only need to use @option{-mxgot} when compiling a single
26915object file that accesses more than 8192 GOT entries. Very few do.
26916
26917These options have no effect unless GCC is generating
26918position-independent code.
26919
d77de738 26920@opindex mlong-jump-table-offsets
ddf6fe37 26921@item -mlong-jump-table-offsets
d77de738
ML
26922Use 32-bit offsets in @code{switch} tables. The default is to use
2692316-bit offsets.
26924
26925@end table
26926
26927@node MCore Options
26928@subsection MCore Options
26929@cindex MCore options
26930
26931These are the @samp{-m} options defined for the Motorola M*Core
26932processors.
26933
26934@table @gcctabopt
26935
d77de738
ML
26936@opindex mhardlit
26937@opindex mno-hardlit
ddf6fe37
AA
26938@item -mhardlit
26939@itemx -mno-hardlit
d77de738
ML
26940Inline constants into the code stream if it can be done in two
26941instructions or less.
26942
d77de738
ML
26943@opindex mdiv
26944@opindex mno-div
ddf6fe37
AA
26945@item -mdiv
26946@itemx -mno-div
d77de738
ML
26947Use the divide instruction. (Enabled by default).
26948
d77de738
ML
26949@opindex mrelax-immediate
26950@opindex mno-relax-immediate
ddf6fe37
AA
26951@item -mrelax-immediate
26952@itemx -mno-relax-immediate
d77de738
ML
26953Allow arbitrary-sized immediates in bit operations.
26954
d77de738
ML
26955@opindex mwide-bitfields
26956@opindex mno-wide-bitfields
ddf6fe37
AA
26957@item -mwide-bitfields
26958@itemx -mno-wide-bitfields
d77de738
ML
26959Always treat bit-fields as @code{int}-sized.
26960
d77de738
ML
26961@opindex m4byte-functions
26962@opindex mno-4byte-functions
ddf6fe37
AA
26963@item -m4byte-functions
26964@itemx -mno-4byte-functions
d77de738
ML
26965Force all functions to be aligned to a 4-byte boundary.
26966
d77de738
ML
26967@opindex mcallgraph-data
26968@opindex mno-callgraph-data
ddf6fe37
AA
26969@item -mcallgraph-data
26970@itemx -mno-callgraph-data
d77de738
ML
26971Emit callgraph information.
26972
d77de738
ML
26973@opindex mslow-bytes
26974@opindex mno-slow-bytes
ddf6fe37
AA
26975@item -mslow-bytes
26976@itemx -mno-slow-bytes
d77de738
ML
26977Prefer word access when reading byte quantities.
26978
d77de738
ML
26979@opindex mlittle-endian
26980@opindex mbig-endian
ddf6fe37
AA
26981@item -mlittle-endian
26982@itemx -mbig-endian
d77de738
ML
26983Generate code for a little-endian target.
26984
d77de738
ML
26985@opindex m210
26986@opindex m340
ddf6fe37
AA
26987@item -m210
26988@itemx -m340
d77de738
ML
26989Generate code for the 210 processor.
26990
d77de738 26991@opindex mno-lsim
ddf6fe37 26992@item -mno-lsim
d77de738
ML
26993Assume that runtime support has been provided and so omit the
26994simulator library (@file{libsim.a)} from the linker command line.
26995
d77de738 26996@opindex mstack-increment
ddf6fe37 26997@item -mstack-increment=@var{size}
d77de738
ML
26998Set the maximum amount for a single stack increment operation. Large
26999values can increase the speed of programs that contain functions
27000that need a large amount of stack space, but they can also trigger a
27001segmentation fault if the stack is extended too much. The default
27002value is 0x1000.
27003
27004@end table
27005
d77de738
ML
27006@node MicroBlaze Options
27007@subsection MicroBlaze Options
27008@cindex MicroBlaze Options
27009
27010@table @gcctabopt
27011
d77de738 27012@opindex msoft-float
ddf6fe37 27013@item -msoft-float
d77de738
ML
27014Use software emulation for floating point (default).
27015
d77de738 27016@opindex mhard-float
ddf6fe37 27017@item -mhard-float
d77de738
ML
27018Use hardware floating-point instructions.
27019
d77de738 27020@opindex mmemcpy
ddf6fe37 27021@item -mmemcpy
d77de738
ML
27022Do not optimize block moves, use @code{memcpy}.
27023
d77de738 27024@opindex mno-clearbss
ddf6fe37 27025@item -mno-clearbss
d77de738
ML
27026This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
27027
d77de738 27028@opindex mcpu=
ddf6fe37 27029@item -mcpu=@var{cpu-type}
d77de738
ML
27030Use features of, and schedule code for, the given CPU.
27031Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
27032where @var{X} is a major version, @var{YY} is the minor version, and
27033@var{Z} is compatibility code. Example values are @samp{v3.00.a},
27034@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
27035
d77de738 27036@opindex mxl-soft-mul
ddf6fe37 27037@item -mxl-soft-mul
d77de738
ML
27038Use software multiply emulation (default).
27039
d77de738 27040@opindex mxl-soft-div
ddf6fe37 27041@item -mxl-soft-div
d77de738
ML
27042Use software emulation for divides (default).
27043
d77de738 27044@opindex mxl-barrel-shift
ddf6fe37 27045@item -mxl-barrel-shift
d77de738
ML
27046Use the hardware barrel shifter.
27047
d77de738 27048@opindex mxl-pattern-compare
ddf6fe37 27049@item -mxl-pattern-compare
d77de738
ML
27050Use pattern compare instructions.
27051
d77de738 27052@opindex msmall-divides
ddf6fe37 27053@item -msmall-divides
d77de738
ML
27054Use table lookup optimization for small signed integer divisions.
27055
d77de738 27056@opindex mxl-stack-check
ddf6fe37 27057@item -mxl-stack-check
d77de738
ML
27058This option is deprecated. Use @option{-fstack-check} instead.
27059
d77de738 27060@opindex mxl-gp-opt
ddf6fe37 27061@item -mxl-gp-opt
d77de738
ML
27062Use GP-relative @code{.sdata}/@code{.sbss} sections.
27063
d77de738 27064@opindex mxl-multiply-high
ddf6fe37 27065@item -mxl-multiply-high
d77de738
ML
27066Use multiply high instructions for high part of 32x32 multiply.
27067
d77de738 27068@opindex mxl-float-convert
ddf6fe37 27069@item -mxl-float-convert
d77de738
ML
27070Use hardware floating-point conversion instructions.
27071
d77de738 27072@opindex mxl-float-sqrt
ddf6fe37 27073@item -mxl-float-sqrt
d77de738
ML
27074Use hardware floating-point square root instruction.
27075
d77de738 27076@opindex mbig-endian
ddf6fe37 27077@item -mbig-endian
d77de738
ML
27078Generate code for a big-endian target.
27079
d77de738 27080@opindex mlittle-endian
ddf6fe37 27081@item -mlittle-endian
d77de738
ML
27082Generate code for a little-endian target.
27083
d77de738 27084@opindex mxl-reorder
ddf6fe37 27085@item -mxl-reorder
d77de738
ML
27086Use reorder instructions (swap and byte reversed load/store).
27087
27088@item -mxl-mode-@var{app-model}
27089Select application model @var{app-model}. Valid models are
27090@table @samp
27091@item executable
27092normal executable (default), uses startup code @file{crt0.o}.
27093
27094@item xmdstub
27095for use with Xilinx Microprocessor Debugger (XMD) based
27096software intrusive debug agent called xmdstub. This uses startup file
27097@file{crt1.o} and sets the start address of the program to 0x800.
27098
27099@item bootstrap
27100for applications that are loaded using a bootloader.
27101This model uses startup file @file{crt2.o} which does not contain a processor
27102reset vector handler. This is suitable for transferring control on a
27103processor reset to the bootloader rather than the application.
27104
27105@item novectors
27106for applications that do not require any of the
27107MicroBlaze vectors. This option may be useful for applications running
27108within a monitoring application. This model uses @file{crt3.o} as a startup file.
27109@end table
27110
27111Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
27112@option{-mxl-mode-@var{app-model}}.
27113
d77de738 27114@opindex mpic-data-is-text-relative
ddf6fe37 27115@item -mpic-data-is-text-relative
d77de738
ML
27116Assume that the displacement between the text and data segments is fixed
27117at static link time. This allows data to be referenced by offset from start of
27118text address instead of GOT since PC-relative addressing is not supported.
27119
27120@end table
27121
27122@node MIPS Options
27123@subsection MIPS Options
27124@cindex MIPS options
27125
27126@table @gcctabopt
27127
d77de738 27128@opindex EB
ddf6fe37 27129@item -EB
d77de738
ML
27130Generate big-endian code.
27131
d77de738 27132@opindex EL
ddf6fe37 27133@item -EL
d77de738
ML
27134Generate little-endian code. This is the default for @samp{mips*el-*-*}
27135configurations.
27136
d77de738 27137@opindex march
ddf6fe37 27138@item -march=@var{arch}
d77de738
ML
27139Generate code that runs on @var{arch}, which can be the name of a
27140generic MIPS ISA, or the name of a particular processor.
27141The ISA names are:
27142@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
27143@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
27144@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
27145@samp{mips64r5} and @samp{mips64r6}.
27146The processor names are:
27147@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
27148@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
27149@samp{5kc}, @samp{5kf},
27150@samp{20kc},
27151@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
27152@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
27153@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
27154@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
27155@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
27156@samp{i6400}, @samp{i6500},
27157@samp{interaptiv},
27158@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
27159@samp{gs464e}, @samp{gs264e},
27160@samp{m4k},
27161@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
27162@samp{m5100}, @samp{m5101},
27163@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
27164@samp{orion},
27165@samp{p5600}, @samp{p6600},
27166@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
27167@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
27168@samp{r6000}, @samp{r8000},
27169@samp{rm7000}, @samp{rm9000},
27170@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
27171@samp{sb1},
27172@samp{sr71000},
27173@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
27174@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
27175@samp{xlr} and @samp{xlp}.
27176The special value @samp{from-abi} selects the
27177most compatible architecture for the selected ABI (that is,
27178@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
27179
27180The native Linux/GNU toolchain also supports the value @samp{native},
27181which selects the best architecture option for the host processor.
27182@option{-march=native} has no effect if GCC does not recognize
27183the processor.
27184
27185In processor names, a final @samp{000} can be abbreviated as @samp{k}
27186(for example, @option{-march=r2k}). Prefixes are optional, and
27187@samp{vr} may be written @samp{r}.
27188
27189Names of the form @samp{@var{n}f2_1} refer to processors with
27190FPUs clocked at half the rate of the core, names of the form
27191@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
27192rate as the core, and names of the form @samp{@var{n}f3_2} refer to
27193processors with FPUs clocked a ratio of 3:2 with respect to the core.
27194For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
27195for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
27196accepted as synonyms for @samp{@var{n}f1_1}.
27197
27198GCC defines two macros based on the value of this option. The first
27199is @code{_MIPS_ARCH}, which gives the name of target architecture, as
27200a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
27201where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
27202For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
27203to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
27204
27205Note that the @code{_MIPS_ARCH} macro uses the processor names given
27206above. In other words, it has the full prefix and does not
27207abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
27208the macro names the resolved architecture (either @code{"mips1"} or
27209@code{"mips3"}). It names the default architecture when no
27210@option{-march} option is given.
27211
d77de738 27212@opindex mtune
ddf6fe37 27213@item -mtune=@var{arch}
d77de738
ML
27214Optimize for @var{arch}. Among other things, this option controls
27215the way instructions are scheduled, and the perceived cost of arithmetic
27216operations. The list of @var{arch} values is the same as for
27217@option{-march}.
27218
27219When this option is not used, GCC optimizes for the processor
27220specified by @option{-march}. By using @option{-march} and
27221@option{-mtune} together, it is possible to generate code that
27222runs on a family of processors, but optimize the code for one
27223particular member of that family.
27224
27225@option{-mtune} defines the macros @code{_MIPS_TUNE} and
27226@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
27227@option{-march} ones described above.
27228
d77de738 27229@opindex mips1
ddf6fe37 27230@item -mips1
d77de738
ML
27231Equivalent to @option{-march=mips1}.
27232
d77de738 27233@opindex mips2
ddf6fe37 27234@item -mips2
d77de738
ML
27235Equivalent to @option{-march=mips2}.
27236
d77de738 27237@opindex mips3
ddf6fe37 27238@item -mips3
d77de738
ML
27239Equivalent to @option{-march=mips3}.
27240
d77de738 27241@opindex mips4
ddf6fe37 27242@item -mips4
d77de738
ML
27243Equivalent to @option{-march=mips4}.
27244
d77de738 27245@opindex mips32
ddf6fe37 27246@item -mips32
d77de738
ML
27247Equivalent to @option{-march=mips32}.
27248
d77de738 27249@opindex mips32r3
ddf6fe37 27250@item -mips32r3
d77de738
ML
27251Equivalent to @option{-march=mips32r3}.
27252
d77de738 27253@opindex mips32r5
ddf6fe37 27254@item -mips32r5
d77de738
ML
27255Equivalent to @option{-march=mips32r5}.
27256
d77de738 27257@opindex mips32r6
ddf6fe37 27258@item -mips32r6
d77de738
ML
27259Equivalent to @option{-march=mips32r6}.
27260
d77de738 27261@opindex mips64
ddf6fe37 27262@item -mips64
d77de738
ML
27263Equivalent to @option{-march=mips64}.
27264
d77de738 27265@opindex mips64r2
ddf6fe37 27266@item -mips64r2
d77de738
ML
27267Equivalent to @option{-march=mips64r2}.
27268
d77de738 27269@opindex mips64r3
ddf6fe37 27270@item -mips64r3
d77de738
ML
27271Equivalent to @option{-march=mips64r3}.
27272
d77de738 27273@opindex mips64r5
ddf6fe37 27274@item -mips64r5
d77de738
ML
27275Equivalent to @option{-march=mips64r5}.
27276
d77de738 27277@opindex mips64r6
ddf6fe37 27278@item -mips64r6
d77de738
ML
27279Equivalent to @option{-march=mips64r6}.
27280
d77de738
ML
27281@opindex mips16
27282@opindex mno-mips16
ddf6fe37
AA
27283@item -mips16
27284@itemx -mno-mips16
d77de738
ML
27285Generate (do not generate) MIPS16 code. If GCC is targeting a
27286MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
27287
27288MIPS16 code generation can also be controlled on a per-function basis
27289by means of @code{mips16} and @code{nomips16} attributes.
27290@xref{Function Attributes}, for more information.
27291
926f2d09
JM
27292@opindex mmips16e2
27293@opindex mno-mips16e2
27294@item -mmips16e2
27295@itemx -mno-mips16e2
27296Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
27297of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
27298
d77de738 27299@opindex mflip-mips16
ddf6fe37 27300@item -mflip-mips16
d77de738
ML
27301Generate MIPS16 code on alternating functions. This option is provided
27302for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
27303not intended for ordinary use in compiling user code.
27304
d77de738
ML
27305@opindex minterlink-compressed
27306@opindex mno-interlink-compressed
ddf6fe37
AA
27307@item -minterlink-compressed
27308@itemx -mno-interlink-compressed
d77de738
ML
27309Require (do not require) that code using the standard (uncompressed) MIPS ISA
27310be link-compatible with MIPS16 and microMIPS code, and vice versa.
27311
27312For example, code using the standard ISA encoding cannot jump directly
27313to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
27314@option{-minterlink-compressed} therefore disables direct jumps unless GCC
27315knows that the target of the jump is not compressed.
27316
d77de738
ML
27317@opindex minterlink-mips16
27318@opindex mno-interlink-mips16
ddf6fe37
AA
27319@item -minterlink-mips16
27320@itemx -mno-interlink-mips16
d77de738
ML
27321Aliases of @option{-minterlink-compressed} and
27322@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
27323and are retained for backwards compatibility.
27324
d77de738
ML
27325@opindex mabi=32
27326@opindex mabi=o64
27327@opindex mabi=n32
27328@opindex mabi=64
27329@opindex mabi=eabi
ddf6fe37
AA
27330@item -mabi=32
27331@itemx -mabi=o64
27332@itemx -mabi=n32
27333@itemx -mabi=64
27334@itemx -mabi=eabi
d77de738
ML
27335Generate code for the given ABI@.
27336
27337Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
27338generates 64-bit code when you select a 64-bit architecture, but you
27339can use @option{-mgp32} to get 32-bit code instead.
27340
27341For information about the O64 ABI, see
27342@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
27343
27344GCC supports a variant of the o32 ABI in which floating-point registers
27345are 64 rather than 32 bits wide. You can select this combination with
27346@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
27347and @code{mfhc1} instructions and is therefore only supported for
27348MIPS32R2, MIPS32R3 and MIPS32R5 processors.
27349
27350The register assignments for arguments and return values remain the
27351same, but each scalar value is passed in a single 64-bit register
27352rather than a pair of 32-bit registers. For example, scalar
27353floating-point values are returned in @samp{$f0} only, not a
27354@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
27355remains the same in that the even-numbered double-precision registers
27356are saved.
27357
27358Two additional variants of the o32 ABI are supported to enable
27359a transition from 32-bit to 64-bit registers. These are FPXX
27360(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
27361The FPXX extension mandates that all code must execute correctly
27362when run using 32-bit or 64-bit registers. The code can be interlinked
27363with either FP32 or FP64, but not both.
27364The FP64A extension is similar to the FP64 extension but forbids the
27365use of odd-numbered single-precision registers. This can be used
27366in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
27367processors and allows both FP32 and FP64A code to interlink and
27368run in the same process without changing FPU modes.
27369
d77de738
ML
27370@opindex mabicalls
27371@opindex mno-abicalls
ddf6fe37
AA
27372@item -mabicalls
27373@itemx -mno-abicalls
d77de738
ML
27374Generate (do not generate) code that is suitable for SVR4-style
27375dynamic objects. @option{-mabicalls} is the default for SVR4-based
27376systems.
27377
27378@item -mshared
27379@itemx -mno-shared
27380Generate (do not generate) code that is fully position-independent,
27381and that can therefore be linked into shared libraries. This option
27382only affects @option{-mabicalls}.
27383
27384All @option{-mabicalls} code has traditionally been position-independent,
27385regardless of options like @option{-fPIC} and @option{-fpic}. However,
27386as an extension, the GNU toolchain allows executables to use absolute
27387accesses for locally-binding symbols. It can also use shorter GP
27388initialization sequences and generate direct calls to locally-defined
27389functions. This mode is selected by @option{-mno-shared}.
27390
27391@option{-mno-shared} depends on binutils 2.16 or higher and generates
27392objects that can only be linked by the GNU linker. However, the option
27393does not affect the ABI of the final executable; it only affects the ABI
27394of relocatable objects. Using @option{-mno-shared} generally makes
27395executables both smaller and quicker.
27396
27397@option{-mshared} is the default.
27398
d77de738
ML
27399@opindex mplt
27400@opindex mno-plt
ddf6fe37
AA
27401@item -mplt
27402@itemx -mno-plt
d77de738
ML
27403Assume (do not assume) that the static and dynamic linkers
27404support PLTs and copy relocations. This option only affects
27405@option{-mno-shared -mabicalls}. For the n64 ABI, this option
27406has no effect without @option{-msym32}.
27407
27408You can make @option{-mplt} the default by configuring
27409GCC with @option{--with-mips-plt}. The default is
27410@option{-mno-plt} otherwise.
27411
d77de738
ML
27412@opindex mxgot
27413@opindex mno-xgot
ddf6fe37
AA
27414@item -mxgot
27415@itemx -mno-xgot
d77de738
ML
27416Lift (do not lift) the usual restrictions on the size of the global
27417offset table.
27418
27419GCC normally uses a single instruction to load values from the GOT@.
27420While this is relatively efficient, it only works if the GOT
27421is smaller than about 64k. Anything larger causes the linker
27422to report an error such as:
27423
27424@cindex relocation truncated to fit (MIPS)
27425@smallexample
27426relocation truncated to fit: R_MIPS_GOT16 foobar
27427@end smallexample
27428
27429If this happens, you should recompile your code with @option{-mxgot}.
27430This works with very large GOTs, although the code is also
27431less efficient, since it takes three instructions to fetch the
27432value of a global symbol.
27433
27434Note that some linkers can create multiple GOTs. If you have such a
27435linker, you should only need to use @option{-mxgot} when a single object
27436file accesses more than 64k's worth of GOT entries. Very few do.
27437
27438These options have no effect unless GCC is generating position
27439independent code.
27440
d77de738 27441@opindex mgp32
ddf6fe37 27442@item -mgp32
d77de738
ML
27443Assume that general-purpose registers are 32 bits wide.
27444
d77de738 27445@opindex mgp64
ddf6fe37 27446@item -mgp64
d77de738
ML
27447Assume that general-purpose registers are 64 bits wide.
27448
d77de738 27449@opindex mfp32
ddf6fe37 27450@item -mfp32
d77de738
ML
27451Assume that floating-point registers are 32 bits wide.
27452
d77de738 27453@opindex mfp64
ddf6fe37 27454@item -mfp64
d77de738
ML
27455Assume that floating-point registers are 64 bits wide.
27456
d77de738 27457@opindex mfpxx
ddf6fe37 27458@item -mfpxx
d77de738
ML
27459Do not assume the width of floating-point registers.
27460
d77de738 27461@opindex mhard-float
ddf6fe37 27462@item -mhard-float
d77de738
ML
27463Use floating-point coprocessor instructions.
27464
d77de738 27465@opindex msoft-float
ddf6fe37 27466@item -msoft-float
d77de738
ML
27467Do not use floating-point coprocessor instructions. Implement
27468floating-point calculations using library calls instead.
27469
d77de738 27470@opindex mno-float
ddf6fe37 27471@item -mno-float
d77de738
ML
27472Equivalent to @option{-msoft-float}, but additionally asserts that the
27473program being compiled does not perform any floating-point operations.
27474This option is presently supported only by some bare-metal MIPS
27475configurations, where it may select a special set of libraries
27476that lack all floating-point support (including, for example, the
27477floating-point @code{printf} formats).
27478If code compiled with @option{-mno-float} accidentally contains
27479floating-point operations, it is likely to suffer a link-time
27480or run-time failure.
27481
d77de738 27482@opindex msingle-float
ddf6fe37 27483@item -msingle-float
d77de738
ML
27484Assume that the floating-point coprocessor only supports single-precision
27485operations.
27486
d77de738 27487@opindex mdouble-float
ddf6fe37 27488@item -mdouble-float
d77de738
ML
27489Assume that the floating-point coprocessor supports double-precision
27490operations. This is the default.
27491
d77de738
ML
27492@opindex modd-spreg
27493@opindex mno-odd-spreg
ddf6fe37
AA
27494@item -modd-spreg
27495@itemx -mno-odd-spreg
d77de738
ML
27496Enable the use of odd-numbered single-precision floating-point registers
27497for the o32 ABI. This is the default for processors that are known to
27498support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
27499is set by default.
27500
d77de738
ML
27501@opindex mabs=2008
27502@opindex mabs=legacy
ddf6fe37
AA
27503@item -mabs=2008
27504@itemx -mabs=legacy
d77de738
ML
27505These options control the treatment of the special not-a-number (NaN)
27506IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
27507@code{neg.@i{fmt}} machine instructions.
27508
27509By default or when @option{-mabs=legacy} is used the legacy
27510treatment is selected. In this case these instructions are considered
27511arithmetic and avoided where correct operation is required and the
27512input operand might be a NaN. A longer sequence of instructions that
27513manipulate the sign bit of floating-point datum manually is used
27514instead unless the @option{-ffinite-math-only} option has also been
27515specified.
27516
27517The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
27518this case these instructions are considered non-arithmetic and therefore
27519operating correctly in all cases, including in particular where the
27520input operand is a NaN. These instructions are therefore always used
27521for the respective operations.
27522
d77de738
ML
27523@opindex mnan=2008
27524@opindex mnan=legacy
ddf6fe37
AA
27525@item -mnan=2008
27526@itemx -mnan=legacy
d77de738
ML
27527These options control the encoding of the special not-a-number (NaN)
27528IEEE 754 floating-point data.
27529
27530The @option{-mnan=legacy} option selects the legacy encoding. In this
27531case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
27532significand field being 0, whereas signaling NaNs (sNaNs) are denoted
27533by the first bit of their trailing significand field being 1.
27534
27535The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
27536this case qNaNs are denoted by the first bit of their trailing
27537significand field being 1, whereas sNaNs are denoted by the first bit of
27538their trailing significand field being 0.
27539
27540The default is @option{-mnan=legacy} unless GCC has been configured with
27541@option{--with-nan=2008}.
27542
d77de738
ML
27543@opindex mllsc
27544@opindex mno-llsc
ddf6fe37
AA
27545@item -mllsc
27546@itemx -mno-llsc
d77de738
ML
27547Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
27548implement atomic memory built-in functions. When neither option is
27549specified, GCC uses the instructions if the target architecture
27550supports them.
27551
27552@option{-mllsc} is useful if the runtime environment can emulate the
27553instructions and @option{-mno-llsc} can be useful when compiling for
27554nonstandard ISAs. You can make either option the default by
27555configuring GCC with @option{--with-llsc} and @option{--without-llsc}
27556respectively. @option{--with-llsc} is the default for some
27557configurations; see the installation documentation for details.
27558
d77de738
ML
27559@opindex mdsp
27560@opindex mno-dsp
ddf6fe37
AA
27561@item -mdsp
27562@itemx -mno-dsp
d77de738
ML
27563Use (do not use) revision 1 of the MIPS DSP ASE@.
27564@xref{MIPS DSP Built-in Functions}. This option defines the
27565preprocessor macro @code{__mips_dsp}. It also defines
27566@code{__mips_dsp_rev} to 1.
27567
d77de738
ML
27568@opindex mdspr2
27569@opindex mno-dspr2
ddf6fe37
AA
27570@item -mdspr2
27571@itemx -mno-dspr2
d77de738
ML
27572Use (do not use) revision 2 of the MIPS DSP ASE@.
27573@xref{MIPS DSP Built-in Functions}. This option defines the
27574preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
27575It also defines @code{__mips_dsp_rev} to 2.
27576
d77de738
ML
27577@opindex msmartmips
27578@opindex mno-smartmips
ddf6fe37
AA
27579@item -msmartmips
27580@itemx -mno-smartmips
d77de738
ML
27581Use (do not use) the MIPS SmartMIPS ASE.
27582
d77de738
ML
27583@opindex mpaired-single
27584@opindex mno-paired-single
ddf6fe37
AA
27585@item -mpaired-single
27586@itemx -mno-paired-single
d77de738
ML
27587Use (do not use) paired-single floating-point instructions.
27588@xref{MIPS Paired-Single Support}. This option requires
27589hardware floating-point support to be enabled.
27590
d77de738
ML
27591@opindex mdmx
27592@opindex mno-mdmx
ddf6fe37
AA
27593@item -mdmx
27594@itemx -mno-mdmx
d77de738
ML
27595Use (do not use) MIPS Digital Media Extension instructions.
27596This option can only be used when generating 64-bit code and requires
27597hardware floating-point support to be enabled.
27598
d77de738
ML
27599@opindex mips3d
27600@opindex mno-mips3d
ddf6fe37
AA
27601@item -mips3d
27602@itemx -mno-mips3d
d77de738
ML
27603Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27604The option @option{-mips3d} implies @option{-mpaired-single}.
27605
d77de738
ML
27606@opindex mmicromips
27607@opindex mno-mmicromips
ddf6fe37
AA
27608@item -mmicromips
27609@itemx -mno-micromips
d77de738
ML
27610Generate (do not generate) microMIPS code.
27611
27612MicroMIPS code generation can also be controlled on a per-function basis
27613by means of @code{micromips} and @code{nomicromips} attributes.
27614@xref{Function Attributes}, for more information.
27615
d77de738
ML
27616@opindex mmt
27617@opindex mno-mt
ddf6fe37
AA
27618@item -mmt
27619@itemx -mno-mt
d77de738
ML
27620Use (do not use) MT Multithreading instructions.
27621
d77de738
ML
27622@opindex mmcu
27623@opindex mno-mcu
ddf6fe37
AA
27624@item -mmcu
27625@itemx -mno-mcu
d77de738
ML
27626Use (do not use) the MIPS MCU ASE instructions.
27627
d77de738
ML
27628@opindex meva
27629@opindex mno-eva
ddf6fe37
AA
27630@item -meva
27631@itemx -mno-eva
d77de738
ML
27632Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27633
d77de738
ML
27634@opindex mvirt
27635@opindex mno-virt
ddf6fe37
AA
27636@item -mvirt
27637@itemx -mno-virt
d77de738
ML
27638Use (do not use) the MIPS Virtualization (VZ) instructions.
27639
d77de738
ML
27640@opindex mxpa
27641@opindex mno-xpa
ddf6fe37
AA
27642@item -mxpa
27643@itemx -mno-xpa
d77de738
ML
27644Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27645
d77de738
ML
27646@opindex mcrc
27647@opindex mno-crc
ddf6fe37
AA
27648@item -mcrc
27649@itemx -mno-crc
d77de738
ML
27650Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27651
d77de738
ML
27652@opindex mginv
27653@opindex mno-ginv
ddf6fe37
AA
27654@item -mginv
27655@itemx -mno-ginv
d77de738
ML
27656Use (do not use) the MIPS Global INValidate (GINV) instructions.
27657
d77de738
ML
27658@opindex mloongson-mmi
27659@opindex mno-loongson-mmi
ddf6fe37
AA
27660@item -mloongson-mmi
27661@itemx -mno-loongson-mmi
d77de738
ML
27662Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27663
d77de738
ML
27664@opindex mloongson-ext
27665@opindex mno-loongson-ext
ddf6fe37
AA
27666@item -mloongson-ext
27667@itemx -mno-loongson-ext
d77de738
ML
27668Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27669
d77de738
ML
27670@opindex mloongson-ext2
27671@opindex mno-loongson-ext2
ddf6fe37
AA
27672@item -mloongson-ext2
27673@itemx -mno-loongson-ext2
d77de738
ML
27674Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27675
d77de738 27676@opindex mlong64
ddf6fe37 27677@item -mlong64
d77de738
ML
27678Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27679an explanation of the default and the way that the pointer size is
27680determined.
27681
d77de738 27682@opindex mlong32
ddf6fe37 27683@item -mlong32
d77de738
ML
27684Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27685
27686The default size of @code{int}s, @code{long}s and pointers depends on
27687the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27688uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2768932-bit @code{long}s. Pointers are the same size as @code{long}s,
27690or the same size as integer registers, whichever is smaller.
27691
d77de738
ML
27692@opindex msym32
27693@opindex mno-sym32
ddf6fe37
AA
27694@item -msym32
27695@itemx -mno-sym32
d77de738
ML
27696Assume (do not assume) that all symbols have 32-bit values, regardless
27697of the selected ABI@. This option is useful in combination with
27698@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27699to generate shorter and faster references to symbolic addresses.
27700
d77de738 27701@opindex G
ddf6fe37 27702@item -G @var{num}
d77de738
ML
27703Put definitions of externally-visible data in a small data section
27704if that data is no bigger than @var{num} bytes. GCC can then generate
27705more efficient accesses to the data; see @option{-mgpopt} for details.
27706
27707The default @option{-G} option depends on the configuration.
27708
d77de738
ML
27709@opindex mlocal-sdata
27710@opindex mno-local-sdata
ddf6fe37
AA
27711@item -mlocal-sdata
27712@itemx -mno-local-sdata
d77de738
ML
27713Extend (do not extend) the @option{-G} behavior to local data too,
27714such as to static variables in C@. @option{-mlocal-sdata} is the
27715default for all configurations.
27716
27717If the linker complains that an application is using too much small data,
27718you might want to try rebuilding the less performance-critical parts with
27719@option{-mno-local-sdata}. You might also want to build large
27720libraries with @option{-mno-local-sdata}, so that the libraries leave
27721more room for the main program.
27722
d77de738
ML
27723@opindex mextern-sdata
27724@opindex mno-extern-sdata
ddf6fe37
AA
27725@item -mextern-sdata
27726@itemx -mno-extern-sdata
d77de738
ML
27727Assume (do not assume) that externally-defined data is in
27728a small data section if the size of that data is within the @option{-G} limit.
27729@option{-mextern-sdata} is the default for all configurations.
27730
27731If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27732@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27733that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27734is placed in a small data section. If @var{Var} is defined by another
27735module, you must either compile that module with a high-enough
27736@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27737definition. If @var{Var} is common, you must link the application
27738with a high-enough @option{-G} setting.
27739
27740The easiest way of satisfying these restrictions is to compile
27741and link every module with the same @option{-G} option. However,
27742you may wish to build a library that supports several different
27743small data limits. You can do this by compiling the library with
27744the highest supported @option{-G} setting and additionally using
27745@option{-mno-extern-sdata} to stop the library from making assumptions
27746about externally-defined data.
27747
d77de738
ML
27748@opindex mgpopt
27749@opindex mno-gpopt
ddf6fe37
AA
27750@item -mgpopt
27751@itemx -mno-gpopt
d77de738
ML
27752Use (do not use) GP-relative accesses for symbols that are known to be
27753in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27754@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27755configurations.
27756
27757@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27758might not hold the value of @code{_gp}. For example, if the code is
27759part of a library that might be used in a boot monitor, programs that
27760call boot monitor routines pass an unknown value in @code{$gp}.
27761(In such situations, the boot monitor itself is usually compiled
27762with @option{-G0}.)
27763
27764@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27765@option{-mno-extern-sdata}.
27766
d77de738
ML
27767@opindex membedded-data
27768@opindex mno-embedded-data
ddf6fe37
AA
27769@item -membedded-data
27770@itemx -mno-embedded-data
d77de738
ML
27771Allocate variables to the read-only data section first if possible, then
27772next in the small data section if possible, otherwise in data. This gives
27773slightly slower code than the default, but reduces the amount of RAM required
27774when executing, and thus may be preferred for some embedded systems.
27775
d77de738
ML
27776@opindex muninit-const-in-rodata
27777@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27778@item -muninit-const-in-rodata
27779@itemx -mno-uninit-const-in-rodata
d77de738
ML
27780Put uninitialized @code{const} variables in the read-only data section.
27781This option is only meaningful in conjunction with @option{-membedded-data}.
27782
d77de738 27783@opindex mcode-readable
ddf6fe37 27784@item -mcode-readable=@var{setting}
d77de738
ML
27785Specify whether GCC may generate code that reads from executable sections.
27786There are three possible settings:
27787
27788@table @gcctabopt
27789@item -mcode-readable=yes
27790Instructions may freely access executable sections. This is the
27791default setting.
27792
27793@item -mcode-readable=pcrel
27794MIPS16 PC-relative load instructions can access executable sections,
27795but other instructions must not do so. This option is useful on 4KSc
27796and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27797It is also useful on processors that can be configured to have a dual
27798instruction/data SRAM interface and that, like the M4K, automatically
27799redirect PC-relative loads to the instruction RAM.
27800
27801@item -mcode-readable=no
27802Instructions must not access executable sections. This option can be
27803useful on targets that are configured to have a dual instruction/data
27804SRAM interface but that (unlike the M4K) do not automatically redirect
27805PC-relative loads to the instruction RAM.
27806@end table
27807
d77de738
ML
27808@opindex msplit-addresses
27809@opindex mno-split-addresses
ddf6fe37
AA
27810@item -msplit-addresses
27811@itemx -mno-split-addresses
d77de738
ML
27812Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27813relocation operators. This option has been superseded by
27814@option{-mexplicit-relocs} but is retained for backwards compatibility.
27815
d77de738
ML
27816@opindex mexplicit-relocs
27817@opindex mno-explicit-relocs
ddf6fe37
AA
27818@item -mexplicit-relocs
27819@itemx -mno-explicit-relocs
d77de738
ML
27820Use (do not use) assembler relocation operators when dealing with symbolic
27821addresses. The alternative, selected by @option{-mno-explicit-relocs},
27822is to use assembler macros instead.
27823
27824@option{-mexplicit-relocs} is the default if GCC was configured
27825to use an assembler that supports relocation operators.
27826
d77de738
ML
27827@opindex mcheck-zero-division
27828@opindex mno-check-zero-division
ddf6fe37
AA
27829@item -mcheck-zero-division
27830@itemx -mno-check-zero-division
d77de738
ML
27831Trap (do not trap) on integer division by zero.
27832
27833The default is @option{-mcheck-zero-division}.
27834
d77de738
ML
27835@opindex mdivide-traps
27836@opindex mdivide-breaks
ddf6fe37
AA
27837@item -mdivide-traps
27838@itemx -mdivide-breaks
d77de738
ML
27839MIPS systems check for division by zero by generating either a
27840conditional trap or a break instruction. Using traps results in
27841smaller code, but is only supported on MIPS II and later. Also, some
27842versions of the Linux kernel have a bug that prevents trap from
27843generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27844allow conditional traps on architectures that support them and
27845@option{-mdivide-breaks} to force the use of breaks.
27846
27847The default is usually @option{-mdivide-traps}, but this can be
27848overridden at configure time using @option{--with-divide=breaks}.
27849Divide-by-zero checks can be completely disabled using
27850@option{-mno-check-zero-division}.
27851
d77de738
ML
27852@opindex mload-store-pairs
27853@opindex mno-load-store-pairs
ddf6fe37
AA
27854@item -mload-store-pairs
27855@itemx -mno-load-store-pairs
d77de738
ML
27856Enable (disable) an optimization that pairs consecutive load or store
27857instructions to enable load/store bonding. This option is enabled by
27858default but only takes effect when the selected architecture is known
27859to support bonding.
27860
d77de738
ML
27861@opindex munaligned-access
27862@opindex mno-unaligned-access
ddf6fe37
AA
27863@item -munaligned-access
27864@itemx -mno-unaligned-access
d77de738
ML
27865Enable (disable) direct unaligned access for MIPS Release 6.
27866MIPSr6 requires load/store unaligned-access support,
27867by hardware or trap&emulate.
27868So @option{-mno-unaligned-access} may be needed by kernel.
27869
d77de738
ML
27870@opindex mmemcpy
27871@opindex mno-memcpy
ddf6fe37
AA
27872@item -mmemcpy
27873@itemx -mno-memcpy
d77de738
ML
27874Force (do not force) the use of @code{memcpy} for non-trivial block
27875moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27876most constant-sized copies.
27877
d77de738
ML
27878@opindex mlong-calls
27879@opindex mno-long-calls
ddf6fe37
AA
27880@item -mlong-calls
27881@itemx -mno-long-calls
d77de738
ML
27882Disable (do not disable) use of the @code{jal} instruction. Calling
27883functions using @code{jal} is more efficient but requires the caller
27884and callee to be in the same 256 megabyte segment.
27885
27886This option has no effect on abicalls code. The default is
27887@option{-mno-long-calls}.
27888
d77de738
ML
27889@opindex mmad
27890@opindex mno-mad
ddf6fe37
AA
27891@item -mmad
27892@itemx -mno-mad
d77de738
ML
27893Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27894instructions, as provided by the R4650 ISA@.
27895
d77de738
ML
27896@opindex mimadd
27897@opindex mno-imadd
ddf6fe37
AA
27898@item -mimadd
27899@itemx -mno-imadd
d77de738
ML
27900Enable (disable) use of the @code{madd} and @code{msub} integer
27901instructions. The default is @option{-mimadd} on architectures
27902that support @code{madd} and @code{msub} except for the 74k
27903architecture where it was found to generate slower code.
27904
d77de738
ML
27905@opindex mfused-madd
27906@opindex mno-fused-madd
ddf6fe37
AA
27907@item -mfused-madd
27908@itemx -mno-fused-madd
d77de738
ML
27909Enable (disable) use of the floating-point multiply-accumulate
27910instructions, when they are available. The default is
27911@option{-mfused-madd}.
27912
27913On the R8000 CPU when multiply-accumulate instructions are used,
27914the intermediate product is calculated to infinite precision
27915and is not subject to the FCSR Flush to Zero bit. This may be
27916undesirable in some circumstances. On other processors the result
27917is numerically identical to the equivalent computation using
27918separate multiply, add, subtract and negate instructions.
27919
d77de738 27920@opindex nocpp
ddf6fe37 27921@item -nocpp
d77de738
ML
27922Tell the MIPS assembler to not run its preprocessor over user
27923assembler files (with a @samp{.s} suffix) when assembling them.
27924
d77de738
ML
27925@opindex mfix-24k
27926@opindex mno-fix-24k
ddf6fe37
AA
27927@item -mfix-24k
27928@itemx -mno-fix-24k
d77de738
ML
27929Work around the 24K E48 (lost data on stores during refill) errata.
27930The workarounds are implemented by the assembler rather than by GCC@.
27931
d77de738
ML
27932@opindex mfix-r4000
27933@opindex mno-fix-r4000
ddf6fe37
AA
27934@item -mfix-r4000
27935@itemx -mno-fix-r4000
d77de738
ML
27936Work around certain R4000 CPU errata:
27937@itemize @minus
27938@item
27939A double-word or a variable shift may give an incorrect result if executed
27940immediately after starting an integer division.
27941@item
27942A double-word or a variable shift may give an incorrect result if executed
27943while an integer multiplication is in progress.
27944@item
27945An integer division may give an incorrect result if started in a delay slot
27946of a taken branch or a jump.
27947@end itemize
27948
d77de738
ML
27949@opindex mfix-r4400
27950@opindex mno-fix-r4400
ddf6fe37
AA
27951@item -mfix-r4400
27952@itemx -mno-fix-r4400
d77de738
ML
27953Work around certain R4400 CPU errata:
27954@itemize @minus
27955@item
27956A double-word or a variable shift may give an incorrect result if executed
27957immediately after starting an integer division.
27958@end itemize
27959
d77de738
ML
27960@opindex mfix-r10000
27961@opindex mno-fix-r10000
ddf6fe37
AA
27962@item -mfix-r10000
27963@itemx -mno-fix-r10000
d77de738
ML
27964Work around certain R10000 errata:
27965@itemize @minus
27966@item
27967@code{ll}/@code{sc} sequences may not behave atomically on revisions
27968prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27969@end itemize
27970
27971This option can only be used if the target architecture supports
27972branch-likely instructions. @option{-mfix-r10000} is the default when
27973@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27974otherwise.
27975
ddf6fe37 27976@opindex mfix-r5900
d77de738
ML
27977@item -mfix-r5900
27978@itemx -mno-fix-r5900
d77de738
ML
27979Do not attempt to schedule the preceding instruction into the delay slot
27980of a branch instruction placed at the end of a short loop of six
27981instructions or fewer and always schedule a @code{nop} instruction there
27982instead. The short loop bug under certain conditions causes loops to
27983execute only once or twice, due to a hardware bug in the R5900 chip. The
27984workaround is implemented by the assembler rather than by GCC@.
27985
ddf6fe37 27986@opindex mfix-rm7000
d77de738
ML
27987@item -mfix-rm7000
27988@itemx -mno-fix-rm7000
d77de738
ML
27989Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27990workarounds are implemented by the assembler rather than by GCC@.
27991
ddf6fe37 27992@opindex mfix-vr4120
d77de738
ML
27993@item -mfix-vr4120
27994@itemx -mno-fix-vr4120
d77de738
ML
27995Work around certain VR4120 errata:
27996@itemize @minus
27997@item
27998@code{dmultu} does not always produce the correct result.
27999@item
28000@code{div} and @code{ddiv} do not always produce the correct result if one
28001of the operands is negative.
28002@end itemize
28003The workarounds for the division errata rely on special functions in
28004@file{libgcc.a}. At present, these functions are only provided by
28005the @code{mips64vr*-elf} configurations.
28006
28007Other VR4120 errata require a NOP to be inserted between certain pairs of
28008instructions. These errata are handled by the assembler, not by GCC itself.
28009
d77de738 28010@opindex mfix-vr4130
ddf6fe37 28011@item -mfix-vr4130
d77de738
ML
28012Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
28013workarounds are implemented by the assembler rather than by GCC,
28014although GCC avoids using @code{mflo} and @code{mfhi} if the
28015VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
28016instructions are available instead.
28017
ddf6fe37 28018@opindex mfix-sb1
d77de738
ML
28019@item -mfix-sb1
28020@itemx -mno-fix-sb1
d77de738
ML
28021Work around certain SB-1 CPU core errata.
28022(This flag currently works around the SB-1 revision 2
28023``F1'' and ``F2'' floating-point errata.)
28024
d77de738 28025@opindex mr10k-cache-barrier
ddf6fe37 28026@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
28027Specify whether GCC should insert cache barriers to avoid the
28028side effects of speculation on R10K processors.
28029
28030In common with many processors, the R10K tries to predict the outcome
28031of a conditional branch and speculatively executes instructions from
28032the ``taken'' branch. It later aborts these instructions if the
28033predicted outcome is wrong. However, on the R10K, even aborted
28034instructions can have side effects.
28035
28036This problem only affects kernel stores and, depending on the system,
28037kernel loads. As an example, a speculatively-executed store may load
28038the target memory into cache and mark the cache line as dirty, even if
28039the store itself is later aborted. If a DMA operation writes to the
28040same area of memory before the ``dirty'' line is flushed, the cached
28041data overwrites the DMA-ed data. See the R10K processor manual
28042for a full description, including other potential problems.
28043
28044One workaround is to insert cache barrier instructions before every memory
28045access that might be speculatively executed and that might have side
28046effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
28047controls GCC's implementation of this workaround. It assumes that
28048aborted accesses to any byte in the following regions does not have
28049side effects:
28050
28051@enumerate
28052@item
28053the memory occupied by the current function's stack frame;
28054
28055@item
28056the memory occupied by an incoming stack argument;
28057
28058@item
28059the memory occupied by an object with a link-time-constant address.
28060@end enumerate
28061
28062It is the kernel's responsibility to ensure that speculative
28063accesses to these regions are indeed safe.
28064
28065If the input program contains a function declaration such as:
28066
28067@smallexample
28068void foo (void);
28069@end smallexample
28070
28071then the implementation of @code{foo} must allow @code{j foo} and
28072@code{jal foo} to be executed speculatively. GCC honors this
28073restriction for functions it compiles itself. It expects non-GCC
28074functions (such as hand-written assembly code) to do the same.
28075
28076The option has three forms:
28077
28078@table @gcctabopt
28079@item -mr10k-cache-barrier=load-store
28080Insert a cache barrier before a load or store that might be
28081speculatively executed and that might have side effects even
28082if aborted.
28083
28084@item -mr10k-cache-barrier=store
28085Insert a cache barrier before a store that might be speculatively
28086executed and that might have side effects even if aborted.
28087
28088@item -mr10k-cache-barrier=none
28089Disable the insertion of cache barriers. This is the default setting.
28090@end table
28091
ddf6fe37 28092@opindex mflush-func
d77de738
ML
28093@item -mflush-func=@var{func}
28094@itemx -mno-flush-func
d77de738
ML
28095Specifies the function to call to flush the I and D caches, or to not
28096call any such function. If called, the function must take the same
28097arguments as the common @code{_flush_func}, that is, the address of the
28098memory range for which the cache is being flushed, the size of the
28099memory range, and the number 3 (to flush both caches). The default
28100depends on the target GCC was configured for, but commonly is either
28101@code{_flush_func} or @code{__cpu_flush}.
28102
d77de738 28103@opindex mbranch-cost
ddf6fe37 28104@item mbranch-cost=@var{num}
d77de738
ML
28105Set the cost of branches to roughly @var{num} ``simple'' instructions.
28106This cost is only a heuristic and is not guaranteed to produce
28107consistent results across releases. A zero cost redundantly selects
28108the default, which is based on the @option{-mtune} setting.
28109
d77de738
ML
28110@opindex mbranch-likely
28111@opindex mno-branch-likely
ddf6fe37
AA
28112@item -mbranch-likely
28113@itemx -mno-branch-likely
d77de738
ML
28114Enable or disable use of Branch Likely instructions, regardless of the
28115default for the selected architecture. By default, Branch Likely
28116instructions may be generated if they are supported by the selected
28117architecture. An exception is for the MIPS32 and MIPS64 architectures
28118and processors that implement those architectures; for those, Branch
28119Likely instructions are not be generated by default because the MIPS32
28120and MIPS64 architectures specifically deprecate their use.
28121
d77de738
ML
28122@opindex mcompact-branches=never
28123@opindex mcompact-branches=optimal
28124@opindex mcompact-branches=always
ddf6fe37
AA
28125@item -mcompact-branches=never
28126@itemx -mcompact-branches=optimal
28127@itemx -mcompact-branches=always
d77de738
ML
28128These options control which form of branches will be generated. The
28129default is @option{-mcompact-branches=optimal}.
28130
28131The @option{-mcompact-branches=never} option ensures that compact branch
28132instructions will never be generated.
28133
28134The @option{-mcompact-branches=always} option ensures that a compact
28135branch instruction will be generated if available for MIPS Release 6 onwards.
28136If a compact branch instruction is not available (or pre-R6),
28137a delay slot form of the branch will be used instead.
28138
28139If it is used for MIPS16/microMIPS targets, it will be just ignored now.
28140The behaviour for MIPS16/microMIPS may change in future,
28141since they do have some compact branch instructions.
28142
28143The @option{-mcompact-branches=optimal} option will cause a delay slot
28144branch to be used if one is available in the current ISA and the delay
28145slot is successfully filled. If the delay slot is not filled, a compact
28146branch will be chosen if one is available.
28147
ddf6fe37 28148@opindex mfp-exceptions
d77de738
ML
28149@item -mfp-exceptions
28150@itemx -mno-fp-exceptions
d77de738
ML
28151Specifies whether FP exceptions are enabled. This affects how
28152FP instructions are scheduled for some processors.
28153The default is that FP exceptions are
28154enabled.
28155
28156For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2815764-bit code, then we can use both FP pipes. Otherwise, we can only use one
28158FP pipe.
28159
ddf6fe37 28160@opindex mvr4130-align
d77de738
ML
28161@item -mvr4130-align
28162@itemx -mno-vr4130-align
d77de738
ML
28163The VR4130 pipeline is two-way superscalar, but can only issue two
28164instructions together if the first one is 8-byte aligned. When this
28165option is enabled, GCC aligns pairs of instructions that it
28166thinks should execute in parallel.
28167
28168This option only has an effect when optimizing for the VR4130.
28169It normally makes code faster, but at the expense of making it bigger.
28170It is enabled by default at optimization level @option{-O3}.
28171
ddf6fe37 28172@opindex msynci
d77de738
ML
28173@item -msynci
28174@itemx -mno-synci
d77de738
ML
28175Enable (disable) generation of @code{synci} instructions on
28176architectures that support it. The @code{synci} instructions (if
28177enabled) are generated when @code{__builtin___clear_cache} is
28178compiled.
28179
28180This option defaults to @option{-mno-synci}, but the default can be
28181overridden by configuring GCC with @option{--with-synci}.
28182
28183When compiling code for single processor systems, it is generally safe
28184to use @code{synci}. However, on many multi-core (SMP) systems, it
28185does not invalidate the instruction caches on all cores and may lead
28186to undefined behavior.
28187
ddf6fe37 28188@opindex mrelax-pic-calls
d77de738
ML
28189@item -mrelax-pic-calls
28190@itemx -mno-relax-pic-calls
d77de738
ML
28191Try to turn PIC calls that are normally dispatched via register
28192@code{$25} into direct calls. This is only possible if the linker can
28193resolve the destination at link time and if the destination is within
28194range for a direct call.
28195
28196@option{-mrelax-pic-calls} is the default if GCC was configured to use
28197an assembler and a linker that support the @code{.reloc} assembly
28198directive and @option{-mexplicit-relocs} is in effect. With
28199@option{-mno-explicit-relocs}, this optimization can be performed by the
28200assembler and the linker alone without help from the compiler.
28201
d77de738
ML
28202@opindex mmcount-ra-address
28203@opindex mno-mcount-ra-address
ddf6fe37
AA
28204@item -mmcount-ra-address
28205@itemx -mno-mcount-ra-address
d77de738
ML
28206Emit (do not emit) code that allows @code{_mcount} to modify the
28207calling function's return address. When enabled, this option extends
28208the usual @code{_mcount} interface with a new @var{ra-address}
28209parameter, which has type @code{intptr_t *} and is passed in register
28210@code{$12}. @code{_mcount} can then modify the return address by
28211doing both of the following:
28212@itemize
28213@item
28214Returning the new address in register @code{$31}.
28215@item
28216Storing the new address in @code{*@var{ra-address}},
28217if @var{ra-address} is nonnull.
28218@end itemize
28219
28220The default is @option{-mno-mcount-ra-address}.
28221
ddf6fe37 28222@opindex mframe-header-opt
d77de738
ML
28223@item -mframe-header-opt
28224@itemx -mno-frame-header-opt
d77de738
ML
28225Enable (disable) frame header optimization in the o32 ABI. When using the
28226o32 ABI, calling functions will allocate 16 bytes on the stack for the called
28227function to write out register arguments. When enabled, this optimization
28228will suppress the allocation of the frame header if it can be determined that
28229it is unused.
28230
28231This optimization is off by default at all optimization levels.
28232
ddf6fe37 28233@opindex mlxc1-sxc1
d77de738
ML
28234@item -mlxc1-sxc1
28235@itemx -mno-lxc1-sxc1
d77de738
ML
28236When applicable, enable (disable) the generation of @code{lwxc1},
28237@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
28238
ddf6fe37 28239@opindex mmadd4
d77de738
ML
28240@item -mmadd4
28241@itemx -mno-madd4
d77de738
ML
28242When applicable, enable (disable) the generation of 4-operand @code{madd.s},
28243@code{madd.d} and related instructions. Enabled by default.
28244
28245@end table
28246
28247@node MMIX Options
28248@subsection MMIX Options
28249@cindex MMIX Options
28250
28251These options are defined for the MMIX:
28252
28253@table @gcctabopt
d77de738
ML
28254@opindex mlibfuncs
28255@opindex mno-libfuncs
ddf6fe37
AA
28256@item -mlibfuncs
28257@itemx -mno-libfuncs
d77de738
ML
28258Specify that intrinsic library functions are being compiled, passing all
28259values in registers, no matter the size.
28260
d77de738
ML
28261@opindex mepsilon
28262@opindex mno-epsilon
ddf6fe37
AA
28263@item -mepsilon
28264@itemx -mno-epsilon
d77de738
ML
28265Generate floating-point comparison instructions that compare with respect
28266to the @code{rE} epsilon register.
28267
d77de738
ML
28268@opindex mabi=mmixware
28269@opindex mabi=gnu
ddf6fe37
AA
28270@item -mabi=mmixware
28271@itemx -mabi=gnu
d77de738
ML
28272Generate code that passes function parameters and return values that (in
28273the called function) are seen as registers @code{$0} and up, as opposed to
28274the GNU ABI which uses global registers @code{$231} and up.
28275
d77de738
ML
28276@opindex mzero-extend
28277@opindex mno-zero-extend
ddf6fe37
AA
28278@item -mzero-extend
28279@itemx -mno-zero-extend
d77de738
ML
28280When reading data from memory in sizes shorter than 64 bits, use (do not
28281use) zero-extending load instructions by default, rather than
28282sign-extending ones.
28283
d77de738
ML
28284@opindex mknuthdiv
28285@opindex mno-knuthdiv
ddf6fe37
AA
28286@item -mknuthdiv
28287@itemx -mno-knuthdiv
d77de738
ML
28288Make the result of a division yielding a remainder have the same sign as
28289the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
28290remainder follows the sign of the dividend. Both methods are
28291arithmetically valid, the latter being almost exclusively used.
28292
d77de738
ML
28293@opindex mtoplevel-symbols
28294@opindex mno-toplevel-symbols
ddf6fe37
AA
28295@item -mtoplevel-symbols
28296@itemx -mno-toplevel-symbols
d77de738
ML
28297Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
28298code can be used with the @code{PREFIX} assembly directive.
28299
d77de738 28300@opindex melf
ddf6fe37 28301@item -melf
d77de738
ML
28302Generate an executable in the ELF format, rather than the default
28303@samp{mmo} format used by the @command{mmix} simulator.
28304
d77de738
ML
28305@opindex mbranch-predict
28306@opindex mno-branch-predict
ddf6fe37
AA
28307@item -mbranch-predict
28308@itemx -mno-branch-predict
d77de738
ML
28309Use (do not use) the probable-branch instructions, when static branch
28310prediction indicates a probable branch.
28311
d77de738
ML
28312@opindex mbase-addresses
28313@opindex mno-base-addresses
ddf6fe37
AA
28314@item -mbase-addresses
28315@itemx -mno-base-addresses
d77de738
ML
28316Generate (do not generate) code that uses @emph{base addresses}. Using a
28317base address automatically generates a request (handled by the assembler
28318and the linker) for a constant to be set up in a global register. The
28319register is used for one or more base address requests within the range 0
28320to 255 from the value held in the register. The generally leads to short
28321and fast code, but the number of different data items that can be
28322addressed is limited. This means that a program that uses lots of static
28323data may require @option{-mno-base-addresses}.
28324
d77de738
ML
28325@opindex msingle-exit
28326@opindex mno-single-exit
ddf6fe37
AA
28327@item -msingle-exit
28328@itemx -mno-single-exit
d77de738
ML
28329Force (do not force) generated code to have a single exit point in each
28330function.
28331@end table
28332
28333@node MN10300 Options
28334@subsection MN10300 Options
28335@cindex MN10300 options
28336
28337These @option{-m} options are defined for Matsushita MN10300 architectures:
28338
28339@table @gcctabopt
d77de738 28340@opindex mmult-bug
ddf6fe37 28341@item -mmult-bug
d77de738
ML
28342Generate code to avoid bugs in the multiply instructions for the MN10300
28343processors. This is the default.
28344
d77de738 28345@opindex mno-mult-bug
ddf6fe37 28346@item -mno-mult-bug
d77de738
ML
28347Do not generate code to avoid bugs in the multiply instructions for the
28348MN10300 processors.
28349
d77de738 28350@opindex mam33
ddf6fe37 28351@item -mam33
d77de738
ML
28352Generate code using features specific to the AM33 processor.
28353
d77de738 28354@opindex mno-am33
ddf6fe37 28355@item -mno-am33
d77de738
ML
28356Do not generate code using features specific to the AM33 processor. This
28357is the default.
28358
d77de738 28359@opindex mam33-2
ddf6fe37 28360@item -mam33-2
d77de738
ML
28361Generate code using features specific to the AM33/2.0 processor.
28362
d77de738 28363@opindex mam34
ddf6fe37 28364@item -mam34
d77de738
ML
28365Generate code using features specific to the AM34 processor.
28366
d77de738 28367@opindex mtune
ddf6fe37 28368@item -mtune=@var{cpu-type}
d77de738
ML
28369Use the timing characteristics of the indicated CPU type when
28370scheduling instructions. This does not change the targeted processor
28371type. The CPU type must be one of @samp{mn10300}, @samp{am33},
28372@samp{am33-2} or @samp{am34}.
28373
d77de738 28374@opindex mreturn-pointer-on-d0
ddf6fe37 28375@item -mreturn-pointer-on-d0
d77de738
ML
28376When generating a function that returns a pointer, return the pointer
28377in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
28378only in @code{a0}, and attempts to call such functions without a prototype
28379result in errors. Note that this option is on by default; use
28380@option{-mno-return-pointer-on-d0} to disable it.
28381
d77de738 28382@opindex mno-crt0
ddf6fe37 28383@item -mno-crt0
d77de738
ML
28384Do not link in the C run-time initialization object file.
28385
d77de738 28386@opindex mrelax
ddf6fe37 28387@item -mrelax
d77de738
ML
28388Indicate to the linker that it should perform a relaxation optimization pass
28389to shorten branches, calls and absolute memory addresses. This option only
28390has an effect when used on the command line for the final link step.
28391
28392This option makes symbolic debugging impossible.
28393
d77de738 28394@opindex mliw
ddf6fe37 28395@item -mliw
d77de738
ML
28396Allow the compiler to generate @emph{Long Instruction Word}
28397instructions if the target is the @samp{AM33} or later. This is the
28398default. This option defines the preprocessor macro @code{__LIW__}.
28399
d77de738 28400@opindex mno-liw
ddf6fe37 28401@item -mno-liw
d77de738
ML
28402Do not allow the compiler to generate @emph{Long Instruction Word}
28403instructions. This option defines the preprocessor macro
28404@code{__NO_LIW__}.
28405
d77de738 28406@opindex msetlb
ddf6fe37 28407@item -msetlb
d77de738
ML
28408Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
28409instructions if the target is the @samp{AM33} or later. This is the
28410default. This option defines the preprocessor macro @code{__SETLB__}.
28411
d77de738 28412@opindex mno-setlb
ddf6fe37 28413@item -mno-setlb
d77de738
ML
28414Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
28415instructions. This option defines the preprocessor macro
28416@code{__NO_SETLB__}.
28417
28418@end table
28419
28420@node Moxie Options
28421@subsection Moxie Options
28422@cindex Moxie Options
28423
28424@table @gcctabopt
28425
d77de738 28426@opindex meb
ddf6fe37 28427@item -meb
d77de738
ML
28428Generate big-endian code. This is the default for @samp{moxie-*-*}
28429configurations.
28430
d77de738 28431@opindex mel
ddf6fe37 28432@item -mel
d77de738
ML
28433Generate little-endian code.
28434
d77de738 28435@opindex mmul.x
ddf6fe37 28436@item -mmul.x
d77de738
ML
28437Generate mul.x and umul.x instructions. This is the default for
28438@samp{moxiebox-*-*} configurations.
28439
d77de738 28440@opindex mno-crt0
ddf6fe37 28441@item -mno-crt0
d77de738
ML
28442Do not link in the C run-time initialization object file.
28443
28444@end table
28445
28446@node MSP430 Options
28447@subsection MSP430 Options
28448@cindex MSP430 Options
28449
28450These options are defined for the MSP430:
28451
28452@table @gcctabopt
28453
d77de738 28454@opindex masm-hex
ddf6fe37 28455@item -masm-hex
d77de738
ML
28456Force assembly output to always use hex constants. Normally such
28457constants are signed decimals, but this option is available for
28458testsuite and/or aesthetic purposes.
28459
d77de738 28460@opindex mmcu=
ddf6fe37 28461@item -mmcu=
d77de738
ML
28462Select the MCU to target. This is used to create a C preprocessor
28463symbol based upon the MCU name, converted to upper case and pre- and
28464post-fixed with @samp{__}. This in turn is used by the
28465@file{msp430.h} header file to select an MCU-specific supplementary
28466header file.
28467
28468The option also sets the ISA to use. If the MCU name is one that is
28469known to only support the 430 ISA then that is selected, otherwise the
28470430X ISA is selected. A generic MCU name of @samp{msp430} can also be
28471used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
28472name selects the 430X ISA.
28473
28474In addition an MCU-specific linker script is added to the linker
28475command line. The script's name is the name of the MCU with
28476@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
28477command line defines the C preprocessor symbol @code{__XXX__} and
28478cause the linker to search for a script called @file{xxx.ld}.
28479
28480The ISA and hardware multiply supported for the different MCUs is hard-coded
28481into GCC. However, an external @samp{devices.csv} file can be used to
28482extend device support beyond those that have been hard-coded.
28483
28484GCC searches for the @samp{devices.csv} file using the following methods in the
28485given precedence order, where the first method takes precendence over the
28486second which takes precedence over the third.
28487
28488@table @asis
28489@item Include path specified with @code{-I} and @code{-L}
28490@samp{devices.csv} will be searched for in each of the directories specified by
28491include paths and linker library search paths.
28492@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
28493Define the value of the global environment variable
28494@samp{MSP430_GCC_INCLUDE_DIR}
28495to the full path to the directory containing devices.csv, and GCC will search
28496this directory for devices.csv. If devices.csv is found, this directory will
28497also be registered as an include path, and linker library path. Header files
28498and linker scripts in this directory can therefore be used without manually
28499specifying @code{-I} and @code{-L} on the command line.
28500@item The @samp{msp430-elf@{,bare@}/include/devices} directory
28501Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
28502toolchain root directory. This directory does not exist in a default
28503installation, but if the user has created it and copied @samp{devices.csv}
28504there, then the MCU data will be read. As above, this directory will
28505also be registered as an include path, and linker library path.
28506
28507@end table
28508If none of the above search methods find @samp{devices.csv}, then the
28509hard-coded MCU data is used.
28510
28511
d77de738
ML
28512@opindex mwarn-mcu
28513@opindex mno-warn-mcu
ddf6fe37
AA
28514@item -mwarn-mcu
28515@itemx -mno-warn-mcu
d77de738
ML
28516This option enables or disables warnings about conflicts between the
28517MCU name specified by the @option{-mmcu} option and the ISA set by the
28518@option{-mcpu} option and/or the hardware multiply support set by the
28519@option{-mhwmult} option. It also toggles warnings about unrecognized
28520MCU names. This option is on by default.
28521
d77de738 28522@opindex mcpu=
ddf6fe37 28523@item -mcpu=
d77de738
ML
28524Specifies the ISA to use. Accepted values are @samp{msp430},
28525@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
28526@option{-mmcu=} option should be used to select the ISA.
28527
d77de738 28528@opindex msim
ddf6fe37 28529@item -msim
d77de738
ML
28530Link to the simulator runtime libraries and linker script. Overrides
28531any scripts that would be selected by the @option{-mmcu=} option.
28532
d77de738 28533@opindex mlarge
ddf6fe37 28534@item -mlarge
d77de738
ML
28535Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
28536
d77de738 28537@opindex msmall
ddf6fe37 28538@item -msmall
d77de738
ML
28539Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
28540
d77de738 28541@opindex mrelax
ddf6fe37 28542@item -mrelax
d77de738
ML
28543This option is passed to the assembler and linker, and allows the
28544linker to perform certain optimizations that cannot be done until
28545the final link.
28546
d77de738 28547@opindex mhwmult=
ddf6fe37 28548@item mhwmult=
d77de738
ML
28549Describes the type of hardware multiply supported by the target.
28550Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
28551for the original 16-bit-only multiply supported by early MCUs.
28552@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
28553@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
28554A value of @samp{auto} can also be given. This tells GCC to deduce
28555the hardware multiply support based upon the MCU name provided by the
28556@option{-mmcu} option. If no @option{-mmcu} option is specified or if
28557the MCU name is not recognized then no hardware multiply support is
28558assumed. @code{auto} is the default setting.
28559
28560Hardware multiplies are normally performed by calling a library
28561routine. This saves space in the generated code. When compiling at
28562@option{-O3} or higher however the hardware multiplier is invoked
28563inline. This makes for bigger, but faster code.
28564
28565The hardware multiply routines disable interrupts whilst running and
28566restore the previous interrupt state when they finish. This makes
28567them safe to use inside interrupt handlers as well as in normal code.
28568
d77de738 28569@opindex minrt
ddf6fe37 28570@item -minrt
d77de738
ML
28571Enable the use of a minimum runtime environment - no static
28572initializers or constructors. This is intended for memory-constrained
28573devices. The compiler includes special symbols in some objects
28574that tell the linker and runtime which code fragments are required.
28575
d77de738 28576@opindex mtiny-printf
ddf6fe37 28577@item -mtiny-printf
d77de738
ML
28578Enable reduced code size @code{printf} and @code{puts} library functions.
28579The @samp{tiny} implementations of these functions are not reentrant, so
28580must be used with caution in multi-threaded applications.
28581
28582Support for streams has been removed and the string to be printed will
28583always be sent to stdout via the @code{write} syscall. The string is not
28584buffered before it is sent to write.
28585
28586This option requires Newlib Nano IO, so GCC must be configured with
28587@samp{--enable-newlib-nano-formatted-io}.
28588
d77de738 28589@opindex mmax-inline-shift=
ddf6fe37 28590@item -mmax-inline-shift=
d77de738
ML
28591This option takes an integer between 0 and 64 inclusive, and sets
28592the maximum number of inline shift instructions which should be emitted to
28593perform a shift operation by a constant amount. When this value needs to be
28594exceeded, an mspabi helper function is used instead. The default value is 4.
28595
28596This only affects cases where a shift by multiple positions cannot be
28597completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28598
28599Shifts of a 32-bit value are at least twice as costly, so the value passed for
28600this option is divided by 2 and the resulting value used instead.
28601
d77de738
ML
28602@opindex mcode-region
28603@opindex mdata-region
ddf6fe37
AA
28604@item -mcode-region=
28605@itemx -mdata-region=
d77de738
ML
28606These options tell the compiler where to place functions and data that
28607do not have one of the @code{lower}, @code{upper}, @code{either} or
28608@code{section} attributes. Possible values are @code{lower},
28609@code{upper}, @code{either} or @code{any}. The first three behave
28610like the corresponding attribute. The fourth possible value -
28611@code{any} - is the default. It leaves placement entirely up to the
28612linker script and how it assigns the standard sections
28613(@code{.text}, @code{.data}, etc) to the memory regions.
28614
d77de738 28615@opindex msilicon-errata
ddf6fe37 28616@item -msilicon-errata=
d77de738
ML
28617This option passes on a request to assembler to enable the fixes for
28618the named silicon errata.
28619
d77de738 28620@opindex msilicon-errata-warn
ddf6fe37 28621@item -msilicon-errata-warn=
d77de738
ML
28622This option passes on a request to the assembler to enable warning
28623messages when a silicon errata might need to be applied.
28624
d77de738
ML
28625@opindex mwarn-devices-csv
28626@opindex mno-warn-devices-csv
ddf6fe37
AA
28627@item -mwarn-devices-csv
28628@itemx -mno-warn-devices-csv
d77de738
ML
28629Warn if @samp{devices.csv} is not found or there are problem parsing it
28630(default: on).
28631
28632@end table
28633
28634@node NDS32 Options
28635@subsection NDS32 Options
28636@cindex NDS32 Options
28637
28638These options are defined for NDS32 implementations:
28639
28640@table @gcctabopt
28641
d77de738 28642@opindex mbig-endian
ddf6fe37 28643@item -mbig-endian
d77de738
ML
28644Generate code in big-endian mode.
28645
d77de738 28646@opindex mlittle-endian
ddf6fe37 28647@item -mlittle-endian
d77de738
ML
28648Generate code in little-endian mode.
28649
d77de738 28650@opindex mreduced-regs
ddf6fe37 28651@item -mreduced-regs
d77de738
ML
28652Use reduced-set registers for register allocation.
28653
d77de738 28654@opindex mfull-regs
ddf6fe37 28655@item -mfull-regs
d77de738
ML
28656Use full-set registers for register allocation.
28657
d77de738 28658@opindex mcmov
ddf6fe37 28659@item -mcmov
d77de738
ML
28660Generate conditional move instructions.
28661
d77de738 28662@opindex mno-cmov
ddf6fe37 28663@item -mno-cmov
d77de738
ML
28664Do not generate conditional move instructions.
28665
d77de738 28666@opindex mext-perf
ddf6fe37 28667@item -mext-perf
d77de738
ML
28668Generate performance extension instructions.
28669
d77de738 28670@opindex mno-ext-perf
ddf6fe37 28671@item -mno-ext-perf
d77de738
ML
28672Do not generate performance extension instructions.
28673
d77de738 28674@opindex mext-perf2
ddf6fe37 28675@item -mext-perf2
d77de738
ML
28676Generate performance extension 2 instructions.
28677
d77de738 28678@opindex mno-ext-perf2
ddf6fe37 28679@item -mno-ext-perf2
d77de738
ML
28680Do not generate performance extension 2 instructions.
28681
d77de738 28682@opindex mext-string
ddf6fe37 28683@item -mext-string
d77de738
ML
28684Generate string extension instructions.
28685
d77de738 28686@opindex mno-ext-string
ddf6fe37 28687@item -mno-ext-string
d77de738
ML
28688Do not generate string extension instructions.
28689
d77de738 28690@opindex mv3push
ddf6fe37 28691@item -mv3push
d77de738
ML
28692Generate v3 push25/pop25 instructions.
28693
d77de738 28694@opindex mno-v3push
ddf6fe37 28695@item -mno-v3push
d77de738
ML
28696Do not generate v3 push25/pop25 instructions.
28697
d77de738 28698@opindex m16-bit
ddf6fe37 28699@item -m16-bit
d77de738
ML
28700Generate 16-bit instructions.
28701
d77de738 28702@opindex mno-16-bit
ddf6fe37 28703@item -mno-16-bit
d77de738
ML
28704Do not generate 16-bit instructions.
28705
d77de738 28706@opindex misr-vector-size
ddf6fe37 28707@item -misr-vector-size=@var{num}
d77de738
ML
28708Specify the size of each interrupt vector, which must be 4 or 16.
28709
d77de738 28710@opindex mcache-block-size
ddf6fe37 28711@item -mcache-block-size=@var{num}
d77de738
ML
28712Specify the size of each cache block,
28713which must be a power of 2 between 4 and 512.
28714
d77de738 28715@opindex march
ddf6fe37 28716@item -march=@var{arch}
d77de738
ML
28717Specify the name of the target architecture.
28718
d77de738 28719@opindex mcmodel
ddf6fe37 28720@item -mcmodel=@var{code-model}
d77de738
ML
28721Set the code model to one of
28722@table @asis
28723@item @samp{small}
28724All the data and read-only data segments must be within 512KB addressing space.
28725The text segment must be within 16MB addressing space.
28726@item @samp{medium}
28727The data segment must be within 512KB while the read-only data segment can be
28728within 4GB addressing space. The text segment should be still within 16MB
28729addressing space.
28730@item @samp{large}
28731All the text and data segments can be within 4GB addressing space.
28732@end table
28733
d77de738 28734@opindex mctor-dtor
ddf6fe37 28735@item -mctor-dtor
d77de738
ML
28736Enable constructor/destructor feature.
28737
d77de738 28738@opindex mrelax
ddf6fe37 28739@item -mrelax
d77de738
ML
28740Guide linker to relax instructions.
28741
28742@end table
28743
28744@node Nios II Options
28745@subsection Nios II Options
28746@cindex Nios II options
28747@cindex Altera Nios II options
28748
28749These are the options defined for the Altera Nios II processor.
28750
28751@table @gcctabopt
28752
d77de738
ML
28753@opindex G
28754@cindex smaller data references
f33d7a88 28755@item -G @var{num}
d77de738
ML
28756Put global and static objects less than or equal to @var{num} bytes
28757into the small data or BSS sections instead of the normal data or BSS
28758sections. The default value of @var{num} is 8.
28759
ddf6fe37
AA
28760@opindex mgpopt
28761@opindex mno-gpopt
d77de738
ML
28762@item -mgpopt=@var{option}
28763@itemx -mgpopt
28764@itemx -mno-gpopt
d77de738
ML
28765Generate (do not generate) GP-relative accesses. The following
28766@var{option} names are recognized:
28767
28768@table @samp
28769
28770@item none
28771Do not generate GP-relative accesses.
28772
28773@item local
28774Generate GP-relative accesses for small data objects that are not
28775external, weak, or uninitialized common symbols.
28776Also use GP-relative addressing for objects that
28777have been explicitly placed in a small data section via a @code{section}
28778attribute.
28779
28780@item global
28781As for @samp{local}, but also generate GP-relative accesses for
28782small data objects that are external, weak, or common. If you use this option,
28783you must ensure that all parts of your program (including libraries) are
28784compiled with the same @option{-G} setting.
28785
28786@item data
28787Generate GP-relative accesses for all data objects in the program. If you
28788use this option, the entire data and BSS segments
28789of your program must fit in 64K of memory and you must use an appropriate
28790linker script to allocate them within the addressable range of the
28791global pointer.
28792
28793@item all
28794Generate GP-relative addresses for function pointers as well as data
28795pointers. If you use this option, the entire text, data, and BSS segments
28796of your program must fit in 64K of memory and you must use an appropriate
28797linker script to allocate them within the addressable range of the
28798global pointer.
28799
28800@end table
28801
28802@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28803@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28804
28805The default is @option{-mgpopt} except when @option{-fpic} or
28806@option{-fPIC} is specified to generate position-independent code.
28807Note that the Nios II ABI does not permit GP-relative accesses from
28808shared libraries.
28809
28810You may need to specify @option{-mno-gpopt} explicitly when building
28811programs that include large amounts of small data, including large
28812GOT data sections. In this case, the 16-bit offset for GP-relative
28813addressing may not be large enough to allow access to the entire
28814small data section.
28815
d77de738 28816@opindex mgprel-sec
ddf6fe37 28817@item -mgprel-sec=@var{regexp}
d77de738
ML
28818This option specifies additional section names that can be accessed via
28819GP-relative addressing. It is most useful in conjunction with
28820@code{section} attributes on variable declarations
28821(@pxref{Common Variable Attributes}) and a custom linker script.
28822The @var{regexp} is a POSIX Extended Regular Expression.
28823
28824This option does not affect the behavior of the @option{-G} option, and
28825the specified sections are in addition to the standard @code{.sdata}
28826and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28827
d77de738 28828@opindex mr0rel-sec
ddf6fe37 28829@item -mr0rel-sec=@var{regexp}
d77de738
ML
28830This option specifies names of sections that can be accessed via a
2883116-bit offset from @code{r0}; that is, in the low 32K or high 32K
28832of the 32-bit address space. It is most useful in conjunction with
28833@code{section} attributes on variable declarations
28834(@pxref{Common Variable Attributes}) and a custom linker script.
28835The @var{regexp} is a POSIX Extended Regular Expression.
28836
28837In contrast to the use of GP-relative addressing for small data,
28838zero-based addressing is never generated by default and there are no
28839conventional section names used in standard linker scripts for sections
28840in the low or high areas of memory.
28841
d77de738
ML
28842@opindex mel
28843@opindex meb
ddf6fe37
AA
28844@item -mel
28845@itemx -meb
d77de738
ML
28846Generate little-endian (default) or big-endian (experimental) code,
28847respectively.
28848
d77de738 28849@opindex march
ddf6fe37 28850@item -march=@var{arch}
d77de738
ML
28851This specifies the name of the target Nios II architecture. GCC uses this
28852name to determine what kind of instructions it can emit when generating
28853assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28854
28855The preprocessor macro @code{__nios2_arch__} is available to programs,
28856with value 1 or 2, indicating the targeted ISA level.
28857
d77de738
ML
28858@opindex mno-bypass-cache
28859@opindex mbypass-cache
ddf6fe37
AA
28860@item -mbypass-cache
28861@itemx -mno-bypass-cache
d77de738
ML
28862Force all load and store instructions to always bypass cache by
28863using I/O variants of the instructions. The default is not to
28864bypass the cache.
28865
d77de738
ML
28866@opindex mcache-volatile
28867@opindex mno-cache-volatile
ddf6fe37
AA
28868@item -mno-cache-volatile
28869@itemx -mcache-volatile
d77de738
ML
28870Volatile memory access bypass the cache using the I/O variants of
28871the load and store instructions. The default is not to bypass the cache.
28872
d77de738
ML
28873@opindex mno-fast-sw-div
28874@opindex mfast-sw-div
ddf6fe37
AA
28875@item -mno-fast-sw-div
28876@itemx -mfast-sw-div
d77de738
ML
28877Do not use table-based fast divide for small numbers. The default
28878is to use the fast divide at @option{-O3} and above.
28879
d77de738
ML
28880@opindex mno-hw-mul
28881@opindex mhw-mul
28882@opindex mno-hw-mulx
28883@opindex mhw-mulx
28884@opindex mno-hw-div
28885@opindex mhw-div
ddf6fe37
AA
28886@item -mno-hw-mul
28887@itemx -mhw-mul
28888@itemx -mno-hw-mulx
28889@itemx -mhw-mulx
28890@itemx -mno-hw-div
28891@itemx -mhw-div
d77de738
ML
28892Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28893instructions by the compiler. The default is to emit @code{mul}
28894and not emit @code{div} and @code{mulx}.
28895
28896@item -mbmx
28897@itemx -mno-bmx
28898@itemx -mcdx
28899@itemx -mno-cdx
28900Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28901CDX (code density) instructions. Enabling these instructions also
28902requires @option{-march=r2}. Since these instructions are optional
28903extensions to the R2 architecture, the default is not to emit them.
28904
d77de738
ML
28905@opindex mcustom-@var{insn}
28906@opindex mno-custom-@var{insn}
ddf6fe37
AA
28907@item -mcustom-@var{insn}=@var{N}
28908@itemx -mno-custom-@var{insn}
d77de738
ML
28909Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28910custom instruction with encoding @var{N} when generating code that uses
28911@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28912instruction 253 for single-precision floating-point add operations instead
28913of the default behavior of using a library call.
28914
28915The following values of @var{insn} are supported. Except as otherwise
28916noted, floating-point operations are expected to be implemented with
28917normal IEEE 754 semantics and correspond directly to the C operators or the
28918equivalent GCC built-in functions (@pxref{Other Builtins}).
28919
28920Single-precision floating point:
28921@table @asis
28922
28923@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28924Binary arithmetic operations.
28925
28926@item @samp{fnegs}
28927Unary negation.
28928
28929@item @samp{fabss}
28930Unary absolute value.
28931
28932@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28933Comparison operations.
28934
28935@item @samp{fmins}, @samp{fmaxs}
28936Floating-point minimum and maximum. These instructions are only
28937generated if @option{-ffinite-math-only} is specified.
28938
28939@item @samp{fsqrts}
28940Unary square root operation.
28941
28942@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28943Floating-point trigonometric and exponential functions. These instructions
28944are only generated if @option{-funsafe-math-optimizations} is also specified.
28945
28946@end table
28947
28948Double-precision floating point:
28949@table @asis
28950
28951@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28952Binary arithmetic operations.
28953
28954@item @samp{fnegd}
28955Unary negation.
28956
28957@item @samp{fabsd}
28958Unary absolute value.
28959
28960@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28961Comparison operations.
28962
28963@item @samp{fmind}, @samp{fmaxd}
28964Double-precision minimum and maximum. These instructions are only
28965generated if @option{-ffinite-math-only} is specified.
28966
28967@item @samp{fsqrtd}
28968Unary square root operation.
28969
28970@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28971Double-precision trigonometric and exponential functions. These instructions
28972are only generated if @option{-funsafe-math-optimizations} is also specified.
28973
28974@end table
28975
28976Conversions:
28977@table @asis
28978@item @samp{fextsd}
28979Conversion from single precision to double precision.
28980
28981@item @samp{ftruncds}
28982Conversion from double precision to single precision.
28983
28984@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28985Conversion from floating point to signed or unsigned integer types, with
28986truncation towards zero.
28987
28988@item @samp{round}
28989Conversion from single-precision floating point to signed integer,
28990rounding to the nearest integer and ties away from zero.
28991This corresponds to the @code{__builtin_lroundf} function when
28992@option{-fno-math-errno} is used.
28993
28994@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28995Conversion from signed or unsigned integer types to floating-point types.
28996
28997@end table
28998
28999In addition, all of the following transfer instructions for internal
29000registers X and Y must be provided to use any of the double-precision
29001floating-point instructions. Custom instructions taking two
29002double-precision source operands expect the first operand in the
2900364-bit register X. The other operand (or only operand of a unary
29004operation) is given to the custom arithmetic instruction with the
29005least significant half in source register @var{src1} and the most
29006significant half in @var{src2}. A custom instruction that returns a
29007double-precision result returns the most significant 32 bits in the
29008destination register and the other half in 32-bit register Y.
29009GCC automatically generates the necessary code sequences to write
29010register X and/or read register Y when double-precision floating-point
29011instructions are used.
29012
29013@table @asis
29014
29015@item @samp{fwrx}
29016Write @var{src1} into the least significant half of X and @var{src2} into
29017the most significant half of X.
29018
29019@item @samp{fwry}
29020Write @var{src1} into Y.
29021
29022@item @samp{frdxhi}, @samp{frdxlo}
29023Read the most or least (respectively) significant half of X and store it in
29024@var{dest}.
29025
29026@item @samp{frdy}
29027Read the value of Y and store it into @var{dest}.
29028@end table
29029
29030Note that you can gain more local control over generation of Nios II custom
29031instructions by using the @code{target("custom-@var{insn}=@var{N}")}
29032and @code{target("no-custom-@var{insn}")} function attributes
29033(@pxref{Function Attributes})
29034or pragmas (@pxref{Function Specific Option Pragmas}).
29035
d77de738 29036@opindex mcustom-fpu-cfg
ddf6fe37 29037@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
29038
29039This option enables a predefined, named set of custom instruction encodings
29040(see @option{-mcustom-@var{insn}} above).
29041Currently, the following sets are defined:
29042
29043@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
29044@gccoptlist{-mcustom-fmuls=252
29045-mcustom-fadds=253
29046-mcustom-fsubs=254
d77de738
ML
29047-fsingle-precision-constant}
29048
29049@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
29050@gccoptlist{-mcustom-fmuls=252
29051-mcustom-fadds=253
29052-mcustom-fsubs=254
29053-mcustom-fdivs=255
d77de738
ML
29054-fsingle-precision-constant}
29055
29056@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
29057@gccoptlist{-mcustom-floatus=243
29058-mcustom-fixsi=244
29059-mcustom-floatis=245
29060-mcustom-fcmpgts=246
29061-mcustom-fcmples=249
29062-mcustom-fcmpeqs=250
29063-mcustom-fcmpnes=251
29064-mcustom-fmuls=252
29065-mcustom-fadds=253
29066-mcustom-fsubs=254
29067-mcustom-fdivs=255
d77de738
ML
29068-fsingle-precision-constant}
29069
29070@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
29071@gccoptlist{-mcustom-fabss=224
29072-mcustom-fnegs=225
29073-mcustom-fcmpnes=226
29074-mcustom-fcmpeqs=227
29075-mcustom-fcmpges=228
29076-mcustom-fcmpgts=229
29077-mcustom-fcmples=230
29078-mcustom-fcmplts=231
29079-mcustom-fmaxs=232
29080-mcustom-fmins=233
29081-mcustom-round=248
29082-mcustom-fixsi=249
29083-mcustom-floatis=250
29084-mcustom-fsqrts=251
29085-mcustom-fmuls=252
29086-mcustom-fadds=253
29087-mcustom-fsubs=254
29088-mcustom-fdivs=255}
d77de738
ML
29089
29090Custom instruction assignments given by individual
29091@option{-mcustom-@var{insn}=} options override those given by
29092@option{-mcustom-fpu-cfg=}, regardless of the
29093order of the options on the command line.
29094
29095Note that you can gain more local control over selection of a FPU
29096configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
29097function attribute (@pxref{Function Attributes})
29098or pragma (@pxref{Function Specific Option Pragmas}).
29099
29100The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
29101Hardware 2 Component}. Please note that the custom instructions enabled by
29102@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
29103if @option{-ffinite-math-only} is specified. The custom instruction enabled by
29104@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
29105specified. In contrast to the other configurations,
29106@option{-fsingle-precision-constant} is not set.
29107
29108@end table
29109
29110These additional @samp{-m} options are available for the Altera Nios II
29111ELF (bare-metal) target:
29112
29113@table @gcctabopt
29114
d77de738 29115@opindex mhal
ddf6fe37 29116@item -mhal
d77de738
ML
29117Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
29118startup and termination code, and is typically used in conjunction with
29119@option{-msys-crt0=} to specify the location of the alternate startup code
29120provided by the HAL BSP.
29121
d77de738 29122@opindex msmallc
ddf6fe37 29123@item -msmallc
d77de738
ML
29124Link with a limited version of the C library, @option{-lsmallc}, rather than
29125Newlib.
29126
d77de738 29127@opindex msys-crt0
ddf6fe37 29128@item -msys-crt0=@var{startfile}
d77de738
ML
29129@var{startfile} is the file name of the startfile (crt0) to use
29130when linking. This option is only useful in conjunction with @option{-mhal}.
29131
d77de738 29132@opindex msys-lib
ddf6fe37 29133@item -msys-lib=@var{systemlib}
d77de738
ML
29134@var{systemlib} is the library name of the library that provides
29135low-level system calls required by the C library,
29136e.g.@: @code{read} and @code{write}.
29137This option is typically used to link with a library provided by a HAL BSP.
29138
29139@end table
29140
29141@node Nvidia PTX Options
29142@subsection Nvidia PTX Options
29143@cindex Nvidia PTX options
29144@cindex nvptx options
29145
29146These options are defined for Nvidia PTX:
29147
29148@table @gcctabopt
29149
d77de738 29150@opindex m64
ddf6fe37 29151@item -m64
d77de738
ML
29152Ignored, but preserved for backward compatibility. Only 64-bit ABI is
29153supported.
29154
d77de738 29155@opindex march
ddf6fe37 29156@item -march=@var{architecture-string}
d77de738
ML
29157Generate code for the specified PTX ISA target architecture
29158(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
29159@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
29160@samp{sm_80}.
29161The default depends on how the compiler has been configured, see
29162@option{--with-arch}.
29163
29164This option sets the value of the preprocessor macro
29165@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
29166@samp{350}.
29167
d77de738 29168@opindex misa
ddf6fe37 29169@item -misa=@var{architecture-string}
d77de738
ML
29170Alias of @option{-march=}.
29171
d77de738 29172@opindex march
ddf6fe37 29173@item -march-map=@var{architecture-string}
d77de738
ML
29174Select the closest available @option{-march=} value that is not more
29175capable. For instance, for @option{-march-map=sm_50} select
29176@option{-march=sm_35}, and for @option{-march-map=sm_53} select
29177@option{-march=sm_53}.
29178
d77de738 29179@opindex mptx
ddf6fe37 29180@item -mptx=@var{version-string}
d77de738
ML
29181Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
29182Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
29183@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
29184version is required for specified PTX ISA target architecture via
29185option @option{-march=}.
29186
29187This option sets the values of the preprocessor macros
29188@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
29189for instance, for @samp{3.1} the macros have the values @samp{3} and
29190@samp{1}, respectively.
29191
d77de738 29192@opindex mmainkernel
ddf6fe37 29193@item -mmainkernel
d77de738
ML
29194Link in code for a __main kernel. This is for stand-alone instead of
29195offloading execution.
29196
d77de738 29197@opindex moptimize
ddf6fe37 29198@item -moptimize
d77de738
ML
29199Apply partitioned execution optimizations. This is the default when any
29200level of optimization is selected.
29201
d77de738 29202@opindex msoft-stack
ddf6fe37 29203@item -msoft-stack
d77de738
ML
29204Generate code that does not use @code{.local} memory
29205directly for stack storage. Instead, a per-warp stack pointer is
29206maintained explicitly. This enables variable-length stack allocation (with
29207variable-length arrays or @code{alloca}), and when global memory is used for
29208underlying storage, makes it possible to access automatic variables from other
29209threads, or with atomic instructions. This code generation variant is used
29210for OpenMP offloading, but the option is exposed on its own for the purpose
29211of testing the compiler; to generate code suitable for linking into programs
29212using OpenMP offloading, use option @option{-mgomp}.
29213
d77de738 29214@opindex muniform-simt
ddf6fe37 29215@item -muniform-simt
d77de738
ML
29216Switch to code generation variant that allows to execute all threads in each
29217warp, while maintaining memory state and side effects as if only one thread
29218in each warp was active outside of OpenMP SIMD regions. All atomic operations
29219and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
29220current lane index equals the master lane index), and the register being
29221assigned is copied via a shuffle instruction from the master lane. Outside of
29222SIMD regions lane 0 is the master; inside, each thread sees itself as the
29223master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
29224all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
29225regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
29226with current lane index to compute the master lane index.
29227
d77de738 29228@opindex mgomp
ddf6fe37 29229@item -mgomp
d77de738
ML
29230Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
29231@option{-muniform-simt} options, and selects corresponding multilib variant.
29232
29233@end table
29234
29235@node OpenRISC Options
29236@subsection OpenRISC Options
29237@cindex OpenRISC Options
29238
29239These options are defined for OpenRISC:
29240
29241@table @gcctabopt
29242
d77de738 29243@opindex mboard
ddf6fe37 29244@item -mboard=@var{name}
d77de738
ML
29245Configure a board specific runtime. This will be passed to the linker for
29246newlib board library linking. The default is @code{or1ksim}.
29247
d77de738 29248@opindex mnewlib
ddf6fe37 29249@item -mnewlib
d77de738
ML
29250This option is ignored; it is for compatibility purposes only. This used to
29251select linker and preprocessor options for use with newlib.
29252
d77de738
ML
29253@opindex msoft-div
29254@opindex mhard-div
ddf6fe37
AA
29255@item -msoft-div
29256@itemx -mhard-div
d77de738
ML
29257Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
29258This default is hardware divide.
29259
d77de738
ML
29260@opindex msoft-mul
29261@opindex mhard-mul
ddf6fe37
AA
29262@item -msoft-mul
29263@itemx -mhard-mul
d77de738
ML
29264Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
29265This default is hardware multiply.
29266
d77de738
ML
29267@opindex msoft-float
29268@opindex mhard-float
ddf6fe37
AA
29269@item -msoft-float
29270@itemx -mhard-float
d77de738
ML
29271Select software or hardware for floating point operations.
29272The default is software.
29273
d77de738 29274@opindex mdouble-float
ddf6fe37 29275@item -mdouble-float
d77de738
ML
29276When @option{-mhard-float} is selected, enables generation of double-precision
29277floating point instructions. By default functions from @file{libgcc} are used
29278to perform double-precision floating point operations.
29279
d77de738 29280@opindex munordered-float
ddf6fe37 29281@item -munordered-float
d77de738
ML
29282When @option{-mhard-float} is selected, enables generation of unordered
29283floating point compare and set flag (@code{lf.sfun*}) instructions. By default
29284functions from @file{libgcc} are used to perform unordered floating point
29285compare and set flag operations.
29286
d77de738 29287@opindex mcmov
ddf6fe37 29288@item -mcmov
d77de738
ML
29289Enable generation of conditional move (@code{l.cmov}) instructions. By
29290default the equivalent will be generated using set and branch.
29291
d77de738 29292@opindex mror
ddf6fe37 29293@item -mror
d77de738
ML
29294Enable generation of rotate right (@code{l.ror}) instructions. By default
29295functions from @file{libgcc} are used to perform rotate right operations.
29296
d77de738 29297@opindex mrori
ddf6fe37 29298@item -mrori
d77de738
ML
29299Enable generation of rotate right with immediate (@code{l.rori}) instructions.
29300By default functions from @file{libgcc} are used to perform rotate right with
29301immediate operations.
29302
d77de738 29303@opindex msext
ddf6fe37 29304@item -msext
d77de738
ML
29305Enable generation of sign extension (@code{l.ext*}) instructions. By default
29306memory loads are used to perform sign extension.
29307
d77de738 29308@opindex msfimm
ddf6fe37 29309@item -msfimm
d77de738
ML
29310Enable generation of compare and set flag with immediate (@code{l.sf*i})
29311instructions. By default extra instructions will be generated to store the
29312immediate to a register first.
29313
d77de738 29314@opindex mshftimm
ddf6fe37 29315@item -mshftimm
d77de738
ML
29316Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
29317@code{l.slli}) instructions. By default extra instructions will be generated
29318to store the immediate to a register first.
29319
d77de738 29320@opindex mcmodel=small
ddf6fe37 29321@item -mcmodel=small
d77de738
ML
29322Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
29323the default model.
29324
d77de738 29325@opindex mcmodel=large
ddf6fe37 29326@item -mcmodel=large
d77de738
ML
29327Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
29328
29329
29330@end table
29331
29332@node PDP-11 Options
29333@subsection PDP-11 Options
29334@cindex PDP-11 Options
29335
29336These options are defined for the PDP-11:
29337
29338@table @gcctabopt
d77de738 29339@opindex mfpu
ddf6fe37 29340@item -mfpu
d77de738
ML
29341Use hardware FPP floating point. This is the default. (FIS floating
29342point on the PDP-11/40 is not supported.) Implies -m45.
29343
d77de738 29344@opindex msoft-float
ddf6fe37 29345@item -msoft-float
d77de738
ML
29346Do not use hardware floating point.
29347
d77de738 29348@opindex mac0
ddf6fe37 29349@item -mac0
d77de738
ML
29350Return floating-point results in ac0 (fr0 in Unix assembler syntax).
29351
d77de738 29352@opindex mno-ac0
ddf6fe37 29353@item -mno-ac0
d77de738
ML
29354Return floating-point results in memory. This is the default.
29355
d77de738 29356@opindex m40
ddf6fe37 29357@item -m40
d77de738
ML
29358Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
29359
d77de738 29360@opindex m45
ddf6fe37 29361@item -m45
d77de738
ML
29362Generate code for a PDP-11/45. This is the default.
29363
d77de738 29364@opindex m10
ddf6fe37 29365@item -m10
d77de738
ML
29366Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
29367
d77de738
ML
29368@opindex mint16
29369@opindex mno-int32
ddf6fe37
AA
29370@item -mint16
29371@itemx -mno-int32
d77de738
ML
29372Use 16-bit @code{int}. This is the default.
29373
d77de738
ML
29374@opindex mint32
29375@opindex mno-int16
ddf6fe37
AA
29376@item -mint32
29377@itemx -mno-int16
d77de738
ML
29378Use 32-bit @code{int}.
29379
d77de738 29380@opindex msplit
ddf6fe37 29381@item -msplit
d77de738
ML
29382Target has split instruction and data space. Implies -m45.
29383
d77de738 29384@opindex munix-asm
ddf6fe37 29385@item -munix-asm
d77de738
ML
29386Use Unix assembler syntax.
29387
d77de738 29388@opindex mdec-asm
ddf6fe37 29389@item -mdec-asm
d77de738
ML
29390Use DEC assembler syntax.
29391
d77de738 29392@opindex mgnu-asm
ddf6fe37 29393@item -mgnu-asm
d77de738
ML
29394Use GNU assembler syntax. This is the default.
29395
d77de738 29396@opindex mlra
ddf6fe37 29397@item -mlra
d77de738
ML
29398Use the new LRA register allocator. By default, the old ``reload''
29399allocator is used.
29400@end table
29401
d77de738
ML
29402@node PowerPC Options
29403@subsection PowerPC Options
29404@cindex PowerPC options
29405
29406These are listed under @xref{RS/6000 and PowerPC Options}.
29407
29408@node PRU Options
29409@subsection PRU Options
29410@cindex PRU Options
29411
29412These command-line options are defined for PRU target:
29413
29414@table @gcctabopt
d77de738 29415@opindex minrt
ddf6fe37 29416@item -minrt
d77de738
ML
29417Link with a minimum runtime environment, with no support for static
29418initializers and constructors. Using this option can significantly reduce
29419the size of the final ELF binary. Beware that the compiler could still
29420generate code with static initializers and constructors. It is up to the
29421programmer to ensure that the source program will not use those features.
29422
d77de738 29423@opindex mmcu
ddf6fe37 29424@item -mmcu=@var{mcu}
d77de738
ML
29425Specify the PRU MCU variant to use. Check Newlib for the exact list of
29426supported MCUs.
29427
d77de738 29428@opindex mno-relax
ddf6fe37 29429@item -mno-relax
d77de738
ML
29430Make GCC pass the @option{--no-relax} command-line option to the linker
29431instead of the @option{--relax} option.
29432
d77de738 29433@opindex mloop
ddf6fe37 29434@item -mloop
d77de738
ML
29435Allow (or do not allow) GCC to use the LOOP instruction.
29436
d77de738 29437@opindex mabi
ddf6fe37 29438@item -mabi=@var{variant}
d77de738
ML
29439Specify the ABI variant to output code for. @option{-mabi=ti} selects the
29440unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
29441more naturally with certain GCC assumptions. These are the differences:
29442
29443@table @samp
29444@item Function Pointer Size
29445TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
29446supports only 32-bit data and code pointers.
29447
29448@item Optional Return Value Pointer
29449Function return values larger than 64 bits are passed by using a hidden
29450pointer as the first argument of the function. TI ABI, though, mandates that
29451the pointer can be NULL in case the caller is not using the returned value.
29452GNU always passes and expects a valid return value pointer.
29453
29454@end table
29455
29456The current @option{-mabi=ti} implementation simply raises a compile error
29457when any of the above code constructs is detected. As a consequence
29458the standard C library cannot be built and it is omitted when linking with
29459@option{-mabi=ti}.
29460
29461Relaxation is a GNU feature and for safety reasons is disabled when using
29462@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
29463instructions, so the GNU linker cannot adjust them when shortening adjacent
29464LDI32 pseudo instructions.
29465
29466@end table
29467
29468@node RISC-V Options
29469@subsection RISC-V Options
29470@cindex RISC-V Options
29471
29472These command-line options are defined for RISC-V targets:
29473
29474@table @gcctabopt
d77de738 29475@opindex mbranch-cost
ddf6fe37 29476@item -mbranch-cost=@var{n}
d77de738
ML
29477Set the cost of branches to roughly @var{n} instructions.
29478
ddf6fe37 29479@opindex plt
d77de738
ML
29480@item -mplt
29481@itemx -mno-plt
d77de738
ML
29482When generating PIC code, do or don't allow the use of PLTs. Ignored for
29483non-PIC. The default is @option{-mplt}.
29484
d77de738 29485@opindex mabi
ddf6fe37 29486@item -mabi=@var{ABI-string}
d77de738
ML
29487Specify integer and floating-point calling convention. @var{ABI-string}
29488contains two parts: the size of integer types and the registers used for
29489floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
29490@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2949132-bit), and that floating-point values up to 64 bits wide are passed in F
29492registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
29493allows the compiler to generate code that uses the F and D extensions but only
29494allows floating-point values up to 32 bits long to be passed in registers; or
29495@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
29496passed in registers.
29497
29498The default for this argument is system dependent, users who want a specific
29499calling convention should specify one explicitly. The valid calling
29500conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
29501@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
29502implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
29503invalid because the ABI requires 64-bit values be passed in F registers, but F
29504registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
29505only be used with the @samp{rv32e} architecture. This ABI is not well
29506specified at present, and is subject to change.
29507
ddf6fe37 29508@opindex mfdiv
d77de738
ML
29509@item -mfdiv
29510@itemx -mno-fdiv
d77de738
ML
29511Do or don't use hardware floating-point divide and square root instructions.
29512This requires the F or D extensions for floating-point registers. The default
29513is to use them if the specified architecture has these instructions.
29514
ddf6fe37 29515@opindex mdiv
d77de738
ML
29516@item -mdiv
29517@itemx -mno-div
d77de738
ML
29518Do or don't use hardware instructions for integer division. This requires the
29519M extension. The default is to use them if the specified architecture has
29520these instructions.
29521
d77de738 29522@opindex misa-spec
ddf6fe37 29523@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
29524Specify the version of the RISC-V Unprivileged (formerly User-Level)
29525ISA specification to produce code conforming to. The possibilities
29526for @var{ISA-spec-string} are:
29527@table @code
29528@item 2.2
29529Produce code conforming to version 2.2.
29530@item 20190608
29531Produce code conforming to version 20190608.
29532@item 20191213
29533Produce code conforming to version 20191213.
29534@end table
29535The default is @option{-misa-spec=20191213} unless GCC has been configured
29536with @option{--with-isa-spec=} specifying a different default version.
29537
d77de738 29538@opindex march
ddf6fe37 29539@item -march=@var{ISA-string}
d77de738
ML
29540Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
29541lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
29542@samp{rv32imaf}.
29543
29544When @option{-march=} is not specified, use the setting from @option{-mcpu}.
29545
29546If both @option{-march} and @option{-mcpu=} are not specified, the default for
29547this argument is system dependent, users who want a specific architecture
29548extensions should specify one explicitly.
29549
d77de738 29550@opindex mcpu
ddf6fe37 29551@item -mcpu=@var{processor-string}
d77de738
ML
29552Use architecture of and optimize the output for the given processor, specified
29553by particular CPU name.
29554Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
29555@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
29556@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 29557@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 29558
d77de738 29559@opindex mtune
ddf6fe37 29560@item -mtune=@var{processor-string}
d77de738
ML
29561Optimize the output for the given processor, specified by microarchitecture or
29562particular CPU name. Permissible values for this option are: @samp{rocket},
29563@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 29564@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
29565
29566When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
29567the default is @samp{rocket} if both are not specified.
29568
29569The @samp{size} choice is not intended for use by end-users. This is used
29570when @option{-Os} is specified. It overrides the instruction cost info
29571provided by @option{-mtune=}, but does not override the pipeline info. This
29572helps reduce code size while still giving good performance.
29573
d77de738 29574@opindex mpreferred-stack-boundary
ddf6fe37 29575@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
29576Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
29577byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
29578the default is 4 (16 bytes or 128-bits).
29579
29580@strong{Warning:} If you use this switch, then you must build all modules with
29581the same value, including any libraries. This includes the system libraries
29582and startup modules.
29583
d77de738 29584@opindex msmall-data-limit
ddf6fe37 29585@item -msmall-data-limit=@var{n}
d77de738
ML
29586Put global and static data smaller than @var{n} bytes into a special section
29587(on some targets).
29588
ddf6fe37 29589@opindex msave-restore
d77de738
ML
29590@item -msave-restore
29591@itemx -mno-save-restore
d77de738
ML
29592Do or don't use smaller but slower prologue and epilogue code that uses
29593library function calls. The default is to use fast inline prologues and
29594epilogues.
29595
f797260a
PN
29596@opindex minline-atomics
29597@item -minline-atomics
29598@itemx -mno-inline-atomics
29599Do or don't use smaller but slower subword atomic emulation code that uses
29600libatomic function calls. The default is to use fast inline subword atomics
29601that do not require libatomic.
29602
df48285b
CM
29603@opindex minline-strlen
29604@item -minline-strlen
29605@itemx -mno-inline-strlen
29606Do or do not attempt to inline strlen calls if possible.
29607Inlining will only be done if the string is properly aligned
29608and instructions for accelerated processing are available.
29609The default is to not inline strlen calls.
29610
949f1ccf
CM
29611@opindex minline-strcmp
29612@item -minline-strcmp
29613@itemx -mno-inline-strcmp
29614Do or do not attempt to inline strcmp calls if possible.
29615Inlining will only be done if the strings are properly aligned
29616and instructions for accelerated processing are available.
29617The default is to not inline strcmp calls.
29618
29619@opindex minline-strncmp
29620@item -minline-strncmp
29621@itemx -mno-inline-strncmp
29622Do or do not attempt to inline strncmp calls if possible.
29623Inlining will only be done if the strings are properly aligned
29624and instructions for accelerated processing are available.
29625The default is to not inline strncmp calls.
29626
ddf6fe37 29627@opindex mshorten-memrefs
d77de738
ML
29628@item -mshorten-memrefs
29629@itemx -mno-shorten-memrefs
d77de738
ML
29630Do or do not attempt to make more use of compressed load/store instructions by
29631replacing a load/store of 'base register + large offset' with a new load/store
29632of 'new base + small offset'. If the new base gets stored in a compressed
29633register, then the new load/store can be compressed. Currently targets 32-bit
29634integer load/stores only.
29635
ddf6fe37 29636@opindex mstrict-align
d77de738
ML
29637@item -mstrict-align
29638@itemx -mno-strict-align
d77de738
ML
29639Do not or do generate unaligned memory accesses. The default is set depending
29640on whether the processor we are optimizing for supports fast unaligned access
29641or not.
29642
d77de738 29643@opindex mcmodel=medlow
ddf6fe37 29644@item -mcmodel=medlow
d77de738
ML
29645Generate code for the medium-low code model. The program and its statically
29646defined symbols must lie within a single 2 GiB address range and must lie
29647between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29648statically or dynamically linked. This is the default code model.
29649
d77de738 29650@opindex mcmodel=medany
ddf6fe37 29651@item -mcmodel=medany
d77de738
ML
29652Generate code for the medium-any code model. The program and its statically
29653defined symbols must be within any single 2 GiB address range. Programs can be
29654statically or dynamically linked.
29655
29656The code generated by the medium-any code model is position-independent, but is
29657not guaranteed to function correctly when linked into position-independent
29658executables or libraries.
29659
29660@item -mexplicit-relocs
29661@itemx -mno-exlicit-relocs
29662Use or do not use assembler relocation operators when dealing with symbolic
29663addresses. The alternative is to use assembler macros instead, which may
29664limit optimization.
29665
ddf6fe37 29666@opindex mrelax
d77de738
ML
29667@item -mrelax
29668@itemx -mno-relax
d77de738
ML
29669Take advantage of linker relaxations to reduce the number of instructions
29670required to materialize symbol addresses. The default is to take advantage of
29671linker relaxations.
29672
ddf6fe37 29673@opindex mriscv-attribute
d77de738
ML
29674@item -mriscv-attribute
29675@itemx -mno-riscv-attribute
d77de738
ML
29676Emit (do not emit) RISC-V attribute to record extra information into ELF
29677objects. This feature requires at least binutils 2.32.
29678
ddf6fe37 29679@opindex mcsr-check
d77de738
ML
29680@item -mcsr-check
29681@itemx -mno-csr-check
d77de738
ML
29682Enables or disables the CSR checking.
29683
d77de738 29684@opindex malign-data
ddf6fe37 29685@item -malign-data=@var{type}
d77de738
ML
29686Control how GCC aligns variables and constants of array, structure, or union
29687types. Supported values for @var{type} are @samp{xlen} which uses x register
29688width as the alignment value, and @samp{natural} which uses natural alignment.
29689@samp{xlen} is the default.
29690
d77de738 29691@opindex mbig-endian
ddf6fe37 29692@item -mbig-endian
d77de738
ML
29693Generate big-endian code. This is the default when GCC is configured for a
29694@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29695
d77de738 29696@opindex mlittle-endian
ddf6fe37 29697@item -mlittle-endian
d77de738
ML
29698Generate little-endian code. This is the default when GCC is configured for a
29699@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29700@samp{riscv32be-*-*} target.
29701
d77de738
ML
29702@opindex mstack-protector-guard
29703@opindex mstack-protector-guard-reg
29704@opindex mstack-protector-guard-offset
ddf6fe37
AA
29705@item -mstack-protector-guard=@var{guard}
29706@itemx -mstack-protector-guard-reg=@var{reg}
29707@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29708Generate stack protection code using canary at @var{guard}. Supported
29709locations are @samp{global} for a global canary or @samp{tls} for per-thread
29710canary in the TLS block.
29711
29712With the latter choice the options
29713@option{-mstack-protector-guard-reg=@var{reg}} and
29714@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29715which register to use as base register for reading the canary,
29716and from what offset from that base register. There is no default
29717register or offset as this is entirely for use within the Linux
29718kernel.
29719@end table
29720
29721@node RL78 Options
29722@subsection RL78 Options
29723@cindex RL78 Options
29724
29725@table @gcctabopt
29726
d77de738 29727@opindex msim
ddf6fe37 29728@item -msim
d77de738
ML
29729Links in additional target libraries to support operation within a
29730simulator.
29731
ddf6fe37 29732@opindex mmul
d77de738
ML
29733@item -mmul=none
29734@itemx -mmul=g10
29735@itemx -mmul=g13
29736@itemx -mmul=g14
29737@itemx -mmul=rl78
d77de738
ML
29738Specifies the type of hardware multiplication and division support to
29739be used. The simplest is @code{none}, which uses software for both
29740multiplication and division. This is the default. The @code{g13}
29741value is for the hardware multiply/divide peripheral found on the
29742RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29743the multiplication and division instructions supported by the RL78/G14
29744(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29745the value @code{mg10} is an alias for @code{none}.
29746
29747In addition a C preprocessor macro is defined, based upon the setting
29748of this option. Possible values are: @code{__RL78_MUL_NONE__},
29749@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29750
ddf6fe37 29751@opindex mcpu
d77de738
ML
29752@item -mcpu=g10
29753@itemx -mcpu=g13
29754@itemx -mcpu=g14
29755@itemx -mcpu=rl78
d77de738
ML
29756Specifies the RL78 core to target. The default is the G14 core, also
29757known as an S3 core or just RL78. The G13 or S2 core does not have
29758multiply or divide instructions, instead it uses a hardware peripheral
29759for these operations. The G10 or S1 core does not have register
29760banks, so it uses a different calling convention.
29761
29762If this option is set it also selects the type of hardware multiply
29763support to use, unless this is overridden by an explicit
29764@option{-mmul=none} option on the command line. Thus specifying
29765@option{-mcpu=g13} enables the use of the G13 hardware multiply
29766peripheral and specifying @option{-mcpu=g10} disables the use of
29767hardware multiplications altogether.
29768
29769Note, although the RL78/G14 core is the default target, specifying
29770@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29771change the behavior of the toolchain since it also enables G14
29772hardware multiply support. If these options are not specified on the
29773command line then software multiplication routines will be used even
29774though the code targets the RL78 core. This is for backwards
29775compatibility with older toolchains which did not have hardware
29776multiply and divide support.
29777
29778In addition a C preprocessor macro is defined, based upon the setting
29779of this option. Possible values are: @code{__RL78_G10__},
29780@code{__RL78_G13__} or @code{__RL78_G14__}.
29781
d77de738
ML
29782@opindex mg10
29783@opindex mg13
29784@opindex mg14
29785@opindex mrl78
ddf6fe37
AA
29786@item -mg10
29787@itemx -mg13
29788@itemx -mg14
29789@itemx -mrl78
d77de738
ML
29790These are aliases for the corresponding @option{-mcpu=} option. They
29791are provided for backwards compatibility.
29792
d77de738 29793@opindex mallregs
ddf6fe37 29794@item -mallregs
d77de738
ML
29795Allow the compiler to use all of the available registers. By default
29796registers @code{r24..r31} are reserved for use in interrupt handlers.
29797With this option enabled these registers can be used in ordinary
29798functions as well.
29799
d77de738
ML
29800@opindex m64bit-doubles
29801@opindex m32bit-doubles
ddf6fe37
AA
29802@item -m64bit-doubles
29803@itemx -m32bit-doubles
d77de738
ML
29804Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29805or 32 bits (@option{-m32bit-doubles}) in size. The default is
29806@option{-m32bit-doubles}.
29807
d77de738
ML
29808@opindex msave-mduc-in-interrupts
29809@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29810@item -msave-mduc-in-interrupts
29811@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29812Specifies that interrupt handler functions should preserve the
29813MDUC registers. This is only necessary if normal code might use
29814the MDUC registers, for example because it performs multiplication
29815and division operations. The default is to ignore the MDUC registers
29816as this makes the interrupt handlers faster. The target option -mg13
29817needs to be passed for this to work as this feature is only available
29818on the G13 target (S2 core). The MDUC registers will only be saved
29819if the interrupt handler performs a multiplication or division
29820operation or it calls another function.
29821
29822@end table
29823
29824@node RS/6000 and PowerPC Options
29825@subsection IBM RS/6000 and PowerPC Options
29826@cindex RS/6000 and PowerPC Options
29827@cindex IBM RS/6000 and PowerPC Options
29828
29829These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29830@table @gcctabopt
29831@item -mpowerpc-gpopt
29832@itemx -mno-powerpc-gpopt
29833@itemx -mpowerpc-gfxopt
29834@itemx -mno-powerpc-gfxopt
29835@need 800
29836@itemx -mpowerpc64
29837@itemx -mno-powerpc64
29838@itemx -mmfcrf
29839@itemx -mno-mfcrf
29840@itemx -mpopcntb
29841@itemx -mno-popcntb
29842@itemx -mpopcntd
29843@itemx -mno-popcntd
29844@itemx -mfprnd
29845@itemx -mno-fprnd
29846@need 800
d77de738
ML
29847@opindex mpowerpc-gpopt
29848@opindex mno-powerpc-gpopt
29849@opindex mpowerpc-gfxopt
29850@opindex mno-powerpc-gfxopt
29851@opindex mpowerpc64
29852@opindex mno-powerpc64
29853@opindex mmfcrf
29854@opindex mno-mfcrf
29855@opindex mpopcntb
29856@opindex mno-popcntb
29857@opindex mpopcntd
29858@opindex mno-popcntd
29859@opindex mfprnd
29860@opindex mno-fprnd
29861@opindex mcmpb
29862@opindex mno-cmpb
29863@opindex mhard-dfp
29864@opindex mno-hard-dfp
ddf6fe37
AA
29865@itemx -mcmpb
29866@itemx -mno-cmpb
29867@itemx -mhard-dfp
29868@itemx -mno-hard-dfp
d77de738
ML
29869You use these options to specify which instructions are available on the
29870processor you are using. The default value of these options is
29871determined when configuring GCC@. Specifying the
29872@option{-mcpu=@var{cpu_type}} overrides the specification of these
29873options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29874rather than the options listed above.
29875
29876Specifying @option{-mpowerpc-gpopt} allows
29877GCC to use the optional PowerPC architecture instructions in the
29878General Purpose group, including floating-point square root. Specifying
29879@option{-mpowerpc-gfxopt} allows GCC to
29880use the optional PowerPC architecture instructions in the Graphics
29881group, including floating-point select.
29882
29883The @option{-mmfcrf} option allows GCC to generate the move from
29884condition register field instruction implemented on the POWER4
29885processor and other processors that support the PowerPC V2.01
29886architecture.
29887The @option{-mpopcntb} option allows GCC to generate the popcount and
29888double-precision FP reciprocal estimate instruction implemented on the
29889POWER5 processor and other processors that support the PowerPC V2.02
29890architecture.
29891The @option{-mpopcntd} option allows GCC to generate the popcount
29892instruction implemented on the POWER7 processor and other processors
29893that support the PowerPC V2.06 architecture.
29894The @option{-mfprnd} option allows GCC to generate the FP round to
29895integer instructions implemented on the POWER5+ processor and other
29896processors that support the PowerPC V2.03 architecture.
29897The @option{-mcmpb} option allows GCC to generate the compare bytes
29898instruction implemented on the POWER6 processor and other processors
29899that support the PowerPC V2.05 architecture.
29900The @option{-mhard-dfp} option allows GCC to generate the decimal
29901floating-point instructions implemented on some POWER processors.
29902
29903The @option{-mpowerpc64} option allows GCC to generate the additional
2990464-bit instructions that are found in the full PowerPC64 architecture
29905and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29906@option{-mno-powerpc64}.
29907
d77de738 29908@opindex mcpu
ddf6fe37 29909@item -mcpu=@var{cpu_type}
d77de738
ML
29910Set architecture type, register usage, and
29911instruction scheduling parameters for machine type @var{cpu_type}.
29912Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29913@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29914@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29915@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29916@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29917@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29918@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29919@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29920@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29921@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29922@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29923@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29924
29925@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29926@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29927endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29928architecture machine types, with an appropriate, generic processor
29929model assumed for scheduling purposes.
29930
29931Specifying @samp{native} as cpu type detects and selects the
29932architecture option that corresponds to the host processor of the
29933system performing the compilation.
29934@option{-mcpu=native} has no effect if GCC does not recognize the
29935processor.
29936
29937The other options specify a specific processor. Code generated under
29938those options runs best on that processor, and may not run at all on
29939others.
29940
29941The @option{-mcpu} options automatically enable or disable the
29942following options:
29943
43b72ede
AA
29944@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
29945-mpopcntb -mpopcntd -mpowerpc64
29946-mpowerpc-gpopt -mpowerpc-gfxopt
29947-mmulhw -mdlmzb -mmfpgpr -mvsx
29948-mcrypto -mhtm -mpower8-fusion -mpower8-vector
29949-mquad-memory -mquad-memory-atomic -mfloat128
29950-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
29951-mrop-protect}
29952
29953The particular options set for any particular CPU varies between
29954compiler versions, depending on what setting seems to produce optimal
29955code for that CPU; it doesn't necessarily reflect the actual hardware's
29956capabilities. If you wish to set an individual option to a particular
29957value, you may specify it after the @option{-mcpu} option, like
29958@option{-mcpu=970 -mno-altivec}.
29959
29960On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29961not enabled or disabled by the @option{-mcpu} option at present because
29962AIX does not have full support for these options. You may still
29963enable or disable them individually if you're sure it'll work in your
29964environment.
29965
d77de738 29966@opindex mtune
ddf6fe37 29967@item -mtune=@var{cpu_type}
d77de738
ML
29968Set the instruction scheduling parameters for machine type
29969@var{cpu_type}, but do not set the architecture type or register usage,
29970as @option{-mcpu=@var{cpu_type}} does. The same
29971values for @var{cpu_type} are used for @option{-mtune} as for
29972@option{-mcpu}. If both are specified, the code generated uses the
29973architecture and registers set by @option{-mcpu}, but the
29974scheduling parameters set by @option{-mtune}.
29975
d77de738 29976@opindex mcmodel=small
ddf6fe37 29977@item -mcmodel=small
d77de738
ML
29978Generate PowerPC64 code for the small model: The TOC is limited to
2997964k.
29980
d77de738 29981@opindex mcmodel=medium
ddf6fe37 29982@item -mcmodel=medium
d77de738
ML
29983Generate PowerPC64 code for the medium model: The TOC and other static
29984data may be up to a total of 4G in size. This is the default for 64-bit
29985Linux.
29986
d77de738 29987@opindex mcmodel=large
ddf6fe37 29988@item -mcmodel=large
d77de738
ML
29989Generate PowerPC64 code for the large model: The TOC may be up to 4G
29990in size. Other data and code is only limited by the 64-bit address
29991space.
29992
d77de738
ML
29993@opindex maltivec
29994@opindex mno-altivec
ddf6fe37
AA
29995@item -maltivec
29996@itemx -mno-altivec
d77de738
ML
29997Generate code that uses (does not use) AltiVec instructions, and also
29998enable the use of built-in functions that allow more direct access to
29999the AltiVec instruction set. You may also need to set
30000@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
30001enhancements.
30002
30003When @option{-maltivec} is used, the element order for AltiVec intrinsics
30004such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
30005match array element order corresponding to the endianness of the
30006target. That is, element zero identifies the leftmost element in a
30007vector register when targeting a big-endian platform, and identifies
30008the rightmost element in a vector register when targeting a
30009little-endian platform.
30010
d77de738
ML
30011@opindex mvrsave
30012@opindex mno-vrsave
ddf6fe37
AA
30013@item -mvrsave
30014@itemx -mno-vrsave
d77de738
ML
30015Generate VRSAVE instructions when generating AltiVec code.
30016
d77de738 30017@opindex msecure-plt
ddf6fe37 30018@item -msecure-plt
d77de738
ML
30019Generate code that allows @command{ld} and @command{ld.so}
30020to build executables and shared
30021libraries with non-executable @code{.plt} and @code{.got} sections.
30022This is a PowerPC
3002332-bit SYSV ABI option.
30024
d77de738 30025@opindex mbss-plt
ddf6fe37 30026@item -mbss-plt
d77de738
ML
30027Generate code that uses a BSS @code{.plt} section that @command{ld.so}
30028fills in, and
30029requires @code{.plt} and @code{.got}
30030sections that are both writable and executable.
30031This is a PowerPC 32-bit SYSV ABI option.
30032
d77de738
ML
30033@opindex misel
30034@opindex mno-isel
ddf6fe37
AA
30035@item -misel
30036@itemx -mno-isel
d77de738
ML
30037This switch enables or disables the generation of ISEL instructions.
30038
d77de738
ML
30039@opindex mvsx
30040@opindex mno-vsx
ddf6fe37
AA
30041@item -mvsx
30042@itemx -mno-vsx
d77de738
ML
30043Generate code that uses (does not use) vector/scalar (VSX)
30044instructions, and also enable the use of built-in functions that allow
30045more direct access to the VSX instruction set.
30046
d77de738
ML
30047@opindex mcrypto
30048@opindex mno-crypto
ddf6fe37
AA
30049@item -mcrypto
30050@itemx -mno-crypto
d77de738
ML
30051Enable the use (disable) of the built-in functions that allow direct
30052access to the cryptographic instructions that were added in version
300532.07 of the PowerPC ISA.
30054
d77de738
ML
30055@opindex mhtm
30056@opindex mno-htm
ddf6fe37
AA
30057@item -mhtm
30058@itemx -mno-htm
d77de738
ML
30059Enable (disable) the use of the built-in functions that allow direct
30060access to the Hardware Transactional Memory (HTM) instructions that
30061were added in version 2.07 of the PowerPC ISA.
30062
d77de738
ML
30063@opindex mpower8-fusion
30064@opindex mno-power8-fusion
ddf6fe37
AA
30065@item -mpower8-fusion
30066@itemx -mno-power8-fusion
d77de738
ML
30067Generate code that keeps (does not keeps) some integer operations
30068adjacent so that the instructions can be fused together on power8 and
30069later processors.
30070
d77de738
ML
30071@opindex mpower8-vector
30072@opindex mno-power8-vector
ddf6fe37
AA
30073@item -mpower8-vector
30074@itemx -mno-power8-vector
d77de738
ML
30075Generate code that uses (does not use) the vector and scalar
30076instructions that were added in version 2.07 of the PowerPC ISA. Also
30077enable the use of built-in functions that allow more direct access to
30078the vector instructions.
30079
d77de738
ML
30080@opindex mquad-memory
30081@opindex mno-quad-memory
ddf6fe37
AA
30082@item -mquad-memory
30083@itemx -mno-quad-memory
d77de738
ML
30084Generate code that uses (does not use) the non-atomic quad word memory
30085instructions. The @option{-mquad-memory} option requires use of
3008664-bit mode.
30087
d77de738
ML
30088@opindex mquad-memory-atomic
30089@opindex mno-quad-memory-atomic
ddf6fe37
AA
30090@item -mquad-memory-atomic
30091@itemx -mno-quad-memory-atomic
d77de738
ML
30092Generate code that uses (does not use) the atomic quad word memory
30093instructions. The @option{-mquad-memory-atomic} option requires use of
3009464-bit mode.
30095
d77de738
ML
30096@opindex mfloat128
30097@opindex mno-float128
ddf6fe37
AA
30098@item -mfloat128
30099@itemx -mno-float128
d77de738
ML
30100Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
30101and use either software emulation for IEEE 128-bit floating point or
30102hardware instructions.
30103
30104The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
30105128-bit floating point support. The IEEE 128-bit floating point is only
30106supported on Linux.
30107
30108The default for @option{-mfloat128} is enabled on PowerPC Linux
30109systems using the VSX instruction set, and disabled on other systems.
30110
30111If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
30112@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
30113point support will also enable the generation of ISA 3.0 IEEE 128-bit
30114floating point instructions. Otherwise, if you do not specify to
30115generate ISA 3.0 instructions or you are targeting a 32-bit big endian
30116system, IEEE 128-bit floating point will be done with software
30117emulation.
30118
d77de738
ML
30119@opindex mfloat128-hardware
30120@opindex mno-float128-hardware
ddf6fe37
AA
30121@item -mfloat128-hardware
30122@itemx -mno-float128-hardware
d77de738
ML
30123Enable/disable using ISA 3.0 hardware instructions to support the
30124@var{__float128} data type.
30125
30126The default for @option{-mfloat128-hardware} is enabled on PowerPC
30127Linux systems using the ISA 3.0 instruction set, and disabled on other
30128systems.
30129
d77de738
ML
30130@opindex m32
30131@opindex m64
ddf6fe37
AA
30132@item -m32
30133@itemx -m64
d77de738
ML
30134Generate code for 32-bit or 64-bit environments of Darwin and SVR4
30135targets (including GNU/Linux). The 32-bit environment sets int, long
30136and pointer to 32 bits and generates code that runs on any PowerPC
30137variant. The 64-bit environment sets int to 32 bits and long and
30138pointer to 64 bits, and generates code for PowerPC64, as for
30139@option{-mpowerpc64}.
30140
d77de738
ML
30141@opindex mfull-toc
30142@opindex mno-fp-in-toc
30143@opindex mno-sum-in-toc
30144@opindex mminimal-toc
ddf6fe37
AA
30145@item -mfull-toc
30146@itemx -mno-fp-in-toc
30147@itemx -mno-sum-in-toc
30148@itemx -mminimal-toc
d77de738
ML
30149Modify generation of the TOC (Table Of Contents), which is created for
30150every executable file. The @option{-mfull-toc} option is selected by
30151default. In that case, GCC allocates at least one TOC entry for
30152each unique non-automatic variable reference in your program. GCC
30153also places floating-point constants in the TOC@. However, only
3015416,384 entries are available in the TOC@.
30155
30156If you receive a linker error message that saying you have overflowed
30157the available TOC space, you can reduce the amount of TOC space used
30158with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
30159@option{-mno-fp-in-toc} prevents GCC from putting floating-point
30160constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
30161generate code to calculate the sum of an address and a constant at
30162run time instead of putting that sum into the TOC@. You may specify one
30163or both of these options. Each causes GCC to produce very slightly
30164slower and larger code at the expense of conserving TOC space.
30165
30166If you still run out of space in the TOC even when you specify both of
30167these options, specify @option{-mminimal-toc} instead. This option causes
30168GCC to make only one TOC entry for every file. When you specify this
30169option, GCC produces code that is slower and larger but which
30170uses extremely little TOC space. You may wish to use this option
30171only on files that contain less frequently-executed code.
30172
d77de738
ML
30173@opindex maix64
30174@opindex maix32
ddf6fe37
AA
30175@item -maix64
30176@itemx -maix32
d77de738
ML
30177Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
30178@code{long} type, and the infrastructure needed to support them.
30179Specifying @option{-maix64} implies @option{-mpowerpc64},
30180while @option{-maix32} disables the 64-bit ABI and
30181implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
30182
d77de738
ML
30183@opindex mxl-compat
30184@opindex mno-xl-compat
ddf6fe37
AA
30185@item -mxl-compat
30186@itemx -mno-xl-compat
d77de738
ML
30187Produce code that conforms more closely to IBM XL compiler semantics
30188when using AIX-compatible ABI@. Pass floating-point arguments to
30189prototyped functions beyond the register save area (RSA) on the stack
30190in addition to argument FPRs. Do not assume that most significant
30191double in 128-bit long double value is properly rounded when comparing
30192values and converting to double. Use XL symbol names for long double
30193support routines.
30194
30195The AIX calling convention was extended but not initially documented to
30196handle an obscure K&R C case of calling a function that takes the
30197address of its arguments with fewer arguments than declared. IBM XL
30198compilers access floating-point arguments that do not fit in the
30199RSA from the stack when a subroutine is compiled without
30200optimization. Because always storing floating-point arguments on the
30201stack is inefficient and rarely needed, this option is not enabled by
30202default and only is necessary when calling subroutines compiled by IBM
30203XL compilers without optimization.
30204
d77de738 30205@opindex mpe
ddf6fe37 30206@item -mpe
d77de738
ML
30207Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
30208application written to use message passing with special startup code to
30209enable the application to run. The system must have PE installed in the
30210standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
30211must be overridden with the @option{-specs=} option to specify the
30212appropriate directory location. The Parallel Environment does not
30213support threads, so the @option{-mpe} option and the @option{-pthread}
30214option are incompatible.
30215
d77de738
ML
30216@opindex malign-natural
30217@opindex malign-power
ddf6fe37
AA
30218@item -malign-natural
30219@itemx -malign-power
d77de738
ML
30220On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
30221@option{-malign-natural} overrides the ABI-defined alignment of larger
30222types, such as floating-point doubles, on their natural size-based boundary.
30223The option @option{-malign-power} instructs GCC to follow the ABI-specified
30224alignment rules. GCC defaults to the standard alignment defined in the ABI@.
30225
30226On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
30227is not supported.
30228
d77de738
ML
30229@opindex msoft-float
30230@opindex mhard-float
ddf6fe37
AA
30231@item -msoft-float
30232@itemx -mhard-float
d77de738
ML
30233Generate code that does not use (uses) the floating-point register set.
30234Software floating-point emulation is provided if you use the
30235@option{-msoft-float} option, and pass the option to GCC when linking.
30236
d77de738
ML
30237@opindex mmultiple
30238@opindex mno-multiple
ddf6fe37
AA
30239@item -mmultiple
30240@itemx -mno-multiple
d77de738
ML
30241Generate code that uses (does not use) the load multiple word
30242instructions and the store multiple word instructions. These
30243instructions are generated by default on POWER systems, and not
30244generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
30245PowerPC systems, since those instructions do not work when the
30246processor is in little-endian mode. The exceptions are PPC740 and
30247PPC750 which permit these instructions in little-endian mode.
30248
d77de738
ML
30249@opindex mupdate
30250@opindex mno-update
ddf6fe37
AA
30251@item -mupdate
30252@itemx -mno-update
d77de738
ML
30253Generate code that uses (does not use) the load or store instructions
30254that update the base register to the address of the calculated memory
30255location. These instructions are generated by default. If you use
30256@option{-mno-update}, there is a small window between the time that the
30257stack pointer is updated and the address of the previous frame is
30258stored, which means code that walks the stack frame across interrupts or
30259signals may get corrupted data.
30260
d77de738
ML
30261@opindex mavoid-indexed-addresses
30262@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
30263@item -mavoid-indexed-addresses
30264@itemx -mno-avoid-indexed-addresses
d77de738
ML
30265Generate code that tries to avoid (not avoid) the use of indexed load
30266or store instructions. These instructions can incur a performance
30267penalty on Power6 processors in certain situations, such as when
30268stepping through large arrays that cross a 16M boundary. This option
30269is enabled by default when targeting Power6 and disabled otherwise.
30270
d77de738
ML
30271@opindex mfused-madd
30272@opindex mno-fused-madd
ddf6fe37
AA
30273@item -mfused-madd
30274@itemx -mno-fused-madd
d77de738
ML
30275Generate code that uses (does not use) the floating-point multiply and
30276accumulate instructions. These instructions are generated by default
30277if hardware floating point is used. The machine-dependent
30278@option{-mfused-madd} option is now mapped to the machine-independent
30279@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
30280mapped to @option{-ffp-contract=off}.
30281
d77de738
ML
30282@opindex mmulhw
30283@opindex mno-mulhw
ddf6fe37
AA
30284@item -mmulhw
30285@itemx -mno-mulhw
d77de738
ML
30286Generate code that uses (does not use) the half-word multiply and
30287multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
30288These instructions are generated by default when targeting those
30289processors.
30290
d77de738
ML
30291@opindex mdlmzb
30292@opindex mno-dlmzb
ddf6fe37
AA
30293@item -mdlmzb
30294@itemx -mno-dlmzb
d77de738
ML
30295Generate code that uses (does not use) the string-search @samp{dlmzb}
30296instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
30297generated by default when targeting those processors.
30298
d77de738
ML
30299@opindex mno-bit-align
30300@opindex mbit-align
ddf6fe37
AA
30301@item -mno-bit-align
30302@itemx -mbit-align
d77de738
ML
30303On System V.4 and embedded PowerPC systems do not (do) force structures
30304and unions that contain bit-fields to be aligned to the base type of the
30305bit-field.
30306
30307For example, by default a structure containing nothing but 8
30308@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
30309boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
30310the structure is aligned to a 1-byte boundary and is 1 byte in
30311size.
30312
d77de738
ML
30313@opindex mno-strict-align
30314@opindex mstrict-align
ddf6fe37
AA
30315@item -mno-strict-align
30316@itemx -mstrict-align
d77de738
ML
30317On System V.4 and embedded PowerPC systems do not (do) assume that
30318unaligned memory references are handled by the system.
30319
d77de738
ML
30320@opindex mrelocatable
30321@opindex mno-relocatable
ddf6fe37
AA
30322@item -mrelocatable
30323@itemx -mno-relocatable
d77de738
ML
30324Generate code that allows (does not allow) a static executable to be
30325relocated to a different address at run time. A simple embedded
30326PowerPC system loader should relocate the entire contents of
30327@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
30328a table of 32-bit addresses generated by this option. For this to
30329work, all objects linked together must be compiled with
30330@option{-mrelocatable} or @option{-mrelocatable-lib}.
30331@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
30332
d77de738
ML
30333@opindex mrelocatable-lib
30334@opindex mno-relocatable-lib
ddf6fe37
AA
30335@item -mrelocatable-lib
30336@itemx -mno-relocatable-lib
d77de738
ML
30337Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
30338@code{.fixup} section to allow static executables to be relocated at
30339run time, but @option{-mrelocatable-lib} does not use the smaller stack
30340alignment of @option{-mrelocatable}. Objects compiled with
30341@option{-mrelocatable-lib} may be linked with objects compiled with
30342any combination of the @option{-mrelocatable} options.
30343
d77de738
ML
30344@opindex mno-toc
30345@opindex mtoc
ddf6fe37
AA
30346@item -mno-toc
30347@itemx -mtoc
d77de738
ML
30348On System V.4 and embedded PowerPC systems do not (do) assume that
30349register 2 contains a pointer to a global area pointing to the addresses
30350used in the program.
30351
d77de738
ML
30352@opindex mlittle
30353@opindex mlittle-endian
ddf6fe37
AA
30354@item -mlittle
30355@itemx -mlittle-endian
d77de738
ML
30356On System V.4 and embedded PowerPC systems compile code for the
30357processor in little-endian mode. The @option{-mlittle-endian} option is
30358the same as @option{-mlittle}.
30359
d77de738
ML
30360@opindex mbig
30361@opindex mbig-endian
ddf6fe37
AA
30362@item -mbig
30363@itemx -mbig-endian
d77de738
ML
30364On System V.4 and embedded PowerPC systems compile code for the
30365processor in big-endian mode. The @option{-mbig-endian} option is
30366the same as @option{-mbig}.
30367
d77de738 30368@opindex mdynamic-no-pic
ddf6fe37 30369@item -mdynamic-no-pic
a335cf24 30370On Darwin / macOS systems, compile code so that it is not
d77de738
ML
30371relocatable, but that its external references are relocatable. The
30372resulting code is suitable for applications, but not shared
30373libraries.
30374
d77de738 30375@opindex msingle-pic-base
ddf6fe37 30376@item -msingle-pic-base
d77de738
ML
30377Treat the register used for PIC addressing as read-only, rather than
30378loading it in the prologue for each function. The runtime system is
30379responsible for initializing this register with an appropriate value
30380before execution begins.
30381
d77de738 30382@opindex mprioritize-restricted-insns
ddf6fe37 30383@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
30384This option controls the priority that is assigned to
30385dispatch-slot restricted instructions during the second scheduling
30386pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
30387or @samp{2} to assign no, highest, or second-highest (respectively)
30388priority to dispatch-slot restricted
30389instructions.
30390
d77de738 30391@opindex msched-costly-dep
ddf6fe37 30392@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
30393This option controls which dependences are considered costly
30394by the target during instruction scheduling. The argument
30395@var{dependence_type} takes one of the following values:
30396
30397@table @asis
30398@item @samp{no}
30399No dependence is costly.
30400
30401@item @samp{all}
30402All dependences are costly.
30403
30404@item @samp{true_store_to_load}
30405A true dependence from store to load is costly.
30406
30407@item @samp{store_to_load}
30408Any dependence from store to load is costly.
30409
30410@item @var{number}
30411Any dependence for which the latency is greater than or equal to
30412@var{number} is costly.
30413@end table
30414
d77de738 30415@opindex minsert-sched-nops
ddf6fe37 30416@item -minsert-sched-nops=@var{scheme}
d77de738
ML
30417This option controls which NOP insertion scheme is used during
30418the second scheduling pass. The argument @var{scheme} takes one of the
30419following values:
30420
30421@table @asis
30422@item @samp{no}
30423Don't insert NOPs.
30424
30425@item @samp{pad}
30426Pad with NOPs any dispatch group that has vacant issue slots,
30427according to the scheduler's grouping.
30428
30429@item @samp{regroup_exact}
30430Insert NOPs to force costly dependent insns into
30431separate groups. Insert exactly as many NOPs as needed to force an insn
30432to a new group, according to the estimated processor grouping.
30433
30434@item @var{number}
30435Insert NOPs to force costly dependent insns into
30436separate groups. Insert @var{number} NOPs to force an insn to a new group.
30437@end table
30438
d77de738 30439@opindex mcall-sysv
ddf6fe37 30440@item -mcall-sysv
d77de738
ML
30441On System V.4 and embedded PowerPC systems compile code using calling
30442conventions that adhere to the March 1995 draft of the System V
30443Application Binary Interface, PowerPC processor supplement. This is the
30444default unless you configured GCC using @samp{powerpc-*-eabiaix}.
30445
d77de738
ML
30446@opindex mcall-sysv-eabi
30447@opindex mcall-eabi
ddf6fe37
AA
30448@item -mcall-sysv-eabi
30449@itemx -mcall-eabi
d77de738
ML
30450Specify both @option{-mcall-sysv} and @option{-meabi} options.
30451
d77de738 30452@opindex mcall-sysv-noeabi
ddf6fe37 30453@item -mcall-sysv-noeabi
d77de738
ML
30454Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
30455
d7971cf7 30456@opindex mcall-aixdesc
ddf6fe37 30457@item -mcall-aixdesc
d77de738
ML
30458On System V.4 and embedded PowerPC systems compile code for the AIX
30459operating system.
30460
d77de738 30461@opindex mcall-linux
ddf6fe37 30462@item -mcall-linux
d77de738
ML
30463On System V.4 and embedded PowerPC systems compile code for the
30464Linux-based GNU system.
30465
d77de738 30466@opindex mcall-freebsd
ddf6fe37 30467@item -mcall-freebsd
d77de738
ML
30468On System V.4 and embedded PowerPC systems compile code for the
30469FreeBSD operating system.
30470
d77de738 30471@opindex mcall-netbsd
ddf6fe37 30472@item -mcall-netbsd
d77de738
ML
30473On System V.4 and embedded PowerPC systems compile code for the
30474NetBSD operating system.
30475
d7971cf7 30476@opindex mcall-openbsd
ddf6fe37 30477@item -mcall-openbsd
d77de738
ML
30478On System V.4 and embedded PowerPC systems compile code for the
30479OpenBSD operating system.
30480
d77de738 30481@opindex mtraceback
ddf6fe37 30482@item -mtraceback=@var{traceback_type}
d77de738
ML
30483Select the type of traceback table. Valid values for @var{traceback_type}
30484are @samp{full}, @samp{part}, and @samp{no}.
30485
d77de738 30486@opindex maix-struct-return
ddf6fe37 30487@item -maix-struct-return
d77de738
ML
30488Return all structures in memory (as specified by the AIX ABI)@.
30489
d77de738 30490@opindex msvr4-struct-return
ddf6fe37 30491@item -msvr4-struct-return
d77de738
ML
30492Return structures smaller than 8 bytes in registers (as specified by the
30493SVR4 ABI)@.
30494
d77de738 30495@opindex mabi
ddf6fe37 30496@item -mabi=@var{abi-type}
d77de738
ML
30497Extend the current ABI with a particular extension, or remove such extension.
30498Valid values are: @samp{altivec}, @samp{no-altivec},
30499@samp{ibmlongdouble}, @samp{ieeelongdouble},
30500@samp{elfv1}, @samp{elfv2},
30501and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
30502
d77de738 30503@opindex mabi=ibmlongdouble
ddf6fe37 30504@item -mabi=ibmlongdouble
d77de738
ML
30505Change the current ABI to use IBM extended-precision long double.
30506This is not likely to work if your system defaults to using IEEE
30507extended-precision long double. If you change the long double type
30508from IEEE extended-precision, the compiler will issue a warning unless
30509you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30510to be enabled.
30511
d77de738 30512@opindex mabi=ieeelongdouble
ddf6fe37 30513@item -mabi=ieeelongdouble
d77de738
ML
30514Change the current ABI to use IEEE extended-precision long double.
30515This is not likely to work if your system defaults to using IBM
30516extended-precision long double. If you change the long double type
30517from IBM extended-precision, the compiler will issue a warning unless
30518you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30519to be enabled.
30520
d77de738 30521@opindex mabi=elfv1
ddf6fe37 30522@item -mabi=elfv1
d77de738
ML
30523Change the current ABI to use the ELFv1 ABI.
30524This is the default ABI for big-endian PowerPC 64-bit Linux.
30525Overriding the default ABI requires special system support and is
30526likely to fail in spectacular ways.
30527
d77de738 30528@opindex mabi=elfv2
ddf6fe37 30529@item -mabi=elfv2
d77de738
ML
30530Change the current ABI to use the ELFv2 ABI.
30531This is the default ABI for little-endian PowerPC 64-bit Linux.
30532Overriding the default ABI requires special system support and is
30533likely to fail in spectacular ways.
30534
d77de738
ML
30535@opindex mgnu-attribute
30536@opindex mno-gnu-attribute
ddf6fe37
AA
30537@item -mgnu-attribute
30538@itemx -mno-gnu-attribute
d77de738
ML
30539Emit .gnu_attribute assembly directives to set tag/value pairs in a
30540.gnu.attributes section that specify ABI variations in function
30541parameters or return values.
30542
d77de738
ML
30543@opindex mprototype
30544@opindex mno-prototype
ddf6fe37
AA
30545@item -mprototype
30546@itemx -mno-prototype
d77de738
ML
30547On System V.4 and embedded PowerPC systems assume that all calls to
30548variable argument functions are properly prototyped. Otherwise, the
30549compiler must insert an instruction before every non-prototyped call to
30550set or clear bit 6 of the condition code register (@code{CR}) to
30551indicate whether floating-point values are passed in the floating-point
30552registers in case the function takes variable arguments. With
30553@option{-mprototype}, only calls to prototyped variable argument functions
30554set or clear the bit.
30555
d77de738 30556@opindex msim
ddf6fe37 30557@item -msim
d77de738
ML
30558On embedded PowerPC systems, assume that the startup module is called
30559@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
30560@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
30561configurations.
30562
d77de738 30563@opindex mmvme
ddf6fe37 30564@item -mmvme
d77de738
ML
30565On embedded PowerPC systems, assume that the startup module is called
30566@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
30567@file{libc.a}.
30568
d77de738 30569@opindex mads
ddf6fe37 30570@item -mads
d77de738
ML
30571On embedded PowerPC systems, assume that the startup module is called
30572@file{crt0.o} and the standard C libraries are @file{libads.a} and
30573@file{libc.a}.
30574
d77de738 30575@opindex myellowknife
ddf6fe37 30576@item -myellowknife
d77de738
ML
30577On embedded PowerPC systems, assume that the startup module is called
30578@file{crt0.o} and the standard C libraries are @file{libyk.a} and
30579@file{libc.a}.
30580
d77de738 30581@opindex mvxworks
ddf6fe37 30582@item -mvxworks
d77de738
ML
30583On System V.4 and embedded PowerPC systems, specify that you are
30584compiling for a VxWorks system.
30585
d77de738 30586@opindex memb
ddf6fe37 30587@item -memb
d77de738
ML
30588On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
30589header to indicate that @samp{eabi} extended relocations are used.
30590
d77de738
ML
30591@opindex meabi
30592@opindex mno-eabi
ddf6fe37
AA
30593@item -meabi
30594@itemx -mno-eabi
d77de738
ML
30595On System V.4 and embedded PowerPC systems do (do not) adhere to the
30596Embedded Applications Binary Interface (EABI), which is a set of
30597modifications to the System V.4 specifications. Selecting @option{-meabi}
30598means that the stack is aligned to an 8-byte boundary, a function
30599@code{__eabi} is called from @code{main} to set up the EABI
30600environment, and the @option{-msdata} option can use both @code{r2} and
30601@code{r13} to point to two separate small data areas. Selecting
30602@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
30603no EABI initialization function is called from @code{main}, and the
30604@option{-msdata} option only uses @code{r13} to point to a single
30605small data area. The @option{-meabi} option is on by default if you
30606configured GCC using one of the @samp{powerpc*-*-eabi*} options.
30607
d77de738 30608@opindex msdata=eabi
ddf6fe37 30609@item -msdata=eabi
d77de738
ML
30610On System V.4 and embedded PowerPC systems, put small initialized
30611@code{const} global and static data in the @code{.sdata2} section, which
30612is pointed to by register @code{r2}. Put small initialized
30613non-@code{const} global and static data in the @code{.sdata} section,
30614which is pointed to by register @code{r13}. Put small uninitialized
30615global and static data in the @code{.sbss} section, which is adjacent to
30616the @code{.sdata} section. The @option{-msdata=eabi} option is
30617incompatible with the @option{-mrelocatable} option. The
30618@option{-msdata=eabi} option also sets the @option{-memb} option.
30619
d77de738 30620@opindex msdata=sysv
ddf6fe37 30621@item -msdata=sysv
d77de738
ML
30622On System V.4 and embedded PowerPC systems, put small global and static
30623data in the @code{.sdata} section, which is pointed to by register
30624@code{r13}. Put small uninitialized global and static data in the
30625@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30626The @option{-msdata=sysv} option is incompatible with the
30627@option{-mrelocatable} option.
30628
d77de738
ML
30629@opindex msdata=default
30630@opindex msdata
ddf6fe37
AA
30631@item -msdata=default
30632@itemx -msdata
d77de738
ML
30633On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30634compile code the same as @option{-msdata=eabi}, otherwise compile code the
30635same as @option{-msdata=sysv}.
30636
d77de738 30637@opindex msdata=data
ddf6fe37 30638@item -msdata=data
d77de738
ML
30639On System V.4 and embedded PowerPC systems, put small global
30640data in the @code{.sdata} section. Put small uninitialized global
30641data in the @code{.sbss} section. Do not use register @code{r13}
30642to address small data however. This is the default behavior unless
30643other @option{-msdata} options are used.
30644
d77de738
ML
30645@opindex msdata=none
30646@opindex mno-sdata
ddf6fe37
AA
30647@item -msdata=none
30648@itemx -mno-sdata
d77de738
ML
30649On embedded PowerPC systems, put all initialized global and static data
30650in the @code{.data} section, and all uninitialized data in the
30651@code{.bss} section.
30652
d77de738
ML
30653@opindex mreadonly-in-sdata
30654@opindex mno-readonly-in-sdata
ddf6fe37 30655@item -mreadonly-in-sdata
d77de738
ML
30656Put read-only objects in the @code{.sdata} section as well. This is the
30657default.
30658
d77de738 30659@opindex mblock-move-inline-limit
ddf6fe37 30660@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30661Inline all block moves (such as calls to @code{memcpy} or structure
30662copies) less than or equal to @var{num} bytes. The minimum value for
30663@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30664targets. The default value is target-specific.
30665
d77de738 30666@opindex mblock-compare-inline-limit
ddf6fe37 30667@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30668Generate non-looping inline code for all block compares (such as calls
30669to @code{memcmp} or structure compares) less than or equal to @var{num}
30670bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30671block compare is disabled. The default value is target-specific.
30672
d77de738 30673@opindex mblock-compare-inline-loop-limit
ddf6fe37 30674@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30675Generate an inline expansion using loop code for all block compares that
30676are less than or equal to @var{num} bytes, but greater than the limit
30677for non-loop inline block compare expansion. If the block length is not
30678constant, at most @var{num} bytes will be compared before @code{memcmp}
30679is called to compare the remainder of the block. The default value is
30680target-specific.
30681
d77de738 30682@opindex mstring-compare-inline-limit
ddf6fe37 30683@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30684Compare at most @var{num} string bytes with inline code.
30685If the difference or end of string is not found at the
30686end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30687take care of the rest of the comparison. The default is 64 bytes.
30688
d77de738
ML
30689@opindex G
30690@cindex smaller data references (PowerPC)
30691@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30692@item -G @var{num}
d77de738
ML
30693On embedded PowerPC systems, put global and static items less than or
30694equal to @var{num} bytes into the small data or BSS sections instead of
30695the normal data or BSS section. By default, @var{num} is 8. The
30696@option{-G @var{num}} switch is also passed to the linker.
30697All modules should be compiled with the same @option{-G @var{num}} value.
30698
d77de738
ML
30699@opindex mregnames
30700@opindex mno-regnames
ddf6fe37
AA
30701@item -mregnames
30702@itemx -mno-regnames
d77de738
ML
30703On System V.4 and embedded PowerPC systems do (do not) emit register
30704names in the assembly language output using symbolic forms.
30705
d77de738
ML
30706@opindex mlongcall
30707@opindex mno-longcall
ddf6fe37
AA
30708@item -mlongcall
30709@itemx -mno-longcall
d77de738
ML
30710By default assume that all calls are far away so that a longer and more
30711expensive calling sequence is required. This is required for calls
30712farther than 32 megabytes (33,554,432 bytes) from the current location.
30713A short call is generated if the compiler knows
30714the call cannot be that far away. This setting can be overridden by
30715the @code{shortcall} function attribute, or by @code{#pragma
30716longcall(0)}.
30717
30718Some linkers are capable of detecting out-of-range calls and generating
30719glue code on the fly. On these systems, long calls are unnecessary and
30720generate slower code. As of this writing, the AIX linker can do this,
30721as can the GNU linker for PowerPC/64. It is planned to add this feature
30722to the GNU linker for 32-bit PowerPC systems as well.
30723
30724On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30725GCC can generate long calls using an inline PLT call sequence (see
30726@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30727ELFv1 (big-endian) do not support inline PLT calls.
30728
30729On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30730callee, L42}, plus a @dfn{branch island} (glue code). The two target
30731addresses represent the callee and the branch island. The
30732Darwin/PPC linker prefers the first address and generates a @code{bl
30733callee} if the PPC @code{bl} instruction reaches the callee directly;
30734otherwise, the linker generates @code{bl L42} to call the branch
30735island. The branch island is appended to the body of the
30736calling function; it computes the full 32-bit address of the callee
30737and jumps to it.
30738
30739On Mach-O (Darwin) systems, this option directs the compiler emit to
30740the glue for every direct call, and the Darwin linker decides whether
30741to use or discard it.
30742
30743In the future, GCC may ignore all longcall specifications
30744when the linker is known to generate glue.
30745
d77de738
ML
30746@opindex mpltseq
30747@opindex mno-pltseq
ddf6fe37
AA
30748@item -mpltseq
30749@itemx -mno-pltseq
d77de738
ML
30750Implement (do not implement) -fno-plt and long calls using an inline
30751PLT call sequence that supports lazy linking and long calls to
30752functions in dlopen'd shared libraries. Inline PLT calls are only
30753supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30754linkers, and are enabled by default if the support is detected when
30755configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30756configured with @option{--enable-secureplt}. @option{-mpltseq} code
30757and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30758linked together.
30759
d77de738
ML
30760@opindex mtls-markers
30761@opindex mno-tls-markers
ddf6fe37
AA
30762@item -mtls-markers
30763@itemx -mno-tls-markers
d77de738
ML
30764Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30765specifying the function argument. The relocation allows the linker to
30766reliably associate function call with argument setup instructions for
30767TLS optimization, which in turn allows GCC to better schedule the
30768sequence.
30769
ddf6fe37 30770@opindex mrecip
d77de738
ML
30771@item -mrecip
30772@itemx -mno-recip
d77de738
ML
30773This option enables use of the reciprocal estimate and
30774reciprocal square root estimate instructions with additional
30775Newton-Raphson steps to increase precision instead of doing a divide or
30776square root and divide for floating-point arguments. You should use
30777the @option{-ffast-math} option when using @option{-mrecip} (or at
30778least @option{-funsafe-math-optimizations},
30779@option{-ffinite-math-only}, @option{-freciprocal-math} and
30780@option{-fno-trapping-math}). Note that while the throughput of the
30781sequence is generally higher than the throughput of the non-reciprocal
30782instruction, the precision of the sequence can be decreased by up to 2
30783ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30784roots.
30785
d77de738 30786@opindex mrecip=opt
ddf6fe37 30787@item -mrecip=@var{opt}
d77de738
ML
30788This option controls which reciprocal estimate instructions
30789may be used. @var{opt} is a comma-separated list of options, which may
30790be preceded by a @code{!} to invert the option:
30791
30792@table @samp
30793
30794@item all
30795Enable all estimate instructions.
30796
30797@item default
30798Enable the default instructions, equivalent to @option{-mrecip}.
30799
30800@item none
30801Disable all estimate instructions, equivalent to @option{-mno-recip}.
30802
30803@item div
30804Enable the reciprocal approximation instructions for both
30805single and double precision.
30806
30807@item divf
30808Enable the single-precision reciprocal approximation instructions.
30809
30810@item divd
30811Enable the double-precision reciprocal approximation instructions.
30812
30813@item rsqrt
30814Enable the reciprocal square root approximation instructions for both
30815single and double precision.
30816
30817@item rsqrtf
30818Enable the single-precision reciprocal square root approximation instructions.
30819
30820@item rsqrtd
30821Enable the double-precision reciprocal square root approximation instructions.
30822
30823@end table
30824
30825So, for example, @option{-mrecip=all,!rsqrtd} enables
30826all of the reciprocal estimate instructions, except for the
30827@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30828which handle the double-precision reciprocal square root calculations.
30829
ddf6fe37 30830@opindex mrecip-precision
d77de738
ML
30831@item -mrecip-precision
30832@itemx -mno-recip-precision
d77de738
ML
30833Assume (do not assume) that the reciprocal estimate instructions
30834provide higher-precision estimates than is mandated by the PowerPC
30835ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30836@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30837The double-precision square root estimate instructions are not generated by
30838default on low-precision machines, since they do not provide an
30839estimate that converges after three steps.
30840
d77de738 30841@opindex mveclibabi
ddf6fe37 30842@item -mveclibabi=@var{type}
d77de738
ML
30843Specifies the ABI type to use for vectorizing intrinsics using an
30844external library. The only type supported at present is @samp{mass},
30845which specifies to use IBM's Mathematical Acceleration Subsystem
30846(MASS) libraries for vectorizing intrinsics using external libraries.
30847GCC currently emits calls to @code{acosd2}, @code{acosf4},
30848@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30849@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30850@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30851@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30852@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30853@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30854@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30855@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30856@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30857@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30858@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30859@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30860@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30861for power7. Both @option{-ftree-vectorize} and
30862@option{-funsafe-math-optimizations} must also be enabled. The MASS
30863libraries must be specified at link time.
30864
ddf6fe37 30865@opindex mfriz
d77de738
ML
30866@item -mfriz
30867@itemx -mno-friz
d77de738
ML
30868Generate (do not generate) the @code{friz} instruction when the
30869@option{-funsafe-math-optimizations} option is used to optimize
30870rounding of floating-point values to 64-bit integer and back to floating
30871point. The @code{friz} instruction does not return the same value if
30872the floating-point number is too large to fit in an integer.
30873
ddf6fe37 30874@opindex mpointers-to-nested-functions
d77de738
ML
30875@item -mpointers-to-nested-functions
30876@itemx -mno-pointers-to-nested-functions
d77de738
ML
30877Generate (do not generate) code to load up the static chain register
30878(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30879systems where a function pointer points to a 3-word descriptor giving
30880the function address, TOC value to be loaded in register @code{r2}, and
30881static chain value to be loaded in register @code{r11}. The
30882@option{-mpointers-to-nested-functions} is on by default. You cannot
30883call through pointers to nested functions or pointers
30884to functions compiled in other languages that use the static chain if
30885you use @option{-mno-pointers-to-nested-functions}.
30886
ddf6fe37 30887@opindex msave-toc-indirect
d77de738
ML
30888@item -msave-toc-indirect
30889@itemx -mno-save-toc-indirect
d77de738
ML
30890Generate (do not generate) code to save the TOC value in the reserved
30891stack location in the function prologue if the function calls through
30892a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30893saved in the prologue, it is saved just before the call through the
30894pointer. The @option{-mno-save-toc-indirect} option is the default.
30895
ddf6fe37 30896@opindex mcompat-align-parm
d77de738
ML
30897@item -mcompat-align-parm
30898@itemx -mno-compat-align-parm
d77de738
ML
30899Generate (do not generate) code to pass structure parameters with a
30900maximum alignment of 64 bits, for compatibility with older versions
30901of GCC.
30902
30903Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30904structure parameter on a 128-bit boundary when that structure contained
30905a member requiring 128-bit alignment. This is corrected in more
30906recent versions of GCC. This option may be used to generate code
30907that is compatible with functions compiled with older versions of
30908GCC.
30909
30910The @option{-mno-compat-align-parm} option is the default.
30911
d77de738
ML
30912@opindex mstack-protector-guard
30913@opindex mstack-protector-guard-reg
30914@opindex mstack-protector-guard-offset
30915@opindex mstack-protector-guard-symbol
ddf6fe37
AA
30916@item -mstack-protector-guard=@var{guard}
30917@itemx -mstack-protector-guard-reg=@var{reg}
30918@itemx -mstack-protector-guard-offset=@var{offset}
30919@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
30920Generate stack protection code using canary at @var{guard}. Supported
30921locations are @samp{global} for global canary or @samp{tls} for per-thread
30922canary in the TLS block (the default with GNU libc version 2.4 or later).
30923
30924With the latter choice the options
30925@option{-mstack-protector-guard-reg=@var{reg}} and
30926@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30927which register to use as base register for reading the canary, and from what
30928offset from that base register. The default for those is as specified in the
30929relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30930the offset with a symbol reference to a canary in the TLS block.
30931
d77de738
ML
30932@opindex mpcrel
30933@opindex mno-pcrel
ddf6fe37
AA
30934@item -mpcrel
30935@itemx -mno-pcrel
d77de738
ML
30936Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30937option requires that the medium code model (@option{-mcmodel=medium})
30938and prefixed addressing (@option{-mprefixed}) options are enabled.
30939
d77de738
ML
30940@opindex mprefixed
30941@opindex mno-prefixed
ddf6fe37
AA
30942@item -mprefixed
30943@itemx -mno-prefixed
d77de738
ML
30944Generate (do not generate) addressing modes using prefixed load and
30945store instructions. The @option{-mprefixed} option requires that
30946the option @option{-mcpu=power10} (or later) is enabled.
30947
d77de738
ML
30948@opindex mmma
30949@opindex mno-mma
ddf6fe37
AA
30950@item -mmma
30951@itemx -mno-mma
d77de738
ML
30952Generate (do not generate) the MMA instructions. The @option{-mma}
30953option requires that the option @option{-mcpu=power10} (or later)
30954is enabled.
30955
d77de738
ML
30956@opindex mrop-protect
30957@opindex mno-rop-protect
ddf6fe37
AA
30958@item -mrop-protect
30959@itemx -mno-rop-protect
d77de738
ML
30960Generate (do not generate) ROP protection instructions when the target
30961processor supports them. Currently this option disables the shrink-wrap
30962optimization (@option{-fshrink-wrap}).
30963
d77de738
ML
30964@opindex mprivileged
30965@opindex mno-privileged
ddf6fe37
AA
30966@item -mprivileged
30967@itemx -mno-privileged
d77de738
ML
30968Generate (do not generate) code that will run in privileged state.
30969
d77de738
ML
30970@opindex block-ops-unaligned-vsx
30971@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
30972@item -mblock-ops-unaligned-vsx
30973@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
30974Generate (do not generate) unaligned vsx loads and stores for
30975inline expansion of @code{memcpy} and @code{memmove}.
30976
30977@item --param rs6000-vect-unroll-limit=
30978The vectorizer will check with target information to determine whether it
30979would be beneficial to unroll the main vectorized loop and by how much. This
30980parameter sets the upper bound of how much the vectorizer will unroll the main
30981loop. The default value is four.
30982
30983@end table
30984
30985@node RX Options
30986@subsection RX Options
30987@cindex RX Options
30988
30989These command-line options are defined for RX targets:
30990
30991@table @gcctabopt
d77de738
ML
30992@opindex m64bit-doubles
30993@opindex m32bit-doubles
ddf6fe37
AA
30994@item -m64bit-doubles
30995@itemx -m32bit-doubles
d77de738
ML
30996Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30997or 32 bits (@option{-m32bit-doubles}) in size. The default is
30998@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30999works on 32-bit values, which is why the default is
31000@option{-m32bit-doubles}.
31001
d77de738
ML
31002@opindex fpu
31003@opindex nofpu
ddf6fe37
AA
31004@item -fpu
31005@itemx -nofpu
d77de738
ML
31006Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
31007floating-point hardware. The default is enabled for the RX600
31008series and disabled for the RX200 series.
31009
31010Floating-point instructions are only generated for 32-bit floating-point
31011values, however, so the FPU hardware is not used for doubles if the
31012@option{-m64bit-doubles} option is used.
31013
31014@emph{Note} If the @option{-fpu} option is enabled then
31015@option{-funsafe-math-optimizations} is also enabled automatically.
31016This is because the RX FPU instructions are themselves unsafe.
31017
d77de738 31018@opindex mcpu
ddf6fe37 31019@item -mcpu=@var{name}
d77de738
ML
31020Selects the type of RX CPU to be targeted. Currently three types are
31021supported, the generic @samp{RX600} and @samp{RX200} series hardware and
31022the specific @samp{RX610} CPU. The default is @samp{RX600}.
31023
31024The only difference between @samp{RX600} and @samp{RX610} is that the
31025@samp{RX610} does not support the @code{MVTIPL} instruction.
31026
31027The @samp{RX200} series does not have a hardware floating-point unit
31028and so @option{-nofpu} is enabled by default when this type is
31029selected.
31030
d77de738
ML
31031@opindex mbig-endian-data
31032@opindex mlittle-endian-data
ddf6fe37
AA
31033@item -mbig-endian-data
31034@itemx -mlittle-endian-data
d77de738
ML
31035Store data (but not code) in the big-endian format. The default is
31036@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
31037format.
31038
d77de738 31039@opindex msmall-data-limit
ddf6fe37 31040@item -msmall-data-limit=@var{N}
d77de738
ML
31041Specifies the maximum size in bytes of global and static variables
31042which can be placed into the small data area. Using the small data
31043area can lead to smaller and faster code, but the size of area is
31044limited and it is up to the programmer to ensure that the area does
31045not overflow. Also when the small data area is used one of the RX's
31046registers (usually @code{r13}) is reserved for use pointing to this
31047area, so it is no longer available for use by the compiler. This
31048could result in slower and/or larger code if variables are pushed onto
31049the stack instead of being held in this register.
31050
31051Note, common variables (variables that have not been initialized) and
31052constants are not placed into the small data area as they are assigned
31053to other sections in the output executable.
31054
31055The default value is zero, which disables this feature. Note, this
31056feature is not enabled by default with higher optimization levels
31057(@option{-O2} etc) because of the potentially detrimental effects of
31058reserving a register. It is up to the programmer to experiment and
31059discover whether this feature is of benefit to their program. See the
31060description of the @option{-mpid} option for a description of how the
31061actual register to hold the small data area pointer is chosen.
31062
d77de738
ML
31063@opindex msim
31064@opindex mno-sim
ddf6fe37
AA
31065@item -msim
31066@itemx -mno-sim
d77de738
ML
31067Use the simulator runtime. The default is to use the libgloss
31068board-specific runtime.
31069
d77de738
ML
31070@opindex mas100-syntax
31071@opindex mno-as100-syntax
ddf6fe37
AA
31072@item -mas100-syntax
31073@itemx -mno-as100-syntax
d77de738
ML
31074When generating assembler output use a syntax that is compatible with
31075Renesas's AS100 assembler. This syntax can also be handled by the GAS
31076assembler, but it has some restrictions so it is not generated by default.
31077
d77de738 31078@opindex mmax-constant-size
ddf6fe37 31079@item -mmax-constant-size=@var{N}
d77de738
ML
31080Specifies the maximum size, in bytes, of a constant that can be used as
31081an operand in a RX instruction. Although the RX instruction set does
31082allow constants of up to 4 bytes in length to be used in instructions,
31083a longer value equates to a longer instruction. Thus in some
31084circumstances it can be beneficial to restrict the size of constants
31085that are used in instructions. Constants that are too big are instead
31086placed into a constant pool and referenced via register indirection.
31087
31088The value @var{N} can be between 0 and 4. A value of 0 (the default)
31089or 4 means that constants of any size are allowed.
31090
d77de738 31091@opindex mrelax
ddf6fe37 31092@item -mrelax
d77de738
ML
31093Enable linker relaxation. Linker relaxation is a process whereby the
31094linker attempts to reduce the size of a program by finding shorter
31095versions of various instructions. Disabled by default.
31096
d77de738 31097@opindex mint-register
ddf6fe37 31098@item -mint-register=@var{N}
d77de738
ML
31099Specify the number of registers to reserve for fast interrupt handler
31100functions. The value @var{N} can be between 0 and 4. A value of 1
31101means that register @code{r13} is reserved for the exclusive use
31102of fast interrupt handlers. A value of 2 reserves @code{r13} and
31103@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
31104@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
31105A value of 0, the default, does not reserve any registers.
31106
d77de738 31107@opindex msave-acc-in-interrupts
ddf6fe37 31108@item -msave-acc-in-interrupts
d77de738
ML
31109Specifies that interrupt handler functions should preserve the
31110accumulator register. This is only necessary if normal code might use
31111the accumulator register, for example because it performs 64-bit
31112multiplications. The default is to ignore the accumulator as this
31113makes the interrupt handlers faster.
31114
d77de738
ML
31115@opindex mpid
31116@opindex mno-pid
ddf6fe37
AA
31117@item -mpid
31118@itemx -mno-pid
d77de738
ML
31119Enables the generation of position independent data. When enabled any
31120access to constant data is done via an offset from a base address
31121held in a register. This allows the location of constant data to be
31122determined at run time without requiring the executable to be
31123relocated, which is a benefit to embedded applications with tight
31124memory constraints. Data that can be modified is not affected by this
31125option.
31126
31127Note, using this feature reserves a register, usually @code{r13}, for
31128the constant data base address. This can result in slower and/or
31129larger code, especially in complicated functions.
31130
31131The actual register chosen to hold the constant data base address
31132depends upon whether the @option{-msmall-data-limit} and/or the
31133@option{-mint-register} command-line options are enabled. Starting
31134with register @code{r13} and proceeding downwards, registers are
31135allocated first to satisfy the requirements of @option{-mint-register},
31136then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
31137is possible for the small data area register to be @code{r8} if both
31138@option{-mint-register=4} and @option{-mpid} are specified on the
31139command line.
31140
31141By default this feature is not enabled. The default can be restored
31142via the @option{-mno-pid} command-line option.
31143
d77de738
ML
31144@opindex mno-warn-multiple-fast-interrupts
31145@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
31146@item -mno-warn-multiple-fast-interrupts
31147@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
31148Prevents GCC from issuing a warning message if it finds more than one
31149fast interrupt handler when it is compiling a file. The default is to
31150issue a warning for each extra fast interrupt handler found, as the RX
31151only supports one such interrupt.
31152
d77de738
ML
31153@opindex mallow-string-insns
31154@opindex mno-allow-string-insns
ddf6fe37
AA
31155@item -mallow-string-insns
31156@itemx -mno-allow-string-insns
d77de738
ML
31157Enables or disables the use of the string manipulation instructions
31158@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
31159@code{SWHILE} and also the @code{RMPA} instruction. These
31160instructions may prefetch data, which is not safe to do if accessing
31161an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
31162for more information).
31163
31164The default is to allow these instructions, but it is not possible for
31165GCC to reliably detect all circumstances where a string instruction
31166might be used to access an I/O register, so their use cannot be
31167disabled automatically. Instead it is reliant upon the programmer to
31168use the @option{-mno-allow-string-insns} option if their program
31169accesses I/O space.
31170
31171When the instructions are enabled GCC defines the C preprocessor
31172symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
31173symbol @code{__RX_DISALLOW_STRING_INSNS__}.
31174
d77de738
ML
31175@opindex mjsr
31176@opindex mno-jsr
ddf6fe37
AA
31177@item -mjsr
31178@itemx -mno-jsr
d77de738
ML
31179Use only (or not only) @code{JSR} instructions to access functions.
31180This option can be used when code size exceeds the range of @code{BSR}
31181instructions. Note that @option{-mno-jsr} does not mean to not use
31182@code{JSR} but instead means that any type of branch may be used.
31183@end table
31184
31185@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
31186has special significance to the RX port when used with the
31187@code{interrupt} function attribute. This attribute indicates a
31188function intended to process fast interrupts. GCC ensures
31189that it only uses the registers @code{r10}, @code{r11}, @code{r12}
31190and/or @code{r13} and only provided that the normal use of the
31191corresponding registers have been restricted via the
31192@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
31193options.
31194
31195@node S/390 and zSeries Options
31196@subsection S/390 and zSeries Options
31197@cindex S/390 and zSeries Options
31198
31199These are the @samp{-m} options defined for the S/390 and zSeries architecture.
31200
31201@table @gcctabopt
d77de738
ML
31202@opindex mhard-float
31203@opindex msoft-float
ddf6fe37
AA
31204@item -mhard-float
31205@itemx -msoft-float
d77de738
ML
31206Use (do not use) the hardware floating-point instructions and registers
31207for floating-point operations. When @option{-msoft-float} is specified,
31208functions in @file{libgcc.a} are used to perform floating-point
31209operations. When @option{-mhard-float} is specified, the compiler
31210generates IEEE floating-point instructions. This is the default.
31211
d77de738
ML
31212@opindex mhard-dfp
31213@opindex mno-hard-dfp
ddf6fe37
AA
31214@item -mhard-dfp
31215@itemx -mno-hard-dfp
d77de738
ML
31216Use (do not use) the hardware decimal-floating-point instructions for
31217decimal-floating-point operations. When @option{-mno-hard-dfp} is
31218specified, functions in @file{libgcc.a} are used to perform
31219decimal-floating-point operations. When @option{-mhard-dfp} is
31220specified, the compiler generates decimal-floating-point hardware
31221instructions. This is the default for @option{-march=z9-ec} or higher.
31222
d77de738
ML
31223@opindex mlong-double-64
31224@opindex mlong-double-128
ddf6fe37
AA
31225@item -mlong-double-64
31226@itemx -mlong-double-128
d77de738
ML
31227These switches control the size of @code{long double} type. A size
31228of 64 bits makes the @code{long double} type equivalent to the @code{double}
31229type. This is the default.
31230
d77de738
ML
31231@opindex mbackchain
31232@opindex mno-backchain
ddf6fe37
AA
31233@item -mbackchain
31234@itemx -mno-backchain
d77de738
ML
31235Store (do not store) the address of the caller's frame as backchain pointer
31236into the callee's stack frame.
31237A backchain may be needed to allow debugging using tools that do not understand
31238DWARF call frame information.
31239When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
31240at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
31241the backchain is placed into the topmost word of the 96/160 byte register
31242save area.
31243
31244In general, code compiled with @option{-mbackchain} is call-compatible with
31245code compiled with @option{-mno-backchain}; however, use of the backchain
31246for debugging purposes usually requires that the whole binary is built with
31247@option{-mbackchain}. Note that the combination of @option{-mbackchain},
31248@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31249to build a linux kernel use @option{-msoft-float}.
31250
31251The default is to not maintain the backchain.
31252
d77de738
ML
31253@opindex mpacked-stack
31254@opindex mno-packed-stack
ddf6fe37
AA
31255@item -mpacked-stack
31256@itemx -mno-packed-stack
d77de738
ML
31257Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
31258specified, the compiler uses the all fields of the 96/160 byte register save
31259area only for their default purpose; unused fields still take up stack space.
31260When @option{-mpacked-stack} is specified, register save slots are densely
31261packed at the top of the register save area; unused space is reused for other
31262purposes, allowing for more efficient use of the available stack space.
31263However, when @option{-mbackchain} is also in effect, the topmost word of
31264the save area is always used to store the backchain, and the return address
31265register is always saved two words below the backchain.
31266
31267As long as the stack frame backchain is not used, code generated with
31268@option{-mpacked-stack} is call-compatible with code generated with
31269@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
31270S/390 or zSeries generated code that uses the stack frame backchain at run
31271time, not just for debugging purposes. Such code is not call-compatible
31272with code compiled with @option{-mpacked-stack}. Also, note that the
31273combination of @option{-mbackchain},
31274@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
31275to build a linux kernel use @option{-msoft-float}.
31276
31277The default is to not use the packed stack layout.
31278
d77de738
ML
31279@opindex msmall-exec
31280@opindex mno-small-exec
ddf6fe37
AA
31281@item -msmall-exec
31282@itemx -mno-small-exec
d77de738
ML
31283Generate (or do not generate) code using the @code{bras} instruction
31284to do subroutine calls.
31285This only works reliably if the total executable size does not
31286exceed 64k. The default is to use the @code{basr} instruction instead,
31287which does not have this limitation.
31288
d77de738
ML
31289@opindex m64
31290@opindex m31
ddf6fe37
AA
31291@item -m64
31292@itemx -m31
d77de738
ML
31293When @option{-m31} is specified, generate code compliant to the
31294GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
31295code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
31296particular to generate 64-bit instructions. For the @samp{s390}
31297targets, the default is @option{-m31}, while the @samp{s390x}
31298targets default to @option{-m64}.
31299
d77de738
ML
31300@opindex mzarch
31301@opindex mesa
ddf6fe37
AA
31302@item -mzarch
31303@itemx -mesa
d77de738
ML
31304When @option{-mzarch} is specified, generate code using the
31305instructions available on z/Architecture.
31306When @option{-mesa} is specified, generate code using the
31307instructions available on ESA/390. Note that @option{-mesa} is
31308not possible with @option{-m64}.
31309When generating code compliant to the GNU/Linux for S/390 ABI,
31310the default is @option{-mesa}. When generating code compliant
31311to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
31312
d77de738
ML
31313@opindex mhtm
31314@opindex mno-htm
ddf6fe37
AA
31315@item -mhtm
31316@itemx -mno-htm
d77de738
ML
31317The @option{-mhtm} option enables a set of builtins making use of
31318instructions available with the transactional execution facility
31319introduced with the IBM zEnterprise EC12 machine generation
31320@ref{S/390 System z Built-in Functions}.
31321@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
31322
d77de738
ML
31323@opindex mvx
31324@opindex mno-vx
ddf6fe37
AA
31325@item -mvx
31326@itemx -mno-vx
d77de738
ML
31327When @option{-mvx} is specified, generate code using the instructions
31328available with the vector extension facility introduced with the IBM
31329z13 machine generation.
31330This option changes the ABI for some vector type values with regard to
31331alignment and calling conventions. In case vector type values are
31332being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
31333command will be added to mark the resulting binary with the ABI used.
31334@option{-mvx} is enabled by default when using @option{-march=z13}.
31335
d77de738
ML
31336@opindex mzvector
31337@opindex mno-zvector
ddf6fe37
AA
31338@item -mzvector
31339@itemx -mno-zvector
d77de738
ML
31340The @option{-mzvector} option enables vector language extensions and
31341builtins using instructions available with the vector extension
31342facility introduced with the IBM z13 machine generation.
31343This option adds support for @samp{vector} to be used as a keyword to
31344define vector type variables and arguments. @samp{vector} is only
31345available when GNU extensions are enabled. It will not be expanded
31346when requesting strict standard compliance e.g.@: with @option{-std=c99}.
31347In addition to the GCC low-level builtins @option{-mzvector} enables
31348a set of builtins added for compatibility with AltiVec-style
31349implementations like Power and Cell. In order to make use of these
31350builtins the header file @file{vecintrin.h} needs to be included.
31351@option{-mzvector} is disabled by default.
31352
d77de738
ML
31353@opindex mmvcle
31354@opindex mno-mvcle
ddf6fe37
AA
31355@item -mmvcle
31356@itemx -mno-mvcle
d77de738
ML
31357Generate (or do not generate) code using the @code{mvcle} instruction
31358to perform block moves. When @option{-mno-mvcle} is specified,
31359use a @code{mvc} loop instead. This is the default unless optimizing for
31360size.
31361
d77de738
ML
31362@opindex mdebug
31363@opindex mno-debug
ddf6fe37
AA
31364@item -mdebug
31365@itemx -mno-debug
d77de738
ML
31366Print (or do not print) additional debug information when compiling.
31367The default is to not print debug information.
31368
d77de738 31369@opindex march
ddf6fe37 31370@item -march=@var{cpu-type}
d77de738
ML
31371Generate code that runs on @var{cpu-type}, which is the name of a
31372system representing a certain processor type. Possible values for
31373@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
31374@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
31375@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
31376@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
31377@samp{z16}/@samp{arch14}, and @samp{native}.
31378
31379The default is @option{-march=z900}.
31380
31381Specifying @samp{native} as cpu type can be used to select the best
31382architecture option for the host processor.
31383@option{-march=native} has no effect if GCC does not recognize the
31384processor.
31385
d77de738 31386@opindex mtune
ddf6fe37 31387@item -mtune=@var{cpu-type}
d77de738
ML
31388Tune to @var{cpu-type} everything applicable about the generated code,
31389except for the ABI and the set of available instructions.
31390The list of @var{cpu-type} values is the same as for @option{-march}.
31391The default is the value used for @option{-march}.
31392
d77de738
ML
31393@opindex mtpf-trace
31394@opindex mno-tpf-trace
ddf6fe37
AA
31395@item -mtpf-trace
31396@itemx -mno-tpf-trace
d77de738
ML
31397Generate code that adds (does not add) in TPF OS specific branches to trace
31398routines in the operating system. This option is off by default, even
31399when compiling for the TPF OS@.
31400
d77de738
ML
31401@opindex mtpf-trace-skip
31402@opindex mno-tpf-trace-skip
ddf6fe37
AA
31403@item -mtpf-trace-skip
31404@itemx -mno-tpf-trace-skip
d77de738
ML
31405Generate code that changes (does not change) the default branch
31406targets enabled by @option{-mtpf-trace} to point to specialized trace
31407routines providing the ability of selectively skipping function trace
31408entries for the TPF OS. This option is off by default, even when
31409compiling for the TPF OS and specifying @option{-mtpf-trace}.
31410
d77de738
ML
31411@opindex mfused-madd
31412@opindex mno-fused-madd
ddf6fe37
AA
31413@item -mfused-madd
31414@itemx -mno-fused-madd
d77de738
ML
31415Generate code that uses (does not use) the floating-point multiply and
31416accumulate instructions. These instructions are generated by default if
31417hardware floating point is used.
31418
d77de738 31419@opindex mwarn-framesize
ddf6fe37 31420@item -mwarn-framesize=@var{framesize}
d77de738
ML
31421Emit a warning if the current function exceeds the given frame size. Because
31422this is a compile-time check it doesn't need to be a real problem when the program
31423runs. It is intended to identify functions that most probably cause
31424a stack overflow. It is useful to be used in an environment with limited stack
31425size e.g.@: the linux kernel.
31426
d77de738 31427@opindex mwarn-dynamicstack
ddf6fe37 31428@item -mwarn-dynamicstack
d77de738
ML
31429Emit a warning if the function calls @code{alloca} or uses dynamically-sized
31430arrays. This is generally a bad idea with a limited stack size.
31431
d77de738
ML
31432@opindex mstack-guard
31433@opindex mstack-size
ddf6fe37
AA
31434@item -mstack-guard=@var{stack-guard}
31435@itemx -mstack-size=@var{stack-size}
d77de738
ML
31436If these options are provided the S/390 back end emits additional instructions in
31437the function prologue that trigger a trap if the stack size is @var{stack-guard}
31438bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
31439If the @var{stack-guard} option is omitted the smallest power of 2 larger than
31440the frame size of the compiled function is chosen.
31441These options are intended to be used to help debugging stack overflow problems.
31442The additionally emitted code causes only little overhead and hence can also be
31443used in production-like systems without greater performance degradation. The given
31444values have to be exact powers of 2 and @var{stack-size} has to be greater than
31445@var{stack-guard} without exceeding 64k.
31446In order to be efficient the extra code makes the assumption that the stack starts
31447at an address aligned to the value given by @var{stack-size}.
31448The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
31449
d77de738 31450@opindex mhotpatch
ddf6fe37 31451@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
31452If the hotpatch option is enabled, a ``hot-patching'' function
31453prologue is generated for all functions in the compilation unit.
31454The funtion label is prepended with the given number of two-byte
31455NOP instructions (@var{pre-halfwords}, maximum 1000000). After
31456the label, 2 * @var{post-halfwords} bytes are appended, using the
31457largest NOP like instructions the architecture allows (maximum
314581000000).
31459
31460If both arguments are zero, hotpatching is disabled.
31461
31462This option can be overridden for individual functions with the
31463@code{hotpatch} attribute.
31464@end table
31465
d77de738
ML
31466@node SH Options
31467@subsection SH Options
31468
31469These @samp{-m} options are defined for the SH implementations:
31470
31471@table @gcctabopt
d77de738 31472@opindex m1
ddf6fe37 31473@item -m1
d77de738
ML
31474Generate code for the SH1.
31475
d77de738 31476@opindex m2
ddf6fe37 31477@item -m2
d77de738
ML
31478Generate code for the SH2.
31479
31480@item -m2e
31481Generate code for the SH2e.
31482
d77de738 31483@opindex m2a-nofpu
ddf6fe37 31484@item -m2a-nofpu
d77de738
ML
31485Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
31486that the floating-point unit is not used.
31487
d77de738 31488@opindex m2a-single-only
ddf6fe37 31489@item -m2a-single-only
d77de738
ML
31490Generate code for the SH2a-FPU, in such a way that no double-precision
31491floating-point operations are used.
31492
d77de738 31493@opindex m2a-single
ddf6fe37 31494@item -m2a-single
d77de738
ML
31495Generate code for the SH2a-FPU assuming the floating-point unit is in
31496single-precision mode by default.
31497
d77de738 31498@opindex m2a
ddf6fe37 31499@item -m2a
d77de738
ML
31500Generate code for the SH2a-FPU assuming the floating-point unit is in
31501double-precision mode by default.
31502
d77de738 31503@opindex m3
ddf6fe37 31504@item -m3
d77de738
ML
31505Generate code for the SH3.
31506
d77de738 31507@opindex m3e
ddf6fe37 31508@item -m3e
d77de738
ML
31509Generate code for the SH3e.
31510
d77de738 31511@opindex m4-nofpu
ddf6fe37 31512@item -m4-nofpu
d77de738
ML
31513Generate code for the SH4 without a floating-point unit.
31514
d77de738 31515@opindex m4-single-only
ddf6fe37 31516@item -m4-single-only
d77de738
ML
31517Generate code for the SH4 with a floating-point unit that only
31518supports single-precision arithmetic.
31519
d77de738 31520@opindex m4-single
ddf6fe37 31521@item -m4-single
d77de738
ML
31522Generate code for the SH4 assuming the floating-point unit is in
31523single-precision mode by default.
31524
d77de738 31525@opindex m4
ddf6fe37 31526@item -m4
d77de738
ML
31527Generate code for the SH4.
31528
d77de738 31529@opindex m4-100
ddf6fe37 31530@item -m4-100
d77de738
ML
31531Generate code for SH4-100.
31532
d77de738 31533@opindex m4-100-nofpu
ddf6fe37 31534@item -m4-100-nofpu
d77de738
ML
31535Generate code for SH4-100 in such a way that the
31536floating-point unit is not used.
31537
d77de738 31538@opindex m4-100-single
ddf6fe37 31539@item -m4-100-single
d77de738
ML
31540Generate code for SH4-100 assuming the floating-point unit is in
31541single-precision mode by default.
31542
d77de738 31543@opindex m4-100-single-only
ddf6fe37 31544@item -m4-100-single-only
d77de738
ML
31545Generate code for SH4-100 in such a way that no double-precision
31546floating-point operations are used.
31547
d77de738 31548@opindex m4-200
ddf6fe37 31549@item -m4-200
d77de738
ML
31550Generate code for SH4-200.
31551
d77de738 31552@opindex m4-200-nofpu
ddf6fe37 31553@item -m4-200-nofpu
d77de738
ML
31554Generate code for SH4-200 without in such a way that the
31555floating-point unit is not used.
31556
d77de738 31557@opindex m4-200-single
ddf6fe37 31558@item -m4-200-single
d77de738
ML
31559Generate code for SH4-200 assuming the floating-point unit is in
31560single-precision mode by default.
31561
d77de738 31562@opindex m4-200-single-only
ddf6fe37 31563@item -m4-200-single-only
d77de738
ML
31564Generate code for SH4-200 in such a way that no double-precision
31565floating-point operations are used.
31566
d77de738 31567@opindex m4-300
ddf6fe37 31568@item -m4-300
d77de738
ML
31569Generate code for SH4-300.
31570
d77de738 31571@opindex m4-300-nofpu
ddf6fe37 31572@item -m4-300-nofpu
d77de738
ML
31573Generate code for SH4-300 without in such a way that the
31574floating-point unit is not used.
31575
d77de738 31576@opindex m4-300-single
ddf6fe37 31577@item -m4-300-single
d77de738
ML
31578Generate code for SH4-300 in such a way that no double-precision
31579floating-point operations are used.
31580
d77de738 31581@opindex m4-300-single-only
ddf6fe37 31582@item -m4-300-single-only
d77de738
ML
31583Generate code for SH4-300 in such a way that no double-precision
31584floating-point operations are used.
31585
d77de738 31586@opindex m4-340
ddf6fe37 31587@item -m4-340
d77de738
ML
31588Generate code for SH4-340 (no MMU, no FPU).
31589
d77de738 31590@opindex m4-500
ddf6fe37 31591@item -m4-500
d77de738
ML
31592Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
31593assembler.
31594
d77de738 31595@opindex m4a-nofpu
ddf6fe37 31596@item -m4a-nofpu
d77de738
ML
31597Generate code for the SH4al-dsp, or for a SH4a in such a way that the
31598floating-point unit is not used.
31599
d77de738 31600@opindex m4a-single-only
ddf6fe37 31601@item -m4a-single-only
d77de738
ML
31602Generate code for the SH4a, in such a way that no double-precision
31603floating-point operations are used.
31604
d77de738 31605@opindex m4a-single
ddf6fe37 31606@item -m4a-single
d77de738
ML
31607Generate code for the SH4a assuming the floating-point unit is in
31608single-precision mode by default.
31609
d77de738 31610@opindex m4a
ddf6fe37 31611@item -m4a
d77de738
ML
31612Generate code for the SH4a.
31613
d77de738 31614@opindex m4al
ddf6fe37 31615@item -m4al
d77de738
ML
31616Same as @option{-m4a-nofpu}, except that it implicitly passes
31617@option{-dsp} to the assembler. GCC doesn't generate any DSP
31618instructions at the moment.
31619
d77de738 31620@opindex mb
ddf6fe37 31621@item -mb
d77de738
ML
31622Compile code for the processor in big-endian mode.
31623
d77de738 31624@opindex ml
ddf6fe37 31625@item -ml
d77de738
ML
31626Compile code for the processor in little-endian mode.
31627
d77de738 31628@opindex mdalign
ddf6fe37 31629@item -mdalign
d77de738
ML
31630Align doubles at 64-bit boundaries. Note that this changes the calling
31631conventions, and thus some functions from the standard C library do
31632not work unless you recompile it first with @option{-mdalign}.
31633
d77de738 31634@opindex mrelax
ddf6fe37 31635@item -mrelax
d77de738
ML
31636Shorten some address references at link time, when possible; uses the
31637linker option @option{-relax}.
31638
d77de738 31639@opindex mbigtable
ddf6fe37 31640@item -mbigtable
d77de738
ML
31641Use 32-bit offsets in @code{switch} tables. The default is to use
3164216-bit offsets.
31643
d77de738 31644@opindex mbitops
ddf6fe37 31645@item -mbitops
d77de738
ML
31646Enable the use of bit manipulation instructions on SH2A.
31647
d77de738 31648@opindex mfmovd
ddf6fe37 31649@item -mfmovd
d77de738
ML
31650Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31651alignment constraints.
31652
d77de738 31653@opindex mrenesas
ddf6fe37 31654@item -mrenesas
d77de738
ML
31655Comply with the calling conventions defined by Renesas.
31656
d77de738 31657@opindex mno-renesas
ddf6fe37 31658@item -mno-renesas
d77de738
ML
31659Comply with the calling conventions defined for GCC before the Renesas
31660conventions were available. This option is the default for all
31661targets of the SH toolchain.
31662
d77de738 31663@opindex mnomacsave
ddf6fe37 31664@item -mnomacsave
d77de738
ML
31665Mark the @code{MAC} register as call-clobbered, even if
31666@option{-mrenesas} is given.
31667
d77de738
ML
31668@opindex mieee
31669@opindex mno-ieee
ddf6fe37
AA
31670@item -mieee
31671@itemx -mno-ieee
d77de738
ML
31672Control the IEEE compliance of floating-point comparisons, which affects the
31673handling of cases where the result of a comparison is unordered. By default
31674@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31675enabled @option{-mno-ieee} is implicitly set, which results in faster
31676floating-point greater-equal and less-equal comparisons. The implicit settings
31677can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31678
d77de738 31679@opindex minline-ic_invalidate
ddf6fe37 31680@item -minline-ic_invalidate
d77de738
ML
31681Inline code to invalidate instruction cache entries after setting up
31682nested function trampolines.
31683This option has no effect if @option{-musermode} is in effect and the selected
31684code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31685instruction.
31686If the selected code generation option does not allow the use of the @code{icbi}
31687instruction, and @option{-musermode} is not in effect, the inlined code
31688manipulates the instruction cache address array directly with an associative
31689write. This not only requires privileged mode at run time, but it also
31690fails if the cache line had been mapped via the TLB and has become unmapped.
31691
d77de738 31692@opindex misize
ddf6fe37 31693@item -misize
d77de738
ML
31694Dump instruction size and location in the assembly code.
31695
d77de738 31696@opindex mpadstruct
ddf6fe37 31697@item -mpadstruct
d77de738
ML
31698This option is deprecated. It pads structures to multiple of 4 bytes,
31699which is incompatible with the SH ABI@.
31700
d77de738 31701@opindex matomic-model=@var{model}
ddf6fe37 31702@item -matomic-model=@var{model}
d77de738
ML
31703Sets the model of atomic operations and additional parameters as a comma
31704separated list. For details on the atomic built-in functions see
31705@ref{__atomic Builtins}. The following models and parameters are supported:
31706
31707@table @samp
31708
31709@item none
31710Disable compiler generated atomic sequences and emit library calls for atomic
31711operations. This is the default if the target is not @code{sh*-*-linux*}.
31712
31713@item soft-gusa
31714Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31715built-in functions. The generated atomic sequences require additional support
31716from the interrupt/exception handling code of the system and are only suitable
31717for SH3* and SH4* single-core systems. This option is enabled by default when
31718the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31719this option also partially utilizes the hardware atomic instructions
31720@code{movli.l} and @code{movco.l} to create more efficient code, unless
31721@samp{strict} is specified.
31722
31723@item soft-tcb
31724Generate software atomic sequences that use a variable in the thread control
31725block. This is a variation of the gUSA sequences which can also be used on
31726SH1* and SH2* targets. The generated atomic sequences require additional
31727support from the interrupt/exception handling code of the system and are only
31728suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31729parameter has to be specified as well.
31730
31731@item soft-imask
31732Generate software atomic sequences that temporarily disable interrupts by
31733setting @code{SR.IMASK = 1111}. This model works only when the program runs
31734in privileged mode and is only suitable for single-core systems. Additional
31735support from the interrupt/exception handling code of the system is not
31736required. This model is enabled by default when the target is
31737@code{sh*-*-linux*} and SH1* or SH2*.
31738
31739@item hard-llcs
31740Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31741instructions only. This is only available on SH4A and is suitable for
31742multi-core systems. Since the hardware instructions support only 32 bit atomic
31743variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31744Code compiled with this option is also compatible with other software
31745atomic model interrupt/exception handling systems if executed on an SH4A
31746system. Additional support from the interrupt/exception handling code of the
31747system is not required for this model.
31748
31749@item gbr-offset=
31750This parameter specifies the offset in bytes of the variable in the thread
31751control block structure that should be used by the generated atomic sequences
31752when the @samp{soft-tcb} model has been selected. For other models this
31753parameter is ignored. The specified value must be an integer multiple of four
31754and in the range 0-1020.
31755
31756@item strict
31757This parameter prevents mixed usage of multiple atomic models, even if they
31758are compatible, and makes the compiler generate atomic sequences of the
31759specified model only.
31760
31761@end table
31762
d77de738 31763@opindex mtas
ddf6fe37 31764@item -mtas
d77de738
ML
31765Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31766Notice that depending on the particular hardware and software configuration
31767this can degrade overall performance due to the operand cache line flushes
31768that are implied by the @code{tas.b} instruction. On multi-core SH4A
31769processors the @code{tas.b} instruction must be used with caution since it
31770can result in data corruption for certain cache configurations.
31771
d77de738 31772@opindex mprefergot
ddf6fe37 31773@item -mprefergot
d77de738
ML
31774When generating position-independent code, emit function calls using
31775the Global Offset Table instead of the Procedure Linkage Table.
31776
d77de738
ML
31777@opindex musermode
31778@opindex mno-usermode
ddf6fe37
AA
31779@item -musermode
31780@itemx -mno-usermode
d77de738
ML
31781Don't allow (allow) the compiler generating privileged mode code. Specifying
31782@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31783inlined code would not work in user mode. @option{-musermode} is the default
31784when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31785@option{-musermode} has no effect, since there is no user mode.
31786
d77de738 31787@opindex multcost=@var{number}
ddf6fe37 31788@item -multcost=@var{number}
d77de738
ML
31789Set the cost to assume for a multiply insn.
31790
d77de738 31791@opindex mdiv=@var{strategy}
ddf6fe37 31792@item -mdiv=@var{strategy}
d77de738
ML
31793Set the division strategy to be used for integer division operations.
31794@var{strategy} can be one of:
31795
31796@table @samp
31797
31798@item call-div1
31799Calls a library function that uses the single-step division instruction
31800@code{div1} to perform the operation. Division by zero calculates an
31801unspecified result and does not trap. This is the default except for SH4,
31802SH2A and SHcompact.
31803
31804@item call-fp
31805Calls a library function that performs the operation in double precision
31806floating point. Division by zero causes a floating-point exception. This is
31807the default for SHcompact with FPU. Specifying this for targets that do not
31808have a double precision FPU defaults to @code{call-div1}.
31809
31810@item call-table
31811Calls a library function that uses a lookup table for small divisors and
31812the @code{div1} instruction with case distinction for larger divisors. Division
31813by zero calculates an unspecified result and does not trap. This is the default
31814for SH4. Specifying this for targets that do not have dynamic shift
31815instructions defaults to @code{call-div1}.
31816
31817@end table
31818
31819When a division strategy has not been specified the default strategy is
31820selected based on the current target. For SH2A the default strategy is to
31821use the @code{divs} and @code{divu} instructions instead of library function
31822calls.
31823
d77de738 31824@opindex maccumulate-outgoing-args
ddf6fe37 31825@item -maccumulate-outgoing-args
d77de738
ML
31826Reserve space once for outgoing arguments in the function prologue rather
31827than around each call. Generally beneficial for performance and size. Also
31828needed for unwinding to avoid changing the stack frame around conditional code.
31829
d77de738 31830@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31831@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31832Set the name of the library function used for 32-bit signed division to
31833@var{name}.
31834This only affects the name used in the @samp{call} division strategies, and
31835the compiler still expects the same sets of input/output/clobbered registers as
31836if this option were not present.
31837
d77de738 31838@opindex mfixed-range
ddf6fe37 31839@item -mfixed-range=@var{register-range}
d77de738
ML
31840Generate code treating the given register range as fixed registers.
31841A fixed register is one that the register allocator cannot use. This is
31842useful when compiling kernel code. A register range is specified as
31843two registers separated by a dash. Multiple register ranges can be
31844specified separated by a comma.
31845
d77de738 31846@opindex mbranch-cost=@var{num}
ddf6fe37 31847@item -mbranch-cost=@var{num}
d77de738
ML
31848Assume @var{num} to be the cost for a branch instruction. Higher numbers
31849make the compiler try to generate more branch-free code if possible.
31850If not specified the value is selected depending on the processor type that
31851is being compiled for.
31852
d77de738
ML
31853@opindex mzdcbranch
31854@opindex mno-zdcbranch
ddf6fe37
AA
31855@item -mzdcbranch
31856@itemx -mno-zdcbranch
d77de738
ML
31857Assume (do not assume) that zero displacement conditional branch instructions
31858@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31859compiler prefers zero displacement branch code sequences. This is
31860enabled by default when generating code for SH4 and SH4A. It can be explicitly
31861disabled by specifying @option{-mno-zdcbranch}.
31862
d77de738 31863@opindex mcbranch-force-delay-slot
ddf6fe37 31864@item -mcbranch-force-delay-slot
d77de738
ML
31865Force the usage of delay slots for conditional branches, which stuffs the delay
31866slot with a @code{nop} if a suitable instruction cannot be found. By default
31867this option is disabled. It can be enabled to work around hardware bugs as
31868found in the original SH7055.
31869
d77de738
ML
31870@opindex mfused-madd
31871@opindex mno-fused-madd
ddf6fe37
AA
31872@item -mfused-madd
31873@itemx -mno-fused-madd
d77de738
ML
31874Generate code that uses (does not use) the floating-point multiply and
31875accumulate instructions. These instructions are generated by default
31876if hardware floating point is used. The machine-dependent
31877@option{-mfused-madd} option is now mapped to the machine-independent
31878@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31879mapped to @option{-ffp-contract=off}.
31880
d77de738
ML
31881@opindex mfsca
31882@opindex mno-fsca
ddf6fe37
AA
31883@item -mfsca
31884@itemx -mno-fsca
d77de738
ML
31885Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31886and cosine approximations. The option @option{-mfsca} must be used in
31887combination with @option{-funsafe-math-optimizations}. It is enabled by default
31888when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31889approximations even if @option{-funsafe-math-optimizations} is in effect.
31890
d77de738
ML
31891@opindex mfsrra
31892@opindex mno-fsrra
ddf6fe37
AA
31893@item -mfsrra
31894@itemx -mno-fsrra
d77de738
ML
31895Allow or disallow the compiler to emit the @code{fsrra} instruction for
31896reciprocal square root approximations. The option @option{-mfsrra} must be used
31897in combination with @option{-funsafe-math-optimizations} and
31898@option{-ffinite-math-only}. It is enabled by default when generating code for
31899SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31900even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31901in effect.
31902
d77de738 31903@opindex mpretend-cmove
ddf6fe37 31904@item -mpretend-cmove
d77de738
ML
31905Prefer zero-displacement conditional branches for conditional move instruction
31906patterns. This can result in faster code on the SH4 processor.
31907
d77de738 31908@opindex fdpic
ddf6fe37 31909@item -mfdpic
d77de738
ML
31910Generate code using the FDPIC ABI.
31911
31912@end table
31913
31914@node Solaris 2 Options
31915@subsection Solaris 2 Options
31916@cindex Solaris 2 options
31917
31918These @samp{-m} options are supported on Solaris 2:
31919
31920@table @gcctabopt
d77de738 31921@opindex mclear-hwcap
ddf6fe37 31922@item -mclear-hwcap
d77de738
ML
31923@option{-mclear-hwcap} tells the compiler to remove the hardware
31924capabilities generated by the Solaris assembler. This is only necessary
31925when object files use ISA extensions not supported by the current
31926machine, but check at runtime whether or not to use them.
31927
d77de738 31928@opindex mimpure-text
ddf6fe37 31929@item -mimpure-text
d77de738
ML
31930@option{-mimpure-text}, used in addition to @option{-shared}, tells
31931the compiler to not pass @option{-z text} to the linker when linking a
31932shared object. Using this option, you can link position-dependent
31933code into a shared object.
31934
31935@option{-mimpure-text} suppresses the ``relocations remain against
31936allocatable but non-writable sections'' linker error message.
31937However, the necessary relocations trigger copy-on-write, and the
31938shared object is not actually shared across processes. Instead of
31939using @option{-mimpure-text}, you should compile all source code with
31940@option{-fpic} or @option{-fPIC}.
31941
31942@end table
31943
31944These switches are supported in addition to the above on Solaris 2:
31945
31946@table @gcctabopt
d77de738 31947@opindex pthreads
ddf6fe37 31948@item -pthreads
d77de738
ML
31949This is a synonym for @option{-pthread}.
31950@end table
31951
31952@node SPARC Options
31953@subsection SPARC Options
31954@cindex SPARC options
31955
31956These @samp{-m} options are supported on the SPARC:
31957
31958@table @gcctabopt
d77de738
ML
31959@opindex mno-app-regs
31960@opindex mapp-regs
ddf6fe37
AA
31961@item -mno-app-regs
31962@itemx -mapp-regs
d77de738
ML
31963Specify @option{-mapp-regs} to generate output using the global registers
319642 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31965global register 1, each global register 2 through 4 is then treated as an
31966allocable register that is clobbered by function calls. This is the default.
31967
31968To be fully SVR4 ABI-compliant at the cost of some performance loss,
31969specify @option{-mno-app-regs}. You should compile libraries and system
31970software with this option.
31971
d77de738
ML
31972@opindex mflat
31973@opindex mno-flat
ddf6fe37
AA
31974@item -mflat
31975@itemx -mno-flat
d77de738
ML
31976With @option{-mflat}, the compiler does not generate save/restore instructions
31977and uses a ``flat'' or single register window model. This model is compatible
31978with the regular register window model. The local registers and the input
31979registers (0--5) are still treated as ``call-saved'' registers and are
31980saved on the stack as needed.
31981
31982With @option{-mno-flat} (the default), the compiler generates save/restore
31983instructions (except for leaf functions). This is the normal operating mode.
31984
d77de738
ML
31985@opindex mfpu
31986@opindex mhard-float
ddf6fe37
AA
31987@item -mfpu
31988@itemx -mhard-float
d77de738
ML
31989Generate output containing floating-point instructions. This is the
31990default.
31991
d77de738
ML
31992@opindex mno-fpu
31993@opindex msoft-float
ddf6fe37
AA
31994@item -mno-fpu
31995@itemx -msoft-float
d77de738
ML
31996Generate output containing library calls for floating point.
31997@strong{Warning:} the requisite libraries are not available for all SPARC
31998targets. Normally the facilities of the machine's usual C compiler are
31999used, but this cannot be done directly in cross-compilation. You must make
32000your own arrangements to provide suitable library functions for
32001cross-compilation. The embedded targets @samp{sparc-*-aout} and
32002@samp{sparclite-*-*} do provide software floating-point support.
32003
32004@option{-msoft-float} changes the calling convention in the output file;
32005therefore, it is only useful if you compile @emph{all} of a program with
32006this option. In particular, you need to compile @file{libgcc.a}, the
32007library that comes with GCC, with @option{-msoft-float} in order for
32008this to work.
32009
d77de738 32010@opindex mhard-quad-float
ddf6fe37 32011@item -mhard-quad-float
d77de738
ML
32012Generate output containing quad-word (long double) floating-point
32013instructions.
32014
d77de738 32015@opindex msoft-quad-float
ddf6fe37 32016@item -msoft-quad-float
d77de738
ML
32017Generate output containing library calls for quad-word (long double)
32018floating-point instructions. The functions called are those specified
32019in the SPARC ABI@. This is the default.
32020
32021As of this writing, there are no SPARC implementations that have hardware
32022support for the quad-word floating-point instructions. They all invoke
32023a trap handler for one of these instructions, and then the trap handler
32024emulates the effect of the instruction. Because of the trap handler overhead,
32025this is much slower than calling the ABI library routines. Thus the
32026@option{-msoft-quad-float} option is the default.
32027
d77de738
ML
32028@opindex mno-unaligned-doubles
32029@opindex munaligned-doubles
ddf6fe37
AA
32030@item -mno-unaligned-doubles
32031@itemx -munaligned-doubles
d77de738
ML
32032Assume that doubles have 8-byte alignment. This is the default.
32033
32034With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
32035alignment only if they are contained in another type, or if they have an
32036absolute address. Otherwise, it assumes they have 4-byte alignment.
32037Specifying this option avoids some rare compatibility problems with code
32038generated by other compilers. It is not the default because it results
32039in a performance loss, especially for floating-point code.
32040
d77de738
ML
32041@opindex muser-mode
32042@opindex mno-user-mode
ddf6fe37
AA
32043@item -muser-mode
32044@itemx -mno-user-mode
d77de738
ML
32045Do not generate code that can only run in supervisor mode. This is relevant
32046only for the @code{casa} instruction emitted for the LEON3 processor. This
32047is the default.
32048
d77de738
ML
32049@opindex mfaster-structs
32050@opindex mno-faster-structs
ddf6fe37
AA
32051@item -mfaster-structs
32052@itemx -mno-faster-structs
d77de738
ML
32053With @option{-mfaster-structs}, the compiler assumes that structures
32054should have 8-byte alignment. This enables the use of pairs of
32055@code{ldd} and @code{std} instructions for copies in structure
32056assignment, in place of twice as many @code{ld} and @code{st} pairs.
32057However, the use of this changed alignment directly violates the SPARC
32058ABI@. Thus, it's intended only for use on targets where the developer
32059acknowledges that their resulting code is not directly in line with
32060the rules of the ABI@.
32061
d77de738
ML
32062@opindex mstd-struct-return
32063@opindex mno-std-struct-return
ddf6fe37
AA
32064@item -mstd-struct-return
32065@itemx -mno-std-struct-return
d77de738
ML
32066With @option{-mstd-struct-return}, the compiler generates checking code
32067in functions returning structures or unions to detect size mismatches
32068between the two sides of function calls, as per the 32-bit ABI@.
32069
32070The default is @option{-mno-std-struct-return}. This option has no effect
32071in 64-bit mode.
32072
d77de738
ML
32073@opindex mlra
32074@opindex mno-lra
ddf6fe37
AA
32075@item -mlra
32076@itemx -mno-lra
d77de738
ML
32077Enable Local Register Allocation. This is the default for SPARC since GCC 7
32078so @option{-mno-lra} needs to be passed to get old Reload.
32079
d77de738 32080@opindex mcpu
ddf6fe37 32081@item -mcpu=@var{cpu_type}
d77de738
ML
32082Set the instruction set, register set, and instruction scheduling parameters
32083for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32084@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
32085@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
32086@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
32087@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
32088@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
32089@samp{m8}.
32090
32091Native Solaris and GNU/Linux toolchains also support the value @samp{native},
32092which selects the best architecture option for the host processor.
32093@option{-mcpu=native} has no effect if GCC does not recognize
32094the processor.
32095
32096Default instruction scheduling parameters are used for values that select
32097an architecture and not an implementation. These are @samp{v7}, @samp{v8},
32098@samp{sparclite}, @samp{sparclet}, @samp{v9}.
32099
32100Here is a list of each supported architecture and their supported
32101implementations.
32102
32103@table @asis
32104@item v7
32105cypress, leon3v7
32106
32107@item v8
32108supersparc, hypersparc, leon, leon3, leon5
32109
32110@item sparclite
32111f930, f934, sparclite86x
32112
32113@item sparclet
32114tsc701
32115
32116@item v9
32117ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
32118niagara7, m8
32119@end table
32120
32121By default (unless configured otherwise), GCC generates code for the V7
32122variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
32123additionally optimizes it for the Cypress CY7C602 chip, as used in the
32124SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
32125SPARCStation 1, 2, IPX etc.
32126
32127With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
32128architecture. The only difference from V7 code is that the compiler emits
32129the integer multiply and integer divide instructions which exist in SPARC-V8
32130but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
32131optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
321322000 series.
32133
32134With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
32135the SPARC architecture. This adds the integer multiply, integer divide step
32136and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
32137With @option{-mcpu=f930}, the compiler additionally optimizes it for the
32138Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
32139@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
32140MB86934 chip, which is the more recent SPARClite with FPU@.
32141
32142With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
32143the SPARC architecture. This adds the integer multiply, multiply/accumulate,
32144integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
32145but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
32146optimizes it for the TEMIC SPARClet chip.
32147
32148With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
32149architecture. This adds 64-bit integer and floating-point move instructions,
321503 additional floating-point condition code registers and conditional move
32151instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
32152optimizes it for the Sun UltraSPARC I/II/IIi chips. With
32153@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
32154Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
32155@option{-mcpu=niagara}, the compiler additionally optimizes it for
32156Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
32157additionally optimizes it for Sun UltraSPARC T2 chips. With
32158@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
32159UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
32160additionally optimizes it for Sun UltraSPARC T4 chips. With
32161@option{-mcpu=niagara7}, the compiler additionally optimizes it for
32162Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
32163additionally optimizes it for Oracle M8 chips.
32164
d77de738 32165@opindex mtune
ddf6fe37 32166@item -mtune=@var{cpu_type}
d77de738
ML
32167Set the instruction scheduling parameters for machine type
32168@var{cpu_type}, but do not set the instruction set or register set that the
32169option @option{-mcpu=@var{cpu_type}} does.
32170
32171The same values for @option{-mcpu=@var{cpu_type}} can be used for
32172@option{-mtune=@var{cpu_type}}, but the only useful values are those
32173that select a particular CPU implementation. Those are
32174@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
32175@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
32176@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
32177@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
32178@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
32179and GNU/Linux toolchains, @samp{native} can also be used.
32180
d77de738
ML
32181@opindex mv8plus
32182@opindex mno-v8plus
ddf6fe37
AA
32183@item -mv8plus
32184@itemx -mno-v8plus
d77de738
ML
32185With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
32186difference from the V8 ABI is that the global and out registers are
32187considered 64 bits wide. This is enabled by default on Solaris in 32-bit
32188mode for all SPARC-V9 processors.
32189
d77de738
ML
32190@opindex mvis
32191@opindex mno-vis
ddf6fe37
AA
32192@item -mvis
32193@itemx -mno-vis
d77de738
ML
32194With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
32195Visual Instruction Set extensions. The default is @option{-mno-vis}.
32196
d77de738
ML
32197@opindex mvis2
32198@opindex mno-vis2
ddf6fe37
AA
32199@item -mvis2
32200@itemx -mno-vis2
d77de738
ML
32201With @option{-mvis2}, GCC generates code that takes advantage of
32202version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
32203default is @option{-mvis2} when targeting a cpu that supports such
32204instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
32205also sets @option{-mvis}.
32206
d77de738
ML
32207@opindex mvis3
32208@opindex mno-vis3
ddf6fe37
AA
32209@item -mvis3
32210@itemx -mno-vis3
d77de738
ML
32211With @option{-mvis3}, GCC generates code that takes advantage of
32212version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
32213default is @option{-mvis3} when targeting a cpu that supports such
32214instructions, such as niagara-3 and later. Setting @option{-mvis3}
32215also sets @option{-mvis2} and @option{-mvis}.
32216
d77de738
ML
32217@opindex mvis4
32218@opindex mno-vis4
ddf6fe37
AA
32219@item -mvis4
32220@itemx -mno-vis4
d77de738
ML
32221With @option{-mvis4}, GCC generates code that takes advantage of
32222version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
32223default is @option{-mvis4} when targeting a cpu that supports such
32224instructions, such as niagara-7 and later. Setting @option{-mvis4}
32225also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
32226
d77de738
ML
32227@opindex mvis4b
32228@opindex mno-vis4b
ddf6fe37
AA
32229@item -mvis4b
32230@itemx -mno-vis4b
d77de738
ML
32231With @option{-mvis4b}, GCC generates code that takes advantage of
32232version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
32233the additional VIS instructions introduced in the Oracle SPARC
32234Architecture 2017. The default is @option{-mvis4b} when targeting a
32235cpu that supports such instructions, such as m8 and later. Setting
32236@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
32237@option{-mvis2} and @option{-mvis}.
32238
d77de738
ML
32239@opindex mcbcond
32240@opindex mno-cbcond
ddf6fe37
AA
32241@item -mcbcond
32242@itemx -mno-cbcond
d77de738
ML
32243With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
32244Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
32245when targeting a CPU that supports such instructions, such as Niagara-4 and
32246later.
32247
d77de738
ML
32248@opindex mfmaf
32249@opindex mno-fmaf
ddf6fe37
AA
32250@item -mfmaf
32251@itemx -mno-fmaf
d77de738
ML
32252With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
32253Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
32254when targeting a CPU that supports such instructions, such as Niagara-3 and
32255later.
32256
d77de738
ML
32257@opindex mfsmuld
32258@opindex mno-fsmuld
ddf6fe37
AA
32259@item -mfsmuld
32260@itemx -mno-fsmuld
d77de738
ML
32261With @option{-mfsmuld}, GCC generates code that takes advantage of the
32262Floating-point Multiply Single to Double (FsMULd) instruction. The default is
32263@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
32264or V9 with FPU except @option{-mcpu=leon}.
32265
d77de738
ML
32266@opindex mpopc
32267@opindex mno-popc
ddf6fe37
AA
32268@item -mpopc
32269@itemx -mno-popc
d77de738
ML
32270With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
32271Population Count instruction. The default is @option{-mpopc}
32272when targeting a CPU that supports such an instruction, such as Niagara-2 and
32273later.
32274
d77de738
ML
32275@opindex msubxc
32276@opindex mno-subxc
ddf6fe37
AA
32277@item -msubxc
32278@itemx -mno-subxc
d77de738
ML
32279With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
32280Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
32281when targeting a CPU that supports such an instruction, such as Niagara-7 and
32282later.
32283
d77de738 32284@opindex mfix-at697f
ddf6fe37 32285@item -mfix-at697f
d77de738
ML
32286Enable the documented workaround for the single erratum of the Atmel AT697F
32287processor (which corresponds to erratum #13 of the AT697E processor).
32288
d77de738 32289@opindex mfix-ut699
ddf6fe37 32290@item -mfix-ut699
d77de738
ML
32291Enable the documented workarounds for the floating-point errata and the data
32292cache nullify errata of the UT699 processor.
32293
d77de738 32294@opindex mfix-ut700
ddf6fe37 32295@item -mfix-ut700
d77de738
ML
32296Enable the documented workaround for the back-to-back store errata of
32297the UT699E/UT700 processor.
32298
d77de738 32299@opindex mfix-gr712rc
ddf6fe37 32300@item -mfix-gr712rc
d77de738
ML
32301Enable the documented workaround for the back-to-back store errata of
32302the GR712RC processor.
32303@end table
32304
32305These @samp{-m} options are supported in addition to the above
32306on SPARC-V9 processors in 64-bit environments:
32307
32308@table @gcctabopt
d77de738
ML
32309@opindex m32
32310@opindex m64
ddf6fe37
AA
32311@item -m32
32312@itemx -m64
d77de738
ML
32313Generate code for a 32-bit or 64-bit environment.
32314The 32-bit environment sets int, long and pointer to 32 bits.
32315The 64-bit environment sets int to 32 bits and long and pointer
32316to 64 bits.
32317
d77de738 32318@opindex mcmodel
ddf6fe37 32319@item -mcmodel=@var{which}
d77de738
ML
32320Set the code model to one of
32321
32322@table @samp
32323@item medlow
32324The Medium/Low code model: 64-bit addresses, programs
32325must be linked in the low 32 bits of memory. Programs can be statically
32326or dynamically linked.
32327
32328@item medmid
32329The Medium/Middle code model: 64-bit addresses, programs
32330must be linked in the low 44 bits of memory, the text and data segments must
32331be less than 2GB in size and the data segment must be located within 2GB of
32332the text segment.
32333
32334@item medany
32335The Medium/Anywhere code model: 64-bit addresses, programs
32336may be linked anywhere in memory, the text and data segments must be less
32337than 2GB in size and the data segment must be located within 2GB of the
32338text segment.
32339
32340@item embmedany
32341The Medium/Anywhere code model for embedded systems:
3234264-bit addresses, the text and data segments must be less than 2GB in
32343size, both starting anywhere in memory (determined at link time). The
32344global register %g4 points to the base of the data segment. Programs
32345are statically linked and PIC is not supported.
32346@end table
32347
d77de738 32348@opindex mmemory-model
ddf6fe37 32349@item -mmemory-model=@var{mem-model}
d77de738
ML
32350Set the memory model in force on the processor to one of
32351
32352@table @samp
32353@item default
32354The default memory model for the processor and operating system.
32355
32356@item rmo
32357Relaxed Memory Order
32358
32359@item pso
32360Partial Store Order
32361
32362@item tso
32363Total Store Order
32364
32365@item sc
32366Sequential Consistency
32367@end table
32368
32369These memory models are formally defined in Appendix D of the SPARC-V9
32370architecture manual, as set in the processor's @code{PSTATE.MM} field.
32371
d77de738
ML
32372@opindex mstack-bias
32373@opindex mno-stack-bias
ddf6fe37
AA
32374@item -mstack-bias
32375@itemx -mno-stack-bias
d77de738
ML
32376With @option{-mstack-bias}, GCC assumes that the stack pointer, and
32377frame pointer if present, are offset by @minus{}2047 which must be added back
32378when making stack frame references. This is the default in 64-bit mode.
32379Otherwise, assume no such offset is present.
32380@end table
32381
32382@node System V Options
32383@subsection Options for System V
32384
32385These additional options are available on System V Release 4 for
32386compatibility with other compilers on those systems:
32387
32388@table @gcctabopt
d77de738 32389@opindex G
ddf6fe37 32390@item -G
d77de738
ML
32391Create a shared object.
32392It is recommended that @option{-symbolic} or @option{-shared} be used instead.
32393
d77de738 32394@opindex Qy
ddf6fe37 32395@item -Qy
d77de738
ML
32396Identify the versions of each tool used by the compiler, in a
32397@code{.ident} assembler directive in the output.
32398
d77de738 32399@opindex Qn
ddf6fe37 32400@item -Qn
d77de738
ML
32401Refrain from adding @code{.ident} directives to the output file (this is
32402the default).
32403
d77de738 32404@opindex YP
ddf6fe37 32405@item -YP,@var{dirs}
d77de738
ML
32406Search the directories @var{dirs}, and no others, for libraries
32407specified with @option{-l}.
32408
d77de738 32409@opindex Ym
ddf6fe37 32410@item -Ym,@var{dir}
d77de738
ML
32411Look in the directory @var{dir} to find the M4 preprocessor.
32412The assembler uses this option.
32413@c This is supposed to go with a -Yd for predefined M4 macro files, but
32414@c the generic assembler that comes with Solaris takes just -Ym.
32415@end table
32416
32417@node V850 Options
32418@subsection V850 Options
32419@cindex V850 Options
32420
32421These @samp{-m} options are defined for V850 implementations:
32422
32423@table @gcctabopt
d77de738
ML
32424@opindex mlong-calls
32425@opindex mno-long-calls
ddf6fe37
AA
32426@item -mlong-calls
32427@itemx -mno-long-calls
d77de738
ML
32428Treat all calls as being far away (near). If calls are assumed to be
32429far away, the compiler always loads the function's address into a
32430register, and calls indirect through the pointer.
32431
d77de738
ML
32432@opindex mno-ep
32433@opindex mep
ddf6fe37
AA
32434@item -mno-ep
32435@itemx -mep
d77de738
ML
32436Do not optimize (do optimize) basic blocks that use the same index
32437pointer 4 or more times to copy pointer into the @code{ep} register, and
32438use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
32439option is on by default if you optimize.
32440
d77de738
ML
32441@opindex mno-prolog-function
32442@opindex mprolog-function
ddf6fe37
AA
32443@item -mno-prolog-function
32444@itemx -mprolog-function
d77de738
ML
32445Do not use (do use) external functions to save and restore registers
32446at the prologue and epilogue of a function. The external functions
32447are slower, but use less code space if more than one function saves
32448the same number of registers. The @option{-mprolog-function} option
32449is on by default if you optimize.
32450
d77de738 32451@opindex mspace
ddf6fe37 32452@item -mspace
d77de738
ML
32453Try to make the code as small as possible. At present, this just turns
32454on the @option{-mep} and @option{-mprolog-function} options.
32455
d77de738 32456@opindex mtda
ddf6fe37 32457@item -mtda=@var{n}
d77de738
ML
32458Put static or global variables whose size is @var{n} bytes or less into
32459the tiny data area that register @code{ep} points to. The tiny data
32460area can hold up to 256 bytes in total (128 bytes for byte references).
32461
d77de738 32462@opindex msda
ddf6fe37 32463@item -msda=@var{n}
d77de738
ML
32464Put static or global variables whose size is @var{n} bytes or less into
32465the small data area that register @code{gp} points to. The small data
32466area can hold up to 64 kilobytes.
32467
d77de738 32468@opindex mzda
ddf6fe37 32469@item -mzda=@var{n}
d77de738
ML
32470Put static or global variables whose size is @var{n} bytes or less into
32471the first 32 kilobytes of memory.
32472
d77de738 32473@opindex mv850
ddf6fe37 32474@item -mv850
d77de738
ML
32475Specify that the target processor is the V850.
32476
d77de738 32477@opindex mv850e3v5
ddf6fe37 32478@item -mv850e3v5
d77de738
ML
32479Specify that the target processor is the V850E3V5. The preprocessor
32480constant @code{__v850e3v5__} is defined if this option is used.
32481
d77de738 32482@opindex mv850e2v4
ddf6fe37 32483@item -mv850e2v4
d77de738
ML
32484Specify that the target processor is the V850E3V5. This is an alias for
32485the @option{-mv850e3v5} option.
32486
d77de738 32487@opindex mv850e2v3
ddf6fe37 32488@item -mv850e2v3
d77de738
ML
32489Specify that the target processor is the V850E2V3. The preprocessor
32490constant @code{__v850e2v3__} is defined if this option is used.
32491
d77de738 32492@opindex mv850e2
ddf6fe37 32493@item -mv850e2
d77de738
ML
32494Specify that the target processor is the V850E2. The preprocessor
32495constant @code{__v850e2__} is defined if this option is used.
32496
d77de738 32497@opindex mv850e1
ddf6fe37 32498@item -mv850e1
d77de738
ML
32499Specify that the target processor is the V850E1. The preprocessor
32500constants @code{__v850e1__} and @code{__v850e__} are defined if
32501this option is used.
32502
d77de738 32503@opindex mv850es
ddf6fe37 32504@item -mv850es
d77de738
ML
32505Specify that the target processor is the V850ES. This is an alias for
32506the @option{-mv850e1} option.
32507
d77de738 32508@opindex mv850e
ddf6fe37 32509@item -mv850e
d77de738
ML
32510Specify that the target processor is the V850E@. The preprocessor
32511constant @code{__v850e__} is defined if this option is used.
32512
32513If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
32514nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
32515are defined then a default target processor is chosen and the
32516relevant @samp{__v850*__} preprocessor constant is defined.
32517
32518The preprocessor constants @code{__v850} and @code{__v851__} are always
32519defined, regardless of which processor variant is the target.
32520
d77de738
ML
32521@opindex mdisable-callt
32522@opindex mno-disable-callt
ddf6fe37
AA
32523@item -mdisable-callt
32524@itemx -mno-disable-callt
d77de738
ML
32525This option suppresses generation of the @code{CALLT} instruction for the
32526v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
32527architecture.
32528
32529This option is enabled by default when the RH850 ABI is
32530in use (see @option{-mrh850-abi}), and disabled by default when the
32531GCC ABI is in use. If @code{CALLT} instructions are being generated
32532then the C preprocessor symbol @code{__V850_CALLT__} is defined.
32533
d77de738
ML
32534@opindex mrelax
32535@opindex mno-relax
ddf6fe37
AA
32536@item -mrelax
32537@itemx -mno-relax
d77de738
ML
32538Pass on (or do not pass on) the @option{-mrelax} command-line option
32539to the assembler.
32540
d77de738
ML
32541@opindex mlong-jumps
32542@opindex mno-long-jumps
ddf6fe37
AA
32543@item -mlong-jumps
32544@itemx -mno-long-jumps
d77de738
ML
32545Disable (or re-enable) the generation of PC-relative jump instructions.
32546
d77de738
ML
32547@opindex msoft-float
32548@opindex mhard-float
ddf6fe37
AA
32549@item -msoft-float
32550@itemx -mhard-float
d77de738
ML
32551Disable (or re-enable) the generation of hardware floating point
32552instructions. This option is only significant when the target
32553architecture is @samp{V850E2V3} or higher. If hardware floating point
32554instructions are being generated then the C preprocessor symbol
32555@code{__FPU_OK__} is defined, otherwise the symbol
32556@code{__NO_FPU__} is defined.
32557
d77de738 32558@opindex mloop
ddf6fe37 32559@item -mloop
d77de738
ML
32560Enables the use of the e3v5 LOOP instruction. The use of this
32561instruction is not enabled by default when the e3v5 architecture is
32562selected because its use is still experimental.
32563
d77de738
ML
32564@opindex mrh850-abi
32565@opindex mghs
ddf6fe37
AA
32566@item -mrh850-abi
32567@itemx -mghs
d77de738
ML
32568Enables support for the RH850 version of the V850 ABI. This is the
32569default. With this version of the ABI the following rules apply:
32570
32571@itemize
32572@item
32573Integer sized structures and unions are returned via a memory pointer
32574rather than a register.
32575
32576@item
32577Large structures and unions (more than 8 bytes in size) are passed by
32578value.
32579
32580@item
32581Functions are aligned to 16-bit boundaries.
32582
32583@item
32584The @option{-m8byte-align} command-line option is supported.
32585
32586@item
32587The @option{-mdisable-callt} command-line option is enabled by
32588default. The @option{-mno-disable-callt} command-line option is not
32589supported.
32590@end itemize
32591
32592When this version of the ABI is enabled the C preprocessor symbol
32593@code{__V850_RH850_ABI__} is defined.
32594
d77de738 32595@opindex mgcc-abi
ddf6fe37 32596@item -mgcc-abi
d77de738
ML
32597Enables support for the old GCC version of the V850 ABI. With this
32598version of the ABI the following rules apply:
32599
32600@itemize
32601@item
32602Integer sized structures and unions are returned in register @code{r10}.
32603
32604@item
32605Large structures and unions (more than 8 bytes in size) are passed by
32606reference.
32607
32608@item
32609Functions are aligned to 32-bit boundaries, unless optimizing for
32610size.
32611
32612@item
32613The @option{-m8byte-align} command-line option is not supported.
32614
32615@item
32616The @option{-mdisable-callt} command-line option is supported but not
32617enabled by default.
32618@end itemize
32619
32620When this version of the ABI is enabled the C preprocessor symbol
32621@code{__V850_GCC_ABI__} is defined.
32622
d77de738
ML
32623@opindex m8byte-align
32624@opindex mno-8byte-align
ddf6fe37
AA
32625@item -m8byte-align
32626@itemx -mno-8byte-align
d77de738
ML
32627Enables support for @code{double} and @code{long long} types to be
32628aligned on 8-byte boundaries. The default is to restrict the
32629alignment of all objects to at most 4-bytes. When
32630@option{-m8byte-align} is in effect the C preprocessor symbol
32631@code{__V850_8BYTE_ALIGN__} is defined.
32632
d77de738 32633@opindex mbig-switch
ddf6fe37 32634@item -mbig-switch
d77de738
ML
32635Generate code suitable for big switch tables. Use this option only if
32636the assembler/linker complain about out of range branches within a switch
32637table.
32638
d77de738 32639@opindex mapp-regs
ddf6fe37 32640@item -mapp-regs
d77de738
ML
32641This option causes r2 and r5 to be used in the code generated by
32642the compiler. This setting is the default.
32643
d77de738 32644@opindex mno-app-regs
ddf6fe37 32645@item -mno-app-regs
d77de738
ML
32646This option causes r2 and r5 to be treated as fixed registers.
32647
32648@end table
32649
32650@node VAX Options
32651@subsection VAX Options
32652@cindex VAX options
32653
32654These @samp{-m} options are defined for the VAX:
32655
32656@table @gcctabopt
d77de738 32657@opindex munix
ddf6fe37 32658@item -munix
d77de738
ML
32659Do not output certain jump instructions (@code{aobleq} and so on)
32660that the Unix assembler for the VAX cannot handle across long
32661ranges.
32662
d77de738 32663@opindex mgnu
ddf6fe37 32664@item -mgnu
d77de738
ML
32665Do output those jump instructions, on the assumption that the
32666GNU assembler is being used.
32667
d77de738 32668@opindex mg
ddf6fe37 32669@item -mg
d77de738
ML
32670Output code for G-format floating-point numbers instead of D-format.
32671
d77de738
ML
32672@opindex mlra
32673@opindex mno-lra
ddf6fe37
AA
32674@item -mlra
32675@itemx -mno-lra
d77de738
ML
32676Enable Local Register Allocation. This is still experimental for the VAX,
32677so by default the compiler uses standard reload.
32678@end table
32679
32680@node Visium Options
32681@subsection Visium Options
32682@cindex Visium options
32683
32684@table @gcctabopt
32685
d77de738 32686@opindex mdebug
ddf6fe37 32687@item -mdebug
d77de738
ML
32688A program which performs file I/O and is destined to run on an MCM target
32689should be linked with this option. It causes the libraries libc.a and
32690libdebug.a to be linked. The program should be run on the target under
32691the control of the GDB remote debugging stub.
32692
d77de738 32693@opindex msim
ddf6fe37 32694@item -msim
d77de738
ML
32695A program which performs file I/O and is destined to run on the simulator
32696should be linked with option. This causes libraries libc.a and libsim.a to
32697be linked.
32698
d77de738
ML
32699@opindex mfpu
32700@opindex mhard-float
ddf6fe37
AA
32701@item -mfpu
32702@itemx -mhard-float
d77de738
ML
32703Generate code containing floating-point instructions. This is the
32704default.
32705
d77de738
ML
32706@opindex mno-fpu
32707@opindex msoft-float
ddf6fe37
AA
32708@item -mno-fpu
32709@itemx -msoft-float
d77de738
ML
32710Generate code containing library calls for floating-point.
32711
32712@option{-msoft-float} changes the calling convention in the output file;
32713therefore, it is only useful if you compile @emph{all} of a program with
32714this option. In particular, you need to compile @file{libgcc.a}, the
32715library that comes with GCC, with @option{-msoft-float} in order for
32716this to work.
32717
d77de738 32718@opindex mcpu
ddf6fe37 32719@item -mcpu=@var{cpu_type}
d77de738
ML
32720Set the instruction set, register set, and instruction scheduling parameters
32721for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32722@samp{mcm}, @samp{gr5} and @samp{gr6}.
32723
32724@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32725
32726By default (unless configured otherwise), GCC generates code for the GR5
32727variant of the Visium architecture.
32728
32729With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32730architecture. The only difference from GR5 code is that the compiler will
32731generate block move instructions.
32732
d77de738 32733@opindex mtune
ddf6fe37 32734@item -mtune=@var{cpu_type}
d77de738
ML
32735Set the instruction scheduling parameters for machine type @var{cpu_type},
32736but do not set the instruction set or register set that the option
32737@option{-mcpu=@var{cpu_type}} would.
32738
d77de738 32739@opindex msv-mode
ddf6fe37 32740@item -msv-mode
d77de738
ML
32741Generate code for the supervisor mode, where there are no restrictions on
32742the access to general registers. This is the default.
32743
d77de738 32744@opindex muser-mode
ddf6fe37 32745@item -muser-mode
d77de738
ML
32746Generate code for the user mode, where the access to some general registers
32747is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32748mode; on the GR6, only registers r29 to r31 are affected.
32749@end table
32750
32751@node VMS Options
32752@subsection VMS Options
32753
32754These @samp{-m} options are defined for the VMS implementations:
32755
32756@table @gcctabopt
d77de738 32757@opindex mvms-return-codes
ddf6fe37 32758@item -mvms-return-codes
d77de738
ML
32759Return VMS condition codes from @code{main}. The default is to return POSIX-style
32760condition (e.g.@: error) codes.
32761
d77de738 32762@opindex mdebug-main=@var{prefix}
ddf6fe37 32763@item -mdebug-main=@var{prefix}
d77de738
ML
32764Flag the first routine whose name starts with @var{prefix} as the main
32765routine for the debugger.
32766
d77de738 32767@opindex mmalloc64
ddf6fe37 32768@item -mmalloc64
d77de738
ML
32769Default to 64-bit memory allocation routines.
32770
d77de738 32771@opindex mpointer-size=@var{size}
ddf6fe37 32772@item -mpointer-size=@var{size}
d77de738
ML
32773Set the default size of pointers. Possible options for @var{size} are
32774@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32775for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32776The later option disables @code{pragma pointer_size}.
32777@end table
32778
32779@node VxWorks Options
32780@subsection VxWorks Options
32781@cindex VxWorks Options
32782
32783The options in this section are defined for all VxWorks targets.
32784Options specific to the target hardware are listed with the other
32785options for that target.
32786
32787@table @gcctabopt
d77de738 32788@opindex mrtp
ddf6fe37 32789@item -mrtp
d77de738
ML
32790GCC can generate code for both VxWorks kernels and real time processes
32791(RTPs). This option switches from the former to the latter. It also
32792defines the preprocessor macro @code{__RTP__}.
32793
b6f4b000
AO
32794@opindex msmp
32795@item -msmp
32796Select SMP runtimes for linking. Not available on architectures other
32797than PowerPC, nor on VxWorks version 7 or later, in which the selection
32798is part of the VxWorks build configuration and the library paths are the
32799same for either choice.
32800
d77de738 32801@opindex non-static
ddf6fe37 32802@item -non-static
d77de738
ML
32803Link an RTP executable against shared libraries rather than static
32804libraries. The options @option{-static} and @option{-shared} can
32805also be used for RTPs (@pxref{Link Options}); @option{-static}
32806is the default.
32807
d77de738
ML
32808@opindex Bstatic
32809@opindex Bdynamic
ddf6fe37
AA
32810@item -Bstatic
32811@itemx -Bdynamic
d77de738
ML
32812These options are passed down to the linker. They are defined for
32813compatibility with Diab.
32814
d77de738 32815@opindex Xbind-lazy
ddf6fe37 32816@item -Xbind-lazy
d77de738
ML
32817Enable lazy binding of function calls. This option is equivalent to
32818@option{-Wl,-z,now} and is defined for compatibility with Diab.
32819
d77de738 32820@opindex Xbind-now
ddf6fe37 32821@item -Xbind-now
d77de738
ML
32822Disable lazy binding of function calls. This option is the default and
32823is defined for compatibility with Diab.
32824@end table
32825
32826@node x86 Options
32827@subsection x86 Options
32828@cindex x86 Options
32829
32830These @samp{-m} options are defined for the x86 family of computers.
32831
32832@table @gcctabopt
32833
d77de738 32834@opindex march
ddf6fe37 32835@item -march=@var{cpu-type}
d77de738
ML
32836Generate instructions for the machine type @var{cpu-type}. In contrast to
32837@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32838for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32839to generate code that may not run at all on processors other than the one
32840indicated. Specifying @option{-march=@var{cpu-type}} implies
32841@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32842
32843The choices for @var{cpu-type} are:
32844
32845@table @samp
32846@item native
32847This selects the CPU to generate code for at compilation time by determining
32848the processor type of the compiling machine. Using @option{-march=native}
32849enables all instruction subsets supported by the local machine (hence
32850the result might not run on different machines). Using @option{-mtune=native}
32851produces code optimized for the local machine under the constraints
32852of the selected instruction set.
32853
32854@item x86-64
32855A generic CPU with 64-bit extensions.
32856
32857@item x86-64-v2
32858@itemx x86-64-v3
32859@itemx x86-64-v4
32860These choices for @var{cpu-type} select the corresponding
32861micro-architecture level from the x86-64 psABI. On ABIs other than
32862the x86-64 psABI they select the same CPU features as the x86-64 psABI
32863documents for the particular micro-architecture level.
32864
32865Since these @var{cpu-type} values do not have a corresponding
32866@option{-mtune} setting, using @option{-march} with these values enables
32867generic tuning. Specific tuning can be enabled using the
32868@option{-mtune=@var{other-cpu-type}} option with an appropriate
32869@var{other-cpu-type} value.
32870
32871@item i386
32872Original Intel i386 CPU@.
32873
32874@item i486
32875Intel i486 CPU@. (No scheduling is implemented for this chip.)
32876
32877@item i586
32878@itemx pentium
32879Intel Pentium CPU with no MMX support.
32880
32881@item lakemont
32882Intel Lakemont MCU, based on Intel Pentium CPU.
32883
32884@item pentium-mmx
32885Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32886
32887@item pentiumpro
32888Intel Pentium Pro CPU@.
32889
32890@item i686
32891When used with @option{-march}, the Pentium Pro
32892instruction set is used, so the code runs on all i686 family chips.
32893When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32894
32895@item pentium2
32896Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32897set support.
32898
32899@item pentium3
32900@itemx pentium3m
32901Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32902instruction set support.
32903
32904@item pentium-m
32905Intel Pentium M; low-power version of Intel Pentium III CPU
32906with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32907notebooks.
32908
32909@item pentium4
32910@itemx pentium4m
32911Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32912
32913@item prescott
32914Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32915instruction set support.
32916
32917@item nocona
32918Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32919SSE2, SSE3 and FXSR instruction set support.
32920
32921@item core2
32922Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32923SAHF and FXSR instruction set support.
32924
32925@item nehalem
32926Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32927SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32928
32929@item westmere
32930Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32931SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32932
32933@item sandybridge
32934Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32935SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32936support.
32937
32938@item ivybridge
32939Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32940SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32941and F16C instruction set support.
32942
32943@item haswell
32944Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32945SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32946F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32947
32948@item broadwell
32949Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32950SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32951F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32952instruction set support.
32953
32954@item skylake
32955Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32956SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32957F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32958CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32959
32960@item bonnell
32961Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32962instruction set support.
32963
32964@item silvermont
32965Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32966SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32967instruction set support.
32968
32969@item goldmont
32970Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32971SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32972RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32973set support.
32974
32975@item goldmont-plus
32976Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32977SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32978SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32979RDPID and SGX instruction set support.
32980
32981@item tremont
32982Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32983SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32984RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32985SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32986support.
32987
32988@item sierraforest
32989Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32990SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32991XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32992MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32993PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
32994AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
32995support.
d77de738
ML
32996
32997@item grandridge
32998Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32999SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33000XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33001MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33002PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
33003AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT
33004instruction set support.
d77de738 33005
7370c479
HJ
33006@item clearwaterforest
33007Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
33008SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
33009XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
33010MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
33011LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
faa0e82b
HJ
33012ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
33013SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
f019251a 33014
d77de738
ML
33015@item knl
33016Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33017SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33018RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33019AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
33020
33021@item knm
33022Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33023SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33024RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33025AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
33026AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
33027
33028@item skylake-avx512
33029Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33030SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33031RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33032AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
33033AVX512DQ and AVX512CD instruction set support.
33034
33035@item cannonlake
33036Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
33037SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
33038FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
33039PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
33040AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
33041support.
33042
33043@item icelake-client
33044Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33045SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33046RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33047AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33048AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
33049, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
33050
33051@item icelake-server
33052Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33053SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33054RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33055AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33056AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
33057, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
33058instruction set support.
33059
33060@item cascadelake
33061Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33062SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33063F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33064CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
33065AVX512CD and AVX512VNNI instruction set support.
33066
33067@item cooperlake
33068Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33069SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33070F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33071CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
33072AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
33073
33074@item tigerlake
33075Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33076SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33077F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33078CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
33079PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33080VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
33081AVX512VP2INTERSECT and KEYLOCKER instruction set support.
33082
33083@item sapphirerapids
33084Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33085SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33086RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33087AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33088AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33089VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
33090MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 33091UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
33092instruction set support.
33093
33094@item alderlake
33095Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
33096SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
33097XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
33098CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
33099VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
33100support.
33101
33102@item rocketlake
33103Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
33104, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
33105F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
33106CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
33107PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33108VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
33109
33110@item graniterapids
33111Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33112SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33113RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33114AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33115AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33116VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
33117MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
33118UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
33119and PREFETCHI instruction set support.
d77de738 33120
a0cb65d3
MZ
33121@item graniterapids-d
33122Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33123SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
33124RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
33125AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
33126AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
33127VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
33128MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
33129UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
33130PREFETCHI and AMX-COMPLEX instruction set support.
a0cb65d3 33131
faa0e82b
HJ
33132@item arrowlake
33133Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33134SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33135XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33136MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33137PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33138UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set
33139support.
33140
33141@item arrowlake-s
33142Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33143SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33144XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33145MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33146PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33147UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
33148SM3 and SM4 instruction set support.
33149
33150@item pantherlake
33151Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
33152SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
33153XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
33154MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
33155PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
33156UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
33157SM3, SM4 and PREFETCHI instruction set support.
33158
d77de738
ML
33159@item k6
33160AMD K6 CPU with MMX instruction set support.
33161
33162@item k6-2
33163@itemx k6-3
33164Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
33165
33166@item athlon
33167@itemx athlon-tbird
33168AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
33169support.
33170
33171@item athlon-4
33172@itemx athlon-xp
33173@itemx athlon-mp
33174Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
33175instruction set support.
33176
33177@item k8
33178@itemx opteron
33179@itemx athlon64
33180@itemx athlon-fx
33181Processors based on the AMD K8 core with x86-64 instruction set support,
33182including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
33183(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
33184instruction set extensions.)
33185
33186@item k8-sse3
33187@itemx opteron-sse3
33188@itemx athlon64-sse3
33189Improved versions of AMD K8 cores with SSE3 instruction set support.
33190
33191@item amdfam10
33192@itemx barcelona
33193CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
33194supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
33195instruction set extensions.)
33196
33197@item bdver1
33198CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
33199supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
33200SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
33201
33202@item bdver2
33203AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33204supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
33205SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
33206extensions.)
33207
33208@item bdver3
33209AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33210supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
33211PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3321264-bit instruction set extensions.)
33213
33214@item bdver4
33215AMD Family 15h core based CPUs with x86-64 instruction set support. (This
33216supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
33217AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
33218SSE4.2, ABM and 64-bit instruction set extensions.)
33219
33220@item znver1
33221AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33222supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
33223SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
33224SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
33225instruction set extensions.)
33226
33227@item znver2
33228AMD Family 17h core based CPUs with x86-64 instruction set support. (This
33229supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33230MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33231SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33232WBNOINVD, and 64-bit instruction set extensions.)
33233
33234@item znver3
33235AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33236supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33237MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33238SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33239WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
33240
33241@item znver4
33242AMD Family 19h core based CPUs with x86-64 instruction set support. (This
33243supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
33244MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
33245SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
33246WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
33247AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
33248AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
33249
33250@item btver1
33251CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
33252supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
33253instruction set extensions.)
33254
33255@item btver2
33256CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
33257includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
33258SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
33259
33260@item winchip-c6
33261IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
33262set support.
33263
33264@item winchip2
33265IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
33266instruction set support.
33267
33268@item c3
33269VIA C3 CPU with MMX and 3DNow!@: instruction set support.
33270(No scheduling is implemented for this chip.)
33271
33272@item c3-2
33273VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
33274(No scheduling is implemented for this chip.)
33275
33276@item c7
33277VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33278(No scheduling is implemented for this chip.)
33279
33280@item samuel-2
33281VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
33282(No scheduling is implemented for this chip.)
33283
33284@item nehemiah
33285VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
33286(No scheduling is implemented for this chip.)
33287
33288@item esther
33289VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
33290(No scheduling is implemented for this chip.)
33291
33292@item eden-x2
33293VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
33294(No scheduling is implemented for this chip.)
33295
33296@item eden-x4
33297VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
33298AVX and AVX2 instruction set support.
33299(No scheduling is implemented for this chip.)
33300
33301@item nano
33302Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33303instruction set support.
33304(No scheduling is implemented for this chip.)
33305
33306@item nano-1000
33307VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33308instruction set support.
33309(No scheduling is implemented for this chip.)
33310
33311@item nano-2000
33312VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
33313instruction set support.
33314(No scheduling is implemented for this chip.)
33315
33316@item nano-3000
33317VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33318instruction set support.
33319(No scheduling is implemented for this chip.)
33320
33321@item nano-x2
33322VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33323instruction set support.
33324(No scheduling is implemented for this chip.)
33325
33326@item nano-x4
33327VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
33328instruction set support.
33329(No scheduling is implemented for this chip.)
33330
33331@item lujiazui
33332ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
33333SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
33334ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
33335
94c0b26f
M
33336@item yongfeng
33337ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
33338SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
33339ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
33340instruction set support.
33341
d77de738
ML
33342@item geode
33343AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
33344@end table
33345
d77de738 33346@opindex mtune
ddf6fe37 33347@item -mtune=@var{cpu-type}
d77de738
ML
33348Tune to @var{cpu-type} everything applicable about the generated code, except
33349for the ABI and the set of available instructions.
33350While picking a specific @var{cpu-type} schedules things appropriately
33351for that particular chip, the compiler does not generate any code that
33352cannot run on the default machine type unless you use a
33353@option{-march=@var{cpu-type}} option.
33354For example, if GCC is configured for i686-pc-linux-gnu
33355then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
33356but still runs on i686 machines.
33357
33358The choices for @var{cpu-type} are the same as for @option{-march}.
33359In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
33360
33361@table @samp
33362@item generic
33363Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
33364If you know the CPU on which your code will run, then you should use
33365the corresponding @option{-mtune} or @option{-march} option instead of
33366@option{-mtune=generic}. But, if you do not know exactly what CPU users
33367of your application will have, then you should use this option.
33368
33369As new processors are deployed in the marketplace, the behavior of this
33370option will change. Therefore, if you upgrade to a newer version of
33371GCC, code generation controlled by this option will change to reflect
33372the processors
33373that are most common at the time that version of GCC is released.
33374
33375There is no @option{-march=generic} option because @option{-march}
33376indicates the instruction set the compiler can use, and there is no
33377generic instruction set applicable to all processors. In contrast,
33378@option{-mtune} indicates the processor (or, in this case, collection of
33379processors) for which the code is optimized.
33380
33381@item intel
33382Produce code optimized for the most current Intel processors, which are
33383Haswell and Silvermont for this version of GCC. If you know the CPU
33384on which your code will run, then you should use the corresponding
33385@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
33386But, if you want your application performs better on both Haswell and
33387Silvermont, then you should use this option.
33388
33389As new Intel processors are deployed in the marketplace, the behavior of
33390this option will change. Therefore, if you upgrade to a newer version of
33391GCC, code generation controlled by this option will change to reflect
33392the most current Intel processors at the time that version of GCC is
33393released.
33394
33395There is no @option{-march=intel} option because @option{-march} indicates
33396the instruction set the compiler can use, and there is no common
33397instruction set applicable to all processors. In contrast,
33398@option{-mtune} indicates the processor (or, in this case, collection of
33399processors) for which the code is optimized.
33400@end table
33401
d77de738 33402@opindex mcpu
ddf6fe37 33403@item -mcpu=@var{cpu-type}
d77de738
ML
33404A deprecated synonym for @option{-mtune}.
33405
d77de738 33406@opindex mfpmath
ddf6fe37 33407@item -mfpmath=@var{unit}
d77de738
ML
33408Generate floating-point arithmetic for selected unit @var{unit}. The choices
33409for @var{unit} are:
33410
33411@table @samp
33412@item 387
33413Use the standard 387 floating-point coprocessor present on the majority of chips and
33414emulated otherwise. Code compiled with this option runs almost everywhere.
33415The temporary results are computed in 80-bit precision instead of the precision
33416specified by the type, resulting in slightly different results compared to most
33417of other chips. See @option{-ffloat-store} for more detailed description.
33418
33419This is the default choice for non-Darwin x86-32 targets.
33420
33421@item sse
33422Use scalar floating-point instructions present in the SSE instruction set.
33423This instruction set is supported by Pentium III and newer chips,
33424and in the AMD line
33425by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
33426instruction set supports only single-precision arithmetic, thus the double and
33427extended-precision arithmetic are still done using 387. A later version, present
33428only in Pentium 4 and AMD x86-64 chips, supports double-precision
33429arithmetic too.
33430
33431For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
33432or @option{-msse2} switches to enable SSE extensions and make this option
33433effective. For the x86-64 compiler, these extensions are enabled by default.
33434
33435The resulting code should be considerably faster in the majority of cases and avoid
33436the numerical instability problems of 387 code, but may break some existing
33437code that expects temporaries to be 80 bits.
33438
33439This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
33440and the default choice for x86-32 targets with the SSE2 instruction set
33441when @option{-ffast-math} is enabled.
33442
33443@item sse,387
33444@itemx sse+387
33445@itemx both
33446Attempt to utilize both instruction sets at once. This effectively doubles the
33447amount of available registers, and on chips with separate execution units for
33448387 and SSE the execution resources too. Use this option with care, as it is
33449still experimental, because the GCC register allocator does not model separate
33450functional units well, resulting in unstable performance.
33451@end table
33452
d77de738 33453@opindex masm=@var{dialect}
ddf6fe37 33454@item -masm=@var{dialect}
d77de738
ML
33455Output assembly instructions using selected @var{dialect}. Also affects
33456which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
33457extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
33458order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
33459not support @samp{intel}.
33460
d77de738
ML
33461@opindex mieee-fp
33462@opindex mno-ieee-fp
ddf6fe37
AA
33463@item -mieee-fp
33464@itemx -mno-ieee-fp
d77de738
ML
33465Control whether or not the compiler uses IEEE floating-point
33466comparisons. These correctly handle the case where the result of a
33467comparison is unordered.
33468
30348d30 33469@opindex m80387
d77de738 33470@opindex mhard-float
ddf6fe37
AA
33471@item -m80387
33472@itemx -mhard-float
d77de738
ML
33473Generate output containing 80387 instructions for floating point.
33474
d77de738
ML
33475@opindex no-80387
33476@opindex msoft-float
ddf6fe37
AA
33477@item -mno-80387
33478@itemx -msoft-float
d77de738
ML
33479Generate output containing library calls for floating point.
33480
33481@strong{Warning:} the requisite libraries are not part of GCC@.
33482Normally the facilities of the machine's usual C compiler are used, but
33483this cannot be done directly in cross-compilation. You must make your
33484own arrangements to provide suitable library functions for
33485cross-compilation.
33486
33487On machines where a function returns floating-point results in the 80387
33488register stack, some floating-point opcodes may be emitted even if
33489@option{-msoft-float} is used.
33490
d77de738
ML
33491@opindex mno-fp-ret-in-387
33492@opindex mfp-ret-in-387
ddf6fe37 33493@item -mno-fp-ret-in-387
d77de738
ML
33494Do not use the FPU registers for return values of functions.
33495
33496The usual calling convention has functions return values of types
33497@code{float} and @code{double} in an FPU register, even if there
33498is no FPU@. The idea is that the operating system should emulate
33499an FPU@.
33500
33501The option @option{-mno-fp-ret-in-387} causes such values to be returned
33502in ordinary CPU registers instead.
33503
d77de738
ML
33504@opindex mno-fancy-math-387
33505@opindex mfancy-math-387
ddf6fe37 33506@item -mno-fancy-math-387
d77de738
ML
33507Some 387 emulators do not support the @code{sin}, @code{cos} and
33508@code{sqrt} instructions for the 387. Specify this option to avoid
33509generating those instructions.
33510This option is overridden when @option{-march}
33511indicates that the target CPU always has an FPU and so the
33512instruction does not need emulation. These
33513instructions are not generated unless you also use the
33514@option{-funsafe-math-optimizations} switch.
33515
d77de738
ML
33516@opindex malign-double
33517@opindex mno-align-double
ddf6fe37
AA
33518@item -malign-double
33519@itemx -mno-align-double
d77de738
ML
33520Control whether GCC aligns @code{double}, @code{long double}, and
33521@code{long long} variables on a two-word boundary or a one-word
33522boundary. Aligning @code{double} variables on a two-word boundary
33523produces code that runs somewhat faster on a Pentium at the
33524expense of more memory.
33525
33526On x86-64, @option{-malign-double} is enabled by default.
33527
33528@strong{Warning:} if you use the @option{-malign-double} switch,
33529structures containing the above types are aligned differently than
33530the published application binary interface specifications for the x86-32
33531and are not binary compatible with structures in code compiled
33532without that switch.
33533
d77de738
ML
33534@opindex m96bit-long-double
33535@opindex m128bit-long-double
ddf6fe37
AA
33536@item -m96bit-long-double
33537@itemx -m128bit-long-double
d77de738
ML
33538These switches control the size of @code{long double} type. The x86-32
33539application binary interface specifies the size to be 96 bits,
33540so @option{-m96bit-long-double} is the default in 32-bit mode.
33541
33542Modern architectures (Pentium and newer) prefer @code{long double}
33543to be aligned to an 8- or 16-byte boundary. In arrays or structures
33544conforming to the ABI, this is not possible. So specifying
33545@option{-m128bit-long-double} aligns @code{long double}
33546to a 16-byte boundary by padding the @code{long double} with an additional
3354732-bit zero.
33548
33549In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
33550its ABI specifies that @code{long double} is aligned on 16-byte boundary.
33551
33552Notice that neither of these options enable any extra precision over the x87
33553standard of 80 bits for a @code{long double}.
33554
33555@strong{Warning:} if you override the default value for your target ABI, this
33556changes the size of
33557structures and arrays containing @code{long double} variables,
33558as well as modifying the function calling convention for functions taking
33559@code{long double}. Hence they are not binary-compatible
33560with code compiled without that switch.
33561
d77de738
ML
33562@opindex mlong-double-64
33563@opindex mlong-double-80
33564@opindex mlong-double-128
ddf6fe37
AA
33565@item -mlong-double-64
33566@itemx -mlong-double-80
33567@itemx -mlong-double-128
d77de738
ML
33568These switches control the size of @code{long double} type. A size
33569of 64 bits makes the @code{long double} type equivalent to the @code{double}
33570type. This is the default for 32-bit Bionic C library. A size
33571of 128 bits makes the @code{long double} type equivalent to the
33572@code{__float128} type. This is the default for 64-bit Bionic C library.
33573
33574@strong{Warning:} if you override the default value for your target ABI, this
33575changes the size of
33576structures and arrays containing @code{long double} variables,
33577as well as modifying the function calling convention for functions taking
33578@code{long double}. Hence they are not binary-compatible
33579with code compiled without that switch.
33580
d77de738 33581@opindex malign-data
ddf6fe37 33582@item -malign-data=@var{type}
d77de738
ML
33583Control how GCC aligns variables. Supported values for @var{type} are
33584@samp{compat} uses increased alignment value compatible uses GCC 4.8
33585and earlier, @samp{abi} uses alignment value as specified by the
33586psABI, and @samp{cacheline} uses increased alignment value to match
33587the cache line size. @samp{compat} is the default.
33588
d77de738 33589@opindex mlarge-data-threshold
ddf6fe37 33590@item -mlarge-data-threshold=@var{threshold}
1a64156c
UB
33591When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
33592objects larger than @var{threshold} are placed in large data sections. The
33593default is 65535.
d77de738 33594
d77de738 33595@opindex mrtd
ddf6fe37 33596@item -mrtd
d77de738
ML
33597Use a different function-calling convention, in which functions that
33598take a fixed number of arguments return with the @code{ret @var{num}}
33599instruction, which pops their arguments while returning. This saves one
33600instruction in the caller since there is no need to pop the arguments
33601there.
33602
33603You can specify that an individual function is called with this calling
33604sequence with the function attribute @code{stdcall}. You can also
33605override the @option{-mrtd} option by using the function attribute
33606@code{cdecl}. @xref{Function Attributes}.
33607
33608@strong{Warning:} this calling convention is incompatible with the one
33609normally used on Unix, so you cannot use it if you need to call
33610libraries compiled with the Unix compiler.
33611
33612Also, you must provide function prototypes for all functions that
33613take variable numbers of arguments (including @code{printf});
33614otherwise incorrect code is generated for calls to those
33615functions.
33616
33617In addition, seriously incorrect code results if you call a
33618function with too many arguments. (Normally, extra arguments are
33619harmlessly ignored.)
33620
d77de738 33621@opindex mregparm
ddf6fe37 33622@item -mregparm=@var{num}
d77de738
ML
33623Control how many registers are used to pass integer arguments. By
33624default, no registers are used to pass arguments, and at most 3
33625registers can be used. You can control this behavior for a specific
33626function by using the function attribute @code{regparm}.
33627@xref{Function Attributes}.
33628
33629@strong{Warning:} if you use this switch, and
33630@var{num} is nonzero, then you must build all modules with the same
33631value, including any libraries. This includes the system libraries and
33632startup modules.
33633
d77de738 33634@opindex msseregparm
ddf6fe37 33635@item -msseregparm
d77de738
ML
33636Use SSE register passing conventions for float and double arguments
33637and return values. You can control this behavior for a specific
33638function by using the function attribute @code{sseregparm}.
33639@xref{Function Attributes}.
33640
33641@strong{Warning:} if you use this switch then you must build all
33642modules with the same value, including any libraries. This includes
33643the system libraries and startup modules.
33644
d77de738 33645@opindex mvect8-ret-in-mem
ddf6fe37 33646@item -mvect8-ret-in-mem
d77de738
ML
33647Return 8-byte vectors in memory instead of MMX registers. This is the
33648default on VxWorks to match the ABI of the Sun Studio compilers until
33649version 12. @emph{Only} use this option if you need to remain
33650compatible with existing code produced by those previous compiler
33651versions or older versions of GCC@.
33652
d77de738
ML
33653@opindex mpc32
33654@opindex mpc64
33655@opindex mpc80
ddf6fe37
AA
33656@item -mpc32
33657@itemx -mpc64
33658@itemx -mpc80
d77de738
ML
33659
33660Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
33661is specified, the significands of results of floating-point operations are
33662rounded to 24 bits (single precision); @option{-mpc64} rounds the
33663significands of results of floating-point operations to 53 bits (double
33664precision) and @option{-mpc80} rounds the significands of results of
33665floating-point operations to 64 bits (extended double precision), which is
33666the default. When this option is used, floating-point operations in higher
33667precisions are not available to the programmer without setting the FPU
33668control word explicitly.
33669
33670Setting the rounding of floating-point operations to less than the default
3367180 bits can speed some programs by 2% or more. Note that some mathematical
33672libraries assume that extended-precision (80-bit) floating-point operations
33673are enabled by default; routines in such libraries could suffer significant
33674loss of accuracy, typically through so-called ``catastrophic cancellation'',
33675when this option is used to set the precision to less than extended precision.
33676
e54375d8 33677@opindex mdaz-ftz
ddf6fe37 33678@item -mdaz-ftz
e54375d8 33679
33680The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
33681are used to control floating-point calculations.SSE and AVX instructions
33682including scalar and vector instructions could benefit from enabling the FTZ
33683and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33684when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33685will set FTZ/DAZ flags even with @option{-shared}.
33686
d77de738 33687@opindex mstackrealign
ddf6fe37 33688@item -mstackrealign
d77de738
ML
33689Realign the stack at entry. On the x86, the @option{-mstackrealign}
33690option generates an alternate prologue and epilogue that realigns the
33691run-time stack if necessary. This supports mixing legacy codes that keep
336924-byte stack alignment with modern codes that keep 16-byte stack alignment for
33693SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33694applicable to individual functions.
33695
d77de738 33696@opindex mpreferred-stack-boundary
ddf6fe37 33697@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33698Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33699byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33700the default is 4 (16 bytes or 128 bits).
33701
33702@strong{Warning:} When generating code for the x86-64 architecture with
33703SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33704used to keep the stack boundary aligned to 8 byte boundary. Since
33705x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33706intended to be used in controlled environment where stack space is
33707important limitation. This option leads to wrong code when functions
33708compiled with 16 byte stack alignment (such as functions from a standard
33709library) are called with misaligned stack. In this case, SSE
33710instructions may lead to misaligned memory access traps. In addition,
33711variable arguments are handled incorrectly for 16 byte aligned
33712objects (including x87 long double and __int128), leading to wrong
33713results. You must build all modules with
33714@option{-mpreferred-stack-boundary=3}, including any libraries. This
33715includes the system libraries and startup modules.
33716
d77de738 33717@opindex mincoming-stack-boundary
ddf6fe37 33718@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33719Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33720boundary. If @option{-mincoming-stack-boundary} is not specified,
33721the one specified by @option{-mpreferred-stack-boundary} is used.
33722
33723On Pentium and Pentium Pro, @code{double} and @code{long double} values
33724should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33725suffer significant run time performance penalties. On Pentium III, the
33726Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33727properly if it is not 16-byte aligned.
33728
33729To ensure proper alignment of this values on the stack, the stack boundary
33730must be as aligned as that required by any value stored on the stack.
33731Further, every function must be generated such that it keeps the stack
33732aligned. Thus calling a function compiled with a higher preferred
33733stack boundary from a function compiled with a lower preferred stack
33734boundary most likely misaligns the stack. It is recommended that
33735libraries that use callbacks always use the default setting.
33736
33737This extra alignment does consume extra stack space, and generally
33738increases code size. Code that is sensitive to stack space usage, such
33739as embedded systems and operating system kernels, may want to reduce the
33740preferred alignment to @option{-mpreferred-stack-boundary=2}.
33741
33742@need 200
d77de738 33743@opindex mmmx
ddf6fe37 33744@item -mmmx
d77de738 33745@need 200
d77de738 33746@opindex msse
ddf6fe37 33747@itemx -msse
d77de738 33748@need 200
d77de738 33749@opindex msse2
ddf6fe37 33750@itemx -msse2
d77de738 33751@need 200
d77de738 33752@opindex msse3
ddf6fe37 33753@itemx -msse3
d77de738 33754@need 200
d77de738 33755@opindex mssse3
ddf6fe37 33756@itemx -mssse3
d77de738 33757@need 200
d77de738 33758@opindex msse4
ddf6fe37 33759@itemx -msse4
d77de738 33760@need 200
d77de738 33761@opindex msse4a
ddf6fe37 33762@itemx -msse4a
d77de738 33763@need 200
d77de738 33764@opindex msse4.1
ddf6fe37 33765@itemx -msse4.1
d77de738 33766@need 200
d77de738 33767@opindex msse4.2
ddf6fe37 33768@itemx -msse4.2
d77de738 33769@need 200
d77de738 33770@opindex mavx
ddf6fe37 33771@itemx -mavx
d77de738 33772@need 200
d77de738 33773@opindex mavx2
ddf6fe37 33774@itemx -mavx2
d77de738 33775@need 200
d77de738 33776@opindex mavx512f
ddf6fe37 33777@itemx -mavx512f
d77de738 33778@need 200
d77de738 33779@opindex mavx512pf
ddf6fe37 33780@itemx -mavx512pf
d77de738 33781@need 200
d77de738 33782@opindex mavx512er
ddf6fe37 33783@itemx -mavx512er
d77de738 33784@need 200
d77de738 33785@opindex mavx512cd
ddf6fe37 33786@itemx -mavx512cd
d77de738 33787@need 200
d77de738 33788@opindex mavx512vl
ddf6fe37 33789@itemx -mavx512vl
d77de738 33790@need 200
d77de738 33791@opindex mavx512bw
ddf6fe37 33792@itemx -mavx512bw
d77de738 33793@need 200
d77de738 33794@opindex mavx512dq
ddf6fe37 33795@itemx -mavx512dq
d77de738 33796@need 200
d77de738 33797@opindex mavx512ifma
ddf6fe37 33798@itemx -mavx512ifma
d77de738 33799@need 200
d77de738 33800@opindex mavx512vbmi
ddf6fe37 33801@itemx -mavx512vbmi
d77de738 33802@need 200
d77de738 33803@opindex msha
ddf6fe37 33804@itemx -msha
d77de738 33805@need 200
d77de738 33806@opindex maes
ddf6fe37 33807@itemx -maes
d77de738 33808@need 200
d77de738 33809@opindex mpclmul
ddf6fe37 33810@itemx -mpclmul
d77de738 33811@need 200
d77de738 33812@opindex mclflushopt
ddf6fe37 33813@itemx -mclflushopt
d77de738 33814@need 200
d77de738 33815@opindex mclwb
ddf6fe37 33816@itemx -mclwb
d77de738 33817@need 200
d77de738 33818@opindex mfsgsbase
ddf6fe37 33819@itemx -mfsgsbase
d77de738 33820@need 200
d77de738 33821@opindex mptwrite
ddf6fe37 33822@itemx -mptwrite
d77de738 33823@need 200
d77de738 33824@opindex mrdrnd
ddf6fe37 33825@itemx -mrdrnd
d77de738 33826@need 200
d77de738 33827@opindex mf16c
ddf6fe37 33828@itemx -mf16c
d77de738 33829@need 200
d77de738 33830@opindex mfma
ddf6fe37 33831@itemx -mfma
d77de738 33832@need 200
d77de738 33833@opindex mpconfig
ddf6fe37 33834@itemx -mpconfig
d77de738 33835@need 200
d77de738 33836@opindex mwbnoinvd
ddf6fe37 33837@itemx -mwbnoinvd
d77de738 33838@need 200
d77de738 33839@opindex mfma4
ddf6fe37 33840@itemx -mfma4
d77de738 33841@need 200
d77de738 33842@opindex mprfchw
ddf6fe37 33843@itemx -mprfchw
d77de738 33844@need 200
d77de738 33845@opindex mrdpid
ddf6fe37 33846@itemx -mrdpid
d77de738 33847@need 200
d77de738 33848@opindex mprefetchwt1
ddf6fe37 33849@itemx -mprefetchwt1
d77de738 33850@need 200
d77de738 33851@opindex mrdseed
ddf6fe37 33852@itemx -mrdseed
d77de738 33853@need 200
d77de738 33854@opindex msgx
ddf6fe37 33855@itemx -msgx
d77de738 33856@need 200
d77de738 33857@opindex mxop
ddf6fe37 33858@itemx -mxop
d77de738 33859@need 200
d77de738 33860@opindex mlwp
ddf6fe37 33861@itemx -mlwp
d77de738 33862@need 200
d77de738 33863@opindex m3dnow
ddf6fe37 33864@itemx -m3dnow
d77de738 33865@need 200
d77de738 33866@opindex m3dnowa
ddf6fe37 33867@itemx -m3dnowa
d77de738 33868@need 200
d77de738 33869@opindex mpopcnt
ddf6fe37 33870@itemx -mpopcnt
d77de738 33871@need 200
d77de738 33872@opindex mabm
ddf6fe37 33873@itemx -mabm
d77de738 33874@need 200
d77de738 33875@opindex madx
ddf6fe37 33876@itemx -madx
d77de738 33877@need 200
d77de738 33878@opindex mbmi
ddf6fe37 33879@itemx -mbmi
d77de738 33880@need 200
d77de738 33881@opindex mbmi2
ddf6fe37 33882@itemx -mbmi2
d77de738 33883@need 200
d77de738 33884@opindex mlzcnt
ddf6fe37 33885@itemx -mlzcnt
d77de738 33886@need 200
d77de738 33887@opindex mfxsr
ddf6fe37 33888@itemx -mfxsr
d77de738 33889@need 200
d77de738 33890@opindex mxsave
ddf6fe37 33891@itemx -mxsave
d77de738 33892@need 200
d77de738 33893@opindex mxsaveopt
ddf6fe37 33894@itemx -mxsaveopt
d77de738 33895@need 200
d77de738 33896@opindex mxsavec
ddf6fe37 33897@itemx -mxsavec
d77de738 33898@need 200
d77de738 33899@opindex mxsaves
ddf6fe37 33900@itemx -mxsaves
d77de738 33901@need 200
d77de738 33902@opindex mrtm
ddf6fe37 33903@itemx -mrtm
d77de738 33904@need 200
d77de738 33905@opindex mhle
ddf6fe37 33906@itemx -mhle
d77de738 33907@need 200
d77de738 33908@opindex mtbm
ddf6fe37 33909@itemx -mtbm
d77de738 33910@need 200
d77de738 33911@opindex mmwaitx
ddf6fe37 33912@itemx -mmwaitx
d77de738 33913@need 200
d77de738 33914@opindex mclzero
ddf6fe37 33915@itemx -mclzero
d77de738 33916@need 200
d77de738 33917@opindex mpku
ddf6fe37 33918@itemx -mpku
d77de738 33919@need 200
d77de738 33920@opindex mavx512vbmi2
ddf6fe37 33921@itemx -mavx512vbmi2
d77de738 33922@need 200
d77de738 33923@opindex mavx512bf16
ddf6fe37 33924@itemx -mavx512bf16
d77de738 33925@need 200
d77de738 33926@opindex mavx512fp16
ddf6fe37 33927@itemx -mavx512fp16
d77de738 33928@need 200
d77de738 33929@opindex mgfni
ddf6fe37 33930@itemx -mgfni
d77de738 33931@need 200
d77de738 33932@opindex mvaes
ddf6fe37 33933@itemx -mvaes
d77de738 33934@need 200
d77de738 33935@opindex mwaitpkg
ddf6fe37 33936@itemx -mwaitpkg
d77de738 33937@need 200
d77de738 33938@opindex mvpclmulqdq
ddf6fe37 33939@itemx -mvpclmulqdq
d77de738 33940@need 200
d77de738 33941@opindex mavx512bitalg
ddf6fe37 33942@itemx -mavx512bitalg
d77de738 33943@need 200
d77de738 33944@opindex mmovdiri
ddf6fe37 33945@itemx -mmovdiri
d77de738 33946@need 200
d77de738 33947@opindex mmovdir64b
ddf6fe37 33948@itemx -mmovdir64b
d77de738 33949@need 200
d77de738 33950@opindex menqcmd
d77de738 33951@opindex muintr
ddf6fe37
AA
33952@itemx -menqcmd
33953@itemx -muintr
d77de738 33954@need 200
d77de738 33955@opindex mtsxldtrk
ddf6fe37 33956@itemx -mtsxldtrk
d77de738 33957@need 200
d77de738 33958@opindex mavx512vpopcntdq
ddf6fe37 33959@itemx -mavx512vpopcntdq
d77de738 33960@need 200
d77de738 33961@opindex mavx512vp2intersect
ddf6fe37 33962@itemx -mavx512vp2intersect
d77de738 33963@need 200
d77de738 33964@opindex mavx5124fmaps
ddf6fe37 33965@itemx -mavx5124fmaps
d77de738 33966@need 200
d77de738 33967@opindex mavx512vnni
ddf6fe37 33968@itemx -mavx512vnni
d77de738 33969@need 200
d77de738 33970@opindex mavxvnni
ddf6fe37 33971@itemx -mavxvnni
d77de738 33972@need 200
d77de738 33973@opindex mavx5124vnniw
ddf6fe37 33974@itemx -mavx5124vnniw
d77de738 33975@need 200
d77de738 33976@opindex mcldemote
ddf6fe37 33977@itemx -mcldemote
d77de738 33978@need 200
d77de738 33979@opindex mserialize
ddf6fe37 33980@itemx -mserialize
d77de738 33981@need 200
d77de738 33982@opindex mamx-tile
ddf6fe37 33983@itemx -mamx-tile
d77de738 33984@need 200
d77de738 33985@opindex mamx-int8
ddf6fe37 33986@itemx -mamx-int8
d77de738 33987@need 200
d77de738 33988@opindex mamx-bf16
ddf6fe37 33989@itemx -mamx-bf16
d77de738 33990@need 200
d77de738 33991@opindex mhreset
d77de738 33992@opindex mkl
ddf6fe37
AA
33993@itemx -mhreset
33994@itemx -mkl
d77de738 33995@need 200
d77de738 33996@opindex mwidekl
ddf6fe37 33997@itemx -mwidekl
d77de738 33998@need 200
d77de738 33999@opindex mavxifma
ddf6fe37 34000@itemx -mavxifma
d77de738 34001@need 200
d77de738 34002@opindex mavxvnniint8
ddf6fe37 34003@itemx -mavxvnniint8
d77de738 34004@need 200
d77de738 34005@opindex mavxneconvert
ddf6fe37 34006@itemx -mavxneconvert
d77de738 34007@need 200
d77de738 34008@opindex mcmpccxadd
ddf6fe37 34009@itemx -mcmpccxadd
d77de738 34010@need 200
d77de738 34011@opindex mamx-fp16
ddf6fe37 34012@itemx -mamx-fp16
d77de738 34013@need 200
d77de738 34014@opindex mprefetchi
ddf6fe37 34015@itemx -mprefetchi
d77de738 34016@need 200
d77de738 34017@opindex mraoint
ddf6fe37 34018@itemx -mraoint
efa6a82b
HJ
34019@need 200
34020@opindex mamx-complex
34021@itemx -mamx-complex
1dbc1081
KL
34022@need 200
34023@opindex mavxvnniint16
34024@itemx -mavxvnniint16
8643bcba
HJ
34025@need 200
34026@opindex msm3
34027@itemx -msm3
86446132
HJ
34028@need 200
34029@opindex msha512
34030@itemx -msha512
37bdeb8f
HJ
34031@need 200
34032@opindex msm4
34033@itemx -msm4
e686416b
KL
34034@need 200
34035@opindex mapxf
34036@itemx -mapxf
5fbd91b1
HL
34037@need 200
34038@opindex musermsr
34039@itemx -musermsr
d77de738 34040These switches enable the use of instructions in the MMX, SSE,
d77de738
ML
34041AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
34042AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
34043WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
340443DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
34045XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
34046GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
34047ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 34048UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b 34049AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
5fbd91b1
HL
34050AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR or CLDEMOTE
34051extended instruction sets. Each has a corresponding @option{-mno-} option
34052to disable use of these instructions.
d77de738
ML
34053
34054These extensions are also available as built-in functions: see
34055@ref{x86 Built-in Functions}, for details of the functions enabled and
34056disabled by these switches.
34057
34058To generate SSE/SSE2 instructions automatically from floating-point
34059code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
34060
34061GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
34062generates new AVX instructions or AVX equivalence for all SSEx instructions
34063when needed.
34064
34065These options enable GCC to use these extended instructions in
34066generated code, even without @option{-mfpmath=sse}. Applications that
34067perform run-time CPU detection must compile separate files for each
34068supported architecture, using the appropriate flags. In particular,
34069the file containing the CPU detection code should be compiled without
34070these options.
34071
d77de738 34072@opindex mdump-tune-features
ddf6fe37 34073@item -mdump-tune-features
d77de738
ML
34074This option instructs GCC to dump the names of the x86 performance
34075tuning features and default settings. The names can be used in
34076@option{-mtune-ctrl=@var{feature-list}}.
34077
d77de738 34078@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 34079@item -mtune-ctrl=@var{feature-list}
d77de738
ML
34080This option is used to do fine grain control of x86 code generation features.
34081@var{feature-list} is a comma separated list of @var{feature} names. See also
34082@option{-mdump-tune-features}. When specified, the @var{feature} is turned
34083on if it is not preceded with @samp{^}, otherwise, it is turned off.
34084@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
34085developers. Using it may lead to code paths not covered by testing and can
34086potentially result in compiler ICEs or runtime errors.
34087
d77de738 34088@opindex mno-default
ddf6fe37 34089@item -mno-default
d77de738
ML
34090This option instructs GCC to turn off all tunable features. See also
34091@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
34092
d77de738 34093@opindex mcld
ddf6fe37 34094@item -mcld
d77de738
ML
34095This option instructs GCC to emit a @code{cld} instruction in the prologue
34096of functions that use string instructions. String instructions depend on
34097the DF flag to select between autoincrement or autodecrement mode. While the
34098ABI specifies the DF flag to be cleared on function entry, some operating
34099systems violate this specification by not clearing the DF flag in their
34100exception dispatchers. The exception handler can be invoked with the DF flag
34101set, which leads to wrong direction mode when string instructions are used.
34102This option can be enabled by default on 32-bit x86 targets by configuring
34103GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
34104instructions can be suppressed with the @option{-mno-cld} compiler option
34105in this case.
34106
d77de738 34107@opindex mvzeroupper
ddf6fe37 34108@item -mvzeroupper
d77de738
ML
34109This option instructs GCC to emit a @code{vzeroupper} instruction
34110before a transfer of control flow out of the function to minimize
34111the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
34112intrinsics.
34113
d77de738 34114@opindex mprefer-avx128
ddf6fe37 34115@item -mprefer-avx128
d77de738
ML
34116This option instructs GCC to use 128-bit AVX instructions instead of
34117256-bit AVX instructions in the auto-vectorizer.
34118
d77de738 34119@opindex mprefer-vector-width
ddf6fe37 34120@item -mprefer-vector-width=@var{opt}
d77de738
ML
34121This option instructs GCC to use @var{opt}-bit vector width in instructions
34122instead of default on the selected platform.
34123
ad5b757d
UB
34124@opindex mpartial-vector-fp-math
34125@item -mpartial-vector-fp-math
34126This option enables GCC to generate floating-point operations that might
34127affect the set of floating-point status flags on partial vectors, where
34128vector elements reside in the low part of the 128-bit SSE register. Unless
34129@option{-fno-trapping-math} is specified, the compiler guarantees correct
34130behavior by sanitizing all input operands to have zeroes in the unused
34131upper part of the vector register. Note that by using built-in functions
34132or inline assembly with partial vector arguments, NaNs, denormal or invalid
34133values can leak into the upper part of the vector, causing possible
34134performance issues when @option{-fno-trapping-math} is in effect. These
34135issues can be mitigated by manually sanitizing the upper part of the partial
34136vector argument register or by using @option{-mdaz-ftz} to set
34137denormals-are-zero (DAZ) flag in the MXCSR register.
34138
34139This option is enabled by default.
34140
d77de738 34141@opindex mmove-max
ddf6fe37 34142@item -mmove-max=@var{bits}
d77de738
ML
34143This option instructs GCC to set the maximum number of bits can be
34144moved from memory to memory efficiently to @var{bits}. The valid
34145@var{bits} are 128, 256 and 512.
34146
d77de738 34147@opindex mstore-max
ddf6fe37 34148@item -mstore-max=@var{bits}
d77de738
ML
34149This option instructs GCC to set the maximum number of bits can be
34150stored to memory efficiently to @var{bits}. The valid @var{bits} are
34151128, 256 and 512.
34152
34153@table @samp
34154@item none
34155No extra limitations applied to GCC other than defined by the selected platform.
34156
34157@item 128
34158Prefer 128-bit vector width for instructions.
34159
34160@item 256
34161Prefer 256-bit vector width for instructions.
34162
34163@item 512
34164Prefer 512-bit vector width for instructions.
34165@end table
34166
d77de738 34167@opindex mcx16
ddf6fe37 34168@item -mcx16
d77de738
ML
34169This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
34170code to implement compare-and-exchange operations on 16-byte aligned 128-bit
34171objects. This is useful for atomic updates of data structures exceeding one
34172machine word in size. The compiler uses this instruction to implement
34173@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
34174128-bit integers, a library call is always used.
34175
d77de738 34176@opindex msahf
ddf6fe37 34177@item -msahf
d77de738
ML
34178This option enables generation of @code{SAHF} instructions in 64-bit code.
34179Early Intel Pentium 4 CPUs with Intel 64 support,
34180prior to the introduction of Pentium 4 G1 step in December 2005,
34181lacked the @code{LAHF} and @code{SAHF} instructions
34182which are supported by AMD64.
34183These are load and store instructions, respectively, for certain status flags.
34184In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
34185@code{drem}, and @code{remainder} built-in functions;
34186see @ref{Other Builtins} for details.
34187
d77de738 34188@opindex mmovbe
ddf6fe37 34189@item -mmovbe
d77de738
ML
34190This option enables use of the @code{movbe} instruction to implement
34191@code{__builtin_bswap32} and @code{__builtin_bswap64}.
34192
d77de738 34193@opindex mshstk
ddf6fe37 34194@item -mshstk
d77de738
ML
34195The @option{-mshstk} option enables shadow stack built-in functions
34196from x86 Control-flow Enforcement Technology (CET).
34197
d77de738 34198@opindex mcrc32
ddf6fe37 34199@item -mcrc32
d77de738
ML
34200This option enables built-in functions @code{__builtin_ia32_crc32qi},
34201@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
34202@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
34203
d77de738 34204@opindex mmwait
ddf6fe37 34205@item -mmwait
d77de738
ML
34206This option enables built-in functions @code{__builtin_ia32_monitor},
34207and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
34208@code{mwait} machine instructions.
34209
d77de738 34210@opindex mrecip
ddf6fe37 34211@item -mrecip
d77de738
ML
34212This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
34213(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
34214with an additional Newton-Raphson step
34215to increase precision instead of @code{DIVSS} and @code{SQRTSS}
34216(and their vectorized
34217variants) for single-precision floating-point arguments. These instructions
34218are generated only when @option{-funsafe-math-optimizations} is enabled
34219together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
34220Note that while the throughput of the sequence is higher than the throughput
34221of the non-reciprocal instruction, the precision of the sequence can be
34222decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
34223
34224Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
34225(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
34226combination), and doesn't need @option{-mrecip}.
34227
34228Also note that GCC emits the above sequence with additional Newton-Raphson step
34229for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
34230already with @option{-ffast-math} (or the above option combination), and
34231doesn't need @option{-mrecip}.
34232
d77de738 34233@opindex mrecip=opt
ddf6fe37 34234@item -mrecip=@var{opt}
d77de738
ML
34235This option controls which reciprocal estimate instructions
34236may be used. @var{opt} is a comma-separated list of options, which may
34237be preceded by a @samp{!} to invert the option:
34238
34239@table @samp
34240@item all
34241Enable all estimate instructions.
34242
34243@item default
34244Enable the default instructions, equivalent to @option{-mrecip}.
34245
34246@item none
34247Disable all estimate instructions, equivalent to @option{-mno-recip}.
34248
34249@item div
34250Enable the approximation for scalar division.
34251
34252@item vec-div
34253Enable the approximation for vectorized division.
34254
34255@item sqrt
34256Enable the approximation for scalar square root.
34257
34258@item vec-sqrt
34259Enable the approximation for vectorized square root.
34260@end table
34261
34262So, for example, @option{-mrecip=all,!sqrt} enables
34263all of the reciprocal approximations, except for square root.
34264
d77de738 34265@opindex mveclibabi
ddf6fe37 34266@item -mveclibabi=@var{type}
d77de738
ML
34267Specifies the ABI type to use for vectorizing intrinsics using an
34268external library. Supported values for @var{type} are @samp{svml}
34269for the Intel short
34270vector math library and @samp{acml} for the AMD math core library.
34271To use this option, both @option{-ftree-vectorize} and
34272@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
34273ABI-compatible library must be specified at link time.
34274
34275GCC currently emits calls to @code{vmldExp2},
34276@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
34277@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
34278@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
34279@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
34280@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
34281@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
34282@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
34283@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
34284@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
34285function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
34286@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
34287@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
34288@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
34289@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
34290when @option{-mveclibabi=acml} is used.
34291
d77de738 34292@opindex mabi
ddf6fe37 34293@item -mabi=@var{name}
d77de738
ML
34294Generate code for the specified calling convention. Permissible values
34295are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
34296@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
34297ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
34298You can control this behavior for specific functions by
34299using the function attributes @code{ms_abi} and @code{sysv_abi}.
34300@xref{Function Attributes}.
34301
d77de738 34302@opindex mforce-indirect-call
ddf6fe37 34303@item -mforce-indirect-call
d77de738
ML
34304Force all calls to functions to be indirect. This is useful
34305when using Intel Processor Trace where it generates more precise timing
34306information for function calls.
34307
d77de738 34308@opindex mmanual-endbr
ddf6fe37 34309@item -mmanual-endbr
d77de738
ML
34310Insert ENDBR instruction at function entry only via the @code{cf_check}
34311function attribute. This is useful when used with the option
34312@option{-fcf-protection=branch} to control ENDBR insertion at the
34313function entry.
34314
d77de738 34315@opindex mcet-switch
ddf6fe37 34316@item -mcet-switch
d77de738
ML
34317By default, CET instrumentation is turned off on switch statements that
34318use a jump table and indirect branch track is disabled. Since jump
34319tables are stored in read-only memory, this does not result in a direct
34320loss of hardening. But if the jump table index is attacker-controlled,
34321the indirect jump may not be constrained by CET. This option turns on
34322CET instrumentation to enable indirect branch track for switch statements
34323with jump tables which leads to the jump targets reachable via any indirect
34324jumps.
34325
d77de738
ML
34326@opindex mcall-ms2sysv-xlogues
34327@opindex mno-call-ms2sysv-xlogues
ddf6fe37 34328@item -mcall-ms2sysv-xlogues
d77de738
ML
34329Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
34330System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
34331default, the code for saving and restoring these registers is emitted inline,
34332resulting in fairly lengthy prologues and epilogues. Using
34333@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
34334use stubs in the static portion of libgcc to perform these saves and restores,
34335thus reducing function size at the cost of a few extra instructions.
34336
d77de738 34337@opindex mtls-dialect
ddf6fe37 34338@item -mtls-dialect=@var{type}
d77de738
ML
34339Generate code to access thread-local storage using the @samp{gnu} or
34340@samp{gnu2} conventions. @samp{gnu} is the conservative default;
34341@samp{gnu2} is more efficient, but it may add compile- and run-time
34342requirements that cannot be satisfied on all systems.
34343
d77de738
ML
34344@opindex mpush-args
34345@opindex mno-push-args
ddf6fe37
AA
34346@item -mpush-args
34347@itemx -mno-push-args
d77de738
ML
34348Use PUSH operations to store outgoing parameters. This method is shorter
34349and usually equally fast as method using SUB/MOV operations and is enabled
34350by default. In some cases disabling it may improve performance because of
34351improved scheduling and reduced dependencies.
34352
d77de738 34353@opindex maccumulate-outgoing-args
ddf6fe37 34354@item -maccumulate-outgoing-args
d77de738
ML
34355If enabled, the maximum amount of space required for outgoing arguments is
34356computed in the function prologue. This is faster on most modern CPUs
34357because of reduced dependencies, improved scheduling and reduced stack usage
34358when the preferred stack boundary is not equal to 2. The drawback is a notable
34359increase in code size. This switch implies @option{-mno-push-args}.
34360
d77de738 34361@opindex mthreads
ddf6fe37 34362@item -mthreads
d77de738
ML
34363Support thread-safe exception handling on MinGW. Programs that rely
34364on thread-safe exception handling must compile and link all code with the
34365@option{-mthreads} option. When compiling, @option{-mthreads} defines
34366@option{-D_MT}; when linking, it links in a special thread helper library
34367@option{-lmingwthrd} which cleans up per-thread exception-handling data.
34368
d77de738
ML
34369@opindex mms-bitfields
34370@opindex mno-ms-bitfields
ddf6fe37
AA
34371@item -mms-bitfields
34372@itemx -mno-ms-bitfields
d77de738
ML
34373
34374Enable/disable bit-field layout compatible with the native Microsoft
34375Windows compiler.
34376
34377If @code{packed} is used on a structure, or if bit-fields are used,
34378it may be that the Microsoft ABI lays out the structure differently
34379than the way GCC normally does. Particularly when moving packed
34380data between functions compiled with GCC and the native Microsoft compiler
34381(either via function call or as data in a file), it may be necessary to access
34382either format.
34383
34384This option is enabled by default for Microsoft Windows
34385targets. This behavior can also be controlled locally by use of variable
34386or type attributes. For more information, see @ref{x86 Variable Attributes}
34387and @ref{x86 Type Attributes}.
34388
34389The Microsoft structure layout algorithm is fairly simple with the exception
34390of the bit-field packing.
34391The padding and alignment of members of structures and whether a bit-field
34392can straddle a storage-unit boundary are determine by these rules:
34393
34394@enumerate
34395@item Structure members are stored sequentially in the order in which they are
34396declared: the first member has the lowest memory address and the last member
34397the highest.
34398
34399@item Every data object has an alignment requirement. The alignment requirement
34400for all data except structures, unions, and arrays is either the size of the
34401object or the current packing size (specified with either the
34402@code{aligned} attribute or the @code{pack} pragma),
34403whichever is less. For structures, unions, and arrays,
34404the alignment requirement is the largest alignment requirement of its members.
34405Every object is allocated an offset so that:
34406
34407@smallexample
34408offset % alignment_requirement == 0
34409@end smallexample
34410
34411@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
34412unit if the integral types are the same size and if the next bit-field fits
34413into the current allocation unit without crossing the boundary imposed by the
34414common alignment requirements of the bit-fields.
34415@end enumerate
34416
34417MSVC interprets zero-length bit-fields in the following ways:
34418
34419@enumerate
34420@item If a zero-length bit-field is inserted between two bit-fields that
34421are normally coalesced, the bit-fields are not coalesced.
34422
34423For example:
34424
34425@smallexample
34426struct
34427 @{
34428 unsigned long bf_1 : 12;
34429 unsigned long : 0;
34430 unsigned long bf_2 : 12;
34431 @} t1;
34432@end smallexample
34433
34434@noindent
34435The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
34436zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
34437
34438@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
34439alignment of the zero-length bit-field is greater than the member that follows it,
34440@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
34441
34442For example:
34443
34444@smallexample
34445struct
34446 @{
34447 char foo : 4;
34448 short : 0;
34449 char bar;
34450 @} t2;
34451
34452struct
34453 @{
34454 char foo : 4;
34455 short : 0;
34456 double bar;
34457 @} t3;
34458@end smallexample
34459
34460@noindent
34461For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
34462Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
34463bit-field does not affect the alignment of @code{bar} or, as a result, the size
34464of the structure.
34465
34466Taking this into account, it is important to note the following:
34467
34468@enumerate
34469@item If a zero-length bit-field follows a normal bit-field, the type of the
34470zero-length bit-field may affect the alignment of the structure as whole. For
34471example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
34472normal bit-field, and is of type short.
34473
34474@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
34475still affect the alignment of the structure:
34476
34477@smallexample
34478struct
34479 @{
34480 char foo : 6;
34481 long : 0;
34482 @} t4;
34483@end smallexample
34484
34485@noindent
34486Here, @code{t4} takes up 4 bytes.
34487@end enumerate
34488
34489@item Zero-length bit-fields following non-bit-field members are ignored:
34490
34491@smallexample
34492struct
34493 @{
34494 char foo;
34495 long : 0;
34496 char bar;
34497 @} t5;
34498@end smallexample
34499
34500@noindent
34501Here, @code{t5} takes up 2 bytes.
34502@end enumerate
34503
34504
d77de738
ML
34505@opindex mno-align-stringops
34506@opindex malign-stringops
ddf6fe37 34507@item -mno-align-stringops
d77de738
ML
34508Do not align the destination of inlined string operations. This switch reduces
34509code size and improves performance in case the destination is already aligned,
34510but GCC doesn't know about it.
34511
d77de738 34512@opindex minline-all-stringops
ddf6fe37 34513@item -minline-all-stringops
d77de738
ML
34514By default GCC inlines string operations only when the destination is
34515known to be aligned to least a 4-byte boundary.
34516This enables more inlining and increases code
34517size, but may improve performance of code that depends on fast
34518@code{memcpy} and @code{memset} for short lengths.
34519The option enables inline expansion of @code{strlen} for all
34520pointer alignments.
34521
d77de738 34522@opindex minline-stringops-dynamically
ddf6fe37 34523@item -minline-stringops-dynamically
d77de738
ML
34524For string operations of unknown size, use run-time checks with
34525inline code for small blocks and a library call for large blocks.
34526
d77de738 34527@opindex mstringop-strategy=@var{alg}
ddf6fe37 34528@item -mstringop-strategy=@var{alg}
d77de738
ML
34529Override the internal decision heuristic for the particular algorithm to use
34530for inlining string operations. The allowed values for @var{alg} are:
34531
34532@table @samp
34533@item rep_byte
34534@itemx rep_4byte
34535@itemx rep_8byte
34536Expand using i386 @code{rep} prefix of the specified size.
34537
34538@item byte_loop
34539@itemx loop
34540@itemx unrolled_loop
34541Expand into an inline loop.
34542
34543@item libcall
34544Always use a library call.
34545@end table
34546
d77de738 34547@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 34548@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
34549Override the internal decision heuristic to decide if @code{__builtin_memcpy}
34550should be inlined and what inline algorithm to use when the expected size
34551of the copy operation is known. @var{strategy}
34552is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
34553@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
34554the max byte size with which inline algorithm @var{alg} is allowed. For the last
34555triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
34556in the list must be specified in increasing order. The minimal byte size for
34557@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
34558preceding range.
34559
d77de738 34560@opindex mmemset-strategy=@var{strategy}
ddf6fe37 34561@item -mmemset-strategy=@var{strategy}
d77de738
ML
34562The option is similar to @option{-mmemcpy-strategy=} except that it is to control
34563@code{__builtin_memset} expansion.
34564
d77de738 34565@opindex momit-leaf-frame-pointer
ddf6fe37 34566@item -momit-leaf-frame-pointer
d77de738
ML
34567Don't keep the frame pointer in a register for leaf functions. This
34568avoids the instructions to save, set up, and restore frame pointers and
34569makes an extra register available in leaf functions. The option
34570@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
34571which might make debugging harder.
34572
ddf6fe37 34573@opindex mtls-direct-seg-refs
d77de738
ML
34574@item -mtls-direct-seg-refs
34575@itemx -mno-tls-direct-seg-refs
d77de738
ML
34576Controls whether TLS variables may be accessed with offsets from the
34577TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
34578or whether the thread base pointer must be added. Whether or not this
34579is valid depends on the operating system, and whether it maps the
34580segment to cover the entire TLS area.
34581
34582For systems that use the GNU C Library, the default is on.
34583
ddf6fe37 34584@opindex msse2avx
d77de738
ML
34585@item -msse2avx
34586@itemx -mno-sse2avx
d77de738
ML
34587Specify that the assembler should encode SSE instructions with VEX
34588prefix. The option @option{-mavx} turns this on by default.
34589
ddf6fe37 34590@opindex mfentry
d77de738
ML
34591@item -mfentry
34592@itemx -mno-fentry
d77de738
ML
34593If profiling is active (@option{-pg}), put the profiling
34594counter call before the prologue.
34595Note: On x86 architectures the attribute @code{ms_hook_prologue}
34596isn't possible at the moment for @option{-mfentry} and @option{-pg}.
34597
ddf6fe37 34598@opindex mrecord-mcount
d77de738
ML
34599@item -mrecord-mcount
34600@itemx -mno-record-mcount
d77de738
ML
34601If profiling is active (@option{-pg}), generate a __mcount_loc section
34602that contains pointers to each profiling call. This is useful for
34603automatically patching and out calls.
34604
ddf6fe37 34605@opindex mnop-mcount
d77de738
ML
34606@item -mnop-mcount
34607@itemx -mno-nop-mcount
d77de738
ML
34608If profiling is active (@option{-pg}), generate the calls to
34609the profiling functions as NOPs. This is useful when they
34610should be patched in later dynamically. This is likely only
34611useful together with @option{-mrecord-mcount}.
34612
d77de738 34613@opindex minstrument-return
ddf6fe37 34614@item -minstrument-return=@var{type}
d77de738
ML
34615Instrument function exit in -pg -mfentry instrumented functions with
34616call to specified function. This only instruments true returns ending
34617with ret, but not sibling calls ending with jump. Valid types
34618are @var{none} to not instrument, @var{call} to generate a call to __return__,
34619or @var{nop5} to generate a 5 byte nop.
34620
ddf6fe37 34621@opindex mrecord-return
d77de738
ML
34622@item -mrecord-return
34623@itemx -mno-record-return
d77de738
ML
34624Generate a __return_loc section pointing to all return instrumentation code.
34625
d77de738 34626@opindex mfentry-name
ddf6fe37 34627@item -mfentry-name=@var{name}
d77de738
ML
34628Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
34629
d77de738 34630@opindex mfentry-section
ddf6fe37 34631@item -mfentry-section=@var{name}
d77de738
ML
34632Set name of section to record -mrecord-mcount calls (default __mcount_loc).
34633
ddf6fe37 34634@opindex mskip-rax-setup
d77de738
ML
34635@item -mskip-rax-setup
34636@itemx -mno-skip-rax-setup
d77de738
ML
34637When generating code for the x86-64 architecture with SSE extensions
34638disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
34639register when there are no variable arguments passed in vector registers.
34640
34641@strong{Warning:} Since RAX register is used to avoid unnecessarily
34642saving vector registers on stack when passing variable arguments, the
34643impacts of this option are callees may waste some stack space,
34644misbehave or jump to a random location. GCC 4.4 or newer don't have
34645those issues, regardless the RAX register value.
34646
ddf6fe37 34647@opindex m8bit-idiv
d77de738
ML
34648@item -m8bit-idiv
34649@itemx -mno-8bit-idiv
d77de738
ML
34650On some processors, like Intel Atom, 8-bit unsigned integer divide is
34651much faster than 32-bit/64-bit integer divide. This option generates a
34652run-time check. If both dividend and divisor are within range of 0
34653to 255, 8-bit unsigned integer divide is used instead of
3465432-bit/64-bit integer divide.
34655
d77de738
ML
34656@opindex mavx256-split-unaligned-load
34657@opindex mavx256-split-unaligned-store
ddf6fe37
AA
34658@item -mavx256-split-unaligned-load
34659@itemx -mavx256-split-unaligned-store
d77de738
ML
34660Split 32-byte AVX unaligned load and store.
34661
d77de738
ML
34662@opindex mstack-protector-guard
34663@opindex mstack-protector-guard-reg
34664@opindex mstack-protector-guard-offset
ddf6fe37
AA
34665@item -mstack-protector-guard=@var{guard}
34666@itemx -mstack-protector-guard-reg=@var{reg}
34667@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
34668Generate stack protection code using canary at @var{guard}. Supported
34669locations are @samp{global} for global canary or @samp{tls} for per-thread
34670canary in the TLS block (the default). This option has effect only when
34671@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
34672
34673With the latter choice the options
34674@option{-mstack-protector-guard-reg=@var{reg}} and
34675@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
34676which segment register (@code{%fs} or @code{%gs}) to use as base register
34677for reading the canary, and from what offset from that base register.
34678The default for those is as specified in the relevant ABI.
34679
d77de738 34680@opindex mgeneral-regs-only
ddf6fe37 34681@item -mgeneral-regs-only
d77de738
ML
34682Generate code that uses only the general-purpose registers. This
34683prevents the compiler from using floating-point, vector, mask and bound
34684registers.
34685
d77de738 34686@opindex mrelax-cmpxchg-loop
ddf6fe37 34687@item -mrelax-cmpxchg-loop
85966f0d
AM
34688When emitting a compare-and-swap loop for @ref{__sync Builtins}
34689and @ref{__atomic Builtins} lacking a native instruction, optimize
34690for the highly contended case by issuing an atomic load before the
34691@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
34692to save CPU power when restarting the loop.
d77de738 34693
d77de738 34694@opindex mindirect-branch
ddf6fe37 34695@item -mindirect-branch=@var{choice}
d77de738
ML
34696Convert indirect call and jump with @var{choice}. The default is
34697@samp{keep}, which keeps indirect call and jump unmodified.
34698@samp{thunk} converts indirect call and jump to call and return thunk.
34699@samp{thunk-inline} converts indirect call and jump to inlined call
34700and return thunk. @samp{thunk-extern} converts indirect call and jump
34701to external call and return thunk provided in a separate object file.
34702You can control this behavior for a specific function by using the
34703function attribute @code{indirect_branch}. @xref{Function Attributes}.
34704
34705Note that @option{-mcmodel=large} is incompatible with
34706@option{-mindirect-branch=thunk} and
34707@option{-mindirect-branch=thunk-extern} since the thunk function may
34708not be reachable in the large code model.
34709
34710Note that @option{-mindirect-branch=thunk-extern} is compatible with
34711@option{-fcf-protection=branch} since the external thunk can be made
34712to enable control-flow check.
34713
d77de738 34714@opindex mfunction-return
ddf6fe37 34715@item -mfunction-return=@var{choice}
d77de738
ML
34716Convert function return with @var{choice}. The default is @samp{keep},
34717which keeps function return unmodified. @samp{thunk} converts function
34718return to call and return thunk. @samp{thunk-inline} converts function
34719return to inlined call and return thunk. @samp{thunk-extern} converts
34720function return to external call and return thunk provided in a separate
34721object file. You can control this behavior for a specific function by
34722using the function attribute @code{function_return}.
34723@xref{Function Attributes}.
34724
34725Note that @option{-mindirect-return=thunk-extern} is compatible with
34726@option{-fcf-protection=branch} since the external thunk can be made
34727to enable control-flow check.
34728
34729Note that @option{-mcmodel=large} is incompatible with
34730@option{-mfunction-return=thunk} and
34731@option{-mfunction-return=thunk-extern} since the thunk function may
34732not be reachable in the large code model.
34733
34734
d77de738 34735@opindex mindirect-branch-register
ddf6fe37 34736@item -mindirect-branch-register
d77de738
ML
34737Force indirect call and jump via register.
34738
d77de738 34739@opindex mharden-sls
ddf6fe37 34740@item -mharden-sls=@var{choice}
d77de738
ML
34741Generate code to mitigate against straight line speculation (SLS) with
34742@var{choice}. The default is @samp{none} which disables all SLS
34743hardening. @samp{return} enables SLS hardening for function returns.
34744@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34745@samp{all} enables all SLS hardening.
34746
d77de738 34747@opindex mindirect-branch-cs-prefix
ddf6fe37 34748@item -mindirect-branch-cs-prefix
d77de738
ML
34749Add CS prefix to call and jmp to indirect thunk with branch target in
34750r8-r15 registers so that the call and jmp instruction length is 6 bytes
34751to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34752@samp{lfence; jmp *%r8-r15} at run-time.
34753
34754@end table
34755
34756These @samp{-m} switches are supported in addition to the above
34757on x86-64 processors in 64-bit environments.
34758
34759@table @gcctabopt
d77de738
ML
34760@opindex m32
34761@opindex m64
34762@opindex mx32
34763@opindex m16
34764@opindex miamcu
ddf6fe37
AA
34765@item -m32
34766@itemx -m64
34767@itemx -mx32
34768@itemx -m16
34769@itemx -miamcu
d77de738
ML
34770Generate code for a 16-bit, 32-bit or 64-bit environment.
34771The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34772to 32 bits, and
eeb92704 34773generates code that runs in 32-bit mode.
d77de738
ML
34774
34775The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34776types to 64 bits, and generates code for the x86-64 architecture.
34777For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34778and @option{-mdynamic-no-pic} options.
34779
34780The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34781to 32 bits, and
34782generates code for the x86-64 architecture.
34783
34784The @option{-m16} option is the same as @option{-m32}, except for that
34785it outputs the @code{.code16gcc} assembly directive at the beginning of
34786the assembly output so that the binary can run in 16-bit mode.
34787
34788The @option{-miamcu} option generates code which conforms to Intel MCU
34789psABI. It requires the @option{-m32} option to be turned on.
34790
d77de738
ML
34791@opindex mno-red-zone
34792@opindex mred-zone
ddf6fe37 34793@item -mno-red-zone
d77de738
ML
34794Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34795by the x86-64 ABI; it is a 128-byte area beyond the location of the
34796stack pointer that is not modified by signal or interrupt handlers
34797and therefore can be used for temporary data without adjusting the stack
34798pointer. The flag @option{-mno-red-zone} disables this red zone.
34799
d77de738 34800@opindex mcmodel=small
ddf6fe37 34801@item -mcmodel=small
d77de738
ML
34802Generate code for the small code model: the program and its symbols must
34803be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34804Programs can be statically or dynamically linked. This is the default
34805code model.
34806
d77de738 34807@opindex mcmodel=kernel
ddf6fe37 34808@item -mcmodel=kernel
d77de738
ML
34809Generate code for the kernel code model. The kernel runs in the
34810negative 2 GB of the address space.
34811This model has to be used for Linux kernel code.
34812
d77de738 34813@opindex mcmodel=medium
ddf6fe37 34814@item -mcmodel=medium
d77de738
ML
34815Generate code for the medium model: the program is linked in the lower 2
34816GB of the address space. Small symbols are also placed there. Symbols
34817with sizes larger than @option{-mlarge-data-threshold} are put into
34818large data or BSS sections and can be located above 2GB. Programs can
34819be statically or dynamically linked.
34820
d77de738 34821@opindex mcmodel=large
ddf6fe37 34822@item -mcmodel=large
d77de738
ML
34823Generate code for the large model. This model makes no assumptions
34824about addresses and sizes of sections.
34825
d77de738 34826@opindex maddress-mode=long
ddf6fe37 34827@item -maddress-mode=long
d77de738
ML
34828Generate code for long address mode. This is only supported for 64-bit
34829and x32 environments. It is the default address mode for 64-bit
34830environments.
34831
d77de738 34832@opindex maddress-mode=short
ddf6fe37 34833@item -maddress-mode=short
d77de738
ML
34834Generate code for short address mode. This is only supported for 32-bit
34835and x32 environments. It is the default address mode for 32-bit and
34836x32 environments.
34837
ddf6fe37 34838@opindex mneeded
d77de738
ML
34839@item -mneeded
34840@itemx -mno-needed
d77de738
ML
34841Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34842indicate the micro-architecture ISA level required to execute the binary.
34843
d77de738
ML
34844@opindex mno-direct-extern-access
34845@opindex mdirect-extern-access
ddf6fe37 34846@item -mno-direct-extern-access
d77de738
ML
34847Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34848to access external symbols. With @option{-fpic} or @option{-fPIC},
34849treat access to protected symbols as local symbols. The default is
34850@option{-mdirect-extern-access}.
34851
34852@strong{Warning:} shared libraries compiled with
34853@option{-mno-direct-extern-access} and executable compiled with
34854@option{-mdirect-extern-access} may not be binary compatible if
34855protected symbols are used in shared libraries and executable.
ce51e843 34856
ce51e843
ML
34857@opindex munroll-only-small-loops
34858@opindex mno-unroll-only-small-loops
ddf6fe37 34859@item -munroll-only-small-loops
ce51e843
ML
34860Controls conservative small loop unrolling. It is default enabled by
34861O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34862-f[no-]unroll-[all-]loops would disable this flag to avoid any
34863unintended unrolling behavior that user does not want.
bb576017 34864
bb576017 34865@opindex mlam
ddf6fe37 34866@item -mlam=@var{choice}
bb576017 34867LAM(linear-address masking) allows special bits in the pointer to be used
34868for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34869positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34870positions 62:57 can be used for metadata.
d77de738
ML
34871@end table
34872
34873@node x86 Windows Options
34874@subsection x86 Windows Options
34875@cindex x86 Windows Options
34876@cindex Windows Options for x86
34877
34878These additional options are available for Microsoft Windows targets:
34879
34880@table @gcctabopt
d77de738 34881@opindex mconsole
ddf6fe37 34882@item -mconsole
d77de738
ML
34883This option
34884specifies that a console application is to be generated, by
34885instructing the linker to set the PE header subsystem type
34886required for console applications.
34887This option is available for Cygwin and MinGW targets and is
34888enabled by default on those targets.
34889
453cb585
PR
34890@opindex mcrtdll
34891@item -mcrtdll=@var{library}
34892Preprocess, compile or link with specified C RunTime DLL @var{library}.
34893This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}
34894and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose
34895start file for CRT @var{library} and link with CRT @var{library}.
34896Recognized CRT library names for proprocessor are:
34897@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40},
34898@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90},
34899@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}.
34900If this options is not specified then the default MinGW import library
34901@code{msvcrt} is used for linking and no other adjustment for
34902preprocessor is done. MinGW import library @code{msvcrt} is just a
34903symlink to (or a copy of) another MinGW CRT import library
34904chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
34905is for Windows system CRT DLL library @code{msvcrt.dll} and
34906in most cases is the default MinGW import library.
34907Generally speaking, changing the CRT DLL requires recompiling
34908the entire MinGW CRT. This option is for experimental and testing
34909purposes only.
34910This option is available for MinGW targets.
34911
d77de738 34912@opindex mdll
ddf6fe37 34913@item -mdll
d77de738
ML
34914This option is available for Cygwin and MinGW targets. It
34915specifies that a DLL---a dynamic link library---is to be
34916generated, enabling the selection of the required runtime
34917startup object and entry point.
34918
d77de738 34919@opindex mnop-fun-dllimport
ddf6fe37 34920@item -mnop-fun-dllimport
d77de738
ML
34921This option is available for Cygwin and MinGW targets. It
34922specifies that the @code{dllimport} attribute should be ignored.
34923
d77de738 34924@opindex mthreads
ddf6fe37 34925@item -mthreads
d77de738
ML
34926This option is available for MinGW targets. It specifies
34927that MinGW-specific thread support is to be used.
34928
d77de738 34929@opindex municode
ddf6fe37 34930@item -municode
d77de738
ML
34931This option is available for MinGW-w64 targets. It causes
34932the @code{UNICODE} preprocessor macro to be predefined, and
34933chooses Unicode-capable runtime startup code.
34934
d77de738 34935@opindex mwin32
ddf6fe37 34936@item -mwin32
d77de738
ML
34937This option is available for Cygwin and MinGW targets. It
34938specifies that the typical Microsoft Windows predefined macros are to
34939be set in the pre-processor, but does not influence the choice
34940of runtime library/startup code.
34941
d77de738 34942@opindex mwindows
ddf6fe37 34943@item -mwindows
d77de738
ML
34944This option is available for Cygwin and MinGW targets. It
34945specifies that a GUI application is to be generated by
34946instructing the linker to set the PE header subsystem type
34947appropriately.
34948
d77de738
ML
34949@opindex fno-set-stack-executable
34950@opindex fset-stack-executable
ddf6fe37 34951@item -fno-set-stack-executable
d77de738
ML
34952This option is available for MinGW targets. It specifies that
34953the executable flag for the stack used by nested functions isn't
34954set. This is necessary for binaries running in kernel mode of
34955Microsoft Windows, as there the User32 API, which is used to set executable
34956privileges, isn't available.
34957
d77de738
ML
34958@opindex fno-writable-relocated-rdata
34959@opindex fwritable-relocated-rdata
ddf6fe37 34960@item -fwritable-relocated-rdata
d77de738
ML
34961This option is available for MinGW and Cygwin targets. It specifies
34962that relocated-data in read-only section is put into the @code{.data}
34963section. This is a necessary for older runtimes not supporting
34964modification of @code{.rdata} sections for pseudo-relocation.
34965
d77de738 34966@opindex mpe-aligned-commons
ddf6fe37 34967@item -mpe-aligned-commons
d77de738
ML
34968This option is available for Cygwin and MinGW targets. It
34969specifies that the GNU extension to the PE file format that
34970permits the correct alignment of COMMON variables should be
34971used when generating code. It is enabled by default if
34972GCC detects that the target assembler found during configuration
34973supports the feature.
34974@end table
34975
34976See also under @ref{x86 Options} for standard options.
34977
34978@node Xstormy16 Options
34979@subsection Xstormy16 Options
34980@cindex Xstormy16 Options
34981
34982These options are defined for Xstormy16:
34983
34984@table @gcctabopt
d77de738 34985@opindex msim
ddf6fe37 34986@item -msim
d77de738
ML
34987Choose startup files and linker script suitable for the simulator.
34988@end table
34989
34990@node Xtensa Options
34991@subsection Xtensa Options
34992@cindex Xtensa Options
34993
34994These options are supported for Xtensa targets:
34995
34996@table @gcctabopt
d77de738
ML
34997@opindex mconst16
34998@opindex mno-const16
ddf6fe37
AA
34999@item -mconst16
35000@itemx -mno-const16
d77de738
ML
35001Enable or disable use of @code{CONST16} instructions for loading
35002constant values. The @code{CONST16} instruction is currently not a
35003standard option from Tensilica. When enabled, @code{CONST16}
35004instructions are always used in place of the standard @code{L32R}
35005instructions. The use of @code{CONST16} is enabled by default only if
35006the @code{L32R} instruction is not available.
35007
d77de738
ML
35008@opindex mfused-madd
35009@opindex mno-fused-madd
ddf6fe37
AA
35010@item -mfused-madd
35011@itemx -mno-fused-madd
d77de738
ML
35012Enable or disable use of fused multiply/add and multiply/subtract
35013instructions in the floating-point option. This has no effect if the
35014floating-point option is not also enabled. Disabling fused multiply/add
35015and multiply/subtract instructions forces the compiler to use separate
35016instructions for the multiply and add/subtract operations. This may be
35017desirable in some cases where strict IEEE 754-compliant results are
35018required: the fused multiply add/subtract instructions do not round the
35019intermediate result, thereby producing results with @emph{more} bits of
35020precision than specified by the IEEE standard. Disabling fused multiply
35021add/subtract instructions also ensures that the program output is not
35022sensitive to the compiler's ability to combine multiply and add/subtract
35023operations.
35024
d77de738
ML
35025@opindex mserialize-volatile
35026@opindex mno-serialize-volatile
ddf6fe37
AA
35027@item -mserialize-volatile
35028@itemx -mno-serialize-volatile
d77de738
ML
35029When this option is enabled, GCC inserts @code{MEMW} instructions before
35030@code{volatile} memory references to guarantee sequential consistency.
35031The default is @option{-mserialize-volatile}. Use
35032@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
35033
d77de738 35034@opindex mforce-no-pic
ddf6fe37 35035@item -mforce-no-pic
d77de738
ML
35036For targets, like GNU/Linux, where all user-mode Xtensa code must be
35037position-independent code (PIC), this option disables PIC for compiling
35038kernel code.
35039
d77de738
ML
35040@opindex mtext-section-literals
35041@opindex mno-text-section-literals
ddf6fe37
AA
35042@item -mtext-section-literals
35043@itemx -mno-text-section-literals
d77de738
ML
35044These options control the treatment of literal pools. The default is
35045@option{-mno-text-section-literals}, which places literals in a separate
35046section in the output file. This allows the literal pool to be placed
35047in a data RAM/ROM, and it also allows the linker to combine literal
35048pools from separate object files to remove redundant literals and
35049improve code size. With @option{-mtext-section-literals}, the literals
35050are interspersed in the text section in order to keep them as close as
35051possible to their references. This may be necessary for large assembly
35052files. Literals for each function are placed right before that function.
35053
d77de738
ML
35054@opindex mauto-litpools
35055@opindex mno-auto-litpools
ddf6fe37
AA
35056@item -mauto-litpools
35057@itemx -mno-auto-litpools
d77de738
ML
35058These options control the treatment of literal pools. The default is
35059@option{-mno-auto-litpools}, which places literals in a separate
35060section in the output file unless @option{-mtext-section-literals} is
35061used. With @option{-mauto-litpools} the literals are interspersed in
35062the text section by the assembler. Compiler does not produce explicit
35063@code{.literal} directives and loads literals into registers with
35064@code{MOVI} instructions instead of @code{L32R} to let the assembler
35065do relaxation and place literals as necessary. This option allows
35066assembler to create several literal pools per function and assemble
35067very big functions, which may not be possible with
35068@option{-mtext-section-literals}.
35069
d77de738
ML
35070@opindex mtarget-align
35071@opindex mno-target-align
ddf6fe37
AA
35072@item -mtarget-align
35073@itemx -mno-target-align
d77de738
ML
35074When this option is enabled, GCC instructs the assembler to
35075automatically align instructions to reduce branch penalties at the
35076expense of some code density. The assembler attempts to widen density
35077instructions to align branch targets and the instructions following call
35078instructions. If there are not enough preceding safe density
35079instructions to align a target, no widening is performed. The
35080default is @option{-mtarget-align}. These options do not affect the
35081treatment of auto-aligned instructions like @code{LOOP}, which the
35082assembler always aligns, either by widening density instructions or
35083by inserting NOP instructions.
35084
d77de738
ML
35085@opindex mlongcalls
35086@opindex mno-longcalls
ddf6fe37
AA
35087@item -mlongcalls
35088@itemx -mno-longcalls
d77de738
ML
35089When this option is enabled, GCC instructs the assembler to translate
35090direct calls to indirect calls unless it can determine that the target
35091of a direct call is in the range allowed by the call instruction. This
35092translation typically occurs for calls to functions in other source
35093files. Specifically, the assembler translates a direct @code{CALL}
35094instruction into an @code{L32R} followed by a @code{CALLX} instruction.
35095The default is @option{-mno-longcalls}. This option should be used in
35096programs where the call target can potentially be out of range. This
35097option is implemented in the assembler, not the compiler, so the
35098assembly code generated by GCC still shows direct call
35099instructions---look at the disassembled object code to see the actual
35100instructions. Note that the assembler uses an indirect call for
35101every cross-file call, not just those that really are out of range.
35102
d77de738 35103@opindex mabi
ddf6fe37 35104@item -mabi=@var{name}
d77de738
ML
35105Generate code for the specified ABI@. Permissible values are: @samp{call0},
35106@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
35107
d77de738 35108@opindex mabi=call0
ddf6fe37 35109@item -mabi=call0
d77de738
ML
35110When this option is enabled function parameters are passed in registers
35111@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
35112caller-saved, and register @code{a15} may be used as a frame pointer.
35113When this version of the ABI is enabled the C preprocessor symbol
35114@code{__XTENSA_CALL0_ABI__} is defined.
35115
d77de738 35116@opindex mabi=windowed
ddf6fe37 35117@item -mabi=windowed
d77de738
ML
35118When this option is enabled function parameters are passed in registers
35119@code{a10} through @code{a15}, and called function rotates register window
35120by 8 registers on entry so that its arguments are found in registers
35121@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
35122pointer. Register window is rotated 8 registers back upon return.
35123When this version of the ABI is enabled the C preprocessor symbol
35124@code{__XTENSA_WINDOWED_ABI__} is defined.
35125
d77de738 35126@opindex mextra-l32r-costs
ddf6fe37 35127@item -mextra-l32r-costs=@var{n}
d77de738
ML
35128Specify an extra cost of instruction RAM/ROM access for @code{L32R}
35129instructions, in clock cycles. This affects, when optimizing for speed,
35130whether loading a constant from literal pool using @code{L32R} or
35131synthesizing the constant from a small one with a couple of arithmetic
35132instructions. The default value is 0.
675b390e
MF
35133
35134@opindex mstrict-align
35135@opindex mno-strict-align
35136@item -mstrict-align
35137@itemx -mno-strict-align
35138Avoid or allow generating memory accesses that may not be aligned on a natural
35139object boundary as described in the architecture specification.
35140The default is @option{-mno-strict-align} for cores that support both
35141unaligned loads and stores in hardware and @option{-mstrict-align} for all
35142other cores.
35143
d77de738
ML
35144@end table
35145
35146@node zSeries Options
35147@subsection zSeries Options
35148@cindex zSeries options
35149
35150These are listed under @xref{S/390 and zSeries Options}.
35151
35152
35153@c man end
35154
35155@node Spec Files
35156@section Specifying Subprocesses and the Switches to Pass to Them
35157@cindex Spec Files
35158
35159@command{gcc} is a driver program. It performs its job by invoking a
35160sequence of other programs to do the work of compiling, assembling and
35161linking. GCC interprets its command-line parameters and uses these to
35162deduce which programs it should invoke, and which command-line options
35163it ought to place on their command lines. This behavior is controlled
35164by @dfn{spec strings}. In most cases there is one spec string for each
35165program that GCC can invoke, but a few programs have multiple spec
35166strings to control their behavior. The spec strings built into GCC can
35167be overridden by using the @option{-specs=} command-line switch to specify
35168a spec file.
35169
35170@dfn{Spec files} are plain-text files that are used to construct spec
35171strings. They consist of a sequence of directives separated by blank
35172lines. The type of directive is determined by the first non-whitespace
35173character on the line, which can be one of the following:
35174
35175@table @code
35176@item %@var{command}
35177Issues a @var{command} to the spec file processor. The commands that can
35178appear here are:
35179
35180@table @code
d77de738 35181@cindex @code{%include}
f33d7a88 35182@item %include <@var{file}>
d77de738
ML
35183Search for @var{file} and insert its text at the current point in the
35184specs file.
35185
d77de738 35186@cindex @code{%include_noerr}
f33d7a88 35187@item %include_noerr <@var{file}>
d77de738
ML
35188Just like @samp{%include}, but do not generate an error message if the include
35189file cannot be found.
35190
d77de738 35191@cindex @code{%rename}
f33d7a88 35192@item %rename @var{old_name} @var{new_name}
d77de738
ML
35193Rename the spec string @var{old_name} to @var{new_name}.
35194
35195@end table
35196
35197@item *[@var{spec_name}]:
35198This tells the compiler to create, override or delete the named spec
35199string. All lines after this directive up to the next directive or
35200blank line are considered to be the text for the spec string. If this
35201results in an empty string then the spec is deleted. (Or, if the
35202spec did not exist, then nothing happens.) Otherwise, if the spec
35203does not currently exist a new spec is created. If the spec does
35204exist then its contents are overridden by the text of this
35205directive, unless the first character of that text is the @samp{+}
35206character, in which case the text is appended to the spec.
35207
35208@item [@var{suffix}]:
35209Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
35210and up to the next directive or blank line are considered to make up the
35211spec string for the indicated suffix. When the compiler encounters an
35212input file with the named suffix, it processes the spec string in
35213order to work out how to compile that file. For example:
35214
35215@smallexample
35216.ZZ:
35217z-compile -input %i
35218@end smallexample
35219
35220This says that any input file whose name ends in @samp{.ZZ} should be
35221passed to the program @samp{z-compile}, which should be invoked with the
35222command-line switch @option{-input} and with the result of performing the
35223@samp{%i} substitution. (See below.)
35224
35225As an alternative to providing a spec string, the text following a
35226suffix directive can be one of the following:
35227
35228@table @code
35229@item @@@var{language}
35230This says that the suffix is an alias for a known @var{language}. This is
35231similar to using the @option{-x} command-line switch to GCC to specify a
35232language explicitly. For example:
35233
35234@smallexample
35235.ZZ:
35236@@c++
35237@end smallexample
35238
35239Says that .ZZ files are, in fact, C++ source files.
35240
35241@item #@var{name}
35242This causes an error messages saying:
35243
35244@smallexample
35245@var{name} compiler not installed on this system.
35246@end smallexample
35247@end table
35248
35249GCC already has an extensive list of suffixes built into it.
35250This directive adds an entry to the end of the list of suffixes, but
35251since the list is searched from the end backwards, it is effectively
35252possible to override earlier entries using this technique.
35253
35254@end table
35255
35256GCC has the following spec strings built into it. Spec files can
35257override these strings or create their own. Note that individual
35258targets can also add their own spec strings to this list.
35259
35260@smallexample
35261asm Options to pass to the assembler
35262asm_final Options to pass to the assembler post-processor
35263cpp Options to pass to the C preprocessor
35264cc1 Options to pass to the C compiler
35265cc1plus Options to pass to the C++ compiler
35266endfile Object files to include at the end of the link
35267link Options to pass to the linker
35268lib Libraries to include on the command line to the linker
35269libgcc Decides which GCC support library to pass to the linker
35270linker Sets the name of the linker
35271predefines Defines to be passed to the C preprocessor
35272signed_char Defines to pass to CPP to say whether @code{char} is signed
35273 by default
35274startfile Object files to include at the start of the link
35275@end smallexample
35276
35277Here is a small example of a spec file:
35278
35279@smallexample
35280%rename lib old_lib
35281
35282*lib:
35283--start-group -lgcc -lc -leval1 --end-group %(old_lib)
35284@end smallexample
35285
35286This example renames the spec called @samp{lib} to @samp{old_lib} and
35287then overrides the previous definition of @samp{lib} with a new one.
35288The new definition adds in some extra command-line options before
35289including the text of the old definition.
35290
35291@dfn{Spec strings} are a list of command-line options to be passed to their
35292corresponding program. In addition, the spec strings can contain
35293@samp{%}-prefixed sequences to substitute variable text or to
35294conditionally insert text into the command line. Using these constructs
35295it is possible to generate quite complex command lines.
35296
35297Here is a table of all defined @samp{%}-sequences for spec
35298strings. Note that spaces are not generated automatically around the
35299results of expanding these sequences. Therefore you can concatenate them
35300together or combine them with constant text in a single argument.
35301
35302@table @code
35303@item %%
35304Substitute one @samp{%} into the program name or argument.
35305
35306@item %"
35307Substitute an empty argument.
35308
35309@item %i
35310Substitute the name of the input file being processed.
35311
35312@item %b
35313Substitute the basename for outputs related with the input file being
35314processed. This is often the substring up to (and not including) the
35315last period and not including the directory but, unless %w is active, it
35316expands to the basename for auxiliary outputs, which may be influenced
35317by an explicit output name, and by various other options that control
35318how auxiliary outputs are named.
35319
35320@item %B
35321This is the same as @samp{%b}, but include the file suffix (text after
35322the last period). Without %w, it expands to the basename for dump
35323outputs.
35324
35325@item %d
35326Marks the argument containing or following the @samp{%d} as a
35327temporary file name, so that that file is deleted if GCC exits
35328successfully. Unlike @samp{%g}, this contributes no text to the
35329argument.
35330
35331@item %g@var{suffix}
35332Substitute a file name that has suffix @var{suffix} and is chosen
35333once per compilation, and mark the argument in the same way as
35334@samp{%d}. To reduce exposure to denial-of-service attacks, the file
35335name is now chosen in a way that is hard to predict even when previously
35336chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
35337might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
35338the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
35339treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
35340was simply substituted with a file name chosen once per compilation,
35341without regard to any appended suffix (which was therefore treated
35342just like ordinary text), making such attacks more likely to succeed.
35343
35344@item %u@var{suffix}
35345Like @samp{%g}, but generates a new temporary file name
35346each time it appears instead of once per compilation.
35347
35348@item %U@var{suffix}
35349Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
35350new one if there is no such last file name. In the absence of any
35351@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
35352the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
35353involves the generation of two distinct file names, one
35354for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
35355simply substituted with a file name chosen for the previous @samp{%u},
35356without regard to any appended suffix.
35357
35358@item %j@var{suffix}
35359Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
35360writable, and if @option{-save-temps} is not used;
35361otherwise, substitute the name
35362of a temporary file, just like @samp{%u}. This temporary file is not
35363meant for communication between processes, but rather as a junk
35364disposal mechanism.
35365
35366@item %|@var{suffix}
35367@itemx %m@var{suffix}
35368Like @samp{%g}, except if @option{-pipe} is in effect. In that case
35369@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
35370all. These are the two most common ways to instruct a program that it
35371should read from standard input or write to standard output. If you
35372need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
35373construct: see for example @file{gcc/fortran/lang-specs.h}.
35374
35375@item %.@var{SUFFIX}
35376Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
35377when it is subsequently output with @samp{%*}. @var{SUFFIX} is
35378terminated by the next space or %.
35379
35380@item %w
35381Marks the argument containing or following the @samp{%w} as the
35382designated output file of this compilation. This puts the argument
35383into the sequence of arguments that @samp{%o} substitutes.
35384
35385@item %V
35386Indicates that this compilation produces no output file.
35387
35388@item %o
35389Substitutes the names of all the output files, with spaces
35390automatically placed around them. You should write spaces
35391around the @samp{%o} as well or the results are undefined.
35392@samp{%o} is for use in the specs for running the linker.
35393Input files whose names have no recognized suffix are not compiled
35394at all, but they are included among the output files, so they are
35395linked.
35396
35397@item %O
35398Substitutes the suffix for object files. Note that this is
35399handled specially when it immediately follows @samp{%g, %u, or %U},
35400because of the need for those to form complete file names. The
35401handling is such that @samp{%O} is treated exactly as if it had already
35402been substituted, except that @samp{%g, %u, and %U} do not currently
35403support additional @var{suffix} characters following @samp{%O} as they do
35404following, for example, @samp{.o}.
35405
35406@item %I
35407Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
35408@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
35409@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
35410and @option{-imultilib} as necessary.
35411
35412@item %s
35413Current argument is the name of a library or startup file of some sort.
35414Search for that file in a standard list of directories and substitute
35415the full name found. The current working directory is included in the
35416list of directories scanned.
35417
35418@item %T
35419Current argument is the name of a linker script. Search for that file
35420in the current list of directories to scan for libraries. If the file
35421is located insert a @option{--script} option into the command line
35422followed by the full path name found. If the file is not found then
35423generate an error message. Note: the current working directory is not
35424searched.
35425
35426@item %e@var{str}
35427Print @var{str} as an error message. @var{str} is terminated by a newline.
35428Use this when inconsistent options are detected.
35429
35430@item %n@var{str}
35431Print @var{str} as a notice. @var{str} is terminated by a newline.
35432
35433@item %(@var{name})
35434Substitute the contents of spec string @var{name} at this point.
35435
35436@item %x@{@var{option}@}
35437Accumulate an option for @samp{%X}.
35438
35439@item %X
35440Output the accumulated linker options specified by a @samp{%x} spec string.
35441
35442@item %Y
35443Output the accumulated assembler options specified by @option{-Wa}.
35444
35445@item %Z
35446Output the accumulated preprocessor options specified by @option{-Wp}.
35447
35448@item %M
35449Output @code{multilib_os_dir}.
35450
35451@item %R
35452Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
35453
35454@item %a
35455Process the @code{asm} spec. This is used to compute the
35456switches to be passed to the assembler.
35457
35458@item %A
35459Process the @code{asm_final} spec. This is a spec string for
35460passing switches to an assembler post-processor, if such a program is
35461needed.
35462
35463@item %l
35464Process the @code{link} spec. This is the spec for computing the
35465command line passed to the linker. Typically it makes use of the
35466@samp{%L %G %S %D and %E} sequences.
35467
35468@item %D
35469Dump out a @option{-L} option for each directory that GCC believes might
35470contain startup files. If the target supports multilibs then the
35471current multilib directory is prepended to each of these paths.
35472
35473@item %L
35474Process the @code{lib} spec. This is a spec string for deciding which
35475libraries are included on the command line to the linker.
35476
35477@item %G
35478Process the @code{libgcc} spec. This is a spec string for deciding
35479which GCC support library is included on the command line to the linker.
35480
35481@item %S
35482Process the @code{startfile} spec. This is a spec for deciding which
35483object files are the first ones passed to the linker. Typically
35484this might be a file named @file{crt0.o}.
35485
35486@item %E
35487Process the @code{endfile} spec. This is a spec string that specifies
35488the last object files that are passed to the linker.
35489
35490@item %C
35491Process the @code{cpp} spec. This is used to construct the arguments
35492to be passed to the C preprocessor.
35493
35494@item %1
35495Process the @code{cc1} spec. This is used to construct the options to be
35496passed to the actual C compiler (@command{cc1}).
35497
35498@item %2
35499Process the @code{cc1plus} spec. This is used to construct the options to be
35500passed to the actual C++ compiler (@command{cc1plus}).
35501
35502@item %*
35503Substitute the variable part of a matched option. See below.
35504Note that each comma in the substituted string is replaced by
35505a single space.
35506
35507@item %<S
35508Remove all occurrences of @code{-S} from the command line. Note---this
35509command is position dependent. @samp{%} commands in the spec string
35510before this one see @code{-S}, @samp{%} commands in the spec string
35511after this one do not.
35512
35513@item %<S*
35514Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
35515
35516@item %>S
35517Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
35518
35519@item %:@var{function}(@var{args})
35520Call the named function @var{function}, passing it @var{args}.
35521@var{args} is first processed as a nested spec string, then split
35522into an argument vector in the usual fashion. The function returns
35523a string which is processed as if it had appeared literally as part
35524of the current spec.
35525
35526The following built-in spec functions are provided:
35527
35528@table @code
35529@item @code{getenv}
35530The @code{getenv} spec function takes two arguments: an environment
35531variable name and a string. If the environment variable is not
35532defined, a fatal error is issued. Otherwise, the return value is the
35533value of the environment variable concatenated with the string. For
35534example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
35535
35536@smallexample
35537%:getenv(TOPDIR /include)
35538@end smallexample
35539
35540expands to @file{/path/to/top/include}.
35541
35542@item @code{if-exists}
35543The @code{if-exists} spec function takes one argument, an absolute
35544pathname to a file. If the file exists, @code{if-exists} returns the
35545pathname. Here is a small example of its usage:
35546
35547@smallexample
35548*startfile:
35549crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
35550@end smallexample
35551
35552@item @code{if-exists-else}
35553The @code{if-exists-else} spec function is similar to the @code{if-exists}
35554spec function, except that it takes two arguments. The first argument is
35555an absolute pathname to a file. If the file exists, @code{if-exists-else}
35556returns the pathname. If it does not exist, it returns the second argument.
35557This way, @code{if-exists-else} can be used to select one file or another,
35558based on the existence of the first. Here is a small example of its usage:
35559
35560@smallexample
35561*startfile:
35562crt0%O%s %:if-exists(crti%O%s) \
35563%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
35564@end smallexample
35565
35566@item @code{if-exists-then-else}
35567The @code{if-exists-then-else} spec function takes at least two arguments
35568and an optional third one. The first argument is an absolute pathname to a
35569file. If the file exists, the function returns the second argument.
35570If the file does not exist, the function returns the third argument if there
35571is one, or NULL otherwise. This can be used to expand one text, or optionally
35572another, based on the existence of a file. Here is a small example of its
35573usage:
35574
35575@smallexample
35576-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
35577@end smallexample
35578
35579@item @code{sanitize}
35580The @code{sanitize} spec function takes no arguments. It returns non-NULL if
35581any address, thread or undefined behavior sanitizers are active.
35582
35583@smallexample
35584%@{%:sanitize(address):-funwind-tables@}
35585@end smallexample
35586
35587@item @code{replace-outfile}
35588The @code{replace-outfile} spec function takes two arguments. It looks for the
35589first argument in the outfiles array and replaces it with the second argument. Here
35590is a small example of its usage:
35591
35592@smallexample
35593%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
35594@end smallexample
35595
35596@item @code{remove-outfile}
35597The @code{remove-outfile} spec function takes one argument. It looks for the
35598first argument in the outfiles array and removes it. Here is a small example
35599its usage:
35600
35601@smallexample
35602%:remove-outfile(-lm)
35603@end smallexample
35604
35605@item @code{version-compare}
35606The @code{version-compare} spec function takes four or five arguments of the following
35607form:
35608
35609@smallexample
35610<comparison-op> <arg1> [<arg2>] <switch> <result>
35611@end smallexample
35612
35613It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
35614The supported @code{comparison-op} values are:
35615
35616@table @code
35617@item >=
35618True if @code{switch} is a later (or same) version than @code{arg1}
35619
35620@item !>
35621Opposite of @code{>=}
35622
35623@item <
35624True if @code{switch} is an earlier version than @code{arg1}
35625
35626@item !<
35627Opposite of @code{<}
35628
35629@item ><
35630True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
35631
35632@item <>
35633True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
35634@end table
35635
35636If the @code{switch} is not present at all, the condition is false unless the first character
35637of the @code{comparison-op} is @code{!}.
35638
35639@smallexample
35640%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
35641@end smallexample
35642
35643The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
35644passed.
35645
35646@item @code{include}
35647The @code{include} spec function behaves much like @code{%include}, with the advantage
35648that it can be nested inside a spec and thus be conditionalized. It takes one argument,
35649the filename, and looks for it in the startfile path. It always returns NULL.
35650
35651@smallexample
35652%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
35653@end smallexample
35654
35655@item @code{pass-through-libs}
35656The @code{pass-through-libs} spec function takes any number of arguments. It
35657finds any @option{-l} options and any non-options ending in @file{.a} (which it
35658assumes are the names of linker input library archive files) and returns a
35659result containing all the found arguments each prepended by
35660@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
35661intended to be passed to the LTO linker plugin.
35662
35663@smallexample
35664%:pass-through-libs(%G %L %G)
35665@end smallexample
35666
35667@item @code{print-asm-header}
35668The @code{print-asm-header} function takes no arguments and simply
35669prints a banner like:
35670
35671@smallexample
35672Assembler options
35673=================
35674
35675Use "-Wa,OPTION" to pass "OPTION" to the assembler.
35676@end smallexample
35677
35678It is used to separate compiler options from assembler options
35679in the @option{--target-help} output.
35680
35681@item @code{gt}
35682The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
35683empty string) if the second-to-last argument is greater than the last argument, and NULL
35684otherwise. The following example inserts the @code{link_gomp} spec if the last
35685@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
35686
35687@smallexample
35688%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
35689@end smallexample
35690
35691@item @code{debug-level-gt}
35692The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
35693empty string) if @code{debug_info_level} is greater than the specified number, and NULL
35694otherwise.
35695
35696@smallexample
35697%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
35698@end smallexample
35699@end table
35700
35701@item %@{S@}
35702Substitutes the @code{-S} switch, if that switch is given to GCC@.
35703If that switch is not specified, this substitutes nothing. Note that
35704the leading dash is omitted when specifying this option, and it is
35705automatically inserted if the substitution is performed. Thus the spec
35706string @samp{%@{foo@}} matches the command-line option @option{-foo}
35707and outputs the command-line option @option{-foo}.
35708
35709@item %W@{S@}
35710Like %@{@code{S}@} but mark last argument supplied within as a file to be
35711deleted on failure.
35712
35713@item %@@@{S@}
35714Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
35715@code{@@FILE} if an @code{@@file} argument has been supplied.
35716
35717@item %@{S*@}
35718Substitutes all the switches specified to GCC whose names start
35719with @code{-S}, but which also take an argument. This is used for
35720switches like @option{-o}, @option{-D}, @option{-I}, etc.
35721GCC considers @option{-o foo} as being
35722one switch whose name starts with @samp{o}. %@{o*@} substitutes this
35723text, including the space. Thus two arguments are generated.
35724
35725@item %@{S*&T*@}
35726Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
35727(the order of @code{S} and @code{T} in the spec is not significant).
35728There can be any number of ampersand-separated variables; for each the
35729wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
35730
35731@item %@{S:X@}
35732Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
35733
35734@item %@{!S:X@}
35735Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
35736
35737@item %@{S*:X@}
35738Substitutes @code{X} if one or more switches whose names start with
35739@code{-S} are specified to GCC@. Normally @code{X} is substituted only
35740once, no matter how many such switches appeared. However, if @code{%*}
35741appears somewhere in @code{X}, then @code{X} is substituted once
35742for each matching switch, with the @code{%*} replaced by the part of
35743that switch matching the @code{*}.
35744
35745If @code{%*} appears as the last part of a spec sequence then a space
35746is added after the end of the last substitution. If there is more
35747text in the sequence, however, then a space is not generated. This
35748allows the @code{%*} substitution to be used as part of a larger
35749string. For example, a spec string like this:
35750
35751@smallexample
35752%@{mcu=*:--script=%*/memory.ld@}
35753@end smallexample
35754
35755@noindent
35756when matching an option like @option{-mcu=newchip} produces:
35757
35758@smallexample
35759--script=newchip/memory.ld
35760@end smallexample
35761
35762@item %@{.S:X@}
35763Substitutes @code{X}, if processing a file with suffix @code{S}.
35764
35765@item %@{!.S:X@}
35766Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35767
35768@item %@{,S:X@}
35769Substitutes @code{X}, if processing a file for language @code{S}.
35770
35771@item %@{!,S:X@}
35772Substitutes @code{X}, if not processing a file for language @code{S}.
35773
35774@item %@{S|P:X@}
35775Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35776GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35777@code{*} sequences as well, although they have a stronger binding than
35778the @samp{|}. If @code{%*} appears in @code{X}, all of the
35779alternatives must be starred, and only the first matching alternative
35780is substituted.
35781
35782For example, a spec string like this:
35783
35784@smallexample
35785%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35786@end smallexample
35787
35788@noindent
35789outputs the following command-line options from the following input
35790command-line options:
35791
35792@smallexample
35793fred.c -foo -baz
35794jim.d -bar -boggle
35795-d fred.c -foo -baz -boggle
35796-d jim.d -bar -baz -boggle
35797@end smallexample
35798
35799@item %@{%:@var{function}(@var{args}):X@}
35800
35801Call function named @var{function} with args @var{args}. If the
35802function returns non-NULL, then @code{X} is substituted, if it returns
35803NULL, it isn't substituted.
35804
35805@item %@{S:X; T:Y; :D@}
35806
35807If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35808given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35809be as many clauses as you need. This may be combined with @code{.},
35810@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35811
35812
35813@end table
35814
35815The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35816or similar construct can use a backslash to ignore the special meaning
35817of the character following it, thus allowing literal matching of a
35818character that is otherwise specially treated. For example,
35819@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35820@option{-std=iso9899:1999} option is given.
35821
35822The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35823construct may contain other nested @samp{%} constructs or spaces, or
35824even newlines. They are processed as usual, as described above.
35825Trailing white space in @code{X} is ignored. White space may also
35826appear anywhere on the left side of the colon in these constructs,
35827except between @code{.} or @code{*} and the corresponding word.
35828
35829The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35830handled specifically in these constructs. If another value of
35831@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35832@option{-W} switch is found later in the command line, the earlier
35833switch value is ignored, except with @{@code{S}*@} where @code{S} is
35834just one letter, which passes all matching options.
35835
35836The character @samp{|} at the beginning of the predicate text is used to
35837indicate that a command should be piped to the following command, but
35838only if @option{-pipe} is specified.
35839
35840It is built into GCC which switches take arguments and which do not.
35841(You might think it would be useful to generalize this to allow each
35842compiler's spec to say which switches take arguments. But this cannot
35843be done in a consistent fashion. GCC cannot even decide which input
35844files have been specified without knowing which switches take arguments,
35845and it must know which input files to compile in order to tell which
35846compilers to run).
35847
35848GCC also knows implicitly that arguments starting in @option{-l} are to be
35849treated as compiler output files, and passed to the linker in their
35850proper position among the other output files.
35851
35852@node Environment Variables
35853@section Environment Variables Affecting GCC
35854@cindex environment variables
35855
35856@c man begin ENVIRONMENT
35857This section describes several environment variables that affect how GCC
35858operates. Some of them work by specifying directories or prefixes to use
35859when searching for various kinds of files. Some are used to specify other
35860aspects of the compilation environment.
35861
35862Note that you can also specify places to search using options such as
35863@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35864take precedence over places specified using environment variables, which
35865in turn take precedence over those specified by the configuration of GCC@.
35866@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35867GNU Compiler Collection (GCC) Internals}.
35868
35869@table @env
f33d7a88
AA
35870@vindex LANG
35871@vindex LC_CTYPE
35872@c @vindex LC_COLLATE
35873@vindex LC_MESSAGES
35874@c @vindex LC_MONETARY
35875@c @vindex LC_NUMERIC
35876@c @vindex LC_TIME
35877@vindex LC_ALL
35878@cindex locale
d77de738
ML
35879@item LANG
35880@itemx LC_CTYPE
35881@c @itemx LC_COLLATE
35882@itemx LC_MESSAGES
35883@c @itemx LC_MONETARY
35884@c @itemx LC_NUMERIC
35885@c @itemx LC_TIME
35886@itemx LC_ALL
d77de738
ML
35887These environment variables control the way that GCC uses
35888localization information which allows GCC to work with different
35889national conventions. GCC inspects the locale categories
35890@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35891so. These locale categories can be set to any value supported by your
35892installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35893Kingdom encoded in UTF-8.
35894
35895The @env{LC_CTYPE} environment variable specifies character
35896classification. GCC uses it to determine the character boundaries in
35897a string; this is needed for some multibyte encodings that contain quote
35898and escape characters that are otherwise interpreted as a string
35899end or escape.
35900
35901The @env{LC_MESSAGES} environment variable specifies the language to
35902use in diagnostic messages.
35903
35904If the @env{LC_ALL} environment variable is set, it overrides the value
35905of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35906and @env{LC_MESSAGES} default to the value of the @env{LANG}
35907environment variable. If none of these variables are set, GCC
35908defaults to traditional C English behavior.
35909
f33d7a88 35910@vindex TMPDIR
d77de738 35911@item TMPDIR
d77de738
ML
35912If @env{TMPDIR} is set, it specifies the directory to use for temporary
35913files. GCC uses temporary files to hold the output of one stage of
35914compilation which is to be used as input to the next stage: for example,
35915the output of the preprocessor, which is the input to the compiler
35916proper.
35917
f33d7a88 35918@vindex GCC_COMPARE_DEBUG
d77de738 35919@item GCC_COMPARE_DEBUG
d77de738
ML
35920Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35921@option{-fcompare-debug} to the compiler driver. See the documentation
35922of this option for more details.
35923
f33d7a88 35924@vindex GCC_EXEC_PREFIX
d77de738 35925@item GCC_EXEC_PREFIX
d77de738
ML
35926If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35927names of the subprograms executed by the compiler. No slash is added
35928when this prefix is combined with the name of a subprogram, but you can
35929specify a prefix that ends with a slash if you wish.
35930
35931If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35932an appropriate prefix to use based on the pathname it is invoked with.
35933
35934If GCC cannot find the subprogram using the specified prefix, it
35935tries looking in the usual places for the subprogram.
35936
35937The default value of @env{GCC_EXEC_PREFIX} is
35938@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35939the installed compiler. In many cases @var{prefix} is the value
35940of @code{prefix} when you ran the @file{configure} script.
35941
35942Other prefixes specified with @option{-B} take precedence over this prefix.
35943
35944This prefix is also used for finding files such as @file{crt0.o} that are
35945used for linking.
35946
35947In addition, the prefix is used in an unusual way in finding the
35948directories to search for header files. For each of the standard
35949directories whose name normally begins with @samp{/usr/local/lib/gcc}
35950(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35951replacing that beginning with the specified prefix to produce an
35952alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35953@file{foo/bar} just before it searches the standard directory
35954@file{/usr/local/lib/bar}.
35955If a standard directory begins with the configured
35956@var{prefix} then the value of @var{prefix} is replaced by
35957@env{GCC_EXEC_PREFIX} when looking for header files.
35958
f33d7a88 35959@vindex COMPILER_PATH
d77de738 35960@item COMPILER_PATH
d77de738
ML
35961The value of @env{COMPILER_PATH} is a colon-separated list of
35962directories, much like @env{PATH}. GCC tries the directories thus
35963specified when searching for subprograms, if it cannot find the
35964subprograms using @env{GCC_EXEC_PREFIX}.
35965
f33d7a88 35966@vindex LIBRARY_PATH
d77de738 35967@item LIBRARY_PATH
d77de738
ML
35968The value of @env{LIBRARY_PATH} is a colon-separated list of
35969directories, much like @env{PATH}. When configured as a native compiler,
35970GCC tries the directories thus specified when searching for special
35971linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35972using GCC also uses these directories when searching for ordinary
35973libraries for the @option{-l} option (but directories specified with
35974@option{-L} come first).
35975
f33d7a88 35976@vindex LANG
d77de738 35977@cindex locale definition
f33d7a88 35978@item LANG
d77de738
ML
35979This variable is used to pass locale information to the compiler. One way in
35980which this information is used is to determine the character set to be used
35981when character literals, string literals and comments are parsed in C and C++.
35982When the compiler is configured to allow multibyte characters,
35983the following values for @env{LANG} are recognized:
35984
35985@table @samp
35986@item C-JIS
35987Recognize JIS characters.
35988@item C-SJIS
35989Recognize SJIS characters.
35990@item C-EUCJP
35991Recognize EUCJP characters.
35992@end table
35993
35994If @env{LANG} is not defined, or if it has some other value, then the
35995compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35996recognize and translate multibyte characters.
35997
f33d7a88 35998@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 35999@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
36000If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
36001then additional text will be emitted to stderr when fix-it hints are
36002emitted. @option{-fdiagnostics-parseable-fixits} and
36003@option{-fno-diagnostics-parseable-fixits} take precedence over this
36004environment variable.
36005
36006@table @samp
36007@item fixits-v1
36008Emit parseable fix-it hints, equivalent to
36009@option{-fdiagnostics-parseable-fixits}. In particular, columns are
36010expressed as a count of bytes, starting at byte 1 for the initial column.
36011
36012@item fixits-v2
36013As @code{fixits-v1}, but columns are expressed as display columns,
36014as per @option{-fdiagnostics-column-unit=display}.
36015@end table
36016
36017@end table
36018
36019@noindent
36020Some additional environment variables affect the behavior of the
36021preprocessor.
36022
36023@include cppenv.texi
36024
36025@c man end
36026
36027@node Precompiled Headers
36028@section Using Precompiled Headers
36029@cindex precompiled headers
36030@cindex speed of compilation
36031
36032Often large projects have many header files that are included in every
36033source file. The time the compiler takes to process these header files
36034over and over again can account for nearly all of the time required to
36035build the project. To make builds faster, GCC allows you to
36036@dfn{precompile} a header file.
36037
36038To create a precompiled header file, simply compile it as you would any
36039other file, if necessary using the @option{-x} option to make the driver
36040treat it as a C or C++ header file. You may want to use a
36041tool like @command{make} to keep the precompiled header up-to-date when
36042the headers it contains change.
36043
36044A precompiled header file is searched for when @code{#include} is
36045seen in the compilation. As it searches for the included file
36046(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
36047compiler looks for a precompiled header in each directory just before it
36048looks for the include file in that directory. The name searched for is
36049the name specified in the @code{#include} with @samp{.gch} appended. If
36050the precompiled header file cannot be used, it is ignored.
36051
36052For instance, if you have @code{#include "all.h"}, and you have
36053@file{all.h.gch} in the same directory as @file{all.h}, then the
36054precompiled header file is used if possible, and the original
36055header is used otherwise.
36056
36057Alternatively, you might decide to put the precompiled header file in a
36058directory and use @option{-I} to ensure that directory is searched
36059before (or instead of) the directory containing the original header.
36060Then, if you want to check that the precompiled header file is always
36061used, you can put a file of the same name as the original header in this
36062directory containing an @code{#error} command.
36063
36064This also works with @option{-include}. So yet another way to use
36065precompiled headers, good for projects not designed with precompiled
36066header files in mind, is to simply take most of the header files used by
36067a project, include them from another header file, precompile that header
36068file, and @option{-include} the precompiled header. If the header files
36069have guards against multiple inclusion, they are skipped because
36070they've already been included (in the precompiled header).
36071
36072If you need to precompile the same header file for different
36073languages, targets, or compiler options, you can instead make a
36074@emph{directory} named like @file{all.h.gch}, and put each precompiled
36075header in the directory, perhaps using @option{-o}. It doesn't matter
36076what you call the files in the directory; every precompiled header in
36077the directory is considered. The first precompiled header
36078encountered in the directory that is valid for this compilation is
36079used; they're searched in no particular order.
36080
36081There are many other possibilities, limited only by your imagination,
36082good sense, and the constraints of your build system.
36083
36084A precompiled header file can be used only when these conditions apply:
36085
36086@itemize
36087@item
36088Only one precompiled header can be used in a particular compilation.
36089
36090@item
36091A precompiled header cannot be used once the first C token is seen. You
36092can have preprocessor directives before a precompiled header; you cannot
36093include a precompiled header from inside another header.
36094
36095@item
36096The precompiled header file must be produced for the same language as
36097the current compilation. You cannot use a C precompiled header for a C++
36098compilation.
36099
36100@item
36101The precompiled header file must have been produced by the same compiler
36102binary as the current compilation is using.
36103
36104@item
36105Any macros defined before the precompiled header is included must
36106either be defined in the same way as when the precompiled header was
36107generated, or must not affect the precompiled header, which usually
36108means that they don't appear in the precompiled header at all.
36109
36110The @option{-D} option is one way to define a macro before a
36111precompiled header is included; using a @code{#define} can also do it.
36112There are also some options that define macros implicitly, like
36113@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
36114defined this way.
36115
36116@item If debugging information is output when using the precompiled
36117header, using @option{-g} or similar, the same kind of debugging information
36118must have been output when building the precompiled header. However,
36119a precompiled header built using @option{-g} can be used in a compilation
36120when no debugging information is being output.
36121
36122@item The same @option{-m} options must generally be used when building
36123and using the precompiled header. @xref{Submodel Options},
36124for any cases where this rule is relaxed.
36125
36126@item Each of the following options must be the same when building and using
36127the precompiled header:
36128
36129@gccoptlist{-fexceptions}
36130
36131@item
36132Some other command-line options starting with @option{-f},
36133@option{-p}, or @option{-O} must be defined in the same way as when
36134the precompiled header was generated. At present, it's not clear
36135which options are safe to change and which are not; the safest choice
36136is to use exactly the same options when generating and using the
36137precompiled header. The following are known to be safe:
36138
43b72ede
AA
36139@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
36140-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
36141-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
36142-pedantic-errors}
36143
36144@item Address space layout randomization (ASLR) can lead to not binary identical
36145PCH files. If you rely on stable PCH file contents disable ASLR when generating
36146PCH files.
36147
36148@end itemize
36149
36150For all of these except the last, the compiler automatically
36151ignores the precompiled header if the conditions aren't met. If you
36152find an option combination that doesn't work and doesn't cause the
36153precompiled header to be ignored, please consider filing a bug report,
36154see @ref{Bugs}.
36155
36156If you do use differing options when generating and using the
36157precompiled header, the actual behavior is a mixture of the
36158behavior for the options. For instance, if you use @option{-g} to
36159generate the precompiled header but not when using it, you may or may
36160not get debugging information for routines in the precompiled header.
36161
36162@node C++ Modules
36163@section C++ Modules
36164@cindex speed of compilation
36165
36166Modules are a C++20 language feature. As the name suggests, they
36167provides a modular compilation system, intending to provide both
36168faster builds and better library isolation. The ``Merging Modules''
36169paper @uref{https://wg21.link/p1103}, provides the easiest to read set
36170of changes to the standard, although it does not capture later
36171changes.
36172
36173@emph{G++'s modules support is not complete.} Other than bugs, the
36174known missing pieces are:
36175
36176@table @emph
36177
36178@item Private Module Fragment
36179The Private Module Fragment is recognized, but an error is emitted.
36180
36181@item Partition definition visibility rules
36182Entities may be defined in implementation partitions, and those
36183definitions are not available outside of the module. This is not
36184implemented, and the definitions are available to extra-module use.
36185
36186@item Textual merging of reachable GM entities
36187Entities may be multiply defined across different header-units.
36188These must be de-duplicated, and this is implemented across imports,
36189or when an import redefines a textually-defined entity. However the
36190reverse is not implemented---textually redefining an entity that has
36191been defined in an imported header-unit. A redefinition error is
36192emitted.
36193
36194@item Translation-Unit local referencing rules
36195Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
36196(@uref{https://wg21.link/p2003}) add limitations on which entities an
36197exported region may reference (for instance, the entities an exported
36198template definition may reference). These are not fully implemented.
36199
36200@item Standard Library Header Units
36201The Standard Library is not provided as importable header units. If
36202you want to import such units, you must explicitly build them first.
36203If you do not do this with care, you may have multiple declarations,
36204which the module machinery must merge---compiler resource usage can be
36205affected by how you partition header files into header units.
36206
36207@end table
36208
36209Modular compilation is @emph{not} enabled with just the
36210@option{-std=c++20} option. You must explicitly enable it with the
36211@option{-fmodules-ts} option. It is independent of the language
36212version selected, although in pre-C++20 versions, it is of course an
36213extension.
36214
36215No new source file suffixes are required or supported. If you wish to
36216use a non-standard suffix (@pxref{Overall Options}), you also need
36217to provide a @option{-x c++} option too.@footnote{Some users like to
36218distinguish module interface files with a new suffix, such as naming
36219the source @code{module.cppm}, which involves
36220teaching all tools about the new suffix. A different scheme, such as
36221naming @code{module-m.cpp} would be less invasive.}
36222
36223Compiling a module interface unit produces an additional output (to
36224the assembly or object file), called a Compiled Module Interface
36225(CMI). This encodes the exported declarations of the module.
36226Importing a module reads in the CMI. The import graph is a Directed
36227Acyclic Graph (DAG). You must build imports before the importer.
36228
36229Header files may themselves be compiled to header units, which are a
36230transitional ability aiming at faster compilation. The
36231@option{-fmodule-header} option is used to enable this, and implies
36232the @option{-fmodules-ts} option. These CMIs are named by the fully
36233resolved underlying header file, and thus may be a complete pathname
36234containing subdirectories. If the header file is found at an absolute
36235pathname, the CMI location is still relative to a CMI root directory.
36236
36237As header files often have no suffix, you commonly have to specify a
36238@option{-x} option to tell the compiler the source is a header file.
36239You may use @option{-x c++-header}, @option{-x c++-user-header} or
36240@option{-x c++-system-header}. When used in conjunction with
36241@option{-fmodules-ts}, these all imply an appropriate
36242@option{-fmodule-header} option. The latter two variants use the
36243user or system include path to search for the file specified. This
36244allows you to, for instance, compile standard library header files as
36245header units, without needing to know exactly where they are
36246installed. Specifying the language as one of these variants also
36247inhibits output of the object file, as header files have no associated
36248object file.
36249
36250The @option{-fmodule-only} option disables generation of the
36251associated object file for compiling a module interface. Only the CMI
36252is generated. This option is implied when using the
36253@option{-fmodule-header} option.
36254
36255The @option{-flang-info-include-translate} and
36256@option{-flang-info-include-translate-not} options notes whether
36257include translation occurs or not. With no argument, the first will
36258note all include translation. The second will note all
36259non-translations of include files not known to intentionally be
36260textual. With an argument, queries about include translation of a
36261header files with that particular trailing pathname are noted. You
36262may repeat this form to cover several different header files. This
36263option may be helpful in determining whether include translation is
36264happening---if it is working correctly, it behaves as if it isn't
36265there at all.
36266
36267The @option{-flang-info-module-cmi} option can be used to determine
36268where the compiler is reading a CMI from. Without the option, the
36269compiler is silent when such a read is successful. This option has an
36270optional argument, which will restrict the notification to just the
36271set of named modules or header units specified.
36272
36273The @option{-Winvalid-imported-macros} option causes all imported macros
36274to be resolved at the end of compilation. Without this, imported
36275macros are only resolved when expanded or (re)defined. This option
36276detects conflicting import definitions for all macros.
36277
36278For details of the @option{-fmodule-mapper} family of options,
36279@pxref{C++ Module Mapper}.
36280
36281@menu
36282* C++ Module Mapper:: Module Mapper
36283* C++ Module Preprocessing:: Module Preprocessing
36284* C++ Compiled Module Interface:: Compiled Module Interface
36285@end menu
36286
36287@node C++ Module Mapper
36288@subsection Module Mapper
36289@cindex C++ Module Mapper
36290
36291A module mapper provides a server or file that the compiler queries to
36292determine the mapping between module names and CMI files. It is also
36293used to build CMIs on demand. @emph{Mapper functionality is in its
36294infancy and is intended for experimentation with build system
36295interactions.}
36296
36297You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
36298option or @env{CXX_MODULE_MAPPER} environment variable. The value may
36299have one of the following forms:
36300
36301@table @gcctabopt
36302
36303@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
36304An optional hostname and a numeric port number to connect to. If the
36305hostname is omitted, the loopback address is used. If the hostname
36306corresponds to multiple IPV6 addresses, these are tried in turn, until
36307one is successful. If your host lacks IPv6, this form is
36308non-functional. If you must use IPv4 use
36309@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
36310
36311@item =@var{socket}@r{[}?@var{ident}@r{]}
36312A local domain socket. If your host lacks local domain sockets, this
36313form is non-functional.
36314
36315@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
36316A program to spawn, and communicate with on its stdin/stdout streams.
36317Your @var{PATH} environment variable is searched for the program.
36318Arguments are separated by space characters, (it is not possible for
36319one of the arguments delivered to the program to contain a space). An
36320exception is if @var{program} begins with @@. In that case
36321@var{program} (sans @@) is looked for in the compiler's internal
36322binary directory. Thus the sample mapper-server can be specified
36323with @code{@@g++-mapper-server}.
36324
36325@item <>@r{[}?@var{ident}@r{]}
36326@item <>@var{inout}@r{[}?@var{ident}@r{]}
36327@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
36328Named pipes or file descriptors to communicate over. The first form,
36329@option{<>}, communicates over stdin and stdout. The other forms
36330allow you to specify a file descriptor or name a pipe. A numeric value
36331is interpreted as a file descriptor, otherwise named pipe is opened.
36332The second form specifies a bidirectional pipe and the last form
36333allows specifying two independent pipes. Using file descriptors
36334directly in this manner is fragile in general, as it can require the
36335cooperation of intermediate processes. In particular using stdin &
36336stdout is fraught with danger as other compiler options might also
36337cause the compiler to read stdin or write stdout, and it can have
36338unfortunate interactions with signal delivery from the terminal.
36339
36340@item @var{file}@r{[}?@var{ident}@r{]}
36341A mapping file consisting of space-separated module-name, filename
36342pairs, one per line. Only the mappings for the direct imports and any
36343module export name need be provided. If other mappings are provided,
36344they override those stored in any imported CMI files. A repository
36345root may be specified in the mapping file by using @samp{$root} as the
36346module name in the first active line. Use of this option will disable
36347any default module->CMI name mapping.
36348
36349@end table
36350
36351As shown, an optional @var{ident} may suffix the first word of the
36352option, indicated by a @samp{?} prefix. The value is used in the
36353initial handshake with the module server, or to specify a prefix on
36354mapping file lines. In the server case, the main source file name is
36355used if no @var{ident} is specified. In the file case, all non-blank
36356lines are significant, unless a value is specified, in which case only
36357lines beginning with @var{ident} are significant. The @var{ident}
36358must be separated by whitespace from the module name. Be aware that
36359@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
36360significant to the shell, and therefore may need quoting.
36361
36362The mapper is connected to or loaded lazily, when the first module
36363mapping is required. The networking protocols are only supported on
36364hosts that provide networking. If no mapper is specified a default is
36365provided.
36366
36367A project-specific mapper is expected to be provided by the build
36368system that invokes the compiler. It is not expected that a
36369general-purpose server is provided for all compilations. As such, the
36370server will know the build configuration, the compiler it invoked, and
36371the environment (such as working directory) in which that is
36372operating. As it may parallelize builds, several compilations may
36373connect to the same socket.
36374
36375The default mapper generates CMI files in a @samp{gcm.cache}
36376directory. CMI files have a @samp{.gcm} suffix. The module unit name
36377is used directly to provide the basename. Header units construct a
36378relative path using the underlying header file name. If the path is
36379already relative, a @samp{,} directory is prepended. Internal
36380@samp{..} components are translated to @samp{,,}. No attempt is made
36381to canonicalize these filenames beyond that done by the preprocessor's
36382include search algorithm, as in general it is ambiguous when symbolic
36383links are present.
36384
36385The mapper protocol was published as ``A Module Mapper''
36386@uref{https://wg21.link/p1184}. The implementation is provided by
36387@command{libcody}, @uref{https://github.com/urnathan/libcody},
36388which specifies the canonical protocol definition. A proof of concept
36389server implementation embedded in @command{make} was described in
36390''Make Me A Module'', @uref{https://wg21.link/p1602}.
36391
36392@node C++ Module Preprocessing
36393@subsection Module Preprocessing
36394@cindex C++ Module Preprocessing
36395
36396Modules affect preprocessing because of header units and include
36397translation. Some uses of the preprocessor as a separate step either
36398do not produce a correct output, or require CMIs to be available.
36399
36400Header units import macros. These macros can affect later conditional
36401inclusion, which therefore can cascade to differing import sets. When
36402preprocessing, it is necessary to load the CMI. If a header unit is
36403unavailable, the preprocessor issues a warning and continue (when
36404not just preprocessing, an error is emitted). Detecting such imports
36405requires preprocessor tokenization of the input stream to phase 4
36406(macro expansion).
36407
36408Include translation converts @code{#include}, @code{#include_next} and
36409@code{#import} directives to internal @code{import} declarations.
36410Whether a particular directive is translated is controlled by the
36411module mapper. Header unit names are canonicalized during
36412preprocessing.
36413
36414Dependency information can be emitted for macro import, extending the
36415functionality of @option{-MD} and @option{-MMD} options. Detection of
36416import declarations also requires phase 4 preprocessing, and thus
36417requires full preprocessing (or compilation).
36418
36419The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
36420preprocessing before phase 4.
36421
36422The @option{-save-temps} option uses @option{-fdirectives-only} for
36423preprocessing, and preserve the macro definitions in the preprocessed
36424output. Usually you also want to use this option when explicitly
36425preprocessing a header-unit, or consuming such preprocessed output:
36426
36427@smallexample
36428g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
36429g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
36430@end smallexample
36431
36432@node C++ Compiled Module Interface
36433@subsection Compiled Module Interface
36434@cindex C++ Compiled Module Interface
36435
36436CMIs are an additional artifact when compiling named module
36437interfaces, partitions or header units. These are read when
36438importing. CMI contents are implementation-specific, and in GCC's
36439case tied to the compiler version. Consider them a rebuildable cache
36440artifact, not a distributable object.
36441
36442When creating an output CMI, any missing directory components are
36443created in a manner that is safe for concurrent builds creating
36444multiple, different, CMIs within a common subdirectory tree.
36445
36446CMI contents are written to a temporary file, which is then atomically
36447renamed. Observers either see old contents (if there is an
36448existing file), or complete new contents. They do not observe the
36449CMI during its creation. This is unlike object file writing, which
36450may be observed by an external process.
36451
36452CMIs are read in lazily, if the host OS provides @code{mmap}
36453functionality. Generally blocks are read when name lookup or template
36454instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
36455option may be used.
36456
36457The @option{--param lazy-modules=@var{n}} parameter controls the limit
36458on the number of concurrently open module files during lazy loading.
36459Should more modules be imported, an LRU algorithm is used to determine
36460which files to close---until that file is needed again. This limit
36461may be exceeded with deep module dependency hierarchies. With large
36462code bases there may be more imports than the process limit of file
36463descriptors. By default, the limit is a few less than the per-process
36464file descriptor hard limit, if that is determinable.@footnote{Where
36465applicable the soft limit is incremented as needed towards the hard limit.}
36466
36467GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
36468You may use @command{readelf} to inspect them, although section
36469contents are largely undecipherable. There is a section named
36470@code{.gnu.c++.README}, which contains human-readable text. Other
36471than the first line, each line consists of @code{@var{tag}: @code{value}}
36472tuples.
36473
36474@smallexample
36475> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
36476
36477String dump of section '.gnu.c++.README':
36478 [ 0] GNU C++ primary module interface
36479 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
36480 [ 6f] version: 2020/11/16-04:54
36481 [ 89] module: foo
36482 [ 95] source: c_b.ii
36483 [ a4] dialect: C++20/coroutines
36484 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
36485 [ ee] repository: gcm.cache
36486 [ 104] buildtime: 2020/11/16 15:03:21 UTC
36487 [ 127] localtime: 2020/11/16 07:03:21 PST
36488 [ 14a] export: foo:part1 foo-part1.gcm
36489@end smallexample
36490
36491Amongst other things, this lists the source that was built, C++
36492dialect used and imports of the module.@footnote{The precise contents
36493of this output may change.} The timestamp is the same value as that
36494provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
36495explicitly specified with the environment variable
36496@code{SOURCE_DATE_EPOCH}. For further details
36497@pxref{Environment Variables}.
36498
36499A set of related CMIs may be copied, provided the relative pathnames
36500are preserved.
36501
36502The @code{.gnu.c++.README} contents do not affect CMI integrity, and
36503it may be removed or altered. The section numbering of the sections
36504whose names do not begin with @code{.gnu.c++.}, or are not the string
36505section is significant and must not be altered.